// Internal headers are allowed here
-#include <dali/internal/imaging/common/pixel-manipulation.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/internal/imaging/common/pixel-manipulation.h>
using namespace Dali;
using namespace Dali::Internal::Adaptor;
namespace
{
-
// resolution: 96*96, pixel format: LA88
const char* TEST_IMAGE_LA88 = TEST_IMAGE_DIR "/circle1-LA88.png";
Devel::PixelBuffer pixelBuffer = Dali::LoadImageFromFile(TEST_IMAGE_LA88);
DALI_TEST_CHECK(pixelBuffer);
- unsigned int width = pixelBuffer.GetWidth();
+ unsigned int width = pixelBuffer.GetWidth();
unsigned int height = pixelBuffer.GetHeight();
DALI_TEST_EQUALS(width, 96u, TEST_LOCATION);
DALI_TEST_EQUALS(height, 96u, TEST_LOCATION);
DALI_TEST_EQUALS(pixelBuffer.GetPixelFormat(), Pixel::LA88, TEST_LOCATION);
unsigned char* pixel = pixelBuffer.GetBuffer();
- unsigned int value;
+ unsigned int value;
value = Dali::Internal::Adaptor::ReadChannel(&pixel[0], Dali::Pixel::LA88, Dali::Internal::Adaptor::LUMINANCE);
DALI_TEST_EQUALS(value, 0x0, TEST_LOCATION);
// Get center pixel
unsigned int stride = width * Pixel::GetBytesPerPixel(Dali::Pixel::LA88);
unsigned int center = height / 2 * stride + width / 2 * Pixel::GetBytesPerPixel(Dali::Pixel::LA88);
- value = Dali::Internal::Adaptor::ReadChannel(&pixel[center], Dali::Pixel::LA88, Dali::Internal::Adaptor::LUMINANCE);
+ value = Dali::Internal::Adaptor::ReadChannel(&pixel[center], Dali::Pixel::LA88, Dali::Internal::Adaptor::LUMINANCE);
DALI_TEST_EQUALS(value, 0x0, TEST_LOCATION);
value = Dali::Internal::Adaptor::ReadChannel(&pixel[center], Dali::Pixel::LA88, Dali::Internal::Adaptor::ALPHA);
DALI_TEST_EQUALS(value, 0xFF, TEST_LOCATION);
/*
- * 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.
*
*/
+#include <adaptor-test-application.h>
+#include <dali-test-suite-utils.h>
#include <dali/dali.h>
#include <dali/devel-api/adaptor-framework/gl-window.h>
#include <dali/internal/system/linux/dali-ecore-x.h>
-#include <dali-test-suite-utils.h>
-#include <adaptor-test-application.h>
-
using namespace Dali;
int UtcDaliGlWindowConstructorP(void)
{
Dali::GlWindow window;
- DALI_TEST_CHECK( !window );
+ DALI_TEST_CHECK(!window);
END_TEST;
}
int UtcDaliGlWindowCopyConstructorP(void)
{
Dali::GlWindow window;
- Dali::GlWindow copy( window );
- DALI_TEST_CHECK( copy == window );
+ Dali::GlWindow copy(window);
+ DALI_TEST_CHECK(copy == window);
END_TEST;
}
int UtcDaliGlWindowConstructorFromInternalPointerN(void)
{
Internal::Adaptor::GlWindow* internalWindow = NULL;
- Dali::GlWindow window(internalWindow);
- DALI_TEST_CHECK( !window );
+ Dali::GlWindow window(internalWindow);
+ DALI_TEST_CHECK(!window);
END_TEST;
}
int UtcDaliGlWindowAssignmentOperatorP(void)
{
const Dali::GlWindow window;
- Dali::GlWindow copy;
- DALI_TEST_CHECK( ! copy );
+ Dali::GlWindow copy;
+ DALI_TEST_CHECK(!copy);
copy = window;
- DALI_TEST_CHECK( copy == window );
+ DALI_TEST_CHECK(copy == window);
END_TEST;
}
Dali::GlWindow* window = new Dali::GlWindow();
delete window;
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
END_TEST;
}
{
try
{
- PositionSize windowPosition(0, 0, 10, 10);
- Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true );
- tet_result( TET_FAIL );
+ PositionSize windowPosition(0, 0, 10, 10);
+ Dali::GlWindow window = Dali::GlWindow::New(windowPosition, "test-window", "test-window-class", true);
+ tet_result(TET_FAIL);
}
- catch ( DaliException& e )
+ catch(DaliException& e)
{
- DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
+ DALI_TEST_ASSERT(e, "Failed to create X window", TEST_LOCATION);
}
END_TEST;
{
try
{
- PositionSize windowPosition(20, 10, 10, 10);
- Dali::GlWindow window = Dali::GlWindow::New( windowPosition, "test-window", "test-window-class", true );
+ PositionSize windowPosition(20, 10, 10, 10);
+ Dali::GlWindow window = Dali::GlWindow::New(windowPosition, "test-window", "test-window-class", true);
- tet_result( TET_FAIL );
+ tet_result(TET_FAIL);
}
- catch ( DaliException& e )
+ catch(DaliException& e)
{
- DALI_TEST_ASSERT( e, "Failed to create X window", TEST_LOCATION );
+ DALI_TEST_ASSERT(e, "Failed to create X window", TEST_LOCATION);
}
END_TEST;
}
Dali::GlWindow window;
try
{
- window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_2_0 );
+ window.SetEglConfig(true, true, 0, Dali::GlWindow::GlesVersion::VERSION_2_0);
- DALI_TEST_CHECK( false);
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
Dali::GlWindow window;
try
{
- window.SetEglConfig( true, true, 0, Dali::GlWindow::GlesVersion::VERSION_3_0 );
+ window.SetEglConfig(true, true, 0, Dali::GlWindow::GlesVersion::VERSION_3_0);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.Raise();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.Lower();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.Activate();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.Show();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.Hide();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- PositionSize setPositionSize( 0, 0, 100, 100);
- window.SetPositionSize( setPositionSize );
+ PositionSize setPositionSize(0, 0, 100, 100);
+ window.SetPositionSize(setPositionSize);
PositionSize getPositionSize = window.GetPositionSize();
- DALI_TEST_CHECK( setPositionSize == getPositionSize );
+ DALI_TEST_CHECK(setPositionSize == getPositionSize);
setPositionSize.x = 10;
setPositionSize.y = 20;
- window.SetPositionSize( setPositionSize );
+ window.SetPositionSize(setPositionSize);
getPositionSize = window.GetPositionSize();
- DALI_TEST_CHECK( setPositionSize == getPositionSize );
+ DALI_TEST_CHECK(setPositionSize == getPositionSize);
- setPositionSize.width = 50;
+ setPositionSize.width = 50;
setPositionSize.height = 50;
- window.SetPositionSize( setPositionSize );
+ window.SetPositionSize(setPositionSize);
getPositionSize = window.GetPositionSize();
- DALI_TEST_CHECK( setPositionSize == getPositionSize );
+ DALI_TEST_CHECK(setPositionSize == getPositionSize);
- setPositionSize.x = 0;
- setPositionSize.y = 0;
- setPositionSize.width = 100;
+ setPositionSize.x = 0;
+ setPositionSize.y = 0;
+ setPositionSize.width = 100;
setPositionSize.height = 100;
- window.SetPositionSize( setPositionSize );
+ window.SetPositionSize(setPositionSize);
getPositionSize = window.GetPositionSize();
- DALI_TEST_CHECK( setPositionSize == getPositionSize );
+ DALI_TEST_CHECK(setPositionSize == getPositionSize);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.SetInputRegion( Rect< int >( 0, 0, 100, 10 ) );
+ window.SetInputRegion(Rect<int>(0, 0, 100, 10));
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
bool opaquestate = window.IsOpaqueState();
- DALI_TEST_CHECK( opaquestate == true );
+ DALI_TEST_CHECK(opaquestate == true);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- Dali::Vector< Dali::WindowOrientation> orientations;
- orientations.PushBack( Dali::WindowOrientation::PORTRAIT );
- orientations.PushBack( Dali::WindowOrientation::LANDSCAPE );
- orientations.PushBack( Dali::WindowOrientation::PORTRAIT_INVERSE );
- orientations.PushBack( Dali::WindowOrientation::LANDSCAPE_INVERSE );
- orientations.PushBack( Dali::WindowOrientation::NO_ORIENTATION_PREFERENCE );
- orientations.PushBack( Dali::WindowOrientation::PORTRAIT );
- orientations.PushBack( Dali::WindowOrientation::LANDSCAPE );
- orientations.PushBack( Dali::WindowOrientation::PORTRAIT_INVERSE );
+ Dali::Vector<Dali::WindowOrientation> orientations;
+ orientations.PushBack(Dali::WindowOrientation::PORTRAIT);
+ orientations.PushBack(Dali::WindowOrientation::LANDSCAPE);
+ orientations.PushBack(Dali::WindowOrientation::PORTRAIT_INVERSE);
+ orientations.PushBack(Dali::WindowOrientation::LANDSCAPE_INVERSE);
+ orientations.PushBack(Dali::WindowOrientation::NO_ORIENTATION_PREFERENCE);
+ orientations.PushBack(Dali::WindowOrientation::PORTRAIT);
+ orientations.PushBack(Dali::WindowOrientation::LANDSCAPE);
+ orientations.PushBack(Dali::WindowOrientation::PORTRAIT_INVERSE);
window.SetAvailableOrientations(orientations);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.SetPreferredOrientation(Dali::WindowOrientation::PORTRAIT);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.SetPreferredOrientation(Dali::WindowOrientation::NO_ORIENTATION_PREFERENCE);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
Dali::WindowOrientation orientation = window.GetCurrentOrientation();
- DALI_TEST_CHECK( orientation == Dali::WindowOrientation::PORTRAIT );
+ DALI_TEST_CHECK(orientation == Dali::WindowOrientation::PORTRAIT);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.RegisterGlCallback( Dali::MakeCallback( glInit ), Dali::MakeCallback( glRenderFrame ), Dali::MakeCallback( glTerminate ) );
+ window.RegisterGlCallback(Dali::MakeCallback(glInit), Dali::MakeCallback(glRenderFrame), Dali::MakeCallback(glTerminate));
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.RegisterGlCallback( Dali::MakeCallback( glInit ), Dali::MakeCallback( glRenderFrame ), Dali::MakeCallback( glTerminate ) );
+ window.RegisterGlCallback(Dali::MakeCallback(glInit), Dali::MakeCallback(glRenderFrame), Dali::MakeCallback(glTerminate));
window.RenderOnce();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.GetSupportedAuxiliaryHintCount();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.GetSupportedAuxiliaryHint( 0 );
+ window.GetSupportedAuxiliaryHint(0);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.AddAuxiliaryHint( "stack_pop_to", "1" );
+ window.AddAuxiliaryHint("stack_pop_to", "1");
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.RemoveAuxiliaryHint( 0 );
+ window.RemoveAuxiliaryHint(0);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.SetAuxiliaryHintValue( 0, "0" );
+ window.SetAuxiliaryHintValue(0, "0");
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.GetAuxiliaryHintValue( 0 );
+ window.GetAuxiliaryHintValue(0);
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
try
{
- window.GetAuxiliaryHintId( "0" );
+ window.GetAuxiliaryHintId("0");
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.FocusChangeSignal();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.ResizeSignal();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.KeyEventSignal();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.TouchedSignal();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
{
window.VisibilityChangedSignal();
- DALI_TEST_CHECK( false );
+ DALI_TEST_CHECK(false);
}
- catch( ... )
+ catch(...)
{
- DALI_TEST_CHECK( true );
+ DALI_TEST_CHECK(true);
}
END_TEST;
}
/*
- * 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.
namespace
{
-void GetCharacterScriptCheckRange(Character start, Character end, Script expectedScript, const char * location)
+void GetCharacterScriptCheckRange(Character start, Character end, Script expectedScript, const char* location)
{
- for( auto character = start; character <= end; ++character )
+ for(auto character = start; character <= end; ++character)
{
if(!IsCommonScript(character)) // Some characters are part of the common script and can be in the range
{
GetCharacterScriptCheckRange(0xA788, 0xA78A, NON_LATIN_LED, TEST_LOCATION);
GetCharacterScriptCheckRange(0xA78B, 0xa7ff, LATIN, TEST_LOCATION);
-
GetCharacterScriptCheckRange(0xa960, 0xa97f, HANGUL, TEST_LOCATION);
GetCharacterScriptCheckRange(0xa980, 0xa9fd, JAVANESE, TEST_LOCATION);
GetCharacterScriptCheckRange(0xab00, 0xab2f, GEEZ, TEST_LOCATION);
END_TEST;
}
-
/*
- * 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.
*/
// EXTERNAL INCLUDES
-#include <iostream>
-#include <dali/public-api/dali-core.h>
#include <dali/devel-api/adaptor-framework/orientation.h>
+#include <dali/public-api/dali-core.h>
+#include <iostream>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/timer.h>
-#include <dali/public-api/adaptor-framework/application.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/public-api/adaptor-framework/application.h>
+#include <dali/public-api/adaptor-framework/timer.h>
using namespace Dali;
class LinkerApp : public ConnectionTracker
{
public:
- LinkerApp(Application &app)
+ LinkerApp(Application& app)
{
app.InitSignal().Connect(this, &LinkerApp::Create);
}
public:
-
void Create(Application& app)
{
}
/*****************************************************************************/
-int
-main(int argc, char **argv)
+int main(int argc, char** argv)
{
try
{
Application app = Application::New(&argc, &argv);
- LinkerApp linkerApp (app);
+ LinkerApp linkerApp(app);
app.MainLoop();
}
catch(...)
#include <dali/public-api/object/type-registry-helper.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/public-api/dali-adaptor-common.h>
using namespace Dali::Accessibility;
using namespace Dali;
std::string Accessible::GetRoleName()
{
- switch( GetRole() )
+ switch(GetRole())
{
case Role::INVALID:
{
void Accessible::SetCurrentlyHighlightedActor(Dali::Actor actor)
{
- if (IsUp())
+ if(IsUp())
{
Bridge::GetCurrentBridge()->data->currentlyHighlightedActor = actor;
}
void Accessible::SetHighlightActor(Dali::Actor actor)
{
- if (IsUp())
+ if(IsUp())
{
Bridge::GetCurrentBridge()->data->highlightActor = actor;
}
void Bridge::ForceDown()
{
auto highlighted = Accessible::GetCurrentlyHighlightedActor();
- if( highlighted )
+ if(highlighted)
{
- auto p = dynamic_cast< Component* >( Accessible::Get( highlighted ) );
- if( p )
+ auto p = dynamic_cast<Component*>(Accessible::Get(highlighted));
+ if(p)
{
p->ClearHighlight();
}
data = {};
}
-void Bridge::SetIsOnRootLevel( Accessible* o )
+void Bridge::SetIsOnRootLevel(Accessible* o)
{
o->isOnRootLevel = true;
}
{
public:
Dali::Actor actor;
- bool root = false;
+ bool root = false;
- NonControlAccessible( Dali::Actor actor, bool root ) : actor( actor ), root( root )
+ NonControlAccessible(Dali::Actor actor, bool root)
+ : actor(actor),
+ root(root)
{
}
- Dali::Rect<> GetExtents( Dali::Accessibility::CoordType ctype ) override
+ Dali::Rect<> GetExtents(Dali::Accessibility::CoordType ctype) override
{
- Vector2 screenPosition = actor.GetProperty( Actor::Property::SCREEN_POSITION ).Get< Vector2 >();
- Vector3 size = actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) * actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_SCALE );
- bool positionUsesAnchorPoint = actor.GetProperty( Actor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >();
- Vector3 anchorPointOffSet = size * ( positionUsesAnchorPoint ? actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) : AnchorPoint::TOP_LEFT );
- Vector2 position = Vector2( screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y );
+ Vector2 screenPosition = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
+ Vector3 size = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
+ bool positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>();
+ Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+ Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
- return { position.x, position.y, size.x, size.y };
+ return {position.x, position.y, size.x, size.y};
}
Dali::Accessibility::ComponentLayer GetLayer() override
{
}
std::string GetName() override
{
- return actor.GetProperty< std::string >( Dali::Actor::Property::NAME );
+ return actor.GetProperty<std::string>(Dali::Actor::Property::NAME);
}
std::string GetDescription() override
{
}
Accessible* GetParent() override
{
- if( GetIsOnRootLevel() )
+ if(GetIsOnRootLevel())
{
auto b = GetBridgeData();
return b->bridge->GetApplication();
}
- return Get( actor.GetParent() );
+ return Get(actor.GetParent());
}
size_t GetChildCount() override
{
- return static_cast< size_t >( actor.GetChildCount() );
+ return static_cast<size_t>(actor.GetChildCount());
}
- Accessible* GetChildAtIndex( size_t index ) override
+ Accessible* GetChildAtIndex(size_t index) override
{
- auto s = static_cast< size_t >( actor.GetChildCount() );
- if( index >= s )
+ auto s = static_cast<size_t>(actor.GetChildCount());
+ if(index >= s)
{
- throw std::domain_error{"invalid index " + std::to_string( index ) + " for object with " + std::to_string( s ) + " children"};
+ throw std::domain_error{"invalid index " + std::to_string(index) + " for object with " + std::to_string(s) + " children"};
}
- return Get( actor.GetChildAt( static_cast< unsigned int >( index ) ) );
+ return Get(actor.GetChildAt(static_cast<unsigned int>(index)));
}
size_t GetIndexInParent() override
{
auto parent = actor.GetParent();
- if( !parent )
+ if(!parent)
{
return 0;
}
- auto size = static_cast< size_t >( parent.GetChildCount() );
- for( auto i = 0u; i < size; ++i )
+ auto size = static_cast<size_t>(parent.GetChildCount());
+ for(auto i = 0u; i < size; ++i)
{
- if( parent.GetChildAt( i ) == actor )
+ if(parent.GetChildAt(i) == actor)
{
return i;
}
States GetStates() override
{
States s;
- if( root )
+ if(root)
{
- s[State::ENABLED] = true;
+ s[State::ENABLED] = true;
s[State::SENSITIVE] = true;
- s[State::SHOWING] = true;
- s[State::VISIBLE] = true;
- s[State::ACTIVE] = true;
+ s[State::SHOWING] = true;
+ s[State::VISIBLE] = true;
+ s[State::ACTIVE] = true;
}
else
{
- auto t = GetParent()->GetStates();
+ auto t = GetParent()->GetStates();
s[State::SHOWING] = t[State::SHOWING];
s[State::VISIBLE] = t[State::VISIBLE];
}
Attributes GetAttributes() override
{
Dali::TypeInfo type;
- actor.GetTypeInfo( type );
- return { {"t", type.GetName()}, };
+ actor.GetTypeInfo(type);
+ return {
+ {"t", type.GetName()},
+ };
}
- bool DoGesture(const GestureInfo &gestureInfo) override
+ bool DoGesture(const GestureInfo& gestureInfo) override
{
return false;
}
}
};
-using NonControlAccessiblesType = std::unordered_map< const Dali::RefObject*, std::unique_ptr< NonControlAccessible > >;
+using NonControlAccessiblesType = std::unordered_map<const Dali::RefObject*, std::unique_ptr<NonControlAccessible> >;
NonControlAccessiblesType nonControlAccessibles;
-std::function< Accessible*( Dali::Actor ) > convertingFunctor = []( Dali::Actor ) -> Accessible*
-{
+std::function<Accessible*(Dali::Actor)> convertingFunctor = [](Dali::Actor) -> Accessible* {
return nullptr;
};
objectRegistry = registry;
}
-void Accessible::RegisterControlAccessibilityGetter( std::function< Accessible*( Dali::Actor ) > functor )
+void Accessible::RegisterControlAccessibilityGetter(std::function<Accessible*(Dali::Actor)> functor)
{
convertingFunctor = functor;
}
-Accessible* Accessible::Get( Dali::Actor actor, bool root )
+Accessible* Accessible::Get(Dali::Actor actor, bool root)
{
- if( !actor )
+ if(!actor)
{
return nullptr;
}
- auto accessible = convertingFunctor( actor );
- if( !accessible )
+ auto accessible = convertingFunctor(actor);
+ if(!accessible)
{
- if( nonControlAccessibles.empty() && objectRegistry )
+ if(nonControlAccessibles.empty() && objectRegistry)
{
- objectRegistry.ObjectDestroyedSignal().Connect( []( const Dali::RefObject* obj )
- {
- nonControlAccessibles.erase( obj );
- }
- );
+ objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) {
+ nonControlAccessibles.erase(obj);
+ });
}
- auto it = nonControlAccessibles.emplace( &actor.GetBaseObject(), nullptr );
- if( it.second )
+ auto it = nonControlAccessibles.emplace(&actor.GetBaseObject(), nullptr);
+ if(it.second)
{
- it.first->second.reset( new NonControlAccessible( actor, root ) );
+ it.first->second.reset(new NonControlAccessible(actor, root));
}
accessible = it.first->second.get();
}
/*
- * Copyright (c) 2019 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.
*
*/
-#include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
+#include <dali/devel-api/adaptor-framework/atspi-accessibility.h>
void Dali::AtspiAccessibility::Pause()
{
- if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
{
bridge->Pause();
}
void Dali::AtspiAccessibility::Resume()
{
- if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
{
bridge->Resume();
}
}
-void Dali::AtspiAccessibility::Say( const std::string& text, bool discardable, std::function<void( std::string )> callback )
+void Dali::AtspiAccessibility::Say(const std::string& text, bool discardable, std::function<void(std::string)> callback)
{
- if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
{
bridge->Say(text, discardable, callback);
}
}
-int Dali::AtspiAccessibility::SetForcefully( bool turnOn )
+int Dali::AtspiAccessibility::SetForcefully(bool turnOn)
{
- if( turnOn )
+ if(turnOn)
{
- if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
{
bridge->Initialize();
auto ret = bridge->ForceUp();
}
else
{
- if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
{
bridge->ForceDown();
return 0;
int Dali::AtspiAccessibility::GetStatus()
{
//0(ATSPI OFF, ScreenReader OFF), 1(ATSPI ON, ScreenReader OFF), 2 (ATSPI OFF, ScreenReader ON), 3(ATSPI ON, ScreenReader ON)
- if( auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge() )
+ if(auto bridge = Dali::Accessibility::Bridge::GetCurrentBridge())
{
- if( bridge->GetScreenReaderEnabled() )
+ if(bridge->GetScreenReaderEnabled())
{
- if( bridge->GetIsEnabled() )
+ if(bridge->GetIsEnabled())
{
return 3;
}
}
else
{
- if( bridge->GetIsEnabled() )
+ if(bridge->GetIsEnabled())
{
return 1;
}
/*
- * 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.
namespace Dali
{
-
GlWindow GlWindow::New()
{
- PositionSize positionSize( 0, 0, 0, 0 );
- return Dali::GlWindow::New( positionSize, "", "", false );
+ PositionSize positionSize(0, 0, 0, 0);
+ return Dali::GlWindow::New(positionSize, "", "", false);
}
-GlWindow GlWindow::New(PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent )
+GlWindow GlWindow::New(PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent)
{
- GlWindow newWindow;
- Internal::Adaptor::GlWindow* window = Internal::Adaptor::GlWindow::New( positionSize, name, className, isTransparent );
- newWindow = GlWindow(window);
+ GlWindow newWindow;
+ Internal::Adaptor::GlWindow* window = Internal::Adaptor::GlWindow::New(positionSize, name, className, isTransparent);
+ newWindow = GlWindow(window);
const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
- if( isAdaptorAvailable )
+ if(isAdaptorAvailable)
{
- Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
+ Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
Dali::WindowContainer windows = adaptor.GetWindows();
- if( !windows.empty() )
+ if(!windows.empty())
{
- window->SetChild( windows[0] );
+ window->SetChild(windows[0]);
}
}
return newWindow;
GlWindow& GlWindow::operator=(GlWindow&& rhs) = default;
-void GlWindow::SetEglConfig( bool depth, bool stencil, int msaa, GlesVersion version )
+void GlWindow::SetEglConfig(bool depth, bool stencil, int msaa, GlesVersion version)
{
- GetImplementation(*this).SetEglConfig( depth, stencil, msaa, version );
+ GetImplementation(*this).SetEglConfig(depth, stencil, msaa, version);
}
void GlWindow::Raise()
return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
}
-std::string GlWindow::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string GlWindow::GetSupportedAuxiliaryHint(unsigned int index) const
{
- return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
+ return GetImplementation(*this).GetSupportedAuxiliaryHint(index);
}
-unsigned int GlWindow::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int GlWindow::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
- return GetImplementation(*this).AddAuxiliaryHint( hint, value );
+ return GetImplementation(*this).AddAuxiliaryHint(hint, value);
}
-bool GlWindow::RemoveAuxiliaryHint( unsigned int id )
+bool GlWindow::RemoveAuxiliaryHint(unsigned int id)
{
- return GetImplementation(*this).RemoveAuxiliaryHint( id );
+ return GetImplementation(*this).RemoveAuxiliaryHint(id);
}
-bool GlWindow::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool GlWindow::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
- return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
+ return GetImplementation(*this).SetAuxiliaryHintValue(id, value);
}
-std::string GlWindow::GetAuxiliaryHintValue( unsigned int id ) const
+std::string GlWindow::GetAuxiliaryHintValue(unsigned int id) const
{
- return GetImplementation(*this).GetAuxiliaryHintValue( id );
+ return GetImplementation(*this).GetAuxiliaryHintValue(id);
}
-unsigned int GlWindow::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int GlWindow::GetAuxiliaryHintId(const std::string& hint) const
{
- return GetImplementation(*this).GetAuxiliaryHintId( hint );
+ return GetImplementation(*this).GetAuxiliaryHintId(hint);
}
-void GlWindow::SetInputRegion( const Rect< int >& inputRegion )
+void GlWindow::SetInputRegion(const Rect<int>& inputRegion)
{
- GetImplementation(*this).SetInputRegion( inputRegion );
+ GetImplementation(*this).SetInputRegion(inputRegion);
}
-void GlWindow::SetOpaqueState( bool opaque )
+void GlWindow::SetOpaqueState(bool opaque)
{
- GetImplementation(*this).SetOpaqueState( opaque );
+ GetImplementation(*this).SetOpaqueState(opaque);
}
bool GlWindow::IsOpaqueState() const
return GetImplementation(*this).IsOpaqueState();
}
-void GlWindow::SetPositionSize( PositionSize positionSize )
+void GlWindow::SetPositionSize(PositionSize positionSize)
{
- GetImplementation(*this).SetPositionSize( positionSize );
+ GetImplementation(*this).SetPositionSize(positionSize);
}
PositionSize GlWindow::GetPositionSize() const
WindowOrientation GlWindow::GetCurrentOrientation() const
{
- return GetImplementation( *this ).GetCurrentOrientation();
+ return GetImplementation(*this).GetCurrentOrientation();
}
-void GlWindow::SetAvailableOrientations( const Dali::Vector< WindowOrientation >& orientations )
+void GlWindow::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
{
- GetImplementation( *this ).SetAvailableOrientations( orientations );
+ GetImplementation(*this).SetAvailableOrientations(orientations);
}
-void GlWindow::SetPreferredOrientation( WindowOrientation orientation )
+void GlWindow::SetPreferredOrientation(WindowOrientation orientation)
{
- GetImplementation(*this).SetPreferredOrientation( orientation );
+ GetImplementation(*this).SetPreferredOrientation(orientation);
}
-void GlWindow::RegisterGlCallback( CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback )
+void GlWindow::RegisterGlCallback(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback)
{
- GetImplementation(*this).RegisterGlCallback( initCallback, renderFrameCallback, terminateCallback );
+ GetImplementation(*this).RegisterGlCallback(initCallback, renderFrameCallback, terminateCallback);
}
void GlWindow::RenderOnce()
GetImplementation(*this).RenderOnce();
}
-void GlWindow::SetRenderingMode( RenderingMode mode )
+void GlWindow::SetRenderingMode(RenderingMode mode)
{
- GetImplementation(*this).SetRenderingMode( mode );
+ GetImplementation(*this).SetRenderingMode(mode);
}
GlWindow::RenderingMode GlWindow::GetRenderingMode() const
return GetImplementation(*this).VisibilityChangedSignal();
}
-GlWindow::GlWindow( Internal::Adaptor::GlWindow* window )
-: BaseHandle( window )
+GlWindow::GlWindow(Internal::Adaptor::GlWindow* window)
+: BaseHandle(window)
{
}
-}// Dali
+} // namespace Dali
/*
- * 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.
namespace Dali
{
-
VectorImageRenderer VectorImageRenderer::New()
{
Internal::Adaptor::VectorImageRendererPtr imageRenderer = Internal::Adaptor::VectorImageRenderer::New();
- return VectorImageRenderer( imageRenderer.Get() );
+ return VectorImageRenderer(imageRenderer.Get());
}
VectorImageRenderer::VectorImageRenderer()
{
}
-VectorImageRenderer::VectorImageRenderer( Internal::Adaptor::VectorImageRenderer* internal )
-: BaseHandle( internal )
+VectorImageRenderer::VectorImageRenderer(Internal::Adaptor::VectorImageRenderer* internal)
+: BaseHandle(internal)
{
}
return GetImplementation(*this).Rasterize(buffer, scale);
}
-void VectorImageRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+void VectorImageRenderer::GetDefaultSize(uint32_t& width, uint32_t& height) const
{
- GetImplementation( *this ).GetDefaultSize( width, height );
+ GetImplementation(*this).GetDefaultSize(width, height);
}
} // namespace Dali
/*
- * 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.
GetImplementation(*this).Create(width, height, locale, timezoneId);
}
-void WebEngine::Create( int width, int height, int argc, char** argv )
+void WebEngine::Create(int width, int height, int argc, char** argv)
{
- GetImplementation( *this ).Create( width, height, argc, argv );
+ GetImplementation(*this).Create(width, height, argc, argv);
}
void WebEngine::Destroy()
Dali::WebEngineSettings& WebEngine::GetSettings() const
{
- return GetImplementation( *this ).GetSettings();
+ return GetImplementation(*this).GetSettings();
}
Dali::WebEngineContext& WebEngine::GetContext() const
{
- return GetImplementation( *this ).GetContext();
+ return GetImplementation(*this).GetContext();
}
Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
{
- return GetImplementation( *this ).GetCookieManager();
+ return GetImplementation(*this).GetCookieManager();
}
Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
{
- return GetImplementation( *this ).GetBackForwardList();
+ return GetImplementation(*this).GetBackForwardList();
}
void WebEngine::LoadUrl(const std::string& url)
std::string WebEngine::GetTitle() const
{
- return GetImplementation( *this ).GetTitle();
+ return GetImplementation(*this).GetTitle();
}
Dali::PixelData WebEngine::GetFavicon() const
{
- return GetImplementation( *this ).GetFavicon();
+ return GetImplementation(*this).GetFavicon();
}
const std::string& WebEngine::GetUrl()
GetImplementation(*this).Resume();
}
-void WebEngine::ScrollBy( int deltaX, int deltaY )
+void WebEngine::ScrollBy(int deltaX, int deltaY)
{
- GetImplementation( *this ).ScrollBy( deltaX, deltaY );
+ GetImplementation(*this).ScrollBy(deltaX, deltaY);
}
-void WebEngine::SetScrollPosition( int x, int y )
+void WebEngine::SetScrollPosition(int x, int y)
{
- GetImplementation( *this ).SetScrollPosition( x, y );
+ GetImplementation(*this).SetScrollPosition(x, y);
}
Dali::Vector2 WebEngine::GetScrollPosition() const
{
- return GetImplementation( *this ).GetScrollPosition();
+ return GetImplementation(*this).GetScrollPosition();
}
Dali::Vector2 WebEngine::GetScrollSize() const
{
- return GetImplementation( *this ).GetScrollSize();
+ return GetImplementation(*this).GetScrollSize();
}
Dali::Vector2 WebEngine::GetContentSize() const
{
- return GetImplementation( *this ).GetContentSize();
+ return GetImplementation(*this).GetContentSize();
}
bool WebEngine::CanGoForward()
void WebEngine::ClearAllTilesResources()
{
- GetImplementation( *this ).ClearAllTilesResources();
+ GetImplementation(*this).ClearAllTilesResources();
}
void WebEngine::ClearHistory()
return GetImplementation(*this).SendKeyEvent(event);
}
-void WebEngine::SetFocus( bool focused )
+void WebEngine::SetFocus(bool focused)
{
- GetImplementation( *this ).SetFocus( focused );
+ GetImplementation(*this).SetFocus(focused);
}
-void WebEngine::UpdateDisplayArea( Dali::Rect< int > displayArea )
+void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
{
- GetImplementation( *this ).UpdateDisplayArea( displayArea );
+ GetImplementation(*this).UpdateDisplayArea(displayArea);
}
-void WebEngine::EnableVideoHole( bool enabled )
+void WebEngine::EnableVideoHole(bool enabled)
{
- GetImplementation( *this ).EnableVideoHole( enabled );
+ GetImplementation(*this).EnableVideoHole(enabled);
}
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
{
- return GetImplementation( *this ).ScrollEdgeReachedSignal();
+ return GetImplementation(*this).ScrollEdgeReachedSignal();
}
} // namespace Dali
/*
- * 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.
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/public-api/events/key-event.h>
#include <dali/public-api/events/wheel-event.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/window-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.
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace
{
-constexpr unsigned int WHITE_SPACE_THRESHOLD = 0x21; ///< All characters below 0x21 are considered white spaces.
-constexpr unsigned int CHAR_LF = 0x000A; ///< NL Line feed, new line.
-constexpr unsigned int CHAR_VT = 0x000B; ///< Vertical tab.
-constexpr unsigned int CHAR_FF = 0x000C; ///< NP Form feed, new page.
-constexpr unsigned int CHAR_CR = 0x000D; ///< Carriage return, new line.
-constexpr unsigned int CHAR_NEL = 0x0085; ///< Next line.
-constexpr unsigned int CHAR_LS = 0x2028; ///< Line separator.
-constexpr unsigned int CHAR_PS = 0x2029; ///< Paragraph separator
+constexpr unsigned int WHITE_SPACE_THRESHOLD = 0x21; ///< All characters below 0x21 are considered white spaces.
+constexpr unsigned int CHAR_LF = 0x000A; ///< NL Line feed, new line.
+constexpr unsigned int CHAR_VT = 0x000B; ///< Vertical tab.
+constexpr unsigned int CHAR_FF = 0x000C; ///< NP Form feed, new page.
+constexpr unsigned int CHAR_CR = 0x000D; ///< Carriage return, new line.
+constexpr unsigned int CHAR_NEL = 0x0085; ///< Next line.
+constexpr unsigned int CHAR_LS = 0x2028; ///< Line separator.
+constexpr unsigned int CHAR_PS = 0x2029; ///< Paragraph separator
constexpr unsigned int CHAR_ZWS = 0x200B; ///< Zero width space.
constexpr unsigned int CHAR_ZWNJ = 0x200C; ///< Zero width non joiner.
// 0x25aa
// 0x262a
-
/// character <= 0x077f
inline Script GetScriptTillArabicSupplement(Character character)
{
Script script = UNKNOWN;
- if( ( 0x0030 <= character ) && ( character <= 0x0039 ) )
+ if((0x0030 <= character) && (character <= 0x0039))
{
script = ASCII_DIGITS;
}
- else if( character <= 0x007E )
+ else if(character <= 0x007E)
{
- if( ( 0x0020 <= character ) && ( character <= 0x002F ) )
+ if((0x0020 <= character) && (character <= 0x002F))
{
script = ASCII_PS;
}
- else if( ( 0x003A <= character ) && ( character <= 0x0040 ) )
+ else if((0x003A <= character) && (character <= 0x0040))
{
script = ASCII_PS;
}
- else if( ( 0x005B <= character ) && ( character <= 0x0060 ) )
+ else if((0x005B <= character) && (character <= 0x0060))
{
script = ASCII_PS;
}
- else if( ( 0x007B <= character ) && ( character <= 0x007E ) )
+ else if((0x007B <= character) && (character <= 0x007E))
{
script = ASCII_PS;
}
script = LATIN;
}
}
- else if( ( 0x007F <= character ) && ( character <= 0x009F ) )
+ else if((0x007F <= character) && (character <= 0x009F))
{
// 0x007F is actually part of C0 Controls and Basic Latin. However, is the last and only control character of its block
// and the following characters of the next block are consecutive.
script = C1_CONTROLS;
}
- else if( ( 0x00A0 <= character ) && ( character <= 0x00BF ) )
+ else if((0x00A0 <= character) && (character <= 0x00BF))
{
- if( character == 0x00A9 )
+ if(character == 0x00A9)
{
script = EMOJI; // 5. Uncategorized: copyright sign
}
- else if( character == 0x00AE )
+ else if(character == 0x00AE)
{
script = EMOJI; // 5. Uncategorized: registered sign
}
script = C1_PS;
}
}
- else if( character == 0x00D7 )
+ else if(character == 0x00D7)
{
script = C1_MATH;
}
- else if( character == 0x00F7 )
+ else if(character == 0x00F7)
{
script = C1_MATH;
}
- else if( ( 0x00C0 <= character ) && ( character <= 0x02ff ) )
+ else if((0x00C0 <= character) && (character <= 0x02ff))
{
- if( ( 0x02B9 <= character ) && ( character <= 0x02BF ) )
+ if((0x02B9 <= character) && (character <= 0x02BF))
{
script = SML_P;
}
script = LATIN;
}
}
- else if( ( 0x0370 <= character ) && ( character <= 0x03ff ) )
+ else if((0x0370 <= character) && (character <= 0x03ff))
{
script = GREEK;
}
- else if( ( 0x0400 <= character ) && ( character <= 0x04ff ) )
+ else if((0x0400 <= character) && (character <= 0x04ff))
{
script = CYRILLIC;
}
- else if( ( 0x0500 <= character ) && ( character <= 0x052f ) )
+ else if((0x0500 <= character) && (character <= 0x052f))
{
script = CYRILLIC;
}
- else if( ( 0x0530 <= character ) && ( character <= 0x058f ) )
+ else if((0x0530 <= character) && (character <= 0x058f))
{
script = ARMENIAN;
}
- else if( ( 0x0591 <= character ) && ( character <= 0x05f4 ) )
+ else if((0x0591 <= character) && (character <= 0x05f4))
{
script = HEBREW;
}
- else if( ( 0x0600 <= character ) && ( character <= 0x06ff ) )
+ else if((0x0600 <= character) && (character <= 0x06ff))
{
script = ARABIC;
}
- else if( ( 0x0750 <= character ) && ( character <= 0x077f ) )
+ else if((0x0750 <= character) && (character <= 0x077f))
{
script = ARABIC;
}
{
Script script = UNKNOWN;
- if( character <= 0x077f )
+ if(character <= 0x077f)
{
script = GetScriptTillArabicSupplement(character);
}
else // > 0x077f
{
- if( ( 0x08A0 <= character ) && ( character <= 0x08ff ) )
+ if((0x08A0 <= character) && (character <= 0x08ff))
{
script = ARABIC;
}
- else if( ( 0x0900 <= character ) && ( character <= 0x097f ) )
+ else if((0x0900 <= character) && (character <= 0x097f))
{
script = DEVANAGARI;
}
- else if( ( 0x0980 <= character ) && ( character <= 0x09ff ) )
+ else if((0x0980 <= character) && (character <= 0x09ff))
{
script = BENGALI;
}
}
/// 0x09ff < character <= 0x0cff
-inline Script GetScriptBetweenBengaliAndKannada( Character character )
+inline Script GetScriptBetweenBengaliAndKannada(Character character)
{
Script script = UNKNOWN;
- if( character <= 0x0b7f )
+ if(character <= 0x0b7f)
{
- if( ( 0x0a00 <= character ) && ( character <= 0x0a7f ) )
+ if((0x0a00 <= character) && (character <= 0x0a7f))
{
script = GURMUKHI;
}
- else if( ( 0x0a80 <= character ) && ( character <= 0x0aff ) )
+ else if((0x0a80 <= character) && (character <= 0x0aff))
{
script = GUJARATI;
}
- else if( ( 0x0b00 <= character ) && ( character <= 0x0b7f ) )
+ else if((0x0b00 <= character) && (character <= 0x0b7f))
{
script = ORIYA;
}
}
else // > 0x0b7f
{
- if( ( 0x0b80 <= character ) && ( character <= 0x0bff ) )
+ if((0x0b80 <= character) && (character <= 0x0bff))
{
script = TAMIL;
}
- else if( ( 0x0c00 <= character ) && ( character <= 0x0c7f ) )
+ else if((0x0c00 <= character) && (character <= 0x0c7f))
{
script = TELUGU;
}
- else if( ( 0x0c80 <= character ) && ( character <= 0x0cff ) )
+ else if((0x0c80 <= character) && (character <= 0x0cff))
{
script = KANNADA;
}
{
Script script = UNKNOWN;
- if( ( 0x0d00 <= character ) && ( character <= 0x0d7f ) )
+ if((0x0d00 <= character) && (character <= 0x0d7f))
{
script = MALAYALAM;
}
- else if( ( 0x0d80 <= character ) && ( character <= 0x0dff ) )
+ else if((0x0d80 <= character) && (character <= 0x0dff))
{
script = SINHALA;
}
- else if( ( 0x0e00 <= character ) && ( character <= 0x0e7f ) )
+ else if((0x0e00 <= character) && (character <= 0x0e7f))
{
script = THAI;
}
- else if( ( 0x0e80 <= character ) && ( character <= 0x0eff ) )
+ else if((0x0e80 <= character) && (character <= 0x0eff))
{
script = LAO;
}
- else if( ( 0x1000 <= character ) && ( character <= 0x109f ) )
+ else if((0x1000 <= character) && (character <= 0x109f))
{
script = BURMESE;
}
- else if( ( 0x10a0 <= character ) && ( character <= 0x10ff ) )
+ else if((0x10a0 <= character) && (character <= 0x10ff))
{
script = GEORGIAN;
}
- else if( ( 0x1100 <= character ) && ( character <= 0x11ff ) )
+ else if((0x1100 <= character) && (character <= 0x11ff))
{
script = HANGUL;
}
- else if( ( 0x1200 <= character ) && ( character <= 0x137f ) )
+ else if((0x1200 <= character) && (character <= 0x137f))
{
script = GEEZ;
}
- else if( ( 0x1380 <= character ) && ( character <= 0x139f ) )
+ else if((0x1380 <= character) && (character <= 0x139f))
{
script = GEEZ;
}
- else if( ( 0x1700 <= character ) && ( character <= 0x171f ) )
+ else if((0x1700 <= character) && (character <= 0x171f))
{
script = BAYBAYIN;
}
- else if( ( 0x1780 <= character ) && ( character <= 0x17ff ) )
+ else if((0x1780 <= character) && (character <= 0x17ff))
{
script = KHMER;
}
- else if( ( 0x19e0 <= character ) && ( character <= 0x19ff ) )
+ else if((0x19e0 <= character) && (character <= 0x19ff))
{
script = KHMER;
}
- else if( ( 0x1b80 <= character ) && ( character <= 0x1bbf ) )
+ else if((0x1b80 <= character) && (character <= 0x1bbf))
{
script = SUNDANESE;
}
- else if( ( 0x1c50 <= character ) && ( character <= 0x1c7f ) )
+ else if((0x1c50 <= character) && (character <= 0x1c7f))
{
script = OL_CHIKI;
}
- else if( ( 0x1cc0 <= character ) && ( character <= 0x1ccf ) )
+ else if((0x1cc0 <= character) && (character <= 0x1ccf))
{
script = SUNDANESE;
}
- else if( ( 0x1d00 <= character ) && ( character <= 0x1eff ) )
+ else if((0x1d00 <= character) && (character <= 0x1eff))
{
- if( ( 0x1D26 <= character ) && ( character <= 0x1D2B ) )
+ if((0x1D26 <= character) && (character <= 0x1D2B))
{
script = PHONETIC_U;
}
- else if( ( 0x1D5D <= character ) && ( character <= 0x1D61 ) )
+ else if((0x1D5D <= character) && (character <= 0x1D61))
{
script = PHONETIC_SS;
}
- else if( ( 0x1D66 <= character ) && ( character <= 0x1D6A ) )
+ else if((0x1D66 <= character) && (character <= 0x1D6A))
{
script = PHONETIC_SS;
}
- else if( character == 0x1D78 )
+ else if(character == 0x1D78)
{
script = PHONETIC_SS;
}
- else if( character == 0x1DBF)
+ else if(character == 0x1DBF)
{
script = PHONETIC_SS;
}
{
Script script = UNKNOWN;
- if( ( 0x1f00 <= character ) && ( character <= 0x1fff ) )
+ if((0x1f00 <= character) && (character <= 0x1fff))
{
script = GREEK;
}
- else if( character == 0x203c )
+ else if(character == 0x203c)
{
script = EMOJI; // 5. Uncategorized: double exclamation mark
}
- else if( character == 0x2049 )
+ else if(character == 0x2049)
{
script = EMOJI; // 5. Uncategorized: exclamation question mark
}
- else if( ( 0x2070 <= character ) && ( character <= 0x209f ) )
+ else if((0x2070 <= character) && (character <= 0x209f))
{
- if( character == 0x2070 )
+ if(character == 0x2070)
{
script = NUMERIC_SS;
}
- else if( ( 0x2074 <= character ) && ( character <= 0x207E ) )
+ else if((0x2074 <= character) && (character <= 0x207E))
{
script = NUMERIC_SS;
}
script = LATIN;
}
}
- else if( character == 0x20e3 )
+ else if(character == 0x20e3)
{
script = EMOJI; // 5. Uncategorized: combining enclosing keycap
}
- else if( character == 0x2122 )
+ else if(character == 0x2122)
{
script = EMOJI; // 5. Uncategorized: trade mark sign
}
- else if( character == 0x2139 )
+ else if(character == 0x2139)
{
script = EMOJI; // 5. Uncategorized: information source
}
- else if( ( 0x2100 <= character ) && ( character <= 0x2189 ) )
+ else if((0x2100 <= character) && (character <= 0x2189))
{
- if( ( 0x2100 <= character ) && ( character <= 0x214f ) )
+ if((0x2100 <= character) && (character <= 0x214f))
{
- if( ( 0x212A <= character ) && ( character <= 0x212B ) )
+ if((0x212A <= character) && (character <= 0x212B))
{
script = LATIN;
}
- else if( character == 0x2132 )
+ else if(character == 0x2132)
{
script = LATIN;
}
- else if( character == 0x214E )
+ else if(character == 0x214E)
{
script = LATIN;
}
script = LETTER_LIKE;
}
}
- else if( ( 0x2150 <= character ) && ( character <= 0x215F ) )
+ else if((0x2150 <= character) && (character <= 0x215F))
{
script = FRACTIONS_NF;
}
- else if( character == 0x2189 )
+ else if(character == 0x2189)
{
script = FRACTIONS_NF;
}
}
}
// Symbols
- else if( ( 0x25cb == character ) ||
- ( 0x25cf == character ) ||
- ( 0x25a1 == character ) )
+ else if((0x25cb == character) ||
+ (0x25cf == character) ||
+ (0x25a1 == character))
{
script = SYMBOLS1;
}
- else if( 0x25a0 == character )
+ else if(0x25a0 == character)
{
script = SYMBOLS2;
}
- else if( ( 0x2664 == character ) ||
- ( 0x2661 == character ) ||
- ( 0x2662 == character ) ||
- ( 0x2667 == character ) )
+ else if((0x2664 == character) ||
+ (0x2661 == character) ||
+ (0x2662 == character) ||
+ (0x2667 == character))
{
script = SYMBOLS3;
}
- else if( ( 0x2606 == character ) ||
- ( 0x25aa == character ) )
+ else if((0x2606 == character) ||
+ (0x25aa == character))
{
script = SYMBOLS4;
}
- else if( 0x262a == character )
+ else if(0x262a == character)
{
script = SYMBOLS5;
}
// U+2194 5. Uncategorized: left right arrow
// U+2B55 5. Uncategorized: heavy large circle
- else if( ( 0x2194 <= character ) && ( character <= 0x2B55 ) )
+ else if((0x2194 <= character) && (character <= 0x2B55))
{
script = EMOJI;
}
- else if( ( 0x2c60 <= character ) && ( character <= 0x2c7f ) )
+ else if((0x2c60 <= character) && (character <= 0x2c7f))
{
script = LATIN;
}
{
Script script = UNKNOWN;
- if( character <= 0x1eff )
+ if(character <= 0x1eff)
{
script = GetScriptBetweenKannadaAndLatinExtendedAdditional(character);
}
{
Script script = UNKNOWN;
- if( ( 0x2d00 <= character ) && ( character <= 0x2d2f ) )
+ if((0x2d00 <= character) && (character <= 0x2d2f))
{
script = GEORGIAN;
}
- else if( ( 0x2d80 <= character ) && ( character <= 0x2ddf ) )
+ else if((0x2d80 <= character) && (character <= 0x2ddf))
{
script = GEEZ;
}
- else if( ( 0x2de0 <= character ) && ( character <= 0x2dff ) )
+ else if((0x2de0 <= character) && (character <= 0x2dff))
{
script = CYRILLIC;
}
- else if( ( 0x2e80 <= character ) && ( character <= 0x2eff ) )
+ else if((0x2e80 <= character) && (character <= 0x2eff))
{
script = CJK;
}
- else if( ( 0x2f00 <= character ) && ( character <= 0x2fdf ) )
+ else if((0x2f00 <= character) && (character <= 0x2fdf))
{
script = CJK;
}
- else if( ( 0x3000 <= character ) && ( character <= 0x303f ) )
+ else if((0x3000 <= character) && (character <= 0x303f))
{
script = CJK;
}
- else if( ( 0x3040 <= character ) && ( character <= 0x309f ) )
+ else if((0x3040 <= character) && (character <= 0x309f))
{
script = HIRAGANA;
}
- else if( ( 0x30a0 <= character ) && ( character <= 0x30ff ) )
+ else if((0x30a0 <= character) && (character <= 0x30ff))
{
script = KATAKANA;
}
- else if( ( 0x3100 <= character ) && ( character <= 0x312f ) )
+ else if((0x3100 <= character) && (character <= 0x312f))
{
script = BOPOMOFO;
}
- else if( ( 0x3130 <= character ) && ( character <= 0x318f ) )
+ else if((0x3130 <= character) && (character <= 0x318f))
{
script = HANGUL;
}
- else if( ( 0x31a0 <= character ) && ( character <= 0x31bf ) )
+ else if((0x31a0 <= character) && (character <= 0x31bf))
{
script = BOPOMOFO;
}
- else if( ( 0x3200 <= character ) && ( character <= 0x32ff ) )
+ else if((0x3200 <= character) && (character <= 0x32ff))
{
script = CJK;
}
- else if( ( 0x3400 <= character ) && ( character <= 0x4dbf ) )
+ else if((0x3400 <= character) && (character <= 0x4dbf))
{
script = CJK;
}
- else if( ( 0x4e00 <= character ) && ( character <= 0x62ff ) )
+ else if((0x4e00 <= character) && (character <= 0x62ff))
{
script = CJK;
}
- else if( ( 0x6300 <= character ) && ( character <= 0x77ff ) )
+ else if((0x6300 <= character) && (character <= 0x77ff))
{
script = CJK;
}
- else if( ( 0x7800 <= character ) && ( character <= 0x8cff ) )
+ else if((0x7800 <= character) && (character <= 0x8cff))
{
script = CJK;
}
- else if( ( 0x8d00 <= character ) && ( character <= 0x9fff ) )
+ else if((0x8d00 <= character) && (character <= 0x9fff))
{
script = CJK;
}
- else if( ( 0xa640 <= character ) && ( character <= 0xa69f ) )
+ else if((0xa640 <= character) && (character <= 0xa69f))
{
script = CYRILLIC;
}
- else if( ( 0xa720 <= character ) && ( character <= 0xa7ff ) )
+ else if((0xa720 <= character) && (character <= 0xa7ff))
{
- if( character == 0xA720 )
+ if(character == 0xA720)
{
script = PHONETIC_U;
}
- else if( character == 0xA721 )
+ else if(character == 0xA721)
{
script = PHONETIC_U;
}
- else if( character == 0xA788 )
+ else if(character == 0xA788)
{
script = NON_LATIN_LED;
}
- else if( character == 0xA789 )
+ else if(character == 0xA789)
{
script = NON_LATIN_LED;
}
- else if( character == 0xA78A )
+ else if(character == 0xA78A)
{
script = NON_LATIN_LED;
}
{
Script script = GetScriptBetweenLatinExtendedCAndLatinExtendedD(character);
- if( ( 0xa960 <= character ) && ( character <= 0xa97f ) )
+ if((0xa960 <= character) && (character <= 0xa97f))
{
script = HANGUL;
}
- else if( ( 0xa980 <= character ) && ( character <= 0xa9fd ) )
+ else if((0xa980 <= character) && (character <= 0xa9fd))
{
script = JAVANESE;
}
- else if( ( 0xab00 <= character ) && ( character <= 0xab2f ) )
+ else if((0xab00 <= character) && (character <= 0xab2f))
{
script = GEEZ;
}
- else if( ( 0xab30 <= character ) && ( character <= 0xab6f ) )
+ else if((0xab30 <= character) && (character <= 0xab6f))
{
script = LATIN;
}
- else if( ( 0xaae0 <= character ) && ( character <= 0xaaff ) )
+ else if((0xaae0 <= character) && (character <= 0xaaff))
{
script = MEITEI;
}
- else if( ( 0xabc0 <= character ) && ( character <= 0xabff ) )
+ else if((0xabc0 <= character) && (character <= 0xabff))
{
script = MEITEI;
}
- else if( ( 0xac00 <= character ) && ( character <= 0xd7af ) )
+ else if((0xac00 <= character) && (character <= 0xd7af))
{
script = HANGUL;
}
- else if( ( 0xd7b0 <= character ) && ( character <= 0xd7ff ) )
+ else if((0xd7b0 <= character) && (character <= 0xd7ff))
{
script = HANGUL;
}
- else if( ( 0xfb00 <= character ) && ( character <= 0xfb06 ) )
+ else if((0xfb00 <= character) && (character <= 0xfb06))
{
script = LATIN;
}
- else if( ( 0xfb13 <= character ) && ( character <= 0xfb17 ) )
+ else if((0xfb13 <= character) && (character <= 0xfb17))
{
script = ARMENIAN;
}
- else if( ( 0xfb1d <= character ) && ( character <= 0xfb4f ) )
+ else if((0xfb1d <= character) && (character <= 0xfb4f))
{
script = HEBREW;
}
- else if( ( 0xfb50 <= character ) && ( character <= 0xfdff ) )
+ else if((0xfb50 <= character) && (character <= 0xfdff))
{
script = ARABIC;
}
{
Script script = UNKNOWN;
- if( ( 0xfe70 <= character ) && ( character <= 0xfeff ) )
+ if((0xfe70 <= character) && (character <= 0xfeff))
{
script = ARABIC;
}
- else if( ( 0xff00 <= character ) && ( character <= 0xffef ) )
+ else if((0xff00 <= character) && (character <= 0xffef))
{
- if( ( 0xFF00 <= character ) && ( character <= 0xFF20 ) )
+ if((0xFF00 <= character) && (character <= 0xFF20))
{
script = HWFW_S;
}
- else if( ( 0xFF3B <= character ) && ( character <= 0xFF40 ) )
+ else if((0xFF3B <= character) && (character <= 0xFF40))
{
script = HWFW_S;
}
- else if( ( 0xFF5B <= character ) && ( character <= 0xFFEF ) )
+ else if((0xFF5B <= character) && (character <= 0xFFEF))
{
script = HWFW_S;
}
script = LATIN;
}
}
- else if( ( 0x1ee00 <= character ) && ( character <= 0x1eeff ) )
+ else if((0x1ee00 <= character) && (character <= 0x1eeff))
{
script = ARABIC;
}
// U+1f170 4. Enclosed characters: negative squared latin capital letter A
// U+1f6ff 6b. Additional transport and map symbols
- else if( ( 0x1f170 <= character ) && ( character <= 0x1f6ff ) )
+ else if((0x1f170 <= character) && (character <= 0x1f6ff))
{
script = EMOJI;
}
// 7. Supplemental Symbols and Pictographs
- else if( ( 0x1f900 <= character ) && ( character <= 0x1f9ff ) )
+ else if((0x1f900 <= character) && (character <= 0x1f9ff))
{
script = EMOJI;
}
- else if( ( 0x20000 <= character ) && ( character <= 0x215ff ) )
+ else if((0x20000 <= character) && (character <= 0x215ff))
{
script = CJK;
}
- else if( ( 0x21600 <= character ) && ( character <= 0x230ff ) )
+ else if((0x21600 <= character) && (character <= 0x230ff))
{
script = CJK;
}
- else if( ( 0x23100 <= character ) && ( character <= 0x245ff ) )
+ else if((0x23100 <= character) && (character <= 0x245ff))
{
script = CJK;
}
- else if( ( 0x24600 <= character ) && ( character <= 0x260ff ) )
+ else if((0x24600 <= character) && (character <= 0x260ff))
{
script = CJK;
}
- else if( ( 0x26100 <= character ) && ( character <= 0x275ff ) )
+ else if((0x26100 <= character) && (character <= 0x275ff))
{
script = CJK;
}
- else if( ( 0x27600 <= character ) && ( character <= 0x290ff ) )
+ else if((0x27600 <= character) && (character <= 0x290ff))
{
script = CJK;
}
- else if( ( 0x29100 <= character ) && ( character <= 0x2a6df ) )
+ else if((0x29100 <= character) && (character <= 0x2a6df))
{
script = CJK;
}
- else if( ( 0x2a700 <= character ) && ( character <= 0x2b73f ) )
+ else if((0x2a700 <= character) && (character <= 0x2b73f))
{
script = CJK;
}
- else if( ( 0x2b740 <= character ) && ( character <= 0x2b81f ) )
+ else if((0x2b740 <= character) && (character <= 0x2b81f))
{
script = CJK;
}
{
Script script = UNKNOWN;
- if( character <= 0xfdff )
+ if(character <= 0xfdff)
{
script = GetScriptBetweenLatinExtendedCAndArabicPresentationFormsA(character);
}
} // namespace
-bool IsRightToLeftScript( Script script )
+bool IsRightToLeftScript(Script script)
{
- return ( ( ARABIC == script ) ||
- ( HEBREW == script ) );
+ return ((ARABIC == script) ||
+ (HEBREW == script));
}
-Script GetCharacterScript( Character character )
+Script GetCharacterScript(Character character)
{
Script script = UNKNOWN;
- if( IsCommonScript( character ) )
+ if(IsCommonScript(character))
{
script = COMMON;
}
- else if( character <= 0x0cff )
+ else if(character <= 0x0cff)
{
- if( character <= 0x09ff )
+ if(character <= 0x09ff)
{
script = GetScriptTillBengali(character);
}
}
else // > 0x0cff
{
- if( character <= 0x2c7f )
+ if(character <= 0x2c7f)
{
- script = GetScriptBetweenKannadaAndLatinExtendedC(character);
+ script = GetScriptBetweenKannadaAndLatinExtendedC(character);
}
else // > 0x2c7f
{
/*
- * 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.
// Create the scene
PositionSize surfacePositionSize = mSurface->GetPositionSize();
- int orientation = mSurface->GetOrientation();
+ int orientation = mSurface->GetOrientation();
mScene = Dali::Integration::Scene::New(Size(static_cast<float>(surfacePositionSize.width), static_cast<float>(surfacePositionSize.height)), orientation);
Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
/*
- * Copyright (c) 2019 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.
*
*/
- // CLASS HEADER
+// CLASS HEADER
- //INTERNAL INCLUDES
+//INTERNAL INCLUDES
#include <dali/internal/accessibility/bridge/accessibility-common.h>
-#include <third-party/libunibreak/wordbreak.h>
#include <third-party/libunibreak/linebreak.h>
+#include <third-party/libunibreak/wordbreak.h>
using namespace Dali::Accessibility;
-std::vector< std::string > Accessible::GetInterfaces()
-{
- std::vector< std::string > tmp;
- tmp.push_back(AtspiDbusInterfaceAccessible);
- if (dynamic_cast<Collection*>(this))
- {
- tmp.push_back(AtspiDbusInterfaceCollection);
- }
- if (dynamic_cast<Text*>(this))
- {
- tmp.push_back(AtspiDbusInterfaceText);
- }
- if (dynamic_cast<EditableText*>(this))
- {
- tmp.push_back(AtspiDbusInterfaceEditableText);
- }
- if (dynamic_cast<Value*>(this))
- {
- tmp.push_back(AtspiDbusInterfaceValue);
- }
- if (dynamic_cast<Component*>(this))
- {
- tmp.push_back(AtspiDbusInterfaceComponent);
- }
- if (auto d = dynamic_cast<Action*>(this))
- {
- if (d->GetActionCount() > 0)
- {
- tmp.push_back(AtspiDbusInterfaceAction);
- }
- }
- return tmp;
+std::vector<std::string> Accessible::GetInterfaces()
+{
+ std::vector<std::string> tmp;
+ tmp.push_back(AtspiDbusInterfaceAccessible);
+ if(dynamic_cast<Collection*>(this))
+ {
+ tmp.push_back(AtspiDbusInterfaceCollection);
+ }
+ if(dynamic_cast<Text*>(this))
+ {
+ tmp.push_back(AtspiDbusInterfaceText);
+ }
+ if(dynamic_cast<EditableText*>(this))
+ {
+ tmp.push_back(AtspiDbusInterfaceEditableText);
+ }
+ if(dynamic_cast<Value*>(this))
+ {
+ tmp.push_back(AtspiDbusInterfaceValue);
+ }
+ if(dynamic_cast<Component*>(this))
+ {
+ tmp.push_back(AtspiDbusInterfaceComponent);
+ }
+ if(auto d = dynamic_cast<Action*>(this))
+ {
+ if(d->GetActionCount() > 0)
+ {
+ tmp.push_back(AtspiDbusInterfaceAction);
+ }
+ }
+ return tmp;
}
Accessible::Accessible()
Accessible::~Accessible()
{
- auto b = bridgeData.lock();
- if (b)
- b->knownObjects.erase(this);
+ auto b = bridgeData.lock();
+ if(b)
+ b->knownObjects.erase(this);
}
void Accessible::EmitActiveDescendantChanged(Accessible* obj, Accessible* child)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->EmitActiveDescendantChanged(obj, child);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitActiveDescendantChanged(obj, child);
+ }
}
void Accessible::EmitStateChanged(State state, int newValue1, int newValue2)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->EmitStateChanged(this, state, newValue1, newValue2);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitStateChanged(this, state, newValue1, newValue2);
+ }
}
void Accessible::EmitShowing(bool showing)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->EmitStateChanged(this, State::SHOWING, showing ? 1 : 0, 0);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitStateChanged(this, State::SHOWING, showing ? 1 : 0, 0);
+ }
}
void Accessible::EmitVisible(bool visible)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->EmitStateChanged(this, State::VISIBLE, visible ? 1 : 0, 0);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitStateChanged(this, State::VISIBLE, visible ? 1 : 0, 0);
+ }
}
void Accessible::EmitHighlighted(bool set)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->EmitStateChanged(this, State::HIGHLIGHTED, set ? 1 : 0, 0);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitStateChanged(this, State::HIGHLIGHTED, set ? 1 : 0, 0);
+ }
}
void Accessible::EmitFocused(bool set)
{
- if (auto b = GetBridgeData()) {
- b->bridge->EmitStateChanged(this, State::FOCUSED, set ? 1 : 0, 0);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitStateChanged(this, State::FOCUSED, set ? 1 : 0, 0);
+ }
}
void Accessible::EmitTextInserted(unsigned int position, unsigned int length, const std::string& content)
{
- if (auto b = GetBridgeData()) {
- b->bridge->EmitTextChanged(this, TextChangedState::INSERTED, position, length, content);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitTextChanged(this, TextChangedState::INSERTED, position, length, content);
+ }
}
void Accessible::EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content)
{
- if (auto b = GetBridgeData()) {
- b->bridge->EmitTextChanged(this, TextChangedState::DELETED, position, length, content);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitTextChanged(this, TextChangedState::DELETED, position, length, content);
+ }
}
void Accessible::EmitTextCaretMoved(unsigned int cursorPosition)
{
- if (auto b = GetBridgeData()) {
- b->bridge->EmitCaretMoved(this, cursorPosition);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitCaretMoved(this, cursorPosition);
+ }
}
void Accessible::Emit(WindowEvent we, unsigned int detail1)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->Emit(this, we, detail1);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->Emit(this, we, detail1);
+ }
}
void Accessible::Emit(ObjectPropertyChangeEvent ev)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->Emit(this, ev);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->Emit(this, ev);
+ }
}
void Accessible::EmitBoundsChanged(Rect<> rect)
{
- if (auto b = GetBridgeData())
- {
- b->bridge->EmitBoundsChanged(this, rect);
- }
+ if(auto b = GetBridgeData())
+ {
+ b->bridge->EmitBoundsChanged(this, rect);
+ }
}
-std::vector< Accessible* > Accessible::GetChildren()
+std::vector<Accessible*> Accessible::GetChildren()
{
- std::vector< Accessible* > tmp(GetChildCount());
- for (auto i = 0u; i < tmp.size(); ++i)
- {
- tmp[i] = GetChildAtIndex(i);
- }
- return tmp;
+ std::vector<Accessible*> tmp(GetChildCount());
+ for(auto i = 0u; i < tmp.size(); ++i)
+ {
+ tmp[i] = GetChildAtIndex(i);
+ }
+ return tmp;
}
-std::shared_ptr< Bridge::Data > Accessible::GetBridgeData()
+std::shared_ptr<Bridge::Data> Accessible::GetBridgeData()
{
- auto b = bridgeData.lock();
- if (!b)
- {
- auto p = Bridge::GetCurrentBridge();
- b = p->data;
- }
- return b;
+ auto b = bridgeData.lock();
+ if(!b)
+ {
+ auto p = Bridge::GetCurrentBridge();
+ b = p->data;
+ }
+ return b;
}
Address Accessible::GetAddress()
{
- auto b = bridgeData.lock();
- if (!b)
- {
- b = GetBridgeData();
- if (b)
- b->bridge->RegisterOnBridge(this);
- }
- std::ostringstream tmp;
- tmp << this;
- return { b ? b->busName : "", tmp.str() };
+ auto b = bridgeData.lock();
+ if(!b)
+ {
+ b = GetBridgeData();
+ if(b)
+ b->bridge->RegisterOnBridge(this);
+ }
+ std::ostringstream tmp;
+ tmp << this;
+ return {b ? b->busName : "", tmp.str()};
}
void Bridge::RegisterOnBridge(Accessible* obj)
{
- assert(!obj->bridgeData.lock() || obj->bridgeData.lock() == data);
- if (!obj->bridgeData.lock())
- {
- assert(data);
- data->knownObjects.insert(obj);
- obj->bridgeData = data;
- }
+ assert(!obj->bridgeData.lock() || obj->bridgeData.lock() == data);
+ if(!obj->bridgeData.lock())
+ {
+ assert(data);
+ data->knownObjects.insert(obj);
+ obj->bridgeData = data;
+ }
}
bool Accessible::IsProxy()
{
- return false;
+ return false;
}
Accessible* Accessible::GetDefaultLabel()
{
- return this;
+ return this;
}
void Accessible::NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool doRecursive)
{
- if (auto b = GetBridgeData())
+ if(auto b = GetBridgeData())
+ {
+ auto s = GetStates() & states;
+ for(auto i = 0u; i < s.size(); i++)
+ {
+ auto index = static_cast<Dali::Accessibility::State>(i);
+ if(s[index])
+ b->bridge->EmitStateChanged(this, index, 1, 0);
+ }
+ if(doRecursive)
{
- auto s = GetStates() & states;
- for (auto i = 0u; i < s.size(); i++)
- {
- auto index = static_cast<Dali::Accessibility::State>(i);
- if (s[index])
- b->bridge->EmitStateChanged(this, index, 1, 0);
- }
- if (doRecursive)
- {
- auto children = GetChildren();
- for (auto c : children)
- c->NotifyAccessibilityStateChange(states, doRecursive);
- }
+ auto children = GetChildren();
+ for(auto c : children)
+ c->NotifyAccessibilityStateChange(states, doRecursive);
}
+ }
}
void Accessible::FindWordSeparationsUtf8(const utf8_t* s, size_t length, const char* language, char* breaks)
{
- set_wordbreaks_utf8(s, length, language, breaks);
+ set_wordbreaks_utf8(s, length, language, breaks);
}
void Accessible::FindLineSeparationsUtf8(const utf8_t* s, size_t length, const char* language, char* breaks)
{
- set_linebreaks_utf8(s, length, language, breaks);
+ set_linebreaks_utf8(s, length, language, breaks);
}
/*
- * Copyright (c) 2019 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 BridgeAccessible::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceAccessible};
- AddGetPropertyToInterface( desc, "ChildCount", &BridgeAccessible::GetChildCount );
- AddGetPropertyToInterface( desc, "Name", &BridgeAccessible::GetName );
- AddGetPropertyToInterface( desc, "Description", &BridgeAccessible::GetDescription );
- AddGetPropertyToInterface( desc, "Parent", &BridgeAccessible::GetParent );
- AddFunctionToInterface( desc, "GetRole", &BridgeAccessible::GetRole );
- AddFunctionToInterface( desc, "GetRoleName", &BridgeAccessible::GetRoleName );
- AddFunctionToInterface( desc, "GetLocalizedRoleName", &BridgeAccessible::GetLocalizedRoleName );
- AddFunctionToInterface( desc, "GetState", &BridgeAccessible::GetStates );
- AddFunctionToInterface( desc, "GetAttributes", &BridgeAccessible::GetAttributes );
- AddFunctionToInterface( desc, "GetInterfaces", &BridgeAccessible::GetInterfaces );
- AddFunctionToInterface( desc, "GetChildAtIndex", &BridgeAccessible::GetChildAtIndex );
- AddFunctionToInterface( desc, "GetChildren", &BridgeAccessible::GetChildren );
- AddFunctionToInterface( desc, "GetIndexInParent", &BridgeAccessible::GetIndexInParent );
- AddFunctionToInterface( desc, "GetNavigableAtPoint", &BridgeAccessible::GetNavigableAtPoint );
- AddFunctionToInterface( desc, "GetNeighbor", &BridgeAccessible::GetNeighbor );
- AddFunctionToInterface( desc, "GetDefaultLabelInfo", &BridgeAccessible::GetDefaultLabelInfo );
- AddFunctionToInterface( desc, "DoGesture", &BridgeAccessible::DoGesture );
- AddFunctionToInterface( desc, "GetReadingMaterial", &BridgeAccessible::GetReadingMaterial );
- AddFunctionToInterface( desc, "GetRelationSet", &BridgeAccessible::GetRelationSet );
- dbusServer.addInterface( "/", desc, true );
-}
-
-static bool AcceptObjectCheckRole( Component* obj )
-{
- if( !obj )
+ AddGetPropertyToInterface(desc, "ChildCount", &BridgeAccessible::GetChildCount);
+ AddGetPropertyToInterface(desc, "Name", &BridgeAccessible::GetName);
+ AddGetPropertyToInterface(desc, "Description", &BridgeAccessible::GetDescription);
+ AddGetPropertyToInterface(desc, "Parent", &BridgeAccessible::GetParent);
+ AddFunctionToInterface(desc, "GetRole", &BridgeAccessible::GetRole);
+ AddFunctionToInterface(desc, "GetRoleName", &BridgeAccessible::GetRoleName);
+ AddFunctionToInterface(desc, "GetLocalizedRoleName", &BridgeAccessible::GetLocalizedRoleName);
+ AddFunctionToInterface(desc, "GetState", &BridgeAccessible::GetStates);
+ AddFunctionToInterface(desc, "GetAttributes", &BridgeAccessible::GetAttributes);
+ AddFunctionToInterface(desc, "GetInterfaces", &BridgeAccessible::GetInterfaces);
+ AddFunctionToInterface(desc, "GetChildAtIndex", &BridgeAccessible::GetChildAtIndex);
+ AddFunctionToInterface(desc, "GetChildren", &BridgeAccessible::GetChildren);
+ AddFunctionToInterface(desc, "GetIndexInParent", &BridgeAccessible::GetIndexInParent);
+ AddFunctionToInterface(desc, "GetNavigableAtPoint", &BridgeAccessible::GetNavigableAtPoint);
+ AddFunctionToInterface(desc, "GetNeighbor", &BridgeAccessible::GetNeighbor);
+ AddFunctionToInterface(desc, "GetDefaultLabelInfo", &BridgeAccessible::GetDefaultLabelInfo);
+ AddFunctionToInterface(desc, "DoGesture", &BridgeAccessible::DoGesture);
+ AddFunctionToInterface(desc, "GetReadingMaterial", &BridgeAccessible::GetReadingMaterial);
+ AddFunctionToInterface(desc, "GetRelationSet", &BridgeAccessible::GetRelationSet);
+ dbusServer.addInterface("/", desc, true);
+}
+
+static bool AcceptObjectCheckRole(Component* obj)
+{
+ if(!obj)
return false;
- switch( obj->GetRole() )
+ switch(obj->GetRole())
{
case Role::APPLICATION:
case Role::FILLER:
return true;
}
-static bool AcceptObjectCheckRelations( Component* obj)
+static bool AcceptObjectCheckRelations(Component* obj)
{
auto r = obj->GetRelationSet();
- for (const auto& it : r)
- if (it.relationType == RelationType::CONTROLLED_BY)
+ for(const auto& it : r)
+ if(it.relationType == RelationType::CONTROLLED_BY)
return false;
return true;
}
-static Component* GetScrollableParent( Accessible* obj )
+static Component* GetScrollableParent(Accessible* obj)
{
- while( obj )
+ while(obj)
{
- obj = obj->GetParent();
- auto comp = dynamic_cast< Component* >( obj );
- if( comp && comp->IsScrollable() )
+ obj = obj->GetParent();
+ auto comp = dynamic_cast<Component*>(obj);
+ if(comp && comp->IsScrollable())
return comp;
}
return nullptr;
}
-static bool ObjectIsItem( Component* obj )
+static bool ObjectIsItem(Component* obj)
{
- if( !obj )
+ if(!obj)
return false;
auto role = obj->GetRole();
return role == Role::LIST_ITEM || role == Role::MENU_ITEM;
}
-static bool ObjectIsCollapsed( Component* obj )
+static bool ObjectIsCollapsed(Component* obj)
{
- if( !obj )
+ if(!obj)
return false;
const auto states = obj->GetStates();
return states[State::EXPANDABLE] && !states[State::EXPANDED];
}
-static bool OobjectIsZeroSize( Component* obj )
+static bool OobjectIsZeroSize(Component* obj)
{
- if( !obj )
+ if(!obj)
return false;
- auto extents = obj->GetExtents( CoordType::WINDOW );
+ auto extents = obj->GetExtents(CoordType::WINDOW);
return extents.height == 0 || extents.width == 0;
}
-static bool AcceptObject( Component* obj )
+static bool AcceptObject(Component* obj)
{
- if( !obj )
+ if(!obj)
return false;
const auto states = obj->GetStates();
- if( !states[State::VISIBLE] )
+ if(!states[State::VISIBLE])
return false;
- if( !AcceptObjectCheckRole( obj ) )
+ if(!AcceptObjectCheckRole(obj))
return false;
- if ( !AcceptObjectCheckRelations( obj ) )
+ if(!AcceptObjectCheckRelations(obj))
return false;
- if( !states[State::HIGHLIGHTABLE] )
+ if(!states[State::HIGHLIGHTABLE])
return false;
- if( GetScrollableParent( obj ) != nullptr )
+ if(GetScrollableParent(obj) != nullptr)
{
- auto parent = dynamic_cast< Component* >( obj->GetParent() );
+ auto parent = dynamic_cast<Component*>(obj->GetParent());
- if( parent )
+ if(parent)
{
- return !ObjectIsItem( obj ) || !ObjectIsCollapsed( parent );
+ return !ObjectIsItem(obj) || !ObjectIsCollapsed(parent);
}
}
else
{
- if( OobjectIsZeroSize( obj ) )
+ if(OobjectIsZeroSize(obj))
{
return false;
}
- if( !states[State::SHOWING] )
+ if(!states[State::SHOWING])
{
return false;
}
return true;
}
-static bool AcceptObject( Accessible* obj )
+static bool AcceptObject(Accessible* obj)
{
- auto c = dynamic_cast< Component* >( obj );
- return AcceptObject( c );
+ auto c = dynamic_cast<Component*>(obj);
+ return AcceptObject(c);
}
-static std::string objDump( Component* obj )
+static std::string objDump(Component* obj)
{
- if ( !obj )
+ if(!obj)
return "nullptr";
std::ostringstream o;
- auto e = obj->GetExtents( CoordType::SCREEN );
+ auto e = obj->GetExtents(CoordType::SCREEN);
o << "name: " << obj->GetName() << " extent: (" << e.x << ", "
- << e.y << "), [" << e.width << ", " << e.height << "]";
+ << e.y << "), [" << e.width << ", " << e.height << "]";
return o.str();
}
-Component * BridgeAccessible::GetObjectInRelation( Accessible * obj, RelationType ralationType )
+Component* BridgeAccessible::GetObjectInRelation(Accessible* obj, RelationType ralationType)
{
- if ( !obj )
+ if(!obj)
return nullptr;
- for ( auto &relation : obj->GetRelationSet() )
+ for(auto& relation : obj->GetRelationSet())
{
- if ( relation.relationType == ralationType )
+ if(relation.relationType == ralationType)
{
- for ( auto &address : relation.targets )
+ for(auto& address : relation.targets)
{
- auto component = dynamic_cast<Component*>( Find( address ) );
- if ( component )
+ auto component = dynamic_cast<Component*>(Find(address));
+ if(component)
return component;
}
}
return nullptr;
}
-static std::string makeIndent( unsigned int maxRecursionDepth )
+static std::string makeIndent(unsigned int maxRecursionDepth)
{
- return std::string( GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH - maxRecursionDepth, ' ' );
+ return std::string(GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH - maxRecursionDepth, ' ');
}
-Component* BridgeAccessible::CalculateNavigableAccessibleAtPoint( Accessible* root, Point p, CoordType cType, unsigned int maxRecursionDepth )
+Component* BridgeAccessible::CalculateNavigableAccessibleAtPoint(Accessible* root, Point p, CoordType cType, unsigned int maxRecursionDepth)
{
- if( !root || maxRecursionDepth == 0 )
+ if(!root || maxRecursionDepth == 0)
return nullptr;
- auto root_component = dynamic_cast< Component* >( root );
+ auto root_component = dynamic_cast<Component*>(root);
LOG() << "CalculateNavigableAccessibleAtPoint: checking: " << makeIndent(maxRecursionDepth) << objDump(root_component);
- if( root_component && !root_component->Contains( p, cType ) )
+ if(root_component && !root_component->Contains(p, cType))
return nullptr;
auto children = root->GetChildren();
- for( auto childIt = children.rbegin(); childIt != children.rend(); childIt++ )
+ for(auto childIt = children.rbegin(); childIt != children.rend(); childIt++)
{
//check recursively all children first
- auto result = CalculateNavigableAccessibleAtPoint( *childIt, p, cType, maxRecursionDepth - 1 );
- if( result )
+ auto result = CalculateNavigableAccessibleAtPoint(*childIt, p, cType, maxRecursionDepth - 1);
+ if(result)
return result;
}
- if( root_component )
+ if(root_component)
{
//Found a candidate, all its children are already checked
- auto controledBy = GetObjectInRelation( root_component, RelationType::CONTROLLED_BY );
- if ( !controledBy )
+ auto controledBy = GetObjectInRelation(root_component, RelationType::CONTROLLED_BY);
+ if(!controledBy)
controledBy = root_component;
- if ( controledBy->IsProxy() || AcceptObject( controledBy ) )
+ if(controledBy->IsProxy() || AcceptObject(controledBy))
{
- LOG() << "CalculateNavigableAccessibleAtPoint: found: " << makeIndent(maxRecursionDepth) << objDump( root_component );
+ LOG() << "CalculateNavigableAccessibleAtPoint: found: " << makeIndent(maxRecursionDepth) << objDump(root_component);
return controledBy;
}
}
BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
{
- auto self = FindSelf();
- auto attributes = self->GetAttributes();
- auto name = self->GetName();
+ auto self = FindSelf();
+ auto attributes = self->GetAttributes();
+ auto name = self->GetName();
std::string labeledByName = "";
- std::string textIfceName = "";
- auto role = static_cast< uint32_t >( self->GetRole() );
- auto states = self->GetStates();
- auto localizedName = self->GetLocalizedRoleName();
- auto childCount = static_cast< int32_t >( self->GetChildCount() );
+ std::string textIfceName = "";
+ auto role = static_cast<uint32_t>(self->GetRole());
+ auto states = self->GetStates();
+ auto localizedName = self->GetLocalizedRoleName();
+ auto childCount = static_cast<int32_t>(self->GetChildCount());
- double currentValue = 0.0;
+ double currentValue = 0.0;
double minimumIncrement = 0.0;
- double maximumValue = 0.0;
- double minimumValue = 0.0;
+ double maximumValue = 0.0;
+ double minimumValue = 0.0;
- auto *value = dynamic_cast<Dali::Accessibility::Value *>(self);
- if (value)
+ auto* value = dynamic_cast<Dali::Accessibility::Value*>(self);
+ if(value)
{
- currentValue = value->GetCurrent();
+ currentValue = value->GetCurrent();
minimumIncrement = value->GetMinimumIncrement();
- maximumValue = value->GetMaximum();
- minimumValue = value->GetMinimum();
+ maximumValue = value->GetMaximum();
+ minimumValue = value->GetMinimum();
}
- auto description = self->GetDescription();
- auto indexInParent = static_cast< int32_t >( self->GetIndexInParent() );
- bool isSelectedInParent = false;
- bool hasCheckBoxChild = false;
+ auto description = self->GetDescription();
+ auto indexInParent = static_cast<int32_t>(self->GetIndexInParent());
+ bool isSelectedInParent = false;
+ bool hasCheckBoxChild = false;
int32_t firstSelectedChildIndex = -1;
- int32_t selectedChildCount = 0;
+ int32_t selectedChildCount = 0;
- for( auto i = 0u; i < static_cast< size_t >( childCount ); ++i )
+ for(auto i = 0u; i < static_cast<size_t>(childCount); ++i)
{
- auto q = self->GetChildAtIndex( i );
+ auto q = self->GetChildAtIndex(i);
auto s = q->GetStates();
- if( s[State::SELECTABLE] )
+ if(s[State::SELECTABLE])
{
- if( s[State::SELECTED] )
+ if(s[State::SELECTED])
{
++selectedChildCount;
- if( firstSelectedChildIndex < 0 )
- firstSelectedChildIndex = static_cast< int32_t >( i );
+ if(firstSelectedChildIndex < 0)
+ firstSelectedChildIndex = static_cast<int32_t>(i);
}
}
- if( q->GetRole() == Role::CHECK_BOX )
+ if(q->GetRole() == Role::CHECK_BOX)
hasCheckBoxChild = true;
}
- int32_t listChildrenCount = 0;
- Accessible* parent = self->GetParent();
- auto parentStateSet = parent ? parent->GetStates() : States{};
- auto parentChildCount = parent ? static_cast< int32_t >( parent->GetChildCount() ) : 0;
- auto parentRole = static_cast< uint32_t >( parent ? parent->GetRole() : Role{} );
+ int32_t listChildrenCount = 0;
+ Accessible* parent = self->GetParent();
+ auto parentStateSet = parent ? parent->GetStates() : States{};
+ auto parentChildCount = parent ? static_cast<int32_t>(parent->GetChildCount()) : 0;
+ auto parentRole = static_cast<uint32_t>(parent ? parent->GetRole() : Role{});
Accessible* describedByObject = nullptr;
return {
- attributes,
- name,
- labeledByName,
- textIfceName,
- role,
- states,
- localizedName,
- childCount,
- currentValue,
- minimumIncrement,
- maximumValue,
- minimumValue,
- description,
- indexInParent,
- isSelectedInParent,
- hasCheckBoxChild,
- listChildrenCount,
- firstSelectedChildIndex,
- parent,
- parentStateSet,
- parentChildCount,
- parentRole,
- selectedChildCount,
- describedByObject};
-}
-
-DBus::ValueOrError< bool > BridgeAccessible::DoGesture( Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime )
-{
- return FindSelf()->DoGesture( Dali::Accessibility::GestureInfo {type, xBeg, xEnd, yBeg, yEnd, state, eventTime});
-}
-
-DBus::ValueOrError< Accessible*, uint8_t, Accessible* > BridgeAccessible::GetNavigableAtPoint( int32_t x, int32_t y, uint32_t coordType )
-{
- Accessible* deputy = nullptr;
- auto accessible = FindSelf();
- auto cType = static_cast< CoordType >( coordType );
+ attributes,
+ name,
+ labeledByName,
+ textIfceName,
+ role,
+ states,
+ localizedName,
+ childCount,
+ currentValue,
+ minimumIncrement,
+ maximumValue,
+ minimumValue,
+ description,
+ indexInParent,
+ isSelectedInParent,
+ hasCheckBoxChild,
+ listChildrenCount,
+ firstSelectedChildIndex,
+ parent,
+ parentStateSet,
+ parentChildCount,
+ parentRole,
+ selectedChildCount,
+ describedByObject};
+}
+
+DBus::ValueOrError<bool> BridgeAccessible::DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime)
+{
+ return FindSelf()->DoGesture(Dali::Accessibility::GestureInfo{type, xBeg, xEnd, yBeg, yEnd, state, eventTime});
+}
+
+DBus::ValueOrError<Accessible*, uint8_t, Accessible*> BridgeAccessible::GetNavigableAtPoint(int32_t x, int32_t y, uint32_t coordType)
+{
+ Accessible* deputy = nullptr;
+ auto accessible = FindSelf();
+ auto cType = static_cast<CoordType>(coordType);
LOG() << "GetNavigableAtPoint: " << x << ", " << y << " type: " << coordType;
- auto component = CalculateNavigableAccessibleAtPoint( accessible, {x, y}, cType, GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH );
- bool recurse = false;
- if( component )
+ auto component = CalculateNavigableAccessibleAtPoint(accessible, {x, y}, cType, GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH);
+ bool recurse = false;
+ if(component)
{
recurse = component->IsProxy();
}
return {component, recurse, deputy};
}
-static bool CheckChainEndWithAttribute( Accessible* obj, unsigned char forward )
+static bool CheckChainEndWithAttribute(Accessible* obj, unsigned char forward)
{
- if( !obj )
+ if(!obj)
return false;
auto attrs = obj->GetAttributes();
- for( auto& attr : attrs )
+ for(auto& attr : attrs)
{
- if( attr.first == "relation_chain_end" )
+ if(attr.first == "relation_chain_end")
{
- if( ( attr.second == "prev,end" && forward == 0 ) || ( attr.second == "next,end" && forward == 1 ) || attr.second == "prev,next,end" )
+ if((attr.second == "prev,end" && forward == 0) || (attr.second == "next,end" && forward == 1) || attr.second == "prev,next,end")
{
return true;
}
return false;
}
-static Accessible* DeputyOfProxyInParentGet( Accessible* obj )
+static Accessible* DeputyOfProxyInParentGet(Accessible* obj)
{
return nullptr;
}
return nullptr;
}
-std::vector< Accessible* > BridgeAccessible::ValidChildrenGet( const std::vector< Accessible* >& children, Accessible* start, Accessible* root )
+std::vector<Accessible*> BridgeAccessible::ValidChildrenGet(const std::vector<Accessible*>& children, Accessible* start, Accessible* root)
{
return children;
}
-static bool DeputyIs( Accessible* obj )
+static bool DeputyIs(Accessible* obj)
{
//TODO: add deputy
return false;
}
-static Accessible* ProxyInParentGet( Accessible* obj )
+static Accessible* ProxyInParentGet(Accessible* obj)
{
- if( !obj )
+ if(!obj)
return nullptr;
auto children = obj->GetChildren();
- for( auto& child : children )
+ for(auto& child : children)
{
- if( child->IsProxy() )
+ if(child->IsProxy())
return child;
}
return nullptr;
}
-static bool ObjectRoleIsAcceptableWhenNavigatingNextPrev( Accessible* obj )
+static bool ObjectRoleIsAcceptableWhenNavigatingNextPrev(Accessible* obj)
{
- if( !obj )
+ if(!obj)
return false;
auto role = obj->GetRole();
return role != Role::POPUP_MENU && role != Role::DIALOG;
}
-template < class T >
+template<class T>
struct CycleDetection
{
- CycleDetection( const T value ) : key( value ), currentSearchSize( 1 ), counter( 1 ) {}
- bool check( const T value )
+ CycleDetection(const T value)
+ : key(value),
+ currentSearchSize(1),
+ counter(1)
{
- if( key == value )
+ }
+ bool check(const T value)
+ {
+ if(key == value)
return true;
- if( --counter == 0 )
+ if(--counter == 0)
{
currentSearchSize <<= 1;
- if( currentSearchSize == 0 )
+ if(currentSearchSize == 0)
return true; // UNDEFINED BEHAVIOR
counter = currentSearchSize;
- key = value;
+ key = value;
}
return false;
}
- T key;
+ T key;
unsigned int currentSearchSize;
unsigned int counter;
};
-static Accessible* FindNonDefunctChild( const std::vector< Accessible* >& children, unsigned int currentIndex, unsigned char forward )
+static Accessible* FindNonDefunctChild(const std::vector<Accessible*>& children, unsigned int currentIndex, unsigned char forward)
{
unsigned int childrenCount = children.size();
- for( ; currentIndex < childrenCount; forward ? ++currentIndex : --currentIndex )
+ for(; currentIndex < childrenCount; forward ? ++currentIndex : --currentIndex)
{
Accessible* n = children[currentIndex];
- if( n && !n->GetStates()[State::DEFUNCT] )
+ if(n && !n->GetStates()[State::DEFUNCT])
return n;
}
return nullptr;
}
-static Accessible* DirectionalDepthFirstSearchTryNonDefunctChild( Accessible* node, const std::vector< Accessible* >& children, unsigned char forward )
+static Accessible* DirectionalDepthFirstSearchTryNonDefunctChild(Accessible* node, const std::vector<Accessible*>& children, unsigned char forward)
{
- if( !node )
+ if(!node)
return nullptr;
auto childrenCount = children.size();
- if( childrenCount > 0 )
+ if(childrenCount > 0)
{
- const bool isShowing = GetScrollableParent( node ) == nullptr ? node->GetStates()[State::SHOWING] : true;
- if( isShowing )
+ const bool isShowing = GetScrollableParent(node) == nullptr ? node->GetStates()[State::SHOWING] : true;
+ if(isShowing)
{
- return FindNonDefunctChild( children, forward ? 0 : childrenCount - 1, forward );
+ return FindNonDefunctChild(children, forward ? 0 : childrenCount - 1, forward);
}
}
return nullptr;
}
-Accessible* BridgeAccessible::GetNextNonDefunctSibling( Accessible* obj, Accessible* start, Accessible* root, unsigned char forward )
+Accessible* BridgeAccessible::GetNextNonDefunctSibling(Accessible* obj, Accessible* start, Accessible* root, unsigned char forward)
{
- if( !obj )
+ if(!obj)
return nullptr;
auto parent = obj->GetParent();
- if( !parent )
+ if(!parent)
return nullptr;
- auto children = ValidChildrenGet( parent->GetChildren(), start, root );
+ auto children = ValidChildrenGet(parent->GetChildren(), start, root);
unsigned int children_count = children.size();
- if( children_count == 0 )
+ if(children_count == 0)
{
return nullptr;
}
unsigned int current = 0;
- for( ; current < children_count && children[current] != obj; ++current )
+ for(; current < children_count && children[current] != obj; ++current)
;
- if( current >= children_count )
+ if(current >= children_count)
{
return nullptr;
}
forward ? ++current : --current;
- auto ret = FindNonDefunctChild( children, current, forward );
+ auto ret = FindNonDefunctChild(children, current, forward);
return ret;
}
-Accessible* BridgeAccessible::DirectionalDepthFirstSearchTryNonDefunctSibling( bool& all_children_visited, Accessible* node, Accessible* start, Accessible* root, unsigned char forward )
+Accessible* BridgeAccessible::DirectionalDepthFirstSearchTryNonDefunctSibling(bool& all_children_visited, Accessible* node, Accessible* start, Accessible* root, unsigned char forward)
{
- while( true )
+ while(true)
{
- Accessible* sibling = GetNextNonDefunctSibling( node, start, root, forward );
- if( sibling )
+ Accessible* sibling = GetNextNonDefunctSibling(node, start, root, forward);
+ if(sibling)
{
- node = sibling;
+ node = sibling;
all_children_visited = false;
break;
}
// walk up...
node = node->GetParent();
- if( node == nullptr || node == root )
+ if(node == nullptr || node == root)
return nullptr;
// in backward traversing stop the walk up on parent
- if( !forward )
+ if(!forward)
break;
}
return node;
}
-Accessible* BridgeAccessible::CalculateNeighbor( Accessible* root, Accessible* start, unsigned char forward, BridgeAccessible::GetNeighborSearchMode search_mode )
+Accessible* BridgeAccessible::CalculateNeighbor(Accessible* root, Accessible* start, unsigned char forward, BridgeAccessible::GetNeighborSearchMode search_mode)
{
- if( start && CheckChainEndWithAttribute( start, forward ) )
+ if(start && CheckChainEndWithAttribute(start, forward))
return start;
- if( root && root->GetStates()[State::DEFUNCT] )
+ if(root && root->GetStates()[State::DEFUNCT])
return NULL;
- if( start && start->GetStates()[State::DEFUNCT] )
+ if(start && start->GetStates()[State::DEFUNCT])
{
- start = NULL;
+ start = NULL;
forward = 1;
}
- if( search_mode == BridgeAccessible::GetNeighborSearchMode::recurseToOutside )
+ if(search_mode == BridgeAccessible::GetNeighborSearchMode::recurseToOutside)
{
// This only works if we navigate backward, and it is not possible to
// find in embedded process. In this case the deputy should be used */
- return DeputyOfProxyInParentGet( start );
+ return DeputyOfProxyInParentGet(start);
}
Accessible* node = start ? start : root;
- if( !node )
+ if(!node)
return nullptr;
// initialization of all-children-visited flag for start node - we assume
// Regarding condtion (start != root):
// The last object can be found only if all_children_visited is false.
// The start is same with root, when looking for the last object.
- bool all_children_visited = ( start != root ) && ( search_mode != BridgeAccessible::GetNeighborSearchMode::recurseFromRoot && !forward );
+ bool all_children_visited = (start != root) && (search_mode != BridgeAccessible::GetNeighborSearchMode::recurseFromRoot && !forward);
// true, if starting element should be ignored. this is only used in rare case of
// recursive search failing to find an object.
// consider tree, where element A on bus BUS_A has child B on bus BUS_B. when going "next" from
// if next object will be found there (on BUS_B), then search ends. but if not, then our caller will find it out
// and will call us again with object A and flag search_mode set to NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING.
// this flag means, that object A was already checked previously and we should skip it and its children.
- bool force_next = ( search_mode == BridgeAccessible::GetNeighborSearchMode::continueAfterFailedRecursion );
+ bool force_next = (search_mode == BridgeAccessible::GetNeighborSearchMode::continueAfterFailedRecursion);
- CycleDetection< Accessible* > cycleDetection( node );
- while( node )
+ CycleDetection<Accessible*> cycleDetection(node);
+ while(node)
{
- if( node->GetStates()[State::DEFUNCT] )
+ if(node->GetStates()[State::DEFUNCT])
return nullptr;
// always accept proxy object from different world
- if( !force_next && node->IsProxy() )
+ if(!force_next && node->IsProxy())
return node;
auto children = node->GetChildren();
- children = ValidChildrenGet( children, start, root );
+ children = ValidChildrenGet(children, start, root);
// do accept:
// 1. not start node
// 2. parent after all children in backward traversing
// 3. Nodes with roles: ATSPI_ROLE_PAGE_TAB, ATSPI_ROLE_POPUP_MENU and ATSPI_ROLE_DIALOG, only when looking for first or last element.
// Objects with those roles shouldnt be reachable, when navigating next / prev.
- bool all_children_visited_or_moving_forward = ( children.size() == 0 || forward || all_children_visited );
- if( !force_next && node != start && all_children_visited_or_moving_forward && AcceptObject( node ) )
+ bool all_children_visited_or_moving_forward = (children.size() == 0 || forward || all_children_visited);
+ if(!force_next && node != start && all_children_visited_or_moving_forward && AcceptObject(node))
{
- if( start == NULL || ObjectRoleIsAcceptableWhenNavigatingNextPrev( node ) )
+ if(start == NULL || ObjectRoleIsAcceptableWhenNavigatingNextPrev(node))
return node;
}
- Accessible* next_related_in_direction = !force_next ? GetObjectInRelation( node, forward ? RelationType::FLOWS_TO : RelationType::FLOWS_FROM ) : nullptr;
+ Accessible* next_related_in_direction = !force_next ? GetObjectInRelation(node, forward ? RelationType::FLOWS_TO : RelationType::FLOWS_FROM) : nullptr;
// force_next means that the search_mode is NEIGHBOR_SEARCH_MODE_CONTINUE_AFTER_FAILED_RECURSING
// in this case the node is elm_layout which is parent of proxy object.
// There is an access object working for the proxy object, and the access
// object could have relation information. This relation information should
// be checked first before using the elm_layout as a node.
- if( force_next && forward )
+ if(force_next && forward)
{
- auto deputy = DeputyOfProxyInParentGet( node );
+ auto deputy = DeputyOfProxyInParentGet(node);
next_related_in_direction =
- GetObjectInRelation( deputy, RelationType::FLOWS_TO );
+ GetObjectInRelation(deputy, RelationType::FLOWS_TO);
}
- if( next_related_in_direction && start && start->GetStates()[State::DEFUNCT] )
+ if(next_related_in_direction && start && start->GetStates()[State::DEFUNCT])
{
next_related_in_direction = NULL;
}
unsigned char want_cycle_detection = 0;
- if( next_related_in_direction )
+ if(next_related_in_direction)
{
// Check next_related_in_direction is deputy object
Accessible* parent;
- if( !forward )
+ if(!forward)
{
// If the prev object is deputy, then go to inside of its proxy first
- if( DeputyIs( next_related_in_direction ) )
+ if(DeputyIs(next_related_in_direction))
{
- parent = next_related_in_direction->GetParent();
- next_related_in_direction = ProxyInParentGet( parent );
+ parent = next_related_in_direction->GetParent();
+ next_related_in_direction = ProxyInParentGet(parent);
}
}
else
{
// If current object is deputy, and it has relation next object,
// then do not use the relation next object, and use proxy first
- if( DeputyIs( node ) )
+ if(DeputyIs(node))
{
- parent = node->GetParent();
- next_related_in_direction = ProxyInParentGet( parent );
+ parent = node->GetParent();
+ next_related_in_direction = ProxyInParentGet(parent);
}
}
- node = next_related_in_direction;
+ node = next_related_in_direction;
want_cycle_detection = 1;
}
else
{
- auto child = !force_next && !all_children_visited ? DirectionalDepthFirstSearchTryNonDefunctChild( node, children, forward ) : nullptr;
- if( child )
+ auto child = !force_next && !all_children_visited ? DirectionalDepthFirstSearchTryNonDefunctChild(node, children, forward) : nullptr;
+ if(child)
{
want_cycle_detection = 1;
}
else
{
- if( !force_next && node == root )
+ if(!force_next && node == root)
return NULL;
all_children_visited = true;
- child = DirectionalDepthFirstSearchTryNonDefunctSibling( all_children_visited, node, start, root, forward );
+ child = DirectionalDepthFirstSearchTryNonDefunctSibling(all_children_visited, node, start, root, forward);
}
node = child;
}
force_next = 0;
- if( want_cycle_detection && cycleDetection.check( node ) )
+ if(want_cycle_detection && cycleDetection.check(node))
{
return NULL;
}
return NULL;
}
-DBus::ValueOrError< Accessible*, uint8_t > BridgeAccessible::GetNeighbor( std::string rootPath, int32_t direction, int32_t search_mode )
+DBus::ValueOrError<Accessible*, uint8_t> BridgeAccessible::GetNeighbor(std::string rootPath, int32_t direction, int32_t search_mode)
{
- auto start = FindSelf();
- rootPath = StripPrefix( rootPath );
- auto root = !rootPath.empty() ? Find( rootPath ) : nullptr;
- auto accessible = CalculateNeighbor( root, start, direction == 1, static_cast< GetNeighborSearchMode >( search_mode ) );
- unsigned char recurse = 0;
- if( accessible )
+ auto start = FindSelf();
+ rootPath = StripPrefix(rootPath);
+ auto root = !rootPath.empty() ? Find(rootPath) : nullptr;
+ auto accessible = CalculateNeighbor(root, start, direction == 1, static_cast<GetNeighborSearchMode>(search_mode));
+ unsigned char recurse = 0;
+ if(accessible)
{
recurse = accessible->IsProxy();
}
// if you want more, then you need to change setApplicationRoot to
// add/remove ApplicationRoot and make roots a vector.
auto p = FindSelf()->GetParent();
- assert( p );
+ assert(p);
return p;
}
-DBus::ValueOrError< std::vector< Accessible* > > BridgeAccessible::GetChildren()
+DBus::ValueOrError<std::vector<Accessible*>> BridgeAccessible::GetChildren()
{
return FindSelf()->GetChildren();
}
{
return FindSelf()->GetDescription();
}
-DBus::ValueOrError< uint32_t > BridgeAccessible::GetRole()
+DBus::ValueOrError<uint32_t> BridgeAccessible::GetRole()
{
- return static_cast< unsigned int >( FindSelf()->GetRole() );
+ return static_cast<unsigned int>(FindSelf()->GetRole());
}
-DBus::ValueOrError< std::string > BridgeAccessible::GetRoleName()
+DBus::ValueOrError<std::string> BridgeAccessible::GetRoleName()
{
return FindSelf()->GetRoleName();
}
-DBus::ValueOrError< std::string > BridgeAccessible::GetLocalizedRoleName()
+DBus::ValueOrError<std::string> BridgeAccessible::GetLocalizedRoleName()
{
return FindSelf()->GetLocalizedRoleName();
}
-DBus::ValueOrError< int32_t > BridgeAccessible::GetIndexInParent()
+DBus::ValueOrError<int32_t> BridgeAccessible::GetIndexInParent()
{
return FindSelf()->GetIndexInParent();
}
-DBus::ValueOrError< std::array< uint32_t, 2 > > BridgeAccessible::GetStates()
+DBus::ValueOrError<std::array<uint32_t, 2>> BridgeAccessible::GetStates()
{
return FindSelf()->GetStates().GetRawData();
}
-DBus::ValueOrError< std::unordered_map< std::string, std::string > > BridgeAccessible::GetAttributes()
+DBus::ValueOrError<std::unordered_map<std::string, std::string>> BridgeAccessible::GetAttributes()
{
return FindSelf()->GetAttributes();
}
-DBus::ValueOrError< std::vector< std::string > > BridgeAccessible::GetInterfaces()
+DBus::ValueOrError<std::vector<std::string>> BridgeAccessible::GetInterfaces()
{
return FindSelf()->GetInterfaces();
}
{
return FindSelf()->GetChildCount();
}
-DBus::ValueOrError< Accessible* > BridgeAccessible::GetChildAtIndex( int index )
+DBus::ValueOrError<Accessible*> BridgeAccessible::GetChildAtIndex(int index)
{
- if( index < 0 )
- throw std::domain_error{"negative index (" + std::to_string( index ) + ")"};
- return FindSelf()->GetChildAtIndex( static_cast< size_t >( index ) );
+ if(index < 0)
+ throw std::domain_error{"negative index (" + std::to_string(index) + ")"};
+ return FindSelf()->GetChildAtIndex(static_cast<size_t>(index));
}
std::string BridgeAccessible::GetName()
return FindSelf()->GetName();
}
-DBus::ValueOrError< Accessible*, uint32_t , std::unordered_map< std::string, std::string > > BridgeAccessible::GetDefaultLabelInfo()
+DBus::ValueOrError<Accessible*, uint32_t, std::unordered_map<std::string, std::string>> BridgeAccessible::GetDefaultLabelInfo()
{
auto defaultLabel = FindSelf()->GetDefaultLabel();
- return {defaultLabel, static_cast< uint32_t >( defaultLabel->GetRole() ) , defaultLabel->GetAttributes()};
+ return {defaultLabel, static_cast<uint32_t>(defaultLabel->GetRole()), defaultLabel->GetAttributes()};
}
-DBus::ValueOrError<std::vector< BridgeAccessible::Relation >> BridgeAccessible::GetRelationSet()
+DBus::ValueOrError<std::vector<BridgeAccessible::Relation>> BridgeAccessible::GetRelationSet()
{
- auto relations = FindSelf()->GetRelationSet();
- std::vector< BridgeAccessible::Relation > ret;
+ auto relations = FindSelf()->GetRelationSet();
+ std::vector<BridgeAccessible::Relation> ret;
- for (auto &it : relations)
+ for(auto& it : relations)
ret.emplace_back(Relation{static_cast<uint32_t>(it.relationType), it.targets});
return ret;
/*
- * Copyright (c) 2019 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.
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceAction};
- AddGetPropertyToInterface( desc, "NActions", &BridgeAction::GetActionCount );
+ AddGetPropertyToInterface(desc, "NActions", &BridgeAction::GetActionCount);
- AddFunctionToInterface( desc, "GetName", &BridgeAction::GetActionName );
- AddFunctionToInterface( desc, "GetLocalizedName", &BridgeAction::GetLocalizedActionName );
- AddFunctionToInterface( desc, "GetDescription", &BridgeAction::GetActionDescription );
- AddFunctionToInterface( desc, "GetKeyBinding", &BridgeAction::GetActionKeyBinding );
- AddFunctionToInterface( desc, "DoAction", &BridgeAction::DoAction );
- AddFunctionToInterface( desc, "DoActionName", &BridgeAction::DoActionName );
- dbusServer.addInterface( "/", desc, true );
+ AddFunctionToInterface(desc, "GetName", &BridgeAction::GetActionName);
+ AddFunctionToInterface(desc, "GetLocalizedName", &BridgeAction::GetLocalizedActionName);
+ AddFunctionToInterface(desc, "GetDescription", &BridgeAction::GetActionDescription);
+ AddFunctionToInterface(desc, "GetKeyBinding", &BridgeAction::GetActionKeyBinding);
+ AddFunctionToInterface(desc, "DoAction", &BridgeAction::DoAction);
+ AddFunctionToInterface(desc, "DoActionName", &BridgeAction::DoActionName);
+ dbusServer.addInterface("/", desc, true);
}
Action* BridgeAction::FindSelf() const
{
auto s = BridgeBase::FindSelf();
- assert( s );
- auto s2 = dynamic_cast< Action* >( s );
- if( !s2 )
+ assert(s);
+ auto s2 = dynamic_cast<Action*>(s);
+ if(!s2)
throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Action interface"};
return s2;
}
-DBus::ValueOrError< std::string > BridgeAction::GetActionName( int32_t index )
+DBus::ValueOrError<std::string> BridgeAction::GetActionName(int32_t index)
{
- return FindSelf()->GetActionName( index );
+ return FindSelf()->GetActionName(index);
}
-DBus::ValueOrError< std::string > BridgeAction::GetLocalizedActionName( int32_t index )
+DBus::ValueOrError<std::string> BridgeAction::GetLocalizedActionName(int32_t index)
{
- return FindSelf()->GetLocalizedActionName( index );
+ return FindSelf()->GetLocalizedActionName(index);
}
-DBus::ValueOrError< std::string > BridgeAction::GetActionDescription( int32_t index )
+DBus::ValueOrError<std::string> BridgeAction::GetActionDescription(int32_t index)
{
- return FindSelf()->GetActionDescription( index );
+ return FindSelf()->GetActionDescription(index);
}
-DBus::ValueOrError< std::string > BridgeAction::GetActionKeyBinding( int32_t index )
+DBus::ValueOrError<std::string> BridgeAction::GetActionKeyBinding(int32_t index)
{
- return FindSelf()->GetActionKeyBinding( index );
+ return FindSelf()->GetActionKeyBinding(index);
}
-DBus::ValueOrError< int32_t > BridgeAction::GetActionCount()
+DBus::ValueOrError<int32_t> BridgeAction::GetActionCount()
{
return FindSelf()->GetActionCount();
;
}
-DBus::ValueOrError< bool > BridgeAction::DoAction( int32_t index )
+DBus::ValueOrError<bool> BridgeAction::DoAction(int32_t index)
{
- return FindSelf()->DoAction( index );
+ return FindSelf()->DoAction(index);
}
-DBus::ValueOrError< bool > BridgeAction::DoActionName( std::string name )
+DBus::ValueOrError<bool> BridgeAction::DoActionName(std::string name)
{
auto self = FindSelf();
- auto cnt = self->GetActionCount();
- for( auto i = 0u; i < cnt; ++i )
+ auto cnt = self->GetActionCount();
+ for(auto i = 0u; i < cnt; ++i)
{
- if( self->GetActionName( i ) == name )
+ if(self->GetActionName(i) == name)
{
- return self->DoAction( i );
+ return self->DoAction(i);
}
}
throw std::domain_error{"object " + self->GetAddress().ToString() + " doesn't have action '" + name + "'"};
/*
- * Copyright (c) 2019 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 BridgeBase::addFilteredEvent( FilteredEvents kind, Dali::Accessibility::Accessible* obj, float delay, std::function<void()> functor )
+void BridgeBase::addFilteredEvent(FilteredEvents kind, Dali::Accessibility::Accessible* obj, float delay, std::function<void()> functor)
{
- if( delay < 0 )
+ if(delay < 0)
{
delay = 0;
}
- auto it = filteredEvents.insert({ { kind, obj }, { static_cast<unsigned int>(delay * 10), {} } });
- if (it.second)
+ auto it = filteredEvents.insert({{kind, obj}, {static_cast<unsigned int>(delay * 10), {}}});
+ if(it.second)
{
functor();
}
it.first->second.second = std::move(functor);
}
- if (!tickTimer)
+ if(!tickTimer)
{
tickTimer = Dali::Timer::New(100);
tickTimer.TickSignal().Connect(this, &BridgeBase::tickFilteredEvents);
bool BridgeBase::tickFilteredEvents()
{
- for(auto it = filteredEvents.begin(); it != filteredEvents.end(); )
+ for(auto it = filteredEvents.begin(); it != filteredEvents.end();)
{
- if (it->second.first)
+ if(it->second.first)
{
--it->second.first;
}
else
{
- if (it->second.second)
+ if(it->second.second)
{
it->second.second();
it->second.second = {};
BridgeBase::ForceUpResult BridgeBase::ForceUp()
{
- if( Bridge::ForceUp() == ForceUpResult::ALREADY_UP )
+ if(Bridge::ForceUp() == ForceUpResult::ALREADY_UP)
{
return ForceUpResult::ALREADY_UP;
}
auto proxy = DBus::DBusClient{dbusLocators::atspi::BUS, dbusLocators::atspi::OBJ_PATH, dbusLocators::atspi::BUS_INTERFACE, DBus::ConnectionType::SESSION};
- auto addr = proxy.method< std::string() >( dbusLocators::atspi::GET_ADDRESS ).call();
+ auto addr = proxy.method<std::string()>(dbusLocators::atspi::GET_ADDRESS).call();
- if( !addr )
+ if(!addr)
{
- throw std::domain_error{std::string( "failed at call '" ) + dbusLocators::atspi::GET_ADDRESS + "': " + addr.getError().message};
+ throw std::domain_error{std::string("failed at call '") + dbusLocators::atspi::GET_ADDRESS + "': " + addr.getError().message};
}
- con = DBusWrapper::Installed()->eldbus_address_connection_get_impl( std::get< 0 >( addr ) );
- data->busName = DBus::getConnectionName( con );
- dbusServer = { con };
+ con = DBusWrapper::Installed()->eldbus_address_connection_get_impl(std::get<0>(addr));
+ data->busName = DBus::getConnectionName(con);
+ dbusServer = {con};
{
DBus::DBusInterfaceDescription desc{"org.a11y.atspi.Cache"};
- AddFunctionToInterface( desc, "GetItems", &BridgeBase::GetItems );
- dbusServer.addInterface( "/org/a11y/atspi/cache", desc );
+ AddFunctionToInterface(desc, "GetItems", &BridgeBase::GetItems);
+ dbusServer.addInterface("/org/a11y/atspi/cache", desc);
}
{
DBus::DBusInterfaceDescription desc{"org.a11y.atspi.Application"};
- AddGetSetPropertyToInterface( desc, "Id", &BridgeBase::IdGet, &BridgeBase::IdSet );
- dbusServer.addInterface( AtspiPath, desc );
+ AddGetSetPropertyToInterface(desc, "Id", &BridgeBase::IdGet, &BridgeBase::IdSet);
+ dbusServer.addInterface(AtspiPath, desc);
}
return ForceUpResult::JUST_STARTED;
{
Bridge::ForceDown();
dbusServer = {};
- con = {};
+ con = {};
}
const std::string& BridgeBase::GetBusName() const
return data ? data->busName : empty;
}
-Accessible* BridgeBase::FindByPath( const std::string& name ) const
+Accessible* BridgeBase::FindByPath(const std::string& name) const
{
try
{
- return Find( name );
+ return Find(name);
}
- catch( std::domain_error& )
+ catch(std::domain_error&)
{
return nullptr;
}
}
-void BridgeBase::AddPopup( Accessible* obj )
+void BridgeBase::AddPopup(Accessible* obj)
{
- if( std::find( popups.begin(), popups.end(), obj ) != popups.end() )
+ if(std::find(popups.begin(), popups.end(), obj) != popups.end())
{
return;
}
- popups.push_back( obj );
- if (IsUp())
+ popups.push_back(obj);
+ if(IsUp())
{
- obj->Emit( WindowEvent::ACTIVATE, 0 );
+ obj->Emit(WindowEvent::ACTIVATE, 0);
}
}
-void BridgeBase::RemovePopup( Accessible* obj )
+void BridgeBase::RemovePopup(Accessible* obj)
{
- auto it = std::find( popups.begin(), popups.end(), obj );
- if( it == popups.end() )
+ auto it = std::find(popups.begin(), popups.end(), obj);
+ if(it == popups.end())
{
return;
}
- popups.erase( it );
- if (IsUp())
+ popups.erase(it);
+ if(IsUp())
{
- obj->Emit( WindowEvent::DEACTIVATE, 0 );
- if( popups.empty() )
+ obj->Emit(WindowEvent::DEACTIVATE, 0);
+ if(popups.empty())
{
- application.children.back()->Emit( WindowEvent::ACTIVATE, 0 );
+ application.children.back()->Emit(WindowEvent::ACTIVATE, 0);
}
else
{
- popups.back()->Emit( WindowEvent::ACTIVATE, 0 );
+ popups.back()->Emit(WindowEvent::ACTIVATE, 0);
}
}
}
-void BridgeBase::AddTopLevelWindow( Accessible* root )
+void BridgeBase::AddTopLevelWindow(Accessible* root)
{
- application.children.push_back( root );
- SetIsOnRootLevel( root );
+ application.children.push_back(root);
+ SetIsOnRootLevel(root);
}
-void BridgeBase::RemoveTopLevelWindow( Accessible* root )
+void BridgeBase::RemoveTopLevelWindow(Accessible* root)
{
for(auto i = 0u; i < application.children.size(); ++i)
{
- if( application.children[i] == root )
+ if(application.children[i] == root)
{
application.children.erase(application.children.begin() + i);
break;
}
}
-std::string BridgeBase::StripPrefix( const std::string& path )
+std::string BridgeBase::StripPrefix(const std::string& path)
{
- auto size = strlen( AtspiPath );
- return path.substr( size + 1 );
+ auto size = strlen(AtspiPath);
+ return path.substr(size + 1);
}
-Accessible* BridgeBase::Find( const std::string& path ) const
+Accessible* BridgeBase::Find(const std::string& path) const
{
- if( path == "root" )
+ if(path == "root")
{
return &application;
}
- void* p;
- std::istringstream tmp{ path };
- if (! ( tmp >> p) )
+ void* p;
+ std::istringstream tmp{path};
+ if(!(tmp >> p))
{
throw std::domain_error{"invalid path '" + path + "'"};
}
- auto it = data->knownObjects.find( static_cast<Accessible*>( p ) );
- if( it == data->knownObjects.end() )
+ auto it = data->knownObjects.find(static_cast<Accessible*>(p));
+ if(it == data->knownObjects.end())
{
throw std::domain_error{"unknown object '" + path + "'"};
}
- return static_cast<Accessible*>( p );
+ return static_cast<Accessible*>(p);
}
-Accessible* BridgeBase::Find( const Address& ptr ) const
+Accessible* BridgeBase::Find(const Address& ptr) const
{
- assert( ptr.GetBus() == data->busName );
- return Find( ptr.GetPath() );
+ assert(ptr.GetBus() == data->busName);
+ return Find(ptr.GetPath());
}
Accessible* BridgeBase::FindSelf() const
{
- auto pth = DBus::DBusServer::getCurrentObjectPath();
- auto size = strlen( AtspiPath );
- if( pth.size() <= size )
+ auto pth = DBus::DBusServer::getCurrentObjectPath();
+ auto size = strlen(AtspiPath);
+ if(pth.size() <= size)
{
throw std::domain_error{"invalid path '" + pth + "'"};
}
- if( pth.substr( 0, size ) != AtspiPath )
+ if(pth.substr(0, size) != AtspiPath)
{
throw std::domain_error{"invalid path '" + pth + "'"};
}
- if( pth[size] != '/' )
+ if(pth[size] != '/')
{
throw std::domain_error{"invalid path '" + pth + "'"};
}
- return Find( StripPrefix( pth ) );
+ return Find(StripPrefix(pth));
}
-void BridgeBase::IdSet( int id )
+void BridgeBase::IdSet(int id)
{
this->id = id;
}
return this->id;
}
-auto BridgeBase::GetItems() -> DBus::ValueOrError< std::vector< CacheElementType > >
+auto BridgeBase::GetItems() -> DBus::ValueOrError<std::vector<CacheElementType> >
{
auto root = &application;
- std::vector< CacheElementType > res;
+ std::vector<CacheElementType> res;
- std::function< void(Accessible*) > proc =
- [&]( Accessible* item )
- {
- res.emplace_back( std::move( CreateCacheElement( root ) ) );
- for( auto i = 0u; i < item->GetChildCount(); ++i )
+ std::function<void(Accessible*)> proc =
+ [&](Accessible* item) {
+ res.emplace_back(std::move(CreateCacheElement(root)));
+ for(auto i = 0u; i < item->GetChildCount(); ++i)
{
- proc( item->GetChildAtIndex( i ) );
+ proc(item->GetChildAtIndex(i));
}
};
return res;
}
-auto BridgeBase::CreateCacheElement( Accessible* item ) -> CacheElementType
+auto BridgeBase::CreateCacheElement(Accessible* item) -> CacheElementType
{
- if( !item )
+ if(!item)
{
return {};
}
- auto root = &application;
+ auto root = &application;
auto parent = item->GetParent();
- std::vector< Address > children;
- for( auto i = 0u; i < item->GetChildCount(); ++i )
+ std::vector<Address> children;
+ for(auto i = 0u; i < item->GetChildCount(); ++i)
{
- children.emplace_back( item->GetChildAtIndex( i )->GetAddress() );
+ children.emplace_back(item->GetChildAtIndex(i)->GetAddress());
}
return std::make_tuple(
item->GetName(),
item->GetRole(),
item->GetDescription(),
- item->GetStates().GetRawData()
- );
+ item->GetStates().GetRawData());
}
-
/*
- * Copyright (c) 2019 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 BridgeCollection::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceCollection};
- AddFunctionToInterface( desc, "GetMatches", &BridgeCollection::GetMatches );
- dbusServer.addInterface( "/", desc, true );
+ AddFunctionToInterface(desc, "GetMatches", &BridgeCollection::GetMatches);
+ dbusServer.addInterface("/", desc, true);
}
Collection* BridgeCollection::FindSelf() const
{
auto s = BridgeBase::FindSelf();
- assert( s );
- auto s2 = dynamic_cast< Collection* >( s );
- if( !s2 )
+ assert(s);
+ auto s2 = dynamic_cast<Collection*>(s);
+ if(!s2)
throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Collection interface"};
return s2;
}
FIRST_NOT_FOUND
};
- static Mode ConvertToMatchType( int32_t mode )
+ static Mode ConvertToMatchType(int32_t mode)
{
- switch( mode )
+ switch(mode)
{
case ATSPI_Collection_MATCH_INVALID:
{
struct ComparerInterfaces
{
- std::unordered_set< std::string > object;
- std::vector< std::string > requested;
- Mode mode = Mode::INVALID;
+ std::unordered_set<std::string> object;
+ std::vector<std::string> requested;
+ Mode mode = Mode::INVALID;
- ComparerInterfaces( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::InterfacesMatchType >( *rule ) ) )
+ ComparerInterfaces(MatchRule* rule)
+ : mode(ConvertToMatchType(std::get<Index::InterfacesMatchType>(*rule)))
{
- requested = {std::get< Index::Interfaces >( *rule ).begin(), std::get< Index::Interfaces >( *rule ).end()};
+ requested = {std::get<Index::Interfaces>(*rule).begin(), std::get<Index::Interfaces>(*rule).end()};
}
- void Update( Accessible* obj )
+ void Update(Accessible* obj)
{
object.clear();
- for( auto& q : obj->GetInterfaces() )
- object.insert( std::move( q ) );
+ for(auto& q : obj->GetInterfaces())
+ object.insert(std::move(q));
}
- bool RequestEmpty() const { return requested.empty(); }
- bool ObjectEmpty() const { return object.empty(); }
- bool Compare( CompareFuncExit exit )
+ bool RequestEmpty() const
+ {
+ return requested.empty();
+ }
+ bool ObjectEmpty() const
+ {
+ return object.empty();
+ }
+ bool Compare(CompareFuncExit exit)
{
bool foundAny = false;
- for( auto& iname : requested )
+ for(auto& iname : requested)
{
- bool found = ( object.find( iname ) != object.end() );
- if( found )
+ bool found = (object.find(iname) != object.end());
+ if(found)
foundAny = true;
- if( found == ( exit == CompareFuncExit::FIRST_FOUND ) )
+ if(found == (exit == CompareFuncExit::FIRST_FOUND))
return found;
}
return foundAny;
};
struct ComparerAttributes
{
- std::unordered_map< std::string, std::string > requested, object;
- Mode mode = Mode::INVALID;
+ std::unordered_map<std::string, std::string> requested, object;
+ Mode mode = Mode::INVALID;
- ComparerAttributes( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::AttributesMatchType >( *rule ) ) )
+ ComparerAttributes(MatchRule* rule)
+ : mode(ConvertToMatchType(std::get<Index::AttributesMatchType>(*rule)))
{
- requested = std::get< Index::Attributes >( *rule );
+ requested = std::get<Index::Attributes>(*rule);
}
- void Update( Accessible* obj )
+ void Update(Accessible* obj)
{
object = obj->GetAttributes();
}
- bool RequestEmpty() const { return requested.empty(); }
- bool ObjectEmpty() const { return object.empty(); }
- bool Compare( CompareFuncExit exit )
+ bool RequestEmpty() const
+ {
+ return requested.empty();
+ }
+ bool ObjectEmpty() const
+ {
+ return object.empty();
+ }
+ bool Compare(CompareFuncExit exit)
{
bool foundAny = false;
- for( auto& iname : requested )
+ for(auto& iname : requested)
{
- auto it = object.find( iname.first );
+ auto it = object.find(iname.first);
bool found = it != object.end() && iname.second == it->second;
- if( found )
+ if(found)
foundAny = true;
- if( found == ( exit == CompareFuncExit::FIRST_FOUND ) )
+ if(found == (exit == CompareFuncExit::FIRST_FOUND))
{
return found;
}
};
struct ComparerRoles
{
- using Roles = BitSets< 4, Role >;
+ using Roles = BitSets<4, Role>;
Roles requested, object;
- Mode mode = Mode::INVALID;
+ Mode mode = Mode::INVALID;
- ComparerRoles( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::RolesMatchType >( *rule ) ) )
+ ComparerRoles(MatchRule* rule)
+ : mode(ConvertToMatchType(std::get<Index::RolesMatchType>(*rule)))
{
- requested = Roles{std::get< Index::Roles >( *rule )};
+ requested = Roles{std::get<Index::Roles>(*rule)};
}
- void Update( Accessible* obj )
+ void Update(Accessible* obj)
{
- object = {};
+ object = {};
object[obj->GetRole()] = true;
- assert( object );
+ assert(object);
+ }
+ bool RequestEmpty() const
+ {
+ return !requested;
+ }
+ bool ObjectEmpty() const
+ {
+ return !object;
}
- bool RequestEmpty() const { return !requested; }
- bool ObjectEmpty() const { return !object; }
- bool Compare( CompareFuncExit exit )
+ bool Compare(CompareFuncExit exit)
{
- switch( mode )
+ switch(mode)
{
case Mode::INVALID:
{
case Mode::EMPTY:
case Mode::ALL:
{
- return requested == ( object & requested );
+ return requested == (object & requested);
}
case Mode::ANY:
{
- return bool( object & requested );
+ return bool(object & requested);
}
case Mode::NONE:
{
- return bool( object & requested );
+ return bool(object & requested);
}
}
return false;
struct ComparerStates
{
States requested, object;
- Mode mode = Mode::INVALID;
+ Mode mode = Mode::INVALID;
- ComparerStates( MatchRule* rule ) : mode( ConvertToMatchType( std::get< Index::StatesMatchType >( *rule ) ) )
+ ComparerStates(MatchRule* rule)
+ : mode(ConvertToMatchType(std::get<Index::StatesMatchType>(*rule)))
{
- requested = States{std::get< Index::States >( *rule )};
+ requested = States{std::get<Index::States>(*rule)};
}
- void Update( Accessible* obj )
+ void Update(Accessible* obj)
{
object = obj->GetStates();
}
- bool RequestEmpty() const { return !requested; }
- bool ObjectEmpty() const { return !object; }
- bool Compare( CompareFuncExit exit )
+ bool RequestEmpty() const
+ {
+ return !requested;
+ }
+ bool ObjectEmpty() const
{
- switch( mode )
+ return !object;
+ }
+ bool Compare(CompareFuncExit exit)
+ {
+ switch(mode)
{
case Mode::INVALID:
{
case Mode::EMPTY:
case Mode::ALL:
{
- return requested == ( object & requested );
+ return requested == (object & requested);
}
case Mode::ANY:
{
- return bool( object & requested );
+ return bool(object & requested);
}
case Mode::NONE:
{
- return bool( object & requested );
+ return bool(object & requested);
}
}
return false;
}
};
- template < typename T >
- bool compareFunc( T& cmp, Accessible* obj )
+ template<typename T>
+ bool compareFunc(T& cmp, Accessible* obj)
{
- if( cmp.mode == Mode::INVALID )
+ if(cmp.mode == Mode::INVALID)
return true;
- cmp.Update( obj );
- switch( cmp.mode )
+ cmp.Update(obj);
+ switch(cmp.mode)
{
case Mode::ANY:
{
- if( cmp.RequestEmpty() || cmp.ObjectEmpty() )
+ if(cmp.RequestEmpty() || cmp.ObjectEmpty())
return false;
break;
}
case Mode::ALL:
{
- if( cmp.RequestEmpty() )
+ if(cmp.RequestEmpty())
return true;
- if( cmp.ObjectEmpty() )
+ if(cmp.ObjectEmpty())
return false;
break;
}
case Mode::NONE:
{
- if( cmp.RequestEmpty() || cmp.ObjectEmpty() )
+ if(cmp.RequestEmpty() || cmp.ObjectEmpty())
return true;
break;
}
case Mode::EMPTY:
{
- if( cmp.RequestEmpty() && cmp.ObjectEmpty() )
+ if(cmp.RequestEmpty() && cmp.ObjectEmpty())
return true;
- if( cmp.RequestEmpty() || cmp.ObjectEmpty() )
+ if(cmp.RequestEmpty() || cmp.ObjectEmpty())
return false;
break;
}
}
}
- switch( cmp.mode )
+ switch(cmp.mode)
{
case Mode::EMPTY:
case Mode::ALL:
{
- if( !cmp.Compare( CompareFuncExit::FIRST_NOT_FOUND ) )
+ if(!cmp.Compare(CompareFuncExit::FIRST_NOT_FOUND))
return false;
break;
}
case Mode::ANY:
{
- if( cmp.Compare( CompareFuncExit::FIRST_FOUND ) )
+ if(cmp.Compare(CompareFuncExit::FIRST_FOUND))
return true;
break;
}
case Mode::NONE:
{
- if( cmp.Compare( CompareFuncExit::FIRST_FOUND ) )
+ if(cmp.Compare(CompareFuncExit::FIRST_FOUND))
return false;
break;
}
return true;
}
}
- switch( cmp.mode )
+ switch(cmp.mode)
{
case Mode::EMPTY:
case Mode::ALL:
ComparerInterfaces ci;
ComparerAttributes ca;
- ComparerRoles cr;
- ComparerStates cs;
+ ComparerRoles cr;
+ ComparerStates cs;
- Comparer( MatchRule* mr ) : ci( mr ), ca( mr ), cr( mr ), cs( mr ) {}
+ Comparer(MatchRule* mr)
+ : ci(mr),
+ ca(mr),
+ cr(mr),
+ cs(mr)
+ {
+ }
- bool operator()( Accessible* obj )
+ bool operator()(Accessible* obj)
{
- return compareFunc( ci, obj ) &&
- compareFunc( ca, obj ) &&
- compareFunc( cr, obj ) &&
- compareFunc( cs, obj );
+ return compareFunc(ci, obj) &&
+ compareFunc(ca, obj) &&
+ compareFunc(cr, obj) &&
+ compareFunc(cs, obj);
}
};
-void BridgeCollection::VisitNodes( Accessible* obj, std::vector< Accessible* >& result, Comparer& cmp, size_t maxCount )
+void BridgeCollection::VisitNodes(Accessible* obj, std::vector<Accessible*>& result, Comparer& cmp, size_t maxCount)
{
- if( maxCount > 0 && result.size() >= maxCount )
+ if(maxCount > 0 && result.size() >= maxCount)
return;
- if( cmp( obj ) )
- result.emplace_back( obj );
+ if(cmp(obj))
+ result.emplace_back(obj);
- for( auto i = 0u; i < obj->GetChildCount(); ++i )
- VisitNodes( obj->GetChildAtIndex( i ), result, cmp, maxCount );
+ for(auto i = 0u; i < obj->GetChildCount(); ++i)
+ VisitNodes(obj->GetChildAtIndex(i), result, cmp, maxCount);
}
-DBus::ValueOrError< std::vector< Accessible* > > BridgeCollection::GetMatches( MatchRule rule, uint32_t sortBy, int32_t count, bool traverse )
+DBus::ValueOrError<std::vector<Accessible*> > BridgeCollection::GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse)
{
- std::vector< Accessible* > res;
- auto self = BridgeBase::FindSelf();
- auto matcher = Comparer{&rule};
- VisitNodes( self, res, matcher, count );
+ std::vector<Accessible*> res;
+ auto self = BridgeBase::FindSelf();
+ auto matcher = Comparer{&rule};
+ VisitNodes(self, res, matcher, count);
- switch( static_cast< SortOrder >( sortBy ) )
+ switch(static_cast<SortOrder>(sortBy))
{
case SortOrder::CANONICAL:
{
case SortOrder::REVERSE_CANONICAL:
{
- std::reverse( res.begin(), res.end() );
+ std::reverse(res.begin(), res.end());
break;
}
/*
- * Copyright (c) 2019 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 BridgeComponent::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceComponent};
- AddFunctionToInterface( desc, "Contains", &BridgeComponent::Contains );
- AddFunctionToInterface( desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint );
- AddFunctionToInterface( desc, "GetExtents", &BridgeComponent::GetExtents );
- AddFunctionToInterface( desc, "GetPosition", &BridgeComponent::GetPosition );
- AddFunctionToInterface( desc, "GetSize", &BridgeComponent::GetSize );
- AddFunctionToInterface( desc, "GetLayer", &BridgeComponent::GetLayer );
- AddFunctionToInterface( desc, "GetAlpha", &BridgeComponent::GetAlpha );
- AddFunctionToInterface( desc, "GetMDIZOrder", &BridgeComponent::GetMdiZOrder );
- AddFunctionToInterface( desc, "GrabHighlight", &BridgeComponent::GrabHighlight );
- AddFunctionToInterface( desc, "GrabFocus", &BridgeComponent::GrabFocus );
- AddFunctionToInterface( desc, "ClearHighlight", &BridgeComponent::ClearHighlight );
- dbusServer.addInterface( "/", desc, true );
+ AddFunctionToInterface(desc, "Contains", &BridgeComponent::Contains);
+ AddFunctionToInterface(desc, "GetAccessibleAtPoint", &BridgeComponent::GetAccessibleAtPoint);
+ AddFunctionToInterface(desc, "GetExtents", &BridgeComponent::GetExtents);
+ AddFunctionToInterface(desc, "GetPosition", &BridgeComponent::GetPosition);
+ AddFunctionToInterface(desc, "GetSize", &BridgeComponent::GetSize);
+ AddFunctionToInterface(desc, "GetLayer", &BridgeComponent::GetLayer);
+ AddFunctionToInterface(desc, "GetAlpha", &BridgeComponent::GetAlpha);
+ AddFunctionToInterface(desc, "GetMDIZOrder", &BridgeComponent::GetMdiZOrder);
+ AddFunctionToInterface(desc, "GrabHighlight", &BridgeComponent::GrabHighlight);
+ AddFunctionToInterface(desc, "GrabFocus", &BridgeComponent::GrabFocus);
+ AddFunctionToInterface(desc, "ClearHighlight", &BridgeComponent::ClearHighlight);
+ dbusServer.addInterface("/", desc, true);
}
Component* BridgeComponent::FindSelf() const
{
auto s = BridgeBase::FindSelf();
- assert( s );
- auto s2 = dynamic_cast< Component* >( s );
- if( !s2 )
+ assert(s);
+ auto s2 = dynamic_cast<Component*>(s);
+ if(!s2)
throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Component interface"};
return s2;
}
-DBus::ValueOrError< bool > BridgeComponent::Contains( int32_t x, int32_t y, uint32_t coordType )
+DBus::ValueOrError<bool> BridgeComponent::Contains(int32_t x, int32_t y, uint32_t coordType)
{
- return FindSelf()->Contains( {x, y}, static_cast< CoordType >( coordType ) );
+ return FindSelf()->Contains({x, y}, static_cast<CoordType>(coordType));
}
-DBus::ValueOrError< Accessible* > BridgeComponent::GetAccessibleAtPoint( int32_t x, int32_t y, uint32_t coordType )
+DBus::ValueOrError<Accessible*> BridgeComponent::GetAccessibleAtPoint(int32_t x, int32_t y, uint32_t coordType)
{
- return FindSelf()->GetAccessibleAtPoint( {x, y}, static_cast< CoordType >( coordType ) );
+ return FindSelf()->GetAccessibleAtPoint({x, y}, static_cast<CoordType>(coordType));
}
-DBus::ValueOrError< std::tuple< int32_t, int32_t, int32_t, int32_t > > BridgeComponent::GetExtents( uint32_t coordType )
+DBus::ValueOrError<std::tuple<int32_t, int32_t, int32_t, int32_t> > BridgeComponent::GetExtents(uint32_t coordType)
{
- auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
- return std::tuple< int32_t, int32_t, int32_t, int32_t >{p.x, p.y, p.width, p.height};
+ auto p = FindSelf()->GetExtents(static_cast<CoordType>(coordType));
+ return std::tuple<int32_t, int32_t, int32_t, int32_t>{p.x, p.y, p.width, p.height};
}
-DBus::ValueOrError< int32_t, int32_t > BridgeComponent::GetPosition( uint32_t coordType )
+DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetPosition(uint32_t coordType)
{
- auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
- return { static_cast<int32_t>(p.x), static_cast<int32_t>(p.y) };
+ auto p = FindSelf()->GetExtents(static_cast<CoordType>(coordType));
+ return {static_cast<int32_t>(p.x), static_cast<int32_t>(p.y)};
}
-DBus::ValueOrError< int32_t, int32_t > BridgeComponent::GetSize( uint32_t coordType )
+DBus::ValueOrError<int32_t, int32_t> BridgeComponent::GetSize(uint32_t coordType)
{
- auto p = FindSelf()->GetExtents( static_cast< CoordType >( coordType ) );
- return { static_cast<int32_t>(p.width), static_cast<int32_t>(p.height) };
+ auto p = FindSelf()->GetExtents(static_cast<CoordType>(coordType));
+ return {static_cast<int32_t>(p.width), static_cast<int32_t>(p.height)};
}
-DBus::ValueOrError< ComponentLayer > BridgeComponent::GetLayer()
+DBus::ValueOrError<ComponentLayer> BridgeComponent::GetLayer()
{
return FindSelf()->GetLayer();
}
-DBus::ValueOrError< double > BridgeComponent::GetAlpha()
+DBus::ValueOrError<double> BridgeComponent::GetAlpha()
{
return FindSelf()->GetAlpha();
}
-DBus::ValueOrError< bool > BridgeComponent::GrabFocus()
+DBus::ValueOrError<bool> BridgeComponent::GrabFocus()
{
return FindSelf()->GrabFocus();
}
-DBus::ValueOrError< bool > BridgeComponent::GrabHighlight()
+DBus::ValueOrError<bool> BridgeComponent::GrabHighlight()
{
return FindSelf()->GrabHighlight();
}
-DBus::ValueOrError< bool > BridgeComponent::ClearHighlight()
+DBus::ValueOrError<bool> BridgeComponent::ClearHighlight()
{
return FindSelf()->ClearHighlight();
}
-DBus::ValueOrError< int16_t > BridgeComponent::GetMdiZOrder()
+DBus::ValueOrError<int16_t> BridgeComponent::GetMdiZOrder()
{
return FindSelf()->GetMdiZOrder();
}
/*
- * Copyright (c) 2019 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 BridgeEditableText::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceEditableText};
- AddFunctionToInterface( desc, "CopyText", &BridgeEditableText::CopyText );
- AddFunctionToInterface( desc, "CutText", &BridgeEditableText::CutText );
- AddFunctionToInterface( desc, "PasteText", &BridgeEditableText::PasteText );
- dbusServer.addInterface( "/", desc, true );
+ AddFunctionToInterface(desc, "CopyText", &BridgeEditableText::CopyText);
+ AddFunctionToInterface(desc, "CutText", &BridgeEditableText::CutText);
+ AddFunctionToInterface(desc, "PasteText", &BridgeEditableText::PasteText);
+ dbusServer.addInterface("/", desc, true);
}
EditableText* BridgeEditableText::FindSelf() const
{
auto s = BridgeBase::FindSelf();
- assert( s );
- auto s2 = dynamic_cast< EditableText* >( s );
- if( !s2 )
+ assert(s);
+ auto s2 = dynamic_cast<EditableText*>(s);
+ if(!s2)
throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Text interface"};
return s2;
}
-DBus::ValueOrError< bool > BridgeEditableText::CopyText( int32_t startPos, int32_t endPos )
+DBus::ValueOrError<bool> BridgeEditableText::CopyText(int32_t startPos, int32_t endPos)
{
- return FindSelf()->CopyText( startPos, endPos );
+ return FindSelf()->CopyText(startPos, endPos);
}
-DBus::ValueOrError< bool > BridgeEditableText::CutText( int32_t startPos, int32_t endPos )
+DBus::ValueOrError<bool> BridgeEditableText::CutText(int32_t startPos, int32_t endPos)
{
- return FindSelf()->CutText( startPos, endPos );
+ return FindSelf()->CutText(startPos, endPos);
}
-DBus::ValueOrError< bool > BridgeEditableText::PasteText( int32_t pos )
+DBus::ValueOrError<bool> BridgeEditableText::PasteText(int32_t pos)
{
// auto imfManager = Dali::Internal::Adaptor::ImfManager::Get();
// imfManager.SetCursorPosition( pos );
/*
- * Copyright (c) 2019 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.
#include <dali/internal/accessibility/bridge/bridge-action.h>
#include <dali/internal/accessibility/bridge/bridge-collection.h>
#include <dali/internal/accessibility/bridge/bridge-component.h>
+#include <dali/internal/accessibility/bridge/bridge-editable-text.h>
#include <dali/internal/accessibility/bridge/bridge-object.h>
-#include <dali/internal/accessibility/bridge/bridge-value.h>
#include <dali/internal/accessibility/bridge/bridge-text.h>
-#include <dali/internal/accessibility/bridge/bridge-editable-text.h>
+#include <dali/internal/accessibility/bridge/bridge-value.h>
using namespace Dali::Accessibility;
public BridgeText,
public BridgeEditableText
{
- DBus::DBusClient listenOnAtspiEnabledSignalClient;
- DBus::DBusClient registryClient, directReadingClient;
- bool screenReaderEnabled = false;
- bool isEnabled = false;
- bool isShown = false;
- std::unordered_map <int32_t, std::function<void(std::string)>> directReadingCallbacks;
- Dali::Actor highlightedActor;
- std::function<void(Dali::Actor)> highlightClearAction;
+ DBus::DBusClient listenOnAtspiEnabledSignalClient;
+ DBus::DBusClient registryClient, directReadingClient;
+ bool screenReaderEnabled = false;
+ bool isEnabled = false;
+ bool isShown = false;
+ std::unordered_map<int32_t, std::function<void(std::string)>> directReadingCallbacks;
+ Dali::Actor highlightedActor;
+ std::function<void(Dali::Actor)> highlightClearAction;
public:
BridgeImpl()
{
- listenOnAtspiEnabledSignalClient = DBus::DBusClient{ A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION };
+ listenOnAtspiEnabledSignalClient = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION};
- listenOnAtspiEnabledSignalClient.addPropertyChangedEvent< bool >( "ScreenReaderEnabled", [this]( bool res )
+ listenOnAtspiEnabledSignalClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
+ screenReaderEnabled = res;
+ if(screenReaderEnabled || isEnabled)
{
- screenReaderEnabled = res;
- if( screenReaderEnabled || isEnabled )
- {
- ForceUp();
- }
- else
- {
- ForceDown();
- }
+ ForceUp();
}
- );
+ else
+ {
+ ForceDown();
+ }
+ });
- listenOnAtspiEnabledSignalClient.addPropertyChangedEvent< bool >( "IsEnabled", [this]( bool res )
+ listenOnAtspiEnabledSignalClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) {
+ isEnabled = res;
+ if(screenReaderEnabled || isEnabled)
+ {
+ ForceUp();
+ }
+ else
{
- isEnabled = res;
- if( screenReaderEnabled || isEnabled )
- {
- ForceUp();
- }
- else
- {
- ForceDown();
- }
+ ForceDown();
}
- );
+ });
}
- Consumed Emit( KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText ) override
+ Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) override
{
- if (!IsUp())
+ if(!IsUp())
{
return Consumed::NO;
}
unsigned int evType = 0;
- switch( type )
+ switch(type)
{
case KeyEventType::KEY_PRESSED:
{
return Consumed::NO;
}
}
- auto m = registryClient.method< bool( std::tuple< uint32_t, int32_t, int32_t, int32_t, int32_t, std::string, bool > ) >( "NotifyListenersSync" );
- auto result = m.call( std::tuple< uint32_t, int32_t, int32_t, int32_t, int32_t, std::string, bool >{evType, 0, static_cast< int32_t >( keyCode ), 0, static_cast< int32_t >( timeStamp ), keyName, isText ? 1 : 0} );
- if( !result )
+ auto m = registryClient.method<bool(std::tuple<uint32_t, int32_t, int32_t, int32_t, int32_t, std::string, bool>)>("NotifyListenersSync");
+ auto result = m.call(std::tuple<uint32_t, int32_t, int32_t, int32_t, int32_t, std::string, bool>{evType, 0, static_cast<int32_t>(keyCode), 0, static_cast<int32_t>(timeStamp), keyName, isText ? 1 : 0});
+ if(!result)
{
LOG() << result.getError().message;
return Consumed::NO;
}
- return std::get< 0 >( result ) ? Consumed::YES : Consumed::NO;
+ return std::get<0>(result) ? Consumed::YES : Consumed::NO;
}
void Pause() override
{
- if (!IsUp())
+ if(!IsUp())
{
return;
}
- directReadingClient.method< DBus::ValueOrError< void >( bool ) > ( "PauseResume" ).asyncCall(
- []( DBus::ValueOrError< void > msg ) {
- if (!msg)
- {
- LOG() << "Direct reading command failed (" << msg.getError().message << ")";
- }
- },
- true);
+ directReadingClient.method<DBus::ValueOrError<void>(bool)>("PauseResume").asyncCall([](DBus::ValueOrError<void> msg) {
+ if(!msg)
+ {
+ LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+ }
+ },
+ true);
}
void Resume() override
{
- if (!IsUp())
+ if(!IsUp())
{
return;
}
- directReadingClient.method< DBus::ValueOrError< void >( bool ) > ( "PauseResume" ).asyncCall(
- []( DBus::ValueOrError< void > msg) {
- if (!msg)
- {
- LOG() << "Direct reading command failed (" << msg.getError().message << ")";
- }
- },
- false);
+ directReadingClient.method<DBus::ValueOrError<void>(bool)>("PauseResume").asyncCall([](DBus::ValueOrError<void> msg) {
+ if(!msg)
+ {
+ LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+ }
+ },
+ false);
}
- void Say( const std::string& text, bool discardable, std::function< void(std::string) > callback ) override
+ void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) override
{
- if (!IsUp())
+ if(!IsUp())
{
return;
}
- directReadingClient.method< DBus::ValueOrError< std::string, bool, int32_t >( std::string, bool ) > ( "ReadCommand" ).asyncCall(
- [=]( DBus::ValueOrError<std::string, bool, int32_t> msg ) {
- if ( !msg )
- {
- LOG() << "Direct reading command failed (" << msg.getError().message << ")";
- }
- else if( callback )
- {
- directReadingCallbacks.emplace( std::get< 2 >( msg ), callback);
- }
- },
- text,
- discardable);
+ directReadingClient.method<DBus::ValueOrError<std::string, bool, int32_t>(std::string, bool)>("ReadCommand").asyncCall([=](DBus::ValueOrError<std::string, bool, int32_t> msg) {
+ if(!msg)
+ {
+ LOG() << "Direct reading command failed (" << msg.getError().message << ")";
+ }
+ else if(callback)
+ {
+ directReadingCallbacks.emplace(std::get<2>(msg), callback);
+ }
+ },
+ text,
+ discardable);
}
void ForceDown() override
{
- if (data)
+ if(data)
{
- if (data->currentlyHighlightedActor && data->highlightActor)
+ if(data->currentlyHighlightedActor && data->highlightActor)
{
data->currentlyHighlightedActor.Remove(data->highlightActor);
}
data->currentlyHighlightedActor = {};
- data->highlightActor = {};
+ data->highlightActor = {};
}
- highlightedActor = {};
+ highlightedActor = {};
highlightClearAction = {};
BridgeAccessible::ForceDown();
- registryClient = {};
+ registryClient = {};
directReadingClient = {};
directReadingCallbacks.clear();
}
void Terminate() override
{
- if (data)
+ if(data)
{
data->currentlyHighlightedActor = {};
- data->highlightActor = {};
+ data->highlightActor = {};
}
ForceDown();
listenOnAtspiEnabledSignalClient = {};
- dbusServer = {};
- con = {};
+ dbusServer = {};
+ con = {};
}
ForceUpResult ForceUp() override
{
- if( BridgeAccessible::ForceUp() == ForceUpResult::ALREADY_UP )
+ if(BridgeAccessible::ForceUp() == ForceUpResult::ALREADY_UP)
{
return ForceUpResult::ALREADY_UP;
}
BridgeText::RegisterInterfaces();
BridgeEditableText::RegisterInterfaces();
- RegisterOnBridge( &application );
+ RegisterOnBridge(&application);
- registryClient = { AtspiDbusNameRegistry, AtspiDbusPathDec, AtspiDbusInterfaceDec, con };
- directReadingClient = DBus::DBusClient{ DirectReadingDBusName, DirectReadingDBusPath, DirectReadingDBusInterface, con };
- directReadingClient.addSignal< void(int32_t, std::string) >( "ReadingStateChanged", [=]( int32_t id, std::string readingState )
+ registryClient = {AtspiDbusNameRegistry, AtspiDbusPathDec, AtspiDbusInterfaceDec, con};
+ directReadingClient = DBus::DBusClient{DirectReadingDBusName, DirectReadingDBusPath, DirectReadingDBusInterface, con};
+ directReadingClient.addSignal<void(int32_t, std::string)>("ReadingStateChanged", [=](int32_t id, std::string readingState) {
+ auto it = directReadingCallbacks.find(id);
+ if(it != directReadingCallbacks.end())
{
- auto it = directReadingCallbacks.find( id );
- if (it != directReadingCallbacks.end())
- {
- it->second( readingState );
- if (readingState != "ReadingPaused" && readingState != "ReadingResumed" && readingState != "ReadingStarted")
- directReadingCallbacks.erase( it );
- }
+ it->second(readingState);
+ if(readingState != "ReadingPaused" && readingState != "ReadingResumed" && readingState != "ReadingStarted")
+ directReadingCallbacks.erase(it);
}
- );
+ });
- auto proxy = DBus::DBusClient{AtspiDbusNameRegistry, AtspiDbusPathRoot, AtspiDbusInterfaceSocket, con};
+ auto proxy = DBus::DBusClient{AtspiDbusNameRegistry, AtspiDbusPathRoot, AtspiDbusInterfaceSocket, con};
Address root{"", "root"};
- auto res = proxy.method< Address( Address ) >( "Embed" ).call( root );
- if (!res)
+ auto res = proxy.method<Address(Address)>("Embed").call(root);
+ if(!res)
{
LOG() << "Call to Embed failed: " << res.getError().message;
}
- assert( res );
- application.parent.SetAddress( std::move( std::get< 0 >( res ) ) );
- if (isShown)
+ assert(res);
+ application.parent.SetAddress(std::move(std::get<0>(res)));
+ if(isShown)
{
EmitActivate();
}
void EmitActivate()
{
auto win = application.getActiveWindow();
- if (win)
+ if(win)
{
- win->Emit( WindowEvent::ACTIVATE, 0 );
+ win->Emit(WindowEvent::ACTIVATE, 0);
}
}
void EmitDeactivate()
{
auto win = application.getActiveWindow();
- if (win)
+ if(win)
{
- win->Emit( WindowEvent::DEACTIVATE, 0 );
+ win->Emit(WindowEvent::DEACTIVATE, 0);
}
}
void ApplicationHidden() override
{
- if ( isShown && IsUp() )
+ if(isShown && IsUp())
{
EmitDeactivate();
}
void ApplicationShown() override
{
- if ( !isShown && IsUp() )
+ if(!isShown && IsUp())
{
EmitActivate();
}
void Initialize() override
{
auto req = DBus::DBusClient{A11yDbusName, A11yDbusPath, A11yDbusStatusInterface, DBus::ConnectionType::SESSION};
- auto p = req.property< bool >( "ScreenReaderEnabled" ).get();
- if( p )
+ auto p = req.property<bool>("ScreenReaderEnabled").get();
+ if(p)
{
- screenReaderEnabled = std::get< 0 >( p );
+ screenReaderEnabled = std::get<0>(p);
}
- p = req.property< bool >( "IsEnabled" ).get();
- if( p )
+ p = req.property<bool>("IsEnabled").get();
+ if(p)
{
- isEnabled = std::get< 0 >( p );
+ isEnabled = std::get<0>(p);
}
- if( screenReaderEnabled || isEnabled )
+ if(screenReaderEnabled || isEnabled)
{
ForceUp();
}
{
return isEnabled;
}
-
};
Bridge* Bridge::GetCurrentBridge()
{
- static BridgeImpl *bridge = new BridgeImpl;
+ static BridgeImpl* bridge = new BridgeImpl;
return bridge;
}
-
/*
- * Copyright (c) 2019 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.
// dbusServer.addInterface("/", desc, true);
}
-void BridgeObject::EmitActiveDescendantChanged( Accessible* obj, Accessible *child )
+void BridgeObject::EmitActiveDescendantChanged(Accessible* obj, Accessible* child)
{
- if (!IsUp()) return;
+ if(!IsUp()) return;
auto index = child->GetIndexInParent();
- auto addr = obj->GetAddress();
- const auto prefixPath = "/org/a11y/atspi/accessible/";
- const auto nullPath = "/org/a11y/atspi/null";
+ auto addr = obj->GetAddress();
+ const auto prefixPath = "/org/a11y/atspi/accessible/";
+ const auto nullPath = "/org/a11y/atspi/null";
std::string p;
- if( addr )
+ if(addr)
p = prefixPath + addr.GetPath();
else
p = nullPath;
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< Address >, Address >(
- p,
- AtspiDbusInterfaceEventObject,
- "ActiveDescendantChanged",
- "",
- index,
- 0,
- { child->GetAddress() },
- {"", "root"} );
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<Address>, Address>(
+ p,
+ AtspiDbusInterfaceEventObject,
+ "ActiveDescendantChanged",
+ "",
+ index,
+ 0,
+ {child->GetAddress()},
+ {"", "root"});
}
-void BridgeObject::Emit( Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent ev )
+void BridgeObject::Emit(Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent ev)
{
- if (!IsUp()) return;
+ if(!IsUp()) return;
const char* name = nullptr;
- switch( ev )
+ switch(ev)
{
case ObjectPropertyChangeEvent::NAME:
{
break;
}
}
- if( name )
+ if(name)
{
- auto addr = obj->GetAddress();
+ auto addr = obj->GetAddress();
std::string p;
- if( addr )
+ if(addr)
p = ATSPI_PREFIX_PATH + addr.GetPath();
else
p = ATSPI_NULL_PATH;
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< int >, Address >(
- p,
- AtspiDbusInterfaceEventObject,
- "PropertyChange",
- name,
- 0,
- 0,
- {0},
- {"", "root"} );
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
+ p,
+ AtspiDbusInterfaceEventObject,
+ "PropertyChange",
+ name,
+ 0,
+ 0,
+ {0},
+ {"", "root"});
}
}
-void BridgeObject::Emit( Accessible* obj, WindowEvent we, unsigned int detail1 )
+void BridgeObject::Emit(Accessible* obj, WindowEvent we, unsigned int detail1)
{
- if (!IsUp()) return;
+ if(!IsUp()) return;
const char* name = nullptr;
- switch( we )
+ switch(we)
{
case WindowEvent::PROPERTY_CHANGE:
{
break;
}
}
- if( name )
+ if(name)
{
- auto addr = obj->GetAddress();
+ auto addr = obj->GetAddress();
std::string p;
- if( addr )
+ if(addr)
p = ATSPI_PREFIX_PATH + addr.GetPath();
else
p = ATSPI_NULL_PATH;
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< int >, Address >(
- p,
- AtspiDbusInterfaceEventWindow,
- name,
- "",
- detail1,
- 0,
- {0},
- {"", "root"} );
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
+ p,
+ AtspiDbusInterfaceEventWindow,
+ name,
+ "",
+ detail1,
+ 0,
+ {0},
+ {"", "root"});
}
}
-void BridgeObject::EmitStateChanged( Accessible* obj, State state, int newValue1, int newValue2 )
+void BridgeObject::EmitStateChanged(Accessible* obj, State state, int newValue1, int newValue2)
{
- if (!IsUp()) return;
+ if(!IsUp()) return;
const char* stateName = nullptr;
- switch( state )
+ switch(state)
{
case State::INVALID:
{
break;
}
}
- if( stateName )
+ if(stateName)
{
- auto addr = obj->GetAddress();
+ auto addr = obj->GetAddress();
std::string p;
- if( addr )
+ if(addr)
p = ATSPI_PREFIX_PATH + addr.GetPath();
else
p = ATSPI_NULL_PATH;
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< int >, Address >(
- p,
- AtspiDbusInterfaceEventObject,
- "StateChanged",
- stateName,
- newValue1,
- newValue2,
- {0},
- {"", "root"} );
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
+ p,
+ AtspiDbusInterfaceEventObject,
+ "StateChanged",
+ stateName,
+ newValue1,
+ newValue2,
+ {0},
+ {"", "root"});
}
}
-void BridgeObject::EmitBoundsChanged( Accessible* obj, Dali::Rect<> rect )
+void BridgeObject::EmitBoundsChanged(Accessible* obj, Dali::Rect<> rect)
{
- auto addr = obj->GetAddress();
- const auto prefixPath = "/org/a11y/atspi/accessible/";
- const auto nullPath = "/org/a11y/atspi/null";
+ auto addr = obj->GetAddress();
+ const auto prefixPath = "/org/a11y/atspi/accessible/";
+ const auto nullPath = "/org/a11y/atspi/null";
std::string p;
- if( addr )
+ if(addr)
p = prefixPath + addr.GetPath();
else
p = nullPath;
- DBus::EldbusVariant< std::tuple<int32_t, int32_t, int32_t, int32_t> > tmp {
- std::tuple<int32_t, int32_t, int32_t, int32_t>{ rect.x, rect.y, rect.width, rect.height } };
+ DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> > tmp{
+ std::tuple<int32_t, int32_t, int32_t, int32_t>{rect.x, rect.y, rect.width, rect.height}};
addFilteredEvent(FilteredEvents::boundsChanged, obj, 1.0f, [=]() {
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< std::tuple<int32_t, int32_t, int32_t, int32_t> >, Address >(
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::tuple<int32_t, int32_t, int32_t, int32_t> >, Address>(
p,
AtspiDbusInterfaceEventObject,
"BoundsChanged",
0,
0,
tmp,
- {"", "root"} );
+ {"", "root"});
});
}
-void BridgeObject::EmitCaretMoved( Accessible* obj, unsigned int cursorPosition )
+void BridgeObject::EmitCaretMoved(Accessible* obj, unsigned int cursorPosition)
{
- auto addr = obj->GetAddress();
- std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< int >, Address >(
+ auto addr = obj->GetAddress();
+ std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<int>, Address>(
p,
AtspiDbusInterfaceEventObject,
"TextCaretMoved",
cursorPosition,
0,
{0},
- {"", "root"} );
+ {"", "root"});
}
-void BridgeObject::EmitTextChanged( Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string &content )
+void BridgeObject::EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content)
{
const char* stateName = nullptr;
- switch( state )
+ switch(state)
{
case TextChangedState::INSERTED:
{
break;
}
}
- if( stateName )
+ if(stateName)
{
- auto addr = obj->GetAddress();
- std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
- dbusServer.emit2< std::string, int, int, DBus::EldbusVariant< std::string >, Address >(
- p,
- AtspiDbusInterfaceEventObject,
- "TextChanged",
- stateName,
- position,
- length,
- {content},
- {"", "root"} );
+ auto addr = obj->GetAddress();
+ std::string p = addr ? ATSPI_PREFIX_PATH + addr.GetPath() : ATSPI_NULL_PATH;
+ dbusServer.emit2<std::string, int, int, DBus::EldbusVariant<std::string>, Address>(
+ p,
+ AtspiDbusInterfaceEventObject,
+ "TextChanged",
+ stateName,
+ position,
+ length,
+ {content},
+ {"", "root"});
}
}
/*
- * Copyright (c) 2019 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 BridgeText::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceText};
- AddFunctionToInterface( desc, "GetText", &BridgeText::GetText );
- AddGetPropertyToInterface( desc, "CharacterCount", &BridgeText::GetCharacterCount );
- AddGetPropertyToInterface( desc, "CaretOffset", &BridgeText::GetCaretOffset );
- AddFunctionToInterface( desc, "SetCaretOffset", &BridgeText::SetCaretOffset );
- AddFunctionToInterface( desc, "GetTextAtOffset", &BridgeText::GetTextAtOffset );
- AddFunctionToInterface( desc, "GetSelection", &BridgeText::GetSelection );
- AddFunctionToInterface( desc, "SetSelection", &BridgeText::SetSelection );
- AddFunctionToInterface( desc, "RemoveSelection", &BridgeText::RemoveSelection );
- dbusServer.addInterface( "/", desc, true );
+ AddFunctionToInterface(desc, "GetText", &BridgeText::GetText);
+ AddGetPropertyToInterface(desc, "CharacterCount", &BridgeText::GetCharacterCount);
+ AddGetPropertyToInterface(desc, "CaretOffset", &BridgeText::GetCaretOffset);
+ AddFunctionToInterface(desc, "SetCaretOffset", &BridgeText::SetCaretOffset);
+ AddFunctionToInterface(desc, "GetTextAtOffset", &BridgeText::GetTextAtOffset);
+ AddFunctionToInterface(desc, "GetSelection", &BridgeText::GetSelection);
+ AddFunctionToInterface(desc, "SetSelection", &BridgeText::SetSelection);
+ AddFunctionToInterface(desc, "RemoveSelection", &BridgeText::RemoveSelection);
+ dbusServer.addInterface("/", desc, true);
}
Text* BridgeText::FindSelf() const
{
auto s = BridgeBase::FindSelf();
- assert( s );
- auto s2 = dynamic_cast< Text* >( s );
- if( !s2 )
+ assert(s);
+ auto s2 = dynamic_cast<Text*>(s);
+ if(!s2)
throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Text interface"};
return s2;
}
-DBus::ValueOrError< std::string > BridgeText::GetText( int startOffset, int endOffset )
+DBus::ValueOrError<std::string> BridgeText::GetText(int startOffset, int endOffset)
{
- return FindSelf()->GetText( startOffset, endOffset );
+ return FindSelf()->GetText(startOffset, endOffset);
}
-DBus::ValueOrError< int32_t > BridgeText::GetCharacterCount()
+DBus::ValueOrError<int32_t> BridgeText::GetCharacterCount()
{
return FindSelf()->GetCharacterCount();
}
-DBus::ValueOrError< int32_t > BridgeText::GetCaretOffset()
+DBus::ValueOrError<int32_t> BridgeText::GetCaretOffset()
{
return FindSelf()->GetCaretOffset();
}
-DBus::ValueOrError< bool > BridgeText::SetCaretOffset( int32_t offset )
+DBus::ValueOrError<bool> BridgeText::SetCaretOffset(int32_t offset)
{
return FindSelf()->SetCaretOffset(offset);
}
-DBus::ValueOrError< std::string, int, int > BridgeText::GetTextAtOffset( int32_t offset, uint32_t boundary )
+DBus::ValueOrError<std::string, int, int> BridgeText::GetTextAtOffset(int32_t offset, uint32_t boundary)
{
- auto r = FindSelf()->GetTextAtOffset( offset, static_cast< TextBoundary >( boundary ) );
- return {r.content, static_cast< int >( r.startOffset ), static_cast< int >( r.endOffset )};
+ auto r = FindSelf()->GetTextAtOffset(offset, static_cast<TextBoundary>(boundary));
+ return {r.content, static_cast<int>(r.startOffset), static_cast<int>(r.endOffset)};
}
-DBus::ValueOrError< int, int > BridgeText::GetSelection( int32_t selectionNum )
+DBus::ValueOrError<int, int> BridgeText::GetSelection(int32_t selectionNum)
{
- auto r = FindSelf()->GetSelection( selectionNum );
- return {static_cast< int >( r.startOffset ), static_cast< int >( r.endOffset )};
+ auto r = FindSelf()->GetSelection(selectionNum);
+ return {static_cast<int>(r.startOffset), static_cast<int>(r.endOffset)};
}
-DBus::ValueOrError< bool > BridgeText::RemoveSelection( int32_t selectionNum )
+DBus::ValueOrError<bool> BridgeText::RemoveSelection(int32_t selectionNum)
{
- return FindSelf()->RemoveSelection( selectionNum );
+ return FindSelf()->RemoveSelection(selectionNum);
}
-DBus::ValueOrError< bool > BridgeText::SetSelection( int32_t selectionNum, int32_t startOffset, int32_t endOffset )
+DBus::ValueOrError<bool> BridgeText::SetSelection(int32_t selectionNum, int32_t startOffset, int32_t endOffset)
{
- return FindSelf()->SetSelection( selectionNum, startOffset, endOffset );
+ return FindSelf()->SetSelection(selectionNum, startOffset, endOffset);
}
/*
- * Copyright (c) 2019 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 BridgeValue::RegisterInterfaces()
{
DBus::DBusInterfaceDescription desc{AtspiDbusInterfaceValue};
- AddGetSetPropertyToInterface( desc, "CurrentValue", &BridgeValue::GetCurrentValue, &BridgeValue::SetCurrentValue );
- AddGetPropertyToInterface( desc, "MaximumValue", &BridgeValue::GetMaximumValue );
- AddGetPropertyToInterface( desc, "MinimumIncrement", &BridgeValue::GetMinimumIncrement );
- AddGetPropertyToInterface( desc, "MinimumValue", &BridgeValue::GetMinimumValue );
- dbusServer.addInterface( "/", desc, true );
+ AddGetSetPropertyToInterface(desc, "CurrentValue", &BridgeValue::GetCurrentValue, &BridgeValue::SetCurrentValue);
+ AddGetPropertyToInterface(desc, "MaximumValue", &BridgeValue::GetMaximumValue);
+ AddGetPropertyToInterface(desc, "MinimumIncrement", &BridgeValue::GetMinimumIncrement);
+ AddGetPropertyToInterface(desc, "MinimumValue", &BridgeValue::GetMinimumValue);
+ dbusServer.addInterface("/", desc, true);
}
Value* BridgeValue::FindSelf() const
{
auto s = BridgeBase::FindSelf();
- assert( s );
- auto s2 = dynamic_cast< Value* >( s );
- if( !s2 )
+ assert(s);
+ auto s2 = dynamic_cast<Value*>(s);
+ if(!s2)
throw std::domain_error{"object " + s->GetAddress().ToString() + " doesn't have Value interface"};
return s2;
}
{
return FindSelf()->GetCurrent();
}
-void BridgeValue::SetCurrentValue( double new_value )
+void BridgeValue::SetCurrentValue(double new_value)
{
- FindSelf()->SetCurrent( new_value );
+ FindSelf()->SetCurrent(new_value);
}
double BridgeValue::GetMaximumValue()
{
/*
- * Copyright (c) 2019 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.
using namespace Dali::Accessibility;
-bool Component::Contains( Point p, CoordType ctype )
+bool Component::Contains(Point p, CoordType ctype)
{
- auto extents = GetExtents( ctype );
+ auto extents = GetExtents(ctype);
return p.x >= extents.x && p.y >= extents.y && p.x <= extents.x + extents.width && p.y <= extents.y + extents.height;
}
-Accessible* Component::GetAccessibleAtPoint( Point p, CoordType ctype )
+Accessible* Component::GetAccessibleAtPoint(Point p, CoordType ctype)
{
auto children = GetChildren();
- for( auto childIt = children.rbegin(); childIt != children.rend(); childIt++ )
+ for(auto childIt = children.rbegin(); childIt != children.rend(); childIt++)
{
- auto component = dynamic_cast< Component* >( *childIt );
- if( component && component->Contains( p, ctype ) )
+ auto component = dynamic_cast<Component*>(*childIt);
+ if(component && component->Contains(p, ctype))
{
return component;
}
*/
// CLASS HEADER
-#include <dali/internal/accessibility/bridge/dbus.h>
#include <dali/internal/accessibility/bridge/accessibility-common.h>
+#include <dali/internal/accessibility/bridge/dbus.h>
// EXTERNAL INCLUDES
-#include <sstream>
#include <iostream>
#include <mutex>
+#include <sstream>
-#include <Eldbus.h>
#include <Ecore_Input.h>
+#include <Eldbus.h>
// INTERNAL INCLUDES
#include <dali/public-api/dali-adaptor-common.h>
#undef EINA_FALSE
#undef EINA_TRUE
-#define EINA_TRUE static_cast< Eina_Bool >( 1 )
-#define EINA_FALSE static_cast< Eina_Bool >( 0 )
+#define EINA_TRUE static_cast<Eina_Bool>(1)
+#define EINA_FALSE static_cast<Eina_Bool>(0)
//#define DBUS_DEBUG(...) do { DBus::debugPrint(__FILE__, __LINE__, __VA_ARGS__); } while (0)
-std::atomic< unsigned int > DBus::detail::CallId::LastId{0};
-static std::function< void( const char*, size_t ) > debugPrinter;
-static std::mutex debugLock;
+std::atomic<unsigned int> DBus::detail::CallId::LastId{0};
+static std::function<void(const char*, size_t)> debugPrinter;
+static std::mutex debugLock;
-thread_local std::string DBus::DBusServer::currentObjectPath;
+thread_local std::string DBus::DBusServer::currentObjectPath;
thread_local DBusWrapper::ConnectionPtr DBus::DBusServer::currentConnection;
-void DBus::setDebugPrinter( std::function< void( const char*, size_t ) > printer )
+void DBus::setDebugPrinter(std::function<void(const char*, size_t)> printer)
{
- std::lock_guard< std::mutex > lock( debugLock );
- debugPrinter = std::move( printer );
+ std::lock_guard<std::mutex> lock(debugLock);
+ debugPrinter = std::move(printer);
}
-void DBus::debugPrint( const char* file, size_t line, const char* format, ... )
+void DBus::debugPrint(const char* file, size_t line, const char* format, ...)
{
- std::function< void( const char*, size_t ) > debugPrintFunc;
+ std::function<void(const char*, size_t)> debugPrintFunc;
{
- std::lock_guard< std::mutex > lock( debugLock );
- if( !debugPrinter )
+ std::lock_guard<std::mutex> lock(debugLock);
+ if(!debugPrinter)
return;
debugPrintFunc = debugPrinter;
}
- std::vector< char > buf( 4096 );
- int offset;
- while( true )
+ std::vector<char> buf(4096);
+ int offset;
+ while(true)
{
- offset = snprintf( buf.data(), buf.size(), "%s:%u: ", file, static_cast< unsigned int >( line ) );
- if( offset < 0 )
+ offset = snprintf(buf.data(), buf.size(), "%s:%u: ", file, static_cast<unsigned int>(line));
+ if(offset < 0)
return;
- if( static_cast< size_t >( offset ) < buf.size() )
+ if(static_cast<size_t>(offset) < buf.size())
break;
- buf.resize( offset + 1 );
+ buf.resize(offset + 1);
}
- while( true )
+ while(true)
{
va_list args;
- va_start( args, format );
- int z = vsnprintf( buf.data() + offset, buf.size() - offset, format, args );
- va_end( args );
- if( z < 0 )
+ va_start(args, format);
+ int z = vsnprintf(buf.data() + offset, buf.size() - offset, format, args);
+ va_end(args);
+ if(z < 0)
return;
- bool done = static_cast< size_t >( z ) + static_cast< size_t >( offset ) < buf.size();
- buf.resize( static_cast< size_t >( z ) + static_cast< size_t >( offset ) );
- if( done )
+ bool done = static_cast<size_t>(z) + static_cast<size_t>(offset) < buf.size();
+ buf.resize(static_cast<size_t>(z) + static_cast<size_t>(offset));
+ if(done)
break;
}
- debugPrintFunc( buf.data(), buf.size() );
+ debugPrintFunc(buf.data(), buf.size());
}
-DBusWrapper::ConnectionPtr DBus::getDBusConnectionByName( const std::string& name )
+DBusWrapper::ConnectionPtr DBus::getDBusConnectionByName(const std::string& name)
{
- return DBUS_W->eldbus_address_connection_get_impl( name );
+ return DBUS_W->eldbus_address_connection_get_impl(name);
}
-DBusWrapper::ConnectionPtr DBus::getDBusConnectionByType( ConnectionType connectionType )
+DBusWrapper::ConnectionPtr DBus::getDBusConnectionByType(ConnectionType connectionType)
{
return DBUS_W->eldbus_connection_get_impl(connectionType);
}
-DBus::DBusClient::DBusClient( std::string busName, std::string pathName, std::string interfaceName, ConnectionType tp ) : DBusClient( std::move( busName ), std::move( pathName ), std::move( interfaceName ), getDBusConnectionByType( tp ) )
+DBus::DBusClient::DBusClient(std::string busName, std::string pathName, std::string interfaceName, ConnectionType tp)
+: DBusClient(std::move(busName), std::move(pathName), std::move(interfaceName), getDBusConnectionByType(tp))
{
}
-DBus::DBusClient::DBusClient( std::string busName, std::string pathName, std::string interfaceName, const DBusWrapper::ConnectionPtr &conn )
+DBus::DBusClient::DBusClient(std::string busName, std::string pathName, std::string interfaceName, const DBusWrapper::ConnectionPtr& conn)
{
- if( !conn )
- connectionState->connection = getDBusConnectionByType( ConnectionType::SESSION );
+ if(!conn)
+ connectionState->connection = getDBusConnectionByType(ConnectionType::SESSION);
else
connectionState->connection = conn;
std::ostringstream o;
- o << "bus = " << busName << " path = " << pathName << " connection = " << DBUS_W->eldbus_connection_unique_name_get_impl( connectionState->connection );
+ o << "bus = " << busName << " path = " << pathName << " connection = " << DBUS_W->eldbus_connection_unique_name_get_impl(connectionState->connection);
info = o.str();
- connectionState->object = DBUS_W->eldbus_object_get_impl( connectionState->connection, busName.c_str(), pathName.c_str() );
- if( connectionState->object )
+ connectionState->object = DBUS_W->eldbus_object_get_impl(connectionState->connection, busName.c_str(), pathName.c_str());
+ if(connectionState->object)
{
- connectionState->proxy = DBUS_W->eldbus_proxy_get_impl( connectionState->object, interfaceName );
- if( interfaceName != DBUS_INTERFACE_PROPERTIES )
+ connectionState->proxy = DBUS_W->eldbus_proxy_get_impl(connectionState->object, interfaceName);
+ if(interfaceName != DBUS_INTERFACE_PROPERTIES)
{
- connectionState->propertiesProxy = DBUS_W->eldbus_proxy_get_impl( connectionState->object, DBUS_INTERFACE_PROPERTIES );
+ connectionState->propertiesProxy = DBUS_W->eldbus_proxy_get_impl(connectionState->object, DBUS_INTERFACE_PROPERTIES);
}
else
{
- connectionState->propertiesProxy = DBUS_W->eldbus_proxy_copy_impl( connectionState->proxy );
+ connectionState->propertiesProxy = DBUS_W->eldbus_proxy_copy_impl(connectionState->proxy);
}
}
- connectionInfo = std::make_shared< ConnectionInfo >();
- connectionInfo->busName = std::move( busName );
- connectionInfo->pathName = std::move( pathName );
- connectionInfo->interfaceName = std::move( interfaceName );
+ connectionInfo = std::make_shared<ConnectionInfo>();
+ connectionInfo->busName = std::move(busName);
+ connectionInfo->pathName = std::move(pathName);
+ connectionInfo->interfaceName = std::move(interfaceName);
}
-DBus::DBusServer::DBusServer( ConnectionType tp ) : DBus::DBusServer( DBus::getDBusConnectionByType( tp ) )
+DBus::DBusServer::DBusServer(ConnectionType tp)
+: DBus::DBusServer(DBus::getDBusConnectionByType(tp))
{
}
-DBus::DBusServer::DBusServer( const DBusWrapper::ConnectionPtr &conn )
+DBus::DBusServer::DBusServer(const DBusWrapper::ConnectionPtr& conn)
{
- if( !conn )
- connection = getDBusConnectionByType( ConnectionType::SESSION );
+ if(!conn)
+ connection = getDBusConnectionByType(ConnectionType::SESSION);
else
connection = conn;
}
-DBus::DBusInterfaceDescription::DBusInterfaceDescription( std::string interfaceName ) : interfaceName( std::move( interfaceName ) )
+DBus::DBusInterfaceDescription::DBusInterfaceDescription(std::string interfaceName)
+: interfaceName(std::move(interfaceName))
{
}
-void DBus::DBusServer::addInterface( const std::string& pathName, DBusInterfaceDescription& dscr, bool fallback )
+void DBus::DBusServer::addInterface(const std::string& pathName, DBusInterfaceDescription& dscr, bool fallback)
{
- DBUS_W->add_interface_impl( fallback, pathName, connection, destructorObject->destructors, dscr.interfaceName, dscr.methods, dscr.properties, dscr.signals );
+ DBUS_W->add_interface_impl(fallback, pathName, connection, destructorObject->destructors, dscr.interfaceName, dscr.methods, dscr.properties, dscr.signals);
}
std::string DBus::DBusServer::getBusName() const
{
- return getConnectionName( connection );
+ return getConnectionName(connection);
}
-std::string DBus::getConnectionName( const DBusWrapper::ConnectionPtr &c )
+std::string DBus::getConnectionName(const DBusWrapper::ConnectionPtr& c)
{
- return DBUS_W->eldbus_connection_unique_name_get_impl( c );
+ return DBUS_W->eldbus_connection_unique_name_get_impl(c);
}
-bool DBus::DBusClient::getFromEinaValue(const _Eina_Value *v, void *dst)
+bool DBus::DBusClient::getFromEinaValue(const _Eina_Value* v, void* dst)
{
return eina_value_get(const_cast<Eina_Value*>(v), dst);
}
{
}
- #define DEFINE_GS(name, eldbus_name, unref_call) \
- static eldbus_name *get(const std::shared_ptr<name> &a) { \
- return static_cast<name ## Impl*>(a.get())->Value; \
- } \
- static eldbus_name *release(const std::shared_ptr<name> &a) { \
- auto z = static_cast<name ## Impl*>(a.get())->Value; \
- static_cast<name ## Impl*>(a.get())->Value = nullptr; \
- return z; \
- } \
- template <typename ... ARGS> static std::shared_ptr<name> create(const eldbus_name *v, ARGS && ... args) { \
- return std::make_shared<name ## Impl>(const_cast<eldbus_name*>(v), std::forward<ARGS>(args)...); \
- }
-
- #define DEFINE_TYPE(name, eldbus_name, unref_call) \
- struct name ## Impl : public name { \
- eldbus_name *Value = nullptr; \
- bool EraseOnExit = false; \
- name ## Impl(eldbus_name *Value, bool EraseOnExit = false) : Value(Value), EraseOnExit(EraseOnExit) { } \
- ~name ## Impl() { \
- if (EraseOnExit && Value) { unref_call; } \
- } \
- }; \
+#define DEFINE_GS(name, eldbus_name, unref_call) \
+ static eldbus_name* get(const std::shared_ptr<name>& a) \
+ { \
+ return static_cast<name##Impl*>(a.get())->Value; \
+ } \
+ static eldbus_name* release(const std::shared_ptr<name>& a) \
+ { \
+ auto z = static_cast<name##Impl*>(a.get())->Value; \
+ static_cast<name##Impl*>(a.get())->Value = nullptr; \
+ return z; \
+ } \
+ template<typename... ARGS> \
+ static std::shared_ptr<name> create(const eldbus_name* v, ARGS&&... args) \
+ { \
+ return std::make_shared<name##Impl>(const_cast<eldbus_name*>(v), std::forward<ARGS>(args)...); \
+ }
+
+#define DEFINE_TYPE(name, eldbus_name, unref_call) \
+ struct name##Impl : public name \
+ { \
+ eldbus_name* Value = nullptr; \
+ bool EraseOnExit = false; \
+ name##Impl(eldbus_name* Value, bool EraseOnExit = false): Value(Value), \
+ EraseOnExit(EraseOnExit) \
+ { \
+ } \
+ ~name##Impl() \
+ { \
+ if(EraseOnExit && Value) \
+ { \
+ unref_call; \
+ } \
+ } \
+ }; \
DEFINE_GS(name, eldbus_name, unref_call)
struct ConnectionImpl : public Connection
{
- Eldbus_Connection *Value = nullptr;
- bool EraseOnExit = false;
- ConnectionImpl(Eldbus_Connection *Value, bool EraseOnExit = false) : Value(Value), EraseOnExit(EraseOnExit)
+ Eldbus_Connection* Value = nullptr;
+ bool EraseOnExit = false;
+ ConnectionImpl(Eldbus_Connection* Value, bool EraseOnExit = false)
+ : Value(Value),
+ EraseOnExit(EraseOnExit)
{
ecore_event_init();
eldbus_init();
~ConnectionImpl()
{
- if (EraseOnExit && Value)
+ if(EraseOnExit && Value)
{
- eldbus_connection_unref( Value );
+ eldbus_connection_unref(Value);
}
eldbus_shutdown();
ecore_event_shutdown();
struct MessageIterImpl : public MessageIter
{
Eldbus_Message_Iter *Value = nullptr, *Parent = nullptr;
- bool EraseOnExit = false;
- MessageIterImpl(Eldbus_Message_Iter *Value, Eldbus_Message_Iter *Parent, bool EraseOnExit = false) : Value(Value), Parent(Parent), EraseOnExit(EraseOnExit)
+ bool EraseOnExit = false;
+ MessageIterImpl(Eldbus_Message_Iter* Value, Eldbus_Message_Iter* Parent, bool EraseOnExit = false)
+ : Value(Value),
+ Parent(Parent),
+ EraseOnExit(EraseOnExit)
{
}
~MessageIterImpl()
{
- if (EraseOnExit && Value && Parent)
+ if(EraseOnExit && Value && Parent)
{
eldbus_message_iter_container_close(Parent, Value);
}
DEFINE_GS(Connection, Eldbus_Connection, )
DEFINE_GS(MessageIter, Eldbus_Message_Iter, )
- DEFINE_TYPE(Message, Eldbus_Message, eldbus_message_unref( Value ))
+ DEFINE_TYPE(Message, Eldbus_Message, eldbus_message_unref(Value))
DEFINE_TYPE(Proxy, Eldbus_Proxy, )
- DEFINE_TYPE(Object, Eldbus_Object, eldbus_object_unref( Value ))
+ DEFINE_TYPE(Object, Eldbus_Object, eldbus_object_unref(Value))
DEFINE_TYPE(Pending, Eldbus_Pending, )
DEFINE_TYPE(EventPropertyChanged, Eldbus_Proxy_Event_Property_Changed, )
- #undef DEFINE_TYPE
+#undef DEFINE_TYPE
- std::shared_ptr<Connection> eldbus_address_connection_get_impl(const std::string &addr) override
+ std::shared_ptr<Connection> eldbus_address_connection_get_impl(const std::string& addr) override
{
eldbus_init();
auto p = eldbus_address_connection_get(addr.c_str());
return w;
}
-#define eldbus_message_iter_arguments_append_impl_basic(type, sig) \
- void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, type src) override { \
- eldbus_message_iter_arguments_append( get(it), #sig, src ); \
- } \
- bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, type &dst) override { \
- return eldbus_message_iter_get_and_next( get(it), (#sig)[0], &dst ); \
+#define eldbus_message_iter_arguments_append_impl_basic(type, sig) \
+ void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, type src) override \
+ { \
+ eldbus_message_iter_arguments_append(get(it), #sig, src); \
+ } \
+ bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, type& dst) override \
+ { \
+ return eldbus_message_iter_get_and_next(get(it), (#sig)[0], &dst); \
}
+ // clang-format off
eldbus_message_iter_arguments_append_impl_basic(uint8_t, y)
eldbus_message_iter_arguments_append_impl_basic(uint16_t, q)
eldbus_message_iter_arguments_append_impl_basic(uint32_t, u)
eldbus_message_iter_arguments_append_impl_basic(int32_t, i)
eldbus_message_iter_arguments_append_impl_basic(int64_t, x)
eldbus_message_iter_arguments_append_impl_basic(double, d)
+ // clang-format on
#undef eldbus_message_iter_arguments_append_impl_basic
- void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, bool src) override
+ void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, bool src) override
{
- eldbus_message_iter_arguments_append( get(it), "b", src ? 1 : 0 );
+ eldbus_message_iter_arguments_append(get(it), "b", src ? 1 : 0);
}
- bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, bool &dst) override
+ bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, bool& dst) override
{
unsigned char q;
- auto z = eldbus_message_iter_get_and_next( get(it), 'b', &q );
- dst = q != 0;
+ auto z = eldbus_message_iter_get_and_next(get(it), 'b', &q);
+ dst = q != 0;
return z;
}
- void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, const std::string &src) override
+ void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, const std::string& src) override
{
- eldbus_message_iter_arguments_append( get(it), "s", src.c_str() );
+ eldbus_message_iter_arguments_append(get(it), "s", src.c_str());
}
- bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, std::string &dst) override
+ bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, std::string& dst) override
{
- auto iter = get(it);
+ auto iter = get(it);
const char* q;
- if( !eldbus_message_iter_get_and_next( iter, 's', &q ) )
+ if(!eldbus_message_iter_get_and_next(iter, 's', &q))
{
- if( !eldbus_message_iter_get_and_next( iter, 'o', &q ) )
+ if(!eldbus_message_iter_get_and_next(iter, 'o', &q))
{
return false;
}
return true;
}
- void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, const ObjectPath &src) override
+ void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, const ObjectPath& src) override
{
- eldbus_message_iter_arguments_append( get(it), "o", src.value.c_str() );
+ eldbus_message_iter_arguments_append(get(it), "o", src.value.c_str());
}
- bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, ObjectPath &dst) override
+ bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, ObjectPath& dst) override
{
const char* q;
- if( !eldbus_message_iter_get_and_next( get(it), 'o', &q ) )
+ if(!eldbus_message_iter_get_and_next(get(it), 'o', &q))
{
return false;
}
return true;
}
- MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr &it, int type, const std::string &sig) override
+ MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr& it, int type, const std::string& sig) override
{
- auto z = eldbus_message_iter_container_new( get(it), type, !sig.empty() ? sig.c_str() : NULL );
+ auto z = eldbus_message_iter_container_new(get(it), type, !sig.empty() ? sig.c_str() : NULL);
return create(z, get(it), true);
}
- MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr &it, int type) override
+ MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr& it, int type) override
{
Eldbus_Message_Iter* entry;
- if (!eldbus_message_iter_get_and_next( get(it), type, &entry ) )
+ if(!eldbus_message_iter_get_and_next(get(it), type, &entry))
{
return {};
}
return create(entry, get(it), false);
}
- MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr &msg, bool) override
+ MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr& msg, bool) override
{
return create(eldbus_message_iter_get(get(msg)), nullptr, false);
}
- MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr &proxy, const std::string &funcName)
+ MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr& proxy, const std::string& funcName)
{
- return create(eldbus_proxy_method_call_new( get(proxy), funcName.c_str() ) );
+ return create(eldbus_proxy_method_call_new(get(proxy), funcName.c_str()));
}
- MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr &proxy, const MessagePtr &msg) override
+ MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr& proxy, const MessagePtr& msg) override
{
- return create(eldbus_proxy_send_and_block(get(proxy), release(msg), ELDBUS_CALL_TIMEOUT) );
+ return create(eldbus_proxy_send_and_block(get(proxy), release(msg), ELDBUS_CALL_TIMEOUT));
}
- bool eldbus_message_error_get_impl(const MessagePtr &msg, std::string &name, std::string &text) override
+ bool eldbus_message_error_get_impl(const MessagePtr& msg, std::string& name, std::string& text) override
{
const char *errname, *errmsg;
- if( eldbus_message_error_get( get(msg), &errname, &errmsg ) )
+ if(eldbus_message_error_get(get(msg), &errname, &errmsg))
{
name = errname;
text = errmsg;
return false;
}
- std::string eldbus_message_signature_get_impl(const MessagePtr &msg) override
+ std::string eldbus_message_signature_get_impl(const MessagePtr& msg) override
{
return eldbus_message_signature_get(get(msg));
}
- static void callAsyncCb( void* data, const Eldbus_Message *msg, Eldbus_Pending *pending )
+ static void callAsyncCb(void* data, const Eldbus_Message* msg, Eldbus_Pending* pending)
{
- auto d = static_cast< SendCallback* >( data );
- (*d)( create(msg, false) );
+ auto d = static_cast<SendCallback*>(data);
+ (*d)(create(msg, false));
}
- static void pendingFreeCb( void* data, const void* )
+ static void pendingFreeCb(void* data, const void*)
{
- auto d = static_cast< SendCallback* >( data );
+ auto d = static_cast<SendCallback*>(data);
delete d;
}
- static void listenerCallbackFree( void* data, const void* )
+ static void listenerCallbackFree(void* data, const void*)
{
- auto d = static_cast< std::function< void( const Eldbus_Message* msg ) >* >( data );
+ auto d = static_cast<std::function<void(const Eldbus_Message* msg)>*>(data);
delete d;
}
- PendingPtr eldbus_proxy_send_impl(const ProxyPtr &proxy, const MessagePtr &msg, const SendCallback &callback) override
+ PendingPtr eldbus_proxy_send_impl(const ProxyPtr& proxy, const MessagePtr& msg, const SendCallback& callback) override
{
- auto cb = new SendCallback{ callback };
- auto pending = eldbus_proxy_send( get(proxy), release(msg), callAsyncCb, cb, ELDBUS_CALL_TIMEOUT );
- if( pending )
+ auto cb = new SendCallback{callback};
+ auto pending = eldbus_proxy_send(get(proxy), release(msg), callAsyncCb, cb, ELDBUS_CALL_TIMEOUT);
+ if(pending)
{
- eldbus_pending_free_cb_add( pending, pendingFreeCb, cb );
+ eldbus_pending_free_cb_add(pending, pendingFreeCb, cb);
}
else
{
return create(pending, false);
}
- std::string eldbus_proxy_interface_get_impl(const ProxyPtr &proxy) override
+ std::string eldbus_proxy_interface_get_impl(const ProxyPtr& proxy) override
{
- return eldbus_proxy_interface_get( get(proxy) );
+ return eldbus_proxy_interface_get(get(proxy));
}
- static void listenerCallback( void* data, const Eldbus_Message* msg )
+ static void listenerCallback(void* data, const Eldbus_Message* msg)
{
- auto p = static_cast< std::function< void( const Eldbus_Message* msg ) >* >( data );
- ( *p )( msg );
+ auto p = static_cast<std::function<void(const Eldbus_Message* msg)>*>(data);
+ (*p)(msg);
}
- void eldbus_proxy_signal_handler_add_impl(const ProxyPtr &proxy, const std::string &member, const std::function<void(const MessagePtr &)> &cb) override
+ void eldbus_proxy_signal_handler_add_impl(const ProxyPtr& proxy, const std::string& member, const std::function<void(const MessagePtr&)>& cb) override
{
- auto tmp = new std::function< void( const Eldbus_Message* msg ) >
- {
- [cb](const Eldbus_Message* msg)
- {
+ auto tmp = new std::function<void(const Eldbus_Message* msg)>{
+ [cb](const Eldbus_Message* msg) {
cb(create(msg, false));
- }
- };
- auto handler = eldbus_proxy_signal_handler_add( get(proxy), member.c_str(), listenerCallback, tmp );
- if( handler )
+ }};
+ auto handler = eldbus_proxy_signal_handler_add(get(proxy), member.c_str(), listenerCallback, tmp);
+ if(handler)
{
- eldbus_proxy_free_cb_add( get(proxy), listenerCallbackFree, tmp );
- }
+ eldbus_proxy_free_cb_add(get(proxy), listenerCallbackFree, tmp);
+ }
else
{
delete tmp;
- }
+ }
}
- std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr &iter) override
+ std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr& iter) override
{
- return eldbus_message_iter_signature_get( get(iter) );
+ return eldbus_message_iter_signature_get(get(iter));
}
- MessagePtr eldbus_message_method_return_new_impl( const MessagePtr &msg) override
+ MessagePtr eldbus_message_method_return_new_impl(const MessagePtr& msg) override
{
- return create(eldbus_message_method_return_new( get(msg) ) );
+ return create(eldbus_message_method_return_new(get(msg)));
}
- MessagePtr eldbus_message_error_new_impl( const MessagePtr &msg, const std::string &err, const std::string &txt ) override
+ MessagePtr eldbus_message_error_new_impl(const MessagePtr& msg, const std::string& err, const std::string& txt) override
{
- return create(eldbus_message_error_new( get(msg), err.c_str(), txt.c_str() ) );
+ return create(eldbus_message_error_new(get(msg), err.c_str(), txt.c_str()));
}
- PendingPtr eldbus_connection_send_impl(const ConnectionPtr &conn, const MessagePtr &msg) override
+ PendingPtr eldbus_connection_send_impl(const ConnectionPtr& conn, const MessagePtr& msg) override
{
- return create(eldbus_connection_send( get(conn), get(msg), NULL, NULL, -1 ) );
+ return create(eldbus_connection_send(get(conn), get(msg), NULL, NULL, -1));
}
- MessagePtr eldbus_message_signal_new_impl(const std::string &path, const std::string &iface, const std::string &name) override
+ MessagePtr eldbus_message_signal_new_impl(const std::string& path, const std::string& iface, const std::string& name) override
{
- return create(eldbus_message_signal_new( path.c_str(), iface.c_str(), name.c_str() ) );
+ return create(eldbus_message_signal_new(path.c_str(), iface.c_str(), name.c_str()));
}
- MessagePtr eldbus_message_ref_impl(const MessagePtr &msg) override
+ MessagePtr eldbus_message_ref_impl(const MessagePtr& msg) override
{
- return create(eldbus_message_ref( get(msg) ), true );
+ return create(eldbus_message_ref(get(msg)), true);
}
ConnectionPtr eldbus_connection_get_impl(ConnectionType type) override
{
Eldbus_Connection_Type eldbusType = ELDBUS_CONNECTION_TYPE_SYSTEM;
- switch( type )
+ switch(type)
{
case ConnectionType::SYSTEM:
{
}
eldbus_init();
- auto p = eldbus_connection_get( eldbusType );
+ auto p = eldbus_connection_get(eldbusType);
auto w = create(p, true);
eldbus_shutdown();
return w;
}
- std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr &conn) override
+ std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr& conn) override
{
- return eldbus_connection_unique_name_get( get(conn) );
+ return eldbus_connection_unique_name_get(get(conn));
}
- ObjectPtr eldbus_object_get_impl( const ConnectionPtr &conn, const std::string &bus, const std::string &path ) override
+ ObjectPtr eldbus_object_get_impl(const ConnectionPtr& conn, const std::string& bus, const std::string& path) override
{
- return create(eldbus_object_get(get(conn), bus.c_str(), path.c_str() ), true );
+ return create(eldbus_object_get(get(conn), bus.c_str(), path.c_str()), true);
}
- ProxyPtr eldbus_proxy_get_impl( const ObjectPtr &obj, const std::string &interface ) override
+ ProxyPtr eldbus_proxy_get_impl(const ObjectPtr& obj, const std::string& interface) override
{
- return create(eldbus_proxy_get(get(obj), interface.c_str() ), false );
+ return create(eldbus_proxy_get(get(obj), interface.c_str()), false);
}
- ProxyPtr eldbus_proxy_copy_impl( const ProxyPtr &ptr) override
+ ProxyPtr eldbus_proxy_copy_impl(const ProxyPtr& ptr) override
{
- return create(get(ptr), false );
+ return create(get(ptr), false);
}
struct Implementation
{
- Eldbus_Service_Interface_Desc dsc;
- std::vector< std::vector< Eldbus_Arg_Info > > argsInfos;
- std::vector< Eldbus_Method > methods;
- std::vector< Eldbus_Signal > signals;
- std::vector< Eldbus_Property > properties;
+ Eldbus_Service_Interface_Desc dsc;
+ std::vector<std::vector<Eldbus_Arg_Info>> argsInfos;
+ std::vector<Eldbus_Method> methods;
+ std::vector<Eldbus_Signal> signals;
+ std::vector<Eldbus_Property> properties;
- std::unordered_map< std::string, DBusWrapper::MethodInfo > methodsMap;
- std::unordered_map< std::string, DBusWrapper::PropertyInfo > propertiesMap;
- std::unordered_map< unsigned int, DBusWrapper::SignalInfo > signalsMap;
+ std::unordered_map<std::string, DBusWrapper::MethodInfo> methodsMap;
+ std::unordered_map<std::string, DBusWrapper::PropertyInfo> propertiesMap;
+ std::unordered_map<unsigned int, DBusWrapper::SignalInfo> signalsMap;
DBusWrapper::ConnectionWeakPtr connection;
};
- static std::unordered_map< const Eldbus_Service_Interface*, std::unique_ptr< Implementation > > globalEntries;
- static std::mutex globalEntriesMutex;
+ static std::unordered_map<const Eldbus_Service_Interface*, std::unique_ptr<Implementation>> globalEntries;
+ static std::mutex globalEntriesMutex;
#undef EINA_FALSE
#undef EINA_TRUE
#define EINA_FALSE static_cast<Eina_Bool>(0)
#define EINA_TRUE static_cast<Eina_Bool>(1)
- static Eina_Bool property_get_callback( const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter,
- const Eldbus_Message* message, Eldbus_Message** error )
+ static Eina_Bool property_get_callback(const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter, const Eldbus_Message* message, Eldbus_Message** error)
{
Implementation* impl = nullptr;
{
- std::lock_guard< std::mutex > lock( globalEntriesMutex );
- auto it = globalEntries.find( iface );
- if( it != globalEntries.end() )
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ auto it = globalEntries.find(iface);
+ if(it != globalEntries.end())
{
impl = it->second.get();
}
}
- if( !impl )
+ if(!impl)
{
return EINA_FALSE;
}
- auto it = impl->propertiesMap.find( propertyName );
- if( it == impl->propertiesMap.end() || !it->second.getCallback )
+ auto it = impl->propertiesMap.find(propertyName);
+ if(it == impl->propertiesMap.end() || !it->second.getCallback)
{
return EINA_FALSE;
}
auto connection = impl->connection.lock();
- if( !connection )
+ if(!connection)
{
return EINA_FALSE;
}
- DBus::DBusServer::CurrentObjectSetter currentObjectSetter( connection, eldbus_message_path_get( message ) );
- auto reply = it->second.getCallback( create(message, false), create(iter, nullptr, false) );
- if( !reply.empty() )
+ DBus::DBusServer::CurrentObjectSetter currentObjectSetter(connection, eldbus_message_path_get(message));
+ auto reply = it->second.getCallback(create(message, false), create(iter, nullptr, false));
+ if(!reply.empty())
{
- if( error )
+ if(error)
{
- *error = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", reply.c_str() );
+ *error = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", reply.c_str());
}
return EINA_FALSE;
}
return EINA_TRUE;
}
- static Eldbus_Message* property_set_callback( const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter,
- const Eldbus_Message* message )
+ static Eldbus_Message* property_set_callback(const Eldbus_Service_Interface* iface, const char* propertyName, Eldbus_Message_Iter* iter, const Eldbus_Message* message)
{
Implementation* impl = nullptr;
{
- std::lock_guard< std::mutex > lock( globalEntriesMutex );
- auto it = globalEntries.find( iface );
- if( it != globalEntries.end() )
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ auto it = globalEntries.find(iface);
+ if(it != globalEntries.end())
{
impl = it->second.get();
}
}
- if( !impl )
+ if(!impl)
{
- auto ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", "Unknown interface" );
+ auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Unknown interface");
return ret;
}
- auto it = impl->propertiesMap.find( propertyName );
- if( it == impl->propertiesMap.end() || !it->second.setCallback )
+ auto it = impl->propertiesMap.find(propertyName);
+ if(it == impl->propertiesMap.end() || !it->second.setCallback)
{
- auto ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", "Unknown setter" );
+ auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Unknown setter");
return ret;
}
auto connection = impl->connection.lock();
- if( !connection )
+ if(!connection)
{
- auto ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", "Connection lost" );
+ auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Connection lost");
return ret;
}
- DBus::DBusServer::CurrentObjectSetter currentObjectSetter( connection, eldbus_message_path_get( message ) );
- auto reply = it->second.setCallback( create(message, false), create(iter, nullptr, false) );
+ DBus::DBusServer::CurrentObjectSetter currentObjectSetter(connection, eldbus_message_path_get(message));
+ auto reply = it->second.setCallback(create(message, false), create(iter, nullptr, false));
Eldbus_Message* ret = nullptr;
- if( !reply.empty() )
+ if(!reply.empty())
{
- ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", reply.c_str() );
+ ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", reply.c_str());
}
else
{
- ret = eldbus_message_method_return_new( message );
+ ret = eldbus_message_method_return_new(message);
}
return ret;
}
- static Eldbus_Message* method_callback( const Eldbus_Service_Interface* iface, const Eldbus_Message* message )
+ static Eldbus_Message* method_callback(const Eldbus_Service_Interface* iface, const Eldbus_Message* message)
{
Implementation* impl = nullptr;
{
- std::lock_guard< std::mutex > lock( globalEntriesMutex );
- auto it = globalEntries.find( iface );
- if( it != globalEntries.end() )
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ auto it = globalEntries.find(iface);
+ if(it != globalEntries.end())
impl = it->second.get();
}
- if( !impl )
+ if(!impl)
{
- auto ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", "Unknown interface" );
+ auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Unknown interface");
return ret;
}
- std::string memberName = eldbus_message_member_get( message );
- auto it = impl->methodsMap.find( memberName );
- if( it == impl->methodsMap.end() )
+ std::string memberName = eldbus_message_member_get(message);
+ auto it = impl->methodsMap.find(memberName);
+ if(it == impl->methodsMap.end())
{
- auto ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", "Unknown method" );
+ auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Unknown method");
return ret;
}
auto connection = impl->connection.lock();
- if( !connection )
+ if(!connection)
{
- auto ret = eldbus_message_error_new( message, "org.freedesktop.DBus.Error.Failed", "Connection lost" );
+ auto ret = eldbus_message_error_new(message, "org.freedesktop.DBus.Error.Failed", "Connection lost");
return ret;
}
- DBus::DBusServer::CurrentObjectSetter currentObjectSetter( connection, eldbus_message_path_get( message ) );
- auto reply = it->second.callback( create(message) );
+ DBus::DBusServer::CurrentObjectSetter currentObjectSetter(connection, eldbus_message_path_get(message));
+ auto reply = it->second.callback(create(message));
return release(reply);
}
- void add_interface_impl( bool fallback, const std::string& pathName,
- const ConnectionPtr &connection,
- std::vector<std::function<void()>> &destructors,
- const std::string& interfaceName,
- std::vector< MethodInfo >& dscrMethods,
- std::vector< PropertyInfo >& dscrProperties,
- std::vector< SignalInfo >& dscrSignals ) override
- {
- std::vector< Eldbus_Method > methods;
- std::vector< Eldbus_Signal > signals;
- std::vector< Eldbus_Property > properties;
- std::vector< std::vector< Eldbus_Arg_Info > > argsInfos;
- std::unordered_map< std::string, DBus::DBusInterfaceDescription::MethodInfo > methodsMap;
- std::unordered_map< std::string, DBus::DBusInterfaceDescription::PropertyInfo > propertiesMap;
- std::unordered_map< unsigned int, DBus::DBusInterfaceDescription::SignalInfo > signalsMap;
-
- DBUS_DEBUG( "interface %s path %s on bus %s", interfaceName.c_str(), pathName.c_str(), DBus::getConnectionName( connection ).c_str() );
- auto makeArgInfo = [&](const std::vector<std::pair<std::string, std::string>> &input) {
+ void add_interface_impl(bool fallback,
+ const std::string& pathName,
+ const ConnectionPtr& connection,
+ std::vector<std::function<void()>>& destructors,
+ const std::string& interfaceName,
+ std::vector<MethodInfo>& dscrMethods,
+ std::vector<PropertyInfo>& dscrProperties,
+ std::vector<SignalInfo>& dscrSignals) override
+ {
+ std::vector<Eldbus_Method> methods;
+ std::vector<Eldbus_Signal> signals;
+ std::vector<Eldbus_Property> properties;
+ std::vector<std::vector<Eldbus_Arg_Info>> argsInfos;
+ std::unordered_map<std::string, DBus::DBusInterfaceDescription::MethodInfo> methodsMap;
+ std::unordered_map<std::string, DBus::DBusInterfaceDescription::PropertyInfo> propertiesMap;
+ std::unordered_map<unsigned int, DBus::DBusInterfaceDescription::SignalInfo> signalsMap;
+
+ DBUS_DEBUG("interface %s path %s on bus %s", interfaceName.c_str(), pathName.c_str(), DBus::getConnectionName(connection).c_str());
+ auto makeArgInfo = [&](const std::vector<std::pair<std::string, std::string>>& input) {
argsInfos.push_back({});
- auto &dst = argsInfos.back();
- for(auto &s : input)
+ auto& dst = argsInfos.back();
+ for(auto& s : input)
{
auto a = Strings.add(s.first);
auto b = Strings.add(s.second);
- dst.push_back({ a, b });
+ dst.push_back({a, b});
}
- dst.push_back({ nullptr, nullptr });
+ dst.push_back({nullptr, nullptr});
return dst.data();
};
- for( auto& ee : dscrMethods )
+ for(auto& ee : dscrMethods)
{
auto key = ee.memberName;
- DBUS_DEBUG( "adding method %s", ee.memberName.c_str() );
- for( auto& r : ee.in )
+ DBUS_DEBUG("adding method %s", ee.memberName.c_str());
+ for(auto& r : ee.in)
{
- DBUS_DEBUG( "in %s '%s'", r.first.c_str(), r.second.c_str() );
+ DBUS_DEBUG("in %s '%s'", r.first.c_str(), r.second.c_str());
}
- for( auto& r : ee.out )
+ for(auto& r : ee.out)
{
- DBUS_DEBUG( "out %s '%s'", r.first.c_str(), r.second.c_str() );
+ DBUS_DEBUG("out %s '%s'", r.first.c_str(), r.second.c_str());
}
- auto& e = ( methodsMap[key] = std::move( ee ) );
- methods.push_back( {} );
- auto& m = methods.back();
+ auto& e = (methodsMap[key] = std::move(ee));
+ methods.push_back({});
+ auto& m = methods.back();
m.member = e.memberName.c_str();
- m.in = makeArgInfo(e.in);
- m.out = makeArgInfo(e.out);
- m.cb = method_callback;
- m.flags = 0;
+ m.in = makeArgInfo(e.in);
+ m.out = makeArgInfo(e.out);
+ m.cb = method_callback;
+ m.flags = 0;
}
- for( auto& ee : dscrProperties )
+ for(auto& ee : dscrProperties)
{
auto key = ee.memberName;
- DBUS_DEBUG( "adding property %s", ee.memberName.c_str() );
- auto& e = ( propertiesMap[key] = std::move( ee ) );
- properties.push_back( {} );
- auto& m = properties.back();
- m.name = e.memberName.c_str();
- m.type = e.typeSignature.c_str();
+ DBUS_DEBUG("adding property %s", ee.memberName.c_str());
+ auto& e = (propertiesMap[key] = std::move(ee));
+ properties.push_back({});
+ auto& m = properties.back();
+ m.name = e.memberName.c_str();
+ m.type = e.typeSignature.c_str();
m.get_func = e.getCallback ? property_get_callback : nullptr;
m.set_func = e.setCallback ? property_set_callback : nullptr;
- m.flags = 0;
+ m.flags = 0;
}
dscrMethods.clear();
dscrProperties.clear();
dscrSignals.clear();
- methods.push_back( {nullptr, nullptr, nullptr, nullptr, 0} );
- signals.push_back( {nullptr, nullptr, 0} );
- properties.push_back( {nullptr, nullptr, nullptr, nullptr, 0} );
-
- auto impl = std::unique_ptr< Implementation >( new Implementation{
- {interfaceName.c_str(),
- methods.data(),
- signals.data(),
- properties.data(),
- nullptr,
- nullptr},
- std::move( argsInfos ),
- std::move( methods ),
- std::move( signals ),
- std::move( properties ),
- std::move( methodsMap ),
- std::move( propertiesMap ),
- std::move( signalsMap ),
- connection} );
-
- {
- std::lock_guard< std::mutex > lock( globalEntriesMutex );
- auto v = fallback ? eldbus_service_interface_fallback_register( get(connection), pathName.c_str(), &impl->dsc ) : eldbus_service_interface_register( get(connection), pathName.c_str(), &impl->dsc );
- assert( v );
- globalEntries[v] = std::move( impl );
- DBUS_DEBUG( "registering interface %p (%d)", v, fallback ? 1 : 0 );
- destructors.push_back([=]()
+ methods.push_back({nullptr, nullptr, nullptr, nullptr, 0});
+ signals.push_back({nullptr, nullptr, 0});
+ properties.push_back({nullptr, nullptr, nullptr, nullptr, 0});
+
+ auto impl = std::unique_ptr<Implementation>(new Implementation{
+ {interfaceName.c_str(),
+ methods.data(),
+ signals.data(),
+ properties.data(),
+ nullptr,
+ nullptr},
+ std::move(argsInfos),
+ std::move(methods),
+ std::move(signals),
+ std::move(properties),
+ std::move(methodsMap),
+ std::move(propertiesMap),
+ std::move(signalsMap),
+ connection});
+
+ {
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ auto v = fallback ? eldbus_service_interface_fallback_register(get(connection), pathName.c_str(), &impl->dsc) : eldbus_service_interface_register(get(connection), pathName.c_str(), &impl->dsc);
+ assert(v);
+ globalEntries[v] = std::move(impl);
+ DBUS_DEBUG("registering interface %p (%d)", v, fallback ? 1 : 0);
+ destructors.push_back([=]() {
+ DBUS_DEBUG("unregistering interface %p", v);
{
- DBUS_DEBUG( "unregistering interface %p", v );
- {
- std::lock_guard< std::mutex > lock( globalEntriesMutex );
- globalEntries.erase( v );
- }
- eldbus_service_interface_unregister( v );
+ std::lock_guard<std::mutex> lock(globalEntriesMutex);
+ globalEntries.erase(v);
}
- );
+ eldbus_service_interface_unregister(v);
+ });
}
}
- static void listenerEventChangedCallback( void* data, Eldbus_Proxy* proxy EINA_UNUSED, void* event )
+ static void listenerEventChangedCallback(void* data, Eldbus_Proxy* proxy EINA_UNUSED, void* event)
{
- auto p = static_cast< std::function< void( Eldbus_Proxy_Event_Property_Changed* ) >* >( data );
- ( *p )( static_cast< Eldbus_Proxy_Event_Property_Changed* >( event ) );
+ auto p = static_cast<std::function<void(Eldbus_Proxy_Event_Property_Changed*)>*>(data);
+ (*p)(static_cast<Eldbus_Proxy_Event_Property_Changed*>(event));
}
- static void ProxyEventCallbackDelCb( void* data, const void *obj )
+ static void ProxyEventCallbackDelCb(void* data, const void* obj)
{
- auto d = static_cast< std::function< void( Eldbus_Proxy_Event_Property_Changed* ) >* >( data );
+ auto d = static_cast<std::function<void(Eldbus_Proxy_Event_Property_Changed*)>*>(data);
delete d;
}
- void add_property_changed_event_listener_impl( const ProxyPtr &proxy, const std::string &interface, const std::string &name, std::function< void( const Eina_Value * ) > cb) override
+ void add_property_changed_event_listener_impl(const ProxyPtr& proxy, const std::string& interface, const std::string& name, std::function<void(const Eina_Value*)> cb) override
{
- auto callbackLambdaPtr = new std::function< void( Eldbus_Proxy_Event_Property_Changed *epc ) >
- {
- [cb, name, interface]( Eldbus_Proxy_Event_Property_Changed *ev )
- {
- const char* ifc = eldbus_proxy_interface_get( ev->proxy );
- if( ev->name && ev->name == name && ifc && interface == ifc )
+ auto callbackLambdaPtr = new std::function<void(Eldbus_Proxy_Event_Property_Changed * epc)>{
+ [cb, name, interface](Eldbus_Proxy_Event_Property_Changed* ev) {
+ const char* ifc = eldbus_proxy_interface_get(ev->proxy);
+ if(ev->name && ev->name == name && ifc && interface == ifc)
{
cb(ev->value);
}
- }
- };
+ }};
auto p = get(proxy);
- eldbus_proxy_event_callback_add( p, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, listenerEventChangedCallback, callbackLambdaPtr );
- eldbus_proxy_free_cb_add( p, ProxyEventCallbackDelCb, callbackLambdaPtr );
+ eldbus_proxy_event_callback_add(p, ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, listenerEventChangedCallback, callbackLambdaPtr);
+ eldbus_proxy_free_cb_add(p, ProxyEventCallbackDelCb, callbackLambdaPtr);
}
};
-std::unordered_map< const Eldbus_Service_Interface*, std::unique_ptr< DefaultDBusWrapper::Implementation > > DefaultDBusWrapper::globalEntries;
-std::mutex DefaultDBusWrapper::globalEntriesMutex;
+std::unordered_map<const Eldbus_Service_Interface*, std::unique_ptr<DefaultDBusWrapper::Implementation>> DefaultDBusWrapper::globalEntries;
+std::mutex DefaultDBusWrapper::globalEntriesMutex;
-DBusWrapper *DBusWrapper::Installed()
+DBusWrapper* DBusWrapper::Installed()
{
- if (!InstalledWrapper)
+ if(!InstalledWrapper)
{
InstalledWrapper.reset(new DefaultDBusWrapper);
}
/*
- * 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.
*
*/
-#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
+#include <dali/devel-api/adaptor-framework/accessibility.h>
-namespace Dali {
-namespace {
-
+namespace Dali
+{
+namespace
+{
struct DummyBridge : Dali::Accessibility::Bridge
{
const std::string& GetBusName() const override
return name;
}
- void AddTopLevelWindow(Accessibility::Accessible *) override
+ void AddTopLevelWindow(Accessibility::Accessible*) override
{
}
- void RemoveTopLevelWindow(Accessibility::Accessible *) override
+ void RemoveTopLevelWindow(Accessibility::Accessible*) override
{
}
- void AddPopup(Accessibility::Accessible *) override
+ void AddPopup(Accessibility::Accessible*) override
{
}
- void RemovePopup(Accessibility::Accessible *) override
+ void RemovePopup(Accessibility::Accessible*) override
{
}
{
}
- Accessibility::Accessible *GetApplication() const override
+ Accessibility::Accessible* GetApplication() const override
{
return nullptr;
}
- Accessibility::Accessible *FindByPath(const std::string& s) const override
+ Accessibility::Accessible* FindByPath(const std::string& s) const override
{
return nullptr;
}
{
}
- void EmitCaretMoved(Accessibility::Accessible *obj, unsigned int cursorPosition) override
+ void EmitCaretMoved(Accessibility::Accessible* obj, unsigned int cursorPosition) override
{
}
- void EmitActiveDescendantChanged(Accessibility::Accessible *obj, Accessibility::Accessible *child) override
+ void EmitActiveDescendantChanged(Accessibility::Accessible* obj, Accessibility::Accessible* child) override
{
}
- void EmitTextChanged(Accessibility::Accessible *obj, Accessibility::TextChangedState state, unsigned int position, unsigned int length, const std::string &content) override
+ void EmitTextChanged(Accessibility::Accessible* obj, Accessibility::TextChangedState state, unsigned int position, unsigned int length, const std::string& content) override
{
}
- void EmitStateChanged(Accessibility::Accessible *obj, Accessibility::State state, int val1, int val2) override
+ void EmitStateChanged(Accessibility::Accessible* obj, Accessibility::State state, int val1, int val2) override
{
}
- void Emit(Accessibility::Accessible *obj, Accessibility::WindowEvent we, unsigned int detail1) override
+ void Emit(Accessibility::Accessible* obj, Accessibility::WindowEvent we, unsigned int detail1) override
{
}
- void Emit(Accessibility::Accessible *obj, Accessibility::ObjectPropertyChangeEvent event) override
+ void Emit(Accessibility::Accessible* obj, Accessibility::ObjectPropertyChangeEvent event) override
{
}
- void EmitBoundsChanged(Accessibility::Accessible *obj, Rect<> rect) override
+ void EmitBoundsChanged(Accessibility::Accessible* obj, Rect<> rect) override
{
}
return Accessibility::Consumed::YES;
}
- void Say( const std::string& text, bool discardable, std::function<void(std::string)> callback ) override
+ void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) override
{
}
{
}
-std::vector<Accessibility::Accessible *> Accessibility::Accessible::GetChildren()
+std::vector<Accessibility::Accessible*> Accessibility::Accessible::GetChildren()
{
return {};
}
-Accessibility::Accessible *Accessibility::Accessible::GetDefaultLabel()
+Accessibility::Accessible* Accessibility::Accessible::GetDefaultLabel()
{
return nullptr;
}
return {};
}
-std::shared_ptr< Accessibility::Bridge::Data > Accessibility::Accessible::GetBridgeData()
+std::shared_ptr<Accessibility::Bridge::Data> Accessibility::Accessible::GetBridgeData()
{
return {};
}
return false;
}
-Accessibility::Accessible *Accessibility::Component::GetAccessibleAtPoint(Accessibility::Point p, Accessibility::CoordType ctype)
+Accessibility::Accessible* Accessibility::Component::GetAccessibleAtPoint(Accessibility::Point p, Accessibility::CoordType ctype)
{
return nullptr;
}
-Accessibility::Bridge *Accessibility::Bridge::GetCurrentBridge()
+Accessibility::Bridge* Accessibility::Bridge::GetCurrentBridge()
{
return &dummyBridge;
}
{
}
-void Accessibility::Accessible::EmitTextInserted(unsigned int position, unsigned int length, const std::string &content)
+void Accessibility::Accessible::EmitTextInserted(unsigned int position, unsigned int length, const std::string& content)
{
}
-void Accessibility::Accessible::EmitTextDeleted(unsigned int position, unsigned int length, const std::string &content)
+void Accessibility::Accessible::EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content)
{
}
{
}
-void Accessibility::Accessible::EmitActiveDescendantChanged(Accessibility::Accessible* obj, Accessibility::Accessible *child)
+void Accessibility::Accessible::EmitActiveDescendantChanged(Accessibility::Accessible* obj, Accessibility::Accessible* child)
{
}
-void Accessibility::Accessible::FindWordSeparationsUtf8(const utf8_t *s, size_t length, const char *language, char *breaks)
+void Accessibility::Accessible::FindWordSeparationsUtf8(const utf8_t* s, size_t length, const char* language, char* breaks)
{
}
-void Accessibility::Accessible::FindLineSeparationsUtf8(const utf8_t *s, size_t length, const char *language, char *breaks)
+void Accessibility::Accessible::FindLineSeparationsUtf8(const utf8_t* s, size_t length, const char* language, char* breaks)
{
}
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
class TtsPlayer;
* @return dummy implementation of Tts Player
*/
__attribute__((weak))
-std::unique_ptr<TtsPlayer> New(Dali::TtsPlayer::Mode mode)
+std::unique_ptr<TtsPlayer>
+New(Dali::TtsPlayer::Mode mode)
{
return std::unique_ptr<TtsPlayer>(new Internal::Adaptor::TtsPlayer());
}
-}
+} // namespace TtsPlayerFactory
-}
+} // namespace Adaptor
-}
+} // namespace Internal
-}
\ No newline at end of file
+} // namespace Dali
\ No newline at end of file
/*
- * Copyright (c) 2017 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.
*
*/
-#include <dali/internal/accessibility/common/tts-player-impl.h>
#include <dali/internal/accessibility/common/tts-player-factory.h>
+#include <dali/internal/accessibility/common/tts-player-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
Dali::TtsPlayer TtsPlayer::New(Dali::TtsPlayer::Mode mode)
{
return Dali::TtsPlayer(TtsPlayerFactory::New(mode).release());
}
-void TtsPlayer::Play(const std::string &text)
+void TtsPlayer::Play(const std::string& text)
{
-
}
void TtsPlayer::Stop()
{
-
}
void TtsPlayer::Pause()
{
-
}
void TtsPlayer::Resume()
{
-
}
Dali::TtsPlayer::State TtsPlayer::GetState()
return signal;
}
-}
-}
-}
\ No newline at end of file
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
\ No newline at end of file
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
class TtsPlayer;
namespace TtsPlayerFactory
{
-
std::unique_ptr<TtsPlayer> New(Dali::TtsPlayer::Mode mode)
{
return TtsPlayerGeneric::New(mode);
/*
- * Copyright (c) 2019 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.
#include <memory>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* TtsPlayerGeneric::gLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TTS_PLAYER");
#endif
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
class TtsPlayer;
namespace TtsPlayerFactory
{
-
std::unique_ptr<TtsPlayer> New(Dali::TtsPlayer::Mode mode)
{
return TtsPlayerTizen::New(mode);
}
-}
+} // namespace TtsPlayerFactory
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2018 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.
#include <dali/public-api/object/type-registry.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-
/**
* Helper function to convert Tizen-specific TTS state to external state.
* @param state The Tizen TTS state.
* @return The external TTS state.
*/
-Dali::TtsPlayer::State InternalToExternalState( tts_state_e state )
+Dali::TtsPlayer::State InternalToExternalState(tts_state_e state)
{
- switch( state )
+ switch(state)
{
case TTS_STATE_CREATED:
{
// Unset the callback funtion for TTS state change
int retVal = tts_unset_state_changed_cb(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
// Destroy the TTS handle and disconnects the daemon
retVal = tts_destroy(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
// Create the TTS handle
int retVal = tts_create(&mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
{
// Set the callback funtion for TTS state change
retVal = tts_set_state_changed_cb(mTtsHandle, &StateChangedCallback, this);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
// Check tts mode
tts_mode_e ttsMode = TTS_MODE_DEFAULT;
- switch (mTtsMode)
+ switch(mTtsMode)
{
case Dali::TtsPlayer::DEFAULT:
ttsMode = TTS_MODE_DEFAULT;
- break;
+ break;
case Dali::TtsPlayer::NOTIFICATION:
ttsMode = TTS_MODE_NOTIFICATION;
- break;
+ break;
case Dali::TtsPlayer::SCREEN_READER:
ttsMode = TTS_MODE_SCREEN_READER;
- break;
+ break;
default:
- break;
+ break;
}
// Set mode
{
// Check the current TTS state
tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
+ int retVal = tts_get_state(mTtsHandle, &state);
if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
{
// If it is playing or paused, stop playing and clear the queue
retVal = tts_stop(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
{
// Check the current TTS state
tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
+ int retVal = tts_get_state(mTtsHandle, &state);
if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
{
// If the player is playing, pause it.
retVal = tts_pause(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
{
// Check the current TTS state
tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
+ int retVal = tts_get_state(mTtsHandle, &state);
if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
{
// If the player is paused, resume it.
retVal = tts_play(mTtsHandle);
- if( retVal != TTS_ERROR_NONE )
+ if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
{
// Check the current TTS state
tts_state_e state;
- int retVal = tts_get_state(mTtsHandle, &state);
+ int retVal = tts_get_state(mTtsHandle, &state);
if(retVal != TTS_ERROR_NONE)
{
LogErrorCode(static_cast<tts_error_e>(retVal));
}
else
{
- ttsState = InternalToExternalState( state );
+ ttsState = InternalToExternalState(state);
}
}
return mStateChangedSignal;
}
-void TtsPlayerTizen::EmitStateChangedSignal( tts_state_e previous, tts_state_e current )
+void TtsPlayerTizen::EmitStateChangedSignal(tts_state_e previous, tts_state_e current)
{
// Convert the previous and current states to external states and emit them as a signal.
- if( !mStateChangedSignal.Empty() )
+ if(!mStateChangedSignal.Empty())
{
- mStateChangedSignal.Emit( InternalToExternalState( previous ), InternalToExternalState( current ) );
+ mStateChangedSignal.Emit(InternalToExternalState(previous), InternalToExternalState(current));
}
}
-void TtsPlayerTizen::StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData)
+void TtsPlayerTizen::StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void* userData)
{
// Get the implementation (this is a static function).
TtsPlayerTizen* obj = static_cast<TtsPlayerTizen*>(userData);
// Emit the signal.
- obj->EmitStateChangedSignal( previous, current );
+ obj->EmitStateChangedSignal(previous, current);
if(!obj->mInitialized && current == TTS_STATE_READY)
{
{
std::string error_string;
- switch (reason)
+ switch(reason)
{
case TTS_ERROR_NONE:
{
/*
- * Copyright (c) 2019 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.
#include <dali/internal/adaptor-framework/common/file-loader-impl.h>
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <cstdio>
-#include <string>
#include <fstream>
-#include <dali/integration-api/debug.h>
+#include <string>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
int ReadFile(const std::string& filename, Dali::Vector<char>& memblock, Dali::FileLoader::FileType fileType)
{
std::streampos size;
- return Dali::Internal::Adaptor::ReadFile( filename, size, memblock, fileType);
+ return Dali::Internal::Adaptor::ReadFile(filename, size, memblock, fileType);
}
int ReadFile(const std::string& filename, Dali::Vector<uint8_t>& memblock, Dali::FileLoader::FileType fileType)
{
std::streampos size;
- return Dali::Internal::Adaptor::ReadFile( filename, size, memblock, fileType);
+ return Dali::Internal::Adaptor::ReadFile(filename, size, memblock, fileType);
}
inline bool hasPrefix(const std::string& prefix, const std::string& path)
std::string internalPath = std::string(path.c_str() + offset);
int i = 0;
- while ((i = internalPath.find("//", i)) != std::string::npos)
+ while((i = internalPath.find("//", i)) != std::string::npos)
{
internalPath.replace(i, 2, "/");
}
template<typename T>
int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<T>& memblock, Dali::FileLoader::FileType fileType)
{
- int errorCode = 0;
- int length = 0;
- char mode[3] = { 'r', 0, 0 };
+ int errorCode = 0;
+ int length = 0;
+ char mode[3] = {'r', 0, 0};
- if( fileType == Dali::FileLoader::BINARY )
+ if(fileType == Dali::FileLoader::BINARY)
{
mode[1] = 'b';
}
- else if( fileType != Dali::FileLoader::TEXT )
+ else if(fileType != Dali::FileLoader::TEXT)
{
return errorCode;
}
const std::string assetsPrefix = "assets/";
- if( hasPrefix( assetsPrefix, filename ) )
+ if(hasPrefix(assetsPrefix, filename))
{
- std::string internalPath = ConvertToAssetsInternalPath( filename, assetsPrefix.length() );
+ std::string internalPath = ConvertToAssetsInternalPath(filename, assetsPrefix.length());
AAssetManager* assetManager = Dali::Integration::AndroidFramework::Get().GetApplicationAssets();
- AAsset* asset = AAssetManager_open( assetManager, internalPath.c_str(), AASSET_MODE_BUFFER );
- if( asset )
+ AAsset* asset = AAssetManager_open(assetManager, internalPath.c_str(), AASSET_MODE_BUFFER);
+ if(asset)
{
- length = AAsset_getLength( asset );
- memblock.Resize( length + 1 ); // 1 for extra zero at the end
+ length = AAsset_getLength(asset);
+ memblock.Resize(length + 1); // 1 for extra zero at the end
char* buffer = reinterpret_cast<char*>(memblock.Begin());
- errorCode = ( AAsset_read( asset, buffer, length ) != length ) ? 0 : 1;
- fileSize = length;
+ errorCode = (AAsset_read(asset, buffer, length) != length) ? 0 : 1;
+ fileSize = length;
- AAsset_close( asset );
+ AAsset_close(asset);
}
else
{
- DALI_LOG_ERROR( "Asset not found %s\n", internalPath.c_str() );
+ DALI_LOG_ERROR("Asset not found %s\n", internalPath.c_str());
}
}
else
{
- FILE* file = fopen( filename.c_str(), mode );
- if( file )
+ FILE* file = fopen(filename.c_str(), mode);
+ if(file)
{
- fseek( file, 0, SEEK_END );
- length = ftell( file );
+ fseek(file, 0, SEEK_END);
+ length = ftell(file);
//Dali::Vector.Resize would lead to calling PushBack for each byte, waste of CPU resource
- memblock.ResizeUninitialized( length + 1 );
+ memblock.ResizeUninitialized(length + 1);
//put last byte as 0, in case this is a text file without null-terminator
memblock[length] = 0;
char* buffer = reinterpret_cast<char*>(memblock.Begin());
- fseek( file, 0, SEEK_SET );
- errorCode = ( fread( buffer, 1, length, file ) != length ) ? 0 : 1;
- fileSize = length;
+ fseek(file, 0, SEEK_SET);
+ errorCode = (fread(buffer, 1, length, file) != length) ? 0 : 1;
+ fileSize = length;
- fclose( file );
+ fclose(file);
}
else
{
- DALI_LOG_ERROR( "File not found %s\n", filename.c_str() );
+ DALI_LOG_ERROR("File not found %s\n", filename.c_str());
}
}
std::streampos size = 0;
const std::string assetsPrefix = "assets/";
- if( hasPrefix( assetsPrefix, filename ) )
+ if(hasPrefix(assetsPrefix, filename))
{
- std::string internalPath = ConvertToAssetsInternalPath( filename, assetsPrefix.length() );
+ std::string internalPath = ConvertToAssetsInternalPath(filename, assetsPrefix.length());
AAssetManager* assetManager = Dali::Integration::AndroidFramework::Get().GetApplicationAssets();
- AAsset* asset = AAssetManager_open( assetManager, internalPath.c_str(), AASSET_MODE_BUFFER );
- if( asset )
+ AAsset* asset = AAssetManager_open(assetManager, internalPath.c_str(), AASSET_MODE_BUFFER);
+ if(asset)
{
- size = AAsset_getLength( asset );
- AAsset_close( asset );
+ size = AAsset_getLength(asset);
+ AAsset_close(asset);
}
else
{
- DALI_LOG_ERROR( "Asset not found %s\n", internalPath.c_str() );
+ DALI_LOG_ERROR("Asset not found %s\n", internalPath.c_str());
}
}
else
{
- FILE* file = fopen( filename.c_str(), "r" );
- if( file )
+ FILE* file = fopen(filename.c_str(), "r");
+ if(file)
{
- fseek( file, 0, SEEK_END );
- size = ftell( file );
- fclose( file );
+ fseek(file, 0, SEEK_END);
+ size = ftell(file);
+ fclose(file);
}
else
{
- DALI_LOG_ERROR( "File not found %s\n", filename.c_str() );
+ DALI_LOG_ERROR("File not found %s\n", filename.c_str());
}
}
return size;
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
#include <dali/internal/adaptor-framework/common/file-stream-impl.h>
// EXTERNAL INCLUDES
-#include <string>
-#include <fstream>
#include <dali/integration-api/debug.h>
+#include <fstream>
+#include <string>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
namespace Dali
{
-
FileStream::Impl::Impl(const std::string& filename, uint8_t mode)
-: mFileName( filename ),
- mMode( mode ),
- mBuffer( nullptr ),
- mDataSize( 0 ),
- mFile( nullptr )
+: mFileName(filename),
+ mMode(mode),
+ mBuffer(nullptr),
+ mDataSize(0),
+ mFile(nullptr)
{
- DALI_ASSERT_DEBUG( !filename.empty() && "Can't open a empty filename." );
- DALI_ASSERT_DEBUG( mode != 0 && "No mode is undefined behaviour" );
+ DALI_ASSERT_DEBUG(!filename.empty() && "Can't open a empty filename.");
+ DALI_ASSERT_DEBUG(mode != 0 && "No mode is undefined behaviour");
}
FileStream::Impl::Impl(uint8_t* buffer, size_t dataSize, uint8_t mode)
-: mMode( mode ),
- mBuffer( buffer ),
- mDataSize( dataSize ),
- mFile( nullptr )
+: mMode(mode),
+ mBuffer(buffer),
+ mDataSize(dataSize),
+ mFile(nullptr)
{
- DALI_ASSERT_DEBUG( buffer != 0 && "Can't open file on null buffer." );
- DALI_ASSERT_DEBUG( dataSize > 0 && "Pointless to open file on empty buffer." );
- DALI_ASSERT_DEBUG( mode != 0 && "No mode is undefined behaviour." );
+ DALI_ASSERT_DEBUG(buffer != 0 && "Can't open file on null buffer.");
+ DALI_ASSERT_DEBUG(dataSize > 0 && "Pointless to open file on empty buffer.");
+ DALI_ASSERT_DEBUG(mode != 0 && "No mode is undefined behaviour.");
}
FileStream::Impl::Impl(Dali::Vector<uint8_t>& buffer, size_t dataSize, uint8_t mode)
-: mMode( mode ),
- mBuffer( nullptr ),
- mDataSize( dataSize ),
- mFile( nullptr )
+: mMode(mode),
+ mBuffer(nullptr),
+ mDataSize(dataSize),
+ mFile(nullptr)
{
// Resize the buffer to ensure any null that gets written by
// fmemopen is written past the end of any data that is written to the buffer.
// null if binary mode is specified).
++mDataSize;
- buffer.Resize( mDataSize );
+ buffer.Resize(mDataSize);
mBuffer = &buffer[0];
- DALI_ASSERT_DEBUG( mBuffer != nullptr && "Can't open file on null buffer." );
- DALI_ASSERT_DEBUG( dataSize > 0 && "Pointless to open file on empty buffer." );
- DALI_ASSERT_DEBUG( mode != 0 && "No mode is undefined behaviour." );
+ DALI_ASSERT_DEBUG(mBuffer != nullptr && "Can't open file on null buffer.");
+ DALI_ASSERT_DEBUG(dataSize > 0 && "Pointless to open file on empty buffer.");
+ DALI_ASSERT_DEBUG(mode != 0 && "No mode is undefined behaviour.");
}
FileStream::Impl::~Impl()
{
- if( mFile )
+ if(mFile)
{
- const int closeFailed = fclose( mFile );
- if( closeFailed )
+ const int closeFailed = fclose(mFile);
+ if(closeFailed)
{
- DALI_LOG_WARNING( "File close failed for FILE: \"%p\".\n", static_cast<void*>( mFile ) );
+ DALI_LOG_WARNING("File close failed for FILE: \"%p\".\n", static_cast<void*>(mFile));
}
mFile = nullptr;
}
- if( mFileStream.is_open() )
+ if(mFileStream.is_open())
{
mFileStream.close();
}
std::iostream& FileStream::Impl::GetStream()
{
- if( mFile )
+ if(mFile)
{
// return empty stream if FILE stream is open to avoid simultaneous access to the same file
return mFileStream;
}
- if( mFileStream.is_open() )
+ if(mFileStream.is_open())
{
return mFileStream;
}
- if( mBufferStream.rdbuf()->in_avail() )
+ if(mBufferStream.rdbuf()->in_avail())
{
return mBufferStream;
}
int openMode = 0;
- if( mMode & Dali::FileStream::APPEND )
+ if(mMode & Dali::FileStream::APPEND)
{
- openMode |= ( std::ios::out | std::ios::app );
+ openMode |= (std::ios::out | std::ios::app);
}
- else if( mMode & Dali::FileStream::WRITE )
+ else if(mMode & Dali::FileStream::WRITE)
{
- openMode |= ( std::ios::out | std::ios::ate );
+ openMode |= (std::ios::out | std::ios::ate);
}
- if( mMode & Dali::FileStream::READ )
+ if(mMode & Dali::FileStream::READ)
{
openMode |= std::ios::in;
}
- if( mMode & Dali::FileStream::BINARY )
+ if(mMode & Dali::FileStream::BINARY)
{
openMode |= std::ios::binary;
}
- if( !mFileName.empty() )
+ if(!mFileName.empty())
{
// TODO: it works only with text files, we need custom stream buffer implementation for binary and to avoid buffer copy
- if( !( mMode & Dali::FileStream::WRITE ) && !( mMode & Dali::FileStream::APPEND ) && !( mMode & Dali::FileStream::BINARY ) )
+ if(!(mMode & Dali::FileStream::WRITE) && !(mMode & Dali::FileStream::APPEND) && !(mMode & Dali::FileStream::BINARY))
{
std::streampos fileSize;
- if( ReadFile( mFileName, fileSize, mFileBuffer, Dali::FileLoader::TEXT ) )
+ if(ReadFile(mFileName, fileSize, mFileBuffer, Dali::FileLoader::TEXT))
{
- mBuffer = reinterpret_cast<uint8_t*>( &mFileBuffer[0] );
+ mBuffer = reinterpret_cast<uint8_t*>(&mFileBuffer[0]);
mDataSize = fileSize;
- mBufferStream.str( std::string ( &mFileBuffer[0], fileSize ) );
- if( !mBufferStream.rdbuf()->in_avail() )
+ mBufferStream.str(std::string(&mFileBuffer[0], fileSize));
+ if(!mBufferStream.rdbuf()->in_avail())
{
- DALI_LOG_ERROR( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), static_cast<int>( openMode ) );
+ DALI_LOG_ERROR("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
+ static_cast<void*>(mBuffer),
+ static_cast<unsigned>(mDataSize),
+ static_cast<int>(openMode));
}
return mBufferStream;
}
else
{
- DALI_LOG_ERROR( "stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), static_cast<int>( openMode ) );
+ DALI_LOG_ERROR("stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), static_cast<int>(openMode));
}
}
else
{
- mFileStream.open( mFileName, static_cast<std::ios_base::openmode>( openMode ) );
- if( !mFileStream.is_open() )
+ mFileStream.open(mFileName, static_cast<std::ios_base::openmode>(openMode));
+ if(!mFileStream.is_open())
{
- DALI_LOG_ERROR( "stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), static_cast<int>( openMode ) );
+ DALI_LOG_ERROR("stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), static_cast<int>(openMode));
}
}
return mFileStream;
}
- else if( mBuffer )
+ else if(mBuffer)
{
- mBufferStream.rdbuf()->pubsetbuf( reinterpret_cast<char*>( mBuffer ), mDataSize );
- if( !mBufferStream.rdbuf()->in_avail() )
+ mBufferStream.rdbuf()->pubsetbuf(reinterpret_cast<char*>(mBuffer), mDataSize);
+ if(!mBufferStream.rdbuf()->in_avail())
{
- DALI_LOG_ERROR( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), static_cast<int>( openMode ) );
+ DALI_LOG_ERROR("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
+ static_cast<void*>(mBuffer),
+ static_cast<unsigned>(mDataSize),
+ static_cast<int>(openMode));
}
}
FILE* FileStream::Impl::GetFile()
{
- if( mFileStream.is_open() || mBufferStream.rdbuf()->in_avail() )
+ if(mFileStream.is_open() || mBufferStream.rdbuf()->in_avail())
{
// return empty FILE stream if the stream is open to avoid simultaneous access to the same file
return nullptr;
}
- if( mFile )
+ if(mFile)
{
return mFile;
}
- char openMode[16] = { 0 };
- int i = 0;
+ char openMode[16] = {0};
+ int i = 0;
- if( mMode & Dali::FileStream::APPEND )
+ if(mMode & Dali::FileStream::APPEND)
{
openMode[i++] = 'a';
}
- else if( mMode & Dali::FileStream::WRITE )
+ else if(mMode & Dali::FileStream::WRITE)
{
openMode[i++] = 'w';
}
openMode[i++] = 'r';
}
- if( mMode & Dali::FileStream::BINARY )
+ if(mMode & Dali::FileStream::BINARY)
{
openMode[i++] = 'b';
}
openMode[i++] = 0;
- if( !mFileName.empty() )
+ if(!mFileName.empty())
{
- if ( !( mMode & Dali::FileStream::WRITE ) && !( mMode & Dali::FileStream::APPEND ) )
+ if(!(mMode & Dali::FileStream::WRITE) && !(mMode & Dali::FileStream::APPEND))
{
std::streampos fileSize;
- if ( ReadFile( mFileName, fileSize, mFileBuffer, ( mMode & Dali::FileStream::BINARY ) ? Dali::FileLoader::BINARY : Dali::FileLoader::TEXT ) )
+ if(ReadFile(mFileName, fileSize, mFileBuffer, (mMode & Dali::FileStream::BINARY) ? Dali::FileLoader::BINARY : Dali::FileLoader::TEXT))
{
- mBuffer = reinterpret_cast<uint8_t*>( &mFileBuffer[0] );
+ mBuffer = reinterpret_cast<uint8_t*>(&mFileBuffer[0]);
mDataSize = fileSize;
- mFile = fmemopen( mBuffer, mDataSize, openMode );
- if( !mFile )
+ mFile = fmemopen(mBuffer, mDataSize, openMode);
+ if(!mFile)
{
- DALI_LOG_ERROR( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), openMode );
+ DALI_LOG_ERROR("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
+ static_cast<void*>(mBuffer),
+ static_cast<unsigned>(mDataSize),
+ openMode);
}
}
else
{
- DALI_LOG_ERROR( "read file failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode );
+ DALI_LOG_ERROR("read file failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode);
}
}
else
{
- mFile = fopen( mFileName.c_str(), openMode );
- if( !mFile )
+ mFile = fopen(mFileName.c_str(), openMode);
+ if(!mFile)
{
- DALI_LOG_ERROR( "file open failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode );
+ DALI_LOG_ERROR("file open failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode);
}
}
}
- else if( mBuffer )
+ else if(mBuffer)
{
- mFile = fmemopen( mBuffer, mDataSize, openMode );
- if( !mFile )
+ mFile = fmemopen(mBuffer, mDataSize, openMode);
+ if(!mFile)
{
- DALI_LOG_ERROR( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), openMode );
+ DALI_LOG_ERROR("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
+ static_cast<void*>(mBuffer),
+ static_cast<unsigned>(mDataSize),
+ openMode);
}
}
return mFile;
}
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
int ReadFile(const std::string& filename, Dali::Vector<char>& memblock, Dali::FileLoader::FileType fileType)
{
std::streampos size;
- return Dali::Internal::Adaptor::ReadFile( filename, size, memblock, fileType);
+ return Dali::Internal::Adaptor::ReadFile(filename, size, memblock, fileType);
}
int ReadFile(const std::string& filename, Dali::Vector<uint8_t>& memblock, Dali::FileLoader::FileType fileType)
template<typename T>
int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<T>& memblock, Dali::FileLoader::FileType fileType)
{
- int errorCode = 0;
- std::ifstream * file;
+ int errorCode = 0;
+ std::ifstream* file;
- if( fileType == Dali::FileLoader::BINARY )
+ if(fileType == Dali::FileLoader::BINARY)
{
- file = new std::ifstream (filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);
+ file = new std::ifstream(filename.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
}
- else if( fileType == Dali::FileLoader::TEXT )
+ else if(fileType == Dali::FileLoader::TEXT)
{
- file = new std::ifstream (filename.c_str(), std::ios::in|std::ios::ate);
+ file = new std::ifstream(filename.c_str(), std::ios::in | std::ios::ate);
}
else
{
return errorCode;
}
- if( file->is_open() )
+ if(file->is_open())
{
fileSize = file->tellg();
- memblock.Resize( fileSize );
+ memblock.Resize(fileSize);
- file->seekg (0, std::ios::beg);
- file->read( reinterpret_cast<char*>(memblock.Begin()), fileSize );
+ file->seekg(0, std::ios::beg);
+ file->read(reinterpret_cast<char*>(memblock.Begin()), fileSize);
file->close();
delete file;
else
{
char buf[512];
- DALI_LOG_ERROR( "file open failed for: \"%s\", error : %s\n", filename.c_str(), strerror_r( errno, buf, 512 ) );
+ DALI_LOG_ERROR("file open failed for: \"%s\", error : %s\n", filename.c_str(), strerror_r(errno, buf, 512));
}
return errorCode;
{
std::streampos size = 0;
- std::ifstream file( filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate );
- if( file.is_open() )
+ std::ifstream file(filename.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
+ if(file.is_open())
{
size = file.tellg();
file.close();
return size;
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
FileStream::Impl::Impl(const std::string& filename, uint8_t mode)
-: mFileName( filename ),
- mMode( mode ),
- mBuffer( nullptr ),
- mDataSize( 0 ),
- mFile( nullptr )
+: mFileName(filename),
+ mMode(mode),
+ mBuffer(nullptr),
+ mDataSize(0),
+ mFile(nullptr)
{
- DALI_ASSERT_DEBUG( !filename.empty() && "Can't open a empty filename." );
- DALI_ASSERT_DEBUG( mode != 0 && "No mode is undefined behaviour" );
+ DALI_ASSERT_DEBUG(!filename.empty() && "Can't open a empty filename.");
+ DALI_ASSERT_DEBUG(mode != 0 && "No mode is undefined behaviour");
}
FileStream::Impl::Impl(uint8_t* buffer, size_t dataSize, uint8_t mode)
-: mMode( mode ),
- mBuffer( buffer ),
- mDataSize( dataSize ),
- mFile( nullptr )
+: mMode(mode),
+ mBuffer(buffer),
+ mDataSize(dataSize),
+ mFile(nullptr)
{
- DALI_ASSERT_DEBUG( buffer != 0 && "Can't open file on null buffer." );
- DALI_ASSERT_DEBUG( dataSize > 0 && "Pointless to open file on empty buffer." );
- DALI_ASSERT_DEBUG( mode != 0 && "No mode is undefined behaviour." );
+ DALI_ASSERT_DEBUG(buffer != 0 && "Can't open file on null buffer.");
+ DALI_ASSERT_DEBUG(dataSize > 0 && "Pointless to open file on empty buffer.");
+ DALI_ASSERT_DEBUG(mode != 0 && "No mode is undefined behaviour.");
}
FileStream::Impl::Impl(Dali::Vector<uint8_t>& vector, size_t dataSize, uint8_t mode)
-: mMode( mode ),
- mBuffer( nullptr ),
- mDataSize( dataSize ),
- mFile( nullptr )
+: mMode(mode),
+ mBuffer(nullptr),
+ mDataSize(dataSize),
+ mFile(nullptr)
{
// Resize the buffer to ensure any null that gets written by
// fmemopen is written past the end of any data that is written to the buffer.
// null if binary mode is specified).
++mDataSize;
- vector.Resize( mDataSize );
+ vector.Resize(mDataSize);
mBuffer = &vector[0];
- DALI_ASSERT_DEBUG( mBuffer != nullptr && "Can't open file on null buffer." );
- DALI_ASSERT_DEBUG( dataSize > 0 && "Pointless to open file on empty buffer." );
- DALI_ASSERT_DEBUG( mode != 0 && "No mode is undefined behaviour." );
+ DALI_ASSERT_DEBUG(mBuffer != nullptr && "Can't open file on null buffer.");
+ DALI_ASSERT_DEBUG(dataSize > 0 && "Pointless to open file on empty buffer.");
+ DALI_ASSERT_DEBUG(mode != 0 && "No mode is undefined behaviour.");
}
FileStream::Impl::~Impl()
{
- if( mFile )
+ if(mFile)
{
- const int closeFailed = fclose( mFile );
- if( closeFailed )
+ const int closeFailed = fclose(mFile);
+ if(closeFailed)
{
- DALI_LOG_WARNING( "File close failed for FILE: \"%p\".\n", static_cast<void*>( mFile ) );
+ DALI_LOG_WARNING("File close failed for FILE: \"%p\".\n", static_cast<void*>(mFile));
}
mFile = nullptr;
}
- if( mFileStream.is_open() )
+ if(mFileStream.is_open())
{
mFileStream.close();
}
std::iostream& FileStream::Impl::GetStream()
{
- if( mFile )
+ if(mFile)
{
// return empty stream if FILE stream is open to avoid simultaneous access to the same file
return mFileStream;
}
- if( mFileStream.is_open() )
+ if(mFileStream.is_open())
{
return mFileStream;
}
- if( mBufferStream.rdbuf()->in_avail() )
+ if(mBufferStream.rdbuf()->in_avail())
{
return mBufferStream;
}
int openMode = 0;
- if( mMode & Dali::FileStream::APPEND )
+ if(mMode & Dali::FileStream::APPEND)
{
- openMode |= ( std::ios::out | std::ios::app );
+ openMode |= (std::ios::out | std::ios::app);
}
- else if( mMode & Dali::FileStream::WRITE )
+ else if(mMode & Dali::FileStream::WRITE)
{
- openMode |= ( std::ios::out | std::ios::ate );
+ openMode |= (std::ios::out | std::ios::ate);
}
- if( mMode & Dali::FileStream::READ )
+ if(mMode & Dali::FileStream::READ)
{
openMode |= std::ios::in;
}
- if( mMode & Dali::FileStream::BINARY )
+ if(mMode & Dali::FileStream::BINARY)
{
openMode |= std::ios::binary;
}
- if( !mFileName.empty() )
+ if(!mFileName.empty())
{
- mFileStream.open( mFileName, static_cast<std::ios_base::openmode>( openMode ) );
- if( !mFileStream.is_open() )
+ mFileStream.open(mFileName, static_cast<std::ios_base::openmode>(openMode));
+ if(!mFileStream.is_open())
{
- DALI_LOG_WARNING( "stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), openMode );
+ DALI_LOG_WARNING("stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), openMode);
}
return mFileStream;
}
- else if( mBuffer )
+ else if(mBuffer)
{
- mBufferStream.rdbuf()->pubsetbuf( reinterpret_cast<char*>( mBuffer ), mDataSize );
- if( !mBufferStream.rdbuf()->in_avail() )
+ mBufferStream.rdbuf()->pubsetbuf(reinterpret_cast<char*>(mBuffer), mDataSize);
+ if(!mBufferStream.rdbuf()->in_avail())
{
- DALI_LOG_WARNING( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), openMode );
+ DALI_LOG_WARNING("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
+ static_cast<void*>(mBuffer),
+ static_cast<unsigned>(mDataSize),
+ openMode);
}
}
FILE* FileStream::Impl::GetFile()
{
- if( mFileStream.is_open() || mBufferStream.rdbuf()->in_avail() )
+ if(mFileStream.is_open() || mBufferStream.rdbuf()->in_avail())
{
// return empty FILE stream if the stream is open to avoid simultaneous access to the same file
return nullptr;
}
- if( mFile )
+ if(mFile)
{
return mFile;
}
- char openMode[16] = { 0 };
- int i = 0;
+ char openMode[16] = {0};
+ int i = 0;
- if( mMode & Dali::FileStream::APPEND )
+ if(mMode & Dali::FileStream::APPEND)
{
openMode[i++] = 'a';
}
- else if( mMode & Dali::FileStream::WRITE )
+ else if(mMode & Dali::FileStream::WRITE)
{
openMode[i++] = 'w';
}
openMode[i++] = 'r';
}
- if( mMode & Dali::FileStream::BINARY )
+ if(mMode & Dali::FileStream::BINARY)
{
openMode[i++] = 'b';
}
openMode[i++] = 0;
- if( !mFileName.empty() )
+ if(!mFileName.empty())
{
- mFile = fopen( mFileName.c_str(), openMode );
- if( !mFile )
+ mFile = fopen(mFileName.c_str(), openMode);
+ if(!mFile)
{
char buf[512];
- DALI_LOG_ERROR( "file open failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode );
- DALI_LOG_ERROR( "file open failed error : %s\n", strerror_r( errno, buf, 512 ) );
+ DALI_LOG_ERROR("file open failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode);
+ DALI_LOG_ERROR("file open failed error : %s\n", strerror_r(errno, buf, 512));
}
}
- else if( mBuffer )
+ else if(mBuffer)
{
- mFile = fmemopen( mBuffer, mDataSize, openMode );
- if( !mFile )
+ mFile = fmemopen(mBuffer, mDataSize, openMode);
+ if(!mFile)
{
char buf[512];
- DALI_LOG_ERROR( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), openMode );
- DALI_LOG_ERROR( "file open failed error : %s\n", strerror_r( errno, buf, 512 ) );
+ DALI_LOG_ERROR("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
+ static_cast<void*>(mBuffer),
+ static_cast<unsigned>(mDataSize),
+ openMode);
+ DALI_LOG_ERROR("file open failed error : %s\n", strerror_r(errno, buf, 512));
}
}
return mFile;
}
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
AndroidFramework* gAndroidFramework = nullptr; // raw specific pointer to allow AndroidFramework::Get
Dali::Integration::AndroidFramework& AndroidFramework::New()
{
Dali::Integration::AndroidFramework* androidFramework = new Dali::Integration::AndroidFramework;
- AndroidFramework* impl = new AndroidFramework( androidFramework );
- androidFramework->mImpl = impl;
+ AndroidFramework* impl = new AndroidFramework(androidFramework);
+ androidFramework->mImpl = impl;
return *androidFramework;
}
void AndroidFramework::Delete()
{
- DALI_ASSERT_ALWAYS( gAndroidFramework != nullptr && "Cannot delete already deleted AndroidFramework." );
+ DALI_ASSERT_ALWAYS(gAndroidFramework != nullptr && "Cannot delete already deleted AndroidFramework.");
delete gAndroidFramework->mAndroidFramework;
gAndroidFramework = nullptr;
}
-void AndroidFramework::SetNativeApplication( android_app* application )
+void AndroidFramework::SetNativeApplication(android_app* application)
{
mNativeApplication = application;
}
return mNativeApplication;
}
-void AndroidFramework::SetJVM( JavaVM* jvm )
+void AndroidFramework::SetJVM(JavaVM* jvm)
{
mJVM = jvm;
}
return mJVM;
}
-void AndroidFramework::SetApplicationAssets( AAssetManager* assets )
+void AndroidFramework::SetApplicationAssets(AAssetManager* assets)
{
mAssets = assets;
}
return mAssets;
}
-void AndroidFramework::SetInternalDataPath( const std::string& path )
+void AndroidFramework::SetInternalDataPath(const std::string& path)
{
mInternalDataPath = path;
}
return mInternalDataPath;
}
-void AndroidFramework::SetApplicationConfiguration( AConfiguration* configuration )
+void AndroidFramework::SetApplicationConfiguration(AConfiguration* configuration)
{
mConfiguration = configuration;
}
return mConfiguration;
}
-void AndroidFramework::SetApplicationWindow( ANativeWindow* window )
+void AndroidFramework::SetApplicationWindow(ANativeWindow* window)
{
mWindow = window;
}
void AndroidFramework::OnTerminate()
{
- mFramework->AppStatusHandler( APP_DESTROYED, nullptr );
+ mFramework->AppStatusHandler(APP_DESTROYED, nullptr);
}
void AndroidFramework::OnPause()
{
- mFramework->AppStatusHandler( APP_PAUSE, nullptr );
+ mFramework->AppStatusHandler(APP_PAUSE, nullptr);
}
void AndroidFramework::OnResume()
{
- mFramework->AppStatusHandler( APP_RESUME, nullptr );
+ mFramework->AppStatusHandler(APP_RESUME, nullptr);
}
-void AndroidFramework::OnWindowCreated( ANativeWindow* window )
+void AndroidFramework::OnWindowCreated(ANativeWindow* window)
{
- mFramework->AppStatusHandler( APP_WINDOW_CREATED, window );
+ mFramework->AppStatusHandler(APP_WINDOW_CREATED, window);
}
-void AndroidFramework::OnWindowDestroyed( ANativeWindow* window )
+void AndroidFramework::OnWindowDestroyed(ANativeWindow* window)
{
- mFramework->AppStatusHandler( APP_WINDOW_DESTROYED, window );
+ mFramework->AppStatusHandler(APP_WINDOW_DESTROYED, window);
}
Dali::Integration::AndroidFramework& AndroidFramework::Get()
{
- DALI_ASSERT_ALWAYS( gAndroidFramework != nullptr && "AndroidFramework not instantiated" );
+ DALI_ASSERT_ALWAYS(gAndroidFramework != nullptr && "AndroidFramework not instantiated");
return *gAndroidFramework->mAndroidFramework;
}
-AndroidFramework::AndroidFramework( Dali::Integration::AndroidFramework* androidFramework )
- : mAndroidFramework( androidFramework ),
- mFramework( nullptr ),
- mNativeApplication( nullptr ),
- mWindow( nullptr ),
- mAssets( nullptr ),
- mConfiguration( nullptr ),
- mJVM( nullptr )
+AndroidFramework::AndroidFramework(Dali::Integration::AndroidFramework* androidFramework)
+: mAndroidFramework(androidFramework),
+ mFramework(nullptr),
+ mNativeApplication(nullptr),
+ mWindow(nullptr),
+ mAssets(nullptr),
+ mConfiguration(nullptr),
+ mJVM(nullptr)
{
- DALI_ASSERT_ALWAYS( gAndroidFramework == nullptr && "Cannot create more than one AndroidFramework." );
+ DALI_ASSERT_ALWAYS(gAndroidFramework == nullptr && "Cannot create more than one AndroidFramework.");
gAndroidFramework = this;
}
#include <dali/internal/adaptor/common/framework.h>
// EXTERNAL INCLUDES
+#include <android_native_app_glue.h>
#include <unistd.h>
#include <queue>
#include <unordered_set>
-#include <android_native_app_glue.h>
-#include <dali/integration-api/debug.h>
+#include <dali/devel-api/events/key-event-devel.h>
+#include <dali/devel-api/events/touch-point.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
-#include <dali/devel-api/events/touch-point.h>
-#include <dali/public-api/events/key-event.h>
+#include <dali/integration-api/debug.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/actors/layer.h>
-#include <dali/devel-api/events/key-event-devel.h>
+#include <dali/public-api/events/key-event.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/callback-manager.h>
#include <dali/internal/adaptor/android/android-framework-impl.h>
+#include <dali/internal/system/common/callback-manager.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
// Copied from x server
static unsigned int GetCurrentMilliSeconds(void)
{
struct timeval tv;
- struct timespec tp;
+ struct timespec tp;
static clockid_t clockid;
- if (!clockid)
+ if(!clockid)
{
#ifdef CLOCK_MONOTONIC_COARSE
- if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
- (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+ if(clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+ (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
{
clockid = CLOCK_MONOTONIC_COARSE;
}
else
#endif
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ if(clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
{
clockid = CLOCK_MONOTONIC;
}
clockid = ~0L;
}
}
- if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ if(clockid != ~0L && clock_gettime(clockid, &tp) == 0)
{
return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
}
/// Removes constraints from all actors in all windows.
void RemoveAllConstraints(const Dali::WindowContainer& windows)
{
- for( auto& window : windows )
+ for(auto& window : windows)
{
RemoveAllConstraints(window.GetRootLayer());
}
*/
struct Framework::Impl
{
-
struct IdleCallback
{
- int timestamp;
- int timeout;
- int id;
+ int timestamp;
+ int timeout;
+ int id;
void* data;
- bool ( *callback )( void *data );
+ bool (*callback)(void* data);
- IdleCallback( int timeout, int id, void* data, bool ( *callback )( void *data ) )
- : timestamp( GetCurrentMilliSeconds() + timeout ),
- timeout( timeout ),
- id ( id ),
- data( data ),
- callback( callback )
+ IdleCallback(int timeout, int id, void* data, bool (*callback)(void* data))
+ : timestamp(GetCurrentMilliSeconds() + timeout),
+ timeout(timeout),
+ id(id),
+ data(data),
+ callback(callback)
{
}
bool operator()()
{
- return callback( data );
+ return callback(data);
}
- bool operator<( const IdleCallback& rhs ) const
+ bool operator<(const IdleCallback& rhs) const
{
return timestamp > rhs.timestamp;
}
// Constructor
- Impl( Framework* framework )
- : mAbortCallBack( nullptr ),
- mCallbackManager( CallbackManager::New() ),
- mLanguage( "NOT_SUPPORTED" ),
- mRegion( "NOT_SUPPORTED" ),
- mFinishRequested( false ),
- mIdleId( 0 ),
- mIdleReadPipe( -1 ),
- mIdleWritePipe( -1 )
-
+ Impl(Framework* framework)
+ : mAbortCallBack(nullptr),
+ mCallbackManager(CallbackManager::New()),
+ mLanguage("NOT_SUPPORTED"),
+ mRegion("NOT_SUPPORTED"),
+ mFinishRequested(false),
+ mIdleId(0),
+ mIdleReadPipe(-1),
+ mIdleWritePipe(-1)
{
- AndroidFramework::GetImplementation( AndroidFramework::Get() ).SetFramework( framework );
+ AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(framework);
}
~Impl()
{
- AndroidFramework::GetImplementation( AndroidFramework::Get() ).SetFramework( nullptr );
+ AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(nullptr);
delete mAbortCallBack;
mAbortCallBack = nullptr;
{
// Dequeue the pipe
int8_t msg = -1;
- read( mIdleReadPipe, &msg, sizeof( msg ) );
+ read(mIdleReadPipe, &msg, sizeof(msg));
unsigned int ts = GetCurrentMilliSeconds();
- if ( !mIdleCallbacks.empty() )
+ if(!mIdleCallbacks.empty())
{
IdleCallback callback = mIdleCallbacks.top();
- if( callback.timestamp <= ts )
+ if(callback.timestamp <= ts)
{
mIdleCallbacks.pop();
// Callback wasn't removed
- if( mRemovedIdleCallbacks.find( callback.id ) == mRemovedIdleCallbacks.end() )
+ if(mRemovedIdleCallbacks.find(callback.id) == mRemovedIdleCallbacks.end())
{
- if ( callback() ) // keep the callback
+ if(callback()) // keep the callback
{
- AddIdle( callback.timeout, callback.data, callback.callback, callback.id );
+ AddIdle(callback.timeout, callback.data, callback.callback, callback.id);
}
}
// Callback cane be also removed during the callback call
- auto i = mRemovedIdleCallbacks.find( callback.id );
- if( i != mRemovedIdleCallbacks.end() )
+ auto i = mRemovedIdleCallbacks.find(callback.id);
+ if(i != mRemovedIdleCallbacks.end())
{
- mRemovedIdleCallbacks.erase( i );
+ mRemovedIdleCallbacks.erase(i);
}
}
}
- if( mIdleCallbacks.empty() )
+ if(mIdleCallbacks.empty())
{
mRemovedIdleCallbacks.clear();
}
}
- unsigned int AddIdle( int timeout, void* data, bool ( *callback )( void *data ) , unsigned int existingId = 0 )
+ unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data), unsigned int existingId = 0)
{
unsigned int chosenId;
- if (existingId)
+ if(existingId)
{
chosenId = existingId;
}
else
{
++mIdleId;
- if( mIdleId == 0 )
+ if(mIdleId == 0)
{
++mIdleId;
}
chosenId = mIdleId;
}
- mIdleCallbacks.push( IdleCallback( timeout, chosenId, data, callback ) );
+ mIdleCallbacks.push(IdleCallback(timeout, chosenId, data, callback));
// To wake up the idle pipe and to trigger OnIdle
int8_t msg = 1;
- write( mIdleWritePipe, &msg, sizeof( msg ) );
+ write(mIdleWritePipe, &msg, sizeof(msg));
return chosenId;
}
- void RemoveIdle( unsigned int id )
+ void RemoveIdle(unsigned int id)
{
- if( id != 0 )
+ if(id != 0)
{
- mRemovedIdleCallbacks.insert( id );
+ mRemovedIdleCallbacks.insert(id);
}
}
{
int timeout = -1;
- if( !mIdleCallbacks.empty() )
+ if(!mIdleCallbacks.empty())
{
IdleCallback idleTimeout = mIdleCallbacks.top();
- timeout = idleTimeout.timestamp - GetCurrentMilliSeconds();
- if( timeout < 0 )
+ timeout = idleTimeout.timestamp - GetCurrentMilliSeconds();
+ if(timeout < 0)
{
- timeout = 0;
+ timeout = 0;
}
}
}
// Data
- CallbackBase* mAbortCallBack;
+ CallbackBase* mAbortCallBack;
CallbackManager* mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
- bool mFinishRequested;
+ std::string mLanguage;
+ std::string mRegion;
+ bool mFinishRequested;
- int mIdleReadPipe;
- int mIdleWritePipe;
- unsigned int mIdleId;
+ int mIdleReadPipe;
+ int mIdleWritePipe;
+ unsigned int mIdleId;
std::priority_queue<IdleCallback> mIdleCallbacks;
- std::unordered_set<int> mRemovedIdleCallbacks;
+ std::unordered_set<int> mRemovedIdleCallbacks;
// Static methods
/**
* Called by the native activity loop when the application APP_CMD_INIT_WINDOW event is processed.
*/
- static void NativeWindowCreated( Framework* framework, ANativeWindow* window )
+ static void NativeWindowCreated(Framework* framework, ANativeWindow* window)
{
- if( framework )
+ if(framework)
{
- framework->AppStatusHandler( APP_WINDOW_CREATED, window );
+ framework->AppStatusHandler(APP_WINDOW_CREATED, window);
}
}
/**
* Called by the native activity loop when the application APP_CMD_DESTROY event is processed.
*/
- static void NativeWindowDestroyed( Framework* framework, ANativeWindow* window )
+ static void NativeWindowDestroyed(Framework* framework, ANativeWindow* window)
{
- if( framework )
+ if(framework)
{
- framework->AppStatusHandler( APP_WINDOW_DESTROYED, window );
+ framework->AppStatusHandler(APP_WINDOW_DESTROYED, window);
}
}
/**
* Called by the native activity loop when the application APP_CMD_INIT_WINDOW event is processed.
*/
- static void NativeAppPaused( Framework* framework )
+ static void NativeAppPaused(Framework* framework)
{
- if( framework )
+ if(framework)
{
- framework->AppStatusHandler( APP_PAUSE, nullptr );
+ framework->AppStatusHandler(APP_PAUSE, nullptr);
}
}
/**
* Called by the native activity loop when the application APP_CMD_TERM_WINDOW event is processed.
*/
- static void NativeAppResumed( Framework* framework )
+ static void NativeAppResumed(Framework* framework)
{
- if( framework )
+ if(framework)
{
- framework->AppStatusHandler( APP_RESUME, nullptr );
+ framework->AppStatusHandler(APP_RESUME, nullptr);
}
}
/**
* Called by the native activity loop when the application input touch event is processed.
*/
- static void NativeAppTouchEvent( Framework* framework, Dali::TouchPoint& touchPoint, int64_t timeStamp )
+ static void NativeAppTouchEvent(Framework* framework, Dali::TouchPoint& touchPoint, int64_t timeStamp)
{
- Dali::Adaptor::Get().FeedTouchPoint( touchPoint, timeStamp );
+ Dali::Adaptor::Get().FeedTouchPoint(touchPoint, timeStamp);
}
/**
* Called by the native activity loop when the application input key event is processed.
*/
- static void NativeAppKeyEvent( Framework* framework, Dali::KeyEvent& keyEvent )
+ static void NativeAppKeyEvent(Framework* framework, Dali::KeyEvent& keyEvent)
{
- Dali::Adaptor::Get().FeedKeyEvent( keyEvent );
+ Dali::Adaptor::Get().FeedKeyEvent(keyEvent);
}
/**
* Called by the native activity loop when the application APP_CMD_DESTROY event is processed.
*/
- static void NativeAppDestroyed( Framework* framework )
+ static void NativeAppDestroyed(Framework* framework)
{
- if( framework )
+ if(framework)
{
- framework->AppStatusHandler( APP_DESTROYED, nullptr );
+ framework->AppStatusHandler(APP_DESTROYED, nullptr);
}
}
-/*
+ /*
Order of events:
APP_CMD_START
static void HandleAppCmd(struct android_app* app, int32_t cmd)
{
- Framework* framework = AndroidFramework::GetImplementation( AndroidFramework::Get() ).GetFramework();
- switch( cmd )
+ Framework* framework = AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework();
+ switch(cmd)
{
case APP_CMD_SAVE_STATE:
break;
break;
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
- AndroidFramework::Get().SetApplicationWindow( app->window );
- Dali::Internal::Adaptor::Framework::Impl::NativeWindowCreated( framework, app->window );
- Dali::Internal::Adaptor::Framework::Impl::NativeAppResumed( framework );
+ AndroidFramework::Get().SetApplicationWindow(app->window);
+ Dali::Internal::Adaptor::Framework::Impl::NativeWindowCreated(framework, app->window);
+ Dali::Internal::Adaptor::Framework::Impl::NativeAppResumed(framework);
break;
case APP_CMD_TERM_WINDOW:
// The window is being hidden or closed, clean it up.
- AndroidFramework::Get().SetApplicationWindow( nullptr );
- Dali::Internal::Adaptor::Framework::Impl::NativeAppPaused( framework );
- Dali::Internal::Adaptor::Framework::Impl::NativeWindowDestroyed( framework, app->window );
+ AndroidFramework::Get().SetApplicationWindow(nullptr);
+ Dali::Internal::Adaptor::Framework::Impl::NativeAppPaused(framework);
+ Dali::Internal::Adaptor::Framework::Impl::NativeWindowDestroyed(framework, app->window);
break;
case APP_CMD_GAINED_FOCUS:
break;
case APP_CMD_LOST_FOCUS:
break;
case APP_CMD_DESTROY:
- Dali::Internal::Adaptor::Framework::Impl::NativeAppPaused( framework );
- Dali::Internal::Adaptor::Framework::Impl::NativeAppDestroyed( framework );
+ Dali::Internal::Adaptor::Framework::Impl::NativeAppPaused(framework);
+ Dali::Internal::Adaptor::Framework::Impl::NativeAppDestroyed(framework);
break;
}
}
static int32_t HandleAppInput(struct android_app* app, AInputEvent* event)
{
- Framework* framework = AndroidFramework::GetImplementation( AndroidFramework::Get() ).GetFramework();
+ Framework* framework = AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework();
- if( AInputEvent_getType( event ) == AINPUT_EVENT_TYPE_MOTION )
+ if(AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
{
- int32_t deviceId = AInputEvent_getDeviceId( event );
- float x = AMotionEvent_getX( event, 0 );
- float y = AMotionEvent_getY( event, 0 );
- Dali::PointState::Type state = Dali::PointState::DOWN;
- int32_t action = AMotionEvent_getAction( event );
- int64_t timeStamp = AMotionEvent_getEventTime( event );
+ int32_t deviceId = AInputEvent_getDeviceId(event);
+ float x = AMotionEvent_getX(event, 0);
+ float y = AMotionEvent_getY(event, 0);
+ Dali::PointState::Type state = Dali::PointState::DOWN;
+ int32_t action = AMotionEvent_getAction(event);
+ int64_t timeStamp = AMotionEvent_getEventTime(event);
- switch ( action & AMOTION_EVENT_ACTION_MASK )
+ switch(action & AMOTION_EVENT_ACTION_MASK)
{
- case AMOTION_EVENT_ACTION_DOWN:
- break;
- case AMOTION_EVENT_ACTION_UP:
- state = Dali::PointState::UP;
- break;
- case AMOTION_EVENT_ACTION_MOVE:
- state = Dali::PointState::MOTION;
- break;
- case AMOTION_EVENT_ACTION_CANCEL:
- state = Dali::PointState::INTERRUPTED;
- break;
- case AMOTION_EVENT_ACTION_OUTSIDE:
- state = Dali::PointState::LEAVE;
- break;
+ case AMOTION_EVENT_ACTION_DOWN:
+ break;
+ case AMOTION_EVENT_ACTION_UP:
+ state = Dali::PointState::UP;
+ break;
+ case AMOTION_EVENT_ACTION_MOVE:
+ state = Dali::PointState::MOTION;
+ break;
+ case AMOTION_EVENT_ACTION_CANCEL:
+ state = Dali::PointState::INTERRUPTED;
+ break;
+ case AMOTION_EVENT_ACTION_OUTSIDE:
+ state = Dali::PointState::LEAVE;
+ break;
}
- Dali::TouchPoint point( deviceId, state, x, y );
- Dali::Internal::Adaptor::Framework::Impl::NativeAppTouchEvent( framework, point, timeStamp );
+ Dali::TouchPoint point(deviceId, state, x, y);
+ Dali::Internal::Adaptor::Framework::Impl::NativeAppTouchEvent(framework, point, timeStamp);
return 1;
}
- else if ( AInputEvent_getType( event ) == AINPUT_EVENT_TYPE_KEY )
+ else if(AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
{
- int32_t deviceId = AInputEvent_getDeviceId( event );
- int32_t keyCode = AKeyEvent_getKeyCode( event );
- int32_t action = AKeyEvent_getAction( event );
- int64_t timeStamp = AKeyEvent_getEventTime( event );
+ int32_t deviceId = AInputEvent_getDeviceId(event);
+ int32_t keyCode = AKeyEvent_getKeyCode(event);
+ int32_t action = AKeyEvent_getAction(event);
+ int64_t timeStamp = AKeyEvent_getEventTime(event);
Dali::KeyEvent::State state = Dali::KeyEvent::DOWN;
- switch ( action )
+ switch(action)
{
- case AKEY_EVENT_ACTION_DOWN:
- break;
- case AKEY_EVENT_ACTION_UP:
- state = Dali::KeyEvent::UP;
- break;
+ case AKEY_EVENT_ACTION_DOWN:
+ break;
+ case AKEY_EVENT_ACTION_UP:
+ state = Dali::KeyEvent::UP;
+ break;
}
std::string keyName = "";
- switch( keyCode )
+ switch(keyCode)
{
- case 4:
- keyName = "XF86Back";
- break;
- default:
- break;
+ case 4:
+ keyName = "XF86Back";
+ break;
+ default:
+ break;
}
- Dali::KeyEvent keyEvent = Dali::DevelKeyEvent::New( keyName, "", "", keyCode, 0, timeStamp, state, "", "", Device::Class::NONE, Device::Subclass::NONE );
- Dali::Internal::Adaptor::Framework::Impl::NativeAppKeyEvent( framework, keyEvent );
+ Dali::KeyEvent keyEvent = Dali::DevelKeyEvent::New(keyName, "", "", keyCode, 0, timeStamp, state, "", "", Device::Class::NONE, Device::Subclass::NONE);
+ Dali::Internal::Adaptor::Framework::Impl::NativeAppKeyEvent(framework, keyEvent);
return 1;
}
return 0;
}
- static void HandleAppIdle(struct android_app* app, struct android_poll_source* source) {
- Framework* framework = AndroidFramework::GetImplementation( AndroidFramework::Get() ).GetFramework();
- if( framework && framework->mImpl )
+ static void HandleAppIdle(struct android_app* app, struct android_poll_source* source)
+ {
+ Framework* framework = AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework();
+ if(framework && framework->mImpl)
{
framework->mImpl->OnIdle();
}
}
-
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
-: mObserver( observer ),
- mInitialised( false ),
+Framework::Framework(Framework::Observer& observer, int* argc, char*** argv, Type type)
+: mObserver(observer),
+ mInitialised(false),
mPaused(false),
- mRunning( false ),
- mArgc( argc ),
- mArgv( argv ),
- mBundleName( "" ),
- mBundleId( "" ),
- mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
- mImpl( NULL )
+ mRunning(false),
+ mArgc(argc),
+ mArgv(argv),
+ mBundleName(""),
+ mBundleId(""),
+ mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
+ mImpl(NULL)
{
- mImpl = new Impl( this );
+ mImpl = new Impl(this);
}
Framework::~Framework()
{
- if( mRunning )
+ if(mRunning)
{
Quit();
}
void Framework::Run()
{
struct android_app* app = AndroidFramework::Get().GetNativeApplication();
- app->onAppCmd = Framework::Impl::HandleAppCmd;
- app->onInputEvent = Framework::Impl::HandleAppInput;
+ app->onAppCmd = Framework::Impl::HandleAppCmd;
+ app->onInputEvent = Framework::Impl::HandleAppInput;
struct android_poll_source* source;
- struct android_poll_source idlePollSource;
- idlePollSource.id = LOOPER_ID_USER;
- idlePollSource.app = app;
+ struct android_poll_source idlePollSource;
+ idlePollSource.id = LOOPER_ID_USER;
+ idlePollSource.app = app;
idlePollSource.process = Impl::HandleAppIdle;
int idlePipe[2];
- if( pipe( idlePipe ) )
+ if(pipe(idlePipe))
{
- DALI_LOG_ERROR( "Failed to open idle pipe\n" );
+ DALI_LOG_ERROR("Failed to open idle pipe\n");
return;
}
- mImpl->mIdleReadPipe = idlePipe[0];
+ mImpl->mIdleReadPipe = idlePipe[0];
mImpl->mIdleWritePipe = idlePipe[1];
- ALooper_addFd( app->looper,
- idlePipe[0], LOOPER_ID_USER, ALOOPER_EVENT_INPUT, NULL, &idlePollSource );
+ ALooper_addFd(app->looper,
+ idlePipe[0],
+ LOOPER_ID_USER,
+ ALOOPER_EVENT_INPUT,
+ NULL,
+ &idlePollSource);
mRunning = true;
int events;
int idleTimeout = -1;
- while( true )
+ while(true)
{
- if ( mImpl )
+ if(mImpl)
{
idleTimeout = mImpl->GetIdleTimeout();
}
- int id = ALooper_pollAll( idleTimeout, NULL, &events, (void**)&source );
+ int id = ALooper_pollAll(idleTimeout, NULL, &events, (void**)&source);
// Process the error.
- if( id == ALOOPER_POLL_ERROR )
+ if(id == ALOOPER_POLL_ERROR)
{
- DALI_LOG_ERROR( "ALooper error\n" );
- Quit();
- std::abort();
+ DALI_LOG_ERROR("ALooper error\n");
+ Quit();
+ std::abort();
}
// Process the timeout, trigger OnIdle.
- if( id == ALOOPER_POLL_TIMEOUT )
+ if(id == ALOOPER_POLL_TIMEOUT)
{
int8_t msg = 1;
- write( mImpl->mIdleWritePipe, &msg, sizeof( msg ) );
+ write(mImpl->mIdleWritePipe, &msg, sizeof(msg));
}
// Process the application event.
- if( id >= 0 && source != NULL )
+ if(id >= 0 && source != NULL)
{
- source->process( app, source );
+ source->process(app, source);
}
// Check if we are exiting.
- if( app->destroyRequested )
+ if(app->destroyRequested)
{
break;
}
}
- while (!mImpl->mIdleCallbacks.empty())
+ while(!mImpl->mIdleCallbacks.empty())
{
mImpl->mIdleCallbacks.pop();
}
mImpl->mRemovedIdleCallbacks.clear();
mImpl->mIdleId = 0;
- ALooper_removeFd( app->looper, idlePipe[0] );
- if ( mImpl )
+ ALooper_removeFd(app->looper, idlePipe[0]);
+ if(mImpl)
{
- mImpl->mIdleReadPipe = -1;
+ mImpl->mIdleReadPipe = -1;
mImpl->mIdleWritePipe = -1;
}
- close( idlePipe[0] );
- close( idlePipe[1] );
+ close(idlePipe[0]);
+ close(idlePipe[1]);
mRunning = false;
}
-unsigned int Framework::AddIdle( int timeout, void* data, bool ( *callback )( void *data ) )
+unsigned int Framework::AddIdle(int timeout, void* data, bool (*callback)(void* data))
{
- if( mImpl )
+ if(mImpl)
{
- return mImpl->AddIdle( timeout, data, callback );
+ return mImpl->AddIdle(timeout, data, callback);
}
return -1;
}
-void Framework::RemoveIdle( unsigned int id )
+void Framework::RemoveIdle(unsigned int id)
{
- if( mImpl )
+ if(mImpl)
{
- mImpl->RemoveIdle( id );
+ mImpl->RemoveIdle(id);
}
}
void Framework::Quit()
{
struct android_app* app = AndroidFramework::Get().GetNativeApplication();
- if( app && !app->destroyRequested && !mImpl->mFinishRequested )
+ if(app && !app->destroyRequested && !mImpl->mFinishRequested)
{
mImpl->mFinishRequested = true;
- ANativeActivity_finish( app->activity );
+ ANativeActivity_finish(app->activity);
}
}
return mRunning;
}
-void Framework::AddAbortCallback( CallbackBase* callback )
+void Framework::AddAbortCallback(CallbackBase* callback)
{
mImpl->mAbortCallBack = callback;
}
mBundleId = id;
}
-void Framework::AbortCallback( )
+void Framework::AbortCallback()
{
// if an abort call back has been installed run it.
- if( mImpl->mAbortCallBack )
+ if(mImpl->mAbortCallBack)
{
- CallbackBase::Execute( *mImpl->mAbortCallBack );
+ CallbackBase::Execute(*mImpl->mAbortCallBack);
}
else
{
bool Framework::AppStatusHandler(int type, void* data)
{
Dali::Adaptor* adaptor = nullptr;
- switch (type)
+ switch(type)
{
case APP_WINDOW_CREATED:
{
- if( !mInitialised )
+ if(!mInitialised)
{
mObserver.OnInit();
mInitialised = true;
}
- mObserver.OnSurfaceCreated( data );
+ mObserver.OnSurfaceCreated(data);
break;
}
case APP_WINDOW_DESTROYED:
{
- mObserver.OnSurfaceDestroyed( data );
+ mObserver.OnSurfaceDestroyed(data);
break;
}
/*
- * Copyright (c) 2019 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.
#include <dali/internal/adaptor/common/framework.h>
// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/application-devel.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
+#include <dali/integration-api/debug.h>
#include <dali/public-api/adaptor-framework/application.h>
-#include <dali/devel-api/adaptor-framework/application-devel.h>
// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/application-impl.h>
#include <dali/internal/adaptor/android/android-framework-impl.h>
+#include <dali/internal/adaptor/common/application-impl.h>
#include <dali/internal/system/common/callback-manager.h>
using namespace Dali;
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Impl to hide android data members
*/
{
// Constructor
- Impl( Framework* framework )
- : mAbortCallBack( nullptr ),
- mCallbackManager( CallbackManager::New() ),
- mLanguage( "NOT_SUPPORTED" ),
- mRegion( "NOT_SUPPORTED" )
+ Impl(Framework* framework)
+ : mAbortCallBack(nullptr),
+ mCallbackManager(CallbackManager::New()),
+ mLanguage("NOT_SUPPORTED"),
+ mRegion("NOT_SUPPORTED")
{
- AndroidFramework::GetImplementation( AndroidFramework::Get() ).SetFramework( framework );
+ AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(framework);
}
~Impl()
{
- AndroidFramework::GetImplementation( AndroidFramework::Get() ).SetFramework( nullptr );
+ AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(nullptr);
delete mAbortCallBack;
mAbortCallBack = nullptr;
return mRegion;
}
- CallbackBase* mAbortCallBack;
+ CallbackBase* mAbortCallBack;
CallbackManager* mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
+ std::string mLanguage;
+ std::string mRegion;
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
-: mObserver( observer ),
- mInitialised( false ),
- mPaused( false ),
- mRunning( false ),
- mArgc( argc ),
- mArgv( argv ),
- mBundleName( "" ),
- mBundleId( "" ),
- mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
- mImpl( NULL )
+Framework::Framework(Framework::Observer& observer, int* argc, char*** argv, Type type)
+: mObserver(observer),
+ mInitialised(false),
+ mPaused(false),
+ mRunning(false),
+ mArgc(argc),
+ mArgv(argv),
+ mBundleName(""),
+ mBundleId(""),
+ mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
+ mImpl(NULL)
{
- mImpl = new Impl( this );
+ mImpl = new Impl(this);
}
Framework::~Framework()
{
- if( mRunning )
+ if(mRunning)
{
Quit();
}
void Framework::Run()
{
- AndroidFramework::GetImplementation( AndroidFramework::Get() ).SetFramework( this );
+ AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(this);
mRunning = true;
}
-unsigned int Framework::AddIdle( int timeout, void* data, bool ( *callback )( void *data ) )
+unsigned int Framework::AddIdle(int timeout, void* data, bool (*callback)(void* data))
{
- JNIEnv *env = nullptr;
+ JNIEnv* env = nullptr;
JavaVM* javaVM = AndroidFramework::Get().GetJVM();
- if( javaVM == nullptr || javaVM->GetEnv( reinterpret_cast<void **>( &env ), JNI_VERSION_1_6 ) != JNI_OK )
+ if(javaVM == nullptr || javaVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
{
DALI_LOG_ERROR("Couldn't get JNI env.");
return -1;
}
- jclass clazz = env->FindClass( "com/sec/daliview/DaliView" );
- if ( !clazz )
+ jclass clazz = env->FindClass("com/sec/daliview/DaliView");
+ if(!clazz)
{
DALI_LOG_ERROR("Couldn't find com.sec.daliview.DaliView.");
return -1;
}
- jmethodID addIdle = env->GetStaticMethodID( clazz, "addIdle", "(JJJ)I" );
- if (!addIdle)
+ jmethodID addIdle = env->GetStaticMethodID(clazz, "addIdle", "(JJJ)I");
+ if(!addIdle)
{
DALI_LOG_ERROR("Couldn't find com.sec.daliview.DaliView.addIdle.");
return -1;
}
- jint id = env->CallStaticIntMethod( clazz, addIdle, reinterpret_cast<jlong>( callback ), reinterpret_cast<jlong>( data ), static_cast<jlong>( timeout ) );
- return static_cast<unsigned int>( id );
+ jint id = env->CallStaticIntMethod(clazz, addIdle, reinterpret_cast<jlong>(callback), reinterpret_cast<jlong>(data), static_cast<jlong>(timeout));
+ return static_cast<unsigned int>(id);
}
-void Framework::RemoveIdle( unsigned int id )
+void Framework::RemoveIdle(unsigned int id)
{
- JNIEnv *env = nullptr;
+ JNIEnv* env = nullptr;
JavaVM* javaVM = AndroidFramework::Get().GetJVM();
- if( javaVM == nullptr || javaVM->GetEnv( reinterpret_cast<void **>( &env ), JNI_VERSION_1_6 ) != JNI_OK )
+ if(javaVM == nullptr || javaVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK)
{
DALI_LOG_ERROR("Couldn't get JNI env.");
return;
}
- jclass clazz = env->FindClass( "com/sec/daliview/DaliView" );
- if( !clazz )
+ jclass clazz = env->FindClass("com/sec/daliview/DaliView");
+ if(!clazz)
{
DALI_LOG_ERROR("Couldn't find com.sec.daliview.DaliView.");
return;
}
- jmethodID removeIdle = env->GetStaticMethodID( clazz, "removeIdle", "(I)V" );
- if( !removeIdle )
+ jmethodID removeIdle = env->GetStaticMethodID(clazz, "removeIdle", "(I)V");
+ if(!removeIdle)
{
DALI_LOG_ERROR("Couldn't find com.sec.daliview.DaliView.removeIdle.");
return;
}
- env->CallStaticVoidMethod( clazz, removeIdle, static_cast<jint>( id ) );
+ env->CallStaticVoidMethod(clazz, removeIdle, static_cast<jint>(id));
}
void Framework::Quit()
return mRunning;
}
-void Framework::AddAbortCallback( CallbackBase* callback )
+void Framework::AddAbortCallback(CallbackBase* callback)
{
mImpl->mAbortCallBack = callback;
}
mBundleId = id;
}
-void Framework::AbortCallback( )
+void Framework::AbortCallback()
{
// if an abort call back has been installed run it.
- if (mImpl->mAbortCallBack)
+ if(mImpl->mAbortCallBack)
{
- CallbackBase::Execute( *mImpl->mAbortCallBack );
+ CallbackBase::Execute(*mImpl->mAbortCallBack);
}
else
{
bool Framework::AppStatusHandler(int type, void* data)
{
Dali::Adaptor* adaptor = nullptr;
- switch (type)
+ switch(type)
{
case APP_WINDOW_CREATED:
- if( !mInitialised )
+ if(!mInitialised)
{
mObserver.OnInit();
mInitialised = true;
}
- mObserver.OnSurfaceCreated( data );
+ mObserver.OnSurfaceCreated(data);
break;
case APP_WINDOW_DESTROYED:
- mObserver.OnSurfaceDestroyed( data );
+ mObserver.OnSurfaceDestroyed(data);
break;
case APP_RESET:
case APP_DESTROYED:
mObserver.OnTerminate();
- mRunning = false;
- mPaused = false;
+ mRunning = false;
+ mPaused = false;
mInitialised = false;
break;
/*
- * 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.
#include <dali/integration-api/adaptor-framework/adaptor.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/object-registry.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/object-registry.h>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/style-monitor.h>
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
#include <dali/integration-api/adaptor-framework/scene-holder.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/adaptor/common/thread-controller-interface.h>
+#include <dali/internal/window-system/common/window-impl.h>
namespace Dali
{
-
-Adaptor& Adaptor::New( Window window )
+Adaptor& Adaptor::New(Window window)
{
- Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window );
- Adaptor* adaptor = Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( sceneHolder ), NULL );
+ Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
+ Adaptor* adaptor = Internal::Adaptor::Adaptor::New(Dali::Integration::SceneHolder(sceneHolder), NULL);
return *adaptor;
}
-Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface )
+Adaptor& Adaptor::New(Window window, const Dali::RenderSurfaceInterface& surface)
{
- Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window );
- Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface *>(&surface);
- Adaptor* adaptor = Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( sceneHolder ), pSurface, NULL, Dali::Internal::Adaptor::ThreadMode::NORMAL );
+ Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
+ Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface*>(&surface);
+ Adaptor* adaptor = Internal::Adaptor::Adaptor::New(Dali::Integration::SceneHolder(sceneHolder), pSurface, NULL, Dali::Internal::Adaptor::ThreadMode::NORMAL);
return *adaptor;
}
-Adaptor& Adaptor::New( Dali::Integration::SceneHolder window )
+Adaptor& Adaptor::New(Dali::Integration::SceneHolder window)
{
- Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, NULL );
+ Adaptor* adaptor = Internal::Adaptor::Adaptor::New(window, NULL);
return *adaptor;
}
-Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface )
+Adaptor& Adaptor::New(Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface)
{
- Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface *>(&surface);
- Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, pSurface, NULL, Dali::Internal::Adaptor::ThreadMode::NORMAL );
+ Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface*>(&surface);
+ Adaptor* adaptor = Internal::Adaptor::Adaptor::New(window, pSurface, NULL, Dali::Internal::Adaptor::ThreadMode::NORMAL);
return *adaptor;
}
mImpl->Stop();
}
-bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
{
- DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
- return mImpl->AddIdle( callback, hasReturnValue, false );
+ DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
+ return mImpl->AddIdle(callback, hasReturnValue, false);
}
-bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow )
+bool Adaptor::AddWindow(Dali::Integration::SceneHolder childWindow)
{
- DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
- return mImpl->AddWindow( childWindow );
+ DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
+ return mImpl->AddWindow(childWindow);
}
-void Adaptor::RemoveIdle( CallbackBase* callback )
+void Adaptor::RemoveIdle(CallbackBase* callback)
{
- DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
- mImpl->RemoveIdle( callback );
+ DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
+ mImpl->RemoveIdle(callback);
}
void Adaptor::ProcessIdle()
{
- DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
+ DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
mImpl->ProcessIdle();
}
-void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
+void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& surface)
{
- Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window );
- mImpl->ReplaceSurface( Dali::Integration::SceneHolder( sceneHolder ), surface );
+ Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
+ mImpl->ReplaceSurface(Dali::Integration::SceneHolder(sceneHolder), surface);
}
-void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
+void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface)
{
- mImpl->ReplaceSurface( window, surface );
+ mImpl->ReplaceSurface(window, surface);
}
Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
return mImpl->GetNativeWindowHandle();
}
-Any Adaptor::GetNativeWindowHandle( Actor actor )
+Any Adaptor::GetNativeWindowHandle(Actor actor)
{
- return mImpl->GetNativeWindowHandle( actor );
+ return mImpl->GetNativeWindowHandle(actor);
}
Any Adaptor::GetGraphicsDisplay()
mImpl->ReleaseSurfaceLock();
}
-void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
+void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
{
- mImpl->SetRenderRefreshRate( numberOfVSyncsPerRender );
+ mImpl->SetRenderRefreshRate(numberOfVSyncsPerRender);
}
-void Adaptor::SetPreRenderCallback( CallbackBase* callback )
+void Adaptor::SetPreRenderCallback(CallbackBase* callback)
{
- mImpl->SetPreRenderCallback( callback );
+ mImpl->SetPreRenderCallback(callback);
}
Adaptor& Adaptor::Get()
mImpl->NotifyLanguageChanged();
}
-void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
+void Adaptor::FeedTouchPoint(TouchPoint& point, int timeStamp)
{
mImpl->FeedTouchPoint(point, timeStamp);
}
-void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
+void Adaptor::FeedWheelEvent(WheelEvent& wheelEvent)
{
mImpl->FeedWheelEvent(wheelEvent);
}
-void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
+void Adaptor::FeedKeyEvent(KeyEvent& keyEvent)
{
mImpl->FeedKeyEvent(keyEvent);
}
mImpl->SceneCreated();
}
-void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
{
- mImpl->SurfaceResizePrepare( surface, surfaceSize );
+ mImpl->SurfaceResizePrepare(surface, surfaceSize);
}
-void Adaptor::SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
{
- mImpl->SurfaceResizeComplete( surface, surfaceSize );
+ mImpl->SurfaceResizeComplete(surface, surfaceSize);
}
void Adaptor::RenderOnce()
return mImpl->GetLogFactory();
}
-void Adaptor::RegisterProcessor( Integration::Processor& processor )
+void Adaptor::RegisterProcessor(Integration::Processor& processor)
{
- mImpl->RegisterProcessor( processor );
+ mImpl->RegisterProcessor(processor);
}
-void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+void Adaptor::UnregisterProcessor(Integration::Processor& processor)
{
- mImpl->UnregisterProcessor( processor );
+ mImpl->UnregisterProcessor(processor);
}
Dali::WindowContainer Adaptor::GetWindows() const
}
Adaptor::Adaptor()
-: mImpl( NULL )
+: mImpl(NULL)
{
}
/*
- * 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.
#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
Dali::LifecycleController LifecycleController::Get()
{
Dali::LifecycleController lifecycleController;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::LifecycleController ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::LifecycleController));
if(handle)
{
// If so, downcast the handle
- lifecycleController = Dali::LifecycleController( dynamic_cast< LifecycleController* >( handle.GetObjectPtr() ) );
+ lifecycleController = Dali::LifecycleController(dynamic_cast<LifecycleController*>(handle.GetObjectPtr()));
}
else
{
- lifecycleController = Dali::LifecycleController( new LifecycleController() );
- service.Register( typeid( lifecycleController ), lifecycleController );
+ lifecycleController = Dali::LifecycleController(new LifecycleController());
+ service.Register(typeid(lifecycleController), lifecycleController);
}
}
void LifecycleController::EmitInitSignal()
{
- if( !mInitSignal.Empty() )
+ if(!mInitSignal.Empty())
{
mInitSignal.Emit();
}
void LifecycleController::EmitTerminateSignal()
{
- if( !mTerminateSignal.Empty() )
+ if(!mTerminateSignal.Empty())
{
mTerminateSignal.Emit();
}
void LifecycleController::EmitPauseSignal()
{
- if( !mPauseSignal.Empty() )
+ if(!mPauseSignal.Empty())
{
mPauseSignal.Emit();
}
void LifecycleController::EmitResumeSignal()
{
- if( !mResumeSignal.Empty() )
+ if(!mResumeSignal.Empty())
{
mResumeSignal.Emit();
}
void LifecycleController::EmitResetSignal()
{
- if( !mResetSignal.Empty() )
+ if(!mResetSignal.Empty())
{
mResetSignal.Emit();
}
void LifecycleController::EmitLanguageChangedSignal()
{
- if( !mLanguageChangedSignal.Empty() )
+ if(!mLanguageChangedSignal.Empty())
{
mLanguageChangedSignal.Emit();
}
}
-void LifecycleController::OnInit( Dali::Application& app )
+void LifecycleController::OnInit(Dali::Application& app)
{
EmitInitSignal();
}
-void LifecycleController::OnTerminate( Dali::Application& app )
+void LifecycleController::OnTerminate(Dali::Application& app)
{
EmitTerminateSignal();
}
-void LifecycleController::OnPause( Dali::Application& app )
+void LifecycleController::OnPause(Dali::Application& app)
{
EmitPauseSignal();
}
-void LifecycleController::OnResume( Dali::Application& app )
+void LifecycleController::OnResume(Dali::Application& app)
{
EmitResumeSignal();
}
-void LifecycleController::OnReset( Dali::Application& app )
+void LifecycleController::OnReset(Dali::Application& app)
{
EmitResetSignal();
}
-void LifecycleController::OnLanguageChanged( Dali::Application& app )
+void LifecycleController::OnLanguageChanged(Dali::Application& app)
{
EmitLanguageChangedSignal();
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
std::string Adaptor::GetApplicationPackageName()
{
return "";
}
-void Adaptor::GetDataStoragePath( std::string& path)
+void Adaptor::GetDataStoragePath(std::string& path)
{
path = "";
}
-void Adaptor::GetAppId( std::string& appId )
+void Adaptor::GetAppId(std::string& appId)
{
appId = "";
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
-static void OnSystemLanguageChanged( system_settings_key_e key, void* data )
+static void OnSystemLanguageChanged(system_settings_key_e key, void* data)
{
char* locale = NULL;
- if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
- locale == NULL )
+ if(system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale) != SYSTEM_SETTINGS_ERROR_NONE ||
+ locale == NULL)
{
- DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
+ DALI_LOG_ERROR("DALI OnSystemLanguageChanged failed ");
return;
}
- Adaptor* adaptor = static_cast< Adaptor* >( data );
- if( adaptor != NULL )
+ Adaptor* adaptor = static_cast<Adaptor*>(data);
+ if(adaptor != NULL)
{
- adaptor->SetRootLayoutDirection( locale );
+ adaptor->SetRootLayoutDirection(locale);
}
- free( locale );
+ free(locale);
}
-} // namesapce
+} // namespace
std::string Adaptor::GetApplicationPackageName()
{
char appname[4096] = {0};
- int pid = getpid();
- aul_app_get_pkgname_bypid( pid, appname, sizeof( appname ) );
+ int pid = getpid();
+ aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
return appname;
}
-void Adaptor::GetResourceStoragePath( std::string& path )
+void Adaptor::GetResourceStoragePath(std::string& path)
{
#ifdef USE_APPFW
- char *pathInt = app_get_resource_path();
- if ( pathInt )
+ char* pathInt = app_get_resource_path();
+ if(pathInt)
{
path = pathInt;
- free( pathInt );
+ free(pathInt);
}
else
{
#endif
}
-void Adaptor::GetDataStoragePath( std::string& path )
+void Adaptor::GetDataStoragePath(std::string& path)
{
#ifdef USE_APPFW
- char *pathInt = app_get_data_path();
- if ( pathInt )
+ char* pathInt = app_get_data_path();
+ if(pathInt)
{
path = pathInt;
- free( pathInt );
+ free(pathInt);
}
else
{
path = "";
}
#endif
-
}
-void Adaptor::GetAppId( std::string& appId )
+void Adaptor::GetAppId(std::string& appId)
{
#ifdef USE_APPFW
- char *id;
+ char* id;
app_get_id(&id);
- if ( id )
+ if(id)
{
appId = id;
- free( id );
+ free(id);
}
else
{
void Adaptor::SurfaceInitialized()
{
#ifdef APPCORE_WATCH_AVAILABLE
- if ( !mUseRemoteSurface )
+ if(!mUseRemoteSurface)
{
return;
}
- char *appId;
+ char* appId;
app_get_id(&appId);
// Use strdup() in app_get_id(), so need to free memory
- if( appId )
+ if(appId)
{
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Window* ecoreWlWindow = AnyCast< Ecore_Wl2_Window* >( mWindows.front()->GetNativeHandle() );
- screen_connector_provider_remote_enable( appId, ecore_wl2_window_surface_get( ecoreWlWindow ) );
+ Ecore_Wl2_Window* ecoreWlWindow = AnyCast<Ecore_Wl2_Window*>(mWindows.front()->GetNativeHandle());
+ screen_connector_provider_remote_enable(appId, ecore_wl2_window_surface_get(ecoreWlWindow));
#else
- Ecore_Wl_Window* ecoreWlWindow = AnyCast< Ecore_Wl_Window* >( mWindows.front()->GetNativeHandle() );
- screen_connector_provider_remote_enable( appId, ecore_wl_window_surface_get( ecoreWlWindow ) );
+ Ecore_Wl_Window* ecoreWlWindow = AnyCast<Ecore_Wl_Window*>(mWindows.front()->GetNativeHandle());
+ screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow));
#endif
- free( appId );
+ free(appId);
}
#endif
}
void Adaptor::SetupSystemInformation()
{
- if( system_settings_add_changed_cb( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this ) != SYSTEM_SETTINGS_ERROR_NONE )
+ if(system_settings_add_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this) != SYSTEM_SETTINGS_ERROR_NONE)
{
- DALI_LOG_ERROR( "DALI system_settings_add_changed_cb failed.\n" );
+ DALI_LOG_ERROR("DALI system_settings_add_changed_cb failed.\n");
return;
}
char* locale = NULL;
- if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
- locale == NULL )
+ if(system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale) != SYSTEM_SETTINGS_ERROR_NONE ||
+ locale == NULL)
{
- DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
+ DALI_LOG_ERROR("DALI OnSystemLanguageChanged failed ");
return;
}
- SetRootLayoutDirection( locale );
-
- free( locale );
+ SetRootLayoutDirection(locale);
+ free(locale);
}
} // namespace Adaptor
/*
- * 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
ComponentApplicationPtr ComponentApplication::New(
- int* argc,
- char **argv[],
- const std::string& stylesheet,
+ int* argc,
+ char** argv[],
+ const std::string& stylesheet,
Dali::Application::WINDOW_MODE windowMode)
{
- ComponentApplicationPtr application ( new ComponentApplication (argc, argv, stylesheet, windowMode ) );
+ ComponentApplicationPtr application(new ComponentApplication(argc, argv, stylesheet, windowMode));
return application;
}
-ComponentApplication::ComponentApplication( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode )
+ComponentApplication::ComponentApplication(int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode)
: Application(argc, argv, stylesheet, windowMode, PositionSize(), Framework::COMPONENT)
{
}
/*
- * 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.
namespace Dali
{
-
ComponentApplication ComponentApplication::New()
{
- return New( NULL, NULL );
+ return New(NULL, NULL);
}
-ComponentApplication ComponentApplication::New( int* argc, char **argv[] )
+ComponentApplication ComponentApplication::New(int* argc, char** argv[])
{
- return New( argc, argv, "" );
+ return New(argc, argv, "");
}
-ComponentApplication ComponentApplication::New( int* argc, char **argv[], const std::string& stylesheet )
+ComponentApplication ComponentApplication::New(int* argc, char** argv[], const std::string& stylesheet)
{
- Internal::Adaptor::ComponentApplicationPtr internal = Internal::Adaptor::ComponentApplication::New( argc, argv, stylesheet, TRANSPARENT );
+ Internal::Adaptor::ComponentApplicationPtr internal = Internal::Adaptor::ComponentApplication::New(argc, argv, stylesheet, TRANSPARENT);
return ComponentApplication(internal.Get());
}
/*
- * Copyright (c) 2019 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.
#include <dali/internal/adaptor/common/framework.h>
// EXTERNAL INCLUDES
-#include <appcore_ui_base.h>
-#include <app_control_internal.h>
#include <app_common.h>
+#include <app_control_internal.h>
+#include <appcore_ui_base.h>
#include <bundle.h>
#include <dali/internal/system/linux/dali-ecore.h>
+#include <bundle_internal.h>
#include <system_info.h>
#include <system_settings.h>
-#include <bundle_internal.h>
#include <widget_base.h>
// CONDITIONAL INCLUDES
#ifdef APPCORE_WATCH_AVAILABLE
#include <Eldbus.h>
#endif // DALI_ELDBUS_AVAILABLE
-#if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED
+#if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
#include <tzplatform_config.h>
#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New( Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS" );
+Integration::Log::Filter* gDBusLogging = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_DBUS");
#endif
bool IsWidgetFeatureEnabled()
{
- static bool feature = false;
+ static bool feature = false;
static bool retrieved = false;
- int ret;
+ int ret;
if(retrieved == true)
{
namespace AppCore
{
-
typedef enum
{
LOW_MEMORY, //< The low memory event
} AppEventType;
static int AppEventConverter[APPCORE_BASE_EVENT_MAX] =
-{
- [LOW_MEMORY] = APPCORE_BASE_EVENT_LOW_MEMORY,
- [LOW_BATTERY] = APPCORE_BASE_EVENT_LOW_BATTERY,
- [LANGUAGE_CHANGED] = APPCORE_BASE_EVENT_LANG_CHANGE,
- [DEVICE_ORIENTATION_CHANGED] = APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED,
- [REGION_FORMAT_CHANGED] = APPCORE_BASE_EVENT_REGION_CHANGE,
- [SUSPENDED_STATE_CHANGED] = APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE,
+ {
+ [LOW_MEMORY] = APPCORE_BASE_EVENT_LOW_MEMORY,
+ [LOW_BATTERY] = APPCORE_BASE_EVENT_LOW_BATTERY,
+ [LANGUAGE_CHANGED] = APPCORE_BASE_EVENT_LANG_CHANGE,
+ [DEVICE_ORIENTATION_CHANGED] = APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED,
+ [REGION_FORMAT_CHANGED] = APPCORE_BASE_EVENT_REGION_CHANGE,
+ [SUSPENDED_STATE_CHANGED] = APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE,
};
struct AppEventInfo
{
AppEventType type;
- void *value;
+ void* value;
};
-typedef struct AppEventInfo *AppEventInfoPtr;
+typedef struct AppEventInfo* AppEventInfoPtr;
-typedef void (*AppEventCallback)(AppEventInfoPtr eventInfo, void *userData);
+typedef void (*AppEventCallback)(AppEventInfoPtr eventInfo, void* userData);
struct AppEventHandler
{
- AppEventType type;
+ AppEventType type;
AppEventCallback cb;
- void *data;
- void *raw;
+ void* data;
+ void* raw;
};
-typedef struct AppEventHandler *AppEventHandlerPtr;
+typedef struct AppEventHandler* AppEventHandlerPtr;
-int EventCallback(void *event, void *data)
+int EventCallback(void* event, void* data)
{
AppEventHandlerPtr handler = static_cast<AppEventHandlerPtr>(data);
struct AppEventInfo appEvent;
- appEvent.type = handler->type;
+ appEvent.type = handler->type;
appEvent.value = event;
- if (handler->cb)
+ if(handler->cb)
handler->cb(&appEvent, handler->data);
return 0;
}
-int AppAddEventHandler(AppEventHandlerPtr *eventHandler, AppEventType eventType, AppEventCallback callback, void *userData)
+int AppAddEventHandler(AppEventHandlerPtr* eventHandler, AppEventType eventType, AppEventCallback callback, void* userData)
{
AppEventHandlerPtr handler;
- handler = static_cast<AppEventHandlerPtr>( calloc(1, sizeof(struct AppEventHandler)) );
- if (!handler)
+ handler = static_cast<AppEventHandlerPtr>(calloc(1, sizeof(struct AppEventHandler)));
+ if(!handler)
{
- DALI_LOG_ERROR( "failed to create handler" );
+ DALI_LOG_ERROR("failed to create handler");
return TIZEN_ERROR_UNKNOWN;
}
else
{
handler->type = eventType;
- handler->cb = callback;
+ handler->cb = callback;
handler->data = userData;
- handler->raw = appcore_base_add_event( static_cast<appcore_base_event>(AppEventConverter[static_cast<int>(eventType)]), EventCallback, handler);
+ handler->raw = appcore_base_add_event(static_cast<appcore_base_event>(AppEventConverter[static_cast<int>(eventType)]), EventCallback, handler);
*eventHandler = handler;
}
}
-} // namespace Appcore
+} // namespace AppCore
/**
* Impl to hide EFL data members
*/
struct Framework::Impl
{
-// Constructor
- Impl(void* data, Type type )
- : mAbortCallBack( NULL ),
- mCallbackManager( NULL )
+ // Constructor
+ Impl(void* data, Type type)
+ : mAbortCallBack(NULL),
+ mCallbackManager(NULL)
#ifdef APPCORE_WATCH_AVAILABLE
- , mWatchCallback()
+ ,
+ mWatchCallback()
#endif
{
mFramework = static_cast<Framework*>(data);
#ifndef APPCORE_WATCH_AVAILABLE
- if ( type == WATCH )
+ if(type == WATCH)
{
- throw Dali::DaliException( "", "Watch Application is not supported." );
+ throw Dali::DaliException("", "Watch Application is not supported.");
}
#endif
mApplicationType = type;
mCallbackManager = CallbackManager::New();
- char* region = nullptr;
+ char* region = nullptr;
char* language = nullptr;
- system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, ®ion );
- system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language );
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, ®ion);
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language);
- if (region != nullptr)
+ if(region != nullptr)
{
- mRegion = std::string( region );
- free( region );
+ mRegion = std::string(region);
+ free(region);
}
- if ( language != nullptr)
+ if(language != nullptr)
{
- mLanguage = std::string( language );
- free( language );
+ mLanguage = std::string(language);
+ free(language);
}
}
int AppMain()
{
int ret;
- switch ( mApplicationType )
+ switch(mApplicationType)
{
case NORMAL:
{
void AppExit()
{
- switch ( mApplicationType )
+ switch(mApplicationType)
{
case NORMAL:
{
}
}
- void SetLanguage( const std::string& language )
+ void SetLanguage(const std::string& language)
{
mLanguage = language;
}
- void SetRegion( const std::string& region )
+ void SetRegion(const std::string& region)
{
mRegion = region;
}
}
// Data
- Type mApplicationType;
- CallbackBase* mAbortCallBack;
- CallbackManager *mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
+ Type mApplicationType;
+ CallbackBase* mAbortCallBack;
+ CallbackManager* mCallbackManager;
+ std::string mLanguage;
+ std::string mRegion;
- Framework* mFramework;
+ Framework* mFramework;
AppCore::AppEventHandlerPtr handlers[5];
#ifdef APPCORE_WATCH_AVAILABLE
watch_app_lifecycle_callback_s mWatchCallback;
- app_event_handler_h watchHandlers[5];
+ app_event_handler_h watchHandlers[5];
#endif
- static int AppCreate(void *data)
+ static int AppCreate(void* data)
{
appcore_ui_base_on_create();
- return static_cast<int>( static_cast<Framework*>(data)->Create() );
+ return static_cast<int>(static_cast<Framework*>(data)->Create());
}
- static int AppTerminate(void *data)
+ static int AppTerminate(void* data)
{
appcore_ui_base_on_terminate();
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnTerminate();
return 0;
}
- static int AppPause(void *data)
+ static int AppPause(void* data)
{
appcore_ui_base_on_pause();
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnPause();
return 0;
}
- static int AppResume(void *data)
+ static int AppResume(void* data)
{
appcore_ui_base_on_resume();
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnResume();
return 0;
}
- static void ProcessBundle(Framework* framework, bundle *bundleData)
+ static void ProcessBundle(Framework* framework, bundle* bundleData)
{
if(bundleData == NULL)
{
* Called by AppCore when the application is launched from another module (e.g. homescreen).
* @param[in] b the bundle data which the launcher module sent
*/
- static int AppControl(bundle* bundleData, void *data)
+ static int AppControl(bundle* bundleData, void* data)
{
app_control_h appControl = NULL;
appcore_ui_base_on_control(bundleData);
- if (bundleData)
+ if(bundleData)
{
- if (app_control_create_event(bundleData, &appControl) != TIZEN_ERROR_NONE)
+ if(app_control_create_event(bundleData, &appControl) != TIZEN_ERROR_NONE)
{
DALI_LOG_ERROR("Failed to create an app_control handle");
}
}
else
{
- if (app_control_create(&appControl) != TIZEN_ERROR_NONE)
+ if(app_control_create(&appControl) != TIZEN_ERROR_NONE)
{
DALI_LOG_ERROR("Failed to create an app_control handle");
}
}
Framework* framework = static_cast<Framework*>(data);
- Observer *observer = &framework->mObserver;
+ Observer* observer = &framework->mObserver;
ProcessBundle(framework, bundleData);
return 0;
}
- static void AppInit(int argc, char **argv, void *data)
+ static void AppInit(int argc, char** argv, void* data)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
ecore_init();
- ecore_app_args_set( argc, (const char **)argv );
+ ecore_app_args_set(argc, (const char**)argv);
#pragma GCC diagnostic pop
}
}
}
- static void AppRun(void *data)
+ static void AppRun(void* data)
{
ecore_main_loop_begin();
}
- static void AppExit(void *data)
+ static void AppExit(void* data)
{
ecore_main_loop_quit();
}
- static void AppLanguageChanged(AppCore::AppEventInfoPtr event, void *data)
+ static void AppLanguageChanged(AppCore::AppEventInfoPtr event, void* data)
{
Framework* framework = static_cast<Framework*>(data);
- Observer *observer = &framework->mObserver;
+ Observer* observer = &framework->mObserver;
- if( event && event->value )
+ if(event && event->value)
{
- framework->SetLanguage( std::string( static_cast<const char *>(event->value) ) );
+ framework->SetLanguage(std::string(static_cast<const char*>(event->value)));
observer->OnLanguageChanged();
}
else
{
- DALI_LOG_ERROR( "NULL pointer in Language changed event\n" );
+ DALI_LOG_ERROR("NULL pointer in Language changed event\n");
}
}
- static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void *data)
+ static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void* data)
{
}
- static void AppRegionChanged(AppCore::AppEventInfoPtr event, void *data)
+ static void AppRegionChanged(AppCore::AppEventInfoPtr event, void* data)
{
Framework* framework = static_cast<Framework*>(data);
- Observer *observer = &framework->mObserver;
+ Observer* observer = &framework->mObserver;
- if( event && event->value )
+ if(event && event->value)
{
- framework->SetRegion( std::string( static_cast<const char *>(event->value) ) );
+ framework->SetRegion(std::string(static_cast<const char*>(event->value)));
observer->OnRegionChanged();
}
else
{
- DALI_LOG_ERROR( "NULL pointer in Region changed event\n" );
+ DALI_LOG_ERROR("NULL pointer in Region changed event\n");
}
}
- static void AppBatteryLow(AppCore::AppEventInfoPtr event, void *data)
+ static void AppBatteryLow(AppCore::AppEventInfoPtr event, void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
- int status = *static_cast<int *>(event->value);
- Dali::DeviceStatus::Battery::Status result = Dali::DeviceStatus::Battery::NORMAL;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ int status = *static_cast<int*>(event->value);
+ Dali::DeviceStatus::Battery::Status result = Dali::DeviceStatus::Battery::NORMAL;
// convert to dali battery status
- switch( status )
+ switch(status)
{
case 1:
{
result = Dali::DeviceStatus::Battery::CRITICALLY_LOW;
break;
}
- default :
+ default:
break;
}
observer->OnBatteryLow(result);
}
- static void AppMemoryLow(AppCore::AppEventInfoPtr event, void *data)
+ static void AppMemoryLow(AppCore::AppEventInfoPtr event, void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
- int status = *static_cast<int *>(event->value);
- Dali::DeviceStatus::Memory::Status result = Dali::DeviceStatus::Memory::NORMAL;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ int status = *static_cast<int*>(event->value);
+ Dali::DeviceStatus::Memory::Status result = Dali::DeviceStatus::Memory::NORMAL;
// convert to dali memmory status
- switch( status )
+ switch(status)
{
case 1:
{
result = Dali::DeviceStatus::Memory::CRITICALLY_LOW;
break;
}
- default :
+ default:
break;
}
observer->OnMemoryLow(result);
}
-
int AppNormalMain()
{
int ret;
appcore_ui_base_ops ops = appcore_ui_base_get_default_ops();
/* override methods */
- ops.base.create = AppCreate;
- ops.base.control = AppControl;
+ ops.base.create = AppCreate;
+ ops.base.control = AppControl;
ops.base.terminate = AppTerminate;
- ops.pause = AppPause;
- ops.resume = AppResume;
- ops.base.init = AppInit;
- ops.base.finish = AppFinish;
- ops.base.run = AppRun;
- ops.base.exit = AppExit;
-
- ret = appcore_ui_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework, APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL |
- APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL |
- APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL |
- APPCORE_UI_BASE_HINT_HW_ACC_CONTROL |
- APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL );
-
- if (ret != TIZEN_ERROR_NONE)
+ ops.pause = AppPause;
+ ops.resume = AppResume;
+ ops.base.init = AppInit;
+ ops.base.finish = AppFinish;
+ ops.base.run = AppRun;
+ ops.base.exit = AppExit;
+
+ ret = appcore_ui_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework, APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL | APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL | APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL | APPCORE_UI_BASE_HINT_HW_ACC_CONTROL | APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL);
+
+ if(ret != TIZEN_ERROR_NONE)
return ret;
appcore_ui_base_fini();
widget_base_exit();
}
- static int WidgetAppCreate( void *data )
+ static int WidgetAppCreate(void* data)
{
widget_base_on_create();
- return static_cast<int>( static_cast<Framework*>(data)->Create() );
+ return static_cast<int>(static_cast<Framework*>(data)->Create());
}
- static int WidgetAppTerminate( void *data )
+ static int WidgetAppTerminate(void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnTerminate();
widget_base_on_terminate();
int AppWidgetMain()
{
- if( !IsWidgetFeatureEnabled() )
+ if(!IsWidgetFeatureEnabled())
{
DALI_LOG_ERROR("widget feature is not supported");
return 0;
widget_base_ops ops = widget_base_get_default_ops();
/* override methods */
- ops.create = WidgetAppCreate;
+ ops.create = WidgetAppCreate;
ops.terminate = WidgetAppTerminate;
- ops.init = AppInit;
- ops.finish = AppFinish;
- ops.run = AppRun;
- ops.exit = AppExit;
+ ops.init = AppInit;
+ ops.finish = AppFinish;
+ ops.run = AppRun;
+ ops.exit = AppExit;
int result = widget_base_init(ops, *mFramework->mArgc, *mFramework->mArgv, mFramework);
}
#ifdef APPCORE_WATCH_AVAILABLE
- static bool WatchAppCreate(int width, int height, void *data)
+ static bool WatchAppCreate(int width, int height, void* data)
{
return static_cast<Framework*>(data)->Create();
}
- static void WatchAppTimeTick(watch_time_h time, void *data)
+ static void WatchAppTimeTick(watch_time_h time, void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
WatchTime curTime(time);
observer->OnTimeTick(curTime);
}
- static void WatchAppAmbientTick(watch_time_h time, void *data)
+ static void WatchAppAmbientTick(watch_time_h time, void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
WatchTime curTime(time);
observer->OnAmbientTick(curTime);
}
- static void WatchAppAmbientChanged(bool ambient, void *data)
+ static void WatchAppAmbientChanged(bool ambient, void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnAmbientChanged(ambient);
}
- static void WatchAppControl(app_control_h app_control, void *data)
+ static void WatchAppControl(app_control_h app_control, void* data)
{
- Framework* framework = static_cast<Framework*>(data);
- Observer *observer = &framework->mObserver;
- bundle *bundleData = NULL;
+ Framework* framework = static_cast<Framework*>(data);
+ Observer* observer = &framework->mObserver;
+ bundle* bundleData = NULL;
app_control_to_bundle(app_control, &bundleData);
ProcessBundle(framework, bundleData);
observer->OnAppControl(app_control);
}
- static void WatchAppTerminate(void *data)
+ static void WatchAppTerminate(void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnTerminate();
}
- static void WatchAppPause(void *data)
+ static void WatchAppPause(void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnPause();
}
- static void WatchAppResume(void *data)
+ static void WatchAppResume(void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnResume();
}
int ret = true;
#ifdef APPCORE_WATCH_AVAILABLE
- mWatchCallback.create = WatchAppCreate;
- mWatchCallback.app_control = WatchAppControl;
- mWatchCallback.terminate = WatchAppTerminate;
- mWatchCallback.pause = WatchAppPause;
- mWatchCallback.resume = WatchAppResume;
- mWatchCallback.time_tick = WatchAppTimeTick;
- mWatchCallback.ambient_tick = WatchAppAmbientTick;
+ mWatchCallback.create = WatchAppCreate;
+ mWatchCallback.app_control = WatchAppControl;
+ mWatchCallback.terminate = WatchAppTerminate;
+ mWatchCallback.pause = WatchAppPause;
+ mWatchCallback.resume = WatchAppResume;
+ mWatchCallback.time_tick = WatchAppTimeTick;
+ mWatchCallback.ambient_tick = WatchAppAmbientTick;
mWatchCallback.ambient_changed = WatchAppAmbientChanged;
AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
/*Crate component_based_app_base_lifecycle_callback*/
component_based_app_base_lifecycle_callback_s callback;
- callback.init = AppInit;
- callback.run = AppRun;
- callback.exit = AppExit;
- callback.create = ComponentAppCreate;
+ callback.init = AppInit;
+ callback.run = AppRun;
+ callback.exit = AppExit;
+ callback.create = ComponentAppCreate;
callback.terminate = ComponentAppTerminate;
- callback.fini = ComponentAppFinish;
+ callback.fini = ComponentAppFinish;
- return component_based_app_base_main(*mFramework->mArgc, *mFramework->mArgv, &callback, mFramework);;
+ return component_based_app_base_main(*mFramework->mArgc, *mFramework->mArgv, &callback, mFramework);
+ ;
}
- static void* ComponentAppCreate( void *data )
+ static void* ComponentAppCreate(void* data)
{
Framework* framework = static_cast<Framework*>(data);
- Observer *observer = &framework->mObserver;
+ Observer* observer = &framework->mObserver;
observer->OnInit();
- return Dali::AnyCast<void*>( observer->OnCreate() );
+ return Dali::AnyCast<void*>(observer->OnCreate());
}
- static void ComponentAppTerminate( void *data )
+ static void ComponentAppTerminate(void* data)
{
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<Framework*>(data)->mObserver;
observer->OnTerminate();
}
- static void ComponentAppFinish( void *data )
+ static void ComponentAppFinish(void* data)
{
ecore_shutdown();
private:
// Undefined
- Impl( const Impl& impl );
+ Impl(const Impl& impl);
// Undefined
- Impl& operator=( const Impl& impl );
+ Impl& operator=(const Impl& impl);
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
+Framework::Framework(Framework::Observer& observer, int* argc, char*** argv, Type type)
: mObserver(observer),
mInitialised(false),
mPaused(false),
mArgv(argv),
mBundleName(""),
mBundleId(""),
- mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
+ mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
mImpl(NULL)
{
bool featureFlag = true;
- system_info_get_platform_bool( "tizen.org/feature/opengles.version.2_0", &featureFlag );
+ system_info_get_platform_bool("tizen.org/feature/opengles.version.2_0", &featureFlag);
- if( featureFlag == false )
+ if(featureFlag == false)
{
- set_last_result( TIZEN_ERROR_NOT_SUPPORTED );
+ set_last_result(TIZEN_ERROR_NOT_SUPPORTED);
}
#ifdef DALI_ELDBUS_AVAILABLE
// Initialize ElDBus.
- DALI_LOG_INFO( gDBusLogging, Debug::General, "Starting DBus Initialization\n" );
+ DALI_LOG_INFO(gDBusLogging, Debug::General, "Starting DBus Initialization\n");
eldbus_init();
#endif
InitThreads();
Framework::~Framework()
{
- if (mRunning)
+ if(mRunning)
{
Quit();
}
#ifdef DALI_ELDBUS_AVAILABLE
// Shutdown ELDBus.
- DALI_LOG_INFO( gDBusLogging, Debug::General, "Shutting down DBus\n" );
+ DALI_LOG_INFO(gDBusLogging, Debug::General, "Shutting down DBus\n");
eldbus_shutdown();
#endif
int ret;
ret = mImpl->AppMain();
- if (ret != APP_ERROR_NONE)
+ if(ret != APP_ERROR_NONE)
{
DALI_LOG_ERROR("Framework::Run(), ui_app_main() is failed. err = %d\n", ret);
}
return mRunning;
}
-void Framework::AddAbortCallback( CallbackBase* callback )
+void Framework::AddAbortCallback(CallbackBase* callback)
{
mImpl->mAbortCallBack = callback;
}
std::string Framework::GetResourcePath()
{
std::string resourcePath = "";
-#if defined( TIZEN_PLATFORM_CONFIG_SUPPORTED ) && TIZEN_PLATFORM_CONFIG_SUPPORTED
+#if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
char* app_rsc_path = app_get_resource_path();
- if (app_rsc_path)
+ if(app_rsc_path)
{
resourcePath = app_rsc_path;
free(app_rsc_path);
// "DALI_APPLICATION_PACKAGE" is used to get the already configured Application package path.
const char* environmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv( environmentVariable );
- if ( value != NULL )
+ char* value = getenv(environmentVariable);
+ if(value != NULL)
{
resourcePath = value;
}
- if( resourcePath.back() != '/' )
+ if(resourcePath.back() != '/')
{
- resourcePath+="/";
+ resourcePath += "/";
}
#endif //TIZEN_PLATFORM_CONFIG_SUPPORTED
std::string Framework::GetDataPath()
{
std::string result;
- char* dataPath = app_get_data_path();
- if( dataPath )
+ char* dataPath = app_get_data_path();
+ if(dataPath)
{
result = dataPath;
free(dataPath);
mBundleId = id;
}
-void Framework::AbortCallback( )
+void Framework::AbortCallback()
{
// if an abort call back has been installed run it.
- if (mImpl->mAbortCallBack)
+ if(mImpl->mAbortCallBack)
{
- CallbackBase::Execute( *mImpl->mAbortCallBack );
+ CallbackBase::Execute(*mImpl->mAbortCallBack);
}
else
{
{
}
-void Framework::SetLanguage( const std::string& language )
+void Framework::SetLanguage(const std::string& language)
{
- mImpl->SetLanguage( language );
+ mImpl->SetLanguage(language);
}
-void Framework::SetRegion( const std::string& region )
+void Framework::SetRegion(const std::string& region)
{
- mImpl->SetRegion( region );
+ mImpl->SetRegion(region);
}
std::string Framework::GetLanguage() const
/*
- * Copyright (c) 2016 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
unsigned int GetEnvWatchRenderRefreshRate()
{
- const char* envVariable = std::getenv( DALI_WATCH_REFRESH_RATE );
+ const char* envVariable = std::getenv(DALI_WATCH_REFRESH_RATE);
- return envVariable ? std::atoi( envVariable ) : 2u; // Default 30 fps
+ return envVariable ? std::atoi(envVariable) : 2u; // Default 30 fps
}
} // unnamed namespace
WatchApplicationPtr WatchApplication::New(
- int* argc,
- char **argv[],
- const std::string& stylesheet,
+ int* argc,
+ char** argv[],
+ const std::string& stylesheet,
Dali::WatchApplication::WINDOW_MODE windowMode)
{
- WatchApplicationPtr watch ( new WatchApplication (argc, argv, stylesheet, windowMode ) );
+ WatchApplicationPtr watch(new WatchApplication(argc, argv, stylesheet, windowMode));
return watch;
}
-WatchApplication::WatchApplication( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode )
+WatchApplication::WatchApplication(int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode)
: Application(argc, argv, stylesheet, windowMode, PositionSize(), Framework::WATCH),
- mState( UNINITIALIZED )
+ mState(UNINITIALIZED)
{
}
{
Application::OnInit();
- Dali::Adaptor::Get().SetRenderRefreshRate( GetEnvWatchRenderRefreshRate() );
+ Dali::Adaptor::Get().SetRenderRefreshRate(GetEnvWatchRenderRefreshRate());
mState = INITIALIZED;
}
void WatchApplication::OnTimeTick(WatchTime& time)
{
Dali::WatchApplication watch(this);
- mTickSignal.Emit( watch, time );
+ mTickSignal.Emit(watch, time);
if(mState == PAUSED)
{
// This is a pre-resume scenario. All rendering engine of tizen SHOULD forcely update once at this time.
- Internal::Adaptor::Adaptor::GetImplementation( GetAdaptor() ).RequestUpdateOnce();
+ Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor()).RequestUpdateOnce();
}
// A watch application will queue messages to update the UI in the signal emitted above
// Process these immediately to avoid a blinking issue where the old time is briefly visible
- CoreEventInterface& eventInterface = Internal::Adaptor::Adaptor::GetImplementation( GetAdaptor() );
+ CoreEventInterface& eventInterface = Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor());
eventInterface.ProcessCoreEvents();
}
void WatchApplication::OnAmbientTick(WatchTime& time)
{
Dali::WatchApplication watch(this);
- mAmbientTickSignal.Emit( watch, time );
+ mAmbientTickSignal.Emit(watch, time);
// A watch application will queue messages to update the UI in the signal emitted above
// Process these immediately to avoid a blinking issue where the old time is briefly visible
- CoreEventInterface& eventInterface = Internal::Adaptor::Adaptor::GetImplementation( GetAdaptor() );
+ CoreEventInterface& eventInterface = Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor());
eventInterface.ProcessCoreEvents();
}
void WatchApplication::OnAmbientChanged(bool ambient)
{
Dali::WatchApplication watch(this);
- mAmbientChangeSignal.Emit( watch, ambient );
+ mAmbientChangeSignal.Emit(watch, ambient);
}
} // namespace Adaptor
/*
- * 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.
namespace Dali
{
-
WatchApplication WatchApplication::New()
{
- return New( NULL, NULL );
+ return New(NULL, NULL);
}
-WatchApplication WatchApplication::New( int* argc, char **argv[] )
+WatchApplication WatchApplication::New(int* argc, char** argv[])
{
- Internal::Adaptor::WatchApplicationPtr internal = Internal::Adaptor::WatchApplication::New( argc, argv, "", OPAQUE );
+ Internal::Adaptor::WatchApplicationPtr internal = Internal::Adaptor::WatchApplication::New(argc, argv, "", OPAQUE);
return WatchApplication(internal.Get());
}
-WatchApplication WatchApplication::New( int* argc, char **argv[], const std::string& stylesheet )
+WatchApplication WatchApplication::New(int* argc, char** argv[], const std::string& stylesheet)
{
- Internal::Adaptor::WatchApplicationPtr internal = Internal::Adaptor::WatchApplication::New( argc, argv, stylesheet, OPAQUE );
+ Internal::Adaptor::WatchApplicationPtr internal = Internal::Adaptor::WatchApplication::New(argc, argv, stylesheet, OPAQUE);
return WatchApplication(internal.Get());
}
{
}
-WatchApplication::WatchApplication( const WatchApplication& copy ) = default;
+WatchApplication::WatchApplication(const WatchApplication& copy) = default;
-WatchApplication& WatchApplication::operator=( const WatchApplication& rhs ) = default;
+WatchApplication& WatchApplication::operator=(const WatchApplication& rhs) = default;
-WatchApplication::WatchApplication( WatchApplication&& rhs ) = default;
+WatchApplication::WatchApplication(WatchApplication&& rhs) = default;
-WatchApplication& WatchApplication::operator=( WatchApplication&& rhs ) = default;
+WatchApplication& WatchApplication::operator=(WatchApplication&& rhs) = default;
WatchApplication::WatchTimeSignal& WatchApplication::TimeTickSignal()
{
{
}
-
} // namespace Dali
/*
- * Copyright (c) 2019 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.
#include <dali/internal/adaptor/common/framework.h>
// EXTERNAL INCLUDES
+#include <X11/Xlib.h>
#include <dali/internal/system/linux/dali-ecore.h>
#include <dali/internal/system/linux/dali-elementary.h>
-#include <X11/Xlib.h>
#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
/// Application Status Enum
enum
{
// Constructor
Impl(void* data)
- : mAbortCallBack( NULL ),
- mCallbackManager( CallbackManager::New() ),
- mLanguage( "NOT_SUPPORTED" ),
- mRegion( "NOT_SUPPORTED" )
+ : mAbortCallBack(NULL),
+ mCallbackManager(CallbackManager::New()),
+ mLanguage("NOT_SUPPORTED"),
+ mRegion("NOT_SUPPORTED")
{
}
}
// Data
- CallbackBase* mAbortCallBack;
- CallbackManager *mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
+ CallbackBase* mAbortCallBack;
+ CallbackManager* mCallbackManager;
+ std::string mLanguage;
+ std::string mRegion;
// Static methods
/**
* Called by AppCore on application creation.
*/
- static bool AppCreate(void *data)
+ static bool AppCreate(void* data)
{
return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
}
/**
* Called by AppCore when the application should terminate.
*/
- static void AppTerminate(void *data)
+ static void AppTerminate(void* data)
{
static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
}
/**
* Called by AppCore when the application is paused.
*/
- static void AppPause(void *data)
+ static void AppPause(void* data)
{
static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
}
/**
* Called by AppCore when the application is resumed.
*/
- static void AppResume(void *data)
+ static void AppResume(void* data)
{
static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
}
{
static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
}
-
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
+Framework::Framework(Framework::Observer& observer, int* argc, char*** argv, Type type)
: mObserver(observer),
mInitialised(false),
mPaused(false),
mArgv(argv),
mBundleName(""),
mBundleId(""),
- mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
+ mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
mImpl(NULL)
{
InitThreads();
Framework::~Framework()
{
- if (mRunning)
+ if(mRunning)
{
Quit();
}
{
mRunning = true;
- elm_init( mArgc ? *mArgc : 0, mArgv ? *mArgv : nullptr );
+ elm_init(mArgc ? *mArgc : 0, mArgv ? *mArgv : nullptr);
Impl::AppCreate(this);
return mRunning;
}
-void Framework::AddAbortCallback( CallbackBase* callback )
+void Framework::AddAbortCallback(CallbackBase* callback)
{
mImpl->mAbortCallBack = callback;
}
{
// "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv( ubuntuEnvironmentVariable );
+ char* value = getenv(ubuntuEnvironmentVariable);
std::string resourcePath;
- if ( value != NULL )
+ if(value != NULL)
{
resourcePath = value;
}
- if( resourcePath.back() != '/' )
+ if(resourcePath.back() != '/')
{
- resourcePath+="/";
+ resourcePath += "/";
}
return resourcePath;
std::string Framework::GetDataPath()
{
const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
- char* value = getenv( ubuntuEnvironmentVariable );
+ char* value = getenv(ubuntuEnvironmentVariable);
std::string dataPath;
- if ( value != NULL )
+ if(value != NULL)
{
dataPath = value;
}
mBundleId = id;
}
-void Framework::AbortCallback( )
+void Framework::AbortCallback()
{
// if an abort call back has been installed run it.
- if (mImpl->mAbortCallBack)
+ if(mImpl->mAbortCallBack)
{
- CallbackBase::Execute( *mImpl->mAbortCallBack );
+ CallbackBase::Execute(*mImpl->mAbortCallBack);
}
else
{
}
}
-bool Framework::AppStatusHandler(int type, void *bundleData)
+bool Framework::AppStatusHandler(int type, void* bundleData)
{
- switch (type)
+ switch(type)
{
case APP_CREATE:
{
/*\r
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
#include <windows.h>\r
\r
// INTERNAL INCLUDES\r
-#include <dali/internal/window-system/windows/platform-implement-win.h>\r
#include <dali/internal/system/common/callback-manager.h>\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
\r
namespace Dali\r
{\r
-\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
namespace\r
{\r
-\r
/// Application Status Enum\r
enum\r
{\r
// Constructor\r
\r
Impl(void* data)\r
- : mAbortCallBack( NULL ),\r
- mCallbackManager( CallbackManager::New() ),\r
- mLanguage( "NOT_SUPPORTED" ),\r
- mRegion( "NOT_SUPPORTED" )\r
+ : mAbortCallBack(NULL),\r
+ mCallbackManager(CallbackManager::New()),\r
+ mLanguage("NOT_SUPPORTED"),\r
+ mRegion("NOT_SUPPORTED")\r
{\r
}\r
\r
/**\r
* Called by AppCore on application creation.\r
*/\r
- static bool AppCreate(void *data)\r
+ static bool AppCreate(void* data)\r
{\r
return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);\r
}\r
/**\r
* Called by AppCore when the application should terminate.\r
*/\r
- static void AppTerminate(void *data)\r
+ static void AppTerminate(void* data)\r
{\r
static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);\r
}\r
/**\r
* Called by AppCore when the application is paused.\r
*/\r
- static void AppPause(void *data)\r
+ static void AppPause(void* data)\r
{\r
static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);\r
}\r
/**\r
* Called by AppCore when the application is resumed.\r
*/\r
- static void AppResume(void *data)\r
+ static void AppResume(void* data)\r
{\r
static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);\r
}\r
\r
void Run()\r
{\r
- MSG nMsg = { 0 };\r
+ MSG nMsg = {0};\r
\r
- while (GetMessage(&nMsg, 0, NULL, NULL))\r
+ while(GetMessage(&nMsg, 0, NULL, NULL))\r
{\r
- if (WIN_CALLBACK_EVENT == nMsg.message)\r
+ if(WIN_CALLBACK_EVENT == nMsg.message)\r
{\r
- Dali::CallbackBase *callback = (Dali::CallbackBase*)nMsg.wParam;\r
+ Dali::CallbackBase* callback = (Dali::CallbackBase*)nMsg.wParam;\r
Dali::CallbackBase::Execute(*callback);\r
}\r
\r
\r
mCallbackManager->ClearIdleCallbacks();\r
\r
- if (WM_CLOSE == nMsg.message)\r
+ if(WM_CLOSE == nMsg.message)\r
{\r
break;\r
}\r
{\r
}\r
\r
- void SetCallbackBase( CallbackBase *base )\r
+ void SetCallbackBase(CallbackBase* base)\r
{\r
mAbortCallBack = base;\r
}\r
\r
bool ExcuteCallback()\r
{\r
- if( NULL != mAbortCallBack )\r
+ if(NULL != mAbortCallBack)\r
{\r
- CallbackBase::Execute( *mAbortCallBack );\r
+ CallbackBase::Execute(*mAbortCallBack);\r
return true;\r
}\r
else\r
\r
private:\r
// Undefined\r
- Impl( const Impl& impl ) = delete;\r
+ Impl(const Impl& impl) = delete;\r
\r
// Undefined\r
- Impl& operator=( const Impl& impl ) = delete;\r
+ Impl& operator=(const Impl& impl) = delete;\r
\r
private:\r
// Data\r
- CallbackBase* mAbortCallBack;\r
- CallbackManager *mCallbackManager;\r
- std::string mLanguage;\r
- std::string mRegion;\r
+ CallbackBase* mAbortCallBack;\r
+ CallbackManager* mCallbackManager;\r
+ std::string mLanguage;\r
+ std::string mRegion;\r
};\r
\r
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )\r
+Framework::Framework(Framework::Observer& observer, int* argc, char*** argv, Type type)\r
: mObserver(observer),\r
mInitialised(false),\r
mPaused(false),\r
mArgv(argv),\r
mBundleName(""),\r
mBundleId(""),\r
- mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),\r
+ mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),\r
mImpl(NULL)\r
{\r
- InitThreads();\r
- mImpl = new Impl(this);\r
+ InitThreads();\r
+ mImpl = new Impl(this);\r
}\r
\r
Framework::~Framework()\r
{\r
- if (mRunning)\r
+ if(mRunning)\r
{\r
Quit();\r
}\r
\r
void Framework::Run()\r
{\r
- mRunning = true;\r
+ mRunning = true;\r
\r
- Impl::AppCreate(this);\r
- mImpl->Run();\r
- mRunning = false;\r
+ Impl::AppCreate(this);\r
+ mImpl->Run();\r
+ mRunning = false;\r
}\r
\r
void Framework::Quit()\r
return mRunning;\r
}\r
\r
-void Framework::AddAbortCallback( CallbackBase* callback )\r
+void Framework::AddAbortCallback(CallbackBase* callback)\r
{\r
- mImpl->SetCallbackBase( callback );\r
+ mImpl->SetCallbackBase(callback);\r
}\r
\r
std::string Framework::GetBundleName() const\r
{\r
// "DALI_APPLICATION_PACKAGE" is used by Windows specifically to get the already configured Application package path.\r
const char* winEnvironmentVariable = "DALI_APPLICATION_PACKAGE";\r
- char* value = getenv( winEnvironmentVariable );\r
+ char* value = getenv(winEnvironmentVariable);\r
\r
std::string resourcePath;\r
- if ( value != NULL )\r
+ if(value != NULL)\r
{\r
resourcePath = value;\r
}\r
\r
- if( resourcePath.back() != '/' )\r
+ if(resourcePath.back() != '/')\r
{\r
- resourcePath+="/";\r
+ resourcePath += "/";\r
}\r
\r
return resourcePath;\r
mBundleId = id;\r
}\r
\r
-void Framework::AbortCallback( )\r
+void Framework::AbortCallback()\r
{\r
// if an abort call back has been installed run it.\r
- if( false == mImpl->ExcuteCallback() )\r
+ if(false == mImpl->ExcuteCallback())\r
{\r
Quit();\r
}\r
}\r
\r
-bool Framework::AppStatusHandler(int type, void *bundleData)\r
+bool Framework::AppStatusHandler(int type, void* bundleData)\r
{\r
- switch (type)\r
+ switch(type)\r
{\r
case APP_CREATE:\r
{\r
/*
- * 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 nullptr;
}
-} // AddOnManagerFactory
-}
+} // namespace AddOnManagerFactory
+} // namespace Internal
namespace Adaptor
{
-
-AddOnManager::AddOnManager(Internal::AddOnManager* impl ) : Integration::AddOnManager()
+AddOnManager::AddOnManager(Internal::AddOnManager* impl)
+: Integration::AddOnManager()
{
mImpl.reset(impl);
}
AddOnManager::~AddOnManager() = default;
-void AddOnManager::RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable )
+void AddOnManager::RegisterAddOnDispatchTable(const AddOnDispatchTable* dispatchTable)
{
- mImpl->RegisterAddOnDispatchTable( dispatchTable );
+ mImpl->RegisterAddOnDispatchTable(dispatchTable);
}
std::vector<std::string> AddOnManager::EnumerateAddOns()
return mImpl->EnumerateAddOns();
}
-bool AddOnManager::GetAddOnInfo(const std::string& name, AddOnInfo& info )
+bool AddOnManager::GetAddOnInfo(const std::string& name, AddOnInfo& info)
{
- return mImpl->GetAddOnInfo( name, info );
+ return mImpl->GetAddOnInfo(name, info);
}
-std::vector<Dali::AddOnLibrary> AddOnManager::LoadAddOns(const std::vector<std::string>& addonNames )
+std::vector<Dali::AddOnLibrary> AddOnManager::LoadAddOns(const std::vector<std::string>& addonNames)
{
- return std::move(mImpl->LoadAddOns( addonNames ));
+ return std::move(mImpl->LoadAddOns(addonNames));
}
-void* AddOnManager::GetGlobalProc(const Dali::AddOnLibrary& addonHandle, const char *procName)
+void* AddOnManager::GetGlobalProc(const Dali::AddOnLibrary& addonHandle, const char* procName)
{
- return mImpl->GetGlobalProc( addonHandle, procName );
+ return mImpl->GetGlobalProc(addonHandle, procName);
}
-void* AddOnManager::GetInstanceProc(const Dali::AddOnLibrary& addonHandle, const char* procName )
+void* AddOnManager::GetInstanceProc(const Dali::AddOnLibrary& addonHandle, const char* procName)
{
- return mImpl->GetInstanceProc( addonHandle, procName );
+ return mImpl->GetInstanceProc(addonHandle, procName);
}
void AddOnManager::Pause()
mImpl->Stop();
}
-}
-}
\ No newline at end of file
+} // namespace Adaptor
+} // namespace Dali
\ No newline at end of file
/*
- * 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.
*/
// INTERNAL INCLUDES
-#include <dali/internal/addons/linux/addon-manager-impl-linux.h>
#include <dali/devel-api/adaptor-framework/environment-variable.h>
+#include <dali/internal/addons/linux/addon-manager-impl-linux.h>
#include <dali/internal/system/common/environment-variables.h>
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dlfcn.h>
-#include <functional>
#include <algorithm>
+#include <functional>
#include <iterator>
#include <sstream>
{
namespace Internal
{
-
AddOnManagerLinux::AddOnManagerLinux() = default;
AddOnManagerLinux::~AddOnManagerLinux() = default;
-void AddOnManagerLinux::RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable )
+void AddOnManagerLinux::RegisterAddOnDispatchTable(const AddOnDispatchTable* dispatchTable)
{
mAddOnNames.emplace_back(dispatchTable->name);
mAddOnCache.emplace_back();
- mAddOnCache.back().GetGlobalProc = dispatchTable->GetGlobalProc;
+ mAddOnCache.back().GetGlobalProc = dispatchTable->GetGlobalProc;
mAddOnCache.back().GetInstanceProc = dispatchTable->GetInstanceProc;
- mAddOnCache.back().GetAddOnInfo = dispatchTable->GetAddOnInfo;
+ mAddOnCache.back().GetAddOnInfo = dispatchTable->GetAddOnInfo;
auto& callbacks = mAddOnCache.back().lifecycleCallbacks;
- auto initEvent = [&callbacks](uint32_t event, void(*fn)() ) {
- callbacks[event].function = fn;
+ auto initEvent = [&callbacks](uint32_t event, void (*fn)()) {
+ callbacks[event].function = fn;
callbacks[event].initialized = true;
};
- initEvent( LifecycleCallback::EVENT_START, dispatchTable->OnStart );
- initEvent( LifecycleCallback::EVENT_STOP, dispatchTable->OnStop );
- initEvent( LifecycleCallback::EVENT_PAUSE, dispatchTable->OnPause );
- initEvent( LifecycleCallback::EVENT_RESUME, dispatchTable->OnResume );
+ initEvent(LifecycleCallback::EVENT_START, dispatchTable->OnStart);
+ initEvent(LifecycleCallback::EVENT_STOP, dispatchTable->OnStop);
+ initEvent(LifecycleCallback::EVENT_PAUSE, dispatchTable->OnPause);
+ initEvent(LifecycleCallback::EVENT_RESUME, dispatchTable->OnResume);
}
std::vector<std::string> AddOnManagerLinux::EnumerateAddOns()
{
- if( mAddOnNames.empty() )
+ if(mAddOnNames.empty())
{
// AddOn libs must be separated with ':' character
- const char *addonsLibs = Dali::EnvironmentVariable::GetEnvironmentVariable( DALI_ENV_ADDONS_LIBS );
- if (!addonsLibs)
+ const char* addonsLibs = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_ADDONS_LIBS);
+ if(!addonsLibs)
{
return {};
}
// Get the path where addon libs are stored
- const char *addonsPath = Dali::EnvironmentVariable::GetEnvironmentVariable( DALI_ENV_ADDONS_PATH );
+ const char* addonsPath = Dali::EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_ADDONS_PATH);
std::string addonsPathStr(addonsPath ? addonsPath : "/usr/lib");
// Split libs
- std::string addonLibsStr(addonsLibs);
+ std::string addonLibsStr(addonsLibs);
std::vector<std::string> results;
results.emplace_back();
- std::find_if(addonLibsStr.begin(), addonLibsStr.end(), [&results](char &c)
- {
- if (c == ':')
+ std::find_if(addonLibsStr.begin(), addonLibsStr.end(), [&results](char& c) {
+ if(c == ':')
{
results.emplace_back();
}
return false;
});
- const char *EXTENSION_PATH = (addonsPath) ? addonsPath : "/usr/lib";
+ const char* EXTENSION_PATH = (addonsPath) ? addonsPath : "/usr/lib";
- for (auto &name : results)
+ for(auto& name : results)
{
std::string fullPath(EXTENSION_PATH);
fullPath += "/";
// open lib, look for essential symbols. The libary is opened with RTLD_DEEPBIND flag
// to make sure the local symbol table is going to be used during lookup first.
- auto* handle = dlopen(fullPath.c_str(), RTLD_DEEPBIND|RTLD_LAZY);
- if (handle)
+ auto* handle = dlopen(fullPath.c_str(), RTLD_DEEPBIND | RTLD_LAZY);
+ if(handle)
{
- auto& cacheEntry = mAddOnCache.back();
+ auto& cacheEntry = mAddOnCache.back();
AddOnInfo info{};
cacheEntry.GetAddOnInfo(info);
- cacheEntry.info = info;
- cacheEntry.addOnLib = fullPath;
- cacheEntry.libHandle = handle;
- cacheEntry.opened = false;
+ cacheEntry.info = info;
+ cacheEntry.addOnLib = fullPath;
+ cacheEntry.libHandle = handle;
+ cacheEntry.opened = false;
}
else
{
return mAddOnNames;
}
-bool AddOnManagerLinux::GetAddOnInfo(const std::string& name, AddOnInfo& info )
+bool AddOnManagerLinux::GetAddOnInfo(const std::string& name, AddOnInfo& info)
{
- if( mAddOnNames.empty() )
+ if(mAddOnNames.empty())
{
EnumerateAddOns();
}
- if( mAddOnNames.empty() )
+ if(mAddOnNames.empty())
{
return false;
}
- auto iter = std::find_if( mAddOnCache.begin(), mAddOnCache.end(), [name]( AddOnCacheEntry& item )
- {
+ auto iter = std::find_if(mAddOnCache.begin(), mAddOnCache.end(), [name](AddOnCacheEntry& item) {
return (item.info.name == name);
});
- if (iter == mAddOnCache.end())
+ if(iter == mAddOnCache.end())
{
return false;
}
return true;
}
-std::vector<Dali::AddOnLibrary> AddOnManagerLinux::LoadAddOns( const std::vector<std::string>& addonNames )
+std::vector<Dali::AddOnLibrary> AddOnManagerLinux::LoadAddOns(const std::vector<std::string>& addonNames)
{
std::vector<AddOnLibrary> retval{};
- retval.resize( addonNames.size() );
- std::fill( retval.begin(), retval.end(), nullptr );
+ retval.resize(addonNames.size());
+ std::fill(retval.begin(), retval.end(), nullptr);
- if( mAddOnCache.empty() )
+ if(mAddOnCache.empty())
{
EnumerateAddOns();
if(mAddOnCache.empty())
}
auto nameIndex = 0u;
- for( const auto& name : addonNames )
+ for(const auto& name : addonNames)
{
auto index = 0u;
nameIndex++;
- auto iter = std::find_if( mAddOnCache.begin(), mAddOnCache.end(), [&index, name]( AddOnCacheEntry& item )
- {
+ auto iter = std::find_if(mAddOnCache.begin(), mAddOnCache.end(), [&index, name](AddOnCacheEntry& item) {
++index;
return (item.info.name == name);
});
if(!iter->opened && iter->libHandle)
{
// Open library, pull symbols and keep the handle
- auto& entry = *iter;
+ auto& entry = *iter;
entry.opened = true;
}
// Store cache index of extension for indirect calling
// Stored number in this implementation is always +1 (0 is nullptr, unsuccessful)
- retval[nameIndex-1] = reinterpret_cast<void*>( index );
+ retval[nameIndex - 1] = reinterpret_cast<void*>(index);
}
return retval;
}
-void* AddOnManagerLinux::GetGlobalProc( const Dali::AddOnLibrary& addonHandle, const char* procName )
+void* AddOnManagerLinux::GetGlobalProc(const Dali::AddOnLibrary& addonHandle, const char* procName)
{
- if( !addonHandle )
+ if(!addonHandle)
{
return nullptr;
}
- auto index = (intptr_t(addonHandle));
- const auto& entry = mAddOnCache[ index-1 ];
+ auto index = (intptr_t(addonHandle));
+ const auto& entry = mAddOnCache[index - 1];
- if(entry.opened && entry.libHandle )
+ if(entry.opened && entry.libHandle)
{
// First call into dispatch table
- auto retval = entry.GetGlobalProc( procName );
- if( !retval )
+ auto retval = entry.GetGlobalProc(procName);
+ if(!retval)
{
// fallback
- retval = dlsym( entry.libHandle, procName );
+ retval = dlsym(entry.libHandle, procName);
}
return retval;
}
return nullptr;
}
-void* AddOnManagerLinux::GetInstanceProc( const Dali::AddOnLibrary& addonHandle, const char* procName )
+void* AddOnManagerLinux::GetInstanceProc(const Dali::AddOnLibrary& addonHandle, const char* procName)
{
- if( !addonHandle )
+ if(!addonHandle)
{
return nullptr;
}
- auto index = (intptr_t(addonHandle));
- const auto& entry = mAddOnCache[ index-1 ];
- if(entry.opened && entry.libHandle )
+ auto index = (intptr_t(addonHandle));
+ const auto& entry = mAddOnCache[index - 1];
+ if(entry.opened && entry.libHandle)
{
// First call into dispatch table
- auto retval = entry.GetInstanceProc( procName );
- if( !retval )
+ auto retval = entry.GetInstanceProc(procName);
+ if(!retval)
{
// fallback
- retval = dlsym( entry.libHandle, procName );
+ retval = dlsym(entry.libHandle, procName);
}
return retval;
}
void AddOnManagerLinux::Pause()
{
- InvokeLifecycleFunction( LifecycleCallback::EVENT_PAUSE );
+ InvokeLifecycleFunction(LifecycleCallback::EVENT_PAUSE);
}
void AddOnManagerLinux::Resume()
{
- InvokeLifecycleFunction( LifecycleCallback::EVENT_RESUME );
+ InvokeLifecycleFunction(LifecycleCallback::EVENT_RESUME);
}
void AddOnManagerLinux::Start()
{
- InvokeLifecycleFunction( LifecycleCallback::EVENT_START );
+ InvokeLifecycleFunction(LifecycleCallback::EVENT_START);
}
void AddOnManagerLinux::Stop()
{
- InvokeLifecycleFunction( LifecycleCallback::EVENT_STOP );
+ InvokeLifecycleFunction(LifecycleCallback::EVENT_STOP);
}
-void AddOnManagerLinux::InvokeLifecycleFunction( uint32_t lifecycleEvent )
+void AddOnManagerLinux::InvokeLifecycleFunction(uint32_t lifecycleEvent)
{
- for( auto& entry : mAddOnCache )
+ for(auto& entry : mAddOnCache)
{
auto& callback = entry.lifecycleCallbacks[lifecycleEvent];
/*
- * 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.
{
Integration::AddOnManager* AddOnManagerFactory::CreateAddOnManager()
{
- return new Dali::Adaptor::AddOnManager( new AddOnManagerLinux() );
+ return new Dali::Adaptor::AddOnManager(new AddOnManagerLinux());
}
} // namespace Internal
/*
- * 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.
{
Integration::AddOnManager* AddOnManagerFactory::CreateAddOnManager()
{
- return new Dali::Adaptor::AddOnManager( new AddOnManagerLinux() );
+ return new Dali::Adaptor::AddOnManager(new AddOnManagerLinux());
}
} // namespace Internal
#include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
Dali::ClipboardEventNotifier ClipboardEventNotifier::New()
{
Dali::ClipboardEventNotifier notifier = Dali::ClipboardEventNotifier(new ClipboardEventNotifier());
{
Dali::ClipboardEventNotifier notifier;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ClipboardEventNotifier ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::ClipboardEventNotifier));
if(handle)
{
// If so, downcast the handle
- notifier = Dali::ClipboardEventNotifier( dynamic_cast< ClipboardEventNotifier* >( handle.GetObjectPtr() ) );
+ notifier = Dali::ClipboardEventNotifier(dynamic_cast<ClipboardEventNotifier*>(handle.GetObjectPtr()));
}
else
{
- notifier = Dali::ClipboardEventNotifier( ClipboardEventNotifier::New() );
- service.Register( typeid( notifier ), notifier );
+ notifier = Dali::ClipboardEventNotifier(ClipboardEventNotifier::New());
+ service.Register(typeid(notifier), notifier);
}
}
return mContent;
}
-void ClipboardEventNotifier::SetContent( const std::string& content )
+void ClipboardEventNotifier::SetContent(const std::string& content)
{
mContent = content;
}
void ClipboardEventNotifier::EmitContentSelectedSignal()
{
- if ( !mContentSelectedSignal.Empty() )
+ if(!mContentSelectedSignal.Empty())
{
- Dali::ClipboardEventNotifier handle( this );
- mContentSelectedSignal.Emit( handle );
+ Dali::ClipboardEventNotifier handle(this);
+ mContentSelectedSignal.Emit(handle);
}
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
struct Clipboard::Impl
{
};
-Clipboard::Clipboard( Impl* impl )
-: mImpl( impl )
+Clipboard::Clipboard(Impl* impl)
+: mImpl(impl)
{
}
{
Dali::Clipboard clipboard;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
if(handle)
{
// If so, downcast the handle
- clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
+ clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
}
else
{
- Clipboard::Impl* impl( new Clipboard::Impl() );
- clipboard = Dali::Clipboard( new Clipboard(impl) );
- service.Register( typeid(Dali::Clipboard), clipboard );
+ Clipboard::Impl* impl(new Clipboard::Impl());
+ clipboard = Dali::Clipboard(new Clipboard(impl));
+ service.Register(typeid(Dali::Clipboard), clipboard);
}
}
return clipboard;
}
-bool Clipboard::SetItem(const std::string &itemData )
+bool Clipboard::SetItem(const std::string& itemData)
{
return true;
}
return false;
}
-char* Clipboard::ExcuteBuffered( bool type, void *event )
+char* Clipboard::ExcuteBuffered(bool type, void* event)
{
return NULL;
}
/*
- * Copyright (c) 2019 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.
*/
// CLASS HEADER
-#include <dali/internal/clipboard/common/clipboard-impl.h>
#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
+#include <dali/internal/clipboard/common/clipboard-impl.h>
// EXTERNAL INCLUDES
#include <dali/internal/system/linux/dali-ecore.h>
#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wayland.h>
#endif
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/type-registry.h>
#include <unistd.h>
#ifdef DALI_ELDBUS_AVAILABLE
#define CBHM_DBUS_OBJPATH "/org/tizen/cbhm/dbus"
#ifndef CBHM_DBUS_INTERFACE
#define CBHM_DBUS_INTERFACE "org.tizen.cbhm.dbus"
-#endif /* CBHM_DBUS_INTERFACE */
-#define CBHM_COUNT_ALL 0 // ATOM_INDEX_CBHM_COUNT_ALL
+#endif /* CBHM_DBUS_INTERFACE */
+#define CBHM_COUNT_ALL 0 // ATOM_INDEX_CBHM_COUNT_ALL
///////////////////////////////////////////////////////////////////////////////////////////////////
// Clipboard
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
struct Clipboard::Impl
{
Impl()
{
- Eldbus_Object *eldbus_obj;
+ Eldbus_Object* eldbus_obj;
eldbus_init();
- cbhm_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
- eldbus_obj = eldbus_object_get(cbhm_conn, CBHM_DBUS_INTERFACE, CBHM_DBUS_OBJPATH);
+ cbhm_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
+ eldbus_obj = eldbus_object_get(cbhm_conn, CBHM_DBUS_INTERFACE, CBHM_DBUS_OBJPATH);
eldbus_proxy = eldbus_proxy_get(eldbus_obj, CBHM_DBUS_INTERFACE);
eldbus_name_owner_changed_callback_add(cbhm_conn, CBHM_DBUS_INTERFACE, NULL, cbhm_conn, EINA_TRUE);
eldbus_proxy_signal_handler_add(eldbus_proxy, "ItemClicked", _on_item_clicked, this);
- mVisible = false;
+ mVisible = false;
mIsFirstTimeHidden = true;
}
~Impl()
{
- if (cbhm_conn)
+ if(cbhm_conn)
eldbus_connection_unref(cbhm_conn);
eldbus_shutdown();
}
return cbhm_conn;
}
- void SetItem( const std::string &itemData )
+ void SetItem(const std::string& itemData)
{
- const char *types[10] = {0, };
+ const char* types[10] = {
+ 0,
+ };
int i = -1;
- if (itemData.length() == 0)
+ if(itemData.length() == 0)
{
return;
}
types[++i] = "CLIPBOARD_END";
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) );
- ecore_wl2_dnd_selection_set( input, types );
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
+ ecore_wl2_dnd_selection_set(input, types);
#else
- ecore_wl_dnd_selection_set( ecore_wl_input_get(), types );
+ ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
#endif
}
void RequestItem()
{
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) );
- ecore_wl2_dnd_selection_get( input );
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
+ ecore_wl2_dnd_selection_get(input);
#else
- const char *types[10] = {0, };
+ const char* types[10] = {
+ 0,
+ };
int i = -1;
types[++i] = "text/plain;charset=utf-8";
#endif
Dali::ClipboardEventNotifier clipboardEventNotifier(Dali::ClipboardEventNotifier::Get());
- if ( clipboardEventNotifier )
+ if(clipboardEventNotifier)
{
- clipboardEventNotifier.SetContent( mSendBuffer );
+ clipboardEventNotifier.SetContent(mSendBuffer);
clipboardEventNotifier.EmitContentSelectedSignal();
}
}
- char *ExcuteSend( void *event )
+ char* ExcuteSend(void* event)
{
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Event_Data_Source_Send *ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send *>( event );
+ Ecore_Wl2_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send*>(event);
#else
- Ecore_Wl_Event_Data_Source_Send *ev = reinterpret_cast<Ecore_Wl_Event_Data_Source_Send *>( event );
+ Ecore_Wl_Event_Data_Source_Send* ev = reinterpret_cast<Ecore_Wl_Event_Data_Source_Send*>(event);
#endif
- int len_buf = mSendBuffer.length();
- int len_remained = len_buf;
- int len_written = 0, ret;
- const char *buf = mSendBuffer.c_str();
+ int len_buf = mSendBuffer.length();
+ int len_remained = len_buf;
+ int len_written = 0, ret;
+ const char* buf = mSendBuffer.c_str();
- while (len_written < len_buf)
+ while(len_written < len_buf)
{
- ret = write(ev->fd, buf, len_remained);
- if (ret == -1) break;
- buf += ret;
- len_written += ret;
- len_remained -= ret;
+ ret = write(ev->fd, buf, len_remained);
+ if(ret == -1) break;
+ buf += ret;
+ len_written += ret;
+ len_remained -= ret;
}
close(ev->fd);
return NULL;
}
- char *ExcuteReceive( void *event )
+ char* ExcuteReceive(void* event)
{
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Event_Selection_Data_Ready *ev = reinterpret_cast<Ecore_Wl2_Event_Selection_Data_Ready *>( event );
+ Ecore_Wl2_Event_Selection_Data_Ready* ev = reinterpret_cast<Ecore_Wl2_Event_Selection_Data_Ready*>(event);
#else
- Ecore_Wl_Event_Selection_Data_Ready *ev = reinterpret_cast<Ecore_Wl_Event_Selection_Data_Ready *>( event );
+ Ecore_Wl_Event_Selection_Data_Ready* ev = reinterpret_cast<Ecore_Wl_Event_Selection_Data_Ready*>(event);
#endif
- return reinterpret_cast<char *>( ev->data );
+ return reinterpret_cast<char*>(ev->data);
}
int GetCount()
{
Eldbus_Message *reply, *req;
- const char *errname = NULL, *errmsg = NULL;
- int count = -1;
+ const char * errname = NULL, *errmsg = NULL;
+ int count = -1;
- if (!(req = eldbus_proxy_method_call_new(eldbus_proxy, "CbhmGetCount")))
+ if(!(req = eldbus_proxy_method_call_new(eldbus_proxy, "CbhmGetCount")))
{
DALI_LOG_ERROR("Failed to create method call on org.freedesktop.DBus.Properties.Get");
return -1;
}
eldbus_message_ref(req);
- eldbus_message_arguments_append(req, "i", CBHM_COUNT_ALL) ;
+ eldbus_message_arguments_append(req, "i", CBHM_COUNT_ALL);
reply = eldbus_proxy_send_and_block(eldbus_proxy, req, 100);
- if (!reply || eldbus_message_error_get(reply, &errname, &errmsg))
+ if(!reply || eldbus_message_error_get(reply, &errname, &errmsg))
{
DALI_LOG_ERROR("Unable to call method org.freedesktop.DBus.Properties.Get: %s %s",
- errname, errmsg);
+ errname,
+ errmsg);
eldbus_message_unref(req);
- if( reply )
+ if(reply)
{
eldbus_message_unref(reply);
}
return -1;
}
- if (!eldbus_message_arguments_get(reply, "i", &count))
+ if(!eldbus_message_arguments_get(reply, "i", &count))
{
DALI_LOG_ERROR("Cannot get arguments from eldbus");
eldbus_message_unref(req);
{
eldbus_proxy_call(cbhm_proxy_get(), "CbhmShow", NULL, NULL, -1, "s", "0");
mIsFirstTimeHidden = true;
- mVisible = true;
+ mVisible = true;
}
- void HideClipboard( bool skipFirstHide )
+ void HideClipboard(bool skipFirstHide)
{
- if ( skipFirstHide && mIsFirstTimeHidden )
+ if(skipFirstHide && mIsFirstTimeHidden)
{
mIsFirstTimeHidden = false;
return;
}
eldbus_proxy_call(cbhm_proxy_get(), "CbhmHide", NULL, NULL, -1, "");
mIsFirstTimeHidden = false;
- mVisible = false;
+ mVisible = false;
}
bool IsVisible() const
return mVisible;
}
- static void _on_item_clicked(void *data, const Eldbus_Message *msg EINA_UNUSED)
+ static void _on_item_clicked(void* data, const Eldbus_Message* msg EINA_UNUSED)
{
static_cast<Clipboard::Impl*>(data)->RequestItem();
}
- Eldbus_Proxy *eldbus_proxy;
- Eldbus_Connection *cbhm_conn;
+ Eldbus_Proxy* eldbus_proxy;
+ Eldbus_Connection* cbhm_conn;
std::string mSendBuffer;
- bool mVisible;
- bool mIsFirstTimeHidden;
+ bool mVisible;
+ bool mIsFirstTimeHidden;
};
Clipboard::Clipboard(Impl* impl)
{
Dali::Clipboard clipboard;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
if(handle)
{
// If so, downcast the handle
- clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
+ clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
}
else
{
- Clipboard::Impl* impl( new Clipboard::Impl() );
- clipboard = Dali::Clipboard( new Clipboard(impl) );
- service.Register( typeid(Dali::Clipboard), clipboard );
+ Clipboard::Impl* impl(new Clipboard::Impl());
+ clipboard = Dali::Clipboard(new Clipboard(impl));
+ service.Register(typeid(Dali::Clipboard), clipboard);
}
}
return clipboard;
}
-bool Clipboard::SetItem(const std::string &itemData )
+bool Clipboard::SetItem(const std::string& itemData)
{
- mImpl->SetItem( itemData );
+ mImpl->SetItem(itemData);
return true;
}
return mImpl->IsVisible();
}
-char* Clipboard::ExcuteBuffered( bool type, void *event )
+char* Clipboard::ExcuteBuffered(bool type, void* event)
{
- return (type ? mImpl->ExcuteSend( event ) : mImpl->ExcuteReceive( event ));
+ return (type ? mImpl->ExcuteSend(event) : mImpl->ExcuteReceive(event));
}
} // namespace Adaptor
/*
- * Copyright (c) 2019 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.
#include <dali/internal/clipboard/common/clipboard-impl.h>
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
#include <dali/internal/system/linux/dali-ecore-x.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/window-system/ubuntu-x11/window-interface-ecore-x.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
+#include <dali/internal/window-system/ubuntu-x11/window-interface-ecore-x.h>
namespace //unnamed namespace
{
const char* const CBHM_WINDOW = "CBHM_XWIN";
-const char* const CBHM_MSG = "CBHM_MSG";
-const char* const CBHM_ITEM = "CBHM_ITEM";
+const char* const CBHM_MSG = "CBHM_MSG";
+const char* const CBHM_ITEM = "CBHM_ITEM";
const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
-const char* const CBHM_ERROR = "CBHM_ERROR";
-const char* const SET_ITEM = "SET_ITEM";
-const char* const SHOW = "show0";
-const char* const HIDE = "cbhm_hide";
-}
+const char* const CBHM_ERROR = "CBHM_ERROR";
+const char* const SET_ITEM = "SET_ITEM";
+const char* const SHOW = "show0";
+const char* const HIDE = "cbhm_hide";
+} // namespace
///////////////////////////////////////////////////////////////////////////////////////////////////
// Clipboard
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
struct Clipboard::Impl
{
- Impl( Ecore_X_Window ecoreXwin )
+ Impl(Ecore_X_Window ecoreXwin)
{
mApplicationWindow = ecoreXwin;
}
};
Clipboard::Clipboard(Impl* impl)
-: mImpl( impl )
+: mImpl(impl)
{
}
{
Dali::Clipboard clipboard;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
if(handle)
{
// If so, downcast the handle
- clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
+ clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
}
else
{
- Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
- Any nativewindow = adaptorImpl.GetNativeWindowHandle();
+ Adaptor& adaptorImpl(Adaptor::GetImplementation(Adaptor::Get()));
+ Any nativewindow = adaptorImpl.GetNativeWindowHandle();
// The Ecore_X_Window needs to use the Clipboard.
// Only when the render surface is window, we can get the Ecore_X_Window.
- Ecore_X_Window ecoreXwin( AnyCast<Ecore_X_Window>(nativewindow) );
- if (ecoreXwin)
+ Ecore_X_Window ecoreXwin(AnyCast<Ecore_X_Window>(nativewindow));
+ if(ecoreXwin)
{
// If we fail to get Ecore_X_Window, we can't use the Clipboard correctly.
// Thus you have to call "ecore_imf_context_client_window_set" somewhere.
// In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
- Clipboard::Impl* impl( new Clipboard::Impl( ecoreXwin ) );
- clipboard = Dali::Clipboard( new Clipboard( impl ) );
- service.Register( typeid( clipboard ), clipboard );
+ Clipboard::Impl* impl(new Clipboard::Impl(ecoreXwin));
+ clipboard = Dali::Clipboard(new Clipboard(impl));
+ service.Register(typeid(clipboard), clipboard);
}
}
}
return clipboard;
}
-bool Clipboard::SetItem(const std::string &itemData )
+bool Clipboard::SetItem(const std::string& itemData)
{
- Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
- Ecore_X_Atom atomCbhmItem = ecore_x_atom_get( CBHM_ITEM );
- Ecore_X_Atom dataType = ECORE_X_ATOM_STRING;
+ Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
+ Ecore_X_Atom atomCbhmItem = ecore_x_atom_get(CBHM_ITEM);
+ Ecore_X_Atom dataType = ECORE_X_ATOM_STRING;
// Set item (property) to send
- ecore_x_window_prop_property_set( cbhmWin, atomCbhmItem, dataType, 8, const_cast<char*>( itemData.c_str() ), itemData.length() + 1 );
+ ecore_x_window_prop_property_set(cbhmWin, atomCbhmItem, dataType, 8, const_cast<char*>(itemData.c_str()), itemData.length() + 1);
ecore_x_sync();
// Trigger sending of item (property)
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
- ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SET_ITEM );
+ Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(CBHM_MSG);
+ ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SET_ITEM);
return true;
}
*/
void Clipboard::RequestItem()
{
- int index = 0;
+ int index = 0;
char sendBuf[20];
- snprintf( sendBuf, 20, "%s%d", CBHM_ITEM, index );
- Ecore_X_Atom xAtomCbhmItem = ecore_x_atom_get( sendBuf );
+ snprintf(sendBuf, 20, "%s%d", CBHM_ITEM, index);
+ Ecore_X_Atom xAtomCbhmItem = ecore_x_atom_get(sendBuf);
Ecore_X_Atom xAtomItemType = 0;
- std::string clipboardString( ECore::WindowInterface::GetWindowProperty(xAtomCbhmItem, &xAtomItemType, index ) );
+ std::string clipboardString(ECore::WindowInterface::GetWindowProperty(xAtomCbhmItem, &xAtomItemType, index));
// Only return the text string if the Atom type is text (Do not return a text string/URL for images).
- if( !clipboardString.empty() &&
- ( xAtomItemType == ECORE_X_ATOM_TEXT || xAtomItemType == ECORE_X_ATOM_COMPOUND_TEXT || xAtomItemType == ECORE_X_ATOM_STRING || xAtomItemType == ECORE_X_ATOM_UTF8_STRING ) )
+ if(!clipboardString.empty() &&
+ (xAtomItemType == ECORE_X_ATOM_TEXT || xAtomItemType == ECORE_X_ATOM_COMPOUND_TEXT || xAtomItemType == ECORE_X_ATOM_STRING || xAtomItemType == ECORE_X_ATOM_UTF8_STRING))
{
- Ecore_X_Atom xAtomCbhmError = ecore_x_atom_get( CBHM_ERROR );
- if ( xAtomItemType != xAtomCbhmError )
+ Ecore_X_Atom xAtomCbhmError = ecore_x_atom_get(CBHM_ERROR);
+ if(xAtomItemType != xAtomCbhmError)
{
// Call ClipboardEventNotifier to notify event observe of retrieved string
Dali::ClipboardEventNotifier clipboardEventNotifier(ClipboardEventNotifier::Get());
- if ( clipboardEventNotifier )
+ if(clipboardEventNotifier)
{
- ClipboardEventNotifier& notifierImpl( ClipboardEventNotifier::GetImplementation( clipboardEventNotifier ) );
+ ClipboardEventNotifier& notifierImpl(ClipboardEventNotifier::GetImplementation(clipboardEventNotifier));
- notifierImpl.SetContent( clipboardString );
+ notifierImpl.SetContent(clipboardString);
notifierImpl.EmitContentSelectedSignal();
}
}
*/
unsigned int Clipboard::NumberOfItems()
{
- Ecore_X_Atom xAtomCbhmCountGet = ecore_x_atom_get( CBHM_cCOUNT );
+ Ecore_X_Atom xAtomCbhmCountGet = ecore_x_atom_get(CBHM_cCOUNT);
- std::string ret( ECore::WindowInterface::GetWindowProperty( xAtomCbhmCountGet, NULL, 0 ) );
- int count = 0;
+ std::string ret(ECore::WindowInterface::GetWindowProperty(xAtomCbhmCountGet, NULL, 0));
+ int count = 0;
- if ( !ret.empty() )
+ if(!ret.empty())
{
- count = atoi( ret.c_str() );
+ count = atoi(ret.c_str());
}
return count;
Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
// Launch the clipboard window
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
- ECore::WindowInterface::SendXEvent( ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SHOW );
+ Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(CBHM_MSG);
+ ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, SHOW);
}
void Clipboard::HideClipboard(bool skipFirstHide)
{
Ecore_X_Window cbhmWin = ECore::WindowInterface::GetWindow();
// Launch the clipboard window
- Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get( CBHM_MSG );
- ECore::WindowInterface::SendXEvent( ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, HIDE );
+ Ecore_X_Atom atomCbhmMsg = ecore_x_atom_get(CBHM_MSG);
+ ECore::WindowInterface::SendXEvent(ecore_x_display_get(), cbhmWin, False, NoEventMask, atomCbhmMsg, 8, HIDE);
// release the ownership of SECONDARY selection
ecore_x_selection_secondary_clear();
return false;
}
-char* Clipboard::ExcuteBuffered( bool type, void *event )
+char* Clipboard::ExcuteBuffered(bool type, void* event)
{
- if( !type )
+ if(!type)
{
// Receive
- Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast< Ecore_X_Event_Selection_Notify* >( event );
+ Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast<Ecore_X_Event_Selection_Notify*>(event);
- Ecore_X_Selection_Data* selectionData = static_cast< Ecore_X_Selection_Data* >( selectionNotifyEvent->data );
- if( selectionData->data )
+ Ecore_X_Selection_Data* selectionData = static_cast<Ecore_X_Selection_Data*>(selectionNotifyEvent->data);
+ if(selectionData->data)
{
- if( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ if(selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY)
{
// Claim the ownership of the SECONDARY selection.
- ecore_x_selection_secondary_set( mImpl->mApplicationWindow, "", 1 );
+ ecore_x_selection_secondary_set(mImpl->mApplicationWindow, "", 1);
- return ( reinterpret_cast< char* >( selectionData->data ) );
+ return (reinterpret_cast<char*>(selectionData->data));
}
}
}
/*
- * Copyright (c) 2019 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.
*
*/
-
// CLASS HEADER
#include <dali/internal/graphics/common/egl-image-extensions.h>
// INTERNAL INCLUDES
#include <dali/internal/graphics/gles/egl-implementation.h>
-
namespace
{
// function pointers assigned in InitializeEglImageKHR
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
+PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESProc = 0;
} // unnamed namespace
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
-: mEglImplementation( eglImpl ),
- mImageKHRInitialized( false ),
- mImageKHRInitializeFailed( false )
+: mEglImplementation(eglImpl),
+ mImageKHRInitialized(false),
+ mImageKHRInitializeFailed(false)
{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+ DALI_ASSERT_ALWAYS(eglImpl && "EGL Implementation not instantiated");
}
EglImageExtensions::~EglImageExtensions() = default;
void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
{
- if( mImageKHRInitialized == false )
+ if(mImageKHRInitialized == false)
{
InitializeEglImageKHR();
}
- if( mImageKHRInitialized == false )
+ if(mImageKHRInitialized == false)
{
return NULL;
}
// No extensions
const EGLint attribs[] =
- {
- EGL_NONE
- };
+ {
+ EGL_NONE};
// EGL constants use C casts
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
- EGLImageKHR eglImage = eglCreateImageKHRProc( mEglImplementation->GetDisplay(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_BUFFER_ANDROID,
- clientBuffer,
- attribs );
-
- DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "eglCreateImageKHR failed!\n");
- if( EGL_NO_IMAGE_KHR == eglImage )
+ EGLImageKHR eglImage = eglCreateImageKHRProc(mEglImplementation->GetDisplay(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_BUFFER_ANDROID,
+ clientBuffer,
+ attribs);
+
+ DALI_ASSERT_DEBUG(EGL_NO_IMAGE_KHR != eglImage && "eglCreateImageKHR failed!\n");
+ if(EGL_NO_IMAGE_KHR == eglImage)
{
- switch( eglGetError() )
+ switch(eglGetError())
{
- case EGL_SUCCESS :
+ case EGL_SUCCESS:
{
break;
}
case EGL_BAD_DISPLAY:
{
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY: Invalid EGLDisplay object\n");
break;
}
case EGL_BAD_CONTEXT:
{
- DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object\n" );
+ DALI_LOG_ERROR("EGL_BAD_CONTEXT: Invalid EGLContext object\n");
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n");
break;
}
case EGL_BAD_MATCH:
{
- DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target\n" );
+ DALI_LOG_ERROR("EGL_BAD_MATCH: attrib_list does not match target\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n");
break;
}
case EGL_BAD_ALLOC:
{
- DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" );
+ DALI_LOG_ERROR("EGL_BAD_ALLOC: Insufficient memory is available\n");
break;
}
default:
void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
+ DALI_ASSERT_DEBUG(mImageKHRInitialized);
- if( ! mImageKHRInitialized )
+ if(!mImageKHRInitialized)
{
return;
}
- if( eglImageKHR == NULL )
+ if(eglImageKHR == NULL)
{
return;
}
- EGLImageKHR eglImage = static_cast<EGLImageKHR>( eglImageKHR );
+ EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
- EGLBoolean result = eglDestroyImageKHRProc( mEglImplementation->GetDisplay(), eglImage );
+ EGLBoolean result = eglDestroyImageKHRProc(mEglImplementation->GetDisplay(), eglImage);
- if( EGL_FALSE == result )
+ if(EGL_FALSE == result)
{
- switch( eglGetError() )
+ switch(eglGetError())
{
case EGL_BAD_DISPLAY:
{
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY: Invalid EGLDisplay object\n");
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: EGLImage sibling error\n");
break;
}
default:
void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
+ DALI_ASSERT_DEBUG(mImageKHRInitialized);
- if( eglImageKHR != NULL )
+ if(eglImageKHR != NULL)
{
EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
GLint glError = glGetError();
#endif
- glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast< GLeglImageOES >( eglImage ) );
+ glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast<GLeglImageOES>(eglImage));
#ifdef EGL_ERROR_CHECKING
glError = glGetError();
- if( GL_NO_ERROR != glError )
+ if(GL_NO_ERROR != glError)
{
- DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
+ DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError);
}
#endif
}
void EglImageExtensions::InitializeEglImageKHR()
{
// avoid trying to reload extended KHR functions, if it fails the first time
- if( ! mImageKHRInitializeFailed )
+ if(!mImageKHRInitializeFailed)
{
- eglCreateImageKHRProc = reinterpret_cast< PFNEGLCREATEIMAGEKHRPROC >( eglGetProcAddress("eglCreateImageKHR") );
- eglDestroyImageKHRProc = reinterpret_cast< PFNEGLDESTROYIMAGEKHRPROC >( eglGetProcAddress("eglDestroyImageKHR") );
- glEGLImageTargetTexture2DOESProc = reinterpret_cast< PFNGLEGLIMAGETARGETTEXTURE2DOESPROC >( eglGetProcAddress("glEGLImageTargetTexture2DOES") );
+ eglCreateImageKHRProc = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ eglDestroyImageKHRProc = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ glEGLImageTargetTexture2DOESProc = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
}
- if( eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc )
+ if(eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
{
mImageKHRInitialized = true;
}
/*
- * Copyright (c) 2019 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.
*
*/
-
// CLASS HEADER
#include <dali/internal/graphics/common/egl-image-extensions.h>
// INTERNAL INCLUDES
#include <dali/internal/graphics/gles/egl-implementation.h>
-
namespace
{
// function pointers assigned in InitializeEglImageKHR
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
+PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESProc = 0;
} // unnamed namespace
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
: mEglImplementation(eglImpl),
mImageKHRInitialized(false),
mImageKHRInitializeFailed(false)
{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+ DALI_ASSERT_ALWAYS(eglImpl && "EGL Implementation not instantiated");
}
EglImageExtensions::~EglImageExtensions()
void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
{
- if (mImageKHRInitialized == false)
+ if(mImageKHRInitialized == false)
{
InitializeEglImageKHR();
}
- if (mImageKHRInitialized == false)
+ if(mImageKHRInitialized == false)
{
return NULL;
}
// Use the EGL image extension
const EGLint attribs[] =
+ {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
+
+ EGLImageKHR eglImage = eglCreateImageKHRProc(mEglImplementation->GetDisplay(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ clientBuffer,
+ attribs);
+
+ DALI_ASSERT_DEBUG(EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
+ if(EGL_NO_IMAGE_KHR == eglImage)
{
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
- };
-
- EGLImageKHR eglImage = eglCreateImageKHRProc( mEglImplementation->GetDisplay(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- clientBuffer,
- attribs );
-
- DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
- if( EGL_NO_IMAGE_KHR == eglImage )
- {
- switch( eglGetError() )
+ switch(eglGetError())
{
- case EGL_SUCCESS :
+ case EGL_SUCCESS:
{
break;
}
case EGL_BAD_DISPLAY:
{
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY: Invalid EGLDisplay object\n");
break;
}
case EGL_BAD_CONTEXT:
{
- DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object\n" );
+ DALI_LOG_ERROR("EGL_BAD_CONTEXT: Invalid EGLContext object\n");
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n");
break;
}
case EGL_BAD_MATCH:
{
- DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target\n" );
+ DALI_LOG_ERROR("EGL_BAD_MATCH: attrib_list does not match target\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n");
break;
}
case EGL_BAD_ALLOC:
{
- DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" );
+ DALI_LOG_ERROR("EGL_BAD_ALLOC: Insufficient memory is available\n");
break;
}
default:
void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
+ DALI_ASSERT_DEBUG(mImageKHRInitialized);
- if( ! mImageKHRInitialized )
+ if(!mImageKHRInitialized)
{
return;
}
- if( eglImageKHR == NULL )
+ if(eglImageKHR == NULL)
{
return;
}
EGLBoolean result = eglDestroyImageKHRProc(mEglImplementation->GetDisplay(), eglImage);
- if( EGL_FALSE == result )
+ if(EGL_FALSE == result)
{
- switch( eglGetError() )
+ switch(eglGetError())
{
case EGL_BAD_DISPLAY:
{
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY: Invalid EGLDisplay object\n");
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: EGLImage sibling error\n");
break;
}
default:
void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
+ DALI_ASSERT_DEBUG(mImageKHRInitialized);
- if( eglImageKHR != NULL )
+ if(eglImageKHR != NULL)
{
EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
GLint glError = glGetError();
#endif
- glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast< GLeglImageOES >( eglImage ) );
+ glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast<GLeglImageOES>(eglImage));
#ifdef EGL_ERROR_CHECKING
glError = glGetError();
- if( GL_NO_ERROR != glError )
+ if(GL_NO_ERROR != glError)
{
- DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
+ DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError);
}
#endif
}
void EglImageExtensions::InitializeEglImageKHR()
{
// avoid trying to reload extended KHR functions, if it fails the first time
- if( ! mImageKHRInitializeFailed )
+ if(!mImageKHRInitializeFailed)
{
- eglCreateImageKHRProc = reinterpret_cast< PFNEGLCREATEIMAGEKHRPROC >( eglGetProcAddress("eglCreateImageKHR") );
- eglDestroyImageKHRProc = reinterpret_cast< PFNEGLDESTROYIMAGEKHRPROC >( eglGetProcAddress("eglDestroyImageKHR") );
- glEGLImageTargetTexture2DOESProc = reinterpret_cast< PFNGLEGLIMAGETARGETTEXTURE2DOESPROC >( eglGetProcAddress("glEGLImageTargetTexture2DOES") );
+ eglCreateImageKHRProc = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ eglDestroyImageKHRProc = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ glEGLImageTargetTexture2DOESProc = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
}
- if (eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
+ if(eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
{
mImageKHRInitialized = true;
}
/*
- * 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.
{
namespace Adaptor
{
-
EglContextHelperImplementation::EglContextHelperImplementation()
-: mEglImplementation( NULL )
+: mEglImplementation(NULL)
{
}
-void EglContextHelperImplementation::Initialize( EglImplementation* eglImpl )
+void EglContextHelperImplementation::Initialize(EglImplementation* eglImpl)
{
mEglImplementation = eglImpl;
}
void EglContextHelperImplementation::MakeSurfacelessContextCurrent()
{
- if ( mEglImplementation && mEglImplementation->IsSurfacelessContextSupported() )
+ if(mEglImplementation && mEglImplementation->IsSurfacelessContextSupported())
{
- mEglImplementation->MakeContextCurrent( EGL_NO_SURFACE, mEglImplementation->GetContext() );
+ mEglImplementation->MakeContextCurrent(EGL_NO_SURFACE, mEglImplementation->GetContext());
}
}
void EglContextHelperImplementation::MakeContextNull()
{
- if ( mEglImplementation )
+ if(mEglImplementation)
{
mEglImplementation->MakeContextNull();
}
void EglContextHelperImplementation::WaitClient()
{
- if ( mEglImplementation )
+ if(mEglImplementation)
{
mEglImplementation->WaitClient();
}
}
-} // namespace Dali
-} // namespace Internal
} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace Egl
{
-
-void PrintError( EGLint error)
+void PrintError(EGLint error)
{
- switch (error)
+ switch(error)
{
case EGL_BAD_DISPLAY:
{
}
}
-} // namespace Egl
+} // namespace Egl
-} // namespace Adaptor
+} // namespace Adaptor
-} // namespace Internal
+} // namespace Internal
-} // namespace Dali
+} // namespace Dali
/*
- * 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.
*
*/
-
// CLASS HEADER
#include <dali/internal/graphics/gles/egl-implementation.h>
// EXTERNAL INCLUDES
-#include <sstream>
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/dali-vector.h>
+#include <sstream>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
-#include <dali/internal/graphics/gles/gl-implementation.h>
#include <dali/internal/graphics/gles/egl-debug.h>
+#include <dali/internal/graphics/gles/gl-implementation.h>
+#include <dali/public-api/dali-adaptor-common.h>
// EGL constants use C style casts
#pragma GCC diagnostic push
namespace
{
- const uint32_t THRESHOLD_SWAPBUFFER_COUNT = 5;
- const uint32_t CHECK_EXTENSION_NUMBER = 4;
- const uint32_t EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT = 15;
- const std::string EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
- const std::string EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
- const std::string EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
- const std::string EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE = "EGL_KHR_swap_buffers_with_damage";
+const uint32_t THRESHOLD_SWAPBUFFER_COUNT = 5;
+const uint32_t CHECK_EXTENSION_NUMBER = 4;
+const uint32_t EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT = 15;
+const std::string EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
+const std::string EGL_KHR_CREATE_CONTEXT = "EGL_KHR_create_context";
+const std::string EGL_KHR_PARTIAL_UPDATE = "EGL_KHR_partial_update";
+const std::string EGL_KHR_SWAP_BUFFERS_WITH_DAMAGE = "EGL_KHR_swap_buffers_with_damage";
-}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-#define TEST_EGL_ERROR(lastCommand) \
-{ \
- EGLint err = eglGetError(); \
- if (err != EGL_SUCCESS) \
- { \
- DALI_LOG_ERROR("EGL error after %s\n", lastCommand); \
- Egl::PrintError(err); \
- DALI_ASSERT_ALWAYS(0 && "EGL error"); \
- } \
-}
-
-EglImplementation::EglImplementation( int multiSamplingLevel,
- Integration::DepthBufferAvailable depthBufferRequired,
- Integration::StencilBufferAvailable stencilBufferRequired ,
- Integration::PartialUpdateAvailable partialUpdateRequired )
+#define TEST_EGL_ERROR(lastCommand) \
+ { \
+ EGLint err = eglGetError(); \
+ if(err != EGL_SUCCESS) \
+ { \
+ DALI_LOG_ERROR("EGL error after %s\n", lastCommand); \
+ Egl::PrintError(err); \
+ DALI_ASSERT_ALWAYS(0 && "EGL error"); \
+ } \
+ }
+
+EglImplementation::EglImplementation(int multiSamplingLevel,
+ Integration::DepthBufferAvailable depthBufferRequired,
+ Integration::StencilBufferAvailable stencilBufferRequired,
+ Integration::PartialUpdateAvailable partialUpdateRequired)
: mContextAttribs(),
- mEglNativeDisplay( 0 ),
- mEglNativeWindow( 0 ),
- mCurrentEglNativePixmap( 0 ),
- mEglDisplay( 0 ),
- mEglConfig( 0 ),
- mEglContext( 0 ),
- mCurrentEglSurface( 0 ),
- mCurrentEglContext( EGL_NO_CONTEXT ),
- mMultiSamplingLevel( multiSamplingLevel ),
- mGlesVersion( 30 ),
- mColorDepth( COLOR_DEPTH_24 ),
- mGlesInitialized( false ),
- mIsOwnSurface( true ),
- mIsWindow( true ),
- mDepthBufferRequired( depthBufferRequired == Integration::DepthBufferAvailable::TRUE ),
- mStencilBufferRequired( stencilBufferRequired == Integration::StencilBufferAvailable::TRUE ),
- mPartialUpdateRequired( partialUpdateRequired == Integration::PartialUpdateAvailable::TRUE ),
- mIsSurfacelessContextSupported( false ),
- mIsKhrCreateContextSupported( false ),
- mSwapBufferCountAfterResume( 0 ),
- mEglSetDamageRegionKHR( 0 ),
- mEglSwapBuffersWithDamageKHR( 0 )
+ mEglNativeDisplay(0),
+ mEglNativeWindow(0),
+ mCurrentEglNativePixmap(0),
+ mEglDisplay(0),
+ mEglConfig(0),
+ mEglContext(0),
+ mCurrentEglSurface(0),
+ mCurrentEglContext(EGL_NO_CONTEXT),
+ mMultiSamplingLevel(multiSamplingLevel),
+ mGlesVersion(30),
+ mColorDepth(COLOR_DEPTH_24),
+ mGlesInitialized(false),
+ mIsOwnSurface(true),
+ mIsWindow(true),
+ mDepthBufferRequired(depthBufferRequired == Integration::DepthBufferAvailable::TRUE),
+ mStencilBufferRequired(stencilBufferRequired == Integration::StencilBufferAvailable::TRUE),
+ mPartialUpdateRequired(partialUpdateRequired == Integration::PartialUpdateAvailable::TRUE),
+ mIsSurfacelessContextSupported(false),
+ mIsKhrCreateContextSupported(false),
+ mSwapBufferCountAfterResume(0),
+ mEglSetDamageRegionKHR(0),
+ mEglSwapBuffersWithDamageKHR(0)
{
}
TerminateGles();
}
-bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwnSurface )
+bool EglImplementation::InitializeGles(EGLNativeDisplayType display, bool isOwnSurface)
{
- if ( !mGlesInitialized )
+ if(!mGlesInitialized)
{
mEglNativeDisplay = display;
// Try to get the display connection for the native display first
- mEglDisplay = eglGetDisplay( mEglNativeDisplay );
+ mEglDisplay = eglGetDisplay(mEglNativeDisplay);
- if( mEglDisplay == EGL_NO_DISPLAY )
+ if(mEglDisplay == EGL_NO_DISPLAY)
{
// If failed, try to get the default display connection
- mEglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY );
+ mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
}
- if( mEglDisplay == EGL_NO_DISPLAY )
+ if(mEglDisplay == EGL_NO_DISPLAY)
{
// Still failed to get a display connection
- throw Dali::DaliException( "", "OpenGL ES is not supported");
+ throw Dali::DaliException("", "OpenGL ES is not supported");
}
EGLint majorVersion = 0;
EGLint minorVersion = 0;
- if ( !eglInitialize( mEglDisplay, &majorVersion, &minorVersion ) )
+ if(!eglInitialize(mEglDisplay, &majorVersion, &minorVersion))
{
return false;
}
mIsOwnSurface = isOwnSurface;
}
- const char* const versionStr = eglQueryString( mEglDisplay, EGL_VERSION );
- const char* const extensionStr = eglQueryString( mEglDisplay, EGL_EXTENSIONS );
+ const char* const versionStr = eglQueryString(mEglDisplay, EGL_VERSION);
+ const char* const extensionStr = eglQueryString(mEglDisplay, EGL_EXTENSIONS);
// Query EGL extensions to check whether required extensions are supported
- std::istringstream versionStream( versionStr );
- std::string majorVersion, minorVersion;
- std::getline( versionStream, majorVersion, '.' );
- std::getline( versionStream, minorVersion );
+ std::istringstream versionStream(versionStr);
+ std::string majorVersion, minorVersion;
+ std::getline(versionStream, majorVersion, '.');
+ std::getline(versionStream, minorVersion);
uint32_t extensionCheckCount = 0;
- if( stoul( majorVersion ) * 10 + stoul( minorVersion ) >= EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT )
+ if(stoul(majorVersion) * 10 + stoul(minorVersion) >= EGL_VERSION_SUPPORT_SURFACELESS_CONTEXT)
{
mIsSurfacelessContextSupported = true;
- mIsKhrCreateContextSupported = true;
+ mIsKhrCreateContextSupported = true;
extensionCheckCount += 2;
}
std::istringstream stream(extensionStr);
- std::string currentExtension;
- bool isKhrPartialUpdateSupported = false;
- bool isKhrSwapBuffersWithDamageSupported = false;
+ std::string currentExtension;
+ bool isKhrPartialUpdateSupported = false;
+ bool isKhrSwapBuffersWithDamageSupported = false;
while(std::getline(stream, currentExtension, ' ') && extensionCheckCount < CHECK_EXTENSION_NUMBER)
{
if(currentExtension == EGL_KHR_SURFACELESS_CONTEXT && !mIsSurfacelessContextSupported)
mGlesInitialized = true;
// We want to display this information all the time, so use the LogMessage directly
- Integration::Log::LogMessage(Integration::Log::DebugInfo, "EGL Information\n"
- " PartialUpdate %d\n"
- " Vendor: %s\n"
- " Version: %s\n"
- " Client APIs: %s\n"
- " Extensions: %s\n",
- mPartialUpdateRequired,
- eglQueryString( mEglDisplay, EGL_VENDOR ),
- versionStr,
- eglQueryString( mEglDisplay, EGL_CLIENT_APIS ),
- extensionStr);
+ Integration::Log::LogMessage(Integration::Log::DebugInfo,
+ "EGL Information\n"
+ " PartialUpdate %d\n"
+ " Vendor: %s\n"
+ " Version: %s\n"
+ " Client APIs: %s\n"
+ " Extensions: %s\n",
+ mPartialUpdateRequired,
+ eglQueryString(mEglDisplay, EGL_VENDOR),
+ versionStr,
+ eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
+ extensionStr);
return mGlesInitialized;
}
bool EglImplementation::CreateContext()
{
// make sure a context isn't created twice
- DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" );
+ DALI_ASSERT_ALWAYS((mEglContext == 0) && "EGL context recreated");
mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
TEST_EGL_ERROR("eglCreateContext render thread");
- DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
+ DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != mEglContext && "EGL context not created");
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
- if (!mEglSetDamageRegionKHR)
+ if(!mEglSetDamageRegionKHR)
{
DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
mPartialUpdateRequired = false;
}
mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
- if (!mEglSwapBuffersWithDamageKHR)
+ if(!mEglSwapBuffersWithDamageKHR)
{
DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
mPartialUpdateRequired = false;
return true;
}
-bool EglImplementation::CreateWindowContext( EGLContext& eglContext )
+bool EglImplementation::CreateWindowContext(EGLContext& eglContext)
{
// make sure a context isn't created twice
- DALI_ASSERT_ALWAYS( (eglContext == 0) && "EGL context recreated" );
+ DALI_ASSERT_ALWAYS((eglContext == 0) && "EGL context recreated");
eglContext = eglCreateContext(mEglDisplay, mEglConfig, mEglContext, &(mContextAttribs[0]));
TEST_EGL_ERROR("eglCreateContext render thread");
- DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != eglContext && "EGL context not created" );
+ DALI_ASSERT_ALWAYS(EGL_NO_CONTEXT != eglContext && "EGL context not created");
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
- mEglWindowContexts.push_back( eglContext );
+ mEglWindowContexts.push_back(eglContext);
mEglSetDamageRegionKHR = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
- if (!mEglSetDamageRegionKHR)
+ if(!mEglSetDamageRegionKHR)
{
DALI_LOG_ERROR("Coudn't find eglSetDamageRegionKHR!\n");
mPartialUpdateRequired = false;
}
mEglSwapBuffersWithDamageKHR = reinterpret_cast<PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC>(eglGetProcAddress("eglSwapBuffersWithDamageKHR"));
- if (!mEglSwapBuffersWithDamageKHR)
+ if(!mEglSwapBuffersWithDamageKHR)
{
DALI_LOG_ERROR("Coudn't find eglSwapBuffersWithDamageKHR!\n");
mPartialUpdateRequired = false;
return true;
}
-void EglImplementation::DestroyContext( EGLContext& eglContext )
+void EglImplementation::DestroyContext(EGLContext& eglContext)
{
- if( eglContext )
+ if(eglContext)
{
- eglDestroyContext( mEglDisplay, eglContext );
+ eglDestroyContext(mEglDisplay, eglContext);
eglContext = 0;
}
}
-void EglImplementation::DestroySurface( EGLSurface& eglSurface )
+void EglImplementation::DestroySurface(EGLSurface& eglSurface)
{
if(mIsOwnSurface && eglSurface)
{
// Make context null to prevent crash in driver side
MakeContextNull();
- eglDestroySurface( mEglDisplay, eglSurface );
+ eglDestroySurface(mEglDisplay, eglSurface);
eglSurface = 0;
}
}
-void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext )
+void EglImplementation::MakeContextCurrent(EGLSurface eglSurface, EGLContext eglContext)
{
- if (mCurrentEglContext == eglContext)
+ if(mCurrentEglContext == eglContext)
{
return;
}
if(mIsOwnSurface)
{
- eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
+ eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, eglContext);
mCurrentEglContext = eglContext;
}
EGLint error = eglGetError();
- if ( error != EGL_SUCCESS )
+ if(error != EGL_SUCCESS)
{
Egl::PrintError(error);
}
}
-void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface )
+void EglImplementation::MakeCurrent(EGLNativePixmapType pixmap, EGLSurface eglSurface)
{
- if (mCurrentEglContext == mEglContext)
+ if(mCurrentEglContext == mEglContext)
{
return;
}
mCurrentEglNativePixmap = pixmap;
- mCurrentEglSurface = eglSurface;
+ mCurrentEglSurface = eglSurface;
if(mIsOwnSurface)
{
- eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
+ eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext);
mCurrentEglContext = mEglContext;
}
EGLint error = eglGetError();
- if ( error != EGL_SUCCESS )
+ if(error != EGL_SUCCESS)
{
Egl::PrintError(error);
void EglImplementation::MakeContextNull()
{
// clear the current context
- eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
+ eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
mCurrentEglContext = EGL_NO_CONTEXT;
}
void EglImplementation::TerminateGles()
{
- if ( mGlesInitialized )
+ if(mGlesInitialized)
{
// Make context null to prevent crash in driver side
MakeContextNull();
- for ( auto eglSurface : mEglWindowSurfaces )
+ for(auto eglSurface : mEglWindowSurfaces)
{
if(mIsOwnSurface && eglSurface)
{
}
}
eglDestroyContext(mEglDisplay, mEglContext);
- for ( auto eglContext : mEglWindowContexts )
+ for(auto eglContext : mEglWindowContexts)
{
eglDestroyContext(mEglDisplay, eglContext);
}
eglTerminate(mEglDisplay);
- mEglDisplay = NULL;
- mEglConfig = NULL;
- mEglContext = NULL;
+ mEglDisplay = NULL;
+ mEglConfig = NULL;
+ mEglContext = NULL;
mCurrentEglSurface = NULL;
mCurrentEglContext = EGL_NO_CONTEXT;
return mGlesInitialized;
}
-void EglImplementation::SwapBuffers( EGLSurface& eglSurface )
+void EglImplementation::SwapBuffers(EGLSurface& eglSurface)
{
- if ( eglSurface != EGL_NO_SURFACE ) // skip if using surfaceless context
+ if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
{
#ifndef DALI_PROFILE_UBUNTU
- if( mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT )
+ if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
{
- DALI_LOG_RELEASE_INFO( "EglImplementation::SwapBuffers started.\n" );
+ DALI_LOG_RELEASE_INFO("EglImplementation::SwapBuffers started.\n");
}
#endif //DALI_PROFILE_UBUNTU
// DALI_LOG_ERROR("EglImplementation::SwapBuffers()\n");
- eglSwapBuffers( mEglDisplay, eglSurface );
+ eglSwapBuffers(mEglDisplay, eglSurface);
#ifndef DALI_PROFILE_UBUNTU
- if( mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT )
+ if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
{
- DALI_LOG_RELEASE_INFO( "EglImplementation::SwapBuffers finished.\n" );
+ DALI_LOG_RELEASE_INFO("EglImplementation::SwapBuffers finished.\n");
mSwapBufferCountAfterResume++;
}
#endif //DALI_PROFILE_UBUNTU
{
EGLint age = 0;
eglQuerySurface(mEglDisplay, eglSurface, EGL_BUFFER_AGE_EXT, &age);
- if (age < 0)
+ if(age < 0)
{
DALI_LOG_ERROR("eglQuerySurface(%d)\n", eglGetError());
age = 0;
// 0 - invalid buffer
// 1, 2, 3
- if (age > 3)
+ if(age > 3)
{
DALI_LOG_ERROR("EglImplementation::GetBufferAge() buffer age %d > 3\n", age);
age = 0; // shoudn't be more than 3 back buffers, if there is just reset, I don't want to add extra history level
return age;
}
-void EglImplementation::SetDamageRegion( EGLSurface& eglSurface, std::vector< Rect< int > >& damagedRects )
+void EglImplementation::SetDamageRegion(EGLSurface& eglSurface, std::vector<Rect<int>>& damagedRects)
{
- if( !mPartialUpdateRequired )
+ if(!mPartialUpdateRequired)
{
return;
}
- if( eglSurface != EGL_NO_SURFACE ) // skip if using surfaceless context
+ if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
{
- EGLBoolean result = mEglSetDamageRegionKHR( mEglDisplay, eglSurface, reinterpret_cast< int* >( damagedRects.data() ), 1 );
- if (result == EGL_FALSE)
+ EGLBoolean result = mEglSetDamageRegionKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(damagedRects.data()), 1);
+ if(result == EGL_FALSE)
{
- DALI_LOG_ERROR( "eglSetDamageRegionKHR(%d)\n", eglGetError() );
+ DALI_LOG_ERROR("eglSetDamageRegionKHR(%d)\n", eglGetError());
}
}
}
void EglImplementation::SwapBuffers(EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects)
{
- if (eglSurface != EGL_NO_SURFACE ) // skip if using surfaceless context
+ if(eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
{
- if (!mPartialUpdateRequired )
+ if(!mPartialUpdateRequired)
{
SwapBuffers(eglSurface);
return;
}
#ifndef DALI_PROFILE_UBUNTU
- if( mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT )
+ if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
{
- DALI_LOG_RELEASE_INFO( "EglImplementation::SwapBuffers started.\n" );
+ DALI_LOG_RELEASE_INFO("EglImplementation::SwapBuffers started.\n");
}
#endif //DALI_PROFILE_UBUNTU
- EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(const_cast< std::vector< Rect< int > >& >( damagedRects ).data()), damagedRects.size());
- if (result == EGL_FALSE)
+ EGLBoolean result = mEglSwapBuffersWithDamageKHR(mEglDisplay, eglSurface, reinterpret_cast<int*>(const_cast<std::vector<Rect<int>>&>(damagedRects).data()), damagedRects.size());
+ if(result == EGL_FALSE)
{
DALI_LOG_ERROR("eglSwapBuffersWithDamageKHR(%d)\n", eglGetError());
}
#ifndef DALI_PROFILE_UBUNTU
- if( mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT )
+ if(mSwapBufferCountAfterResume < THRESHOLD_SWAPBUFFER_COUNT)
{
- DALI_LOG_RELEASE_INFO( "EglImplementation::SwapBuffers finished.\n" );
+ DALI_LOG_RELEASE_INFO("EglImplementation::SwapBuffers finished.\n");
mSwapBufferCountAfterResume++;
}
#endif //DALI_PROFILE_UBUNTU
}
}
-void EglImplementation::CopyBuffers( EGLSurface& eglSurface )
+void EglImplementation::CopyBuffers(EGLSurface& eglSurface)
{
- eglCopyBuffers( mEglDisplay, eglSurface, mCurrentEglNativePixmap );
+ eglCopyBuffers(mEglDisplay, eglSurface, mCurrentEglNativePixmap);
}
void EglImplementation::WaitGL()
eglWaitGL();
}
-bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
+bool EglImplementation::ChooseConfig(bool isWindowType, ColorDepth depth)
{
if(mEglConfig && isWindowType == mIsWindow && mColorDepth == depth)
{
}
mColorDepth = depth;
- mIsWindow = isWindowType;
+ mIsWindow = isWindowType;
- EGLint numConfigs;
+ EGLint numConfigs;
Vector<EGLint> configAttribs;
configAttribs.Reserve(31);
if(isWindowType)
{
- configAttribs.PushBack( EGL_SURFACE_TYPE );
- configAttribs.PushBack( EGL_WINDOW_BIT );
+ configAttribs.PushBack(EGL_SURFACE_TYPE);
+ configAttribs.PushBack(EGL_WINDOW_BIT);
}
else
{
- configAttribs.PushBack( EGL_SURFACE_TYPE );
- configAttribs.PushBack( EGL_PIXMAP_BIT );
+ configAttribs.PushBack(EGL_SURFACE_TYPE);
+ configAttribs.PushBack(EGL_PIXMAP_BIT);
}
- configAttribs.PushBack( EGL_RENDERABLE_TYPE );
+ configAttribs.PushBack(EGL_RENDERABLE_TYPE);
- if( mGlesVersion >= 30 )
+ if(mGlesVersion >= 30)
{
- configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
+ configAttribs.PushBack(EGL_OPENGL_ES3_BIT_KHR);
}
else
{
- configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
+ configAttribs.PushBack(EGL_OPENGL_ES2_BIT);
}
-// TODO: enable this flag when it becomes supported
-// configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
-// configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
+ // TODO: enable this flag when it becomes supported
+ // configAttribs.PushBack( EGL_CONTEXT_FLAGS_KHR );
+ // configAttribs.PushBack( EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR );
- configAttribs.PushBack( EGL_RED_SIZE );
- configAttribs.PushBack( 8 );
- configAttribs.PushBack( EGL_GREEN_SIZE );
- configAttribs.PushBack( 8 );
- configAttribs.PushBack( EGL_BLUE_SIZE );
- configAttribs.PushBack( 8 );
+ configAttribs.PushBack(EGL_RED_SIZE);
+ configAttribs.PushBack(8);
+ configAttribs.PushBack(EGL_GREEN_SIZE);
+ configAttribs.PushBack(8);
+ configAttribs.PushBack(EGL_BLUE_SIZE);
+ configAttribs.PushBack(8);
-// For underlay video playback, we also need to set the alpha value of the 24/32bit window.
- configAttribs.PushBack( EGL_ALPHA_SIZE );
- configAttribs.PushBack( 8 );
+ // For underlay video playback, we also need to set the alpha value of the 24/32bit window.
+ configAttribs.PushBack(EGL_ALPHA_SIZE);
+ configAttribs.PushBack(8);
- configAttribs.PushBack( EGL_DEPTH_SIZE );
- configAttribs.PushBack( mDepthBufferRequired ? 24 : 0 );
- configAttribs.PushBack( EGL_STENCIL_SIZE );
- configAttribs.PushBack( mStencilBufferRequired ? 8 : 0 );
+ configAttribs.PushBack(EGL_DEPTH_SIZE);
+ configAttribs.PushBack(mDepthBufferRequired ? 24 : 0);
+ configAttribs.PushBack(EGL_STENCIL_SIZE);
+ configAttribs.PushBack(mStencilBufferRequired ? 8 : 0);
#ifndef DALI_PROFILE_UBUNTU
- if( mMultiSamplingLevel != EGL_DONT_CARE )
+ if(mMultiSamplingLevel != EGL_DONT_CARE)
{
- configAttribs.PushBack( EGL_SAMPLES );
- configAttribs.PushBack( mMultiSamplingLevel );
- configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
- configAttribs.PushBack( 1 );
+ configAttribs.PushBack(EGL_SAMPLES);
+ configAttribs.PushBack(mMultiSamplingLevel);
+ configAttribs.PushBack(EGL_SAMPLE_BUFFERS);
+ configAttribs.PushBack(1);
}
#endif // DALI_PROFILE_UBUNTU
- configAttribs.PushBack( EGL_NONE );
+ configAttribs.PushBack(EGL_NONE);
// Ensure number of configs is set to 1 as on some drivers,
// eglChooseConfig succeeds but does not actually create a proper configuration.
- if ( ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE ) ||
- ( numConfigs != 1 ) )
+ if((eglChooseConfig(mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs) != EGL_TRUE) ||
+ (numConfigs != 1))
{
- if( mGlesVersion >= 30 )
+ if(mGlesVersion >= 30)
{
mEglConfig = NULL;
DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
return false;
}
- if ( numConfigs != 1 )
+ if(numConfigs != 1)
{
DALI_LOG_ERROR("No configurations found.\n");
}
EGLint error = eglGetError();
- switch (error)
+ switch(error)
{
case EGL_BAD_DISPLAY:
{
DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
return false;
}
- Integration::Log::LogMessage(Integration::Log::DebugInfo, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10 );
+ Integration::Log::LogMessage(Integration::Log::DebugInfo, "Using OpenGL es %d.%d.\n", mGlesVersion / 10, mGlesVersion % 10);
mContextAttribs.Clear();
- if( mIsKhrCreateContextSupported )
+ if(mIsKhrCreateContextSupported)
{
mContextAttribs.Reserve(5);
- mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
- mContextAttribs.PushBack( mGlesVersion / 10 );
- mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR );
- mContextAttribs.PushBack( mGlesVersion % 10 );
+ mContextAttribs.PushBack(EGL_CONTEXT_MAJOR_VERSION_KHR);
+ mContextAttribs.PushBack(mGlesVersion / 10);
+ mContextAttribs.PushBack(EGL_CONTEXT_MINOR_VERSION_KHR);
+ mContextAttribs.PushBack(mGlesVersion % 10);
}
else
{
mContextAttribs.Reserve(3);
- mContextAttribs.PushBack( EGL_CONTEXT_CLIENT_VERSION );
- mContextAttribs.PushBack( mGlesVersion / 10 );
+ mContextAttribs.PushBack(EGL_CONTEXT_CLIENT_VERSION);
+ mContextAttribs.PushBack(mGlesVersion / 10);
}
- mContextAttribs.PushBack( EGL_NONE );
+ mContextAttribs.PushBack(EGL_NONE);
return true;
}
-EGLSurface EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth )
+EGLSurface EglImplementation::CreateSurfaceWindow(EGLNativeWindowType window, ColorDepth depth)
{
mEglNativeWindow = window;
- mColorDepth = depth;
- mIsWindow = true;
+ mColorDepth = depth;
+ mIsWindow = true;
// egl choose config
ChooseConfig(mIsWindow, mColorDepth);
- mCurrentEglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, mEglNativeWindow, NULL );
+ mCurrentEglSurface = eglCreateWindowSurface(mEglDisplay, mEglConfig, mEglNativeWindow, NULL);
TEST_EGL_ERROR("eglCreateWindowSurface");
- DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create window surface failed" );
+ DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create window surface failed");
return mCurrentEglSurface;
}
-EGLSurface EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth )
+EGLSurface EglImplementation::CreateSurfacePixmap(EGLNativePixmapType pixmap, ColorDepth depth)
{
mCurrentEglNativePixmap = pixmap;
- mColorDepth = depth;
- mIsWindow = false;
+ mColorDepth = depth;
+ mIsWindow = false;
// egl choose config
ChooseConfig(mIsWindow, mColorDepth);
- mCurrentEglSurface = eglCreatePixmapSurface( mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL );
+ mCurrentEglSurface = eglCreatePixmapSurface(mEglDisplay, mEglConfig, mCurrentEglNativePixmap, NULL);
TEST_EGL_ERROR("eglCreatePixmapSurface");
- DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create pixmap surface failed" );
+ DALI_ASSERT_ALWAYS(mCurrentEglSurface && "Create pixmap surface failed");
return mCurrentEglSurface;
}
-bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext )
+bool EglImplementation::ReplaceSurfaceWindow(EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext)
{
bool contextLost = false;
// the surface is bound to the context, so set the context to null
MakeContextNull();
- if( eglSurface )
+ if(eglSurface)
{
// destroy the surface
- DestroySurface( eglSurface );
+ DestroySurface(eglSurface);
}
// create the EGL surface
- EGLSurface newEglSurface = CreateSurfaceWindow( window, mColorDepth );
+ EGLSurface newEglSurface = CreateSurfaceWindow(window, mColorDepth);
// set the context to be current with the new surface
- MakeContextCurrent( newEglSurface, eglContext );
+ MakeContextCurrent(newEglSurface, eglContext);
return contextLost;
}
-bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface )
+bool EglImplementation::ReplaceSurfacePixmap(EGLNativePixmapType pixmap, EGLSurface& eglSurface)
{
bool contextLost = false;
// display connection has not changed, then we can just create a new surface
// create the EGL surface
- eglSurface = CreateSurfacePixmap( pixmap, mColorDepth );
+ eglSurface = CreateSurfacePixmap(pixmap, mColorDepth);
// set the eglSurface to be current
- MakeCurrent( pixmap, eglSurface );
+ MakeCurrent(pixmap, eglSurface);
return contextLost;
}
-void EglImplementation::SetGlesVersion( const int32_t glesVersion )
+void EglImplementation::SetGlesVersion(const int32_t glesVersion)
{
mGlesVersion = glesVersion;
}
void EglImplementation::WaitClient()
{
// Wait for EGL to finish executing all rendering calls for the current context
- if ( eglWaitClient() != EGL_TRUE )
+ if(eglWaitClient() != EGL_TRUE)
{
TEST_EGL_ERROR("eglWaitClient");
}
/*
- * Copyright (c) 2017 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.
#ifdef _ARCH_ARM_
+#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-#include <EGL/eglext.h>
#endif
#ifdef _ARCH_ARM_
// function pointers
-static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR = NULL;
+static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR = NULL;
static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR = NULL;
-static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR = NULL;
+static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR = NULL;
#endif
{
namespace Adaptor
{
-
#ifdef _ARCH_ARM_
-EglSyncObject::EglSyncObject( EglImplementation& eglSyncImpl )
+EglSyncObject::EglSyncObject(EglImplementation& eglSyncImpl)
: mEglSync(NULL),
mEglImplementation(eglSyncImpl)
{
EGLDisplay display = mEglImplementation.GetDisplay();
- mEglSync = eglCreateSyncKHR( display, EGL_SYNC_FENCE_KHR, NULL );
- if (mEglSync == EGL_NO_SYNC_KHR)
+ mEglSync = eglCreateSyncKHR(display, EGL_SYNC_FENCE_KHR, NULL);
+ if(mEglSync == EGL_NO_SYNC_KHR)
{
DALI_LOG_ERROR("eglCreateSyncKHR failed %#0.4x\n", eglGetError());
mEglSync = NULL;
EglSyncObject::~EglSyncObject()
{
- if( mEglSync != NULL )
+ if(mEglSync != NULL)
{
- eglDestroySyncKHR( mEglImplementation.GetDisplay(), mEglSync );
+ eglDestroySyncKHR(mEglImplementation.GetDisplay(), mEglSync);
EGLint error = eglGetError();
- if( EGL_SUCCESS != error )
+ if(EGL_SUCCESS != error)
{
DALI_LOG_ERROR("eglDestroySyncKHR failed %#0.4x\n", error);
}
{
bool synced = false;
- if( mEglSync != NULL )
+ if(mEglSync != NULL)
{
- EGLint result = eglClientWaitSyncKHR( mEglImplementation.GetDisplay(), mEglSync, 0, 0ull );
- EGLint error = eglGetError();
- if( EGL_SUCCESS != error )
+ EGLint result = eglClientWaitSyncKHR(mEglImplementation.GetDisplay(), mEglSync, 0, 0ull);
+ EGLint error = eglGetError();
+ if(EGL_SUCCESS != error)
{
DALI_LOG_ERROR("eglClientWaitSyncKHR failed %#0.4x\n", error);
}
- else if( result == EGL_CONDITION_SATISFIED_KHR )
+ else if(result == EGL_CONDITION_SATISFIED_KHR)
{
synced = true;
}
}
EglSyncImplementation::EglSyncImplementation()
-: mEglImplementation( NULL ),
- mSyncInitialized( false ),
- mSyncInitializeFailed( false )
+: mEglImplementation(NULL),
+ mSyncInitialized(false),
+ mSyncInitializeFailed(false)
{
}
{
}
-void EglSyncImplementation::Initialize( EglImplementation* eglImpl )
+void EglSyncImplementation::Initialize(EglImplementation* eglImpl)
{
mEglImplementation = eglImpl;
}
Integration::GlSyncAbstraction::SyncObject* EglSyncImplementation::CreateSyncObject()
{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
- if( mSyncInitialized == false )
+ DALI_ASSERT_ALWAYS(mEglImplementation && "Sync Implementation not initialized");
+ if(mSyncInitialized == false)
{
InitializeEglSync();
}
EglSyncObject* syncObject = new EglSyncObject(*mEglImplementation);
- mSyncObjects.PushBack( syncObject );
+ mSyncObjects.PushBack(syncObject);
return syncObject;
}
-void EglSyncImplementation::DestroySyncObject( Integration::GlSyncAbstraction::SyncObject* syncObject )
+void EglSyncImplementation::DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject)
{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+ DALI_ASSERT_ALWAYS(mEglImplementation && "Sync Implementation not initialized");
- if( mSyncInitialized == false )
+ if(mSyncInitialized == false)
{
InitializeEglSync();
}
- for( SyncIter iter=mSyncObjects.Begin(), end=mSyncObjects.End(); iter != end; ++iter )
+ for(SyncIter iter = mSyncObjects.Begin(), end = mSyncObjects.End(); iter != end; ++iter)
{
- if( *iter == syncObject )
+ if(*iter == syncObject)
{
mSyncObjects.Erase(iter);
break;
void EglSyncImplementation::InitializeEglSync()
{
- if( ! mSyncInitializeFailed )
+ if(!mSyncInitializeFailed)
{
- eglCreateSyncKHR = reinterpret_cast< PFNEGLCREATESYNCKHRPROC >( eglGetProcAddress("eglCreateSyncKHR") );
- eglClientWaitSyncKHR = reinterpret_cast< PFNEGLCLIENTWAITSYNCKHRPROC >( eglGetProcAddress("eglClientWaitSyncKHR") );
- eglDestroySyncKHR = reinterpret_cast< PFNEGLDESTROYSYNCKHRPROC >( eglGetProcAddress("eglDestroySyncKHR") );
+ eglCreateSyncKHR = reinterpret_cast<PFNEGLCREATESYNCKHRPROC>(eglGetProcAddress("eglCreateSyncKHR"));
+ eglClientWaitSyncKHR = reinterpret_cast<PFNEGLCLIENTWAITSYNCKHRPROC>(eglGetProcAddress("eglClientWaitSyncKHR"));
+ eglDestroySyncKHR = reinterpret_cast<PFNEGLDESTROYSYNCKHRPROC>(eglGetProcAddress("eglDestroySyncKHR"));
}
- if( eglCreateSyncKHR && eglClientWaitSyncKHR && eglDestroySyncKHR )
+ if(eglCreateSyncKHR && eglClientWaitSyncKHR && eglDestroySyncKHR)
{
mSyncInitialized = true;
}
#else
-EglSyncObject::EglSyncObject( EglImplementation& eglImpl )
+EglSyncObject::EglSyncObject(EglImplementation& eglImpl)
: mPollCounter(3),
mEglImplementation(eglImpl)
{
}
EglSyncImplementation::EglSyncImplementation()
-: mEglImplementation( NULL ),
- mSyncInitialized( false ),
- mSyncInitializeFailed( false )
+: mEglImplementation(NULL),
+ mSyncInitialized(false),
+ mSyncInitializeFailed(false)
{
}
{
}
-void EglSyncImplementation::Initialize( EglImplementation* eglImpl )
+void EglSyncImplementation::Initialize(EglImplementation* eglImpl)
{
mEglImplementation = eglImpl;
}
Integration::GlSyncAbstraction::SyncObject* EglSyncImplementation::CreateSyncObject()
{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+ DALI_ASSERT_ALWAYS(mEglImplementation && "Sync Implementation not initialized");
return new EglSyncObject(*mEglImplementation);
}
void EglSyncImplementation::DestroySyncObject(Integration::GlSyncAbstraction::SyncObject* syncObject)
{
- DALI_ASSERT_ALWAYS( mEglImplementation && "Sync Implementation not initialized" );
+ DALI_ASSERT_ALWAYS(mEglImplementation && "Sync Implementation not initialized");
// The abstraction's virtual destructor is protected, so that Core can't delete the sync objects
// directly (This object also needs removing from the mSyncObject container in the ARM
#endif
-} // namespace Dali
-} // namespace Internal
} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
GlExtensions::GlExtensions()
:
#ifdef GL_EXT_discard_framebuffer
- mGlDiscardFramebuffer( nullptr ),
+ mGlDiscardFramebuffer(nullptr),
#endif
#ifdef GL_OES_get_program_binary
- mGlGetProgramBinaryOES( nullptr ),
- mGlProgramBinaryOES( nullptr ),
+ mGlGetProgramBinaryOES(nullptr),
+ mGlProgramBinaryOES(nullptr),
#endif
#ifdef GL_KHR_blend_equation_advanced
- mBlendBarrierKHR( nullptr ),
+ mBlendBarrierKHR(nullptr),
#endif
- mInitialized( false )
+ mInitialized(false)
{
}
{
}
-void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments)
+void GlExtensions::DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
{
// initialize extension on first use as on some hw platforms a context
// has to be bound for the extensions to return correct pointer
- if( !mInitialized )
+ if(!mInitialized)
{
Initialize();
}
#ifdef GL_EXT_discard_framebuffer
- if( mGlDiscardFramebuffer )
+ if(mGlDiscardFramebuffer)
{
mGlDiscardFramebuffer(target, numAttachments, attachments);
}
#endif
}
-void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
+void GlExtensions::GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
{
// initialize extension on first use as on some hw platforms a context
// has to be bound for the extensions to return correct pointer
- if( !mInitialized )
+ if(!mInitialized)
{
Initialize();
}
#ifdef GL_OES_get_program_binary
- if (mGlGetProgramBinaryOES)
+ if(mGlGetProgramBinaryOES)
{
mGlGetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
}
#endif
}
-void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
+void GlExtensions::ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length)
{
// initialize extension on first use as on some hw platforms a context
// has to be bound for the extensions to return correct pointer
- if( !mInitialized )
+ if(!mInitialized)
{
Initialize();
}
#ifdef GL_OES_get_program_binary
- if (mGlProgramBinaryOES)
+ if(mGlProgramBinaryOES)
{
mGlProgramBinaryOES(program, binaryFormat, binary, length);
}
{
// initialize extension on first use as on some hw platforms a context
// has to be bound for the extensions to return correct pointer
- if( !mInitialized )
+ if(!mInitialized)
{
Initialize();
}
#ifdef GL_KHR_blend_equation_advanced
- if (mBlendBarrierKHR)
+ if(mBlendBarrierKHR)
{
mBlendBarrierKHR();
return true;
mInitialized = true;
#ifdef GL_EXT_discard_framebuffer
- mGlDiscardFramebuffer = reinterpret_cast< PFNGLDISCARDFRAMEBUFFEREXTPROC >( eglGetProcAddress("glDiscardFramebufferEXT") );
+ mGlDiscardFramebuffer = reinterpret_cast<PFNGLDISCARDFRAMEBUFFEREXTPROC>(eglGetProcAddress("glDiscardFramebufferEXT"));
#endif
#ifdef GL_OES_get_program_binary
- mGlGetProgramBinaryOES = reinterpret_cast< PFNGLGETPROGRAMBINARYOESPROC >( eglGetProcAddress("glGetProgramBinaryOES") );
- mGlProgramBinaryOES = reinterpret_cast< PFNGLPROGRAMBINARYOESPROC >( eglGetProcAddress("glProgramBinaryOES") );
+ mGlGetProgramBinaryOES = reinterpret_cast<PFNGLGETPROGRAMBINARYOESPROC>(eglGetProcAddress("glGetProgramBinaryOES"));
+ mGlProgramBinaryOES = reinterpret_cast<PFNGLPROGRAMBINARYOESPROC>(eglGetProcAddress("glProgramBinaryOES"));
#endif
#ifdef GL_KHR_blend_equation_advanced
- mBlendBarrierKHR = reinterpret_cast< PFNGLBLENDBARRIERKHRPROC >( eglGetProcAddress("glBlendBarrierKHR") );
+ mBlendBarrierKHR = reinterpret_cast<PFNGLBLENDBARRIERKHRPROC>(eglGetProcAddress("glBlendBarrierKHR"));
#endif
}
/*
- * 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.
*
*/
-
// CLASS HEADER
#include <dali/internal/graphics/common/egl-image-extensions.h>
namespace Dali::Internal::Adaptor
{
-
EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
: mEglImplementation(eglImpl),
mImageKHRInitialized(false),
mImageKHRInitializeFailed(false)
{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+ DALI_ASSERT_ALWAYS(eglImpl && "EGL Implementation not instantiated");
}
EglImageExtensions::~EglImageExtensions()
/*
- * Copyright (c) 2019 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.
*
*/
-
// CLASS HEADER
#include <dali/internal/graphics/common/egl-image-extensions.h>
namespace
{
// function pointers assigned in InitializeEglImageKHR
-PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
-PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
+PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0;
+PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0;
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESProc = 0;
} // unnamed namespace
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
: mEglImplementation(eglImpl),
mImageKHRInitialized(false),
mImageKHRInitializeFailed(false)
{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+ DALI_ASSERT_ALWAYS(eglImpl && "EGL Implementation not instantiated");
}
EglImageExtensions::~EglImageExtensions()
void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
{
- if (mImageKHRInitialized == false)
+ if(mImageKHRInitialized == false)
{
InitializeEglImageKHR();
}
- if (mImageKHRInitialized == false)
+ if(mImageKHRInitialized == false)
{
return NULL;
}
// Use the EGL image extension
const EGLint attribs[] =
- {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
- };
+ {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = eglCreateImageKHRProc( mEglImplementation->GetDisplay(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_SURFACE_TIZEN,
- clientBuffer,
- attribs );
+ EGLImageKHR eglImage = eglCreateImageKHRProc(mEglImplementation->GetDisplay(),
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_SURFACE_TIZEN,
+ clientBuffer,
+ attribs);
- if( EGL_NO_IMAGE_KHR == eglImage )
+ if(EGL_NO_IMAGE_KHR == eglImage)
{
- switch( eglGetError() )
+ switch(eglGetError())
{
- case EGL_SUCCESS :
+ case EGL_SUCCESS:
{
break;
}
case EGL_BAD_DISPLAY:
{
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY: Invalid EGLDisplay object\n");
break;
}
case EGL_BAD_CONTEXT:
{
- DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object\n" );
+ DALI_LOG_ERROR("EGL_BAD_CONTEXT: Invalid EGLContext object\n");
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n");
break;
}
case EGL_BAD_MATCH:
{
- DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target\n" );
+ DALI_LOG_ERROR("EGL_BAD_MATCH: attrib_list does not match target\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n");
break;
}
case EGL_BAD_ALLOC:
{
- DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" );
+ DALI_LOG_ERROR("EGL_BAD_ALLOC: Insufficient memory is available\n");
break;
}
default:
}
}
}
- DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "EglImageExtensions::CreateImageKHR: eglCreateImageKHR failed!\n");
+ DALI_ASSERT_DEBUG(EGL_NO_IMAGE_KHR != eglImage && "EglImageExtensions::CreateImageKHR: eglCreateImageKHR failed!\n");
return eglImage;
}
void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
+ DALI_ASSERT_DEBUG(mImageKHRInitialized);
- if( ! mImageKHRInitialized )
+ if(!mImageKHRInitialized)
{
return;
}
- if( eglImageKHR == NULL )
+ if(eglImageKHR == NULL)
{
return;
}
EGLBoolean result = eglDestroyImageKHRProc(mEglImplementation->GetDisplay(), eglImage);
- if( EGL_FALSE == result )
+ if(EGL_FALSE == result)
{
- switch( eglGetError() )
+ switch(eglGetError())
{
case EGL_BAD_DISPLAY:
{
- DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" );
+ DALI_LOG_ERROR("EGL_BAD_DISPLAY: Invalid EGLDisplay object\n");
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: EGLImage sibling error\n");
break;
}
default:
void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
{
- DALI_ASSERT_DEBUG( mImageKHRInitialized );
+ DALI_ASSERT_DEBUG(mImageKHRInitialized);
- if( eglImageKHR != NULL )
+ if(eglImageKHR != NULL)
{
EGLImageKHR eglImage = static_cast<EGLImageKHR>(eglImageKHR);
GLint glError = glGetError();
#endif
- glEGLImageTargetTexture2DOESProc(GL_TEXTURE_EXTERNAL_OES, reinterpret_cast< GLeglImageOES >( eglImage ) );
+ glEGLImageTargetTexture2DOESProc(GL_TEXTURE_EXTERNAL_OES, reinterpret_cast<GLeglImageOES>(eglImage));
#ifdef EGL_ERROR_CHECKING
glError = glGetError();
- if( GL_NO_ERROR != glError )
+ if(GL_NO_ERROR != glError)
{
- DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError );
+ DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError);
}
#endif
}
void EglImageExtensions::InitializeEglImageKHR()
{
// avoid trying to reload extended KHR functions, if it fails the first time
- if( ! mImageKHRInitializeFailed )
+ if(!mImageKHRInitializeFailed)
{
- eglCreateImageKHRProc = reinterpret_cast< PFNEGLCREATEIMAGEKHRPROC >( eglGetProcAddress("eglCreateImageKHR") );
- eglDestroyImageKHRProc = reinterpret_cast< PFNEGLDESTROYIMAGEKHRPROC >( eglGetProcAddress("eglDestroyImageKHR") );
- glEGLImageTargetTexture2DOESProc = reinterpret_cast< PFNGLEGLIMAGETARGETTEXTURE2DOESPROC >( eglGetProcAddress("glEGLImageTargetTexture2DOES") );
+ eglCreateImageKHRProc = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>(eglGetProcAddress("eglCreateImageKHR"));
+ eglDestroyImageKHRProc = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(eglGetProcAddress("eglDestroyImageKHR"));
+ glEGLImageTargetTexture2DOESProc = reinterpret_cast<PFNGLEGLIMAGETARGETTEXTURE2DOESPROC>(eglGetProcAddress("glEGLImageTargetTexture2DOES"));
}
- if (eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
+ if(eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc)
{
mImageKHRInitialized = true;
}
/*
- * Copyright (c) 2018 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.
*
*/
-
// CLASS HEADER
#include <dali/internal/graphics/common/egl-image-extensions.h>
// INTERNAL INCLUDES
#include <dali/internal/graphics/gles/egl-implementation.h>
-
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
: mEglImplementation(eglImpl),
mImageKHRInitialized(false),
mImageKHRInitializeFailed(false)
{
- DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+ DALI_ASSERT_ALWAYS(eglImpl && "EGL Implementation not instantiated");
}
EglImageExtensions::~EglImageExtensions()
/*
- * Copyright (c) 2019 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.
#include <dali/internal/haptics/common/feedback-player-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-
// Type Registration
Dali::BaseHandle Create()
{
return FeedbackPlayer::Get();
}
-Dali::TypeRegistration FEEDBACK_PLAYER_TYPE( typeid(Dali::FeedbackPlayer), typeid(Dali::BaseHandle), Create );
+Dali::TypeRegistration FEEDBACK_PLAYER_TYPE(typeid(Dali::FeedbackPlayer), typeid(Dali::BaseHandle), Create);
} // unnamed namespace
Dali::FeedbackPlayer FeedbackPlayer::New()
{
- Dali::FeedbackPlayer player = Dali::FeedbackPlayer( new FeedbackPlayer() );
+ Dali::FeedbackPlayer player = Dali::FeedbackPlayer(new FeedbackPlayer());
return player;
}
{
Dali::FeedbackPlayer player;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::FeedbackPlayer ) );
- if ( handle )
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::FeedbackPlayer));
+ if(handle)
{
// If so, downcast the handle
- player = Dali::FeedbackPlayer( dynamic_cast< FeedbackPlayer* >( handle.GetObjectPtr() ) );
+ player = Dali::FeedbackPlayer(dynamic_cast<FeedbackPlayer*>(handle.GetObjectPtr()));
}
else
{
- player = Dali::FeedbackPlayer( New() );
- service.Register( typeid( player ), player );
+ player = Dali::FeedbackPlayer(New());
+ service.Register(typeid(player), player);
}
}
return player;
}
-void FeedbackPlayer::PlayMonotone( unsigned int duration )
+void FeedbackPlayer::PlayMonotone(unsigned int duration)
{
- mPlugin.PlayHapticMonotone( duration );
+ mPlugin.PlayHapticMonotone(duration);
}
-void FeedbackPlayer::PlayFile( const std::string& filePath )
+void FeedbackPlayer::PlayFile(const std::string& filePath)
{
- mPlugin.PlayHaptic( filePath );
+ mPlugin.PlayHaptic(filePath);
}
void FeedbackPlayer::Stop()
mPlugin.StopHaptic();
}
-int FeedbackPlayer::PlaySound( const std::string& filename )
+int FeedbackPlayer::PlaySound(const std::string& filename)
{
return mPlugin.PlaySound(filename);
}
-void FeedbackPlayer::StopSound( int handle )
+void FeedbackPlayer::StopSound(int handle)
{
mPlugin.StopSound(handle);
}
-void FeedbackPlayer::PlayFeedbackPattern( int type, int pattern )
+void FeedbackPlayer::PlayFeedbackPattern(int type, int pattern)
{
mPlugin.PlayFeedbackPattern(type, pattern);
}
{
bool loaded = false;
- std::streampos bufferSize = 0;
+ std::streampos bufferSize = 0;
Dali::Vector<char> fileBuffer;
- if( Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::TEXT ) )
+ if(Dali::FileLoader::ReadFile(filename, bufferSize, fileBuffer, FileLoader::FileType::TEXT))
{
- data.assign( &fileBuffer[0], bufferSize );
+ data.assign(&fileBuffer[0], bufferSize);
loaded = true;
}
}
FeedbackPlayer::FeedbackPlayer()
-: mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
+: mPlugin(FeedbackPluginProxy::DEFAULT_OBJECT_NAME)
{
}
#include <dali/internal/haptics/common/feedback-plugin-proxy.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
#include <dali/integration-api/debug.h>
+#include <dlfcn.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-const char * const FeedbackPluginProxy::DEFAULT_OBJECT_NAME( "libdali2-feedback-plugin.so" );
-
-FeedbackPluginProxy::FeedbackPluginProxy( const std::string& sharedObjectName )
-: mInitializeAttempted( false ),
- mLibHandle( NULL ),
- mSharedObjectName( sharedObjectName ),
- mCreatePluginFunctionPtr( NULL ),
- mFeedbackPlugin( NULL )
+const char* const FeedbackPluginProxy::DEFAULT_OBJECT_NAME("libdali2-feedback-plugin.so");
+
+FeedbackPluginProxy::FeedbackPluginProxy(const std::string& sharedObjectName)
+: mInitializeAttempted(false),
+ mLibHandle(NULL),
+ mSharedObjectName(sharedObjectName),
+ mCreatePluginFunctionPtr(NULL),
+ mFeedbackPlugin(NULL)
{
// Lazily initialize when sound/haptic is first played
}
FeedbackPluginProxy::~FeedbackPluginProxy()
{
- if( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
delete mFeedbackPlugin;
mFeedbackPlugin = NULL;
- if( mLibHandle && dlclose( mLibHandle ) )
+ if(mLibHandle && dlclose(mLibHandle))
{
- DALI_LOG_ERROR( "Error closing dali feedback plugin library: %s\n", dlerror() );
+ DALI_LOG_ERROR("Error closing dali feedback plugin library: %s\n", dlerror());
}
}
}
-void FeedbackPluginProxy::PlayHaptic( const std::string& filePath )
+void FeedbackPluginProxy::PlayHaptic(const std::string& filePath)
{
// Lazy initialization
Initialize();
- if( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
- mFeedbackPlugin->PlayHaptic( filePath );
+ mFeedbackPlugin->PlayHaptic(filePath);
}
}
-void FeedbackPluginProxy::PlayHapticMonotone( unsigned int duration )
+void FeedbackPluginProxy::PlayHapticMonotone(unsigned int duration)
{
// Lazy initialization
Initialize();
- if( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
- mFeedbackPlugin->PlayHapticMonotone( duration );
+ mFeedbackPlugin->PlayHapticMonotone(duration);
}
}
void FeedbackPluginProxy::StopHaptic()
{
// Must already have been initialized to play haptic
- if( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
mFeedbackPlugin->StopHaptic();
}
}
-int FeedbackPluginProxy::PlaySound( const std::string& fileName )
+int FeedbackPluginProxy::PlaySound(const std::string& fileName)
{
// Lazy initialization
Initialize();
- if( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
- return mFeedbackPlugin->PlaySound( fileName );
+ return mFeedbackPlugin->PlaySound(fileName);
}
return 0;
}
-void FeedbackPluginProxy::StopSound( int handle )
+void FeedbackPluginProxy::StopSound(int handle)
{
// Must already have been initialized to play sound
- if ( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
- mFeedbackPlugin->StopSound( handle );
+ mFeedbackPlugin->StopSound(handle);
}
}
-void FeedbackPluginProxy::PlayFeedbackPattern( int type, int pattern )
+void FeedbackPluginProxy::PlayFeedbackPattern(int type, int pattern)
{
// Lazy initialization
Initialize();
- if( mFeedbackPlugin )
+ if(mFeedbackPlugin)
{
- mFeedbackPlugin->PlayFeedbackPattern( type, pattern );
+ mFeedbackPlugin->PlayFeedbackPattern(type, pattern);
}
}
void FeedbackPluginProxy::Initialize()
{
// Only attempt to load dll once
- if ( !mInitializeAttempted )
+ if(!mInitializeAttempted)
{
mInitializeAttempted = true;
- mLibHandle = dlopen( mSharedObjectName.c_str(), RTLD_NOW | RTLD_GLOBAL );
- if( !mLibHandle )
+ mLibHandle = dlopen(mSharedObjectName.c_str(), RTLD_NOW | RTLD_GLOBAL);
+ if(!mLibHandle)
{
- DALI_LOG_ERROR( "Cannot load dali feedback plugin library error: %s\n", dlerror() );
+ DALI_LOG_ERROR("Cannot load dali feedback plugin library error: %s\n", dlerror());
return;
}
/*
- * Copyright (c) 2019 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.
{
namespace Adaptor
{
-
-std::unique_ptr< NativeImageSource > NativeImageSourceFactoryAndroid::CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+std::unique_ptr<NativeImageSource> NativeImageSourceFactoryAndroid::CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- return std::unique_ptr< NativeImageSource >( NativeImageSourceAndroid::New( width, height, depth, nativeImageSource ) );
+ return std::unique_ptr<NativeImageSource>(NativeImageSourceAndroid::New(width, height, depth, nativeImageSource));
}
-std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryAndroid::CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+std::unique_ptr<NativeImageSourceQueue> NativeImageSourceFactoryAndroid::CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- return std::unique_ptr< NativeImageSourceQueue >( NativeImageSourceQueueAndroid::New( width, height, depth, nativeImageSourceQueue ) );
+ return std::unique_ptr<NativeImageSourceQueue>(NativeImageSourceQueueAndroid::New(width, height, depth, nativeImageSourceQueue));
}
// this should be created from somewhere
-std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
{
// returns native image source factory
- return std::unique_ptr< NativeImageSourceFactoryAndroid >( new NativeImageSourceFactoryAndroid() );
+ return std::unique_ptr<NativeImageSourceFactoryAndroid>(new NativeImageSourceFactoryAndroid());
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
// EXTERNAL INCLUDES
#include <EGL/egl.h>
-#include <include/EGL/eglext.h>
#include <dali/integration-api/debug.h>
+#include <include/EGL/eglext.h>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-
namespace
{
const char* FRAGMENT_PREFIX = "#extension GL_OES_EGL_image_external:require\n";
-const char* SAMPLER_TYPE = "samplerExternalOES";
-}
-
+const char* SAMPLER_TYPE = "samplerExternalOES";
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
using Dali::Integration::PixelBuffer;
-NativeImageSourceAndroid* NativeImageSourceAndroid::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceAndroid* NativeImageSourceAndroid::New(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- NativeImageSourceAndroid* image = new NativeImageSourceAndroid( width, height, depth, nativeImageSource );
- DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
+ NativeImageSourceAndroid* image = new NativeImageSourceAndroid(width, height, depth, nativeImageSource);
+ DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed.");
// 2nd phase construction
- if( image ) //< Defensive in case we ever compile without exceptions.
+ if(image) //< Defensive in case we ever compile without exceptions.
{
image->Initialize();
}
return image;
}
-NativeImageSourceAndroid::NativeImageSourceAndroid( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
- mHeight( height ),
- mOwnPixmap( true ),
- mPixmap( NULL ),
- mBlendingRequired( false ),
- mColorDepth( depth ),
- mEglImageKHR( NULL ),
- mEglImageExtensions( NULL )
+NativeImageSourceAndroid::NativeImageSourceAndroid(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+: mWidth(width),
+ mHeight(height),
+ mOwnPixmap(true),
+ mPixmap(NULL),
+ mBlendingRequired(false),
+ mColorDepth(depth),
+ mEglImageKHR(NULL),
+ mEglImageExtensions(NULL)
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- auto eglGraphics = static_cast<EglGraphics*>( graphics );
+ GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ auto eglGraphics = static_cast<EglGraphics*>(graphics);
mEglImageExtensions = eglGraphics->GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
// assign the pixmap
- mPixmap = static_cast<AHardwareBuffer*>( GetPixmapFromAny( nativeImageSource ) );
- if( !mPixmap )
+ mPixmap = static_cast<AHardwareBuffer*>(GetPixmapFromAny(nativeImageSource));
+ if(!mPixmap)
{
AHardwareBuffer_Desc bufferDescription;
- memset( &bufferDescription, 0, sizeof( AHardwareBuffer_Desc ) );
- bufferDescription.width = width;
+ memset(&bufferDescription, 0, sizeof(AHardwareBuffer_Desc));
+ bufferDescription.width = width;
bufferDescription.height = height;
bufferDescription.layers = 1;
- bufferDescription.usage = AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
- switch( mColorDepth )
+ bufferDescription.usage = AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN | AHARDWAREBUFFER_USAGE_CPU_READ_RARELY | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
+ switch(mColorDepth)
{
case Dali::NativeImageSource::COLOR_DEPTH_32:
case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
break;
}
- int ret = AHardwareBuffer_allocate( &bufferDescription, &mPixmap );
- if( ret )
+ int ret = AHardwareBuffer_allocate(&bufferDescription, &mPixmap);
+ if(ret)
{
DALI_LOG_ERROR("Failed to allocate AHardwareBuffer %d", ret);
}
void NativeImageSourceAndroid::Initialize()
{
- if( mPixmap && !mOwnPixmap )
+ if(mPixmap && !mOwnPixmap)
{
- AHardwareBuffer_acquire( mPixmap ) ;
+ AHardwareBuffer_acquire(mPixmap);
// find out the pixmap width / height and color depth
GetPixmapDetails();
NativeImageSourceAndroid::~NativeImageSourceAndroid()
{
- AHardwareBuffer_release( mPixmap );
+ AHardwareBuffer_release(mPixmap);
mPixmap = NULL;
}
Any NativeImageSourceAndroid::GetNativeImageSource() const
{
- return Any( mPixmap );
+ return Any(mPixmap);
}
bool NativeImageSourceAndroid::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
{
- DALI_ASSERT_DEBUG( sizeof(unsigned) == 4 );
+ DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
bool success = false;
width = mWidth;
height = mHeight;
AHardwareBuffer_Desc bufferDescription;
- memset( &bufferDescription, 0, sizeof( AHardwareBuffer_Desc ) );
- AHardwareBuffer_describe( mPixmap, &bufferDescription );
- switch( bufferDescription.format )
+ memset(&bufferDescription, 0, sizeof(AHardwareBuffer_Desc));
+ AHardwareBuffer_describe(mPixmap, &bufferDescription);
+ switch(bufferDescription.format)
{
case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
pixelFormat = Pixel::Format::RGBA8888;
}
void* buffer = NULL;
- int ret = AHardwareBuffer_lock( mPixmap, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL, &buffer );
- if( ret != 0 )
+ int ret = AHardwareBuffer_lock(mPixmap, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL, &buffer);
+ if(ret != 0)
{
DALI_LOG_ERROR("Failed to AHardwareBuffer_lock %d", ret);
return success;
}
uint32_t pixelBytes = GetBytesPerPixel(pixelFormat);
- if ( bufferDescription.stride < (pixelBytes * bufferDescription.width) )
+ if(bufferDescription.stride < (pixelBytes * bufferDescription.width))
{
//On Android device, bufferDescription.stride doesn't seem to mean (width * pixelbytes)
//in an actual case, (AHardwareBuffer_Desc) bufferDescription = (width = 1080, height = 1060, layers = 1, format = 1, usage = 306, stride = 1088, rfu0 = 0, rfu1 = 0)
//deal with situation
uint32_t dstStride = pixelBytes * bufferDescription.width;
uint32_t srcStride = pixelBytes * bufferDescription.stride;
- uint32_t size = dstStride * bufferDescription.height;
- pixbuf.resize( size );
+ uint32_t size = dstStride * bufferDescription.height;
+ pixbuf.resize(size);
//copy each row over
const unsigned char* ptrSrc = reinterpret_cast<const unsigned char*>(buffer);
- unsigned char* ptrDst = pixbuf.data();
- for (int y=0; y < bufferDescription.height; y++, ptrSrc += srcStride, ptrDst += dstStride )
+ unsigned char* ptrDst = pixbuf.data();
+ for(int y = 0; y < bufferDescription.height; y++, ptrSrc += srcStride, ptrDst += dstStride)
{
- memcpy( ptrDst, ptrSrc, dstStride );
+ memcpy(ptrDst, ptrSrc, dstStride);
}
}
else
{
uint32_t size = bufferDescription.stride * bufferDescription.height;
- pixbuf.resize( size );
- memcpy( pixbuf.data(), buffer, size );
+ pixbuf.resize(size);
+ memcpy(pixbuf.data(), buffer, size);
}
- ret = AHardwareBuffer_unlock( mPixmap, NULL );
- if( ret != 0 )
+ ret = AHardwareBuffer_unlock(mPixmap, NULL);
+ if(ret != 0)
{
DALI_LOG_ERROR("failed to AHardwareBuffer_unlock %d", ret);
return success;
return success;
}
-void NativeImageSourceAndroid::SetSource( Any source )
+void NativeImageSourceAndroid::SetSource(Any source)
{
- if( mPixmap )
+ if(mPixmap)
{
mOwnPixmap = false;
- AHardwareBuffer_release( mPixmap );
+ AHardwareBuffer_release(mPixmap);
mPixmap = NULL;
}
- mPixmap = static_cast<AHardwareBuffer*>( GetPixmapFromAny( source ) );
+ mPixmap = static_cast<AHardwareBuffer*>(GetPixmapFromAny(source));
- if( mPixmap )
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
}
}
-bool NativeImageSourceAndroid::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceAndroid::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
{
return true;
}
bool NativeImageSourceAndroid::CreateResource()
{
// if the image existed previously delete it.
- if( mEglImageKHR != NULL )
+ if(mEglImageKHR != NULL)
{
DestroyResource();
}
- DALI_ASSERT_ALWAYS( mPixmap );
- EGLClientBuffer eglBuffer = eglGetNativeClientBufferANDROID( mPixmap );
- switch( eglGetError() )
+ DALI_ASSERT_ALWAYS(mPixmap);
+ EGLClientBuffer eglBuffer = eglGetNativeClientBufferANDROID(mPixmap);
+ switch(eglGetError())
{
- case EGL_SUCCESS :
+ case EGL_SUCCESS:
{
break;
}
case EGL_BAD_PARAMETER:
{
- DALI_LOG_ERROR( "EGL_BAD_PARAMETER: bad pixmap parameter\n" );
+ DALI_LOG_ERROR("EGL_BAD_PARAMETER: bad pixmap parameter\n");
break;
}
case EGL_BAD_ACCESS:
{
- DALI_LOG_ERROR( "EGL_BAD_ACCESS: bad access to pixmap\n" );
+ DALI_LOG_ERROR("EGL_BAD_ACCESS: bad access to pixmap\n");
break;
}
case EGL_BAD_ALLOC:
{
- DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" );
+ DALI_LOG_ERROR("EGL_BAD_ALLOC: Insufficient memory is available\n");
break;
}
default:
{
- DALI_LOG_ERROR( "eglGetNativeClientBufferANDROID error\n" );
+ DALI_LOG_ERROR("eglGetNativeClientBufferANDROID error\n");
break;
}
}
- DALI_ASSERT_ALWAYS( eglBuffer );
- mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
+ DALI_ASSERT_ALWAYS(eglBuffer);
+ mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
return mEglImageKHR != NULL;
}
void NativeImageSourceAndroid::DestroyResource()
{
- mEglImageExtensions->DestroyImageKHR( mEglImageKHR );
+ mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
}
uint32_t NativeImageSourceAndroid::TargetTexture()
{
- mEglImageExtensions->TargetTextureKHR( mEglImageKHR );
+ mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
return 0;
}
return nullptr;
}
-
void* NativeImageSourceAndroid::GetPixmapFromAny(Any pixmap) const
{
- if( pixmap.Empty() )
+ if(pixmap.Empty())
{
return 0;
}
- return AnyCast<void*>( pixmap );
+ return AnyCast<void*>(pixmap);
}
void NativeImageSourceAndroid::GetPixmapDetails()
mBlendingRequired = false;
AHardwareBuffer_Desc bufferDescription;
- memset( &bufferDescription, 0, sizeof( AHardwareBuffer_Desc ) );
- AHardwareBuffer_describe( mPixmap, &bufferDescription );
+ memset(&bufferDescription, 0, sizeof(AHardwareBuffer_Desc));
+ AHardwareBuffer_describe(mPixmap, &bufferDescription);
- mWidth = bufferDescription.width;
+ mWidth = bufferDescription.width;
mHeight = bufferDescription.height;
- switch (bufferDescription.format)
+ switch(bufferDescription.format)
{
- case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
- mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_32;
- break;
- case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
- mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_24;
- break;
- case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
- mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_16;
- break;
- case AHARDWAREBUFFER_FORMAT_BLOB:
- default:
- mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_8;
+ case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
+ mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_32;
+ break;
+ case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
+ mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_24;
+ break;
+ case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
+ mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_16;
+ break;
+ case AHARDWAREBUFFER_FORMAT_BLOB:
+ default:
+ mColorDepth = Dali::NativeImageSource::COLOR_DEPTH_8;
}
}
-uint8_t* NativeImageSourceAndroid::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+uint8_t* NativeImageSourceAndroid::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
{
- if( mPixmap )
+ if(mPixmap)
{
AHardwareBuffer_Desc bufferDescription;
- memset( &bufferDescription, 0, sizeof( AHardwareBuffer_Desc ) );
- AHardwareBuffer_describe( mPixmap, &bufferDescription );
+ memset(&bufferDescription, 0, sizeof(AHardwareBuffer_Desc));
+ AHardwareBuffer_describe(mPixmap, &bufferDescription);
void* buffer = NULL;
- if( AHardwareBuffer_lock( mPixmap, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL, &buffer ) != 0 )
+ if(AHardwareBuffer_lock(mPixmap, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL, &buffer) != 0)
{
- DALI_LOG_ERROR( "Failed to AHardwareBuffer_lock\n" );
+ DALI_LOG_ERROR("Failed to AHardwareBuffer_lock\n");
return NULL;
}
width = bufferDescription.width;
height = bufferDescription.height;
- return static_cast< uint8_t* >( buffer );
+ return static_cast<uint8_t*>(buffer);
}
return NULL;
}
-
bool NativeImageSourceAndroid::ReleaseBuffer()
{
- if( mPixmap )
+ if(mPixmap)
{
- if( AHardwareBuffer_unlock( mPixmap, NULL ) != 0 )
+ if(AHardwareBuffer_unlock(mPixmap, NULL) != 0)
{
- DALI_LOG_ERROR( "failed to AHardwareBuffer_unlock\n" );
+ DALI_LOG_ERROR("failed to AHardwareBuffer_unlock\n");
return false;
}
return true;
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2019 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.
#include <dali/integration-api/gl-defines.h>
// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
const char* FRAGMENT_PREFIX = "\n";
-const char* SAMPLER_TYPE = "sampler2D";
+const char* SAMPLER_TYPE = "sampler2D";
-}
+} // namespace
-NativeImageSourceQueueAndroid* NativeImageSourceQueueAndroid::New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueAndroid* NativeImageSourceQueueAndroid::New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- NativeImageSourceQueueAndroid* image = new NativeImageSourceQueueAndroid( width, height, depth, nativeImageSourceQueue );
+ NativeImageSourceQueueAndroid* image = new NativeImageSourceQueueAndroid(width, height, depth, nativeImageSourceQueue);
return image;
}
-NativeImageSourceQueueAndroid::NativeImageSourceQueueAndroid( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
-: mWidth( width ),
- mHeight( height )
+NativeImageSourceQueueAndroid::NativeImageSourceQueueAndroid(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
+: mWidth(width),
+ mHeight(height)
{
- DALI_LOG_ERROR( "NativeImageSourceQueueAndroid::NativeImageSourceQueueAndroid: Not supported\n" );
+ DALI_LOG_ERROR("NativeImageSourceQueueAndroid::NativeImageSourceQueueAndroid: Not supported\n");
}
NativeImageSourceQueueAndroid::~NativeImageSourceQueueAndroid()
return Any();
}
-void NativeImageSourceQueueAndroid::SetSize( uint32_t width, uint32_t height )
+void NativeImageSourceQueueAndroid::SetSize(uint32_t width, uint32_t height)
{
- mWidth = width;
+ mWidth = width;
mHeight = height;
}
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2017 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.
* limitations under the License.
*/
-#include <dali/internal/imaging/common/pixel-manipulation.h>
#include <dali/internal/imaging/common/alpha-mask.h>
+#include <dali/internal/imaging/common/image-operations.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
+#include <dali/internal/imaging/common/pixel-manipulation.h>
#include <dali/public-api/images/image-operations.h> // For ImageDimensions
-#include <dali/internal/imaging/common/image-operations.h>
namespace Dali
{
{
namespace Adaptor
{
-
-void ApplyMaskToAlphaChannel( PixelBuffer& buffer, const PixelBuffer& mask )
+void ApplyMaskToAlphaChannel(PixelBuffer& buffer, const PixelBuffer& mask)
{
- int srcAlphaByteOffset=0;
- int srcAlphaMask=0;
- Dali::Pixel::Format srcPixelFormat = mask.GetPixelFormat();
+ int srcAlphaByteOffset = 0;
+ int srcAlphaMask = 0;
+ Dali::Pixel::Format srcPixelFormat = mask.GetPixelFormat();
- if( Pixel::HasAlpha(srcPixelFormat) )
+ if(Pixel::HasAlpha(srcPixelFormat))
{
- Dali::Pixel::GetAlphaOffsetAndMask( srcPixelFormat, srcAlphaByteOffset, srcAlphaMask );
+ Dali::Pixel::GetAlphaOffsetAndMask(srcPixelFormat, srcAlphaByteOffset, srcAlphaMask);
}
- else if( srcPixelFormat == Pixel::L8 )
+ else if(srcPixelFormat == Pixel::L8)
{
- srcAlphaMask=0xFF;
+ srcAlphaMask = 0xFF;
}
- int destAlphaByteOffset=0;
- int destAlphaMask=0;
- Dali::Pixel::Format destPixelFormat = buffer.GetPixelFormat();
- Dali::Pixel::GetAlphaOffsetAndMask( destPixelFormat, destAlphaByteOffset, destAlphaMask );
+ int destAlphaByteOffset = 0;
+ int destAlphaMask = 0;
+ Dali::Pixel::Format destPixelFormat = buffer.GetPixelFormat();
+ Dali::Pixel::GetAlphaOffsetAndMask(destPixelFormat, destAlphaByteOffset, destAlphaMask);
- unsigned int srcBytesPerPixel = Dali::Pixel::GetBytesPerPixel( srcPixelFormat );
- unsigned char* srcBuffer = mask.GetBuffer();
- unsigned char* destBuffer = buffer.GetBuffer();
+ unsigned int srcBytesPerPixel = Dali::Pixel::GetBytesPerPixel(srcPixelFormat);
+ unsigned char* srcBuffer = mask.GetBuffer();
+ unsigned char* destBuffer = buffer.GetBuffer();
- unsigned int destBytesPerPixel = Dali::Pixel::GetBytesPerPixel( buffer.GetPixelFormat() );
+ unsigned int destBytesPerPixel = Dali::Pixel::GetBytesPerPixel(buffer.GetPixelFormat());
- int srcOffset=0;
- int destOffset=0;
+ int srcOffset = 0;
+ int destOffset = 0;
float srcAlphaValue = 1.0f;
// if image is premultiplied, the other channels of the image need to multiply by alpha.
- if( buffer.IsAlphaPreMultiplied() )
+ if(buffer.IsAlphaPreMultiplied())
{
- for( unsigned int row = 0; row < buffer.GetHeight(); ++row )
+ for(unsigned int row = 0; row < buffer.GetHeight(); ++row)
{
- for( unsigned int col = 0; col < buffer.GetWidth(); ++col )
+ for(unsigned int col = 0; col < buffer.GetWidth(); ++col)
{
- auto srcAlpha = ReadChannel( srcBuffer + srcOffset, srcPixelFormat, Adaptor::ALPHA);
- auto destRed = ReadChannel( destBuffer + destOffset, destPixelFormat, Adaptor::RED);
- auto destGreen = ReadChannel( destBuffer + destOffset, destPixelFormat, Adaptor::GREEN);
- auto destBlue = ReadChannel( destBuffer + destOffset, destPixelFormat, Adaptor::BLUE);
- auto destLuminance = ReadChannel( destBuffer + destOffset, destPixelFormat, Adaptor::LUMINANCE);
- auto destAlpha = ReadChannel( destBuffer + destOffset, destPixelFormat, Adaptor::ALPHA);
-
- WriteChannel( destBuffer + destOffset, destPixelFormat, Adaptor::RED, destRed*srcAlpha / 255 );
- WriteChannel( destBuffer + destOffset, destPixelFormat, Adaptor::GREEN, destGreen*srcAlpha/255 );
- WriteChannel( destBuffer + destOffset, destPixelFormat, Adaptor::BLUE, destBlue*srcAlpha/255 );
- WriteChannel( destBuffer + destOffset, destPixelFormat, Adaptor::LUMINANCE, destLuminance*srcAlpha/255 );
- WriteChannel( destBuffer + destOffset, destPixelFormat, Adaptor::ALPHA, destAlpha*srcAlpha/255 );
-
- srcOffset += srcBytesPerPixel;
+ auto srcAlpha = ReadChannel(srcBuffer + srcOffset, srcPixelFormat, Adaptor::ALPHA);
+ auto destRed = ReadChannel(destBuffer + destOffset, destPixelFormat, Adaptor::RED);
+ auto destGreen = ReadChannel(destBuffer + destOffset, destPixelFormat, Adaptor::GREEN);
+ auto destBlue = ReadChannel(destBuffer + destOffset, destPixelFormat, Adaptor::BLUE);
+ auto destLuminance = ReadChannel(destBuffer + destOffset, destPixelFormat, Adaptor::LUMINANCE);
+ auto destAlpha = ReadChannel(destBuffer + destOffset, destPixelFormat, Adaptor::ALPHA);
+
+ WriteChannel(destBuffer + destOffset, destPixelFormat, Adaptor::RED, destRed * srcAlpha / 255);
+ WriteChannel(destBuffer + destOffset, destPixelFormat, Adaptor::GREEN, destGreen * srcAlpha / 255);
+ WriteChannel(destBuffer + destOffset, destPixelFormat, Adaptor::BLUE, destBlue * srcAlpha / 255);
+ WriteChannel(destBuffer + destOffset, destPixelFormat, Adaptor::LUMINANCE, destLuminance * srcAlpha / 255);
+ WriteChannel(destBuffer + destOffset, destPixelFormat, Adaptor::ALPHA, destAlpha * srcAlpha / 255);
+
+ srcOffset += srcBytesPerPixel;
destOffset += destBytesPerPixel;
}
}
}
else
{
- for( unsigned int row = 0; row < buffer.GetHeight(); ++row )
+ for(unsigned int row = 0; row < buffer.GetHeight(); ++row)
{
- for( unsigned int col = 0; col < buffer.GetWidth(); ++col )
+ for(unsigned int col = 0; col < buffer.GetWidth(); ++col)
{
unsigned char alpha = srcBuffer[srcOffset + srcAlphaByteOffset] & srcAlphaMask;
- srcAlphaValue = float(alpha)/255.0f;
+ srcAlphaValue = float(alpha) / 255.0f;
- unsigned char destAlpha = destBuffer[destOffset + destAlphaByteOffset] & destAlphaMask;
- float destAlphaValue = Clamp(float(destAlpha) * srcAlphaValue, 0.0f, 255.0f);
- destAlpha = destAlphaValue;
+ unsigned char destAlpha = destBuffer[destOffset + destAlphaByteOffset] & destAlphaMask;
+ float destAlphaValue = Clamp(float(destAlpha) * srcAlphaValue, 0.0f, 255.0f);
+ destAlpha = destAlphaValue;
destBuffer[destOffset + destAlphaByteOffset] &= ~destAlphaMask;
- destBuffer[destOffset + destAlphaByteOffset] |= ( destAlpha & destAlphaMask );
+ destBuffer[destOffset + destAlphaByteOffset] |= (destAlpha & destAlphaMask);
- srcOffset += srcBytesPerPixel;
+ srcOffset += srcBytesPerPixel;
destOffset += destBytesPerPixel;
}
}
}
}
-PixelBufferPtr CreateNewMaskedBuffer( const PixelBuffer& buffer, const PixelBuffer& mask )
+PixelBufferPtr CreateNewMaskedBuffer(const PixelBuffer& buffer, const PixelBuffer& mask)
{
// Set up source alpha offsets
- int srcAlphaByteOffset=0;
- int srcAlphaMask=0;
- Dali::Pixel::Format srcPixelFormat = mask.GetPixelFormat();
+ int srcAlphaByteOffset = 0;
+ int srcAlphaMask = 0;
+ Dali::Pixel::Format srcPixelFormat = mask.GetPixelFormat();
- if( Pixel::HasAlpha(srcPixelFormat) )
+ if(Pixel::HasAlpha(srcPixelFormat))
{
- Dali::Pixel::GetAlphaOffsetAndMask( srcPixelFormat, srcAlphaByteOffset, srcAlphaMask );
+ Dali::Pixel::GetAlphaOffsetAndMask(srcPixelFormat, srcAlphaByteOffset, srcAlphaMask);
}
- else if( srcPixelFormat == Pixel::L8 )
+ else if(srcPixelFormat == Pixel::L8)
{
- srcAlphaMask=0xFF;
+ srcAlphaMask = 0xFF;
}
- unsigned int srcBytesPerPixel = Dali::Pixel::GetBytesPerPixel( srcPixelFormat );
- unsigned char* srcBuffer = mask.GetBuffer();
+ unsigned int srcBytesPerPixel = Dali::Pixel::GetBytesPerPixel(srcPixelFormat);
+ unsigned char* srcBuffer = mask.GetBuffer();
// Set up source color offsets
- Dali::Pixel::Format srcColorPixelFormat = buffer.GetPixelFormat();
- unsigned int srcColorBytesPerPixel = Dali::Pixel::GetBytesPerPixel( srcColorPixelFormat );
+ Dali::Pixel::Format srcColorPixelFormat = buffer.GetPixelFormat();
+ unsigned int srcColorBytesPerPixel = Dali::Pixel::GetBytesPerPixel(srcColorPixelFormat);
// Setup destination offsets
- Dali::Pixel::Format destPixelFormat = Dali::Pixel::RGBA8888;
- unsigned int destBytesPerPixel = Dali::Pixel::GetBytesPerPixel( destPixelFormat );
- int destAlphaByteOffset=0;
- int destAlphaMask=0;
- Dali::Pixel::GetAlphaOffsetAndMask( destPixelFormat, destAlphaByteOffset, destAlphaMask );
-
- PixelBufferPtr newPixelBuffer = PixelBuffer::New( buffer.GetWidth(), buffer.GetHeight(),
- destPixelFormat );
- unsigned char* destBuffer = newPixelBuffer->GetBuffer();
- unsigned char* oldBuffer = buffer.GetBuffer();
-
- int srcAlphaOffset=0;
- int srcColorOffset=0;
- int destOffset=0;
- bool hasAlpha = Dali::Pixel::HasAlpha(buffer.GetPixelFormat());
+ Dali::Pixel::Format destPixelFormat = Dali::Pixel::RGBA8888;
+ unsigned int destBytesPerPixel = Dali::Pixel::GetBytesPerPixel(destPixelFormat);
+ int destAlphaByteOffset = 0;
+ int destAlphaMask = 0;
+ Dali::Pixel::GetAlphaOffsetAndMask(destPixelFormat, destAlphaByteOffset, destAlphaMask);
- float srcAlphaValue = 1.0f;
- unsigned char destAlpha = 0;
+ PixelBufferPtr newPixelBuffer = PixelBuffer::New(buffer.GetWidth(), buffer.GetHeight(), destPixelFormat);
+ unsigned char* destBuffer = newPixelBuffer->GetBuffer();
+ unsigned char* oldBuffer = buffer.GetBuffer();
+
+ int srcAlphaOffset = 0;
+ int srcColorOffset = 0;
+ int destOffset = 0;
+ bool hasAlpha = Dali::Pixel::HasAlpha(buffer.GetPixelFormat());
+
+ float srcAlphaValue = 1.0f;
+ unsigned char destAlpha = 0;
- for( unsigned int row = 0; row < buffer.GetHeight(); ++row )
+ for(unsigned int row = 0; row < buffer.GetHeight(); ++row)
{
- for( unsigned int col = 0; col < buffer.GetWidth(); ++col )
+ for(unsigned int col = 0; col < buffer.GetWidth(); ++col)
{
unsigned char alpha = srcBuffer[srcAlphaOffset + srcAlphaByteOffset] & srcAlphaMask;
- srcAlphaValue = float(alpha)/255.0f;
+ srcAlphaValue = float(alpha) / 255.0f;
- ConvertColorChannelsToRGBA8888(oldBuffer, srcColorOffset, srcColorPixelFormat, destBuffer, destOffset );
+ ConvertColorChannelsToRGBA8888(oldBuffer, srcColorOffset, srcColorPixelFormat, destBuffer, destOffset);
- if( hasAlpha )
+ if(hasAlpha)
{
- destAlpha = ConvertAlphaChannelToA8( oldBuffer, srcColorOffset, srcColorPixelFormat );
+ destAlpha = ConvertAlphaChannelToA8(oldBuffer, srcColorOffset, srcColorPixelFormat);
float destAlphaValue = Clamp(float(destAlpha) * srcAlphaValue, 0.0f, 255.0f);
- destAlpha = destAlphaValue;
+ destAlpha = destAlphaValue;
}
else
{
}
destBuffer[destOffset + destAlphaByteOffset] &= ~destAlphaMask;
- destBuffer[destOffset + destAlphaByteOffset] |= ( destAlpha & destAlphaMask );
+ destBuffer[destOffset + destAlphaByteOffset] |= (destAlpha & destAlphaMask);
srcColorOffset += srcColorBytesPerPixel;
srcAlphaOffset += srcBytesPerPixel;
} //namespace Adaptor
-}// namespace Internal
+} // namespace Internal
-}// namespace Dali
+} // namespace Dali
/*
- * Copyright (c) 2017 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.
#include <dali/internal/imaging/common/file-download.h>
// EXTERNAL INCLUDES
+#include <curl/curl.h>
#include <dali/integration-api/debug.h>
#include <pthread.h>
-#include <curl/curl.h>
-#include <cstring>
#include <cstdlib>
+#include <cstring>
// INTERNAL INCLUDES
#include <dali/internal/system/common/file-writer.h>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace // unnamed namespace
{
-
-const int CONNECTION_TIMEOUT_SECONDS( 30L );
-const int TIMEOUT_SECONDS( 120L );
-const long VERBOSE_MODE = 0L; // 0 == off, 1 == on
-const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on
-const long EXCLUDE_HEADER = 0L;
-const long INCLUDE_HEADER = 1L;
-const long INCLUDE_BODY = 0L;
-const long EXCLUDE_BODY = 1L;
+const int CONNECTION_TIMEOUT_SECONDS(30L);
+const int TIMEOUT_SECONDS(120L);
+const long VERBOSE_MODE = 0L; // 0 == off, 1 == on
+const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on
+const long EXCLUDE_HEADER = 0L;
+const long INCLUDE_HEADER = 1L;
+const long INCLUDE_BODY = 0L;
+const long EXCLUDE_BODY = 1L;
/**
* Curl library environment. Direct initialize ensures it's constructed before adaptor
*/
static Dali::TizenPlatform::Network::CurlEnvironment gCurlEnvironment;
-void ConfigureCurlOptions( CURL* curlHandle, const std::string& url )
+void ConfigureCurlOptions(CURL* curlHandle, const std::string& url)
{
- curl_easy_setopt( curlHandle, CURLOPT_URL, url.c_str() );
- curl_easy_setopt( curlHandle, CURLOPT_VERBOSE, VERBOSE_MODE );
+ curl_easy_setopt(curlHandle, CURLOPT_URL, url.c_str());
+ curl_easy_setopt(curlHandle, CURLOPT_VERBOSE, VERBOSE_MODE);
// CURLOPT_FAILONERROR is not fail-safe especially when authentication is involved ( see manual )
// Removed CURLOPT_FAILONERROR option
- curl_easy_setopt( curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS );
- curl_easy_setopt( curlHandle, CURLOPT_TIMEOUT, TIMEOUT_SECONDS );
- curl_easy_setopt( curlHandle, CURLOPT_HEADER, INCLUDE_HEADER );
- curl_easy_setopt( curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY );
- curl_easy_setopt( curlHandle, CURLOPT_FOLLOWLOCATION, 1L );
- curl_easy_setopt( curlHandle, CURLOPT_MAXREDIRS, 5L );
+ curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS);
+ curl_easy_setopt(curlHandle, CURLOPT_TIMEOUT, TIMEOUT_SECONDS);
+ curl_easy_setopt(curlHandle, CURLOPT_HEADER, INCLUDE_HEADER);
+ curl_easy_setopt(curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY);
+ curl_easy_setopt(curlHandle, CURLOPT_FOLLOWLOCATION, 1L);
+ curl_easy_setopt(curlHandle, CURLOPT_MAXREDIRS, 5L);
// If the proxy variable is set, ensure it's also used.
// In theory, this variable should be used by the curl library; however, something
// is overriding it.
char* proxy = std::getenv("http_proxy");
- if( proxy != nullptr )
+ if(proxy != nullptr)
{
- curl_easy_setopt( curlHandle, CURLOPT_PROXY, proxy);
+ curl_easy_setopt(curlHandle, CURLOPT_PROXY, proxy);
}
-
}
// Without a write function or a buffer (file descriptor) to write to, curl will pump out
// header/body contents to stdout
-size_t DummyWrite(char *ptr, size_t size, size_t nmemb, void *userdata)
+size_t DummyWrite(char* ptr, size_t size, size_t nmemb, void* userdata)
{
return size * nmemb;
}
struct ChunkData
{
- std::vector< uint8_t > data;
+ std::vector<uint8_t> data;
};
-size_t ChunkLoader(char *ptr, size_t size, size_t nmemb, void *userdata)
+size_t ChunkLoader(char* ptr, size_t size, size_t nmemb, void* userdata)
{
- std::vector<ChunkData>* chunks = static_cast<std::vector<ChunkData>*>( userdata );
- int numBytes = size*nmemb;
- chunks->push_back( ChunkData() );
- ChunkData& chunkData = (*chunks)[chunks->size()-1];
- chunkData.data.reserve( numBytes );
- memcpy( &chunkData.data[0], ptr, numBytes );
+ std::vector<ChunkData>* chunks = static_cast<std::vector<ChunkData>*>(userdata);
+ int numBytes = size * nmemb;
+ chunks->push_back(ChunkData());
+ ChunkData& chunkData = (*chunks)[chunks->size() - 1];
+ chunkData.data.reserve(numBytes);
+ memcpy(&chunkData.data[0], ptr, numBytes);
return numBytes;
}
-
-CURLcode DownloadFileDataWithSize( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t dataSize )
+CURLcode DownloadFileDataWithSize(CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t dataSize)
{
- CURLcode result( CURLE_OK );
+ CURLcode result(CURLE_OK);
// create
- Dali::Internal::Platform::FileWriter fileWriter( dataBuffer, dataSize );
- FILE* dataBufferFilePointer = fileWriter.GetFile();
- if( NULL != dataBufferFilePointer )
+ Dali::Internal::Platform::FileWriter fileWriter(dataBuffer, dataSize);
+ FILE* dataBufferFilePointer = fileWriter.GetFile();
+ if(NULL != dataBufferFilePointer)
{
// we only want the body which contains the file data
- curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
- curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+ curl_easy_setopt(curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER);
+ curl_easy_setopt(curlHandle, CURLOPT_NOBODY, INCLUDE_BODY);
// disable the write callback, and get curl to write directly into our data buffer
- curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, NULL );
- curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer );
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, NULL);
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer);
// synchronous request of the body data
- result = curl_easy_perform( curlHandle );
+ result = curl_easy_perform(curlHandle);
}
return result;
}
-CURLcode DownloadFileDataByChunk( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize )
+CURLcode DownloadFileDataByChunk(CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize)
{
// create
- std::vector< ChunkData > chunks;
+ std::vector<ChunkData> chunks;
// we only want the body which contains the file data
- curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
- curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+ curl_easy_setopt(curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER);
+ curl_easy_setopt(curlHandle, CURLOPT_NOBODY, INCLUDE_BODY);
// Enable the write callback.
- curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader );
- curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, &chunks );
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader);
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &chunks);
// synchronous request of the body data
- CURLcode result = curl_easy_perform( curlHandle );
+ CURLcode result = curl_easy_perform(curlHandle);
// chunks should now contain all of the chunked data. Reassemble into a single vector
dataSize = 0;
- for( size_t i=0; i<chunks.size() ; ++i )
+ for(size_t i = 0; i < chunks.size(); ++i)
{
dataSize += chunks[i].data.capacity();
}
dataBuffer.Resize(dataSize);
size_t offset = 0;
- for( size_t i=0; i<chunks.size() ; ++i )
+ for(size_t i = 0; i < chunks.size(); ++i)
{
- memcpy( &dataBuffer[offset], &chunks[i].data[0], chunks[i].data.capacity() );
+ memcpy(&dataBuffer[offset], &chunks[i].data[0], chunks[i].data.capacity());
offset += chunks[i].data.capacity();
}
return result;
}
-bool DownloadFile( CURL* curlHandle,
- const std::string& url,
- Dali::Vector<uint8_t>& dataBuffer,
- size_t& dataSize,
- size_t maximumAllowedSizeBytes,
- char* errorBuffer)
+bool DownloadFile(CURL* curlHandle,
+ const std::string& url,
+ Dali::Vector<uint8_t>& dataBuffer,
+ size_t& dataSize,
+ size_t maximumAllowedSizeBytes,
+ char* errorBuffer)
{
- CURLcode result( CURLE_OK );
- double size(0);
+ CURLcode result(CURLE_OK);
+ double size(0);
// setup curl to download just the header so we can extract the content length
- ConfigureCurlOptions( curlHandle, url );
- curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, DummyWrite);
+ ConfigureCurlOptions(curlHandle, url);
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, DummyWrite);
if(errorBuffer != nullptr)
{
- errorBuffer[0]=0;
+ errorBuffer[0] = 0;
}
// perform the request to get the header
- result = curl_easy_perform( curlHandle );
+ result = curl_easy_perform(curlHandle);
- if( result != CURLE_OK)
+ if(result != CURLE_OK)
{
if(errorBuffer != nullptr)
{
- DALI_LOG_ERROR( "Failed to download http header for \"%s\" with error code %d (%s)\n", url.c_str(), result, &errorBuffer[0] );
+ DALI_LOG_ERROR("Failed to download http header for \"%s\" with error code %d (%s)\n", url.c_str(), result, &errorBuffer[0]);
}
else
{
- DALI_LOG_ERROR( "Failed to download http header for \"%s\" with error code %d\n", url.c_str(), result);
+ DALI_LOG_ERROR("Failed to download http header for \"%s\" with error code %d\n", url.c_str(), result);
}
return false;
}
// get the content length, -1 == size is not known
- curl_easy_getinfo( curlHandle,CURLINFO_CONTENT_LENGTH_DOWNLOAD , &size );
-
+ curl_easy_getinfo(curlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &size);
- if( size >= maximumAllowedSizeBytes )
+ if(size >= maximumAllowedSizeBytes)
{
- DALI_LOG_ERROR( "File content length %f > max allowed %zu \"%s\" \n", size, maximumAllowedSizeBytes, url.c_str() );
+ DALI_LOG_ERROR("File content length %f > max allowed %zu \"%s\" \n", size, maximumAllowedSizeBytes, url.c_str());
return false;
}
- else if( size > 0 )
+ else if(size > 0)
{
// If we know the size up front, allocate once and avoid chunk copies.
- dataSize = static_cast<size_t>( size );
- result = DownloadFileDataWithSize( curlHandle, dataBuffer, dataSize );
+ dataSize = static_cast<size_t>(size);
+ result = DownloadFileDataWithSize(curlHandle, dataBuffer, dataSize);
}
else
{
- result = DownloadFileDataByChunk( curlHandle, dataBuffer, dataSize );
+ result = DownloadFileDataByChunk(curlHandle, dataBuffer, dataSize);
}
- if( result != CURLE_OK )
+ if(result != CURLE_OK)
{
- if( errorBuffer != nullptr )
+ if(errorBuffer != nullptr)
{
- DALI_LOG_ERROR( "Failed to download image file \"%s\" with error code %d\n", url.c_str(), result );
+ DALI_LOG_ERROR("Failed to download image file \"%s\" with error code %d\n", url.c_str(), result);
}
else
{
- DALI_LOG_ERROR( "Failed to download image file \"%s\" with error code %d (%s)\n", url.c_str(), result, errorBuffer ); }
+ DALI_LOG_ERROR("Failed to download image file \"%s\" with error code %d (%s)\n", url.c_str(), result, errorBuffer);
+ }
return false;
}
return true;
}
-
} // unnamed namespace
-
namespace Network
{
-
CurlEnvironment::CurlEnvironment()
{
// Must be called before we attempt any loads. e.g. by using curl_easy_init()
curl_global_cleanup();
}
-bool DownloadRemoteFileIntoMemory( const std::string& url,
- Dali::Vector<uint8_t>& dataBuffer,
- size_t& dataSize,
- size_t maximumAllowedSizeBytes )
+bool DownloadRemoteFileIntoMemory(const std::string& url,
+ Dali::Vector<uint8_t>& dataBuffer,
+ size_t& dataSize,
+ size_t maximumAllowedSizeBytes)
{
bool result = false;
- if( url.empty() )
+ if(url.empty())
{
DALI_LOG_WARNING("empty url requested \n");
return false;
}
-
// start a libcurl easy session, this internally calls curl_global_init, if we ever have more than one download
// thread we need to explicity call curl_global_init() on startup from a single thread.
CURL* curlHandle = curl_easy_init();
- if ( curlHandle )
+ if(curlHandle)
{
std::vector<char> errorBuffer(CURL_ERROR_SIZE);
- curl_easy_setopt( curlHandle, CURLOPT_ERRORBUFFER, &errorBuffer[0]);
- result = DownloadFile( curlHandle, url, dataBuffer, dataSize, maximumAllowedSizeBytes, &errorBuffer[0]);
+ curl_easy_setopt(curlHandle, CURLOPT_ERRORBUFFER, &errorBuffer[0]);
+ result = DownloadFile(curlHandle, url, dataBuffer, dataSize, maximumAllowedSizeBytes, &errorBuffer[0]);
// clean up session
- curl_easy_cleanup( curlHandle );
+ curl_easy_cleanup(curlHandle);
}
return result;
}
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-
-
-void ConvoluteAndTranspose( unsigned char* inBuffer,
- unsigned char* outBuffer,
- const unsigned int bufferWidth,
- const unsigned int bufferHeight,
- const float blurRadius )
+void ConvoluteAndTranspose(unsigned char* inBuffer,
+ unsigned char* outBuffer,
+ const unsigned int bufferWidth,
+ const unsigned int bufferHeight,
+ const float blurRadius)
{
// Calculate the weights for gaussian blur
- int radius = static_cast<int>( std::ceil( blurRadius ) );
- int rows = radius * 2 + 1;
+ int radius = static_cast<int>(std::ceil(blurRadius));
+ int rows = radius * 2 + 1;
- float sigma = ( blurRadius < Math::MACHINE_EPSILON_1 ) ? 0.0f : blurRadius * 0.4f + 0.6f; // The same equation used by Android
- float sigma22 = 2.0f * sigma * sigma;
- float sqrtSigmaPi2 = std::sqrt( 2.0f * Math::PI ) * sigma;
- float radius2 = radius * radius;
+ float sigma = (blurRadius < Math::MACHINE_EPSILON_1) ? 0.0f : blurRadius * 0.4f + 0.6f; // The same equation used by Android
+ float sigma22 = 2.0f * sigma * sigma;
+ float sqrtSigmaPi2 = std::sqrt(2.0f * Math::PI) * sigma;
+ float radius2 = radius * radius;
float normalizeFactor = 0.0f;
float* weightMatrix = new float[rows];
- int index = 0;
+ int index = 0;
- for ( int row = -radius; row <= radius; row++ )
+ for(int row = -radius; row <= radius; row++)
{
float distance = row * row;
- if ( distance > radius2 )
+ if(distance > radius2)
{
weightMatrix[index] = 0.0f;
}
else
{
- weightMatrix[index] = static_cast<float>( std::exp( -( distance ) / sigma22 ) / sqrtSigmaPi2 );
+ weightMatrix[index] = static_cast<float>(std::exp(-(distance) / sigma22) / sqrtSigmaPi2);
}
normalizeFactor += weightMatrix[index];
index++;
}
- for ( int i = 0; i < rows; i++ )
+ for(int i = 0; i < rows; i++)
{
weightMatrix[i] /= normalizeFactor;
}
// Perform the convolution and transposition using the weights
- int columns = rows;
+ int columns = rows;
int columns2 = columns / 2;
- for ( unsigned int y = 0; y < bufferHeight; y++ )
+ for(unsigned int y = 0; y < bufferHeight; y++)
{
unsigned int targetPixelIndex = y;
- unsigned int ioffset = y * bufferWidth;
- for ( unsigned int x = 0; x < bufferWidth; x++ )
+ unsigned int ioffset = y * bufferWidth;
+ for(unsigned int x = 0; x < bufferWidth; x++)
{
float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f;
- int weightColumnOffset = columns2;
- for ( int column = -columns2; column <= columns2; column++ )
+ int weightColumnOffset = columns2;
+ for(int column = -columns2; column <= columns2; column++)
{
float weight = weightMatrix[weightColumnOffset + column];
- if ( fabsf( weight ) > Math::MACHINE_EPSILON_1 )
+ if(fabsf(weight) > Math::MACHINE_EPSILON_1)
{
- int ix = x + column;
- ix = std::max( 0, std::min( ix, static_cast<int>( bufferWidth - 1 ) ) );
+ int ix = x + column;
+ ix = std::max(0, std::min(ix, static_cast<int>(bufferWidth - 1)));
unsigned int sourcePixelIndex = ioffset + ix;
- r += weight * inBuffer[sourcePixelIndex*4];
- g += weight * inBuffer[sourcePixelIndex*4+1];
- b += weight * inBuffer[sourcePixelIndex*4+2];
- a += weight * inBuffer[sourcePixelIndex*4+3];
+ r += weight * inBuffer[sourcePixelIndex * 4];
+ g += weight * inBuffer[sourcePixelIndex * 4 + 1];
+ b += weight * inBuffer[sourcePixelIndex * 4 + 2];
+ a += weight * inBuffer[sourcePixelIndex * 4 + 3];
}
}
- outBuffer[targetPixelIndex*4] = std::max( 0, std::min( static_cast<int>( r + 0.5f ), 255 ) );
- outBuffer[targetPixelIndex*4+1] = std::max( 0, std::min( static_cast<int>( g + 0.5f ), 255 ) );
- outBuffer[targetPixelIndex*4+2] = std::max( 0, std::min( static_cast<int>( b + 0.5f ), 255 ) );
- outBuffer[targetPixelIndex*4+3] = std::max( 0, std::min( static_cast<int>( a + 0.5f ), 255 ) );
+ outBuffer[targetPixelIndex * 4] = std::max(0, std::min(static_cast<int>(r + 0.5f), 255));
+ outBuffer[targetPixelIndex * 4 + 1] = std::max(0, std::min(static_cast<int>(g + 0.5f), 255));
+ outBuffer[targetPixelIndex * 4 + 2] = std::max(0, std::min(static_cast<int>(b + 0.5f), 255));
+ outBuffer[targetPixelIndex * 4 + 3] = std::max(0, std::min(static_cast<int>(a + 0.5f), 255));
targetPixelIndex += bufferHeight;
}
}
- delete [] weightMatrix;
+ delete[] weightMatrix;
}
-void PerformGaussianBlurRGBA( PixelBuffer& buffer, const float blurRadius )
+void PerformGaussianBlurRGBA(PixelBuffer& buffer, const float blurRadius)
{
- unsigned int bufferWidth = buffer.GetWidth();
+ unsigned int bufferWidth = buffer.GetWidth();
unsigned int bufferHeight = buffer.GetHeight();
// Create a temporary buffer for the two-pass blur
- PixelBufferPtr softShadowImageBuffer = PixelBuffer::New( bufferWidth, bufferHeight, Pixel::RGBA8888 );
- memcpy( softShadowImageBuffer->GetBuffer(), buffer.GetBuffer(), 4u * bufferWidth * bufferHeight );
+ PixelBufferPtr softShadowImageBuffer = PixelBuffer::New(bufferWidth, bufferHeight, Pixel::RGBA8888);
+ memcpy(softShadowImageBuffer->GetBuffer(), buffer.GetBuffer(), 4u * bufferWidth * bufferHeight);
// We perform the blur first but write its output image buffer transposed, so that we
// can just do it in two passes. The first pass blurs horizontally and transposes, the
// second pass does the same, but as the image is now transposed, it's really doing a
// vertical blur. The second transposition makes the image the right way up again. This
// is much faster than doing a 2D convolution.
- ConvoluteAndTranspose( buffer.GetBuffer(), softShadowImageBuffer->GetBuffer(), bufferWidth, bufferHeight, blurRadius );
- ConvoluteAndTranspose( softShadowImageBuffer->GetBuffer(), buffer.GetBuffer(), bufferHeight, bufferWidth, blurRadius );
+ ConvoluteAndTranspose(buffer.GetBuffer(), softShadowImageBuffer->GetBuffer(), bufferWidth, bufferHeight, blurRadius);
+ ConvoluteAndTranspose(softShadowImageBuffer->GetBuffer(), buffer.GetBuffer(), bufferHeight, bufferWidth, blurRadius);
// On leaving scope, softShadowImageBuffer will get destroyed.
}
} //namespace Adaptor
-}// namespace Internal
+} // namespace Internal
-}// namespace Dali
+} // namespace Dali
/*
- * 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.
#include <dali/internal/imaging/common/gif-loading.h>
// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
#include <gif_lib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <cstring>
#include <memory>
#include <dali/integration-api/debug.h>
-#include <dali/public-api/images/pixel-data.h>
#include <dali/internal/imaging/common/file-download.h>
#include <dali/internal/system/common/file-reader.h>
+#include <dali/public-api/images/pixel-data.h>
-#define IMG_TOO_BIG( w, h ) \
- ( ( static_cast<unsigned long long>(w) * static_cast<unsigned long long>(h) ) >= \
- ( (1ULL << (29 * (sizeof(void *) / 4))) - 2048) )
+#define IMG_TOO_BIG(w, h) \
+ ((static_cast<unsigned long long>(w) * static_cast<unsigned long long>(h)) >= \
+ ((1ULL << (29 * (sizeof(void*) / 4))) - 2048))
-#define LOADERR( x ) \
- do { \
- DALI_LOG_ERROR( x ); \
- goto on_error; \
- } while ( 0 )
+#define LOADERR(x) \
+ do \
+ { \
+ DALI_LOG_ERROR(x); \
+ goto on_error; \
+ } while(0)
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
#if defined(DEBUG_ENABLED)
-Debug::Filter *gGifLoadingLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_GIF_LOADING" );
+Debug::Filter* gGifLoadingLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_GIF_LOADING");
#endif
-const int IMG_MAX_SIZE = 65000;
-constexpr size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024;
+const int IMG_MAX_SIZE = 65000;
+constexpr size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024;
#if GIFLIB_MAJOR < 5
-const int DISPOSE_BACKGROUND = 2; /* Set area too background color */
-const int DISPOSE_PREVIOUS = 3; /* Restore to previous content */
+const int DISPOSE_BACKGROUND = 2; /* Set area too background color */
+const int DISPOSE_PREVIOUS = 3; /* Restore to previous content */
#endif
struct FrameInfo
{
FrameInfo()
- : x( 0 ),
- y( 0 ),
- w( 0 ),
- h( 0 ),
- delay( 0 ),
- transparent( -1 ),
- dispose( DISPOSE_BACKGROUND ),
- interlace( 0 )
+ : x(0),
+ y(0),
+ w(0),
+ h(0),
+ delay(0),
+ transparent(-1),
+ dispose(DISPOSE_BACKGROUND),
+ interlace(0)
{
}
- int x, y, w, h;
- unsigned short delay; // delay time in 1/100ths of a sec
- short transparent : 10; // -1 == not, anything else == index
- short dispose : 6; // 0, 1, 2, 3 (others invalid)
- short interlace : 1; // interlaced or not
+ int x, y, w, h;
+ unsigned short delay; // delay time in 1/100ths of a sec
+ short transparent : 10; // -1 == not, anything else == index
+ short dispose : 6; // 0, 1, 2, 3 (others invalid)
+ short interlace : 1; // interlaced or not
};
struct ImageFrame
{
ImageFrame()
- : index( 0 ),
- data( nullptr ),
+ : index(0),
+ data(nullptr),
info(),
- loaded( false )
+ loaded(false)
{
}
~ImageFrame()
{
- if( data != nullptr )
+ if(data != nullptr)
{
// De-allocate memory of the frame data.
delete[] data;
}
int index;
- uint32_t *data; /* frame decoding data */
- FrameInfo info; /* special image type info */
- bool loaded : 1;
+ uint32_t* data; /* frame decoding data */
+ FrameInfo info; /* special image type info */
+ bool loaded : 1;
};
struct GifAnimationData
{
GifAnimationData()
- : frames( ),
- frameCount( 0 ),
- loopCount( 0 ),
- currentFrame( 0 ),
- animated( false )
+ : frames(),
+ frameCount(0),
+ loopCount(0),
+ currentFrame(0),
+ animated(false)
{
}
std::vector<ImageFrame> frames;
- int frameCount;
- int loopCount;
- int currentFrame;
- bool animated;
+ int frameCount;
+ int loopCount;
+ int currentFrame;
+ bool animated;
};
// Forward declaration
struct FileData
{
FileData()
- : fileName( nullptr ),
- globalMap ( nullptr ),
- length( 0 ),
- isLocalResource( true )
+ : fileName(nullptr),
+ globalMap(nullptr),
+ length(0),
+ isLocalResource(true)
{
}
~FileData()
{
- if( globalMap )
+ if(globalMap)
{
- free( globalMap );
+ free(globalMap);
globalMap = nullptr;
}
}
bool LoadRemoteFile();
public:
- const char *fileName; /**< The absolute path of the file. */
- unsigned char *globalMap ; /**< A pointer to the entire contents of the file */
- long long length; /**< The length of the file in bytes. */
- bool isLocalResource; /**< The flag whether the file is a local resource */
+ const char* fileName; /**< The absolute path of the file. */
+ unsigned char* globalMap; /**< A pointer to the entire contents of the file */
+ long long length; /**< The length of the file in bytes. */
+ bool isLocalResource; /**< The flag whether the file is a local resource */
};
struct FileInfo
{
FileInfo()
- : map( nullptr ),
- position( 0 ),
- length( 0 )
+ : map(nullptr),
+ position(0),
+ length(0)
{
}
- unsigned char *map;
- int position, length; // yes - gif uses ints for file sizes.
+ unsigned char* map;
+ int position, length; // yes - gif uses ints for file sizes.
};
- FileData fileData;
- GifAnimationData animated;
+ FileData fileData;
+ GifAnimationData animated;
std::unique_ptr<GifAccessor> gifAccessor{nullptr};
- int imageNumber{0};
- FileInfo fileInfo;
+ int imageNumber{0};
+ FileInfo fileInfo;
};
struct ImageProperties
{
unsigned int w{0};
unsigned int h{0};
- bool alpha{0};
+ bool alpha{0};
};
/**
*/
GifAccessor(LoaderInfo::FileInfo& fileInfo)
{
-
// actually ask libgif to open the file
#if GIFLIB_MAJOR >= 5
- gif = DGifOpen( &fileInfo, FileRead, NULL );
+ gif = DGifOpen(&fileInfo, FileRead, NULL);
#else
- gif = DGifOpen( &fileInfo, FileRead );
+ gif = DGifOpen(&fileInfo, FileRead);
#endif
- if (!gif)
+ if(!gif)
{
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
}
{
if(gif)
{
-#if (GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
- DGifCloseFile( gif, NULL );
+#if(GIFLIB_MAJOR > 5) || ((GIFLIB_MAJOR == 5) && (GIFLIB_MINOR >= 1))
+ DGifCloseFile(gif, NULL);
#else
- DGifCloseFile( gif );
+ DGifCloseFile(gif);
#endif
}
}
* @param[in] len The length in bytes to be copied
* @return The data length of the image in bytes
*/
- static int FileRead( GifFileType *gifFileType, GifByteType *buffer, int length )
+ static int FileRead(GifFileType* gifFileType, GifByteType* buffer, int length)
{
- LoaderInfo::FileInfo *fi = reinterpret_cast<LoaderInfo::FileInfo *>( gifFileType->UserData );
+ LoaderInfo::FileInfo* fi = reinterpret_cast<LoaderInfo::FileInfo*>(gifFileType->UserData);
- if( fi->position >= fi->length )
+ if(fi->position >= fi->length)
{
return 0; // if at or past end - no
}
- if( (fi->position + length) >= fi->length )
+ if((fi->position + length) >= fi->length)
{
length = fi->length - fi->position;
}
- memcpy( buffer, fi->map + fi->position, length );
+ memcpy(buffer, fi->map + fi->position, length);
fi->position += length;
return length;
}
-
- GifFileType *gif = nullptr;
+ GifFileType* gif = nullptr;
};
bool LoaderInfo::FileData::LoadFile()
{
- bool success=false;
- if( isLocalResource )
+ bool success = false;
+ if(isLocalResource)
{
success = LoadLocalFile();
}
bool LoaderInfo::FileData::LoadLocalFile()
{
- Internal::Platform::FileReader fileReader( fileName );
- FILE *fp = fileReader.GetFile();
- if( fp == NULL )
+ Internal::Platform::FileReader fileReader(fileName);
+ FILE* fp = fileReader.GetFile();
+ if(fp == NULL)
{
return false;
}
- if( fseek( fp, 0, SEEK_END ) <= -1 )
+ if(fseek(fp, 0, SEEK_END) <= -1)
{
return false;
}
- length = ftell( fp );
- if( length <= -1 )
+ length = ftell(fp);
+ if(length <= -1)
{
return false;
}
- if( ( ! fseek( fp, 0, SEEK_SET ) ) )
+ if((!fseek(fp, 0, SEEK_SET)))
{
- globalMap = reinterpret_cast<GifByteType*>( malloc(sizeof( GifByteType ) * length ) );
- length = fread( globalMap, sizeof( GifByteType ), length, fp);
+ globalMap = reinterpret_cast<GifByteType*>(malloc(sizeof(GifByteType) * length));
+ length = fread(globalMap, sizeof(GifByteType), length, fp);
}
else
{
bool LoaderInfo::FileData::LoadRemoteFile()
{
// remote file
- bool succeeded=false;
+ bool succeeded = false;
Dali::Vector<uint8_t> dataBuffer;
- size_t dataSize;
+ size_t dataSize;
- succeeded = TizenPlatform::Network::DownloadRemoteFileIntoMemory( fileName, dataBuffer, dataSize,
- MAXIMUM_DOWNLOAD_IMAGE_SIZE );
- if( succeeded )
+ succeeded = TizenPlatform::Network::DownloadRemoteFileIntoMemory(fileName, dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE);
+ if(succeeded)
{
size_t blobSize = dataBuffer.Size();
- if( blobSize > 0U )
+ if(blobSize > 0U)
{
// Open a file handle on the memory buffer:
- Dali::Internal::Platform::FileReader fileReader( dataBuffer, blobSize );
- FILE * const fp = fileReader.GetFile();
- if ( NULL != fp )
+ Dali::Internal::Platform::FileReader fileReader(dataBuffer, blobSize);
+ FILE* const fp = fileReader.GetFile();
+ if(NULL != fp)
{
- if( ( ! fseek( fp, 0, SEEK_SET ) ) )
+ if((!fseek(fp, 0, SEEK_SET)))
{
- globalMap = reinterpret_cast<GifByteType*>( malloc(sizeof( GifByteType ) * blobSize ) );
- length = fread( globalMap, sizeof( GifByteType ), blobSize, fp);
+ globalMap = reinterpret_cast<GifByteType*>(malloc(sizeof(GifByteType) * blobSize));
+ length = fread(globalMap, sizeof(GifByteType), blobSize, fp);
succeeded = true;
}
else
{
- DALI_LOG_ERROR( "Error seeking within file\n" );
+ DALI_LOG_ERROR("Error seeking within file\n");
}
}
else
{
- DALI_LOG_ERROR( "Error reading file\n" );
+ DALI_LOG_ERROR("Error reading file\n");
}
}
}
return succeeded;
}
-
/**
* @brief This combines R, G, B and Alpha values into a single 32-bit (ABGR) value.
*
* @param[in] index Frame index to be searched in GIF
* @return A pointer to the ImageFrame.
*/
-inline int CombinePixelABGR( int a, int r, int g, int b )
+inline int CombinePixelABGR(int a, int r, int g, int b)
{
- return ( ((a) << 24) + ((b) << 16) + ((g) << 8) + (r) );
+ return (((a) << 24) + ((b) << 16) + ((g) << 8) + (r));
}
-inline int PixelLookup( ColorMapObject *colorMap, int index )
+inline int PixelLookup(ColorMapObject* colorMap, int index)
{
- return CombinePixelABGR( 0xFF, colorMap->Colors[index].Red, colorMap->Colors[index].Green, colorMap->Colors[index].Blue );
+ return CombinePixelABGR(0xFF, colorMap->Colors[index].Red, colorMap->Colors[index].Green, colorMap->Colors[index].Blue);
}
/**
* @param[in] index Frame index to be searched in GIF
* @return A pointer to the ImageFrame.
*/
-ImageFrame *FindFrame( const GifAnimationData &animated, int index )
+ImageFrame* FindFrame(const GifAnimationData& animated, int index)
{
- for( auto &&elem : animated.frames )
+ for(auto&& elem : animated.frames)
{
- if( elem.index == index )
+ if(elem.index == index)
{
- return const_cast<ImageFrame *>( &elem );
+ return const_cast<ImageFrame*>(&elem);
}
}
return nullptr;
* @param[in] width Width of the image
* @param[in] height Height of the image
*/
-void FillImage( uint32_t *data, int row, uint32_t val, int x, int y, int width, int height )
+void FillImage(uint32_t* data, int row, uint32_t val, int x, int y, int width, int height)
{
- int xAxis, yAxis;
- uint32_t *pixelPosition;
+ int xAxis, yAxis;
+ uint32_t* pixelPosition;
- for( yAxis = 0; yAxis < height; yAxis++ )
+ for(yAxis = 0; yAxis < height; yAxis++)
{
pixelPosition = data + ((y + yAxis) * row) + x;
- for( xAxis = 0; xAxis < width; xAxis++ )
+ for(xAxis = 0; xAxis < width; xAxis++)
{
*pixelPosition = val;
pixelPosition++;
* @param[in] width Width of the image
* @param[in] height Height of the image
*/
-void FillFrame( uint32_t *data, int row, GifFileType *gif, FrameInfo *frameInfo, int x, int y, int w, int h )
+void FillFrame(uint32_t* data, int row, GifFileType* gif, FrameInfo* frameInfo, int x, int y, int w, int h)
{
// solid color fill for pre frame region
- if( frameInfo->transparent < 0 )
+ if(frameInfo->transparent < 0)
{
- ColorMapObject *colorMap;
- int backGroundColor;
+ ColorMapObject* colorMap;
+ int backGroundColor;
// work out color to use from colorMap
- if( gif->Image.ColorMap )
+ if(gif->Image.ColorMap)
{
colorMap = gif->Image.ColorMap;
}
}
backGroundColor = gif->SBackGroundColor;
// and do the fill
- FillImage( data, row,
- CombinePixelABGR( 0xff, colorMap->Colors[backGroundColor].Red,
- colorMap->Colors[backGroundColor].Green,
- colorMap->Colors[backGroundColor].Blue ),
- x, y, w, h );
+ FillImage(data, row, CombinePixelABGR(0xff, colorMap->Colors[backGroundColor].Red, colorMap->Colors[backGroundColor].Green, colorMap->Colors[backGroundColor].Blue), x, y, w, h);
}
// fill in region with 0 (transparent)
else
{
- FillImage( data, row, 0, x, y, w, h );
+ FillImage(data, row, 0, x, y, w, h);
}
}
* @param[in] gif A pointer pointing to GIF File Type
* @param[in] frameInfo A pointer pointing to Frame Information data
*/
-void StoreFrameInfo( GifFileType *gif, FrameInfo *frameInfo )
+void StoreFrameInfo(GifFileType* gif, FrameInfo* frameInfo)
{
- frameInfo->x = gif->Image.Left;
- frameInfo->y = gif->Image.Top;
- frameInfo->w = gif->Image.Width;
- frameInfo->h = gif->Image.Height;
+ frameInfo->x = gif->Image.Left;
+ frameInfo->y = gif->Image.Top;
+ frameInfo->w = gif->Image.Width;
+ frameInfo->h = gif->Image.Height;
frameInfo->interlace = gif->Image.Interlace;
}
* @param[in] width Width of the image
* @param[in] height Height of the image
*/
-void CheckTransparency( bool &full, FrameInfo *frameInfo, int width, int height )
+void CheckTransparency(bool& full, FrameInfo* frameInfo, int width, int height)
{
- if( ( frameInfo->x == 0 ) && ( frameInfo->y == 0 ) &&
- ( frameInfo->w == width ) && ( frameInfo->h == height ) )
+ if((frameInfo->x == 0) && (frameInfo->y == 0) &&
+ (frameInfo->w == width) && (frameInfo->h == height))
{
- if( frameInfo->transparent >= 0 )
+ if(frameInfo->transparent >= 0)
{
full = false;
}
/**
* @brief Fix coords and work out an x and y inset in orig data if out of image bounds.
*/
-void ClipCoordinates( int imageWidth, int imageHeight, int *xin, int *yin, int x0, int y0, int w0, int h0, int *x, int *y, int *w, int *h )
+void ClipCoordinates(int imageWidth, int imageHeight, int* xin, int* yin, int x0, int y0, int w0, int h0, int* x, int* y, int* w, int* h)
{
- if( x0 < 0 )
+ if(x0 < 0)
{
w0 += x0;
*xin = -x0;
- x0 = 0;
+ x0 = 0;
}
- if( (x0 + w0) > imageWidth )
+ if((x0 + w0) > imageWidth)
{
w0 = imageWidth - x0;
}
- if( y0 < 0 )
+ if(y0 < 0)
{
h0 += y0;
*yin = -y0;
- y0 = 0;
+ y0 = 0;
}
- if( (y0 + h0) > imageHeight )
+ if((y0 + h0) > imageHeight)
{
h0 = imageHeight - y0;
}
* @param[in] prevframe The previous frame
* @param[in] lastPreservedFrame The last preserved frame
*/
-void FlushFrames( GifAnimationData &animated, int width, int height, ImageFrame *thisframe, ImageFrame *prevframe, ImageFrame *lastPreservedFrame )
+void FlushFrames(GifAnimationData& animated, int width, int height, ImageFrame* thisframe, ImageFrame* prevframe, ImageFrame* lastPreservedFrame)
{
- DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "FlushFrames() START \n" );
+ DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "FlushFrames() START \n");
// target is the amount of memory we want to be under for stored frames
int total = 0, target = 512 * 1024;
// total up the amount of memory used by stored frames for this image
- for( auto &&frame : animated.frames )
+ for(auto&& frame : animated.frames)
{
- if( frame.data )
+ if(frame.data)
{
total++;
}
}
- total *= ( width * height * sizeof( uint32_t ) );
+ total *= (width * height * sizeof(uint32_t));
- DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "Total used frame size: %d\n", total );
+ DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "Total used frame size: %d\n", total);
// If we use more than target (512k) for frames - flush
- if( total > target )
+ if(total > target)
{
// Clean frames (except current and previous) until below target
- for( auto &&frame : animated.frames )
+ for(auto&& frame : animated.frames)
{
- if( (frame.index != thisframe->index) && (!prevframe || frame.index != prevframe->index) &&
- (!lastPreservedFrame || frame.index != lastPreservedFrame->index) )
+ if((frame.index != thisframe->index) && (!prevframe || frame.index != prevframe->index) &&
+ (!lastPreservedFrame || frame.index != lastPreservedFrame->index))
{
- if( frame.data != nullptr )
+ if(frame.data != nullptr)
{
delete[] frame.data;
frame.data = nullptr;
// subtract memory used and if below target - stop flush
- total -= ( width * height * sizeof( uint32_t ) );
- if( total < target )
+ total -= (width * height * sizeof(uint32_t));
+ if(total < target)
{
break;
}
}
}
- DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "FlushFrames() END \n" );
+ DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "FlushFrames() END \n");
}
/**
* @param[in] delay The frame delay of new frame
* @param[in] index The index of new frame
*/
-FrameInfo *NewFrame( GifAnimationData &animated, int transparent, int dispose, int delay, int index )
+FrameInfo* NewFrame(GifAnimationData& animated, int transparent, int dispose, int delay, int index)
{
ImageFrame frame;
frame.index = index;
// that frame is stored AT image/screen size
- animated.frames.push_back( frame );
+ animated.frames.push_back(frame);
- DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "NewFrame: animated.frames.size() = %d\n", animated.frames.size() );
+ DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "NewFrame: animated.frames.size() = %d\n", animated.frames.size());
- return &( animated.frames.back().info );
+ return &(animated.frames.back().info);
}
-
/**
* @brief Decode a gif image into rows then expand to 32bit into the destination
* data pointer.
*/
-bool DecodeImage( GifFileType *gif, uint32_t *data, int rowpix, int xin, int yin,
- int transparent, int x, int y, int w, int h, bool fill )
+bool DecodeImage(GifFileType* gif, uint32_t* data, int rowpix, int xin, int yin, int transparent, int x, int y, int w, int h, bool fill)
{
- int intoffset[] = {0, 4, 2, 1};
- int intjump[] = {8, 8, 4, 2};
- int i, xx, yy, pix, gifW, gifH;
- GifRowType *rows = NULL;
- bool ret = false;
- ColorMapObject *colorMap;
- uint32_t *p;
+ int intoffset[] = {0, 4, 2, 1};
+ int intjump[] = {8, 8, 4, 2};
+ int i, xx, yy, pix, gifW, gifH;
+ GifRowType* rows = NULL;
+ bool ret = false;
+ ColorMapObject* colorMap;
+ uint32_t* p;
// what we need is image size.
- SavedImage *sp;
- sp = &gif->SavedImages[ gif->ImageCount - 1 ];
+ SavedImage* sp;
+ sp = &gif->SavedImages[gif->ImageCount - 1];
gifW = sp->ImageDesc.Width;
gifH = sp->ImageDesc.Height;
- if( ( gifW < w ) || ( gifH < h ) )
+ if((gifW < w) || (gifH < h))
{
- DALI_ASSERT_DEBUG( false && "Dimensions are bigger than the Gif image size");
+ DALI_ASSERT_DEBUG(false && "Dimensions are bigger than the Gif image size");
goto on_error;
}
// build a blob of memory to have pointers to rows of pixels
// AND store the decoded gif pixels (1 byte per pixel) as welll
- rows = static_cast<GifRowType *>( malloc( (gifH * sizeof(GifRowType) ) + ( gifW * gifH * sizeof(GifPixelType) )));
- if( !rows )
+ rows = static_cast<GifRowType*>(malloc((gifH * sizeof(GifRowType)) + (gifW * gifH * sizeof(GifPixelType))));
+ if(!rows)
{
goto on_error;
}
// fill in the pointers at the start
- for( yy = 0; yy < gifH; yy++ )
+ for(yy = 0; yy < gifH; yy++)
{
- rows[yy] = reinterpret_cast<unsigned char *>(rows) + (gifH * sizeof(GifRowType)) + (yy * gifW * sizeof(GifPixelType));
+ rows[yy] = reinterpret_cast<unsigned char*>(rows) + (gifH * sizeof(GifRowType)) + (yy * gifW * sizeof(GifPixelType));
}
// if gif is interlaced, walk interlace pattern and decode into rows
- if( gif->Image.Interlace )
+ if(gif->Image.Interlace)
{
- for( i = 0; i < 4; i++ )
+ for(i = 0; i < 4; i++)
{
- for( yy = intoffset[i]; yy < gifH; yy += intjump[i] )
+ for(yy = intoffset[i]; yy < gifH; yy += intjump[i])
{
- if( DGifGetLine( gif, rows[yy], gifW ) != GIF_OK )
+ if(DGifGetLine(gif, rows[yy], gifW) != GIF_OK)
{
goto on_error;
}
// normal top to bottom - decode into rows
else
{
- for( yy = 0; yy < gifH; yy++ )
+ for(yy = 0; yy < gifH; yy++)
{
- if( DGifGetLine( gif, rows[yy], gifW ) != GIF_OK )
+ if(DGifGetLine(gif, rows[yy], gifW) != GIF_OK)
{
goto on_error;
}
}
// work out what colormap to use
- if( gif->Image.ColorMap )
+ if(gif->Image.ColorMap)
{
colorMap = gif->Image.ColorMap;
}
}
// if we need to deal with transparent pixels at all...
- if( transparent >= 0 )
+ if(transparent >= 0)
{
// if we are told to FILL (overwrite with transparency kept)
- if( fill )
+ if(fill)
{
- for( yy = 0; yy < h; yy++ )
+ for(yy = 0; yy < h; yy++)
{
p = data + ((y + yy) * rowpix) + x;
- for( xx = 0; xx < w; xx++ )
+ for(xx = 0; xx < w; xx++)
{
pix = rows[yin + yy][xin + xx];
- if( pix != transparent )
+ if(pix != transparent)
{
- *p = PixelLookup( colorMap, pix );
+ *p = PixelLookup(colorMap, pix);
}
else
{
// paste on top with transparent pixels untouched
else
{
- for( yy = 0; yy < h; yy++ )
+ for(yy = 0; yy < h; yy++)
{
p = data + ((y + yy) * rowpix) + x;
- for( xx = 0; xx < w; xx++ )
+ for(xx = 0; xx < w; xx++)
{
pix = rows[yin + yy][xin + xx];
- if( pix != transparent )
+ if(pix != transparent)
{
- *p = PixelLookup( colorMap, pix );
+ *p = PixelLookup(colorMap, pix);
}
p++;
}
else
{
// walk pixels without worring about transparency at all
- for( yy = 0; yy < h; yy++ )
+ for(yy = 0; yy < h; yy++)
{
p = data + ((y + yy) * rowpix) + x;
- for( xx = 0; xx < w; xx++ )
+ for(xx = 0; xx < w; xx++)
{
pix = rows[yin + yy][xin + xx];
- *p = PixelLookup( colorMap, pix );
+ *p = PixelLookup(colorMap, pix);
p++;
}
}
ret = true;
on_error:
- if( rows )
+ if(rows)
{
- free( rows );
+ free(rows);
}
return ret;
}
-
-
/**
* @brief Reader header from the gif file and populates structures accordingly.
*
* @param[out] error Error code
* @return The true or false whether reading was successful or not.
*/
-bool ReadHeader( LoaderInfo &loaderInfo,
- ImageProperties &prop, //output struct
- int *error )
+bool ReadHeader(LoaderInfo& loaderInfo,
+ ImageProperties& prop, //output struct
+ int* error)
{
- GifAnimationData &animated = loaderInfo.animated;
- LoaderInfo::FileData &fileData = loaderInfo.fileData;
- bool success = false;
- LoaderInfo::FileInfo fileInfo;
- GifRecordType rec;
+ GifAnimationData& animated = loaderInfo.animated;
+ LoaderInfo::FileData& fileData = loaderInfo.fileData;
+ bool success = false;
+ LoaderInfo::FileInfo fileInfo;
+ GifRecordType rec;
// it is possible which gif file have error midle of frames,
// in that case we should play gif file until meet error frame.
- int imageNumber = 0;
- int loopCount = -1;
- FrameInfo *frameInfo = NULL;
- bool full = true;
+ int imageNumber = 0;
+ int loopCount = -1;
+ FrameInfo* frameInfo = NULL;
+ bool full = true;
success = fileData.LoadFile();
if(!success || !fileData.globalMap)
}
else
{
- fileInfo.map = fileData.globalMap;
- fileInfo.length = fileData.length;
+ fileInfo.map = fileData.globalMap;
+ fileInfo.length = fileData.length;
fileInfo.position = 0;
GifAccessor gifAccessor(fileInfo);
- if( gifAccessor.gif )
+ if(gifAccessor.gif)
{
// get the gif "screen size" (the actual image size)
prop.w = gifAccessor.gif->SWidth;
prop.h = gifAccessor.gif->SHeight;
// if size is invalid - abort here
- if( (prop.w < 1) || (prop.h < 1) || (prop.w > IMG_MAX_SIZE) || (prop.h > IMG_MAX_SIZE) || IMG_TOO_BIG(prop.w, prop.h) )
+ if((prop.w < 1) || (prop.h < 1) || (prop.w > IMG_MAX_SIZE) || (prop.h > IMG_MAX_SIZE) || IMG_TOO_BIG(prop.w, prop.h))
{
- if( IMG_TOO_BIG(prop.w, prop.h) )
+ if(IMG_TOO_BIG(prop.w, prop.h))
{
success = false;
DALI_LOG_ERROR("LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
else
{
// walk through gif records in file to figure out info
- success=true;
+ success = true;
do
{
- if( DGifGetRecordType(gifAccessor.gif, &rec) == GIF_ERROR )
+ if(DGifGetRecordType(gifAccessor.gif, &rec) == GIF_ERROR)
{
// if we have a gif that ends part way through a sequence
// (or animation) consider it valid and just break - no error
- if( imageNumber <= 1 )
+ if(imageNumber <= 1)
{
- success=true;
+ success = true;
}
else
{
- success=false;
+ success = false;
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
}
break;
}
// get image description section
- if( rec == IMAGE_DESC_RECORD_TYPE )
+ if(rec == IMAGE_DESC_RECORD_TYPE)
{
- int img_code;
- GifByteType *img;
+ int img_code;
+ GifByteType* img;
// get image desc
- if( DGifGetImageDesc(gifAccessor.gif) == GIF_ERROR )
+ if(DGifGetImageDesc(gifAccessor.gif) == GIF_ERROR)
{
- success=false;
+ success = false;
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
break;
}
// skip decoding and just walk image to next
- if( DGifGetCode(gifAccessor.gif, &img_code, &img) == GIF_ERROR )
+ if(DGifGetCode(gifAccessor.gif, &img_code, &img) == GIF_ERROR)
{
- success=false;
+ success = false;
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
break;
}
// skip till next...
- while( img )
+ while(img)
{
img = NULL;
- DGifGetCodeNext( gifAccessor.gif, &img );
+ DGifGetCodeNext(gifAccessor.gif, &img);
}
// store geometry in the last frame info data
- if( frameInfo )
+ if(frameInfo)
{
- StoreFrameInfo( gifAccessor.gif, frameInfo );
- CheckTransparency( full, frameInfo, prop.w, prop.h );
+ StoreFrameInfo(gifAccessor.gif, frameInfo);
+ CheckTransparency(full, frameInfo, prop.w, prop.h);
}
// or if we dont have a frameInfo entry - create one even for stills
else
{
// allocate and save frame with field data
- frameInfo = NewFrame( animated, -1, 0, 0, imageNumber + 1 );
- if (!frameInfo)
+ frameInfo = NewFrame(animated, -1, 0, 0, imageNumber + 1);
+ if(!frameInfo)
{
- success=false;
+ success = false;
DALI_LOG_ERROR("LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
break;
}
// store geometry info from gif image
- StoreFrameInfo( gifAccessor.gif, frameInfo );
+ StoreFrameInfo(gifAccessor.gif, frameInfo);
// check for transparency/alpha
- CheckTransparency( full, frameInfo, prop.w, prop.h );
+ CheckTransparency(full, frameInfo, prop.w, prop.h);
}
imageNumber++;
}
// we have an extension code block - for animated gifs for sure
- else if( rec == EXTENSION_RECORD_TYPE )
+ else if(rec == EXTENSION_RECORD_TYPE)
{
- int ext_code;
- GifByteType *ext = NULL;
+ int ext_code;
+ GifByteType* ext = NULL;
// get the first extension entry
- DGifGetExtension( gifAccessor.gif, &ext_code, &ext );
- while( ext )
+ DGifGetExtension(gifAccessor.gif, &ext_code, &ext);
+ while(ext)
{
// graphic control extension - for animated gif data
// and transparent index + flag
- if( ext_code == 0xf9 )
+ if(ext_code == 0xf9)
{
// create frame and store it in image
int transparencyIndex = (ext[1] & 1) ? ext[4] : -1;
- int disposeMode = (ext[1] >> 2) & 0x7;
- int delay = (int(ext[3]) << 8) | int(ext[2]);
- frameInfo = NewFrame(animated, transparencyIndex, disposeMode, delay, imageNumber + 1);
- if( !frameInfo )
+ int disposeMode = (ext[1] >> 2) & 0x7;
+ int delay = (int(ext[3]) << 8) | int(ext[2]);
+ frameInfo = NewFrame(animated, transparencyIndex, disposeMode, delay, imageNumber + 1);
+ if(!frameInfo)
{
- success=false;
+ success = false;
DALI_LOG_ERROR("LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
break;
}
}
// netscape extension indicating loop count.
- else if( ext_code == 0xff ) /* application extension */
+ else if(ext_code == 0xff) /* application extension */
{
- if( !strncmp(reinterpret_cast<char *>(&ext[1]), "NETSCAPE2.0", 11) ||
- !strncmp(reinterpret_cast<char *>(&ext[1]), "ANIMEXTS1.0", 11) )
+ if(!strncmp(reinterpret_cast<char*>(&ext[1]), "NETSCAPE2.0", 11) ||
+ !strncmp(reinterpret_cast<char*>(&ext[1]), "ANIMEXTS1.0", 11))
{
ext = NULL;
- DGifGetExtensionNext( gifAccessor.gif, &ext );
- if( ext[1] == 0x01 )
+ DGifGetExtensionNext(gifAccessor.gif, &ext);
+ if(ext[1] == 0x01)
{
loopCount = (int(ext[3]) << 8) | int(ext[2]);
- if( loopCount > 0 )
+ if(loopCount > 0)
{
loopCount++;
}
// and continue onto the next extension entry
ext = NULL;
- DGifGetExtensionNext( gifAccessor.gif, &ext );
+ DGifGetExtensionNext(gifAccessor.gif, &ext);
}
}
- } while( rec != TERMINATE_RECORD_TYPE && success );
+ } while(rec != TERMINATE_RECORD_TYPE && success);
- if( success )
+ if(success)
{
// if the gif main says we have more than one image or our image counting
// says so, then this image is animated - indicate this
- if( (gifAccessor.gif->ImageCount > 1) || (imageNumber > 1) )
+ if((gifAccessor.gif->ImageCount > 1) || (imageNumber > 1))
{
- animated.animated = 1;
+ animated.animated = 1;
animated.loopCount = loopCount;
}
- animated.frameCount = std::min( gifAccessor.gif->ImageCount, imageNumber );
+ animated.frameCount = std::min(gifAccessor.gif->ImageCount, imageNumber);
- if( !full )
+ if(!full)
{
prop.alpha = 1;
}
* @param[out] error Error code
* @return The true or false whether reading was successful or not.
*/
-bool ReadNextFrame( LoaderInfo &loaderInfo, ImageProperties &prop, // use for w and h
- unsigned char *pixels, int *error )
+bool ReadNextFrame(LoaderInfo& loaderInfo, ImageProperties& prop, // use for w and h
+ unsigned char* pixels,
+ int* error)
{
- GifAnimationData &animated = loaderInfo.animated;
- LoaderInfo::FileData &fileData = loaderInfo.fileData;
- bool ret = false;
- GifRecordType rec;
- int index = 0, imageNumber = 0;
- FrameInfo *frameInfo;
- ImageFrame *frame = NULL;
- ImageFrame *lastPreservedFrame = NULL;
+ GifAnimationData& animated = loaderInfo.animated;
+ LoaderInfo::FileData& fileData = loaderInfo.fileData;
+ bool ret = false;
+ GifRecordType rec;
+ int index = 0, imageNumber = 0;
+ FrameInfo* frameInfo;
+ ImageFrame* frame = NULL;
+ ImageFrame* lastPreservedFrame = NULL;
index = animated.currentFrame;
// if index is invalid for animated image - error out
- if ((animated.animated) && ((index <= 0) || (index > animated.frameCount)))
+ if((animated.animated) && ((index <= 0) || (index > animated.frameCount)))
{
DALI_LOG_ERROR("LOAD_ERROR_GENERIC");
return false;
}
// find the given frame index
- frame = FindFrame( animated, index );
- if( !frame )
+ frame = FindFrame(animated, index);
+ if(!frame)
{
DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE");
return false;
}
- else if( !(frame->loaded) || !(frame->data) )
+ else if(!(frame->loaded) || !(frame->data))
{
// if we want to go backwards, we likely need/want to re-decode from the
// start as we have nothing to build on. If there is a gif, imageNumber
// has been set already.
- if( loaderInfo.gifAccessor && loaderInfo.imageNumber > 0)
+ if(loaderInfo.gifAccessor && loaderInfo.imageNumber > 0)
{
- if( (index > 0) && (index < loaderInfo.imageNumber) && (animated.animated) )
+ if((index > 0) && (index < loaderInfo.imageNumber) && (animated.animated))
{
loaderInfo.gifAccessor.reset();
loaderInfo.imageNumber = 0;
}
// actually ask libgif to open the file
- if( !loaderInfo.gifAccessor )
+ if(!loaderInfo.gifAccessor)
{
- loaderInfo.fileInfo.map = fileData.globalMap ;
- loaderInfo.fileInfo.length = fileData.length;
+ loaderInfo.fileInfo.map = fileData.globalMap;
+ loaderInfo.fileInfo.length = fileData.length;
loaderInfo.fileInfo.position = 0;
- if( !loaderInfo.fileInfo.map )
+ if(!loaderInfo.fileInfo.map)
{
DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE");
return false;
}
std::unique_ptr<GifAccessor> gifAccessor = std::make_unique<GifAccessor>(loaderInfo.fileInfo);
- if( !gifAccessor->gif )
+ if(!gifAccessor->gif)
{
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
return false;
// walk through gif records in file to figure out info
do
{
- if( DGifGetRecordType( loaderInfo.gifAccessor->gif, &rec ) == GIF_ERROR )
+ if(DGifGetRecordType(loaderInfo.gifAccessor->gif, &rec) == GIF_ERROR)
{
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
return false;
}
- if( rec == EXTENSION_RECORD_TYPE )
+ if(rec == EXTENSION_RECORD_TYPE)
{
- int ext_code;
- GifByteType *ext = NULL;
- DGifGetExtension( loaderInfo.gifAccessor->gif, &ext_code, &ext );
+ int ext_code;
+ GifByteType* ext = NULL;
+ DGifGetExtension(loaderInfo.gifAccessor->gif, &ext_code, &ext);
- while( ext )
+ while(ext)
{
ext = NULL;
- DGifGetExtensionNext( loaderInfo.gifAccessor->gif, &ext );
+ DGifGetExtensionNext(loaderInfo.gifAccessor->gif, &ext);
}
}
// get image description section
- else if( rec == IMAGE_DESC_RECORD_TYPE )
+ else if(rec == IMAGE_DESC_RECORD_TYPE)
{
- int xin = 0, yin = 0, x = 0, y = 0, w = 0, h = 0;
- int img_code;
- GifByteType *img;
- ImageFrame *previousFrame = NULL;
- ImageFrame *thisFrame = NULL;
+ int xin = 0, yin = 0, x = 0, y = 0, w = 0, h = 0;
+ int img_code;
+ GifByteType* img;
+ ImageFrame* previousFrame = NULL;
+ ImageFrame* thisFrame = NULL;
// get image desc
- if( DGifGetImageDesc(loaderInfo.gifAccessor->gif) == GIF_ERROR )
+ if(DGifGetImageDesc(loaderInfo.gifAccessor->gif) == GIF_ERROR)
{
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
return false;
// get the previous frame entry AND the current one to fill in
previousFrame = FindFrame(animated, imageNumber - 1);
- thisFrame = FindFrame(animated, imageNumber);
+ thisFrame = FindFrame(animated, imageNumber);
// if we have a frame AND we're animated AND we have no data...
- if( (thisFrame) && (!thisFrame->data) && (animated.animated) )
+ if((thisFrame) && (!thisFrame->data) && (animated.animated))
{
bool first = false;
// allocate it
thisFrame->data = new uint32_t[prop.w * prop.h];
- if( !thisFrame->data )
+ if(!thisFrame->data)
{
DALI_LOG_ERROR("LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
return false;
}
// if we have no prior frame OR prior frame data... empty
- if( (!previousFrame) || (!previousFrame->data) )
+ if((!previousFrame) || (!previousFrame->data))
{
- first = true;
+ first = true;
frameInfo = &(thisFrame->info);
- memset( thisFrame->data, 0, prop.w * prop.h * sizeof(uint32_t) );
+ memset(thisFrame->data, 0, prop.w * prop.h * sizeof(uint32_t));
}
// we have a prior frame to copy data from...
else
{
- frameInfo = &( previousFrame->info );
+ frameInfo = &(previousFrame->info);
// fix coords of sub image in case it goes out...
- ClipCoordinates( prop.w, prop.h, &xin, &yin,
- frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h,
- &x, &y, &w, &h );
+ ClipCoordinates(prop.w, prop.h, &xin, &yin, frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h, &x, &y, &w, &h);
// if dispose mode is not restore - then copy pre frame
- if( frameInfo->dispose != DISPOSE_PREVIOUS )
+ if(frameInfo->dispose != DISPOSE_PREVIOUS)
{
- memcpy( thisFrame->data, previousFrame->data, prop.w * prop.h * sizeof(uint32_t) );
+ memcpy(thisFrame->data, previousFrame->data, prop.w * prop.h * sizeof(uint32_t));
}
// if dispose mode is "background" then fill with bg
- if( frameInfo->dispose == DISPOSE_BACKGROUND )
+ if(frameInfo->dispose == DISPOSE_BACKGROUND)
{
- FillFrame( thisFrame->data, prop.w, loaderInfo.gifAccessor->gif, frameInfo, x, y, w, h );
+ FillFrame(thisFrame->data, prop.w, loaderInfo.gifAccessor->gif, frameInfo, x, y, w, h);
}
- else if( frameInfo->dispose == DISPOSE_PREVIOUS ) // GIF_DISPOSE_RESTORE
+ else if(frameInfo->dispose == DISPOSE_PREVIOUS) // GIF_DISPOSE_RESTORE
{
int prevIndex = 2;
do
{
// Find last preserved frame.
- lastPreservedFrame = FindFrame( animated, imageNumber - prevIndex );
- if( ! lastPreservedFrame )
+ lastPreservedFrame = FindFrame(animated, imageNumber - prevIndex);
+ if(!lastPreservedFrame)
{
- DALI_LOG_ERROR( "LOAD_ERROR_LAST_PRESERVED_FRAME_NOT_FOUND" );
+ DALI_LOG_ERROR("LOAD_ERROR_LAST_PRESERVED_FRAME_NOT_FOUND");
return false;
}
prevIndex++;
- } while( lastPreservedFrame && lastPreservedFrame->info.dispose == DISPOSE_PREVIOUS );
+ } while(lastPreservedFrame && lastPreservedFrame->info.dispose == DISPOSE_PREVIOUS);
- if ( lastPreservedFrame )
+ if(lastPreservedFrame)
{
- memcpy( thisFrame->data, lastPreservedFrame->data, prop.w * prop.h * sizeof(uint32_t) );
+ memcpy(thisFrame->data, lastPreservedFrame->data, prop.w * prop.h * sizeof(uint32_t));
}
}
}
// now draw this frame on top
- frameInfo = &( thisFrame->info );
- ClipCoordinates( prop.w, prop.h, &xin, &yin,
- frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h,
- &x, &y, &w, &h );
- if( !DecodeImage( loaderInfo.gifAccessor->gif, thisFrame->data, prop.w,
- xin, yin, frameInfo->transparent,
- x, y, w, h, first) )
+ frameInfo = &(thisFrame->info);
+ ClipCoordinates(prop.w, prop.h, &xin, &yin, frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h, &x, &y, &w, &h);
+ if(!DecodeImage(loaderInfo.gifAccessor->gif, thisFrame->data, prop.w, xin, yin, frameInfo->transparent, x, y, w, h, first))
{
DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE");
return false;
// mark as loaded and done
thisFrame->loaded = true;
- FlushFrames( animated, prop.w, prop.h, thisFrame, previousFrame, lastPreservedFrame );
+ FlushFrames(animated, prop.w, prop.h, thisFrame, previousFrame, lastPreservedFrame);
}
// if we have a frame BUT the image is not animated. different
// path
- else if( (thisFrame) && (!thisFrame->data) && (!animated.animated) )
+ else if((thisFrame) && (!thisFrame->data) && (!animated.animated))
{
// if we don't have the data decoded yet - decode it
- if( (!thisFrame->loaded) || (!thisFrame->data) )
+ if((!thisFrame->loaded) || (!thisFrame->data))
{
// use frame info but we WONT allocate frame pixels
- frameInfo = &( thisFrame->info );
- ClipCoordinates( prop.w, prop.h, &xin, &yin,
- frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h,
- &x, &y, &w, &h );
+ frameInfo = &(thisFrame->info);
+ ClipCoordinates(prop.w, prop.h, &xin, &yin, frameInfo->x, frameInfo->y, frameInfo->w, frameInfo->h, &x, &y, &w, &h);
// clear out all pixels
- FillFrame( reinterpret_cast<uint32_t *>(pixels), prop.w, loaderInfo.gifAccessor->gif,
- frameInfo, 0, 0, prop.w, prop.h );
+ FillFrame(reinterpret_cast<uint32_t*>(pixels), prop.w, loaderInfo.gifAccessor->gif, frameInfo, 0, 0, prop.w, prop.h);
// and decode the gif with overwriting
- if( !DecodeImage( loaderInfo.gifAccessor->gif, reinterpret_cast<uint32_t *>(pixels),
- prop.w, xin, yin, frameInfo->transparent, x, y, w, h, true) )
+ if(!DecodeImage(loaderInfo.gifAccessor->gif, reinterpret_cast<uint32_t*>(pixels), prop.w, xin, yin, frameInfo->transparent, x, y, w, h, true))
{
DALI_LOG_ERROR("LOAD_ERROR_CORRUPT_FILE");
return false;
else
{
// skip decoding and just walk image to next
- if( DGifGetCode( loaderInfo.gifAccessor->gif, &img_code, &img ) == GIF_ERROR )
+ if(DGifGetCode(loaderInfo.gifAccessor->gif, &img_code, &img) == GIF_ERROR)
{
DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT");
return false;
}
- while( img )
+ while(img)
{
img = NULL;
- DGifGetCodeNext( loaderInfo.gifAccessor->gif, &img );
+ DGifGetCodeNext(loaderInfo.gifAccessor->gif, &img);
}
}
imageNumber++;
// if we found the image we wanted - get out of here
- if( imageNumber > index )
+ if(imageNumber > index)
{
break;
}
}
- } while( rec != TERMINATE_RECORD_TYPE );
+ } while(rec != TERMINATE_RECORD_TYPE);
// if we are at the end of the animation or not animated, close file
loaderInfo.imageNumber = imageNumber;
- if( (animated.frameCount <= 1) || (rec == TERMINATE_RECORD_TYPE) )
+ if((animated.frameCount <= 1) || (rec == TERMINATE_RECORD_TYPE))
{
loaderInfo.gifAccessor.reset();
loaderInfo.imageNumber = 0;
// no errors in header scan etc. so set err and return value
*error = 0;
- ret = true;
+ ret = true;
// if it was an animated image we need to copy the data to the
// pixels for the image from the frame holding the data
- if( animated.animated && frame->data )
+ if(animated.animated && frame->data)
{
- memcpy( pixels, frame->data, prop.w * prop.h * sizeof( uint32_t ) );
+ memcpy(pixels, frame->data, prop.w * prop.h * sizeof(uint32_t));
}
return ret;
struct GifLoading::Impl
{
public:
- Impl( const std::string& url, bool isLocalResource )
- : mUrl( url )
+ Impl(const std::string& url, bool isLocalResource)
+ : mUrl(url)
{
loaderInfo.gifAccessor = nullptr;
int error;
- loaderInfo.fileData.fileName = mUrl.c_str();
+ loaderInfo.fileData.fileName = mUrl.c_str();
loaderInfo.fileData.isLocalResource = isLocalResource;
- ReadHeader( loaderInfo, imageProperties, &error );
+ ReadHeader(loaderInfo, imageProperties, &error);
}
// Moveable but not copyable
- Impl( const Impl& ) = delete;
- Impl& operator=( const Impl& ) = delete;
- Impl( Impl&& ) = default;
- Impl& operator=( Impl&& ) = default;
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+ Impl(Impl&&) = default;
+ Impl& operator=(Impl&&) = default;
- std::string mUrl;
- LoaderInfo loaderInfo;
+ std::string mUrl;
+ LoaderInfo loaderInfo;
ImageProperties imageProperties;
};
-AnimatedImageLoadingPtr GifLoading::New( const std::string &url, bool isLocalResource )
+AnimatedImageLoadingPtr GifLoading::New(const std::string& url, bool isLocalResource)
{
- return AnimatedImageLoadingPtr( new GifLoading( url, isLocalResource ) );
+ return AnimatedImageLoadingPtr(new GifLoading(url, isLocalResource));
}
-GifLoading::GifLoading( const std::string &url, bool isLocalResource )
-: mImpl( new GifLoading::Impl( url, isLocalResource ) )
+GifLoading::GifLoading(const std::string& url, bool isLocalResource)
+: mImpl(new GifLoading::Impl(url, isLocalResource))
{
}
-
GifLoading::~GifLoading()
{
delete mImpl;
}
-bool GifLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData> &pixelData )
+bool GifLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData)
{
- int error;
+ int error;
bool ret = false;
- const int bufferSize = mImpl->imageProperties.w * mImpl->imageProperties.h * sizeof( uint32_t );
+ const int bufferSize = mImpl->imageProperties.w * mImpl->imageProperties.h * sizeof(uint32_t);
- DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameStartIndex:%d, count:%d )\n", frameStartIndex, count );
+ DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameStartIndex:%d, count:%d )\n", frameStartIndex, count);
- for( int i = 0; i < count; ++i )
+ for(int i = 0; i < count; ++i)
{
- auto pixelBuffer = new unsigned char[ bufferSize ];
+ auto pixelBuffer = new unsigned char[bufferSize];
- mImpl->loaderInfo.animated.currentFrame = 1 + ( (frameStartIndex + i) % mImpl->loaderInfo.animated.frameCount );
+ mImpl->loaderInfo.animated.currentFrame = 1 + ((frameStartIndex + i) % mImpl->loaderInfo.animated.frameCount);
- if( ReadNextFrame( mImpl->loaderInfo, mImpl->imageProperties, pixelBuffer, &error ) )
+ if(ReadNextFrame(mImpl->loaderInfo, mImpl->imageProperties, pixelBuffer, &error))
{
- if( pixelBuffer )
+ if(pixelBuffer)
{
- pixelData.push_back( Dali::PixelData::New( pixelBuffer, bufferSize,
- mImpl->imageProperties.w, mImpl->imageProperties.h,
- Dali::Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY) );
+ pixelData.push_back(Dali::PixelData::New(pixelBuffer, bufferSize, mImpl->imageProperties.w, mImpl->imageProperties.h, Dali::Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY));
ret = true;
}
}
return ret;
}
-Dali::Devel::PixelBuffer GifLoading::LoadFrame( uint32_t frameIndex )
+Dali::Devel::PixelBuffer GifLoading::LoadFrame(uint32_t frameIndex)
{
- int error;
+ int error;
Dali::Devel::PixelBuffer pixelBuffer;
- DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "LoadFrame( frameIndex:%d )\n", frameIndex );
+ DALI_LOG_INFO(gGifLoadingLogFilter, Debug::Concise, "LoadFrame( frameIndex:%d )\n", frameIndex);
- pixelBuffer = Dali::Devel::PixelBuffer::New( mImpl->imageProperties.w, mImpl->imageProperties.h, Dali::Pixel::RGBA8888 );
+ pixelBuffer = Dali::Devel::PixelBuffer::New(mImpl->imageProperties.w, mImpl->imageProperties.h, Dali::Pixel::RGBA8888);
- mImpl->loaderInfo.animated.currentFrame = 1 + ( frameIndex % mImpl->loaderInfo.animated.frameCount );
- ReadNextFrame( mImpl->loaderInfo, mImpl->imageProperties, pixelBuffer.GetBuffer(), &error );
+ mImpl->loaderInfo.animated.currentFrame = 1 + (frameIndex % mImpl->loaderInfo.animated.frameCount);
+ ReadNextFrame(mImpl->loaderInfo, mImpl->imageProperties, pixelBuffer.GetBuffer(), &error);
- if( error != 0 )
+ if(error != 0)
{
pixelBuffer = Dali::Devel::PixelBuffer();
}
ImageDimensions GifLoading::GetImageSize() const
{
- return ImageDimensions( mImpl->imageProperties.w, mImpl->imageProperties.h );
+ return ImageDimensions(mImpl->imageProperties.w, mImpl->imageProperties.h);
}
uint32_t GifLoading::GetImageCount() const
return mImpl->loaderInfo.animated.frameCount;
}
-uint32_t GifLoading::GetFrameInterval( uint32_t frameIndex ) const
+uint32_t GifLoading::GetFrameInterval(uint32_t frameIndex) const
{
return mImpl->loaderInfo.animated.frames[frameIndex].info.delay * 10;
}
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace
{
const unsigned int MIN_HTTP_URL_LENGTH = 12; // assume we have a least http://xx/yy
-const char HTTP_URL[] = "http://";
-const char HTTPS_URL[] = "https://";
-}
+const char HTTP_URL[] = "http://";
+const char HTTPS_URL[] = "https://";
+} // namespace
-bool Network::IsHttpUrl( const std::string& path )
+bool Network::IsHttpUrl(const std::string& path)
{
- if( path.size() <= MIN_HTTP_URL_LENGTH )
- {
- return false;
- }
-
- if( ( strncasecmp( path.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) == 0 ) ||
- ( strncasecmp( path.c_str(), HTTPS_URL, sizeof(HTTPS_URL) -1 ) == 0 ) )
- {
- return true;
- }
-
- return false;
+ if(path.size() <= MIN_HTTP_URL_LENGTH)
+ {
+ return false;
+ }
+
+ if((strncasecmp(path.c_str(), HTTP_URL, sizeof(HTTP_URL) - 1) == 0) ||
+ (strncasecmp(path.c_str(), HTTPS_URL, sizeof(HTTPS_URL) - 1) == 0))
+ {
+ return true;
+ }
+
+ return false;
}
-} // TizenPlatform
+} // namespace TizenPlatform
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2018 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.
#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
#include <dali/integration-api/debug.h>
+#include <dlfcn.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace ImageLoaderPluginProxy
{
+static const char* DEFAULT_OBJECT_NAME("libdali2-image-loader-plugin.so");
-
-static const char * DEFAULT_OBJECT_NAME( "libdali2-image-loader-plugin.so" );
-
-static bool mInitializeAttempted = false;
-static void* mLibHandle = NULL;
-static CreateImageLoaderPlugin* mCreatePluginFunctionPtr = NULL;
+static bool mInitializeAttempted = false;
+static void* mLibHandle = NULL;
+static CreateImageLoaderPlugin* mCreatePluginFunctionPtr = NULL;
static DestroyImageLoaderPlugin* mDestroyImageLoaderPluginPtr = NULL;
-static Dali::ImageLoaderPlugin* mImageLoaderPlugin = NULL;
+static Dali::ImageLoaderPlugin* mImageLoaderPlugin = NULL;
#if defined(DEBUG_ENABLED)
/**
* LOG_IMAGE_LOADER_PLUGIN=3 dali-demo #< on, verbose
* </code>
*/
-Debug::Filter* gImageLoaderPluginLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_IMAGE_LOADER_PLUGIN" );
+Debug::Filter* gImageLoaderPluginLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMAGE_LOADER_PLUGIN");
#endif
void Initialize()
{
// Only attempt to load dll once
char* error = NULL;
- if ( !mInitializeAttempted )
+ if(!mInitializeAttempted)
{
mInitializeAttempted = true;
- mLibHandle = dlopen( DEFAULT_OBJECT_NAME, RTLD_LAZY );
- error = dlerror();
- if( !mLibHandle )
+ mLibHandle = dlopen(DEFAULT_OBJECT_NAME, RTLD_LAZY);
+ error = dlerror();
+ if(!mLibHandle)
{
- DALI_LOG_INFO( gImageLoaderPluginLogFilter, Dali::Integration::Log::Verbose, "Cannot load dali image loading plugin library error: %s\n", error );
+ DALI_LOG_INFO(gImageLoaderPluginLogFilter, Dali::Integration::Log::Verbose, "Cannot load dali image loading plugin library error: %s\n", error);
return;
}
// load plugin
- mCreatePluginFunctionPtr = reinterpret_cast<CreateImageLoaderPlugin*>( dlsym( mLibHandle, "CreateImageLoaderPlugin" ) );
- error = dlerror();
- if( !mCreatePluginFunctionPtr )
+ mCreatePluginFunctionPtr = reinterpret_cast<CreateImageLoaderPlugin*>(dlsym(mLibHandle, "CreateImageLoaderPlugin"));
+ error = dlerror();
+ if(!mCreatePluginFunctionPtr)
{
- DALI_LOG_ERROR("Cannot load symbol CreateImageLoaderPlugin(): %s\n", error );
+ DALI_LOG_ERROR("Cannot load symbol CreateImageLoaderPlugin(): %s\n", error);
return;
}
- mDestroyImageLoaderPluginPtr = reinterpret_cast<DestroyImageLoaderPlugin*>( dlsym( mLibHandle, "DestroyImageLoaderPlugin" ) );
- error = dlerror();
- if( !mDestroyImageLoaderPluginPtr )
+ mDestroyImageLoaderPluginPtr = reinterpret_cast<DestroyImageLoaderPlugin*>(dlsym(mLibHandle, "DestroyImageLoaderPlugin"));
+ error = dlerror();
+ if(!mDestroyImageLoaderPluginPtr)
{
- DALI_LOG_ERROR("Cannot load symbol DestroyImageLoaderPlugin(): %s\n", error );
+ DALI_LOG_ERROR("Cannot load symbol DestroyImageLoaderPlugin(): %s\n", error);
return;
}
-
mImageLoaderPlugin = mCreatePluginFunctionPtr();
- error = dlerror();
- if( !mImageLoaderPlugin )
+ error = dlerror();
+ if(!mImageLoaderPlugin)
{
- DALI_LOG_ERROR("Call to function CreateImageLoaderPlugin() failed : %s\n", error );
+ DALI_LOG_ERROR("Call to function CreateImageLoaderPlugin() failed : %s\n", error);
return;
}
}
void Destroy()
{
- if( mImageLoaderPlugin && mDestroyImageLoaderPluginPtr )
+ if(mImageLoaderPlugin && mDestroyImageLoaderPluginPtr)
{
- mDestroyImageLoaderPluginPtr( mImageLoaderPlugin );
+ mDestroyImageLoaderPluginPtr(mImageLoaderPlugin);
mImageLoaderPlugin = NULL;
}
}
-const ImageLoader::BitmapLoader* BitmapLoaderLookup( const std::string& filename )
+const ImageLoader::BitmapLoader* BitmapLoaderLookup(const std::string& filename)
{
- if( mImageLoaderPlugin )
+ if(mImageLoaderPlugin)
{
- const ImageLoader::BitmapLoader* data = mImageLoaderPlugin->BitmapLoaderLookup( filename );
+ const ImageLoader::BitmapLoader* data = mImageLoaderPlugin->BitmapLoaderLookup(filename);
return data;
}
return NULL;
} // namespace ImageLoaderPluginProxy
-
} // namespace Adaptor
} // namespace Internal
/*
- * Copyright (c) 2017 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.
#include <dali/devel-api/common/ref-counted-dali-vector.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
+#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
+#include <dali/internal/imaging/common/image-operations.h>
#include <dali/internal/imaging/common/loader-astc.h>
#include <dali/internal/imaging/common/loader-bmp.h>
#include <dali/internal/imaging/common/loader-gif.h>
#include <dali/internal/imaging/common/loader-ktx.h>
#include <dali/internal/imaging/common/loader-png.h>
#include <dali/internal/imaging/common/loader-wbmp.h>
-#include <dali/internal/imaging/common/image-operations.h>
-#include <dali/devel-api/adaptor-framework/image-loader-input.h>
-#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
#include <dali/internal/system/common/file-reader.h>
using namespace Dali::Integration;
{
namespace TizenPlatform
{
-
namespace
{
#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_IMAGE_LOADING" );
+Integration::Log::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_IMAGE_LOADING");
#endif
static unsigned int gMaxTextureSize = 4096;
* A lookup table containing all the bitmap loaders with the appropriate information.
* Has to be in sync with enum FileFormats
*/
+// clang-format off
const Dali::ImageLoader::BitmapLoader BITMAP_LOADER_LOOKUP_TABLE[FORMAT_TOTAL_COUNT] =
-{
- { Png::MAGIC_BYTE_1, Png::MAGIC_BYTE_2, LoadBitmapFromPng, LoadPngHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
- { Jpeg::MAGIC_BYTE_1, Jpeg::MAGIC_BYTE_2, LoadBitmapFromJpeg, LoadJpegHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
- { Bmp::MAGIC_BYTE_1, Bmp::MAGIC_BYTE_2, LoadBitmapFromBmp, LoadBmpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
- { Gif::MAGIC_BYTE_1, Gif::MAGIC_BYTE_2, LoadBitmapFromGif, LoadGifHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
- { Ktx::MAGIC_BYTE_1, Ktx::MAGIC_BYTE_2, LoadBitmapFromKtx, LoadKtxHeader, Bitmap::BITMAP_COMPRESSED },
- { Astc::MAGIC_BYTE_1, Astc::MAGIC_BYTE_2, LoadBitmapFromAstc, LoadAstcHeader, Bitmap::BITMAP_COMPRESSED },
- { Ico::MAGIC_BYTE_1, Ico::MAGIC_BYTE_2, LoadBitmapFromIco, LoadIcoHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
- { 0x0, 0x0, LoadBitmapFromWbmp, LoadWbmpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS },
-};
+ {
+ {Png::MAGIC_BYTE_1, Png::MAGIC_BYTE_2, LoadBitmapFromPng, LoadPngHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+ {Jpeg::MAGIC_BYTE_1, Jpeg::MAGIC_BYTE_2, LoadBitmapFromJpeg, LoadJpegHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+ {Bmp::MAGIC_BYTE_1, Bmp::MAGIC_BYTE_2, LoadBitmapFromBmp, LoadBmpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+ {Gif::MAGIC_BYTE_1, Gif::MAGIC_BYTE_2, LoadBitmapFromGif, LoadGifHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+ {Ktx::MAGIC_BYTE_1, Ktx::MAGIC_BYTE_2, LoadBitmapFromKtx, LoadKtxHeader, Bitmap::BITMAP_COMPRESSED },
+ {Astc::MAGIC_BYTE_1, Astc::MAGIC_BYTE_2, LoadBitmapFromAstc, LoadAstcHeader, Bitmap::BITMAP_COMPRESSED },
+ {Ico::MAGIC_BYTE_1, Ico::MAGIC_BYTE_2, LoadBitmapFromIco, LoadIcoHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+ {0x0, 0x0, LoadBitmapFromWbmp, LoadWbmpHeader, Bitmap::BITMAP_2D_PACKED_PIXELS},
+ };
+// clang-format on
const unsigned int MAGIC_LENGTH = 2;
struct FormatExtension
{
const std::string extension;
- FileFormats format;
+ FileFormats format;
};
+// clang-format off
const FormatExtension FORMAT_EXTENSIONS[] =
-{
- { ".png", FORMAT_PNG },
- { ".jpg", FORMAT_JPEG },
- { ".bmp", FORMAT_BMP },
- { ".gif", FORMAT_GIF },
- { ".ktx", FORMAT_KTX },
- { ".astc", FORMAT_ASTC },
- { ".ico", FORMAT_ICO },
- { ".wbmp", FORMAT_WBMP }
-};
+ {
+ {".png", FORMAT_PNG },
+ {".jpg", FORMAT_JPEG},
+ {".bmp", FORMAT_BMP },
+ {".gif", FORMAT_GIF },
+ {".ktx", FORMAT_KTX },
+ {".astc", FORMAT_ASTC},
+ {".ico", FORMAT_ICO },
+ {".wbmp", FORMAT_WBMP}
+ };
+// clang-format on
const unsigned int FORMAT_EXTENSIONS_COUNT = sizeof(FORMAT_EXTENSIONS) / sizeof(FormatExtension);
-FileFormats GetFormatHint( const std::string& filename )
+FileFormats GetFormatHint(const std::string& filename)
{
FileFormats format = FORMAT_UNKNOWN;
- for ( unsigned int i = 0; i < FORMAT_EXTENSIONS_COUNT; ++i )
+ for(unsigned int i = 0; i < FORMAT_EXTENSIONS_COUNT; ++i)
{
unsigned int length = FORMAT_EXTENSIONS[i].extension.size();
- if ( ( filename.size() > length ) &&
- ( 0 == filename.compare( filename.size() - length, length, FORMAT_EXTENSIONS[i].extension ) ) )
+ if((filename.size() > length) &&
+ (0 == filename.compare(filename.size() - length, length, FORMAT_EXTENSIONS[i].extension)))
{
format = FORMAT_EXTENSIONS[i].format;
break;
* @param[out] profile The kind of bitmap to hold the bits loaded for the bitmap.
* @return true, if we can decode the image, false otherwise
*/
-bool GetBitmapLoaderFunctions( FILE *fp,
- FileFormats format,
- Dali::ImageLoader::LoadBitmapFunction& loader,
- Dali::ImageLoader::LoadBitmapHeaderFunction& header,
- Bitmap::Profile& profile,
- const std::string& filename )
+bool GetBitmapLoaderFunctions(FILE* fp,
+ FileFormats format,
+ Dali::ImageLoader::LoadBitmapFunction& loader,
+ Dali::ImageLoader::LoadBitmapHeaderFunction& header,
+ Bitmap::Profile& profile,
+ const std::string& filename)
{
unsigned char magic[MAGIC_LENGTH];
- size_t read = fread(magic, sizeof(unsigned char), MAGIC_LENGTH, fp);
+ size_t read = fread(magic, sizeof(unsigned char), MAGIC_LENGTH, fp);
// Reset to the start of the file.
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking to start of file\n");
}
- if (read != MAGIC_LENGTH)
+ if(read != MAGIC_LENGTH)
{
return false;
}
- bool loaderFound = false;
- const Dali::ImageLoader::BitmapLoader *lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
- Dali::ImageLoader::Input defaultInput( fp );
+ bool loaderFound = false;
+ const Dali::ImageLoader::BitmapLoader* lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
+ Dali::ImageLoader::Input defaultInput(fp);
// try plugin image loader
- const Dali::ImageLoader::BitmapLoader* data = Internal::Adaptor::ImageLoaderPluginProxy::BitmapLoaderLookup( filename );
- if( data != NULL )
+ const Dali::ImageLoader::BitmapLoader* data = Internal::Adaptor::ImageLoaderPluginProxy::BitmapLoaderLookup(filename);
+ if(data != NULL)
{
- lookupPtr = data;
- unsigned int width = 0;
+ lookupPtr = data;
+ unsigned int width = 0;
unsigned int height = 0;
- loaderFound = lookupPtr->header( fp, width, height );
+ loaderFound = lookupPtr->header(fp, width, height);
}
// try hinted format
- if ( false == loaderFound && format != FORMAT_UNKNOWN )
+ if(false == loaderFound && format != FORMAT_UNKNOWN)
{
lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + format;
- if ( format >= FORMAT_MAGIC_BYTE_COUNT ||
- ( lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1] ) )
+ if(format >= FORMAT_MAGIC_BYTE_COUNT ||
+ (lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1]))
{
- unsigned int width = 0;
+ unsigned int width = 0;
unsigned int height = 0;
- loaderFound = lookupPtr->header( fp, width, height );
+ loaderFound = lookupPtr->header(fp, width, height);
}
}
// then try to get a match with formats that have magic bytes
- if ( false == loaderFound )
+ if(false == loaderFound)
{
- for ( lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
- lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
- ++lookupPtr )
+ for(lookupPtr = BITMAP_LOADER_LOOKUP_TABLE;
+ lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
+ ++lookupPtr)
{
- if ( lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1] )
+ if(lookupPtr->magicByte1 == magic[0] && lookupPtr->magicByte2 == magic[1])
{
// to seperate ico file format and wbmp file format
- unsigned int width = 0;
+ unsigned int width = 0;
unsigned int height = 0;
- loaderFound = lookupPtr->header(fp, width, height);
+ loaderFound = lookupPtr->header(fp, width, height);
}
- if (loaderFound)
+ if(loaderFound)
{
break;
}
}
// finally try formats that do not use magic bytes
- if ( false == loaderFound )
+ if(false == loaderFound)
{
- for ( lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
- lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_TOTAL_COUNT;
- ++lookupPtr )
+ for(lookupPtr = BITMAP_LOADER_LOOKUP_TABLE + FORMAT_MAGIC_BYTE_COUNT;
+ lookupPtr < BITMAP_LOADER_LOOKUP_TABLE + FORMAT_TOTAL_COUNT;
+ ++lookupPtr)
{
// to seperate ico file format and wbmp file format
- unsigned int width = 0;
+ unsigned int width = 0;
unsigned int height = 0;
- loaderFound = lookupPtr->header(fp, width, height);
- if (loaderFound)
+ loaderFound = lookupPtr->header(fp, width, height);
+ if(loaderFound)
{
break;
}
}
// if a loader was found set the outputs
- if ( loaderFound )
+ if(loaderFound)
{
loader = lookupPtr->loader;
header = lookupPtr->header;
}
// Reset to the start of the file.
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking to start of file\n");
}
} // anonymous namespace
-
namespace ImageLoader
{
-
-bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer )
+bool ConvertStreamToBitmap(const BitmapResourceType& resource, std::string path, FILE* const fp, Dali::Devel::PixelBuffer& pixelBuffer)
{
- DALI_LOG_TRACE_METHOD( gLogFilter );
+ DALI_LOG_TRACE_METHOD(gLogFilter);
bool result = false;
- if (fp != NULL)
+ if(fp != NULL)
{
- Dali::ImageLoader::LoadBitmapFunction function;
+ Dali::ImageLoader::LoadBitmapFunction function;
Dali::ImageLoader::LoadBitmapHeaderFunction header;
Bitmap::Profile profile;
- if ( GetBitmapLoaderFunctions( fp,
- GetFormatHint( path ),
- function,
- header,
- profile,
- path ) )
+ if(GetBitmapLoaderFunctions(fp,
+ GetFormatHint(path),
+ function,
+ header,
+ profile,
+ path))
{
- const Dali::ImageLoader::ScalingParameters scalingParameters( resource.size, resource.scalingMode, resource.samplingMode );
- const Dali::ImageLoader::Input input( fp, scalingParameters, resource.orientationCorrection );
+ const Dali::ImageLoader::ScalingParameters scalingParameters(resource.size, resource.scalingMode, resource.samplingMode);
+ const Dali::ImageLoader::Input input(fp, scalingParameters, resource.orientationCorrection);
// Run the image type decoder:
- result = function( input, pixelBuffer );
+ result = function(input, pixelBuffer);
- if (!result)
+ if(!result)
{
- DALI_LOG_WARNING( "Unable to convert %s\n", path.c_str() );
+ DALI_LOG_WARNING("Unable to convert %s\n", path.c_str());
pixelBuffer.Reset();
}
- pixelBuffer = Internal::Platform::ApplyAttributesToBitmap( pixelBuffer, resource.size, resource.scalingMode, resource.samplingMode );
+ pixelBuffer = Internal::Platform::ApplyAttributesToBitmap(pixelBuffer, resource.size, resource.scalingMode, resource.samplingMode);
}
else
{
- DALI_LOG_WARNING( "Image Decoder for %s unavailable\n", path.c_str() );
+ DALI_LOG_WARNING("Image Decoder for %s unavailable\n", path.c_str());
}
}
return result;
}
-ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path )
+ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& path)
{
- ResourcePointer result;
+ ResourcePointer result;
Dali::Devel::PixelBuffer bitmap;
- Internal::Platform::FileReader fileReader( path );
- FILE * const fp = fileReader.GetFile();
- if( fp != NULL )
+ Internal::Platform::FileReader fileReader(path);
+ FILE* const fp = fileReader.GetFile();
+ if(fp != NULL)
{
bool success = ConvertStreamToBitmap(resource, path, fp, bitmap);
- if (success && bitmap)
+ if(success && bitmap)
{
Bitmap::Profile profile{Bitmap::Profile::BITMAP_2D_PACKED_PIXELS};
// For backward compatibility the Bitmap must be created
auto retval = Bitmap::New(profile, Dali::ResourcePolicy::OWNED_DISCARD);
- DALI_LOG_SET_OBJECT_STRING( retval, path );
+ DALI_LOG_SET_OBJECT_STRING(retval, path);
retval->GetPackedPixelsProfile()->ReserveBuffer(
- bitmap.GetPixelFormat(),
- bitmap.GetWidth(),
- bitmap.GetHeight(),
- bitmap.GetWidth(),
- bitmap.GetHeight()
- );
+ bitmap.GetPixelFormat(),
+ bitmap.GetWidth(),
+ bitmap.GetHeight(),
+ bitmap.GetWidth(),
+ bitmap.GetHeight());
auto& impl = Dali::GetImplementation(bitmap);
- std::copy( impl.GetBuffer(), impl.GetBuffer()+impl.GetBufferSize(), retval->GetBuffer());
+ std::copy(impl.GetBuffer(), impl.GetBuffer() + impl.GetBufferSize(), retval->GetBuffer());
result.Reset(retval);
}
}
}
///@ToDo: Rename GetClosestImageSize() functions. Make them use the orientation correction and scaling information. Requires jpeg loader to tell us about reorientation. [Is there still a requirement for this functionality at all?]
-ImageDimensions GetClosestImageSize( const std::string& filename,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection )
+ImageDimensions GetClosestImageSize(const std::string& filename,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection)
{
- unsigned int width = 0;
+ unsigned int width = 0;
unsigned int height = 0;
- Internal::Platform::FileReader fileReader( filename );
- FILE *fp = fileReader.GetFile();
- if (fp != NULL)
+ Internal::Platform::FileReader fileReader(filename);
+ FILE* fp = fileReader.GetFile();
+ if(fp != NULL)
{
- Dali::ImageLoader::LoadBitmapFunction loaderFunction;
+ Dali::ImageLoader::LoadBitmapFunction loaderFunction;
Dali::ImageLoader::LoadBitmapHeaderFunction headerFunction;
- Bitmap::Profile profile;
-
- if ( GetBitmapLoaderFunctions( fp,
- GetFormatHint(filename),
- loaderFunction,
- headerFunction,
- profile,
- filename ) )
+ Bitmap::Profile profile;
+
+ if(GetBitmapLoaderFunctions(fp,
+ GetFormatHint(filename),
+ loaderFunction,
+ headerFunction,
+ profile,
+ filename))
{
- const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
+ const Dali::ImageLoader::Input input(fp, Dali::ImageLoader::ScalingParameters(size, fittingMode, samplingMode), orientationCorrection);
- const bool read_res = headerFunction( input, width, height );
+ const bool read_res = headerFunction(input, width, height);
if(!read_res)
{
DALI_LOG_WARNING("Image Decoder failed to read header for %s\n", filename.c_str());
DALI_LOG_WARNING("Image Decoder for %s unavailable\n", filename.c_str());
}
}
- return ImageDimensions( width, height );
+ return ImageDimensions(width, height);
}
-ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection )
+ImageDimensions GetClosestImageSize(Integration::ResourcePointer resourceBuffer,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection)
{
- unsigned int width = 0;
+ unsigned int width = 0;
unsigned int height = 0;
// Get the blob of binary data that we need to decode:
- DALI_ASSERT_DEBUG( resourceBuffer );
- Dali::RefCountedVector<uint8_t>* const encodedBlob = reinterpret_cast<Dali::RefCountedVector<uint8_t>*>( resourceBuffer.Get() );
+ DALI_ASSERT_DEBUG(resourceBuffer);
+ Dali::RefCountedVector<uint8_t>* const encodedBlob = reinterpret_cast<Dali::RefCountedVector<uint8_t>*>(resourceBuffer.Get());
- if( encodedBlob != 0 )
+ if(encodedBlob != 0)
{
- if( encodedBlob->GetVector().Size() )
+ if(encodedBlob->GetVector().Size())
{
// Open a file handle on the memory buffer:
- Internal::Platform::FileReader fileReader( encodedBlob->GetVector() );
- FILE *fp = fileReader.GetFile();
- if ( fp != NULL )
+ Internal::Platform::FileReader fileReader(encodedBlob->GetVector());
+ FILE* fp = fileReader.GetFile();
+ if(fp != NULL)
{
- Dali::ImageLoader::LoadBitmapFunction loaderFunction;
+ Dali::ImageLoader::LoadBitmapFunction loaderFunction;
Dali::ImageLoader::LoadBitmapHeaderFunction headerFunction;
- Bitmap::Profile profile;
-
- if ( GetBitmapLoaderFunctions( fp,
- FORMAT_UNKNOWN,
- loaderFunction,
- headerFunction,
- profile,
- "" ) )
+ Bitmap::Profile profile;
+
+ if(GetBitmapLoaderFunctions(fp,
+ FORMAT_UNKNOWN,
+ loaderFunction,
+ headerFunction,
+ profile,
+ ""))
{
- const Dali::ImageLoader::Input input( fp, Dali::ImageLoader::ScalingParameters( size, fittingMode, samplingMode ), orientationCorrection );
- const bool read_res = headerFunction( input, width, height );
- if( !read_res )
+ const Dali::ImageLoader::Input input(fp, Dali::ImageLoader::ScalingParameters(size, fittingMode, samplingMode), orientationCorrection);
+ const bool read_res = headerFunction(input, width, height);
+ if(!read_res)
{
- DALI_LOG_WARNING( "Image Decoder failed to read header for resourceBuffer\n" );
+ DALI_LOG_WARNING("Image Decoder failed to read header for resourceBuffer\n");
}
}
}
}
}
- return ImageDimensions( width, height );
+ return ImageDimensions(width, height);
}
-void SetMaxTextureSize( unsigned int size )
+void SetMaxTextureSize(unsigned int size)
{
- gMaxTextureSize = size;
+ gMaxTextureSize = size;
gMaxTextureSizeUpdated = true;
}
return gMaxTextureSizeUpdated;
}
-} // ImageLoader
-} // TizenPlatform
-} // Dali
+} // namespace ImageLoader
+} // namespace TizenPlatform
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
#include <dali/internal/imaging/common/image-operations.h>
// EXTERNAL INCLUDES
-#include <cstring>
-#include <stddef.h>
-#include <cmath>
-#include <limits>
-#include <memory>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/math/vector2.h>
+#include <stddef.h>
#include <third-party/resampler/resampler.h>
-#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <cmath>
+#include <cstring>
+#include <limits>
+#include <memory>
// INTERNAL INCLUDES
{
namespace Platform
{
-
namespace
{
-
// The BORDER_FILL_VALUE is a single byte value that is used for horizontal and vertical borders.
// A value of 0x00 gives us transparency for pixel buffers with an alpha channel, or black otherwise.
// We can optionally use a Vector4 color here, but at reduced fill speed.
-const uint8_t BORDER_FILL_VALUE( 0x00 );
+const uint8_t BORDER_FILL_VALUE(0x00);
// A maximum size limit for newly created bitmaps. ( 1u << 16 ) - 1 is chosen as we are using 16bit words for dimensions.
-const unsigned int MAXIMUM_TARGET_BITMAP_SIZE( ( 1u << 16 ) - 1 );
+const unsigned int MAXIMUM_TARGET_BITMAP_SIZE((1u << 16) - 1);
// Constants used by the ImageResampler.
-const float DEFAULT_SOURCE_GAMMA = 1.75f; ///< Default source gamma value used in the Resampler() function. Partial gamma correction looks better on mips. Set to 1.0 to disable gamma correction.
-const float FILTER_SCALE = 1.f; ///< Default filter scale value used in the Resampler() function. Filter scale - values < 1.0 cause aliasing, but create sharper looking mips.
+const float DEFAULT_SOURCE_GAMMA = 1.75f; ///< Default source gamma value used in the Resampler() function. Partial gamma correction looks better on mips. Set to 1.0 to disable gamma correction.
+const float FILTER_SCALE = 1.f; ///< Default filter scale value used in the Resampler() function. Filter scale - values < 1.0 cause aliasing, but create sharper looking mips.
const float RAD_135 = Math::PI_2 + Math::PI_4; ///< 135 degrees in radians;
-const float RAD_225 = RAD_135 + Math::PI_2; ///< 225 degrees in radians;
+const float RAD_225 = RAD_135 + Math::PI_2; ///< 225 degrees in radians;
const float RAD_270 = 3.f * Math::PI_2; ///< 270 degrees in radians;
-const float RAD_315 = RAD_225 + Math::PI_2; ///< 315 degrees in radians;
+const float RAD_315 = RAD_225 + Math::PI_2; ///< 315 degrees in radians;
using Integration::Bitmap;
using Integration::BitmapPtr;
uint8_t a;
} __attribute__((packed, aligned(2))); //< Tell the compiler it is okay to use a single 16 bit load.
-
#if defined(DEBUG_ENABLED)
/**
* Disable logging of image operations or make it verbose from the commandline
* LOG_IMAGE_OPERATIONS=3 dali-demo #< on, verbose
* </code>
*/
-Debug::Filter* gImageOpsLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_IMAGE_OPERATIONS" );
+Debug::Filter* gImageOpsLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMAGE_OPERATIONS");
#endif
/** @return The greatest even number less than or equal to the argument. */
-inline unsigned int EvenDown( const unsigned int a )
+inline unsigned int EvenDown(const unsigned int a)
{
const unsigned int evened = a & ~1u;
return evened;
/**
* @brief Log bad parameters.
*/
-void ValidateScalingParameters( const unsigned int inputWidth,
- const unsigned int inputHeight,
- const unsigned int desiredWidth,
- const unsigned int desiredHeight )
+void ValidateScalingParameters(const unsigned int inputWidth,
+ const unsigned int inputHeight,
+ const unsigned int desiredWidth,
+ const unsigned int desiredHeight)
{
- if( desiredWidth > inputWidth || desiredHeight > inputHeight )
+ if(desiredWidth > inputWidth || desiredHeight > inputHeight)
{
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Upscaling not supported (%u, %u -> %u, %u).\n", inputWidth, inputHeight, desiredWidth, desiredHeight );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Upscaling not supported (%u, %u -> %u, %u).\n", inputWidth, inputHeight, desiredWidth, desiredHeight);
}
- if( desiredWidth == 0u || desiredHeight == 0u )
+ if(desiredWidth == 0u || desiredHeight == 0u)
{
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Downscaling to a zero-area target is pointless.\n" );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Downscaling to a zero-area target is pointless.\n");
}
- if( inputWidth == 0u || inputHeight == 0u )
+ if(inputWidth == 0u || inputHeight == 0u)
{
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Zero area images cannot be scaled\n" );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Zero area images cannot be scaled\n");
}
}
* @brief Do debug assertions common to all scanline halving functions.
* @note Inline and in anon namespace so should boil away in release builds.
*/
-inline void DebugAssertScanlineParameters( const uint8_t * const pixels, const unsigned int width )
+inline void DebugAssertScanlineParameters(const uint8_t* const pixels, const unsigned int width)
{
- DALI_ASSERT_DEBUG( pixels && "Null pointer." );
- DALI_ASSERT_DEBUG( width > 1u && "Can't average fewer than two pixels." );
- DALI_ASSERT_DEBUG( width < 131072u && "Unusually wide image: are you sure you meant to pass that value in?" );
+ DALI_ASSERT_DEBUG(pixels && "Null pointer.");
+ DALI_ASSERT_DEBUG(width > 1u && "Can't average fewer than two pixels.");
+ DALI_ASSERT_DEBUG(width < 131072u && "Unusually wide image: are you sure you meant to pass that value in?");
}
/**
* @brief Assertions on params to functions averaging pairs of scanlines.
* @note Inline as intended to boil away in release.
*/
-inline void DebugAssertDualScanlineParameters( const uint8_t * const scanline1,
- const uint8_t * const scanline2,
- uint8_t* const outputScanline,
- const size_t widthInComponents )
+inline void DebugAssertDualScanlineParameters(const uint8_t* const scanline1,
+ const uint8_t* const scanline2,
+ uint8_t* const outputScanline,
+ const size_t widthInComponents)
{
- DALI_ASSERT_DEBUG( scanline1 && "Null pointer." );
- DALI_ASSERT_DEBUG( scanline2 && "Null pointer." );
- DALI_ASSERT_DEBUG( outputScanline && "Null pointer." );
- DALI_ASSERT_DEBUG( ((scanline1 >= scanline2 + widthInComponents) || (scanline2 >= scanline1 + widthInComponents )) && "Scanlines alias." );
- DALI_ASSERT_DEBUG( ((outputScanline >= (scanline2 + widthInComponents)) || (scanline2 >= (scanline1 + widthInComponents))) && "Scanline 2 aliases output." );
+ DALI_ASSERT_DEBUG(scanline1 && "Null pointer.");
+ DALI_ASSERT_DEBUG(scanline2 && "Null pointer.");
+ DALI_ASSERT_DEBUG(outputScanline && "Null pointer.");
+ DALI_ASSERT_DEBUG(((scanline1 >= scanline2 + widthInComponents) || (scanline2 >= scanline1 + widthInComponents)) && "Scanlines alias.");
+ DALI_ASSERT_DEBUG(((outputScanline >= (scanline2 + widthInComponents)) || (scanline2 >= (scanline1 + widthInComponents))) && "Scanline 2 aliases output.");
}
/**
* @brief Converts a scaling mode to the definition of which dimensions matter when box filtering as a part of that mode.
*/
-BoxDimensionTest DimensionTestForScalingMode( FittingMode::Type fittingMode )
+BoxDimensionTest DimensionTestForScalingMode(FittingMode::Type fittingMode)
{
BoxDimensionTest dimensionTest;
dimensionTest = BoxDimensionTestEither;
- switch( fittingMode )
+ switch(fittingMode)
{
// Shrink to fit attempts to make one or zero dimensions smaller than the
// desired dimensions and one or two dimensions exactly the same as the desired
* @brief Work out the dimensions for a uniform scaling of the input to map it
* into the target while effecting ShinkToFit scaling mode.
*/
-ImageDimensions FitForShrinkToFit( ImageDimensions target, ImageDimensions source )
+ImageDimensions FitForShrinkToFit(ImageDimensions target, ImageDimensions source)
{
// Scale the input by the least extreme of the two dimensions:
const float widthScale = target.GetX() / float(source.GetX());
const float heightScale = target.GetY() / float(source.GetY());
- const float scale = widthScale < heightScale ? widthScale : heightScale;
+ const float scale = widthScale < heightScale ? widthScale : heightScale;
// Do no scaling at all if the result would increase area:
- if( scale >= 1.0f )
+ if(scale >= 1.0f)
{
return source;
}
- return ImageDimensions( source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f );
+ return ImageDimensions(source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f);
}
/**
* bottom or left and right to be cropped away unless the source was pre-cropped
* to match the destination aspect ratio.
*/
-ImageDimensions FitForScaleToFill( ImageDimensions target, ImageDimensions source )
+ImageDimensions FitForScaleToFill(ImageDimensions target, ImageDimensions source)
{
- DALI_ASSERT_DEBUG( source.GetX() > 0 && source.GetY() > 0 && "Zero-area rectangles should not be passed-in" );
+ DALI_ASSERT_DEBUG(source.GetX() > 0 && source.GetY() > 0 && "Zero-area rectangles should not be passed-in");
// Scale the input by the least extreme of the two dimensions:
const float widthScale = target.GetX() / float(source.GetX());
const float heightScale = target.GetY() / float(source.GetY());
- const float scale = widthScale > heightScale ? widthScale : heightScale;
+ const float scale = widthScale > heightScale ? widthScale : heightScale;
// Do no scaling at all if the result would increase area:
- if( scale >= 1.0f )
+ if(scale >= 1.0f)
{
return source;
}
- return ImageDimensions( source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f );
+ return ImageDimensions(source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f);
}
/**
* @brief Work out the dimensions for a uniform scaling of the input to map it
* into the target while effecting FIT_WIDTH scaling mode.
*/
-ImageDimensions FitForFitWidth( ImageDimensions target, ImageDimensions source )
+ImageDimensions FitForFitWidth(ImageDimensions target, ImageDimensions source)
{
- DALI_ASSERT_DEBUG( source.GetX() > 0 && "Cant fit a zero-dimension rectangle." );
- const float scale = target.GetX() / float(source.GetX());
+ DALI_ASSERT_DEBUG(source.GetX() > 0 && "Cant fit a zero-dimension rectangle.");
+ const float scale = target.GetX() / float(source.GetX());
// Do no scaling at all if the result would increase area:
- if( scale >= 1.0f )
+ if(scale >= 1.0f)
{
- return source;
+ return source;
}
- return ImageDimensions( source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f );
+ return ImageDimensions(source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f);
}
/**
* @brief Work out the dimensions for a uniform scaling of the input to map it
* into the target while effecting FIT_HEIGHT scaling mode.
*/
-ImageDimensions FitForFitHeight( ImageDimensions target, ImageDimensions source )
+ImageDimensions FitForFitHeight(ImageDimensions target, ImageDimensions source)
{
- DALI_ASSERT_DEBUG( source.GetY() > 0 && "Cant fit a zero-dimension rectangle." );
+ DALI_ASSERT_DEBUG(source.GetY() > 0 && "Cant fit a zero-dimension rectangle.");
const float scale = target.GetY() / float(source.GetY());
// Do no scaling at all if the result would increase area:
- if( scale >= 1.0f )
+ if(scale >= 1.0f)
{
return source;
}
- return ImageDimensions( source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f );
+ return ImageDimensions(source.GetX() * scale + 0.5f, source.GetY() * scale + 0.5f);
}
/**
* @brief Generate the rectangle to use as the target of a pixel sampling pass
* (e.g., nearest or linear).
*/
-ImageDimensions FitToScalingMode( ImageDimensions requestedSize, ImageDimensions sourceSize, FittingMode::Type fittingMode )
+ImageDimensions FitToScalingMode(ImageDimensions requestedSize, ImageDimensions sourceSize, FittingMode::Type fittingMode)
{
ImageDimensions fitDimensions;
- switch( fittingMode )
+ switch(fittingMode)
{
case FittingMode::SHRINK_TO_FIT:
{
- fitDimensions = FitForShrinkToFit( requestedSize, sourceSize );
+ fitDimensions = FitForShrinkToFit(requestedSize, sourceSize);
break;
}
case FittingMode::SCALE_TO_FILL:
{
- fitDimensions = FitForScaleToFill( requestedSize, sourceSize );
+ fitDimensions = FitForScaleToFill(requestedSize, sourceSize);
break;
}
case FittingMode::FIT_WIDTH:
{
- fitDimensions = FitForFitWidth( requestedSize, sourceSize );
+ fitDimensions = FitForFitWidth(requestedSize, sourceSize);
break;
}
case FittingMode::FIT_HEIGHT:
{
- fitDimensions = FitForFitHeight( requestedSize, sourceSize );
+ fitDimensions = FitForFitHeight(requestedSize, sourceSize);
break;
}
}
* @param[out] scanlinesToCrop The number of scanlines to remove from the image (can be negative to represent Y borders required)
* @param[out] columnsToCrop The number of columns to remove from the image (can be negative to represent X borders required)
*/
-void CalculateBordersFromFittingMode( ImageDimensions sourceSize, FittingMode::Type fittingMode, ImageDimensions& requestedSize, int& scanlinesToCrop, int& columnsToCrop )
+void CalculateBordersFromFittingMode(ImageDimensions sourceSize, FittingMode::Type fittingMode, ImageDimensions& requestedSize, int& scanlinesToCrop, int& columnsToCrop)
{
- const int sourceWidth( static_cast<int>( sourceSize.GetWidth() ) );
- const int sourceHeight( static_cast<int>(sourceSize.GetHeight() ) );
- const float targetAspect( static_cast< float >( requestedSize.GetWidth() ) / static_cast< float >( requestedSize.GetHeight() ) );
- int finalWidth = 0;
- int finalHeight = 0;
+ const int sourceWidth(static_cast<int>(sourceSize.GetWidth()));
+ const int sourceHeight(static_cast<int>(sourceSize.GetHeight()));
+ const float targetAspect(static_cast<float>(requestedSize.GetWidth()) / static_cast<float>(requestedSize.GetHeight()));
+ int finalWidth = 0;
+ int finalHeight = 0;
- switch( fittingMode )
+ switch(fittingMode)
{
case FittingMode::FIT_WIDTH:
{
- finalWidth = sourceWidth;
- finalHeight = static_cast< float >( sourceWidth ) / targetAspect;
+ finalWidth = sourceWidth;
+ finalHeight = static_cast<float>(sourceWidth) / targetAspect;
- columnsToCrop = 0;
- scanlinesToCrop = -( finalHeight - sourceHeight );
+ columnsToCrop = 0;
+ scanlinesToCrop = -(finalHeight - sourceHeight);
break;
}
case FittingMode::FIT_HEIGHT:
{
- finalWidth = static_cast< float >( sourceHeight ) * targetAspect;
+ finalWidth = static_cast<float>(sourceHeight) * targetAspect;
finalHeight = sourceHeight;
- columnsToCrop = -( finalWidth - sourceWidth );
+ columnsToCrop = -(finalWidth - sourceWidth);
scanlinesToCrop = 0;
break;
}
case FittingMode::SHRINK_TO_FIT:
{
- const float sourceAspect( static_cast< float >( sourceWidth ) / static_cast< float >( sourceHeight ) );
- if( sourceAspect > targetAspect )
+ const float sourceAspect(static_cast<float>(sourceWidth) / static_cast<float>(sourceHeight));
+ if(sourceAspect > targetAspect)
{
- finalWidth = sourceWidth;
- finalHeight = static_cast< float >( sourceWidth ) / targetAspect;
+ finalWidth = sourceWidth;
+ finalHeight = static_cast<float>(sourceWidth) / targetAspect;
- columnsToCrop = 0;
- scanlinesToCrop = -( finalHeight - sourceHeight );
+ columnsToCrop = 0;
+ scanlinesToCrop = -(finalHeight - sourceHeight);
}
else
{
- finalWidth = static_cast< float >( sourceHeight ) * targetAspect;
+ finalWidth = static_cast<float>(sourceHeight) * targetAspect;
finalHeight = sourceHeight;
- columnsToCrop = -( finalWidth - sourceWidth );
+ columnsToCrop = -(finalWidth - sourceWidth);
scanlinesToCrop = 0;
}
break;
case FittingMode::SCALE_TO_FILL:
{
- const float sourceAspect( static_cast< float >( sourceWidth ) / static_cast< float >( sourceHeight ) );
- if( sourceAspect > targetAspect )
+ const float sourceAspect(static_cast<float>(sourceWidth) / static_cast<float>(sourceHeight));
+ if(sourceAspect > targetAspect)
{
- finalWidth = static_cast< float >( sourceHeight ) * targetAspect;
+ finalWidth = static_cast<float>(sourceHeight) * targetAspect;
finalHeight = sourceHeight;
- columnsToCrop = -( finalWidth - sourceWidth );
+ columnsToCrop = -(finalWidth - sourceWidth);
scanlinesToCrop = 0;
}
else
{
- finalWidth = sourceWidth;
- finalHeight = static_cast< float >( sourceWidth ) / targetAspect;
+ finalWidth = sourceWidth;
+ finalHeight = static_cast<float>(sourceWidth) / targetAspect;
- columnsToCrop = 0;
- scanlinesToCrop = -( finalHeight - sourceHeight );
+ columnsToCrop = 0;
+ scanlinesToCrop = -(finalHeight - sourceHeight);
}
break;
}
}
- requestedSize.SetWidth( finalWidth );
- requestedSize.SetHeight( finalHeight );
+ requestedSize.SetWidth(finalWidth);
+ requestedSize.SetHeight(finalHeight);
}
/**
* @brief Construct a pixel buffer object from a copy of the pixel array passed in.
*/
-Dali::Devel::PixelBuffer MakePixelBuffer( const uint8_t * const pixels, Pixel::Format pixelFormat, unsigned int width, unsigned int height )
+Dali::Devel::PixelBuffer MakePixelBuffer(const uint8_t* const pixels, Pixel::Format pixelFormat, unsigned int width, unsigned int height)
{
- DALI_ASSERT_DEBUG( pixels && "Null bitmap buffer to copy." );
+ DALI_ASSERT_DEBUG(pixels && "Null bitmap buffer to copy.");
// Allocate a pixel buffer to hold the image passed in:
- auto newBitmap = Dali::Devel::PixelBuffer::New( width, height, pixelFormat );
+ auto newBitmap = Dali::Devel::PixelBuffer::New(width, height, pixelFormat);
// Copy over the pixels from the downscaled image that was generated in-place in the pixel buffer of the input bitmap:
- memcpy( newBitmap.GetBuffer(), pixels, width * height * Pixel::GetBytesPerPixel( pixelFormat ) );
+ memcpy(newBitmap.GetBuffer(), pixels, width * height * Pixel::GetBytesPerPixel(pixelFormat));
return newBitmap;
}
* @param[in] requestedHeight Height of area to scale image into. Can be zero.
* @return Dimensions of area to scale image into after special rules are applied.
*/
-ImageDimensions CalculateDesiredDimensions( unsigned int bitmapWidth, unsigned int bitmapHeight, unsigned int requestedWidth, unsigned int requestedHeight )
+ImageDimensions CalculateDesiredDimensions(unsigned int bitmapWidth, unsigned int bitmapHeight, unsigned int requestedWidth, unsigned int requestedHeight)
{
unsigned int maxSize = Dali::GetMaxTextureSize();
// If no dimensions have been requested, default to the source ones:
- if( requestedWidth == 0 && requestedHeight == 0 )
+ if(requestedWidth == 0 && requestedHeight == 0)
{
- if( bitmapWidth <= maxSize && bitmapHeight <= maxSize )
+ if(bitmapWidth <= maxSize && bitmapHeight <= maxSize)
{
- return ImageDimensions( bitmapWidth, bitmapHeight );
+ return ImageDimensions(bitmapWidth, bitmapHeight);
}
else
{
// Calculate the size from the max texture size and the source image aspect ratio
- if( bitmapWidth > bitmapHeight )
+ if(bitmapWidth > bitmapHeight)
{
- return ImageDimensions( maxSize, bitmapHeight * maxSize / static_cast< float >( bitmapWidth ) + 0.5f );
+ return ImageDimensions(maxSize, bitmapHeight * maxSize / static_cast<float>(bitmapWidth) + 0.5f);
}
else
{
- return ImageDimensions( bitmapWidth * maxSize / static_cast< float >( bitmapHeight ) + 0.5f, maxSize );
+ return ImageDimensions(bitmapWidth * maxSize / static_cast<float>(bitmapHeight) + 0.5f, maxSize);
}
}
}
// If both dimensions have values requested, use them both:
- if( requestedWidth != 0 && requestedHeight != 0 )
+ if(requestedWidth != 0 && requestedHeight != 0)
{
- if( requestedWidth <= maxSize && requestedHeight <= maxSize )
+ if(requestedWidth <= maxSize && requestedHeight <= maxSize)
{
- return ImageDimensions( requestedWidth, requestedHeight );
+ return ImageDimensions(requestedWidth, requestedHeight);
}
else
{
// Calculate the size from the max texture size and the source image aspect ratio
- if( requestedWidth > requestedHeight )
+ if(requestedWidth > requestedHeight)
{
- return ImageDimensions( maxSize, requestedHeight * maxSize / static_cast< float >( requestedWidth ) + 0.5f );
+ return ImageDimensions(maxSize, requestedHeight * maxSize / static_cast<float>(requestedWidth) + 0.5f);
}
else
{
- return ImageDimensions( requestedWidth * maxSize / static_cast< float >( requestedHeight ) + 0.5f, maxSize );
+ return ImageDimensions(requestedWidth * maxSize / static_cast<float>(requestedHeight) + 0.5f, maxSize);
}
}
}
// Only one of the dimensions has been requested. Calculate the other from
// the requested one and the source image aspect ratio:
- if( requestedWidth != 0 )
+ if(requestedWidth != 0)
{
- requestedWidth = std::min( requestedWidth, maxSize );
- return ImageDimensions( requestedWidth, bitmapHeight / float(bitmapWidth) * requestedWidth + 0.5f );
+ requestedWidth = std::min(requestedWidth, maxSize);
+ return ImageDimensions(requestedWidth, bitmapHeight / float(bitmapWidth) * requestedWidth + 0.5f);
}
- requestedHeight = std::min( requestedHeight, maxSize );
- return ImageDimensions( bitmapWidth / float(bitmapHeight) * requestedHeight + 0.5f, requestedHeight );
+ requestedHeight = std::min(requestedHeight, maxSize);
+ return ImageDimensions(bitmapWidth / float(bitmapHeight) * requestedHeight + 0.5f, requestedHeight);
}
/**
*
* @return Whether the rotation succeded.
*/
-bool Rotate90( const uint8_t* const pixelsIn,
- unsigned int widthIn,
- unsigned int heightIn,
- unsigned int pixelSize,
- uint8_t*& pixelsOut,
- unsigned int& widthOut,
- unsigned int& heightOut )
+bool Rotate90(const uint8_t* const pixelsIn,
+ unsigned int widthIn,
+ unsigned int heightIn,
+ unsigned int pixelSize,
+ uint8_t*& pixelsOut,
+ unsigned int& widthOut,
+ unsigned int& heightOut)
{
// The new size of the image.
- widthOut = heightIn;
+ widthOut = heightIn;
heightOut = widthIn;
// Allocate memory for the rotated buffer.
- pixelsOut = static_cast<uint8_t*>( malloc ( widthOut * heightOut * pixelSize ) );
- if( nullptr == pixelsOut )
+ pixelsOut = static_cast<uint8_t*>(malloc(widthOut * heightOut * pixelSize));
+ if(nullptr == pixelsOut)
{
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
// Return if the memory allocations fails.
}
// Rotate the buffer.
- for( unsigned int y = 0u; y < heightIn; ++y )
+ for(unsigned int y = 0u; y < heightIn; ++y)
{
const unsigned int srcLineIndex = y * widthIn;
- const unsigned int dstX = y;
- for( unsigned int x = 0u; x < widthIn; ++x )
+ const unsigned int dstX = y;
+ for(unsigned int x = 0u; x < widthIn; ++x)
{
- const unsigned int dstY = heightOut - x - 1u;
- const unsigned int dstIndex = pixelSize * ( dstY * widthOut + dstX );
- const unsigned int srcIndex = pixelSize * ( srcLineIndex + x );
+ const unsigned int dstY = heightOut - x - 1u;
+ const unsigned int dstIndex = pixelSize * (dstY * widthOut + dstX);
+ const unsigned int srcIndex = pixelSize * (srcLineIndex + x);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( pixelsOut + dstIndex + channel ) = *( pixelsIn + srcIndex + channel );
+ *(pixelsOut + dstIndex + channel) = *(pixelsIn + srcIndex + channel);
}
}
}
*
* @return Whether the rotation succeded.
*/
-bool Rotate180( const uint8_t* const pixelsIn,
- unsigned int widthIn,
- unsigned int heightIn,
- unsigned int pixelSize,
- uint8_t*& pixelsOut )
+bool Rotate180(const uint8_t* const pixelsIn,
+ unsigned int widthIn,
+ unsigned int heightIn,
+ unsigned int pixelSize,
+ uint8_t*& pixelsOut)
{
// Allocate memory for the rotated buffer.
- pixelsOut = static_cast<uint8_t*>( malloc ( widthIn * heightIn * pixelSize ) );
- if( nullptr == pixelsOut )
+ pixelsOut = static_cast<uint8_t*>(malloc(widthIn * heightIn * pixelSize));
+ if(nullptr == pixelsOut)
{
// Return if the memory allocations fails.
return false;
}
// Rotate the buffer.
- for( unsigned int y = 0u; y < heightIn; ++y )
+ for(unsigned int y = 0u; y < heightIn; ++y)
{
const unsigned int srcLineIndex = y * widthIn;
- const unsigned int dstY = heightIn - y - 1u;
- for( unsigned int x = 0u; x < widthIn; ++x )
+ const unsigned int dstY = heightIn - y - 1u;
+ for(unsigned int x = 0u; x < widthIn; ++x)
{
- const unsigned int dstX = widthIn - x - 1u;
- const unsigned int dstIndex = pixelSize * ( dstY * widthIn + dstX );
- const unsigned int srcIndex = pixelSize * ( srcLineIndex + x );
+ const unsigned int dstX = widthIn - x - 1u;
+ const unsigned int dstIndex = pixelSize * (dstY * widthIn + dstX);
+ const unsigned int srcIndex = pixelSize * (srcLineIndex + x);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( pixelsOut + dstIndex + channel ) = *( pixelsIn + srcIndex + channel );
+ *(pixelsOut + dstIndex + channel) = *(pixelsIn + srcIndex + channel);
}
}
}
*
* @return Whether the rotation succeded.
*/
-bool Rotate270( const uint8_t* const pixelsIn,
- unsigned int widthIn,
- unsigned int heightIn,
- unsigned int pixelSize,
- uint8_t*& pixelsOut,
- unsigned int& widthOut,
- unsigned int& heightOut )
+bool Rotate270(const uint8_t* const pixelsIn,
+ unsigned int widthIn,
+ unsigned int heightIn,
+ unsigned int pixelSize,
+ uint8_t*& pixelsOut,
+ unsigned int& widthOut,
+ unsigned int& heightOut)
{
// The new size of the image.
- widthOut = heightIn;
+ widthOut = heightIn;
heightOut = widthIn;
// Allocate memory for the rotated buffer.
- pixelsOut = static_cast<uint8_t*>( malloc ( widthOut * heightOut * pixelSize ) );
- if( nullptr == pixelsOut )
+ pixelsOut = static_cast<uint8_t*>(malloc(widthOut * heightOut * pixelSize));
+ if(nullptr == pixelsOut)
{
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
// Return if the memory allocations fails.
}
// Rotate the buffer.
- for( unsigned int y = 0u; y < heightIn; ++y )
+ for(unsigned int y = 0u; y < heightIn; ++y)
{
const unsigned int srcLineIndex = y * widthIn;
- const unsigned int dstX = widthOut - y - 1u;
- for( unsigned int x = 0u; x < widthIn; ++x )
+ const unsigned int dstX = widthOut - y - 1u;
+ for(unsigned int x = 0u; x < widthIn; ++x)
{
- const unsigned int dstY = x;
- const unsigned int dstIndex = pixelSize * ( dstY * widthOut + dstX );
- const unsigned int srcIndex = pixelSize * ( srcLineIndex + x );
+ const unsigned int dstY = x;
+ const unsigned int dstIndex = pixelSize * (dstY * widthOut + dstX);
+ const unsigned int srcIndex = pixelSize * (srcLineIndex + x);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( pixelsOut + dstIndex + channel ) = *( pixelsIn + srcIndex + channel );
+ *(pixelsOut + dstIndex + channel) = *(pixelsIn + srcIndex + channel);
}
}
}
* @param[in] offset The skew offset.
* @param[in] weight The relative weight of right pixel.
*/
-void HorizontalSkew( const uint8_t* const srcBufferPtr,
- int srcWidth,
- unsigned int pixelSize,
- uint8_t*& dstBufferPtr,
- int dstWidth,
- unsigned int row,
- int offset,
- float weight )
+void HorizontalSkew(const uint8_t* const srcBufferPtr,
+ int srcWidth,
+ unsigned int pixelSize,
+ uint8_t*& dstBufferPtr,
+ int dstWidth,
+ unsigned int row,
+ int offset,
+ float weight)
{
- if( offset > 0 )
+ if(offset > 0)
{
// Fill gap left of skew with background.
- memset( dstBufferPtr + row * pixelSize * dstWidth, 0u, pixelSize * offset );
+ memset(dstBufferPtr + row * pixelSize * dstWidth, 0u, pixelSize * offset);
}
- unsigned char oldLeft[4u] = { 0u, 0u, 0u, 0u };
+ unsigned char oldLeft[4u] = {0u, 0u, 0u, 0u};
int i = 0;
- for( i = 0u; i < srcWidth; ++i )
+ for(i = 0u; i < srcWidth; ++i)
{
// Loop through row pixels
- const unsigned int srcIndex = pixelSize * ( row * srcWidth + i );
+ const unsigned int srcIndex = pixelSize * (row * srcWidth + i);
- unsigned char src[4u] = { 0u, 0u, 0u, 0u };
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ unsigned char src[4u] = {0u, 0u, 0u, 0u};
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- src[channel] = *( srcBufferPtr + srcIndex + channel );
+ src[channel] = *(srcBufferPtr + srcIndex + channel);
}
// Calculate weights
- unsigned char left[4u] = { 0u, 0u, 0u, 0u };
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ unsigned char left[4u] = {0u, 0u, 0u, 0u};
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- left[channel] = static_cast<unsigned char>( static_cast<float>( src[channel] ) * weight );
+ left[channel] = static_cast<unsigned char>(static_cast<float>(src[channel]) * weight);
// Update left over on source
- src[channel] -= ( left[channel] - oldLeft[channel] );
+ src[channel] -= (left[channel] - oldLeft[channel]);
}
// Check boundaries
- if( ( i + offset >= 0 ) && ( i + offset < dstWidth ) )
+ if((i + offset >= 0) && (i + offset < dstWidth))
{
- const unsigned int dstIndex = pixelSize * ( row * dstWidth + i + offset );
+ const unsigned int dstIndex = pixelSize * (row * dstWidth + i + offset);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( dstBufferPtr + dstIndex + channel ) = src[channel];
+ *(dstBufferPtr + dstIndex + channel) = src[channel];
}
}
// Save leftover for next pixel in scan
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
oldLeft[channel] = left[channel];
}
// Go to rightmost point of skew
i += offset;
- if( i < dstWidth )
+ if(i < dstWidth)
{
// If still in image bounds, put leftovers there
- const unsigned int dstIndex = pixelSize * ( row * dstWidth + i );
+ const unsigned int dstIndex = pixelSize * (row * dstWidth + i);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( dstBufferPtr + dstIndex + channel ) = oldLeft[channel];
+ *(dstBufferPtr + dstIndex + channel) = oldLeft[channel];
}
// Clear to the right of the skewed line with background
++i;
- memset( dstBufferPtr + pixelSize * ( row * dstWidth + i ), 0u, pixelSize * ( dstWidth - i ) );
+ memset(dstBufferPtr + pixelSize * (row * dstWidth + i), 0u, pixelSize * (dstWidth - i));
}
}
* @param[in] offset The skew offset.
* @param[in] weight The relative weight of uppeer pixel.
*/
-void VerticalSkew( const uint8_t* const srcBufferPtr,
- int srcWidth,
- int srcHeight,
- unsigned int pixelSize,
- uint8_t*& dstBufferPtr,
- int dstWidth,
- int dstHeight,
- unsigned int column,
- int offset,
- float weight )
-{
- for( int i = 0; i < offset; ++i )
+void VerticalSkew(const uint8_t* const srcBufferPtr,
+ int srcWidth,
+ int srcHeight,
+ unsigned int pixelSize,
+ uint8_t*& dstBufferPtr,
+ int dstWidth,
+ int dstHeight,
+ unsigned int column,
+ int offset,
+ float weight)
+{
+ for(int i = 0; i < offset; ++i)
{
// Fill gap above skew with background
- const unsigned int dstIndex = pixelSize * ( i * dstWidth + column );
+ const unsigned int dstIndex = pixelSize * (i * dstWidth + column);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( dstBufferPtr + dstIndex + channel ) = 0u;
+ *(dstBufferPtr + dstIndex + channel) = 0u;
}
}
- unsigned char oldLeft[4u] = { 0u, 0u, 0u, 0u };
+ unsigned char oldLeft[4u] = {0u, 0u, 0u, 0u};
int yPos = 0;
- int i = 0;
- for( i = 0; i < srcHeight; ++i )
+ int i = 0;
+ for(i = 0; i < srcHeight; ++i)
{
// Loop through column pixels
- const unsigned int srcIndex = pixelSize * ( i * srcWidth + column );
+ const unsigned int srcIndex = pixelSize * (i * srcWidth + column);
- unsigned char src[4u] = { 0u, 0u, 0u, 0u };
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ unsigned char src[4u] = {0u, 0u, 0u, 0u};
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- src[channel] = *( srcBufferPtr + srcIndex + channel );
+ src[channel] = *(srcBufferPtr + srcIndex + channel);
}
yPos = i + offset;
// Calculate weights
- unsigned char left[4u] = { 0u, 0u, 0u, 0u };
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ unsigned char left[4u] = {0u, 0u, 0u, 0u};
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- left[channel] = static_cast<unsigned char>( static_cast<float>( src[channel] ) * weight );
+ left[channel] = static_cast<unsigned char>(static_cast<float>(src[channel]) * weight);
// Update left over on source
- src[channel] -= ( left[channel] - oldLeft[channel] );
+ src[channel] -= (left[channel] - oldLeft[channel]);
}
// Check boundaries
- if( ( yPos >= 0 ) && ( yPos < dstHeight ) )
+ if((yPos >= 0) && (yPos < dstHeight))
{
- const unsigned int dstIndex = pixelSize * ( yPos * dstWidth + column );
+ const unsigned int dstIndex = pixelSize * (yPos * dstWidth + column);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( dstBufferPtr + dstIndex + channel ) = src[channel];
+ *(dstBufferPtr + dstIndex + channel) = src[channel];
}
}
// Save leftover for next pixel in scan
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
oldLeft[channel] = left[channel];
}
// Go to bottom point of skew
i = yPos;
- if( i < dstHeight )
+ if(i < dstHeight)
{
// If still in image bounds, put leftovers there
- const unsigned int dstIndex = pixelSize * ( i * dstWidth + column );
+ const unsigned int dstIndex = pixelSize * (i * dstWidth + column);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( dstBufferPtr + dstIndex + channel ) = oldLeft[channel];
+ *(dstBufferPtr + dstIndex + channel) = oldLeft[channel];
}
}
- while( ++i < dstHeight )
+ while(++i < dstHeight)
{
// Clear below skewed line with background
- const unsigned int dstIndex = pixelSize * ( i * dstWidth + column );
+ const unsigned int dstIndex = pixelSize * (i * dstWidth + column);
- for( unsigned int channel = 0u; channel < pixelSize; ++channel )
+ for(unsigned int channel = 0u; channel < pixelSize; ++channel)
{
- *( dstBufferPtr + dstIndex + channel ) = 0u;
+ *(dstBufferPtr + dstIndex + channel) = 0u;
}
}
}
-} // namespace - unnamed
+} // namespace
-ImageDimensions CalculateDesiredDimensions( ImageDimensions rawDimensions, ImageDimensions requestedDimensions )
+ImageDimensions CalculateDesiredDimensions(ImageDimensions rawDimensions, ImageDimensions requestedDimensions)
{
- return CalculateDesiredDimensions( rawDimensions.GetWidth(), rawDimensions.GetHeight(), requestedDimensions.GetWidth(), requestedDimensions.GetHeight() ) ;
+ return CalculateDesiredDimensions(rawDimensions.GetWidth(), rawDimensions.GetHeight(), requestedDimensions.GetWidth(), requestedDimensions.GetHeight());
}
/**
* @return A new bitmap with the padding and cropping required for fitting mode applied.
* If no modification is needed or possible, the passed in bitmap is returned.
*/
-Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode );
+Dali::Devel::PixelBuffer CropAndPadForFittingMode(Dali::Devel::PixelBuffer& bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode);
/**
* @brief Adds horizontal or vertical borders to the source image.
* @param[in] targetDimensions The dimensions of the destination image.
* @param[in] padDimensions The columns and scanlines to pad with borders.
*/
-void AddBorders( PixelBuffer *targetPixels, const unsigned int bytesPerPixel, const ImageDimensions targetDimensions, const ImageDimensions padDimensions );
+void AddBorders(PixelBuffer* targetPixels, const unsigned int bytesPerPixel, const ImageDimensions targetDimensions, const ImageDimensions padDimensions);
-Dali::Devel::PixelBuffer ApplyAttributesToBitmap( Dali::Devel::PixelBuffer bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode )
+Dali::Devel::PixelBuffer ApplyAttributesToBitmap(Dali::Devel::PixelBuffer bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode, SamplingMode::Type samplingMode)
{
- if( bitmap )
+ if(bitmap)
{
// Calculate the desired box, accounting for a possible zero component:
- const ImageDimensions desiredDimensions = CalculateDesiredDimensions( bitmap.GetWidth(), bitmap.GetHeight(), dimensions.GetWidth(), dimensions.GetHeight() );
+ const ImageDimensions desiredDimensions = CalculateDesiredDimensions(bitmap.GetWidth(), bitmap.GetHeight(), dimensions.GetWidth(), dimensions.GetHeight());
// If a different size than the raw one has been requested, resize the image
// maximally using a repeated box filter without making it smaller than the
// requested size in either dimension:
- bitmap = DownscaleBitmap( bitmap, desiredDimensions, fittingMode, samplingMode );
+ bitmap = DownscaleBitmap(bitmap, desiredDimensions, fittingMode, samplingMode);
// Cut the bitmap according to the desired width and height so that the
// resulting bitmap has the same aspect ratio as the desired dimensions.
// Add crop and add borders if necessary depending on fitting mode.
- if( bitmap )
+ if(bitmap)
{
- bitmap = CropAndPadForFittingMode( bitmap, desiredDimensions, fittingMode );
+ bitmap = CropAndPadForFittingMode(bitmap, desiredDimensions, fittingMode);
}
}
return bitmap;
}
-Dali::Devel::PixelBuffer CropAndPadForFittingMode( Dali::Devel::PixelBuffer& bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode )
+Dali::Devel::PixelBuffer CropAndPadForFittingMode(Dali::Devel::PixelBuffer& bitmap, ImageDimensions desiredDimensions, FittingMode::Type fittingMode)
{
- const unsigned int inputWidth = bitmap.GetWidth();
+ const unsigned int inputWidth = bitmap.GetWidth();
const unsigned int inputHeight = bitmap.GetHeight();
- if( desiredDimensions.GetWidth() < 1u || desiredDimensions.GetHeight() < 1u )
+ if(desiredDimensions.GetWidth() < 1u || desiredDimensions.GetHeight() < 1u)
{
- DALI_LOG_WARNING( "Image scaling aborted as desired dimensions too small (%u, %u).\n", desiredDimensions.GetWidth(), desiredDimensions.GetHeight() );
+ DALI_LOG_WARNING("Image scaling aborted as desired dimensions too small (%u, %u).\n", desiredDimensions.GetWidth(), desiredDimensions.GetHeight());
}
- else if( inputWidth != desiredDimensions.GetWidth() || inputHeight != desiredDimensions.GetHeight() )
+ else if(inputWidth != desiredDimensions.GetWidth() || inputHeight != desiredDimensions.GetHeight())
{
// Calculate any padding or cropping that needs to be done based on the fitting mode.
// Note: If the desired size is larger than the original image, the desired size will be
// reduced while maintaining the aspect, in order to save unnecessary memory usage.
int scanlinesToCrop = 0;
- int columnsToCrop = 0;
+ int columnsToCrop = 0;
- CalculateBordersFromFittingMode( ImageDimensions( inputWidth, inputHeight ), fittingMode, desiredDimensions, scanlinesToCrop, columnsToCrop );
+ CalculateBordersFromFittingMode(ImageDimensions(inputWidth, inputHeight), fittingMode, desiredDimensions, scanlinesToCrop, columnsToCrop);
- unsigned int desiredWidth( desiredDimensions.GetWidth() );
- unsigned int desiredHeight( desiredDimensions.GetHeight() );
+ unsigned int desiredWidth(desiredDimensions.GetWidth());
+ unsigned int desiredHeight(desiredDimensions.GetHeight());
// Action the changes by making a new bitmap with the central part of the loaded one if required.
- if( scanlinesToCrop != 0 || columnsToCrop != 0 )
+ if(scanlinesToCrop != 0 || columnsToCrop != 0)
{
// Split the adding and removing of scanlines and columns into separate variables,
// so we can use one piece of generic code to action the changes.
unsigned int scanlinesToPad = 0;
- unsigned int columnsToPad = 0;
- if( scanlinesToCrop < 0 )
+ unsigned int columnsToPad = 0;
+ if(scanlinesToCrop < 0)
{
- scanlinesToPad = -scanlinesToCrop;
+ scanlinesToPad = -scanlinesToCrop;
scanlinesToCrop = 0;
}
- if( columnsToCrop < 0 )
+ if(columnsToCrop < 0)
{
- columnsToPad = -columnsToCrop;
+ columnsToPad = -columnsToCrop;
columnsToCrop = 0;
}
// If there is no filtering, then the final image size can become very large, exit if larger than maximum.
- if( ( desiredWidth > MAXIMUM_TARGET_BITMAP_SIZE ) || ( desiredHeight > MAXIMUM_TARGET_BITMAP_SIZE ) ||
- ( columnsToPad > MAXIMUM_TARGET_BITMAP_SIZE ) || ( scanlinesToPad > MAXIMUM_TARGET_BITMAP_SIZE ) )
+ if((desiredWidth > MAXIMUM_TARGET_BITMAP_SIZE) || (desiredHeight > MAXIMUM_TARGET_BITMAP_SIZE) ||
+ (columnsToPad > MAXIMUM_TARGET_BITMAP_SIZE) || (scanlinesToPad > MAXIMUM_TARGET_BITMAP_SIZE))
{
- DALI_LOG_WARNING( "Image scaling aborted as final dimensions too large (%u, %u).\n", desiredWidth, desiredHeight );
+ DALI_LOG_WARNING("Image scaling aborted as final dimensions too large (%u, %u).\n", desiredWidth, desiredHeight);
return bitmap;
}
// Create new PixelBuffer with the desired size.
const auto pixelFormat = bitmap.GetPixelFormat();
- auto croppedBitmap = Devel::PixelBuffer::New( desiredWidth, desiredHeight, pixelFormat );
+ auto croppedBitmap = Devel::PixelBuffer::New(desiredWidth, desiredHeight, pixelFormat);
// Add some pre-calculated offsets to the bitmap pointers so this is not done within a loop.
// The cropping is added to the source pointer, and the padding is added to the destination.
- const auto bytesPerPixel = Pixel::GetBytesPerPixel( pixelFormat );
- const PixelBuffer * const sourcePixels = bitmap.GetBuffer() + ( ( ( ( scanlinesToCrop / 2 ) * inputWidth ) + ( columnsToCrop / 2 ) ) * bytesPerPixel );
- PixelBuffer * const targetPixels = croppedBitmap.GetBuffer();
- PixelBuffer * const targetPixelsActive = targetPixels + ( ( ( ( scanlinesToPad / 2 ) * desiredWidth ) + ( columnsToPad / 2 ) ) * bytesPerPixel );
- DALI_ASSERT_DEBUG( sourcePixels && targetPixels );
+ const auto bytesPerPixel = Pixel::GetBytesPerPixel(pixelFormat);
+ const PixelBuffer* const sourcePixels = bitmap.GetBuffer() + ((((scanlinesToCrop / 2) * inputWidth) + (columnsToCrop / 2)) * bytesPerPixel);
+ PixelBuffer* const targetPixels = croppedBitmap.GetBuffer();
+ PixelBuffer* const targetPixelsActive = targetPixels + ((((scanlinesToPad / 2) * desiredWidth) + (columnsToPad / 2)) * bytesPerPixel);
+ DALI_ASSERT_DEBUG(sourcePixels && targetPixels);
// Copy the image data to the new bitmap.
// Optimize to a single memcpy if the left and right edges don't need a crop or a pad.
- unsigned int outputSpan( desiredWidth * bytesPerPixel );
- if( columnsToCrop == 0 && columnsToPad == 0 )
+ unsigned int outputSpan(desiredWidth * bytesPerPixel);
+ if(columnsToCrop == 0 && columnsToPad == 0)
{
- memcpy( targetPixelsActive, sourcePixels, ( desiredHeight - scanlinesToPad ) * outputSpan );
+ memcpy(targetPixelsActive, sourcePixels, (desiredHeight - scanlinesToPad) * outputSpan);
}
else
{
// The width needs to change (due to either a crop or a pad), so we copy a scanline at a time.
// Precalculate any constants to optimize the inner loop.
- const unsigned int inputSpan( inputWidth * bytesPerPixel );
- const unsigned int copySpan( ( desiredWidth - columnsToPad ) * bytesPerPixel );
- const unsigned int scanlinesToCopy( desiredHeight - scanlinesToPad );
+ const unsigned int inputSpan(inputWidth * bytesPerPixel);
+ const unsigned int copySpan((desiredWidth - columnsToPad) * bytesPerPixel);
+ const unsigned int scanlinesToCopy(desiredHeight - scanlinesToPad);
- for( unsigned int y = 0; y < scanlinesToCopy; ++y )
+ for(unsigned int y = 0; y < scanlinesToCopy; ++y)
{
- memcpy( &targetPixelsActive[ y * outputSpan ], &sourcePixels[ y * inputSpan ], copySpan );
+ memcpy(&targetPixelsActive[y * outputSpan], &sourcePixels[y * inputSpan], copySpan);
}
}
// Add vertical or horizontal borders to the final image (if required).
- desiredDimensions.SetWidth( desiredWidth );
- desiredDimensions.SetHeight( desiredHeight );
- AddBorders( croppedBitmap.GetBuffer(), bytesPerPixel, desiredDimensions, ImageDimensions( columnsToPad, scanlinesToPad ) );
+ desiredDimensions.SetWidth(desiredWidth);
+ desiredDimensions.SetHeight(desiredHeight);
+ AddBorders(croppedBitmap.GetBuffer(), bytesPerPixel, desiredDimensions, ImageDimensions(columnsToPad, scanlinesToPad));
// Overwrite the loaded bitmap with the cropped version
bitmap = croppedBitmap;
}
return bitmap;
}
-void AddBorders( PixelBuffer *targetPixels, const unsigned int bytesPerPixel, const ImageDimensions targetDimensions, const ImageDimensions padDimensions )
+void AddBorders(PixelBuffer* targetPixels, const unsigned int bytesPerPixel, const ImageDimensions targetDimensions, const ImageDimensions padDimensions)
{
// Assign ints for faster access.
- unsigned int desiredWidth( targetDimensions.GetWidth() );
- unsigned int desiredHeight( targetDimensions.GetHeight() );
- unsigned int columnsToPad( padDimensions.GetWidth() );
- unsigned int scanlinesToPad( padDimensions.GetHeight() );
- unsigned int outputSpan( desiredWidth * bytesPerPixel );
+ unsigned int desiredWidth(targetDimensions.GetWidth());
+ unsigned int desiredHeight(targetDimensions.GetHeight());
+ unsigned int columnsToPad(padDimensions.GetWidth());
+ unsigned int scanlinesToPad(padDimensions.GetHeight());
+ unsigned int outputSpan(desiredWidth * bytesPerPixel);
// Add letterboxing (symmetrical borders) if needed.
- if( scanlinesToPad > 0 )
+ if(scanlinesToPad > 0)
{
// Add a top border. Note: This is (deliberately) rounded down if padding is an odd number.
- memset( targetPixels, BORDER_FILL_VALUE, ( scanlinesToPad / 2 ) * outputSpan );
+ memset(targetPixels, BORDER_FILL_VALUE, (scanlinesToPad / 2) * outputSpan);
// We subtract scanlinesToPad/2 from scanlinesToPad so that we have the correct
// offset for odd numbers (as the top border is 1 pixel smaller in these cases.
- unsigned int bottomBorderHeight = scanlinesToPad - ( scanlinesToPad / 2 );
+ unsigned int bottomBorderHeight = scanlinesToPad - (scanlinesToPad / 2);
// Bottom border.
- memset( &targetPixels[ ( desiredHeight - bottomBorderHeight ) * outputSpan ], BORDER_FILL_VALUE, bottomBorderHeight * outputSpan );
+ memset(&targetPixels[(desiredHeight - bottomBorderHeight) * outputSpan], BORDER_FILL_VALUE, bottomBorderHeight * outputSpan);
}
- else if( columnsToPad > 0 )
+ else if(columnsToPad > 0)
{
// Add a left and right border.
// Left:
// Pre-calculate span size outside of loop.
- unsigned int leftBorderSpanWidth( ( columnsToPad / 2 ) * bytesPerPixel );
- for( unsigned int y = 0; y < desiredHeight; ++y )
+ unsigned int leftBorderSpanWidth((columnsToPad / 2) * bytesPerPixel);
+ for(unsigned int y = 0; y < desiredHeight; ++y)
{
- memset( &targetPixels[ y * outputSpan ], BORDER_FILL_VALUE, leftBorderSpanWidth );
+ memset(&targetPixels[y * outputSpan], BORDER_FILL_VALUE, leftBorderSpanWidth);
}
// Right:
// Pre-calculate the initial x offset as it is always the same for a small optimization.
// We subtract columnsToPad/2 from columnsToPad so that we have the correct
// offset for odd numbers (as the left border is 1 pixel smaller in these cases.
- unsigned int rightBorderWidth = columnsToPad - ( columnsToPad / 2 );
- PixelBuffer * const destPixelsRightBorder( targetPixels + ( ( desiredWidth - rightBorderWidth ) * bytesPerPixel ) );
- unsigned int rightBorderSpanWidth = rightBorderWidth * bytesPerPixel;
+ unsigned int rightBorderWidth = columnsToPad - (columnsToPad / 2);
+ PixelBuffer* const destPixelsRightBorder(targetPixels + ((desiredWidth - rightBorderWidth) * bytesPerPixel));
+ unsigned int rightBorderSpanWidth = rightBorderWidth * bytesPerPixel;
- for( unsigned int y = 0; y < desiredHeight; ++y )
+ for(unsigned int y = 0; y < desiredHeight; ++y)
{
- memset( &destPixelsRightBorder[ y * outputSpan ], BORDER_FILL_VALUE, rightBorderSpanWidth );
+ memset(&destPixelsRightBorder[y * outputSpan], BORDER_FILL_VALUE, rightBorderSpanWidth);
}
}
}
-Dali::Devel::PixelBuffer DownscaleBitmap( Dali::Devel::PixelBuffer bitmap,
- ImageDimensions desired,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode )
+Dali::Devel::PixelBuffer DownscaleBitmap(Dali::Devel::PixelBuffer bitmap,
+ ImageDimensions desired,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode)
{
// Source dimensions as loaded from resources (e.g. filesystem):
auto bitmapWidth = bitmap.GetWidth();
auto bitmapHeight = bitmap.GetHeight();
// Desired dimensions (the rectangle to fit the source image to):
- auto desiredWidth = desired.GetWidth();
+ auto desiredWidth = desired.GetWidth();
auto desiredHeight = desired.GetHeight();
- Dali::Devel::PixelBuffer outputBitmap { bitmap };
+ Dali::Devel::PixelBuffer outputBitmap{bitmap};
// If a different size than the raw one has been requested, resize the image:
if(
- (desiredWidth > 0.0f) && (desiredHeight > 0.0f) &&
- ((desiredWidth < bitmapWidth) || (desiredHeight < bitmapHeight)) )
+ (desiredWidth > 0.0f) && (desiredHeight > 0.0f) &&
+ ((desiredWidth < bitmapWidth) || (desiredHeight < bitmapHeight)))
{
auto pixelFormat = bitmap.GetPixelFormat();
// Do the fast power of 2 iterated box filter to get to roughly the right side if the filter mode requests that:
unsigned int shrunkWidth = -1, shrunkHeight = -1;
- DownscaleInPlacePow2( bitmap.GetBuffer(), pixelFormat, bitmapWidth, bitmapHeight, desiredWidth, desiredHeight, fittingMode, samplingMode, shrunkWidth, shrunkHeight );
+ DownscaleInPlacePow2(bitmap.GetBuffer(), pixelFormat, bitmapWidth, bitmapHeight, desiredWidth, desiredHeight, fittingMode, samplingMode, shrunkWidth, shrunkHeight);
// Work out the dimensions of the downscaled bitmap, given the scaling mode and desired dimensions:
- const ImageDimensions filteredDimensions = FitToScalingMode( ImageDimensions( desiredWidth, desiredHeight ), ImageDimensions( shrunkWidth, shrunkHeight ), fittingMode );
- const unsigned int filteredWidth = filteredDimensions.GetWidth();
- const unsigned int filteredHeight = filteredDimensions.GetHeight();
+ const ImageDimensions filteredDimensions = FitToScalingMode(ImageDimensions(desiredWidth, desiredHeight), ImageDimensions(shrunkWidth, shrunkHeight), fittingMode);
+ const unsigned int filteredWidth = filteredDimensions.GetWidth();
+ const unsigned int filteredHeight = filteredDimensions.GetHeight();
// Run a filter to scale down the bitmap if it needs it:
bool filtered = false;
- if( filteredWidth < shrunkWidth || filteredHeight < shrunkHeight )
+ if(filteredWidth < shrunkWidth || filteredHeight < shrunkHeight)
{
- if( samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR ||
- samplingMode == SamplingMode::NEAREST || samplingMode == SamplingMode::BOX_THEN_NEAREST )
+ if(samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR ||
+ samplingMode == SamplingMode::NEAREST || samplingMode == SamplingMode::BOX_THEN_NEAREST)
{
- outputBitmap = Dali::Devel::PixelBuffer::New( filteredWidth, filteredHeight, pixelFormat );
+ outputBitmap = Dali::Devel::PixelBuffer::New(filteredWidth, filteredHeight, pixelFormat);
- if( outputBitmap )
+ if(outputBitmap)
{
- if( samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR )
+ if(samplingMode == SamplingMode::LINEAR || samplingMode == SamplingMode::BOX_THEN_LINEAR)
{
- LinearSample( bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), pixelFormat, outputBitmap.GetBuffer(), filteredDimensions );
+ LinearSample(bitmap.GetBuffer(), ImageDimensions(shrunkWidth, shrunkHeight), pixelFormat, outputBitmap.GetBuffer(), filteredDimensions);
}
else
{
- PointSample( bitmap.GetBuffer(), shrunkWidth, shrunkHeight, pixelFormat, outputBitmap.GetBuffer(), filteredWidth, filteredHeight );
+ PointSample(bitmap.GetBuffer(), shrunkWidth, shrunkHeight, pixelFormat, outputBitmap.GetBuffer(), filteredWidth, filteredHeight);
}
filtered = true;
}
}
}
// Copy out the 2^x downscaled, box-filtered pixels if no secondary filter (point or linear) was applied:
- if( filtered == false && ( shrunkWidth < bitmapWidth || shrunkHeight < bitmapHeight ) )
+ if(filtered == false && (shrunkWidth < bitmapWidth || shrunkHeight < bitmapHeight))
{
- outputBitmap = MakePixelBuffer( bitmap.GetBuffer(), pixelFormat, shrunkWidth, shrunkHeight );
+ outputBitmap = MakePixelBuffer(bitmap.GetBuffer(), pixelFormat, shrunkWidth, shrunkHeight);
}
}
* @param desiredWidth The target width for the downscaling.
* @param desiredHeight The target height for the downscaling.
*/
-bool ContinueScaling( BoxDimensionTest test, unsigned int scaledWidth, unsigned int scaledHeight, unsigned int desiredWidth, unsigned int desiredHeight )
+bool ContinueScaling(BoxDimensionTest test, unsigned int scaledWidth, unsigned int scaledHeight, unsigned int desiredWidth, unsigned int desiredHeight)
{
- bool keepScaling = false;
- const unsigned int nextWidth = scaledWidth >> 1u;
- const unsigned int nextHeight = scaledHeight >> 1u;
+ bool keepScaling = false;
+ const unsigned int nextWidth = scaledWidth >> 1u;
+ const unsigned int nextHeight = scaledHeight >> 1u;
- if( nextWidth >= 1u && nextHeight >= 1u )
+ if(nextWidth >= 1u && nextHeight >= 1u)
{
- switch( test )
+ switch(test)
{
case BoxDimensionTestEither:
{
**/
template<
int BYTES_PER_PIXEL,
- void (*HalveScanlineInPlace)( unsigned char * const pixels, const unsigned int width ),
- void (*AverageScanlines) ( const unsigned char * const scanline1, const unsigned char * const __restrict__ scanline2, unsigned char* const outputScanline, const unsigned int width )
->
-void DownscaleInPlacePow2Generic( unsigned char * const pixels,
- const unsigned int inputWidth,
- const unsigned int inputHeight,
- const unsigned int desiredWidth,
- const unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned& outWidth,
- unsigned& outHeight )
-{
- if( pixels == 0 )
+ void (*HalveScanlineInPlace)(unsigned char* const pixels, const unsigned int width),
+ void (*AverageScanlines)(const unsigned char* const scanline1, const unsigned char* const __restrict__ scanline2, unsigned char* const outputScanline, const unsigned int width)>
+void DownscaleInPlacePow2Generic(unsigned char* const pixels,
+ const unsigned int inputWidth,
+ const unsigned int inputHeight,
+ const unsigned int desiredWidth,
+ const unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned& outWidth,
+ unsigned& outHeight)
+{
+ if(pixels == 0)
{
return;
}
- ValidateScalingParameters( inputWidth, inputHeight, desiredWidth, desiredHeight );
+ ValidateScalingParameters(inputWidth, inputHeight, desiredWidth, desiredHeight);
// Scale the image until it would be smaller than desired, stopping if the
// resulting height or width would be less than 1:
unsigned int scaledWidth = inputWidth, scaledHeight = inputHeight;
- while( ContinueScaling( dimensionTest, scaledWidth, scaledHeight, desiredWidth, desiredHeight ) )
+ while(ContinueScaling(dimensionTest, scaledWidth, scaledHeight, desiredWidth, desiredHeight))
{
const unsigned int lastWidth = scaledWidth;
- scaledWidth >>= 1u;
+ scaledWidth >>= 1u;
scaledHeight >>= 1u;
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Scaling to %u\t%u.\n", scaledWidth, scaledHeight );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Scaling to %u\t%u.\n", scaledWidth, scaledHeight);
const unsigned int lastScanlinePair = scaledHeight - 1;
// Scale pairs of scanlines until any spare one at the end is dropped:
- for( unsigned int y = 0; y <= lastScanlinePair; ++y )
+ for(unsigned int y = 0; y <= lastScanlinePair; ++y)
{
// Scale two scanlines horizontally:
- HalveScanlineInPlace( &pixels[y * 2 * lastWidth * BYTES_PER_PIXEL], lastWidth );
- HalveScanlineInPlace( &pixels[(y * 2 + 1) * lastWidth * BYTES_PER_PIXEL], lastWidth );
+ HalveScanlineInPlace(&pixels[y * 2 * lastWidth * BYTES_PER_PIXEL], lastWidth);
+ HalveScanlineInPlace(&pixels[(y * 2 + 1) * lastWidth * BYTES_PER_PIXEL], lastWidth);
// Scale vertical pairs of pixels while the last two scanlines are still warm in
// the CPU cache(s):
// images but even a 4k wide RGB888 image will use just 24kB of cache (4k pixels
// * 3 Bpp * 2 scanlines) for two scanlines on the first iteration.
AverageScanlines(
- &pixels[y * 2 * lastWidth * BYTES_PER_PIXEL],
- &pixels[(y * 2 + 1) * lastWidth * BYTES_PER_PIXEL],
- &pixels[y * scaledWidth * BYTES_PER_PIXEL],
- scaledWidth );
+ &pixels[y * 2 * lastWidth * BYTES_PER_PIXEL],
+ &pixels[(y * 2 + 1) * lastWidth * BYTES_PER_PIXEL],
+ &pixels[y * scaledWidth * BYTES_PER_PIXEL],
+ scaledWidth);
}
}
///@note: we could finish off with one of two mutually exclusive passes, one squashing horizontally as far as possible, and the other vertically, if we knew a following cpu point or bilinear filter would restore the desired aspect ratio.
- outWidth = scaledWidth;
+ outWidth = scaledWidth;
outHeight = scaledHeight;
}
-}
+} // namespace
-void HalveScanlineInPlaceRGB888( unsigned char * const pixels, const unsigned int width )
+void HalveScanlineInPlaceRGB888(unsigned char* const pixels, const unsigned int width)
{
- DebugAssertScanlineParameters( pixels, width );
+ DebugAssertScanlineParameters(pixels, width);
- const unsigned int lastPair = EvenDown( width - 2 );
+ const unsigned int lastPair = EvenDown(width - 2);
- for( unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel )
+ for(unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel)
{
// Load all the byte pixel components we need:
const unsigned int c11 = pixels[pixel * 3];
const unsigned int c23 = pixels[pixel * 3 + 5];
// Save the averaged byte pixel components:
- pixels[outPixel * 3] = static_cast<unsigned char>( AverageComponent( c11, c21 ) );
- pixels[outPixel * 3 + 1] = static_cast<unsigned char>( AverageComponent( c12, c22 ) );
- pixels[outPixel * 3 + 2] = static_cast<unsigned char>( AverageComponent( c13, c23 ) );
+ pixels[outPixel * 3] = static_cast<unsigned char>(AverageComponent(c11, c21));
+ pixels[outPixel * 3 + 1] = static_cast<unsigned char>(AverageComponent(c12, c22));
+ pixels[outPixel * 3 + 2] = static_cast<unsigned char>(AverageComponent(c13, c23));
}
}
-void HalveScanlineInPlaceRGBA8888( unsigned char * const pixels, const unsigned int width )
+void HalveScanlineInPlaceRGBA8888(unsigned char* const pixels, const unsigned int width)
{
- DebugAssertScanlineParameters( pixels, width );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(pixels) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms." );
+ DebugAssertScanlineParameters(pixels, width);
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(pixels) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms.");
uint32_t* const alignedPixels = reinterpret_cast<uint32_t*>(pixels);
- const unsigned int lastPair = EvenDown( width - 2 );
+ const unsigned int lastPair = EvenDown(width - 2);
- for( unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel )
+ for(unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel)
{
- const uint32_t averaged = AveragePixelRGBA8888( alignedPixels[pixel], alignedPixels[pixel + 1] );
+ const uint32_t averaged = AveragePixelRGBA8888(alignedPixels[pixel], alignedPixels[pixel + 1]);
alignedPixels[outPixel] = averaged;
}
}
-void HalveScanlineInPlaceRGB565( unsigned char * pixels, unsigned int width )
+void HalveScanlineInPlaceRGB565(unsigned char* pixels, unsigned int width)
{
- DebugAssertScanlineParameters( pixels, width );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(pixels) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms." );
+ DebugAssertScanlineParameters(pixels, width);
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(pixels) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms.");
uint16_t* const alignedPixels = reinterpret_cast<uint16_t*>(pixels);
- const unsigned int lastPair = EvenDown( width - 2 );
+ const unsigned int lastPair = EvenDown(width - 2);
- for( unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel )
+ for(unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel)
{
- const uint32_t averaged = AveragePixelRGB565( alignedPixels[pixel], alignedPixels[pixel + 1] );
+ const uint32_t averaged = AveragePixelRGB565(alignedPixels[pixel], alignedPixels[pixel + 1]);
alignedPixels[outPixel] = averaged;
}
}
-void HalveScanlineInPlace2Bytes( unsigned char * const pixels, const unsigned int width )
+void HalveScanlineInPlace2Bytes(unsigned char* const pixels, const unsigned int width)
{
- DebugAssertScanlineParameters( pixels, width );
+ DebugAssertScanlineParameters(pixels, width);
- const unsigned int lastPair = EvenDown( width - 2 );
+ const unsigned int lastPair = EvenDown(width - 2);
- for( unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel )
+ for(unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel)
{
// Load all the byte pixel components we need:
const unsigned int c11 = pixels[pixel * 2];
const unsigned int c22 = pixels[pixel * 2 + 3];
// Save the averaged byte pixel components:
- pixels[outPixel * 2] = static_cast<unsigned char>( AverageComponent( c11, c21 ) );
- pixels[outPixel * 2 + 1] = static_cast<unsigned char>( AverageComponent( c12, c22 ) );
+ pixels[outPixel * 2] = static_cast<unsigned char>(AverageComponent(c11, c21));
+ pixels[outPixel * 2 + 1] = static_cast<unsigned char>(AverageComponent(c12, c22));
}
}
-void HalveScanlineInPlace1Byte( unsigned char * const pixels, const unsigned int width )
+void HalveScanlineInPlace1Byte(unsigned char* const pixels, const unsigned int width)
{
- DebugAssertScanlineParameters( pixels, width );
+ DebugAssertScanlineParameters(pixels, width);
- const unsigned int lastPair = EvenDown( width - 2 );
+ const unsigned int lastPair = EvenDown(width - 2);
- for( unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel )
+ for(unsigned int pixel = 0, outPixel = 0; pixel <= lastPair; pixel += 2, ++outPixel)
{
// Load all the byte pixel components we need:
const unsigned int c1 = pixels[pixel];
const unsigned int c2 = pixels[pixel + 1];
// Save the averaged byte pixel component:
- pixels[outPixel] = static_cast<unsigned char>( AverageComponent( c1, c2 ) );
+ pixels[outPixel] = static_cast<unsigned char>(AverageComponent(c1, c2));
}
}
* @ToDo: Optimise for ARM using a 4 bytes at a time loop wrapped around the single ARMV6 instruction: UHADD8 R4, R0, R5. Note, this is not neon. It runs in the normal integer pipeline so there is no downside like a stall moving between integer and copro, or extra power for clocking-up the idle copro.
* if (widthInComponents >= 7) { word32* aligned1 = scanline1 + 3 & 3; word32* aligned1_end = scanline1 + widthInPixels & 3; while(aligned1 < aligned1_end) { UHADD8 *aligned1++, *aligned2++, *alignedoutput++ } .. + 0 to 3 spare pixels at each end.
*/
-void AverageScanlines1( const unsigned char * const scanline1,
- const unsigned char * const __restrict__ scanline2,
- unsigned char* const outputScanline,
- const unsigned int width )
+void AverageScanlines1(const unsigned char* const scanline1,
+ const unsigned char* const __restrict__ scanline2,
+ unsigned char* const outputScanline,
+ const unsigned int width)
{
- DebugAssertDualScanlineParameters( scanline1, scanline2, outputScanline, width );
+ DebugAssertDualScanlineParameters(scanline1, scanline2, outputScanline, width);
- for( unsigned int component = 0; component < width; ++component )
+ for(unsigned int component = 0; component < width; ++component)
{
- outputScanline[component] = static_cast<unsigned char>( AverageComponent( scanline1[component], scanline2[component] ) );
+ outputScanline[component] = static_cast<unsigned char>(AverageComponent(scanline1[component], scanline2[component]));
}
}
-void AverageScanlines2( const unsigned char * const scanline1,
- const unsigned char * const __restrict__ scanline2,
- unsigned char* const outputScanline,
- const unsigned int width )
+void AverageScanlines2(const unsigned char* const scanline1,
+ const unsigned char* const __restrict__ scanline2,
+ unsigned char* const outputScanline,
+ const unsigned int width)
{
- DebugAssertDualScanlineParameters( scanline1, scanline2, outputScanline, width * 2 );
+ DebugAssertDualScanlineParameters(scanline1, scanline2, outputScanline, width * 2);
- for( unsigned int component = 0; component < width * 2; ++component )
+ for(unsigned int component = 0; component < width * 2; ++component)
{
- outputScanline[component] = static_cast<unsigned char>( AverageComponent( scanline1[component], scanline2[component] ) );
+ outputScanline[component] = static_cast<unsigned char>(AverageComponent(scanline1[component], scanline2[component]));
}
}
-void AverageScanlines3( const unsigned char * const scanline1,
- const unsigned char * const __restrict__ scanline2,
- unsigned char* const outputScanline,
- const unsigned int width )
+void AverageScanlines3(const unsigned char* const scanline1,
+ const unsigned char* const __restrict__ scanline2,
+ unsigned char* const outputScanline,
+ const unsigned int width)
{
- DebugAssertDualScanlineParameters( scanline1, scanline2, outputScanline, width * 3 );
+ DebugAssertDualScanlineParameters(scanline1, scanline2, outputScanline, width * 3);
- for( unsigned int component = 0; component < width * 3; ++component )
+ for(unsigned int component = 0; component < width * 3; ++component)
{
- outputScanline[component] = static_cast<unsigned char>( AverageComponent( scanline1[component], scanline2[component] ) );
+ outputScanline[component] = static_cast<unsigned char>(AverageComponent(scanline1[component], scanline2[component]));
}
}
-void AverageScanlinesRGBA8888( const unsigned char * const scanline1,
- const unsigned char * const __restrict__ scanline2,
- unsigned char * const outputScanline,
- const unsigned int width )
+void AverageScanlinesRGBA8888(const unsigned char* const scanline1,
+ const unsigned char* const __restrict__ scanline2,
+ unsigned char* const outputScanline,
+ const unsigned int width)
{
- DebugAssertDualScanlineParameters( scanline1, scanline2, outputScanline, width * 4 );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(scanline1) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms." );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(scanline2) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms." );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(outputScanline) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms." );
+ DebugAssertDualScanlineParameters(scanline1, scanline2, outputScanline, width * 4);
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(scanline1) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms.");
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(scanline2) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms.");
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(outputScanline) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms.");
const uint32_t* const alignedScanline1 = reinterpret_cast<const uint32_t*>(scanline1);
const uint32_t* const alignedScanline2 = reinterpret_cast<const uint32_t*>(scanline2);
- uint32_t* const alignedOutput = reinterpret_cast<uint32_t*>(outputScanline);
+ uint32_t* const alignedOutput = reinterpret_cast<uint32_t*>(outputScanline);
- for( unsigned int pixel = 0; pixel < width; ++pixel )
+ for(unsigned int pixel = 0; pixel < width; ++pixel)
{
- alignedOutput[pixel] = AveragePixelRGBA8888( alignedScanline1[pixel], alignedScanline2[pixel] );
+ alignedOutput[pixel] = AveragePixelRGBA8888(alignedScanline1[pixel], alignedScanline2[pixel]);
}
}
-void AverageScanlinesRGB565( const unsigned char * const scanline1,
- const unsigned char * const __restrict__ scanline2,
- unsigned char * const outputScanline,
- const unsigned int width )
+void AverageScanlinesRGB565(const unsigned char* const scanline1,
+ const unsigned char* const __restrict__ scanline2,
+ unsigned char* const outputScanline,
+ const unsigned int width)
{
- DebugAssertDualScanlineParameters( scanline1, scanline2, outputScanline, width * 2 );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(scanline1) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms." );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(scanline2) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms." );
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(outputScanline) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms." );
+ DebugAssertDualScanlineParameters(scanline1, scanline2, outputScanline, width * 2);
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(scanline1) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms.");
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(scanline2) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms.");
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(outputScanline) & 1u) == 0u) && "Pointer should be 2-byte aligned for performance on some platforms.");
const uint16_t* const alignedScanline1 = reinterpret_cast<const uint16_t*>(scanline1);
const uint16_t* const alignedScanline2 = reinterpret_cast<const uint16_t*>(scanline2);
- uint16_t* const alignedOutput = reinterpret_cast<uint16_t*>(outputScanline);
+ uint16_t* const alignedOutput = reinterpret_cast<uint16_t*>(outputScanline);
- for( unsigned int pixel = 0; pixel < width; ++pixel )
+ for(unsigned int pixel = 0; pixel < width; ++pixel)
{
- alignedOutput[pixel] = AveragePixelRGB565( alignedScanline1[pixel], alignedScanline2[pixel] );
+ alignedOutput[pixel] = AveragePixelRGB565(alignedScanline1[pixel], alignedScanline2[pixel]);
}
}
/// Dispatch to pixel format appropriate box filter downscaling functions.
-void DownscaleInPlacePow2( unsigned char * const pixels,
- Pixel::Format pixelFormat,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- unsigned& outWidth,
- unsigned& outHeight )
-{
- outWidth = inputWidth;
+void DownscaleInPlacePow2(unsigned char* const pixels,
+ Pixel::Format pixelFormat,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ unsigned& outWidth,
+ unsigned& outHeight)
+{
+ outWidth = inputWidth;
outHeight = inputHeight;
// Perform power of 2 iterated 4:1 box filtering if the requested filter mode requires it:
- if( samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR )
+ if(samplingMode == SamplingMode::BOX || samplingMode == SamplingMode::BOX_THEN_NEAREST || samplingMode == SamplingMode::BOX_THEN_LINEAR)
{
// Check the pixel format is one that is supported:
- if( pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 )
+ if(pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
{
- const BoxDimensionTest dimensionTest = DimensionTestForScalingMode( fittingMode );
+ const BoxDimensionTest dimensionTest = DimensionTestForScalingMode(fittingMode);
- if( pixelFormat == Pixel::RGBA8888 )
+ if(pixelFormat == Pixel::RGBA8888)
{
- Internal::Platform::DownscaleInPlacePow2RGBA8888( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ Internal::Platform::DownscaleInPlacePow2RGBA8888(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
- else if( pixelFormat == Pixel::RGB888 )
+ else if(pixelFormat == Pixel::RGB888)
{
- Internal::Platform::DownscaleInPlacePow2RGB888( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ Internal::Platform::DownscaleInPlacePow2RGB888(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
- else if( pixelFormat == Pixel::RGB565 )
+ else if(pixelFormat == Pixel::RGB565)
{
- Internal::Platform::DownscaleInPlacePow2RGB565( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ Internal::Platform::DownscaleInPlacePow2RGB565(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
- else if( pixelFormat == Pixel::LA88 )
+ else if(pixelFormat == Pixel::LA88)
{
- Internal::Platform::DownscaleInPlacePow2ComponentPair( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ Internal::Platform::DownscaleInPlacePow2ComponentPair(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
- else if( pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 )
+ else if(pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
{
- Internal::Platform::DownscaleInPlacePow2SingleBytePerPixel( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ Internal::Platform::DownscaleInPlacePow2SingleBytePerPixel(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
else
{
- DALI_ASSERT_DEBUG( false && "Inner branch conditions don't match outer branch." );
+ DALI_ASSERT_DEBUG(false && "Inner branch conditions don't match outer branch.");
}
}
}
else
{
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not shrunk: unsupported pixel format: %u.\n", unsigned(pixelFormat) );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not shrunk: unsupported pixel format: %u.\n", unsigned(pixelFormat));
}
}
-void DownscaleInPlacePow2RGB888( unsigned char *pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned& outWidth,
- unsigned& outHeight )
+void DownscaleInPlacePow2RGB888(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned& outWidth,
+ unsigned& outHeight)
{
- DownscaleInPlacePow2Generic<3, HalveScanlineInPlaceRGB888, AverageScanlines3>( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ DownscaleInPlacePow2Generic<3, HalveScanlineInPlaceRGB888, AverageScanlines3>(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
-void DownscaleInPlacePow2RGBA8888( unsigned char * pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned& outWidth,
- unsigned& outHeight )
+void DownscaleInPlacePow2RGBA8888(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned& outWidth,
+ unsigned& outHeight)
{
- DALI_ASSERT_DEBUG( ((reinterpret_cast<ptrdiff_t>(pixels) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms." );
- DownscaleInPlacePow2Generic<4, HalveScanlineInPlaceRGBA8888, AverageScanlinesRGBA8888>( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ DALI_ASSERT_DEBUG(((reinterpret_cast<ptrdiff_t>(pixels) & 3u) == 0u) && "Pointer should be 4-byte aligned for performance on some platforms.");
+ DownscaleInPlacePow2Generic<4, HalveScanlineInPlaceRGBA8888, AverageScanlinesRGBA8888>(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
-void DownscaleInPlacePow2RGB565( unsigned char * pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned int& outWidth,
- unsigned int& outHeight )
+void DownscaleInPlacePow2RGB565(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned int& outWidth,
+ unsigned int& outHeight)
{
- DownscaleInPlacePow2Generic<2, HalveScanlineInPlaceRGB565, AverageScanlinesRGB565>( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ DownscaleInPlacePow2Generic<2, HalveScanlineInPlaceRGB565, AverageScanlinesRGB565>(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
/**
*
* For 2-byte formats such as lum8alpha8, but not packed 16 bit formats like RGB565.
*/
-void DownscaleInPlacePow2ComponentPair( unsigned char *pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned& outWidth,
- unsigned& outHeight )
+void DownscaleInPlacePow2ComponentPair(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned& outWidth,
+ unsigned& outHeight)
{
- DownscaleInPlacePow2Generic<2, HalveScanlineInPlace2Bytes, AverageScanlines2>( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ DownscaleInPlacePow2Generic<2, HalveScanlineInPlace2Bytes, AverageScanlines2>(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
-void DownscaleInPlacePow2SingleBytePerPixel( unsigned char * pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned int& outWidth,
- unsigned int& outHeight )
+void DownscaleInPlacePow2SingleBytePerPixel(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned int& outWidth,
+ unsigned int& outHeight)
{
- DownscaleInPlacePow2Generic<1, HalveScanlineInPlace1Byte, AverageScanlines1>( pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight );
+ DownscaleInPlacePow2Generic<1, HalveScanlineInPlace1Byte, AverageScanlines1>(pixels, inputWidth, inputHeight, desiredWidth, desiredHeight, dimensionTest, outWidth, outHeight);
}
namespace
{
-
/**
* @brief Point sample an image to a new resolution (like GL_NEAREST).
*
* functions below which are exported to rest of module.
*/
template<typename PIXEL>
-inline void PointSampleAddressablePixels( const uint8_t * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- uint8_t * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight )
+inline void PointSampleAddressablePixels(const uint8_t* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ uint8_t* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight)
{
- DALI_ASSERT_DEBUG( ((desiredWidth <= inputWidth && desiredHeight <= inputHeight) ||
- outPixels >= inPixels + inputWidth * inputHeight * sizeof(PIXEL) || outPixels <= inPixels - desiredWidth * desiredHeight * sizeof(PIXEL)) &&
- "The input and output buffers must not overlap for an upscaling.");
- DALI_ASSERT_DEBUG( reinterpret_cast< uint64_t >( inPixels ) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...)." );
- DALI_ASSERT_DEBUG( reinterpret_cast< uint64_t >( outPixels ) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...)." );
+ DALI_ASSERT_DEBUG(((desiredWidth <= inputWidth && desiredHeight <= inputHeight) ||
+ outPixels >= inPixels + inputWidth * inputHeight * sizeof(PIXEL) || outPixels <= inPixels - desiredWidth * desiredHeight * sizeof(PIXEL)) &&
+ "The input and output buffers must not overlap for an upscaling.");
+ DALI_ASSERT_DEBUG(reinterpret_cast<uint64_t>(inPixels) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...).");
+ DALI_ASSERT_DEBUG(reinterpret_cast<uint64_t>(outPixels) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...).");
- if( inputWidth < 1u || inputHeight < 1u || desiredWidth < 1u || desiredHeight < 1u )
+ if(inputWidth < 1u || inputHeight < 1u || desiredWidth < 1u || desiredHeight < 1u)
{
return;
}
- const PIXEL* const inAligned = reinterpret_cast<const PIXEL*>(inPixels);
+ const PIXEL* const inAligned = reinterpret_cast<const PIXEL*>(inPixels);
PIXEL* const outAligned = reinterpret_cast<PIXEL*>(outPixels);
- const unsigned int deltaX = (inputWidth << 16u) / desiredWidth;
- const unsigned int deltaY = (inputHeight << 16u) / desiredHeight;
+ const unsigned int deltaX = (inputWidth << 16u) / desiredWidth;
+ const unsigned int deltaY = (inputHeight << 16u) / desiredHeight;
unsigned int inY = 0;
- for( unsigned int outY = 0; outY < desiredHeight; ++outY )
+ for(unsigned int outY = 0; outY < desiredHeight; ++outY)
{
// Round fixed point y coordinate to nearest integer:
- const unsigned int integerY = (inY + (1u << 15u)) >> 16u;
- const PIXEL* const inScanline = &inAligned[inputWidth * integerY];
- PIXEL* const outScanline = &outAligned[desiredWidth * outY];
+ const unsigned int integerY = (inY + (1u << 15u)) >> 16u;
+ const PIXEL* const inScanline = &inAligned[inputWidth * integerY];
+ PIXEL* const outScanline = &outAligned[desiredWidth * outY];
- DALI_ASSERT_DEBUG( integerY < inputHeight );
- DALI_ASSERT_DEBUG( reinterpret_cast<const uint8_t*>(inScanline) < ( inPixels + inputWidth * inputHeight * sizeof(PIXEL) ) );
- DALI_ASSERT_DEBUG( reinterpret_cast<uint8_t*>(outScanline) < ( outPixels + desiredWidth * desiredHeight * sizeof(PIXEL) ) );
+ DALI_ASSERT_DEBUG(integerY < inputHeight);
+ DALI_ASSERT_DEBUG(reinterpret_cast<const uint8_t*>(inScanline) < (inPixels + inputWidth * inputHeight * sizeof(PIXEL)));
+ DALI_ASSERT_DEBUG(reinterpret_cast<uint8_t*>(outScanline) < (outPixels + desiredWidth * desiredHeight * sizeof(PIXEL)));
unsigned int inX = 0;
- for( unsigned int outX = 0; outX < desiredWidth; ++outX )
+ for(unsigned int outX = 0; outX < desiredWidth; ++outX)
{
// Round the fixed-point x coordinate to an integer:
- const unsigned int integerX = (inX + (1u << 15u)) >> 16u;
+ const unsigned int integerX = (inX + (1u << 15u)) >> 16u;
const PIXEL* const inPixelAddress = &inScanline[integerX];
- const PIXEL pixel = *inPixelAddress;
- outScanline[outX] = pixel;
+ const PIXEL pixel = *inPixelAddress;
+ outScanline[outX] = pixel;
inX += deltaX;
}
inY += deltaY;
}
}
-}
+} // namespace
// RGBA8888
-void PointSample4BPP( const unsigned char * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned char * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight )
+void PointSample4BPP(const unsigned char* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned char* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight)
{
- PointSampleAddressablePixels<uint32_t>( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSampleAddressablePixels<uint32_t>(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
// RGB565, LA88
-void PointSample2BPP( const unsigned char * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned char * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight )
+void PointSample2BPP(const unsigned char* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned char* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight)
{
- PointSampleAddressablePixels<uint16_t>( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSampleAddressablePixels<uint16_t>(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
// L8, A8
-void PointSample1BPP( const unsigned char * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned char * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight )
+void PointSample1BPP(const unsigned char* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned char* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight)
{
- PointSampleAddressablePixels<uint8_t>( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSampleAddressablePixels<uint8_t>(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
/* RGB888
* RGB888 is a special case as its pixels are not aligned addressable units.
*/
-void PointSample3BPP( const uint8_t * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- uint8_t * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight )
+void PointSample3BPP(const uint8_t* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ uint8_t* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight)
{
- if( inputWidth < 1u || inputHeight < 1u || desiredWidth < 1u || desiredHeight < 1u )
+ if(inputWidth < 1u || inputHeight < 1u || desiredWidth < 1u || desiredHeight < 1u)
{
return;
}
const unsigned int BYTES_PER_PIXEL = 3;
// Generate fixed-point 16.16 deltas in input image coordinates:
- const unsigned int deltaX = (inputWidth << 16u) / desiredWidth;
+ const unsigned int deltaX = (inputWidth << 16u) / desiredWidth;
const unsigned int deltaY = (inputHeight << 16u) / desiredHeight;
// Step through output image in whole integer pixel steps while tracking the
// corresponding locations in the input image using 16.16 fixed-point
// coordinates:
unsigned int inY = 0; //< 16.16 fixed-point input image y-coord.
- for( unsigned int outY = 0; outY < desiredHeight; ++outY )
+ for(unsigned int outY = 0; outY < desiredHeight; ++outY)
{
- const unsigned int integerY = (inY + (1u << 15u)) >> 16u;
- const uint8_t* const inScanline = &inPixels[inputWidth * integerY * BYTES_PER_PIXEL];
- uint8_t* const outScanline = &outPixels[desiredWidth * outY * BYTES_PER_PIXEL];
- unsigned int inX = 0; //< 16.16 fixed-point input image x-coord.
+ const unsigned int integerY = (inY + (1u << 15u)) >> 16u;
+ const uint8_t* const inScanline = &inPixels[inputWidth * integerY * BYTES_PER_PIXEL];
+ uint8_t* const outScanline = &outPixels[desiredWidth * outY * BYTES_PER_PIXEL];
+ unsigned int inX = 0; //< 16.16 fixed-point input image x-coord.
- for( unsigned int outX = 0; outX < desiredWidth * BYTES_PER_PIXEL; outX += BYTES_PER_PIXEL )
+ for(unsigned int outX = 0; outX < desiredWidth * BYTES_PER_PIXEL; outX += BYTES_PER_PIXEL)
{
// Round the fixed-point input coordinate to the address of the input pixel to sample:
- const unsigned int integerX = (inX + (1u << 15u)) >> 16u;
+ const unsigned int integerX = (inX + (1u << 15u)) >> 16u;
const uint8_t* const inPixelAddress = &inScanline[integerX * BYTES_PER_PIXEL];
// Issue loads for all pixel color components up-front:
///@ToDo: Optimise - Benchmark one 32bit load that will be unaligned 2/3 of the time + 3 rotate and masks, versus these three aligned byte loads, versus using an RGB packed, aligned(1) struct and letting compiler pick a strategy.
// Output the pixel components:
- outScanline[outX] = static_cast<uint8_t>( c0 );
- outScanline[outX + 1] = static_cast<uint8_t>( c1 );
- outScanline[outX + 2] = static_cast<uint8_t>( c2 );
+ outScanline[outX] = static_cast<uint8_t>(c0);
+ outScanline[outX + 1] = static_cast<uint8_t>(c1);
+ outScanline[outX + 2] = static_cast<uint8_t>(c2);
// Increment the fixed-point input coordinate:
inX += deltaX;
}
// Dispatch to a format-appropriate point sampling function:
-void PointSample( const unsigned char * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- Pixel::Format pixelFormat,
- unsigned char * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight )
+void PointSample(const unsigned char* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ Pixel::Format pixelFormat,
+ unsigned char* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight)
{
// Check the pixel format is one that is supported:
- if( pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 )
+ if(pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
{
- if( pixelFormat == Pixel::RGB888 )
+ if(pixelFormat == Pixel::RGB888)
{
- PointSample3BPP( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSample3BPP(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
- else if( pixelFormat == Pixel::RGBA8888 )
+ else if(pixelFormat == Pixel::RGBA8888)
{
- PointSample4BPP( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSample4BPP(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
- else if( pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88 )
+ else if(pixelFormat == Pixel::RGB565 || pixelFormat == Pixel::LA88)
{
- PointSample2BPP( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSample2BPP(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
- else if( pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 )
+ else if(pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
{
- PointSample1BPP( inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight );
+ PointSample1BPP(inPixels, inputWidth, inputHeight, outPixels, desiredWidth, desiredHeight);
}
else
{
- DALI_ASSERT_DEBUG( 0 == "Inner branch conditions don't match outer branch." );
+ DALI_ASSERT_DEBUG(0 == "Inner branch conditions don't match outer branch.");
}
}
else
{
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not point sampled: unsupported pixel format: %u.\n", unsigned(pixelFormat) );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not point sampled: unsupported pixel format: %u.\n", unsigned(pixelFormat));
}
}
namespace
{
-
/** @brief Blend 4 pixels together using horizontal and vertical weights. */
-inline uint8_t BilinearFilter1BPPByte( uint8_t tl, uint8_t tr, uint8_t bl, uint8_t br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical )
+inline uint8_t BilinearFilter1BPPByte(uint8_t tl, uint8_t tr, uint8_t bl, uint8_t br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
{
- return static_cast<uint8_t>( BilinearFilter1Component( tl, tr, bl, br, fractBlendHorizontal, fractBlendVertical ) );
+ return static_cast<uint8_t>(BilinearFilter1Component(tl, tr, bl, br, fractBlendHorizontal, fractBlendVertical));
}
/** @copydoc BilinearFilter1BPPByte */
-inline Pixel2Bytes BilinearFilter2Bytes( Pixel2Bytes tl, Pixel2Bytes tr, Pixel2Bytes bl, Pixel2Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical )
+inline Pixel2Bytes BilinearFilter2Bytes(Pixel2Bytes tl, Pixel2Bytes tr, Pixel2Bytes bl, Pixel2Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
{
Pixel2Bytes pixel;
- pixel.l = static_cast<uint8_t>( BilinearFilter1Component( tl.l, tr.l, bl.l, br.l, fractBlendHorizontal, fractBlendVertical ) );
- pixel.a = static_cast<uint8_t>( BilinearFilter1Component( tl.a, tr.a, bl.a, br.a, fractBlendHorizontal, fractBlendVertical ) );
+ pixel.l = static_cast<uint8_t>(BilinearFilter1Component(tl.l, tr.l, bl.l, br.l, fractBlendHorizontal, fractBlendVertical));
+ pixel.a = static_cast<uint8_t>(BilinearFilter1Component(tl.a, tr.a, bl.a, br.a, fractBlendHorizontal, fractBlendVertical));
return pixel;
}
/** @copydoc BilinearFilter1BPPByte */
-inline Pixel3Bytes BilinearFilterRGB888( Pixel3Bytes tl, Pixel3Bytes tr, Pixel3Bytes bl, Pixel3Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical )
+inline Pixel3Bytes BilinearFilterRGB888(Pixel3Bytes tl, Pixel3Bytes tr, Pixel3Bytes bl, Pixel3Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
{
Pixel3Bytes pixel;
- pixel.r = static_cast<uint8_t>( BilinearFilter1Component( tl.r, tr.r, bl.r, br.r, fractBlendHorizontal, fractBlendVertical ) );
- pixel.g = static_cast<uint8_t>( BilinearFilter1Component( tl.g, tr.g, bl.g, br.g, fractBlendHorizontal, fractBlendVertical ) );
- pixel.b = static_cast<uint8_t>( BilinearFilter1Component( tl.b, tr.b, bl.b, br.b, fractBlendHorizontal, fractBlendVertical ) );
+ pixel.r = static_cast<uint8_t>(BilinearFilter1Component(tl.r, tr.r, bl.r, br.r, fractBlendHorizontal, fractBlendVertical));
+ pixel.g = static_cast<uint8_t>(BilinearFilter1Component(tl.g, tr.g, bl.g, br.g, fractBlendHorizontal, fractBlendVertical));
+ pixel.b = static_cast<uint8_t>(BilinearFilter1Component(tl.b, tr.b, bl.b, br.b, fractBlendHorizontal, fractBlendVertical));
return pixel;
}
/** @copydoc BilinearFilter1BPPByte */
-inline PixelRGB565 BilinearFilterRGB565( PixelRGB565 tl, PixelRGB565 tr, PixelRGB565 bl, PixelRGB565 br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical )
+inline PixelRGB565 BilinearFilterRGB565(PixelRGB565 tl, PixelRGB565 tr, PixelRGB565 bl, PixelRGB565 br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
{
- const PixelRGB565 pixel = static_cast<PixelRGB565>( (BilinearFilter1Component( tl >> 11u, tr >> 11u, bl >> 11u, br >> 11u, fractBlendHorizontal, fractBlendVertical ) << 11u) +
- (BilinearFilter1Component( (tl >> 5u) & 63u, (tr >> 5u) & 63u, (bl >> 5u) & 63u, (br >> 5u) & 63u, fractBlendHorizontal, fractBlendVertical ) << 5u) +
- BilinearFilter1Component( tl & 31u, tr & 31u, bl & 31u, br & 31u, fractBlendHorizontal, fractBlendVertical ) );
+ const PixelRGB565 pixel = static_cast<PixelRGB565>((BilinearFilter1Component(tl >> 11u, tr >> 11u, bl >> 11u, br >> 11u, fractBlendHorizontal, fractBlendVertical) << 11u) +
+ (BilinearFilter1Component((tl >> 5u) & 63u, (tr >> 5u) & 63u, (bl >> 5u) & 63u, (br >> 5u) & 63u, fractBlendHorizontal, fractBlendVertical) << 5u) +
+ BilinearFilter1Component(tl & 31u, tr & 31u, bl & 31u, br & 31u, fractBlendHorizontal, fractBlendVertical));
return pixel;
}
/** @copydoc BilinearFilter1BPPByte */
-inline Pixel4Bytes BilinearFilter4Bytes( Pixel4Bytes tl, Pixel4Bytes tr, Pixel4Bytes bl, Pixel4Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical )
+inline Pixel4Bytes BilinearFilter4Bytes(Pixel4Bytes tl, Pixel4Bytes tr, Pixel4Bytes bl, Pixel4Bytes br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
{
Pixel4Bytes pixel;
- pixel.r = static_cast<uint8_t>( BilinearFilter1Component( tl.r, tr.r, bl.r, br.r, fractBlendHorizontal, fractBlendVertical ) );
- pixel.g = static_cast<uint8_t>( BilinearFilter1Component( tl.g, tr.g, bl.g, br.g, fractBlendHorizontal, fractBlendVertical ) );
- pixel.b = static_cast<uint8_t>( BilinearFilter1Component( tl.b, tr.b, bl.b, br.b, fractBlendHorizontal, fractBlendVertical ) );
- pixel.a = static_cast<uint8_t>( BilinearFilter1Component( tl.a, tr.a, bl.a, br.a, fractBlendHorizontal, fractBlendVertical ) );
+ pixel.r = static_cast<uint8_t>(BilinearFilter1Component(tl.r, tr.r, bl.r, br.r, fractBlendHorizontal, fractBlendVertical));
+ pixel.g = static_cast<uint8_t>(BilinearFilter1Component(tl.g, tr.g, bl.g, br.g, fractBlendHorizontal, fractBlendVertical));
+ pixel.b = static_cast<uint8_t>(BilinearFilter1Component(tl.b, tr.b, bl.b, br.b, fractBlendHorizontal, fractBlendVertical));
+ pixel.a = static_cast<uint8_t>(BilinearFilter1Component(tl.a, tr.a, bl.a, br.a, fractBlendHorizontal, fractBlendVertical));
return pixel;
}
*/
template<
typename PIXEL,
- PIXEL (*BilinearFilter) ( PIXEL tl, PIXEL tr, PIXEL bl, PIXEL br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical ),
- bool DEBUG_ASSERT_ALIGNMENT
->
-inline void LinearSampleGeneric( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
-{
- const unsigned int inputWidth = inputDimensions.GetWidth();
- const unsigned int inputHeight = inputDimensions.GetHeight();
- const unsigned int desiredWidth = desiredDimensions.GetWidth();
+ PIXEL (*BilinearFilter)(PIXEL tl, PIXEL tr, PIXEL bl, PIXEL br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical),
+ bool DEBUG_ASSERT_ALIGNMENT>
+inline void LinearSampleGeneric(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
+{
+ const unsigned int inputWidth = inputDimensions.GetWidth();
+ const unsigned int inputHeight = inputDimensions.GetHeight();
+ const unsigned int desiredWidth = desiredDimensions.GetWidth();
const unsigned int desiredHeight = desiredDimensions.GetHeight();
- DALI_ASSERT_DEBUG( ((outPixels >= inPixels + inputWidth * inputHeight * sizeof(PIXEL)) ||
- (inPixels >= outPixels + desiredWidth * desiredHeight * sizeof(PIXEL))) &&
- "Input and output buffers cannot overlap.");
- if( DEBUG_ASSERT_ALIGNMENT )
+ DALI_ASSERT_DEBUG(((outPixels >= inPixels + inputWidth * inputHeight * sizeof(PIXEL)) ||
+ (inPixels >= outPixels + desiredWidth * desiredHeight * sizeof(PIXEL))) &&
+ "Input and output buffers cannot overlap.");
+ if(DEBUG_ASSERT_ALIGNMENT)
{
- DALI_ASSERT_DEBUG( reinterpret_cast< uint64_t >( inPixels ) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...)." );
- DALI_ASSERT_DEBUG( reinterpret_cast< uint64_t >( outPixels) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...)." );
+ DALI_ASSERT_DEBUG(reinterpret_cast<uint64_t>(inPixels) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...).");
+ DALI_ASSERT_DEBUG(reinterpret_cast<uint64_t>(outPixels) % sizeof(PIXEL) == 0 && "Pixel pointers need to be aligned to the size of the pixels (E.g., 4 bytes for RGBA, 2 bytes for RGB565, ...).");
}
- if( inputWidth < 1u || inputHeight < 1u || desiredWidth < 1u || desiredHeight < 1u )
+ if(inputWidth < 1u || inputHeight < 1u || desiredWidth < 1u || desiredHeight < 1u)
{
return;
}
- const PIXEL* const inAligned = reinterpret_cast<const PIXEL*>(inPixels);
+ const PIXEL* const inAligned = reinterpret_cast<const PIXEL*>(inPixels);
PIXEL* const outAligned = reinterpret_cast<PIXEL*>(outPixels);
- const unsigned int deltaX = (inputWidth << 16u) / desiredWidth;
- const unsigned int deltaY = (inputHeight << 16u) / desiredHeight;
+ const unsigned int deltaX = (inputWidth << 16u) / desiredWidth;
+ const unsigned int deltaY = (inputHeight << 16u) / desiredHeight;
unsigned int inY = 0;
- for( unsigned int outY = 0; outY < desiredHeight; ++outY )
+ for(unsigned int outY = 0; outY < desiredHeight; ++outY)
{
PIXEL* const outScanline = &outAligned[desiredWidth * outY];
// Find the two scanlines to blend and the weight to blend with:
- const unsigned int integerY1 = inY >> 16u;
- const unsigned int integerY2 = integerY1 >= inputHeight ? integerY1 : integerY1 + 1;
+ const unsigned int integerY1 = inY >> 16u;
+ const unsigned int integerY2 = integerY1 >= inputHeight ? integerY1 : integerY1 + 1;
const unsigned int inputYWeight = inY & 65535u;
- DALI_ASSERT_DEBUG( integerY1 < inputHeight );
- DALI_ASSERT_DEBUG( integerY2 < inputHeight );
+ DALI_ASSERT_DEBUG(integerY1 < inputHeight);
+ DALI_ASSERT_DEBUG(integerY2 < inputHeight);
const PIXEL* const inScanline1 = &inAligned[inputWidth * integerY1];
const PIXEL* const inScanline2 = &inAligned[inputWidth * integerY2];
unsigned int inX = 0;
- for( unsigned int outX = 0; outX < desiredWidth; ++outX )
+ for(unsigned int outX = 0; outX < desiredWidth; ++outX)
{
// Work out the two pixel scanline offsets for this cluster of four samples:
const unsigned int integerX1 = inX >> 16u;
// Weighted bilinear filter:
const unsigned int inputXWeight = inX & 65535u;
- outScanline[outX] = BilinearFilter( pixel1, pixel3, pixel2, pixel4, inputXWeight, inputYWeight );
+ outScanline[outX] = BilinearFilter(pixel1, pixel3, pixel2, pixel4, inputXWeight, inputYWeight);
inX += deltaX;
}
}
}
-}
+} // namespace
// Format-specific linear scaling instantiations:
-void LinearSample1BPP( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LinearSample1BPP(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
- LinearSampleGeneric<uint8_t, BilinearFilter1BPPByte, false>( inPixels, inputDimensions, outPixels, desiredDimensions );
+ LinearSampleGeneric<uint8_t, BilinearFilter1BPPByte, false>(inPixels, inputDimensions, outPixels, desiredDimensions);
}
-void LinearSample2BPP( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LinearSample2BPP(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
- LinearSampleGeneric<Pixel2Bytes, BilinearFilter2Bytes, true>( inPixels, inputDimensions, outPixels, desiredDimensions );
+ LinearSampleGeneric<Pixel2Bytes, BilinearFilter2Bytes, true>(inPixels, inputDimensions, outPixels, desiredDimensions);
}
-void LinearSampleRGB565( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LinearSampleRGB565(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
- LinearSampleGeneric<PixelRGB565, BilinearFilterRGB565, true>( inPixels, inputDimensions, outPixels, desiredDimensions );
+ LinearSampleGeneric<PixelRGB565, BilinearFilterRGB565, true>(inPixels, inputDimensions, outPixels, desiredDimensions);
}
-void LinearSample3BPP( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LinearSample3BPP(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
- LinearSampleGeneric<Pixel3Bytes, BilinearFilterRGB888, false>( inPixels, inputDimensions, outPixels, desiredDimensions );
+ LinearSampleGeneric<Pixel3Bytes, BilinearFilterRGB888, false>(inPixels, inputDimensions, outPixels, desiredDimensions);
}
-void LinearSample4BPP( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LinearSample4BPP(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
- LinearSampleGeneric<Pixel4Bytes, BilinearFilter4Bytes, true>( inPixels, inputDimensions, outPixels, desiredDimensions );
+ LinearSampleGeneric<Pixel4Bytes, BilinearFilter4Bytes, true>(inPixels, inputDimensions, outPixels, desiredDimensions);
}
-
-void Resample( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions,
- Resampler::Filter filterType,
- int numChannels, bool hasAlpha )
+void Resample(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions,
+ Resampler::Filter filterType,
+ int numChannels,
+ bool hasAlpha)
{
// Got from the test.cpp of the ImageResampler lib.
- const float ONE_DIV_255 = 1.0f / 255.0f;
- const int MAX_UNSIGNED_CHAR = std::numeric_limits<uint8_t>::max();
- const int LINEAR_TO_SRGB_TABLE_SIZE = 4096;
- const int ALPHA_CHANNEL = hasAlpha ? (numChannels-1) : 0;
+ const float ONE_DIV_255 = 1.0f / 255.0f;
+ const int MAX_UNSIGNED_CHAR = std::numeric_limits<uint8_t>::max();
+ const int LINEAR_TO_SRGB_TABLE_SIZE = 4096;
+ const int ALPHA_CHANNEL = hasAlpha ? (numChannels - 1) : 0;
- static bool loadColorSpaces = true;
- static float srgbToLinear[MAX_UNSIGNED_CHAR + 1];
+ static bool loadColorSpaces = true;
+ static float srgbToLinear[MAX_UNSIGNED_CHAR + 1];
static unsigned char linearToSrgb[LINEAR_TO_SRGB_TABLE_SIZE];
- if( loadColorSpaces ) // Only create the color space conversions on the first execution
+ if(loadColorSpaces) // Only create the color space conversions on the first execution
{
loadColorSpaces = false;
- for( int i = 0; i <= MAX_UNSIGNED_CHAR; ++i )
+ for(int i = 0; i <= MAX_UNSIGNED_CHAR; ++i)
{
- srgbToLinear[i] = pow( static_cast<float>( i ) * ONE_DIV_255, DEFAULT_SOURCE_GAMMA );
+ srgbToLinear[i] = pow(static_cast<float>(i) * ONE_DIV_255, DEFAULT_SOURCE_GAMMA);
}
- const float invLinearToSrgbTableSize = 1.0f / static_cast<float>( LINEAR_TO_SRGB_TABLE_SIZE );
- const float invSourceGamma = 1.0f / DEFAULT_SOURCE_GAMMA;
+ const float invLinearToSrgbTableSize = 1.0f / static_cast<float>(LINEAR_TO_SRGB_TABLE_SIZE);
+ const float invSourceGamma = 1.0f / DEFAULT_SOURCE_GAMMA;
- for( int i = 0; i < LINEAR_TO_SRGB_TABLE_SIZE; ++i )
+ for(int i = 0; i < LINEAR_TO_SRGB_TABLE_SIZE; ++i)
{
- int k = static_cast<int>( 255.0f * pow( static_cast<float>( i ) * invLinearToSrgbTableSize, invSourceGamma ) + 0.5f );
- if( k < 0 )
+ int k = static_cast<int>(255.0f * pow(static_cast<float>(i) * invLinearToSrgbTableSize, invSourceGamma) + 0.5f);
+ if(k < 0)
{
k = 0;
}
- else if( k > MAX_UNSIGNED_CHAR )
+ else if(k > MAX_UNSIGNED_CHAR)
{
k = MAX_UNSIGNED_CHAR;
}
- linearToSrgb[i] = static_cast<unsigned char>( k );
+ linearToSrgb[i] = static_cast<unsigned char>(k);
}
}
- std::vector<Resampler*> resamplers( numChannels );
+ std::vector<Resampler*> resamplers(numChannels);
std::vector<Vector<float>> samples(numChannels);
- const int srcWidth = inputDimensions.GetWidth();
+ const int srcWidth = inputDimensions.GetWidth();
const int srcHeight = inputDimensions.GetHeight();
- const int dstWidth = desiredDimensions.GetWidth();
+ const int dstWidth = desiredDimensions.GetWidth();
const int dstHeight = desiredDimensions.GetHeight();
// Now create a Resampler instance for each component to process. The first instance will create new contributor tables, which are shared by the resamplers
// used for the other components (a memory and slight cache efficiency optimization).
- resamplers[0] = new Resampler( srcWidth,
- srcHeight,
- dstWidth,
- dstHeight,
- Resampler::BOUNDARY_CLAMP,
- 0.0f, // sample_low,
- 1.0f, // sample_high. Clamp output samples to specified range, or disable clamping if sample_low >= sample_high.
- filterType, // The type of filter.
- NULL, // Pclist_x,
- NULL, // Pclist_y. Optional pointers to contributor lists from another instance of a Resampler.
- FILTER_SCALE, // src_x_ofs,
- FILTER_SCALE ); // src_y_ofs. Offset input image by specified amount (fractional values okay).
- samples[0].Resize( srcWidth );
- for( int i = 1; i < numChannels; ++i )
- {
- resamplers[i] = new Resampler( srcWidth,
- srcHeight,
- dstWidth,
- dstHeight,
- Resampler::BOUNDARY_CLAMP,
- 0.0f,
- 1.0f,
- filterType,
- resamplers[0]->get_clist_x(),
- resamplers[0]->get_clist_y(),
- FILTER_SCALE,
- FILTER_SCALE );
- samples[i].Resize( srcWidth );
+ resamplers[0] = new Resampler(srcWidth,
+ srcHeight,
+ dstWidth,
+ dstHeight,
+ Resampler::BOUNDARY_CLAMP,
+ 0.0f, // sample_low,
+ 1.0f, // sample_high. Clamp output samples to specified range, or disable clamping if sample_low >= sample_high.
+ filterType, // The type of filter.
+ NULL, // Pclist_x,
+ NULL, // Pclist_y. Optional pointers to contributor lists from another instance of a Resampler.
+ FILTER_SCALE, // src_x_ofs,
+ FILTER_SCALE); // src_y_ofs. Offset input image by specified amount (fractional values okay).
+ samples[0].Resize(srcWidth);
+ for(int i = 1; i < numChannels; ++i)
+ {
+ resamplers[i] = new Resampler(srcWidth,
+ srcHeight,
+ dstWidth,
+ dstHeight,
+ Resampler::BOUNDARY_CLAMP,
+ 0.0f,
+ 1.0f,
+ filterType,
+ resamplers[0]->get_clist_x(),
+ resamplers[0]->get_clist_y(),
+ FILTER_SCALE,
+ FILTER_SCALE);
+ samples[i].Resize(srcWidth);
}
const int srcPitch = srcWidth * numChannels;
const int dstPitch = dstWidth * numChannels;
- int dstY = 0;
+ int dstY = 0;
- for( int srcY = 0; srcY < srcHeight; ++srcY )
+ for(int srcY = 0; srcY < srcHeight; ++srcY)
{
const unsigned char* pSrc = &inPixels[srcY * srcPitch];
- for( int x = 0; x < srcWidth; ++x )
+ for(int x = 0; x < srcWidth; ++x)
{
- for( int c = 0; c < numChannels; ++c )
+ for(int c = 0; c < numChannels; ++c)
{
- if( c == ALPHA_CHANNEL && hasAlpha )
+ if(c == ALPHA_CHANNEL && hasAlpha)
{
samples[c][x] = *pSrc++ * ONE_DIV_255;
}
}
}
- for( int c = 0; c < numChannels; ++c )
+ for(int c = 0; c < numChannels; ++c)
{
- if( !resamplers[c]->put_line( &samples[c][0] ) )
+ if(!resamplers[c]->put_line(&samples[c][0]))
{
- DALI_ASSERT_DEBUG( !"Out of memory" );
+ DALI_ASSERT_DEBUG(!"Out of memory");
}
}
for(;;)
{
int compIndex;
- for( compIndex = 0; compIndex < numChannels; ++compIndex )
+ for(compIndex = 0; compIndex < numChannels; ++compIndex)
{
const float* pOutputSamples = resamplers[compIndex]->get_line();
- if( !pOutputSamples )
+ if(!pOutputSamples)
{
break;
}
- const bool isAlphaChannel = ( compIndex == ALPHA_CHANNEL && hasAlpha );
- DALI_ASSERT_DEBUG( dstY < dstHeight );
+ const bool isAlphaChannel = (compIndex == ALPHA_CHANNEL && hasAlpha);
+ DALI_ASSERT_DEBUG(dstY < dstHeight);
unsigned char* pDst = &outPixels[dstY * dstPitch + compIndex];
- for( int x = 0; x < dstWidth; ++x )
+ for(int x = 0; x < dstWidth; ++x)
{
- if( isAlphaChannel )
+ if(isAlphaChannel)
{
- int c = static_cast<int>( 255.0f * pOutputSamples[x] + 0.5f );
- if( c < 0 )
+ int c = static_cast<int>(255.0f * pOutputSamples[x] + 0.5f);
+ if(c < 0)
{
c = 0;
}
- else if( c > MAX_UNSIGNED_CHAR )
+ else if(c > MAX_UNSIGNED_CHAR)
{
c = MAX_UNSIGNED_CHAR;
}
- *pDst = static_cast<unsigned char>( c );
+ *pDst = static_cast<unsigned char>(c);
}
else
{
- int j = static_cast<int>( LINEAR_TO_SRGB_TABLE_SIZE * pOutputSamples[x] + 0.5f );
- if( j < 0 )
+ int j = static_cast<int>(LINEAR_TO_SRGB_TABLE_SIZE * pOutputSamples[x] + 0.5f);
+ if(j < 0)
{
j = 0;
}
- else if( j >= LINEAR_TO_SRGB_TABLE_SIZE )
+ else if(j >= LINEAR_TO_SRGB_TABLE_SIZE)
{
j = LINEAR_TO_SRGB_TABLE_SIZE - 1;
}
pDst += numChannels;
}
}
- if( compIndex < numChannels )
+ if(compIndex < numChannels)
{
break;
}
}
// Delete the resamplers.
- for( int i = 0; i < numChannels; ++i )
+ for(int i = 0; i < numChannels; ++i)
{
delete resamplers[i];
}
}
-void LanczosSample4BPP( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LanczosSample4BPP(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
- Resample( inPixels, inputDimensions, outPixels, desiredDimensions, Resampler::LANCZOS4, 4, true );
+ Resample(inPixels, inputDimensions, outPixels, desiredDimensions, Resampler::LANCZOS4, 4, true);
}
-void LanczosSample1BPP( const unsigned char * __restrict__ inPixels,
- ImageDimensions inputDimensions,
- unsigned char * __restrict__ outPixels,
- ImageDimensions desiredDimensions )
+void LanczosSample1BPP(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inputDimensions,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions desiredDimensions)
{
// For L8 images
- Resample( inPixels, inputDimensions, outPixels, desiredDimensions, Resampler::LANCZOS4, 1, false );
+ Resample(inPixels, inputDimensions, outPixels, desiredDimensions, Resampler::LANCZOS4, 1, false);
}
// Dispatch to a format-appropriate linear sampling function:
-void LinearSample( const unsigned char * __restrict__ inPixels,
- ImageDimensions inDimensions,
- Pixel::Format pixelFormat,
- unsigned char * __restrict__ outPixels,
- ImageDimensions outDimensions )
+void LinearSample(const unsigned char* __restrict__ inPixels,
+ ImageDimensions inDimensions,
+ Pixel::Format pixelFormat,
+ unsigned char* __restrict__ outPixels,
+ ImageDimensions outDimensions)
{
// Check the pixel format is one that is supported:
- if( pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::RGB565 )
+ if(pixelFormat == Pixel::RGB888 || pixelFormat == Pixel::RGBA8888 || pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 || pixelFormat == Pixel::LA88 || pixelFormat == Pixel::RGB565)
{
- if( pixelFormat == Pixel::RGB888 )
+ if(pixelFormat == Pixel::RGB888)
{
- LinearSample3BPP( inPixels, inDimensions, outPixels, outDimensions );
+ LinearSample3BPP(inPixels, inDimensions, outPixels, outDimensions);
}
- else if( pixelFormat == Pixel::RGBA8888 )
+ else if(pixelFormat == Pixel::RGBA8888)
{
- LinearSample4BPP( inPixels, inDimensions, outPixels, outDimensions );
+ LinearSample4BPP(inPixels, inDimensions, outPixels, outDimensions);
}
- else if( pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8 )
+ else if(pixelFormat == Pixel::L8 || pixelFormat == Pixel::A8)
{
- LinearSample1BPP( inPixels, inDimensions, outPixels, outDimensions );
+ LinearSample1BPP(inPixels, inDimensions, outPixels, outDimensions);
}
- else if( pixelFormat == Pixel::LA88 )
+ else if(pixelFormat == Pixel::LA88)
{
- LinearSample2BPP( inPixels, inDimensions, outPixels, outDimensions );
+ LinearSample2BPP(inPixels, inDimensions, outPixels, outDimensions);
}
- else if ( pixelFormat == Pixel::RGB565 )
+ else if(pixelFormat == Pixel::RGB565)
{
- LinearSampleRGB565( inPixels, inDimensions, outPixels, outDimensions );
+ LinearSampleRGB565(inPixels, inDimensions, outPixels, outDimensions);
}
else
{
- DALI_ASSERT_DEBUG( 0 == "Inner branch conditions don't match outer branch." );
+ DALI_ASSERT_DEBUG(0 == "Inner branch conditions don't match outer branch.");
}
}
else
{
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not linear sampled: unsupported pixel format: %u.\n", unsigned(pixelFormat) );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Bitmap was not linear sampled: unsupported pixel format: %u.\n", unsigned(pixelFormat));
}
}
-void RotateByShear( const uint8_t* const pixelsIn,
- unsigned int widthIn,
- unsigned int heightIn,
- unsigned int pixelSize,
- float radians,
- uint8_t*& pixelsOut,
- unsigned int& widthOut,
- unsigned int& heightOut )
+void RotateByShear(const uint8_t* const pixelsIn,
+ unsigned int widthIn,
+ unsigned int heightIn,
+ unsigned int pixelSize,
+ float radians,
+ uint8_t*& pixelsOut,
+ unsigned int& widthOut,
+ unsigned int& heightOut)
{
// @note Code got from https://www.codeproject.com/Articles/202/High-quality-image-rotation-rotate-by-shear by Eran Yariv.
// Do first the fast rotations to transform the angle into a (-45..45] range.
float fastRotationPerformed = false;
- if( ( radians > Math::PI_4 ) && ( radians <= RAD_135 ) )
+ if((radians > Math::PI_4) && (radians <= RAD_135))
{
// Angle in (45.0 .. 135.0]
// Rotate image by 90 degrees into temporary image,
// so it requires only an extra rotation angle
// of -45.0 .. +45.0 to complete rotation.
- fastRotationPerformed = Rotate90( pixelsIn,
- widthIn,
- heightIn,
- pixelSize,
- pixelsOut,
- widthOut,
- heightOut );
-
- if( !fastRotationPerformed )
+ fastRotationPerformed = Rotate90(pixelsIn,
+ widthIn,
+ heightIn,
+ pixelSize,
+ pixelsOut,
+ widthOut,
+ heightOut);
+
+ if(!fastRotationPerformed)
{
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "fast rotation failed\n");
// The fast rotation failed.
radians -= Math::PI_2;
}
- else if( ( radians > RAD_135 ) && ( radians <= RAD_225 ) )
+ else if((radians > RAD_135) && (radians <= RAD_225))
{
// Angle in (135.0 .. 225.0]
// Rotate image by 180 degrees into temporary image,
// so it requires only an extra rotation angle
// of -45.0 .. +45.0 to complete rotation.
- fastRotationPerformed = Rotate180( pixelsIn,
- widthIn,
- heightIn,
- pixelSize,
- pixelsOut );
+ fastRotationPerformed = Rotate180(pixelsIn,
+ widthIn,
+ heightIn,
+ pixelSize,
+ pixelsOut);
- if( !fastRotationPerformed )
+ if(!fastRotationPerformed)
{
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "fast rotation failed\n");
// The fast rotation failed.
}
radians -= Math::PI;
- widthOut = widthIn;
+ widthOut = widthIn;
heightOut = heightIn;
}
- else if( ( radians > RAD_225 ) && ( radians <= RAD_315 ) )
+ else if((radians > RAD_225) && (radians <= RAD_315))
{
// Angle in (225.0 .. 315.0]
// Rotate image by 270 degrees into temporary image,
// so it requires only an extra rotation angle
// of -45.0 .. +45.0 to complete rotation.
- fastRotationPerformed = Rotate270( pixelsIn,
- widthIn,
- heightIn,
- pixelSize,
- pixelsOut,
- widthOut,
- heightOut );
+ fastRotationPerformed = Rotate270(pixelsIn,
+ widthIn,
+ heightIn,
+ pixelSize,
+ pixelsOut,
+ widthOut,
+ heightOut);
- if( !fastRotationPerformed )
+ if(!fastRotationPerformed)
{
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "fast rotation failed\n");
// The fast rotation failed.
radians -= RAD_270;
}
- if( fabs( radians ) < Dali::Math::MACHINE_EPSILON_10 )
+ if(fabs(radians) < Dali::Math::MACHINE_EPSILON_10)
{
// Nothing else to do if the angle is zero.
// The rotation angle was 90, 180 or 270.
return;
}
- const uint8_t* const firstHorizontalSkewPixelsIn = fastRotationPerformed ? pixelsOut : pixelsIn;
- std::unique_ptr<uint8_t, void(*)(void*)> tmpPixelsInPtr( ( fastRotationPerformed ? pixelsOut : nullptr ), free );
+ const uint8_t* const firstHorizontalSkewPixelsIn = fastRotationPerformed ? pixelsOut : pixelsIn;
+ std::unique_ptr<uint8_t, void (*)(void*)> tmpPixelsInPtr((fastRotationPerformed ? pixelsOut : nullptr), free);
// Reset the input/output
- widthIn = widthOut;
- heightIn = heightOut;
+ widthIn = widthOut;
+ heightIn = heightOut;
pixelsOut = nullptr;
- const float angleSinus = sin( radians );
- const float angleCosinus = cos( radians );
- const float angleTangent = tan( 0.5f * radians );
+ const float angleSinus = sin(radians);
+ const float angleCosinus = cos(radians);
+ const float angleTangent = tan(0.5f * radians);
///////////////////////////////////////
// Perform 1st shear (horizontal)
// Calculate first shear (horizontal) destination image dimensions
- widthOut = widthIn + static_cast<unsigned int>( fabs( angleTangent ) * static_cast<float>( heightIn ) );
+ widthOut = widthIn + static_cast<unsigned int>(fabs(angleTangent) * static_cast<float>(heightIn));
heightOut = heightIn;
// Allocate the buffer for the 1st shear
- pixelsOut = static_cast<uint8_t*>( malloc( widthOut * heightOut * pixelSize ) );
+ pixelsOut = static_cast<uint8_t*>(malloc(widthOut * heightOut * pixelSize));
- if( nullptr == pixelsOut )
+ if(nullptr == pixelsOut)
{
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "malloc failed to allocate memory\n");
return;
}
- for( unsigned int y = 0u; y < heightOut; ++y )
+ for(unsigned int y = 0u; y < heightOut; ++y)
{
- const float shear = angleTangent * ( ( angleTangent >= 0.f ) ? ( 0.5f + static_cast<float>( y ) ) : ( 0.5f + static_cast<float>( y ) - static_cast<float>( heightOut ) ) );
+ const float shear = angleTangent * ((angleTangent >= 0.f) ? (0.5f + static_cast<float>(y)) : (0.5f + static_cast<float>(y) - static_cast<float>(heightOut)));
- const int intShear = static_cast<int>( floor( shear ) );
- HorizontalSkew( firstHorizontalSkewPixelsIn, widthIn, pixelSize, pixelsOut, widthOut, y, intShear, shear - static_cast<float>( intShear ) );
+ const int intShear = static_cast<int>(floor(shear));
+ HorizontalSkew(firstHorizontalSkewPixelsIn, widthIn, pixelSize, pixelsOut, widthOut, y, intShear, shear - static_cast<float>(intShear));
}
// Reset the 'pixel in' pointer with the output of the 'First Horizontal Skew' and free the memory allocated by the 'Fast Rotations'.
- tmpPixelsInPtr.reset( pixelsOut );
- unsigned int tmpWidthIn = widthOut;
+ tmpPixelsInPtr.reset(pixelsOut);
+ unsigned int tmpWidthIn = widthOut;
unsigned int tmpHeightIn = heightOut;
// Reset the input/output
///////////////////////////////////////
// Calc 2nd shear (vertical) destination image dimensions
- heightOut = static_cast<unsigned int>( static_cast<float>( widthIn ) * fabs( angleSinus ) + static_cast<float>( heightIn ) * angleCosinus );
+ heightOut = static_cast<unsigned int>(static_cast<float>(widthIn) * fabs(angleSinus) + static_cast<float>(heightIn) * angleCosinus);
// Allocate the buffer for the 2nd shear
- pixelsOut = static_cast<uint8_t*>( malloc( widthOut * heightOut * pixelSize ) );
+ pixelsOut = static_cast<uint8_t*>(malloc(widthOut * heightOut * pixelSize));
- if( nullptr == pixelsOut )
+ if(nullptr == pixelsOut)
{
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "malloc failed to allocate memory\n");
}
// Variable skew offset
- float offset = angleSinus * ( ( angleSinus > 0.f ) ? static_cast<float>( widthIn - 1u ) : -( static_cast<float>( widthIn ) - static_cast<float>( widthOut ) ) );
+ float offset = angleSinus * ((angleSinus > 0.f) ? static_cast<float>(widthIn - 1u) : -(static_cast<float>(widthIn) - static_cast<float>(widthOut)));
unsigned int column = 0u;
- for( column = 0u; column < widthOut; ++column, offset -= angleSinus )
+ for(column = 0u; column < widthOut; ++column, offset -= angleSinus)
{
- const int shear = static_cast<int>( floor( offset ) );
- VerticalSkew( tmpPixelsInPtr.get(), tmpWidthIn, tmpHeightIn, pixelSize, pixelsOut, widthOut, heightOut, column, shear, offset - static_cast<float>( shear ) );
+ const int shear = static_cast<int>(floor(offset));
+ VerticalSkew(tmpPixelsInPtr.get(), tmpWidthIn, tmpHeightIn, pixelSize, pixelsOut, widthOut, heightOut, column, shear, offset - static_cast<float>(shear));
}
// Reset the 'pixel in' pointer with the output of the 'Vertical Skew' and free the memory allocated by the 'First Horizontal Skew'.
// Reset the input/output
- tmpPixelsInPtr.reset( pixelsOut );
- tmpWidthIn = widthOut;
+ tmpPixelsInPtr.reset(pixelsOut);
+ tmpWidthIn = widthOut;
tmpHeightIn = heightOut;
- pixelsOut = nullptr;
+ pixelsOut = nullptr;
///////////////////////////////////////
// Perform 3rd shear (horizontal)
///////////////////////////////////////
// Calc 3rd shear (horizontal) destination image dimensions
- widthOut = static_cast<unsigned int>( static_cast<float>( heightIn ) * fabs( angleSinus ) + static_cast<float>( widthIn ) * angleCosinus ) + 1u;
+ widthOut = static_cast<unsigned int>(static_cast<float>(heightIn) * fabs(angleSinus) + static_cast<float>(widthIn) * angleCosinus) + 1u;
// Allocate the buffer for the 3rd shear
- pixelsOut = static_cast<uint8_t*>( malloc( widthOut * heightOut * pixelSize ) );
+ pixelsOut = static_cast<uint8_t*>(malloc(widthOut * heightOut * pixelSize));
- if( nullptr == pixelsOut )
+ if(nullptr == pixelsOut)
{
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "malloc failed to allocate memory\n");
return;
}
- offset = ( angleSinus >= 0.f ) ? -angleSinus * angleTangent * static_cast<float>( widthIn - 1u ) : angleTangent * ( static_cast<float>( widthIn - 1u ) * -angleSinus + ( 1.f - static_cast<float>( heightOut ) ) );
+ offset = (angleSinus >= 0.f) ? -angleSinus * angleTangent * static_cast<float>(widthIn - 1u) : angleTangent * (static_cast<float>(widthIn - 1u) * -angleSinus + (1.f - static_cast<float>(heightOut)));
- for( unsigned int y = 0u; y < heightOut; ++y, offset += angleTangent )
+ for(unsigned int y = 0u; y < heightOut; ++y, offset += angleTangent)
{
- const int shear = static_cast<int>( floor( offset ) );
- HorizontalSkew( tmpPixelsInPtr.get(), tmpWidthIn, pixelSize, pixelsOut, widthOut, y, shear, offset - static_cast<float>( shear ) );
+ const int shear = static_cast<int>(floor(offset));
+ HorizontalSkew(tmpPixelsInPtr.get(), tmpWidthIn, pixelSize, pixelsOut, widthOut, y, shear, offset - static_cast<float>(shear));
}
// The deleter of the tmpPixelsInPtr unique pointer is called freeing the memory allocated by the 'Vertical Skew'.
// @note Allocated memory by the last 'Horizontal Skew' has to be freed by the caller to this function.
}
-void HorizontalShear( const uint8_t* const pixelsIn,
- unsigned int widthIn,
- unsigned int heightIn,
- unsigned int pixelSize,
- float radians,
- uint8_t*& pixelsOut,
- unsigned int& widthOut,
- unsigned int& heightOut )
+void HorizontalShear(const uint8_t* const pixelsIn,
+ unsigned int widthIn,
+ unsigned int heightIn,
+ unsigned int pixelSize,
+ float radians,
+ uint8_t*& pixelsOut,
+ unsigned int& widthOut,
+ unsigned int& heightOut)
{
// Calculate the destination image dimensions.
- const float absRadians = fabs( radians );
+ const float absRadians = fabs(radians);
- if( absRadians > Math::PI_4 )
+ if(absRadians > Math::PI_4)
{
// Can't shear more than 45 degrees.
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Can't shear more than 45 degrees (PI/4 radians). radians : %f\n", radians );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "Can't shear more than 45 degrees (PI/4 radians). radians : %f\n", radians);
return;
}
- widthOut = widthIn + static_cast<unsigned int>( ceil ( absRadians * static_cast<float>( heightIn ) ) );
+ widthOut = widthIn + static_cast<unsigned int>(ceil(absRadians * static_cast<float>(heightIn)));
heightOut = heightIn;
// Allocate the buffer for the shear.
- pixelsOut = static_cast<uint8_t*>( malloc( widthOut * heightOut * pixelSize ) );
+ pixelsOut = static_cast<uint8_t*>(malloc(widthOut * heightOut * pixelSize));
- if( nullptr == pixelsOut )
+ if(nullptr == pixelsOut)
{
- widthOut = 0u;
+ widthOut = 0u;
heightOut = 0u;
- DALI_LOG_INFO( gImageOpsLogFilter, Dali::Integration::Log::Verbose, "malloc failed to allocate memory\n" );
+ DALI_LOG_INFO(gImageOpsLogFilter, Dali::Integration::Log::Verbose, "malloc failed to allocate memory\n");
return;
}
- for( unsigned int y = 0u; y < heightOut; ++y )
+ for(unsigned int y = 0u; y < heightOut; ++y)
{
- const float shear = radians * ( ( radians >= 0.f ) ? ( 0.5f + static_cast<float>( y ) ) : ( 0.5f + static_cast<float>( y ) - static_cast<float>( heightOut ) ) );
+ const float shear = radians * ((radians >= 0.f) ? (0.5f + static_cast<float>(y)) : (0.5f + static_cast<float>(y) - static_cast<float>(heightOut)));
- const int intShear = static_cast<int>( floor( shear ) );
- HorizontalSkew( pixelsIn, widthIn, pixelSize, pixelsOut, widthOut, y, intShear, shear - static_cast<float>( intShear ) );
+ const int intShear = static_cast<int>(floor(shear));
+ HorizontalSkew(pixelsIn, widthIn, pixelSize, pixelsOut, widthOut, y, intShear, shear - static_cast<float>(intShear));
}
}
/*
- * 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.
#include <dali/internal/imaging/common/loader-astc.h>
// EXTERNAL INCLUDES
-#include <cstring>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/images/pixel.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/debug.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
+#include <dali/public-api/images/pixel.h>
+#include <cstring>
namespace Dali
{
{
namespace
{
-
// Max width or height of an image.
const unsigned MAX_TEXTURE_DIMENSION = 4096;
// Max bytes of image data allowed. Not a precise number, just a sanity check.
// This bytes identify an ASTC native file.
const Byte FileIdentifier[] = {
- 0x13, 0xAB, 0xA1, 0x5C
-};
-
+ 0x13, 0xAB, 0xA1, 0x5C};
/**
* @brief This struct defines the ASTC file header values. From ASTC specifications.
*/
struct AstcFileHeader
{
- unsigned char magic[ 4 ];
+ unsigned char magic[4];
unsigned char blockdim_x;
unsigned char blockdim_y;
unsigned char blockdim_z;
- unsigned char xsize[ 3 ];
- unsigned char ysize[ 3 ];
- unsigned char zsize[ 3 ];
-} __attribute__ ( (__packed__));
+ unsigned char xsize[3];
+ unsigned char ysize[3];
+ unsigned char zsize[3];
+} __attribute__((__packed__));
using namespace Pixel;
* IE. Table format is: Increasing order of block width from left-to-right: 4 -> 12
* Increasing order of block height from top-to-bottom: 4 -> 12
*/
-Pixel::Format AstcLinearBlockSizeToPixelFormatTable[][( MAXIMUM_ASTC_BLOCK_SIZE - MINIMUM_ASTC_BLOCK_SIZE ) + 1] = {
- { COMPRESSED_RGBA_ASTC_4x4_KHR, COMPRESSED_RGBA_ASTC_5x4_KHR, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID },
- { INVALID, COMPRESSED_RGBA_ASTC_5x5_KHR, COMPRESSED_RGBA_ASTC_6x5_KHR, INVALID, COMPRESSED_RGBA_ASTC_8x5_KHR, INVALID, COMPRESSED_RGBA_ASTC_10x5_KHR, INVALID, INVALID },
- { INVALID, INVALID, COMPRESSED_RGBA_ASTC_6x6_KHR, INVALID, COMPRESSED_RGBA_ASTC_8x6_KHR, INVALID, COMPRESSED_RGBA_ASTC_10x6_KHR, INVALID, INVALID },
- { INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID },
- { INVALID, INVALID, INVALID, INVALID, COMPRESSED_RGBA_ASTC_8x8_KHR, INVALID, COMPRESSED_RGBA_ASTC_10x8_KHR, INVALID, INVALID },
- { INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID },
- { INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, COMPRESSED_RGBA_ASTC_10x10_KHR, INVALID, COMPRESSED_RGBA_ASTC_12x10_KHR },
- { INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID },
- { INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, COMPRESSED_RGBA_ASTC_12x12_KHR }
-};
+Pixel::Format AstcLinearBlockSizeToPixelFormatTable[][(MAXIMUM_ASTC_BLOCK_SIZE - MINIMUM_ASTC_BLOCK_SIZE) + 1] = {
+ {COMPRESSED_RGBA_ASTC_4x4_KHR, COMPRESSED_RGBA_ASTC_5x4_KHR, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID},
+ {INVALID, COMPRESSED_RGBA_ASTC_5x5_KHR, COMPRESSED_RGBA_ASTC_6x5_KHR, INVALID, COMPRESSED_RGBA_ASTC_8x5_KHR, INVALID, COMPRESSED_RGBA_ASTC_10x5_KHR, INVALID, INVALID},
+ {INVALID, INVALID, COMPRESSED_RGBA_ASTC_6x6_KHR, INVALID, COMPRESSED_RGBA_ASTC_8x6_KHR, INVALID, COMPRESSED_RGBA_ASTC_10x6_KHR, INVALID, INVALID},
+ {INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID},
+ {INVALID, INVALID, INVALID, INVALID, COMPRESSED_RGBA_ASTC_8x8_KHR, INVALID, COMPRESSED_RGBA_ASTC_10x8_KHR, INVALID, INVALID},
+ {INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID},
+ {INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, COMPRESSED_RGBA_ASTC_10x10_KHR, INVALID, COMPRESSED_RGBA_ASTC_12x10_KHR},
+ {INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID},
+ {INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, COMPRESSED_RGBA_ASTC_12x12_KHR}};
/**
* @brief Uses header information to return the respective ASTC pixel format.
* @param[in] header A populated AstcFileHeader struct
* @return The pixel format, or INVALID if the block size was invalid
*/
-Pixel::Format GetAstcPixelFormat( AstcFileHeader& header )
+Pixel::Format GetAstcPixelFormat(AstcFileHeader& header)
{
// Check the block size is valid. This will also prevent an invalid read from the conversion table.
- if( ( header.blockdim_x < MINIMUM_ASTC_BLOCK_SIZE ) || ( header.blockdim_x > MAXIMUM_ASTC_BLOCK_SIZE ) ||
- ( header.blockdim_y < MINIMUM_ASTC_BLOCK_SIZE ) || ( header.blockdim_y > MAXIMUM_ASTC_BLOCK_SIZE ) )
+ if((header.blockdim_x < MINIMUM_ASTC_BLOCK_SIZE) || (header.blockdim_x > MAXIMUM_ASTC_BLOCK_SIZE) ||
+ (header.blockdim_y < MINIMUM_ASTC_BLOCK_SIZE) || (header.blockdim_y > MAXIMUM_ASTC_BLOCK_SIZE))
{
return Pixel::INVALID;
}
// Read the equivalent pixel format from the conversion table.
- return AstcLinearBlockSizeToPixelFormatTable[ header.blockdim_y - MINIMUM_ASTC_BLOCK_SIZE ][ header.blockdim_x - MINIMUM_ASTC_BLOCK_SIZE ];
+ return AstcLinearBlockSizeToPixelFormatTable[header.blockdim_y - MINIMUM_ASTC_BLOCK_SIZE][header.blockdim_x - MINIMUM_ASTC_BLOCK_SIZE];
}
/**
* @param[out] fileHeader This will be populated with the header data
* @return True if the file is valid, false otherwise
*/
-bool LoadAstcHeader( FILE * const filePointer, unsigned int& width, unsigned int& height, AstcFileHeader& fileHeader )
+bool LoadAstcHeader(FILE* const filePointer, unsigned int& width, unsigned int& height, AstcFileHeader& fileHeader)
{
// Pull the bytes of the file header in as a block:
- const unsigned int readLength = sizeof( AstcFileHeader );
- if( fread( &fileHeader, 1, readLength, filePointer ) != readLength )
+ const unsigned int readLength = sizeof(AstcFileHeader);
+ if(fread(&fileHeader, 1, readLength, filePointer) != readLength)
{
return false;
}
// Check the header contains the ASTC native file identifier.
- bool headerIsValid = memcmp( fileHeader.magic, FileIdentifier, sizeof( fileHeader.magic ) ) == 0;
- if( !headerIsValid )
+ bool headerIsValid = memcmp(fileHeader.magic, FileIdentifier, sizeof(fileHeader.magic)) == 0;
+ if(!headerIsValid)
{
- DALI_LOG_ERROR( "File is not a valid ASTC native file\n" );
+ DALI_LOG_ERROR("File is not a valid ASTC native file\n");
// Return here as otherwise, if not a valid ASTC file, we are likely to pick up other header errors spuriously.
return false;
}
// Convert the 3-byte values for width and height to a single resultant value.
- width = fileHeader.xsize[0] | ( fileHeader.xsize[1] << 8 ) | ( fileHeader.xsize[2] << 16 );
- height = fileHeader.ysize[0] | ( fileHeader.ysize[1] << 8 ) | ( fileHeader.ysize[2] << 16 );
+ width = fileHeader.xsize[0] | (fileHeader.xsize[1] << 8) | (fileHeader.xsize[2] << 16);
+ height = fileHeader.ysize[0] | (fileHeader.ysize[1] << 8) | (fileHeader.ysize[2] << 16);
- const unsigned int zDepth = static_cast<unsigned int>( fileHeader.zsize[0] )
- + ( static_cast<unsigned int>( fileHeader.zsize[1] ) << 8 )
- + ( static_cast<unsigned int>( fileHeader.zsize[2] ) << 16 );
+ const unsigned int zDepth = static_cast<unsigned int>(fileHeader.zsize[0]) + (static_cast<unsigned int>(fileHeader.zsize[1]) << 8) + (static_cast<unsigned int>(fileHeader.zsize[2]) << 16);
// Check image dimensions are within limits.
- if( ( width > MAX_TEXTURE_DIMENSION ) || ( height > MAX_TEXTURE_DIMENSION ) )
+ if((width > MAX_TEXTURE_DIMENSION) || (height > MAX_TEXTURE_DIMENSION))
{
- DALI_LOG_ERROR( "ASTC file has larger than supported dimensions: %d,%d\n", width, height );
+ DALI_LOG_ERROR("ASTC file has larger than supported dimensions: %d,%d\n", width, height);
headerIsValid = false;
}
// Confirm the ASTC block does not have any Z depth.
- if( zDepth != 1 )
+ if(zDepth != 1)
{
- DALI_LOG_ERROR( "ASTC files with z size other than 1 are not supported. Z size is: %d\n", zDepth );
+ DALI_LOG_ERROR("ASTC files with z size other than 1 are not supported. Z size is: %d\n", zDepth);
headerIsValid = false;
}
} // Unnamed namespace.
-
// File loading API entry-point:
-bool LoadAstcHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadAstcHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
AstcFileHeader fileHeader;
- return LoadAstcHeader( input.file, width, height, fileHeader );
+ return LoadAstcHeader(input.file, width, height, fileHeader);
}
// File loading API entry-point:
-bool LoadBitmapFromAstc( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromAstc(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
FILE* const filePointer = input.file;
- if( !filePointer )
+ if(!filePointer)
{
- DALI_LOG_ERROR( "Null file handle passed to ASTC compressed bitmap file loader.\n" );
+ DALI_LOG_ERROR("Null file handle passed to ASTC compressed bitmap file loader.\n");
return false;
}
// Load the header info.
AstcFileHeader fileHeader;
- unsigned int width, height;
+ unsigned int width, height;
- if( !LoadAstcHeader( filePointer, width, height, fileHeader ) )
+ if(!LoadAstcHeader(filePointer, width, height, fileHeader))
{
- DALI_LOG_ERROR( "Could not load ASTC Header from file.\n" );
+ DALI_LOG_ERROR("Could not load ASTC Header from file.\n");
return false;
}
// Retrieve the pixel format from the ASTC block size.
- Pixel::Format pixelFormat = GetAstcPixelFormat( fileHeader );
- if( pixelFormat == Pixel::INVALID )
+ Pixel::Format pixelFormat = GetAstcPixelFormat(fileHeader);
+ if(pixelFormat == Pixel::INVALID)
{
- DALI_LOG_ERROR( "No internal pixel format supported for ASTC file pixel format.\n" );
+ DALI_LOG_ERROR("No internal pixel format supported for ASTC file pixel format.\n");
return false;
}
// Retrieve the file size.
- if( fseek( filePointer, 0L, SEEK_END ) )
+ if(fseek(filePointer, 0L, SEEK_END))
{
- DALI_LOG_ERROR( "Could not seek through file.\n" );
+ DALI_LOG_ERROR("Could not seek through file.\n");
return false;
}
- off_t fileSize = ftell( filePointer );
- if( fileSize == -1L )
+ off_t fileSize = ftell(filePointer);
+ if(fileSize == -1L)
{
- DALI_LOG_ERROR( "Could not determine ASTC file size.\n" );
+ DALI_LOG_ERROR("Could not determine ASTC file size.\n");
return false;
}
- if( fseek( filePointer, sizeof( AstcFileHeader ), SEEK_SET ) )
+ if(fseek(filePointer, sizeof(AstcFileHeader), SEEK_SET))
{
- DALI_LOG_ERROR( "Could not seek through file.\n" );
+ DALI_LOG_ERROR("Could not seek through file.\n");
return false;
}
// Data size is file size - header size.
- size_t imageByteCount = fileSize - sizeof( AstcFileHeader );
+ size_t imageByteCount = fileSize - sizeof(AstcFileHeader);
// Sanity-check the image data is not too large and that it is at less than 2 bytes per texel:
- if( ( imageByteCount > MAX_IMAGE_DATA_SIZE ) || ( imageByteCount > ( ( static_cast< size_t >( width ) * height ) << 1 ) ) )
+ if((imageByteCount > MAX_IMAGE_DATA_SIZE) || (imageByteCount > ((static_cast<size_t>(width) * height) << 1)))
{
- DALI_LOG_ERROR( "ASTC file has too large image-data field.\n" );
+ DALI_LOG_ERROR("ASTC file has too large image-data field.\n");
return false;
}
// Compressed format won't allocate the buffer
auto pixels = bitmap.GetBuffer();
- if( !pixels )
+ if(!pixels)
{
// allocate buffer manually
- auto& impl = GetImplementation( bitmap );
- impl.AllocateFixedSize( imageByteCount );
+ auto& impl = GetImplementation(bitmap);
+ impl.AllocateFixedSize(imageByteCount);
pixels = bitmap.GetBuffer();
}
// Load the image data.
- const size_t bytesRead = fread( pixels, 1, imageByteCount, filePointer );
+ const size_t bytesRead = fread(pixels, 1, imageByteCount, filePointer);
// Check the size of loaded data is what we expected.
- if( bytesRead != imageByteCount )
+ if(bytesRead != imageByteCount)
{
- DALI_LOG_ERROR( "Read of image pixel data failed.\n" );
+ DALI_LOG_ERROR("Read of image pixel data failed.\n");
return false;
}
/*
- * Copyright (c) 2017 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.
#include <dali/internal/imaging/common/loader-bmp.h>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace
{
-const unsigned int FileHeaderOffsetOfBF32V4 = 0x7A;
-const unsigned int MaskForBFRGB565 = 0x80;
+const unsigned int FileHeaderOffsetOfBF32V4 = 0x7A;
+const unsigned int MaskForBFRGB565 = 0x80;
const unsigned int FileHeaderOffsetOfRGB24V5 = 0x8A;
enum BmpFormat
{
- BMP_RGB1 = 14, //BI_RGB & bpp =1
- BMP_RGB4, //BI_RGB & bpp = 4
- BMP_RGB8, //BI_RGB & bpp = 8
- BMP_RGB555, //BI_RGB & bpp = 16
- BMP_BITFIELDS555, //BI_BITFIELDS & 16bit & R:G:B = 5:5:5
- BMP_BITFIELDS32, //BI_BITFIELDS & 32bit & R:G:B:A = 8:8:8:8
- BMP_RLE8, //BI_RLE8
- BMP_RLE4, //BI_RLE4
- BMP_BITFIELDS32V4,//BI_BITFIELDS & 32bit
- BMP_RGB24V5, //BI_RGB & bpp = 24 & bmp version5
+ BMP_RGB1 = 14, //BI_RGB & bpp =1
+ BMP_RGB4, //BI_RGB & bpp = 4
+ BMP_RGB8, //BI_RGB & bpp = 8
+ BMP_RGB555, //BI_RGB & bpp = 16
+ BMP_BITFIELDS555, //BI_BITFIELDS & 16bit & R:G:B = 5:5:5
+ BMP_BITFIELDS32, //BI_BITFIELDS & 32bit & R:G:B:A = 8:8:8:8
+ BMP_RLE8, //BI_RLE8
+ BMP_RLE4, //BI_RLE4
+ BMP_BITFIELDS32V4, //BI_BITFIELDS & 32bit
+ BMP_RGB24V5, //BI_RGB & bpp = 24 & bmp version5
BMP_NOTEXIST
};
struct BmpFileHeader
{
- unsigned short signature; // Bitmap file signature
- unsigned int fileSize; // Bitmap file size in bytes
- unsigned short reserved1; // Reserved bits
- unsigned short reserved2; // Reserved bits
- unsigned int offset; // Offset from BMP file header to BMP bits
-} __attribute__ ( (__packed__)); // Stops the structure from being aligned to every 4 bytes
+ unsigned short signature; // Bitmap file signature
+ unsigned int fileSize; // Bitmap file size in bytes
+ unsigned short reserved1; // Reserved bits
+ unsigned short reserved2; // Reserved bits
+ unsigned int offset; // Offset from BMP file header to BMP bits
+} __attribute__((__packed__)); // Stops the structure from being aligned to every 4 bytes
struct BmpInfoHeader
{
unsigned int yPixelsPerMeter; // The number of pixels per meter in y axis
unsigned int numberOfColors; // The number of colors in the color table
unsigned int importantColors; // The important color count
-} __attribute__ ( (__packed__)); // Stops the structure from being aligned to every 4 bytes
+} __attribute__((__packed__)); // Stops the structure from being aligned to every 4 bytes
/**
* Template function to read from the file directly into our structure.
const unsigned int readLength = sizeof(T);
// Load the information directly into our structure
- if ( fread( &header, 1, readLength, fp ) != readLength )
+ if(fread(&header, 1, readLength, fp) != readLength)
{
return false;
}
return true;
}
-bool LoadBmpHeader(FILE *fp, unsigned int &width, unsigned int &height, BmpFileHeader &fileHeader, BmpInfoHeader &infoHeader)
+bool LoadBmpHeader(FILE* fp, unsigned int& width, unsigned int& height, BmpFileHeader& fileHeader, BmpInfoHeader& infoHeader)
{
- if (!ReadHeader(fp, fileHeader))
+ if(!ReadHeader(fp, fileHeader))
{
return false;
}
- if (!ReadHeader(fp, infoHeader))
+ if(!ReadHeader(fp, infoHeader))
{
return false;
}
- width = infoHeader.width;
+ width = infoHeader.width;
height = abs(infoHeader.height);
- if( infoHeader.width == 0 )
+ if(infoHeader.width == 0)
{
return false;
}
* @param[in] padding padded to a u_int32 boundary for each line
* @return true, if decode successful, false otherwise
*/
-bool DecodeRGB24V5(FILE *fp,
+bool DecodeRGB24V5(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown,
- unsigned int rowStride,
- unsigned int padding)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown,
+ unsigned int rowStride,
+ unsigned int padding)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_RGB24V5 format\n");
return false;
}
- if ( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RGB24V5 data\n");
return false;
}
- for(unsigned int yPos = 0; yPos < height; yPos ++)
+ for(unsigned int yPos = 0; yPos < height; yPos++)
{
unsigned char* pixelsPtr = NULL;
if(topDown)
{
- pixelsPtr = pixels + ( yPos * rowStride);
+ pixelsPtr = pixels + (yPos * rowStride);
}
else
{
- pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
+ pixelsPtr = pixels + (((height - 1) - yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if(fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
for(unsigned int i = 0; i < rowStride; i += 3)
{
unsigned char temp = pixelsPtr[i];
- pixelsPtr[i] = pixelsPtr[i + 2];
- pixelsPtr[i + 2] = temp;
+ pixelsPtr[i] = pixelsPtr[i + 2];
+ pixelsPtr[i + 2] = temp;
}
- if (padding)
+ if(padding)
{
// move past the padding.
- if( fseek(fp, padding, SEEK_CUR) )
+ if(fseek(fp, padding, SEEK_CUR))
{
DALI_LOG_ERROR("Error moving past BMP_RGB24V5 padding\n");
}
* @param[in] padding padded to a u_int32 boundary for each line
* @return true, if decode successful, false otherwise
*/
-bool DecodeBF32V4(FILE *fp,
+bool DecodeBF32V4(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown,
- unsigned int rowStride,
- unsigned int padding)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown,
+ unsigned int rowStride,
+ unsigned int padding)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32V4 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32V4 data\n");
return false;
}
- for(unsigned int yPos = 0; yPos < height; yPos ++)
+ for(unsigned int yPos = 0; yPos < height; yPos++)
{
unsigned char* pixelsPtr = NULL;
if(topDown)
{
- pixelsPtr = pixels + ( yPos * rowStride);
+ pixelsPtr = pixels + (yPos * rowStride);
}
else
{
- pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
+ pixelsPtr = pixels + (((height - 1) - yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if(fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
for(unsigned int i = 0; i < rowStride; i += 4)
{
unsigned char temp = pixelsPtr[i];
- pixelsPtr[i] = pixelsPtr[i + 2];
- pixelsPtr[i + 2] = temp;
+ pixelsPtr[i] = pixelsPtr[i + 2];
+ pixelsPtr[i + 2] = temp;
}
- if (padding)
+ if(padding)
{
// move past the padding.
- if( fseek(fp, padding, SEEK_CUR) )
+ if(fseek(fp, padding, SEEK_CUR))
{
DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32V4 padding\n");
}
}
-
}
return true;
}
* @param[in] padding padded to a u_int32 boundary for each line
* @return true, if decode successful, false otherwise
*/
-bool DecodeBF32(FILE *fp,
+bool DecodeBF32(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown,
- unsigned int rowStride,
- unsigned int padding)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown,
+ unsigned int rowStride,
+ unsigned int padding)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32 data\n");
return false;
}
- for (unsigned int yPos = 0; yPos < height; yPos++)
+ for(unsigned int yPos = 0; yPos < height; yPos++)
{
unsigned char* pixelsPtr;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( yPos * rowStride);
+ pixelsPtr = pixels + (yPos * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
- pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
+ pixelsPtr = pixels + (((height - 1) - yPos) * rowStride);
}
- if (fread(pixelsPtr, 1, rowStride, fp) != rowStride)
+ if(fread(pixelsPtr, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
for(unsigned int i = 0; i < rowStride; i += 4)
{
unsigned char temp = pixelsPtr[i];
- pixelsPtr[i] = pixelsPtr[i + 2];
- pixelsPtr[i + 2] = temp;
+ pixelsPtr[i] = pixelsPtr[i + 2];
+ pixelsPtr[i + 2] = temp;
}
- if (padding)
+ if(padding)
{
// move past the padding.
- if( fseek(fp, padding, SEEK_CUR) )
+ if(fseek(fp, padding, SEEK_CUR))
{
DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32 padding\n");
}
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeBF565(FILE *fp,
+bool DecodeBF565(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding RGB565 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking RGB565 data\n");
return false;
}
- width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
+ width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
unsigned int rowStride = width * 2;
for(unsigned int i = 0; i < height; i++)
{
unsigned char* pixelsPtr = NULL;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( i * rowStride);
+ pixelsPtr = pixels + (i * rowStride);
}
else
{
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeBF555(FILE *fp,
+bool DecodeBF555(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_BITFIELDS555 data\n");
return false;
width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
std::vector<char> raw(width * height * 2);
- unsigned int rawStride = width * 2;
- unsigned int rowStride = width * 3;
+ unsigned int rawStride = width * 2;
+ unsigned int rowStride = width * 3;
- char *rawPtr = NULL;
- for(unsigned int j = 0; j < height; j ++)
+ char* rawPtr = NULL;
+ for(unsigned int j = 0; j < height; j++)
{
- rawPtr = &raw[0] + ( j * rawStride);
+ rawPtr = &raw[0] + (j * rawStride);
if(fread(rawPtr, 1, rawStride, fp) != rawStride)
{
return false;
}
}
- for (unsigned int yPos = 0; yPos < height; yPos++)
+ for(unsigned int yPos = 0; yPos < height; yPos++)
{
unsigned char* pixelsPtr = NULL;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( yPos * rowStride);
+ pixelsPtr = pixels + (yPos * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
- pixelsPtr = pixels + (((height-1)-yPos) * rowStride);
+ pixelsPtr = pixels + (((height - 1) - yPos) * rowStride);
}
- for(unsigned int k = 0; k < width; k ++)
+ for(unsigned int k = 0; k < width; k++)
{
- int index = yPos * rawStride + 2 * k;
- pixelsPtr[3 * k] = ((raw[ index + 1] >> 2) & 0x1F) * 0xFF / 0x1F;
- pixelsPtr[3 * k + 1] = (((raw[index + 1] & 0x03) << 3) | (raw[ index] >> 5)) * 0xFF/ 0x1F;
- pixelsPtr[3 * k + 2] = (raw[ index] & 0x1F) * 0xFF / 0x1F;
+ int index = yPos * rawStride + 2 * k;
+ pixelsPtr[3 * k] = ((raw[index + 1] >> 2) & 0x1F) * 0xFF / 0x1F;
+ pixelsPtr[3 * k + 1] = (((raw[index + 1] & 0x03) << 3) | (raw[index] >> 5)) * 0xFF / 0x1F;
+ pixelsPtr[3 * k + 2] = (raw[index] & 0x1F) * 0xFF / 0x1F;
}
}
return true;
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeRGB555(FILE *fp,
+bool DecodeRGB555(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_RGB555 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RGB555 data\n");
return false;
width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
std::vector<char> raw(width * height * 2);
- unsigned int rawStride = width * 2;
- unsigned int rowStride = width * 3;
+ unsigned int rawStride = width * 2;
+ unsigned int rowStride = width * 3;
- char *rawPtr = NULL;
- for(unsigned int j = 0; j < height; j ++)
+ char* rawPtr = NULL;
+ for(unsigned int j = 0; j < height; j++)
{
- rawPtr = &raw[0] + ( j * rawStride);
+ rawPtr = &raw[0] + (j * rawStride);
if(fread(rawPtr, 1, rawStride, fp) != rawStride)
{
return false;
for(unsigned int i = 0; i < height; i++)
{
unsigned char* pixelsPtr = NULL;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( i * rowStride);
+ pixelsPtr = pixels + (i * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
pixelsPtr = pixels + (((height - 1) - i) * rowStride);
}
- for(unsigned int k = 0; k < width; k ++)
+ for(unsigned int k = 0; k < width; k++)
{
- int index = i * rawStride + 2 * k;
- pixelsPtr[3 * k] = ((raw[ index + 1] >> 2) & 0x1F) * 0xFF / 0x1F;
- pixelsPtr[3 * k + 1] = (((raw[index + 1] & 0x03) << 3) | (raw[ index] >> 5)) * 0xFF/ 0x1F;
- pixelsPtr[3 * k + 2] = (raw[ index] & 0x1F) * 0xFF / 0x1F;
+ int index = i * rawStride + 2 * k;
+ pixelsPtr[3 * k] = ((raw[index + 1] >> 2) & 0x1F) * 0xFF / 0x1F;
+ pixelsPtr[3 * k + 1] = (((raw[index + 1] & 0x03) << 3) | (raw[index] >> 5)) * 0xFF / 0x1F;
+ pixelsPtr[3 * k + 2] = (raw[index] & 0x1F) * 0xFF / 0x1F;
}
-
}
return true;
}
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeRGB1(FILE *fp,
+bool DecodeRGB1(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_RGB1 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RGB1 data\n");
return false;
}
- unsigned char colorTable[8] = {0};
- char cmd;
- unsigned int fillw = ((width & 63) != 0) ? width + 64 - (width & 63) : width;
+ unsigned char colorTable[8] = {0};
+ char cmd;
+ unsigned int fillw = ((width & 63) != 0) ? width + 64 - (width & 63) : width;
std::vector<char> colorIndex(fillw * height);
- unsigned int rowStride = fillw * 3; // RGB
-
+ unsigned int rowStride = fillw * 3; // RGB
if(fread(colorTable, 1, 8, fp) != 8)
{
for(unsigned int index = 0; index < height; index = index + 1)
{
unsigned char* pixelsPtr = NULL;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( index * rowStride);
+ pixelsPtr = pixels + (index * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
pixelsPtr = pixels + (((height - 1) - index) * rowStride);
}
- for(unsigned int j = 0; j < fillw; j ++)
+ for(unsigned int j = 0; j < fillw; j++)
{
unsigned int ctIndex = 0;
- if((fillw * index + j ) < (fillw * height))
+ if((fillw * index + j) < (fillw * height))
{
- ctIndex = colorIndex[ fillw * index + j ];
+ ctIndex = colorIndex[fillw * index + j];
}
else
{
break;
}
// temp solution for PLM bug P130411-5268, there is one mono bmp that cause DecodeRGB1 API crash.
- if( ((3 * j + 2) < height * fillw * 3) && (ctIndex < 2))
+ if(((3 * j + 2) < height * fillw * 3) && (ctIndex < 2))
{
- pixelsPtr[ 3 * j ] = colorTable[4 * ctIndex + 2];
+ pixelsPtr[3 * j] = colorTable[4 * ctIndex + 2];
pixelsPtr[3 * j + 1] = colorTable[4 * ctIndex + 1];
- pixelsPtr[3 * j + 2] = colorTable[4 * ctIndex ];
+ pixelsPtr[3 * j + 2] = colorTable[4 * ctIndex];
}
}
}
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeRGB4(FILE *fp,
+bool DecodeRGB4(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_RGB4 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RGB4 data\n");
return false;
}
- char colorTable[64];
- char cmd;
- unsigned int fillw = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
+ char colorTable[64];
+ char cmd;
+ unsigned int fillw = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
std::vector<char> colorIndex(fillw * height);
- unsigned int rowStride = fillw * 3;
+ unsigned int rowStride = fillw * 3;
if(fread(colorTable, 1, 64, fp) != 64)
{
for(unsigned int i = 0; i < fillw * height; i += 2)
{
- if (fread(&cmd, 1, 1, fp) != 1)
+ if(fread(&cmd, 1, 1, fp) != 1)
{
return false;
}
- colorIndex[i] = cmd >> 4;
+ colorIndex[i] = cmd >> 4;
colorIndex[i + 1] = cmd & (0x0F);
}
unsigned int ctIndex = 0;
for(unsigned int index = 0; index < height; index = index + 1)
{
unsigned char* pixelsPtr = NULL;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( index * rowStride);
+ pixelsPtr = pixels + (index * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
pixelsPtr = pixels + (((height - 1) - index) * rowStride);
}
- for(unsigned int j = 0; j < fillw; j ++)
+ for(unsigned int j = 0; j < fillw; j++)
{
- ctIndex = colorIndex[ fillw * index + j ];
- pixelsPtr[ 3 * j ] = colorTable[4 * ctIndex + 2];
+ ctIndex = colorIndex[fillw * index + j];
+ pixelsPtr[3 * j] = colorTable[4 * ctIndex + 2];
pixelsPtr[(3 * j + 1)] = colorTable[4 * ctIndex + 1];
- pixelsPtr[(3 * j + 2)] = colorTable[4 * ctIndex ];
+ pixelsPtr[(3 * j + 2)] = colorTable[4 * ctIndex];
}
}
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeRGB8(FILE *fp,
+bool DecodeRGB8(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
DALI_LOG_ERROR("Error decoding BMP_RGB8 format\n");
return false;
}
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RGB8 data\n");
return false;
std::vector<char> colorTable(1024);
width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
- char cmd;
+ char cmd;
std::vector<char> colorIndex(width * height);
- unsigned int rowStride = width * 3;//RGB8->RGB24
+ unsigned int rowStride = width * 3; //RGB8->RGB24
if(fread(&colorTable[0], 1, 1024, fp) != 1024)
{
return false;
}
- for(unsigned int i = 0; i < width * height; i ++)
+ for(unsigned int i = 0; i < width * height; i++)
{
- if (fread(&cmd, 1, 1, fp) != 1)
+ if(fread(&cmd, 1, 1, fp) != 1)
{
return false;
}
for(unsigned int index = 0; index < height; index = index + 1)
{
unsigned char* pixelsPtr = NULL;
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsPtr = pixels + ( index * rowStride);
+ pixelsPtr = pixels + (index * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
pixelsPtr = pixels + (((height - 1) - index) * rowStride);
}
- for(unsigned int j = 0; j < width; j ++)
+ for(unsigned int j = 0; j < width; j++)
{
- ctIndex = colorIndex[ width * index + j ];
- pixelsPtr[ 3 * j ] = colorTable[4 * ctIndex + 2];
+ ctIndex = colorIndex[width * index + j];
+ pixelsPtr[3 * j] = colorTable[4 * ctIndex + 2];
pixelsPtr[(3 * j + 1)] = colorTable[4 * ctIndex + 1];
- pixelsPtr[(3 * j + 2)] = colorTable[4 * ctIndex ];
+ pixelsPtr[(3 * j + 2)] = colorTable[4 * ctIndex];
}
}
return true;
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeRLE4(FILE *fp,
+bool DecodeRLE4(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
return false;
}
unsigned char* pixelsPtr = pixels;
- width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
- char cmd[2];
- unsigned int cmdStride = 2;
- char colorTable[64];
+ width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
+ char cmd[2];
+ unsigned int cmdStride = 2;
+ char colorTable[64];
std::vector<char> colorIndex(width * height >> 1);
std::vector<char> run;
- unsigned int x = 0;
- unsigned int y = 0;
- unsigned int dx = 0;
- unsigned int dy = 0;
+ unsigned int x = 0;
+ unsigned int y = 0;
+ unsigned int dx = 0;
+ unsigned int dy = 0;
width += (width & 1);
width = width >> 1;
bool finish = false;
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RLE4 data\n");
return false;
}
- if (fread(colorTable, 1, 64, fp) != 64)
+ if(fread(colorTable, 1, 64, fp) != 64)
{
return false;
}
while((x >> 1) + y * width < width * height)
{
- if (finish)
+ if(finish)
{
break;
}
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if(fread(cmd, 1, cmdStride, fp) != cmdStride)
{
return false;
}
break;
case 0: // end of line
x = 0;
- y ++;
+ y++;
break;
case 2: // delta
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if(fread(cmd, 1, cmdStride, fp) != cmdStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
}
else
{
- for(unsigned int i = 0; i < length; i ++)
+ for(unsigned int i = 0; i < length; i++)
{
- if((i & 1) == 0)//copy high to low
+ if((i & 1) == 0) //copy high to low
{
colorIndex[((x + i) >> 1) + width * (height - y - 1)] |= ((run[i >> 1] & 0xF0) >> 4);
}
{
length += (length & 1);
length >>= 1;
- for(unsigned int i = 0; i < length; i ++)
+ for(unsigned int i = 0; i < length; i++)
{
- colorIndex[(height-y-1)*width + i + (x >> 1)] = cmd[1];
+ colorIndex[(height - y - 1) * width + i + (x >> 1)] = cmd[1];
}
}
else
{
- for(unsigned int i = 0; i < length; i ++)
+ for(unsigned int i = 0; i < length; i++)
{
if((i & 1) == 0)
{
}
int ctIndexHigh = 0;
- int ctIndexLow = 0;
- for(unsigned int index = 0; index < (width * height ); index = index + 1)
+ int ctIndexLow = 0;
+ for(unsigned int index = 0; index < (width * height); index = index + 1)
{
- ctIndexHigh = colorIndex[ index] >> 4;
- ctIndexLow = colorIndex[index] & (0x0F);
- pixelsPtr[6 * index ] = colorTable[4 * ctIndexHigh + 2];
+ ctIndexHigh = colorIndex[index] >> 4;
+ ctIndexLow = colorIndex[index] & (0x0F);
+ pixelsPtr[6 * index] = colorTable[4 * ctIndexHigh + 2];
pixelsPtr[6 * index + 1] = colorTable[4 * ctIndexHigh + 1];
- pixelsPtr[6 * index + 2] = colorTable[4 * ctIndexHigh ];
+ pixelsPtr[6 * index + 2] = colorTable[4 * ctIndexHigh];
pixelsPtr[6 * index + 3] = colorTable[4 * ctIndexLow + 2];
pixelsPtr[6 * index + 4] = colorTable[4 * ctIndexLow + 1];
- pixelsPtr[6 * index + 5] = colorTable[4 * ctIndexLow ];
+ pixelsPtr[6 * index + 5] = colorTable[4 * ctIndexLow];
}
return true;
}
* @param[in] topDown indicate image data is read from bottom or from top
* @return true, if decode successful, false otherwise
*/
-bool DecodeRLE8(FILE *fp,
+bool DecodeRLE8(FILE* fp,
unsigned char* pixels,
- unsigned int width,
- unsigned int height,
- unsigned int offset,
- bool topDown)
+ unsigned int width,
+ unsigned int height,
+ unsigned int offset,
+ bool topDown)
{
if(fp == NULL || pixels == NULL)
{
return false;
}
unsigned char* pixelsPtr = pixels;
- unsigned int x = 0;
- unsigned int y = 0;
- unsigned int cmdStride = 2;
+ unsigned int x = 0;
+ unsigned int y = 0;
+ unsigned int cmdStride = 2;
width = ((width & 3) != 0) ? width + 4 - (width & 3) : width;
std::vector<char> colorTable(1024);
- char cmd[2];
+ char cmd[2];
std::vector<char> colorIndex(width * height);
- if( fseek(fp, offset, SEEK_SET) )
+ if(fseek(fp, offset, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking BMP_RLE8 data\n");
return false;
}
- if (fread(&colorTable[0], 1, 1024, fp) != 1024)
+ if(fread(&colorTable[0], 1, 1024, fp) != 1024)
{
return false;
}
- unsigned int dx = 0;
- unsigned int dy = 0;
- bool finish = false;
- unsigned int length = 0;
- unsigned int copylength = 0;
+ unsigned int dx = 0;
+ unsigned int dy = 0;
+ bool finish = false;
+ unsigned int length = 0;
+ unsigned int copylength = 0;
std::vector<char> run;
- while((x + y * width) < width * height )
+ while((x + y * width) < width * height)
{
- if (finish)
+ if(finish)
{
break;
}
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if(fread(cmd, 1, cmdStride, fp) != cmdStride)
{
return false;
}
- if(cmd[0] == 0)//ESCAPE
+ if(cmd[0] == 0) //ESCAPE
{
switch(cmd[1])
{
break;
case 0: // end of line
x = 0;
- y ++;
+ y++;
break;
case 2: // delta
- if (fread(cmd, 1, cmdStride, fp) != cmdStride)
+ if(fread(cmd, 1, cmdStride, fp) != cmdStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
return false;
break;
default:
//decode a literal run
- length = cmd[1] & (0xFF);
+ length = cmd[1] & (0xFF);
copylength = length;
//absolute mode must be word-aligned
length += (length & 1);
x += copylength;
break;
}
- }// end if cmd[0] ==
+ } // end if cmd[0] ==
else
{
length = cmd[0] & (0xFF);
- for(unsigned int i = 0; i < length; i ++)
+ for(unsigned int i = 0; i < length; i++)
{
colorIndex[(height - y - 1) * width + x] = cmd[1];
x++;
int ctIndex = 0;
for(unsigned int index = 0; index < width * height; index = index + 1)
{
- ctIndex = colorIndex[ index];
- pixelsPtr[3 * index ] = colorTable[4 * ctIndex + 2];
+ ctIndex = colorIndex[index];
+ pixelsPtr[3 * index] = colorTable[4 * ctIndex + 2];
pixelsPtr[3 * index + 1] = colorTable[4 * ctIndex + 1];
- pixelsPtr[3 * index + 2] = colorTable[4 * ctIndex ];
+ pixelsPtr[3 * index + 2] = colorTable[4 * ctIndex];
}
return true;
}
} // unnamed namespace
-bool LoadBmpHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadBmpHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
BmpFileHeader fileHeader;
BmpInfoHeader infoHeader;
- bool ret = LoadBmpHeader( input.file, width, height, fileHeader, infoHeader );
+ bool ret = LoadBmpHeader(input.file, width, height, fileHeader, infoHeader);
return ret;
}
-bool LoadBitmapFromBmp( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromBmp(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
//DALI_ASSERT_DEBUG( bitmap.GetPackedPixelsProfile() != 0 && "Need a packed pixel bitmap to load into." );
FILE* const fp = input.file;
DALI_LOG_ERROR("Error loading bitmap\n");
return false;
}
- BmpFormat customizedFormat = BMP_NOTEXIST;
+ BmpFormat customizedFormat = BMP_NOTEXIST;
BmpFileHeader fileHeader;
BmpInfoHeader infoHeader;
// Load the header info
unsigned int width, height;
- if (!LoadBmpHeader(fp, width, height, fileHeader, infoHeader))
+ if(!LoadBmpHeader(fp, width, height, fileHeader, infoHeader))
{
- return false;
+ return false;
}
Pixel::Format pixelFormat = Pixel::RGB888;
switch(infoHeader.compression)
{
case 0:
- switch (infoHeader.bitsPerPixel)
+ switch(infoHeader.bitsPerPixel)
{
case 32:
pixelFormat = Pixel::BGR8888;
break;
case 24:
- if(fileHeader.offset == FileHeaderOffsetOfRGB24V5)//0x8A
+ if(fileHeader.offset == FileHeaderOffsetOfRGB24V5) //0x8A
{
customizedFormat = BMP_RGB24V5;
}
DALI_LOG_WARNING("%d bits per pixel not supported for BMP files\n", infoHeader.bitsPerPixel);
return false;
}
- break;
+ break;
case 1: //// RLE8
{
if(infoHeader.bitsPerPixel == 8)
{
if(infoHeader.bitsPerPixel == 16)
{
- if( fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET) )
+ if(fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET))
{
return false;
}
{
pixelFormat = Pixel::RGB565;
}
- else if((mask & 0x80) == 0)// mask is 0x 7C
+ else if((mask & 0x80) == 0) // mask is 0x 7C
{
customizedFormat = BMP_BITFIELDS555;
}
}
else if(infoHeader.bitsPerPixel == 32)
{
- if(fileHeader.offset == FileHeaderOffsetOfBF32V4)// 0x7A
+ if(fileHeader.offset == FileHeaderOffsetOfBF32V4) // 0x7A
{
customizedFormat = BMP_BITFIELDS32V4;
}
bool topDown = false;
// if height is negative, bitmap data is top down
- if (infoHeader.height<0)
+ if(infoHeader.height < 0)
{
- infoHeader.height = abs(infoHeader.height);
- height = infoHeader.height;
- topDown = true;
+ infoHeader.height = abs(infoHeader.height);
+ height = infoHeader.height;
+ topDown = true;
}
- unsigned int rowStride = infoHeader.width * (infoHeader.bitsPerPixel >>3);
+ unsigned int rowStride = infoHeader.width * (infoHeader.bitsPerPixel >> 3);
// bitmaps row stride is padded to 4 bytes
unsigned int padding = (rowStride % 4);
- if (padding)
+ if(padding)
{
padding = 4 - padding;
}
- int imageW = infoHeader.width;
- int pixelBufferW = infoHeader.width;
- int pixelBufferH = infoHeader.height;
+ int imageW = infoHeader.width;
+ int pixelBufferW = infoHeader.width;
+ int pixelBufferH = infoHeader.height;
auto newPixelFormat = Pixel::Format::INVALID;
switch(customizedFormat)
{
- case BMP_RLE8:
- case BMP_RGB8:
- case BMP_RGB4:
- case BMP_RLE4:
- case BMP_RGB555:
- case BMP_BITFIELDS555:
- {
- pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
- pixelBufferH = abs(infoHeader.height);
- newPixelFormat = Pixel::RGB888;
- break;
- }
- case BMP_RGB1:
- {
- pixelBufferW = ((imageW & 63) != 0) ? imageW + 64 - (imageW & 63) : imageW;
- pixelBufferH = abs(infoHeader.height);
- newPixelFormat = Pixel::RGB888;
- break;
- }
- case BMP_BITFIELDS32:
- case BMP_BITFIELDS32V4:
- {
- pixelBufferH = abs(infoHeader.height);
- newPixelFormat = Pixel::RGB8888;
- break;
- }
- case BMP_RGB24V5:
- {
- newPixelFormat = Pixel::RGB888;
- break;
- }
- default:
- if(pixelFormat == Pixel::RGB565 )
+ case BMP_RLE8:
+ case BMP_RGB8:
+ case BMP_RGB4:
+ case BMP_RLE4:
+ case BMP_RGB555:
+ case BMP_BITFIELDS555:
{
- pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
- pixelBufferH = abs(infoHeader.height);
- newPixelFormat = Pixel::RGB565;
+ pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB888;
+ break;
}
- else
+ case BMP_RGB1:
{
- pixelBufferW = infoHeader.width;
- pixelBufferH = infoHeader.height;
- newPixelFormat = pixelFormat;
+ pixelBufferW = ((imageW & 63) != 0) ? imageW + 64 - (imageW & 63) : imageW;
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB888;
+ break;
}
- break;
+ case BMP_BITFIELDS32:
+ case BMP_BITFIELDS32V4:
+ {
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB8888;
+ break;
+ }
+ case BMP_RGB24V5:
+ {
+ newPixelFormat = Pixel::RGB888;
+ break;
+ }
+ default:
+ if(pixelFormat == Pixel::RGB565)
+ {
+ pixelBufferW = ((imageW & 3) != 0) ? imageW + 4 - (imageW & 3) : imageW;
+ pixelBufferH = abs(infoHeader.height);
+ newPixelFormat = Pixel::RGB565;
+ }
+ else
+ {
+ pixelBufferW = infoHeader.width;
+ pixelBufferH = infoHeader.height;
+ newPixelFormat = pixelFormat;
+ }
+ break;
}
- bitmap = Dali::Devel::PixelBuffer::New(pixelBufferW, pixelBufferH, newPixelFormat);
+ bitmap = Dali::Devel::PixelBuffer::New(pixelBufferW, pixelBufferH, newPixelFormat);
auto pixels = bitmap.GetBuffer();
// Read the raw bitmap data
{
case BMP_RGB1:
{
- decodeResult = DecodeRGB1( fp, pixels, infoHeader.width, abs(infoHeader.height), 14 + infoHeader.infoHeaderSize, topDown);
+ decodeResult = DecodeRGB1(fp, pixels, infoHeader.width, abs(infoHeader.height), 14 + infoHeader.infoHeaderSize, topDown);
break;
}
case BMP_RGB4:
}
case BMP_RLE4:
{
- decodeResult = DecodeRLE4( fp, pixels, infoHeader.width, abs(infoHeader.height), 14 + infoHeader.infoHeaderSize, topDown);
+ decodeResult = DecodeRLE4(fp, pixels, infoHeader.width, abs(infoHeader.height), 14 + infoHeader.infoHeaderSize, topDown);
break;
}
case BMP_BITFIELDS32:
{
- decodeResult = DecodeBF32(fp, pixels, infoHeader.width, abs(infoHeader.height), fileHeader.offset, topDown, rowStride, padding);
+ decodeResult = DecodeBF32(fp, pixels, infoHeader.width, abs(infoHeader.height), fileHeader.offset, topDown, rowStride, padding);
break;
}
case BMP_BITFIELDS555:
{
- decodeResult = DecodeBF555(fp, pixels,infoHeader.width, abs(infoHeader.height), fileHeader.offset, topDown);
+ decodeResult = DecodeBF555(fp, pixels, infoHeader.width, abs(infoHeader.height), fileHeader.offset, topDown);
break;
}
case BMP_RGB555:
{
if(pixelFormat == Pixel::RGB565)
{
- decodeResult = DecodeBF565(fp, pixels, infoHeader.width, abs(infoHeader.height), fileHeader.offset, topDown);
+ decodeResult = DecodeBF565(fp, pixels, infoHeader.width, abs(infoHeader.height), fileHeader.offset, topDown);
}
else
{
- for (unsigned int yPos = 0; yPos < height; yPos++)
+ for(unsigned int yPos = 0; yPos < height; yPos++)
{
- if (topDown)
+ if(topDown)
{
// the data in the file is top down, and we store the data top down
- pixelsIterator = pixels + ( yPos * rowStride);
+ pixelsIterator = pixels + (yPos * rowStride);
}
else
{
// the data in the file is bottom up, and we store the data top down
- pixelsIterator = pixels + (((height-1)-yPos) * rowStride);
+ pixelsIterator = pixels + (((height - 1) - yPos) * rowStride);
}
- if (fread(pixelsIterator, 1, rowStride, fp) != rowStride)
+ if(fread(pixelsIterator, 1, rowStride, fp) != rowStride)
{
DALI_LOG_ERROR("Error reading the BMP image\n");
break;
// If 24 bit mode then swap Blue and Red pixels
// BGR888 doesn't seem to be supported by dali-core
- if (infoHeader.bitsPerPixel == 24 )
+ if(infoHeader.bitsPerPixel == 24)
{
for(unsigned int i = 0; i < rowStride; i += 3)
{
- unsigned char temp = pixelsIterator[i];
- pixelsIterator[i] = pixelsIterator[i+2];
- pixelsIterator[i+2] = temp;
+ unsigned char temp = pixelsIterator[i];
+ pixelsIterator[i] = pixelsIterator[i + 2];
+ pixelsIterator[i + 2] = temp;
}
}
- if (padding)
+ if(padding)
{
- if( fseek(fp, padding, SEEK_CUR) ) // move past the padding.
+ if(fseek(fp, padding, SEEK_CUR)) // move past the padding.
{
DALI_LOG_ERROR("Error moving past BMP padding\n");
}
}
} // switch
- if( !decodeResult )
+ if(!decodeResult)
{
return false;
}
/*
- * Copyright (c) 2017 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.
#include <gif_lib.h>
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/debug.h>
#include <memory>
// We need to check if giflib has the new open and close API (including error parameter).
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace
{
-
// simple class to enforce clean-up of GIF structures
struct AutoCleanupGif
{
// clean up GIF resources
#ifdef LIBGIF_VERSION_5_1_OR_ABOVE
int errorCode = 0; //D_GIF_SUCCEEDED is 0
- DGifCloseFile( gifInfo, &errorCode );
+ DGifCloseFile(gifInfo, &errorCode);
- if( errorCode )
+ if(errorCode)
{
- DALI_LOG_ERROR( "GIF Loader: DGifCloseFile Error. Code: %d\n", errorCode );
+ DALI_LOG_ERROR("GIF Loader: DGifCloseFile Error. Code: %d\n", errorCode);
}
#else
- DGifCloseFile( gifInfo );
+ DGifCloseFile(gifInfo);
#endif
}
}
// Used in the GIF interlace algorithm to determine the order and which location to read data from
// the file.
-const InterlacePair INTERLACE_PAIR_TABLE [] = {
- { 0, 8 }, // Starting at 0, read every 8 bytes.
- { 4, 8 }, // Starting at 4, read every 8 bytes.
- { 2, 4 }, // Starting at 2, read every 4 bytes.
- { 1, 2 }, // Starting at 1, read every 2 bytes.
+const InterlacePair INTERLACE_PAIR_TABLE[] = {
+ {0, 8}, // Starting at 0, read every 8 bytes.
+ {4, 8}, // Starting at 4, read every 8 bytes.
+ {2, 4}, // Starting at 2, read every 4 bytes.
+ {1, 2}, // Starting at 1, read every 2 bytes.
};
-const unsigned int INTERLACE_PAIR_TABLE_SIZE( sizeof( INTERLACE_PAIR_TABLE ) / sizeof( InterlacePair ) );
+const unsigned int INTERLACE_PAIR_TABLE_SIZE(sizeof(INTERLACE_PAIR_TABLE) / sizeof(InterlacePair));
/// Function used by Gif_Lib to read from the image file.
-int ReadDataFromGif(GifFileType *gifInfo, GifByteType *data, int length)
+int ReadDataFromGif(GifFileType* gifInfo, GifByteType* data, int length)
{
- FILE *fp = reinterpret_cast<FILE*>(gifInfo->UserData);
- return fread( data, sizeof( GifByteType ), length, fp);
+ FILE* fp = reinterpret_cast<FILE*>(gifInfo->UserData);
+ return fread(data, sizeof(GifByteType), length, fp);
}
/// Loads the GIF Header.
-bool LoadGifHeader(FILE *fp, unsigned int &width, unsigned int &height, GifFileType** gifInfo)
+bool LoadGifHeader(FILE* fp, unsigned int& width, unsigned int& height, GifFileType** gifInfo)
{
int errorCode = 0; //D_GIF_SUCCEEDED is 0
#ifdef LIBGIF_VERSION_5_1_OR_ABOVE
- *gifInfo = DGifOpen( reinterpret_cast<void*>(fp), ReadDataFromGif, &errorCode );
+ *gifInfo = DGifOpen(reinterpret_cast<void*>(fp), ReadDataFromGif, &errorCode);
#else
- *gifInfo = DGifOpen( reinterpret_cast<void*>(fp), ReadDataFromGif );
+ *gifInfo = DGifOpen(reinterpret_cast<void*>(fp), ReadDataFromGif);
#endif
- if ( !(*gifInfo) || errorCode )
+ if(!(*gifInfo) || errorCode)
{
- DALI_LOG_ERROR( "GIF Loader: DGifOpen Error. Code: %d\n", errorCode );
+ DALI_LOG_ERROR("GIF Loader: DGifOpen Error. Code: %d\n", errorCode);
return false;
}
height = (*gifInfo)->SHeight;
// No proper size in GIF.
- if ( width <= 0 || height <= 0 )
+ if(width <= 0 || height <= 0)
{
return false;
}
}
/// Decode the GIF image.
-bool DecodeImage( GifFileType* gifInfo, unsigned char* decodedData, const unsigned int width, const unsigned int height, const unsigned int bytesPerRow )
+bool DecodeImage(GifFileType* gifInfo, unsigned char* decodedData, const unsigned int width, const unsigned int height, const unsigned int bytesPerRow)
{
- if ( gifInfo->Image.Interlace )
+ if(gifInfo->Image.Interlace)
{
// If the image is interlaced, then use the GIF interlace algorithm to read the file appropriately.
- const InterlacePair* interlacePairPtr( INTERLACE_PAIR_TABLE );
- for ( unsigned int interlacePair = 0; interlacePair < INTERLACE_PAIR_TABLE_SIZE; ++interlacePair, ++interlacePairPtr )
+ const InterlacePair* interlacePairPtr(INTERLACE_PAIR_TABLE);
+ for(unsigned int interlacePair = 0; interlacePair < INTERLACE_PAIR_TABLE_SIZE; ++interlacePair, ++interlacePairPtr)
{
- for( unsigned int currentByte = interlacePairPtr->startingByte; currentByte < height; currentByte += interlacePairPtr->incrementalByte )
+ for(unsigned int currentByte = interlacePairPtr->startingByte; currentByte < height; currentByte += interlacePairPtr->incrementalByte)
{
unsigned char* row = decodedData + currentByte * bytesPerRow;
- if ( DGifGetLine( gifInfo, row, width ) == GIF_ERROR )
+ if(DGifGetLine(gifInfo, row, width) == GIF_ERROR)
{
- DALI_LOG_ERROR( "GIF Loader: Error reading Interlaced GIF\n" );
+ DALI_LOG_ERROR("GIF Loader: Error reading Interlaced GIF\n");
return false;
}
}
else
{
// Non-interlace does not require any erratic reading / jumping.
- unsigned char* decodedDataPtr( decodedData );
+ unsigned char* decodedDataPtr(decodedData);
- for ( unsigned int row = 0; row < height; ++row )
+ for(unsigned int row = 0; row < height; ++row)
{
- if ( DGifGetLine( gifInfo, decodedDataPtr, width ) == GIF_ERROR)
+ if(DGifGetLine(gifInfo, decodedDataPtr, width) == GIF_ERROR)
{
- DALI_LOG_ERROR( "GIF Loader: Error reading non-interlaced GIF\n" );
+ DALI_LOG_ERROR("GIF Loader: Error reading non-interlaced GIF\n");
return false;
}
decodedDataPtr += bytesPerRow;
}
// Retrieves the colors used in the GIF image.
-GifColorType* GetImageColors( SavedImage* image, GifFileType* gifInfo )
+GifColorType* GetImageColors(SavedImage* image, GifFileType* gifInfo)
{
- GifColorType* color( NULL );
- if ( image->ImageDesc.ColorMap )
+ GifColorType* color(NULL);
+ if(image->ImageDesc.ColorMap)
{
color = image->ImageDesc.ColorMap->Colors;
}
}
/// Called when we want to handle IMAGE_DESC_RECORD_TYPE
-bool HandleImageDescriptionRecordType( Dali::Devel::PixelBuffer& bitmap, GifFileType* gifInfo, unsigned int width, unsigned int height, bool& finished )
+bool HandleImageDescriptionRecordType(Dali::Devel::PixelBuffer& bitmap, GifFileType* gifInfo, unsigned int width, unsigned int height, bool& finished)
{
- if ( DGifGetImageDesc( gifInfo ) == GIF_ERROR )
+ if(DGifGetImageDesc(gifInfo) == GIF_ERROR)
{
- DALI_LOG_ERROR( "GIF Loader: Error getting Image Description\n" );
+ DALI_LOG_ERROR("GIF Loader: Error getting Image Description\n");
return false;
}
// Ensure there is at least 1 image in the GIF.
- if ( gifInfo->ImageCount < 1 )
+ if(gifInfo->ImageCount < 1)
{
- DALI_LOG_ERROR( "GIF Loader: No Images\n" );
+ DALI_LOG_ERROR("GIF Loader: No Images\n");
return false;
}
- Pixel::Format pixelFormat( Pixel::RGB888 );
+ Pixel::Format pixelFormat(Pixel::RGB888);
- SavedImage* image( &gifInfo->SavedImages[ gifInfo->ImageCount - 1 ] );
- const GifImageDesc& desc( image->ImageDesc );
+ SavedImage* image(&gifInfo->SavedImages[gifInfo->ImageCount - 1]);
+ const GifImageDesc& desc(image->ImageDesc);
- auto decodedData = new unsigned char[ width * height * sizeof( GifPixelType ) ];
+ auto decodedData = new unsigned char[width * height * sizeof(GifPixelType)];
- std::unique_ptr<unsigned char[]> ptr{ decodedData };
+ std::unique_ptr<unsigned char[]> ptr{decodedData};
- const unsigned int bytesPerRow( width * sizeof( GifPixelType ) );
- const unsigned int actualWidth( desc.Width );
- const unsigned int actualHeight( desc.Height );
+ const unsigned int bytesPerRow(width * sizeof(GifPixelType));
+ const unsigned int actualWidth(desc.Width);
+ const unsigned int actualHeight(desc.Height);
// Create a buffer to store the decoded data.
- bitmap = Dali::Devel::PixelBuffer::New( actualWidth, actualHeight, pixelFormat );
+ bitmap = Dali::Devel::PixelBuffer::New(actualWidth, actualHeight, pixelFormat);
// Decode the GIF Image
- if ( !DecodeImage( gifInfo, decodedData, actualWidth, actualHeight, bytesPerRow ) )
+ if(!DecodeImage(gifInfo, decodedData, actualWidth, actualHeight, bytesPerRow))
{
return false;
}
// Get the colormap for the GIF
- GifColorType* color( GetImageColors( image, gifInfo ) );
+ GifColorType* color(GetImageColors(image, gifInfo));
// If it's an animated GIF, we still only read the first image
// Create and populate pixel buffer.
auto pixels = bitmap.GetBuffer();
- for (unsigned int row = 0; row < actualHeight; ++row)
+ for(unsigned int row = 0; row < actualHeight; ++row)
{
- for (unsigned int column = 0; column < actualWidth; ++column)
+ for(unsigned int column = 0; column < actualWidth; ++column)
{
unsigned char index = decodedData[row * width + column];
}
/// Called when we want to handle EXTENSION_RECORD_TYPE
-bool HandleExtensionRecordType( GifFileType* gifInfo )
+bool HandleExtensionRecordType(GifFileType* gifInfo)
{
- SavedImage image;
- GifByteType *extensionByte( NULL );
+ SavedImage image;
+ GifByteType* extensionByte(NULL);
#ifdef LIBGIF_VERSION_5_1_OR_ABOVE
ExtensionBlock extensionBlocks;
image.ExtensionBlocks = &extensionBlocks;
image.ExtensionBlockCount = 1;
- int *extensionBlockTypePointer = &image.ExtensionBlocks->Function;
+ int* extensionBlockTypePointer = &image.ExtensionBlocks->Function;
#else
- image.ExtensionBlocks = NULL;
+ image.ExtensionBlocks = NULL;
image.ExtensionBlockCount = 0;
- int *extensionBlockTypePointer = &image.Function;
+ int* extensionBlockTypePointer = &image.Function;
#endif
// Not really interested in the extensions so just skip them unless there is an error.
- for ( int extRetCode = DGifGetExtension( gifInfo, extensionBlockTypePointer, &extensionByte );
- extensionByte != NULL;
- extRetCode = DGifGetExtensionNext( gifInfo, &extensionByte ) )
+ for(int extRetCode = DGifGetExtension(gifInfo, extensionBlockTypePointer, &extensionByte);
+ extensionByte != NULL;
+ extRetCode = DGifGetExtensionNext(gifInfo, &extensionByte))
{
- if ( extRetCode == GIF_ERROR )
+ if(extRetCode == GIF_ERROR)
{
- DALI_LOG_ERROR( "GIF Loader: Error reading GIF Extension record.\n" );
+ DALI_LOG_ERROR("GIF Loader: Error reading GIF Extension record.\n");
return false;
}
}
} // unnamed namespace
-bool LoadGifHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadGifHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
- GifFileType* gifInfo = NULL;
+ GifFileType* gifInfo = NULL;
AutoCleanupGif autoCleanupGif(gifInfo);
- FILE* const fp = input.file;
+ FILE* const fp = input.file;
return LoadGifHeader(fp, width, height, &gifInfo);
}
-bool LoadBitmapFromGif( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromGif(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
FILE* const fp = input.file;
// Load the GIF Header file.
- GifFileType* gifInfo( NULL );
- unsigned int width( 0 );
- unsigned int height( 0 );
- if ( !LoadGifHeader( fp, width, height, &gifInfo ) )
+ GifFileType* gifInfo(NULL);
+ unsigned int width(0);
+ unsigned int height(0);
+ if(!LoadGifHeader(fp, width, height, &gifInfo))
{
return false;
}
- AutoCleanupGif autoGif( gifInfo );
+ AutoCleanupGif autoGif(gifInfo);
// Check each record in the GIF file.
- bool finished( false );
- GifRecordType recordType( UNDEFINED_RECORD_TYPE );
- for ( int returnCode = DGifGetRecordType( gifInfo, &recordType );
- !finished && recordType != TERMINATE_RECORD_TYPE;
- returnCode = DGifGetRecordType( gifInfo, &recordType ) )
+ bool finished(false);
+ GifRecordType recordType(UNDEFINED_RECORD_TYPE);
+ for(int returnCode = DGifGetRecordType(gifInfo, &recordType);
+ !finished && recordType != TERMINATE_RECORD_TYPE;
+ returnCode = DGifGetRecordType(gifInfo, &recordType))
{
- if ( returnCode == GIF_ERROR )
+ if(returnCode == GIF_ERROR)
{
- DALI_LOG_ERROR( "GIF Loader: Error getting Record Type\n" );
+ DALI_LOG_ERROR("GIF Loader: Error getting Record Type\n");
return false;
}
- if( IMAGE_DESC_RECORD_TYPE == recordType )
+ if(IMAGE_DESC_RECORD_TYPE == recordType)
{
- if ( !HandleImageDescriptionRecordType( bitmap, gifInfo, width, height, finished ) )
+ if(!HandleImageDescriptionRecordType(bitmap, gifInfo, width, height, finished))
{
return false;
}
}
- else if ( EXTENSION_RECORD_TYPE == recordType )
+ else if(EXTENSION_RECORD_TYPE == recordType)
{
- if ( !HandleExtensionRecordType( gifInfo ))
+ if(!HandleExtensionRecordType(gifInfo))
{
return false;
}
/*
- * 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.
#include <dali/internal/imaging/common/loader-ico.h>
// EXTERNAL INCLUDES
-#include <cstring>
#include <dali/public-api/common/dali-vector.h>
+#include <cstring>
// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace
{
// Reserved 2 bytes + type 2 bytes + count 2 bytes + count * 16 bytes
// besides, there are rgba color data = numberOfColors * 4 bytes
const unsigned char ICO_IMAGE_INFO_HEADER = 40;
-typedef unsigned char DATA8;
-#define A_VAL(p) (reinterpret_cast< DATA8 * >( p )[3])
+typedef unsigned char DATA8;
+#define A_VAL(p) (reinterpret_cast<DATA8*>(p)[3])
-#define RGB_JOIN(r,g,b) \
- (((r) << 16) + ((g) << 8) + (b))
+#define RGB_JOIN(r, g, b) \
+ (((r) << 16) + ((g) << 8) + (b))
-#define ARGB_JOIN(a,r,g,b) \
- (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
+#define ARGB_JOIN(a, r, g, b) \
+ (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
-bool read_ushort(unsigned char *map, size_t length, size_t *position, unsigned short *ret)
+bool read_ushort(unsigned char* map, size_t length, size_t* position, unsigned short* ret)
{
unsigned char b[2];
- if (*position + 2 > length)
+ if(*position + 2 > length)
{
return false;
}
return true;
}
-bool read_uint(unsigned char *map, size_t length, size_t *position, unsigned int *ret)
+bool read_uint(unsigned char* map, size_t length, size_t* position, unsigned int* ret)
{
unsigned char b[4];
- unsigned int i;
+ unsigned int i;
- if (*position + 4 > length)
+ if(*position + 4 > length)
{
return false;
}
- for (i = 0; i < 4; i++)
+ for(i = 0; i < 4; i++)
{
b[i] = map[(*position)++];
}
return true;
}
-bool read_uchar(unsigned char *map, size_t length, size_t *position, unsigned char *ret)
+bool read_uchar(unsigned char* map, size_t length, size_t* position, unsigned char* ret)
{
- if (*position + 1 > length)
+ if(*position + 1 > length)
{
return false;
}
return true;
}
-bool read_mem(unsigned char *map, size_t length, size_t *position, void *buffer, int size)
+bool read_mem(unsigned char* map, size_t length, size_t* position, void* buffer, int size)
{
- if (*position + size > length)
+ if(*position + size > length)
{
return false;
}
enum
{
- ICON = 1,
+ ICON = 1,
CURSOR = 2
};
struct IcoData
{
- int pdelta;
- int w, h;
- int cols;
- int bpp, planes;
- int hot_x, hot_y;
+ int pdelta;
+ int w, h;
+ int cols;
+ int bpp, planes;
+ int hot_x, hot_y;
unsigned int bmoffset, bmsize;
};
-bool LoadIcoHeaderHelper( FILE* fp,
- IcoData& chosen,
- Dali::Vector<unsigned char>& map,
- unsigned int& fsize )
+bool LoadIcoHeaderHelper(FILE* fp,
+ IcoData& chosen,
+ Dali::Vector<unsigned char>& map,
+ unsigned int& fsize)
{
- memset( &chosen, 0, sizeof(chosen) );
+ memset(&chosen, 0, sizeof(chosen));
if(fp == NULL)
{
DALI_LOG_ERROR("Error loading bitmap\n");
return false;
}
- size_t position = 0;
+ size_t position = 0;
unsigned short word;
- unsigned char byte;
+ unsigned char byte;
- if( fseek(fp,0,SEEK_END) )
+ if(fseek(fp, 0, SEEK_END))
{
DALI_LOG_ERROR("Error seeking ICO data\n");
return false;
}
long positionIndicator = ftell(fp);
- fsize = 0u;
+ fsize = 0u;
- if( positionIndicator > -1L )
+ if(positionIndicator > -1L)
{
fsize = static_cast<unsigned int>(positionIndicator);
}
- if( 0u == fsize )
+ if(0u == fsize)
{
return false;
}
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking ICO data\n");
return false;
}
- if (fsize < (ICO_FILE_HEADER + ICO_IMAGE_INFO_HEADER)) //6 + 16 + 40
+ if(fsize < (ICO_FILE_HEADER + ICO_IMAGE_INFO_HEADER)) //6 + 16 + 40
{
return false;
}
return false;
}
- int search = BIGGEST;
+ int search = BIGGEST;
unsigned short reserved, type, count;
- if (!read_ushort(&map[0], fsize, &position, &reserved))
+ if(!read_ushort(&map[0], fsize, &position, &reserved))
{
return false;
}
- if (!read_ushort(&map[0], fsize, &position, &type))
+ if(!read_ushort(&map[0], fsize, &position, &type))
{
return false;
}
- if (!read_ushort(&map[0], fsize, &position, &count))
+ if(!read_ushort(&map[0], fsize, &position, &count))
{
return false;
}
- if (!((reserved == 0) &&
+ if(!((reserved == 0) &&
((type == ICON) || (type == CURSOR)) && (count != 0)))
{
return false;
}
- search = BIGGEST;
- chosen.pdelta = 0;
+ search = BIGGEST;
+ chosen.pdelta = 0;
bool have_choice = false;
- for (unsigned short i = 0; i < count; i++)
+ for(unsigned short i = 0; i < count; i++)
{
unsigned char tw = 0, th = 0, tcols = 0;
- if (!read_uchar(&map[0], fsize, &position, &tw))
+ if(!read_uchar(&map[0], fsize, &position, &tw))
{
return false;
}
int w = tw;
- if (w <= 0)
+ if(w <= 0)
{
w = 256;
}
- if (!read_uchar(&map[0], fsize, &position, &th))
+ if(!read_uchar(&map[0], fsize, &position, &th))
{
return false;
-
}
int h = th;
- if (h <= 0)
+ if(h <= 0)
{
h = 256;
}
- if (!read_uchar(&map[0], fsize, &position, &tcols))
+ if(!read_uchar(&map[0], fsize, &position, &tcols))
{
return false;
}
int cols = tcols;
- if (!read_uchar(&map[0], fsize, &position, &byte))
+ if(!read_uchar(&map[0], fsize, &position, &byte))
{
return false;
}
- if (!read_ushort(&map[0], fsize, &position, &word))
+ if(!read_ushort(&map[0], fsize, &position, &word))
{
return false;
}
- int planes=0;
- if (type == 1)
+ int planes = 0;
+ if(type == 1)
{
planes = word;
}
//else hot_x = word;
- if (!read_ushort(&map[0], fsize, &position, &word))
+ if(!read_ushort(&map[0], fsize, &position, &word))
{
return false;
}
- int bpp=0;
- if (type == 1)
+ int bpp = 0;
+ if(type == 1)
{
bpp = word;
}
// 0 colors means 256 for paletized modes.
// Note: We must not do this conversion for bpp greater than 8, as there is no palette.
- if( bpp <= 8 && cols == 0 )
+ if(bpp <= 8 && cols == 0)
{
cols = 256;
}
//else hot_y = word;
unsigned int bmoffset, bmsize;
- if (!read_uint(&map[0], fsize, &position, &bmsize))
+ if(!read_uint(&map[0], fsize, &position, &bmsize))
{
return false;
}
- if (!read_uint(&map[0], fsize, &position, &bmoffset))
+ if(!read_uint(&map[0], fsize, &position, &bmoffset))
{
return false;
}
- if ((bmsize <= 0) || (bmoffset <= 0) || (bmoffset >= fsize))
+ if((bmsize <= 0) || (bmoffset <= 0) || (bmoffset >= fsize))
{
return false;
}
- if (search == BIGGEST)
+ if(search == BIGGEST)
{
int pdelta = w * h;
- if ((!have_choice) ||
- ((pdelta >= chosen.pdelta) &&
- (((bpp >= 3) && (bpp >= chosen.bpp)) ||
- ((bpp < 3) && (cols >= chosen.cols)))))
+ if((!have_choice) ||
+ ((pdelta >= chosen.pdelta) &&
+ (((bpp >= 3) && (bpp >= chosen.bpp)) ||
+ ((bpp < 3) && (cols >= chosen.cols)))))
{
- have_choice = true;
- chosen.pdelta = pdelta;
- chosen.w = w;
- chosen.h = h;
- chosen.cols = cols;
- chosen.bpp = bpp;
- chosen.planes = planes;
- chosen.bmsize = bmsize;
+ have_choice = true;
+ chosen.pdelta = pdelta;
+ chosen.w = w;
+ chosen.h = h;
+ chosen.cols = cols;
+ chosen.bpp = bpp;
+ chosen.planes = planes;
+ chosen.bmsize = bmsize;
chosen.bmoffset = bmoffset;
}
}
}
- if (chosen.bmoffset == 0)
+ if(chosen.bmoffset == 0)
{
return false;
}
* @param[in] palette The palette
*/
bool HandleBitsPerPixel(
- const unsigned int bitcount,
- Dali::Vector<unsigned char>& map,
- unsigned int*& pix,
- Dali::Vector<unsigned int>& surface,
- const unsigned int width,
- const unsigned int height,
- const unsigned int fsize,
- size_t& position,
- Dali::Vector<unsigned char>& pixbuf,
- const unsigned int stride,
- const Dali::Vector<unsigned int>& palette)
+ const unsigned int bitcount,
+ Dali::Vector<unsigned char>& map,
+ unsigned int*& pix,
+ Dali::Vector<unsigned int>& surface,
+ const unsigned int width,
+ const unsigned int height,
+ const unsigned int fsize,
+ size_t& position,
+ Dali::Vector<unsigned char>& pixbuf,
+ const unsigned int stride,
+ const Dali::Vector<unsigned int>& palette)
{
// Note: Switch is in order of most common format first.
- switch( bitcount )
+ switch(bitcount)
{
case 32:
{
unsigned char* p = &map[position];
- pix = &surface[0] + ( ( height - 1 ) * width );
+ pix = &surface[0] + ((height - 1) * width);
- for( unsigned int i = 0; i < height; i++ )
+ for(unsigned int i = 0; i < height; i++)
{
- for( unsigned int j = 0; j < width; j++ )
+ for(unsigned int j = 0; j < width; j++)
{
- *pix++ = ARGB_JOIN( p[3], p[0], p[1], p[2] );
+ *pix++ = ARGB_JOIN(p[3], p[0], p[1], p[2]);
p += 4;
}
// Move the output up 1 line (we subtract 2 lines because we moved forward one line while copying).
- pix -= ( width * 2 );
+ pix -= (width * 2);
}
break;
}
case 24:
{
- for( unsigned int i = 0; i < height; i++ )
+ for(unsigned int i = 0; i < height; i++)
{
- pix = &surface[0] + ( ( height - 1 - i ) * width );
- if( !read_mem( &map[0], fsize, &position, &pixbuf[0], stride ) )
+ pix = &surface[0] + ((height - 1 - i) * width);
+ if(!read_mem(&map[0], fsize, &position, &pixbuf[0], stride))
{
return false;
}
unsigned char* p = &pixbuf[0];
- for( unsigned int j = 0; j < width; j++ )
+ for(unsigned int j = 0; j < width; j++)
{
- *pix++ = ARGB_JOIN( 0xff, p[0], p[1], p[2] );
+ *pix++ = ARGB_JOIN(0xff, p[0], p[1], p[2]);
p += 3;
}
}
case 8:
{
- for( unsigned int i = 0; i < height; i++ )
+ for(unsigned int i = 0; i < height; i++)
{
- pix = &surface[0] + ( ( height - 1 - i ) * width );
- if( !read_mem( &map[0], fsize, &position, &pixbuf[0], stride ) )
+ pix = &surface[0] + ((height - 1 - i) * width);
+ if(!read_mem(&map[0], fsize, &position, &pixbuf[0], stride))
{
return false;
}
unsigned char* p = &pixbuf[0];
- for( unsigned int j = 0; j < width; j++ )
+ for(unsigned int j = 0; j < width; j++)
{
*pix++ = palette[*p++];
}
case 4:
{
- for( unsigned int i = 0; i < height; i++ )
+ for(unsigned int i = 0; i < height; i++)
{
- pix = &surface[0] + ( ( height - 1 - i ) * width );
- if( !read_mem( &map[0], fsize, &position, &pixbuf[0], stride ) )
+ pix = &surface[0] + ((height - 1 - i) * width);
+ if(!read_mem(&map[0], fsize, &position, &pixbuf[0], stride))
{
return false;
}
unsigned char* p = &pixbuf[0];
- for( unsigned int j = 0; j < width; j++ )
+ for(unsigned int j = 0; j < width; j++)
{
- if( j & 0x1 )
+ if(j & 0x1)
{
*pix = palette[*p & 0x0f];
p++;
case 1:
{
- for( unsigned int i = 0; i < height; i++ )
+ for(unsigned int i = 0; i < height; i++)
{
- pix = &surface[0] + ( ( height - 1 - i ) * width );
- if( !read_mem( &map[0], fsize, &position, &pixbuf[0], stride ) )
+ pix = &surface[0] + ((height - 1 - i) * width);
+ if(!read_mem(&map[0], fsize, &position, &pixbuf[0], stride))
{
return false;
}
unsigned char* p = &pixbuf[0];
- for( unsigned int j = 0; j < width; j += 8 )
+ for(unsigned int j = 0; j < width; j += 8)
{
- *pix++ = palette[ *p >> 7 ];
- *pix++ = palette[ *p >> 6 & 0x01 ];
- *pix++ = palette[ *p >> 5 & 0x01 ];
- *pix++ = palette[ *p >> 4 & 0x01 ];
- *pix++ = palette[ *p >> 3 & 0x01 ];
- *pix++ = palette[ *p >> 2 & 0x01 ];
- *pix++ = palette[ *p >> 1 & 0x01 ];
- *pix++ = palette[ *p >> 0 & 0x01 ];
+ *pix++ = palette[*p >> 7];
+ *pix++ = palette[*p >> 6 & 0x01];
+ *pix++ = palette[*p >> 5 & 0x01];
+ *pix++ = palette[*p >> 4 & 0x01];
+ *pix++ = palette[*p >> 3 & 0x01];
+ *pix++ = palette[*p >> 2 & 0x01];
+ *pix++ = palette[*p >> 1 & 0x01];
+ *pix++ = palette[*p >> 0 & 0x01];
p++;
}
default:
{
- DALI_LOG_WARNING( "Image file contains unsupported bits-per-pixel %d\n", bitcount );
+ DALI_LOG_WARNING("Image file contains unsupported bits-per-pixel %d\n", bitcount);
return false;
}
}
* @param[in/out] surface A reference to the surface buffer
*/
bool ApplyMask(
- Dali::Vector<unsigned char>& map,
- const unsigned int fsize,
- size_t& position,
- Dali::Vector<unsigned char>& maskbuf,
- const unsigned int bitStride,
- const unsigned int width,
- const unsigned int height,
- unsigned int*& pix,
- Dali::Vector<unsigned int>& surface)
+ Dali::Vector<unsigned char>& map,
+ const unsigned int fsize,
+ size_t& position,
+ Dali::Vector<unsigned char>& maskbuf,
+ const unsigned int bitStride,
+ const unsigned int width,
+ const unsigned int height,
+ unsigned int*& pix,
+ Dali::Vector<unsigned int>& surface)
{
- if( !read_mem( &map[0], fsize, &position, &maskbuf[0], bitStride * height ) )
+ if(!read_mem(&map[0], fsize, &position, &maskbuf[0], bitStride * height))
{
return false;
}
// Apply mask.
// Precalc to save time in the loops.
- unsigned int bytesPerWidth = width / 8;
- unsigned int bytesRemainingPerWidth = width - ( bytesPerWidth << 3 );
+ unsigned int bytesPerWidth = width / 8;
+ unsigned int bytesRemainingPerWidth = width - (bytesPerWidth << 3);
// Loop for each line of the image.
- for( unsigned int i = 0; i < height; ++i )
+ for(unsigned int i = 0; i < height; ++i)
{
- unsigned char *m = &maskbuf[0] + ( bitStride * i );
- pix = &surface[0] + ( ( height - 1 - i ) * width );
+ unsigned char* m = &maskbuf[0] + (bitStride * i);
+ pix = &surface[0] + ((height - 1 - i) * width);
// Do chunks of 8 pixels first so mask operations can be unrolled.
- for( unsigned int j = 0; j < bytesPerWidth; ++j )
+ for(unsigned int j = 0; j < bytesPerWidth; ++j)
{
// Unrolled 8 bits of the mask to avoid many conditions and branches.
- A_VAL( pix++ ) = ( *m & ( 1 << 7 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 6 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 5 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 4 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 3 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 2 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 1 ) ) ? 0x00 : 0xff;
- A_VAL( pix++ ) = ( *m & ( 1 << 0 ) ) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 7)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 6)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 5)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 4)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 3)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 2)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 1)) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << 0)) ? 0x00 : 0xff;
m++;
}
// Handle any remaining width ( < 8 ) or images that are < 8 wide.
- if( bytesRemainingPerWidth > 0 )
+ if(bytesRemainingPerWidth > 0)
{
- for( unsigned int j = 0; j < bytesRemainingPerWidth; ++j )
+ for(unsigned int j = 0; j < bytesRemainingPerWidth; ++j)
{
// Note: Although we are doing less that a bytes worth of mask, we still always start on the first bit.
// If the image is smaller than 8 pixels wide, each mask will still start on a new byte.
- A_VAL( pix++ ) = ( *m & ( 1 << ( 7 - j ) ) ) ? 0x00 : 0xff;
+ A_VAL(pix++) = (*m & (1 << (7 - j))) ? 0x00 : 0xff;
}
m++;
}
return true;
}
-}//unnamed namespace
+} //unnamed namespace
-bool LoadIcoHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadIcoHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
- IcoData chosen;
+ IcoData chosen;
Dali::Vector<unsigned char> map;
- unsigned int fsize;
- FILE* const fp = input.file;
+ unsigned int fsize;
+ FILE* const fp = input.file;
- if ( false == LoadIcoHeaderHelper(fp, chosen, map, fsize) )
+ if(false == LoadIcoHeaderHelper(fp, chosen, map, fsize))
{
return false;
}
- width = chosen.w;
+ width = chosen.w;
height = chosen.h;
return true;
}
-bool LoadBitmapFromIco( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromIco(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
- IcoData chosen;
+ IcoData chosen;
Dali::Vector<unsigned char> map;
- unsigned int fsize;
- FILE* const fp = input.file;
+ unsigned int fsize;
+ FILE* const fp = input.file;
- if ( false == LoadIcoHeaderHelper(fp, chosen, map, fsize) )
+ if(false == LoadIcoHeaderHelper(fp, chosen, map, fsize))
{
return false;
}
- Dali::Vector<unsigned int> pal;
- Dali::Vector<unsigned int> surface;
+ Dali::Vector<unsigned int> pal;
+ Dali::Vector<unsigned int> surface;
Dali::Vector<unsigned char> maskbuf;
Dali::Vector<unsigned char> pixbuf;
pal.Resize(256 * 4);
- unsigned int dword;
+ unsigned int dword;
unsigned short word;
- int diff_size = 0;
+ int diff_size = 0;
unsigned int* pix;
- size_t position = chosen.bmoffset;//22 == position
+ size_t position = chosen.bmoffset; //22 == position
- unsigned int w = chosen.w;
- unsigned int h = chosen.h;
+ unsigned int w = chosen.w;
+ unsigned int h = chosen.h;
unsigned int cols = chosen.cols;
// read bmp header time... let's do some checking
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // headersize - dont care
}
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // width
}
- if (dword > 0)
+ if(dword > 0)
{
- if (dword != w)
+ if(dword != w)
{
- w = dword;
+ w = dword;
diff_size = 1;
}
}
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // height
}
- if (dword > 0)
+ if(dword > 0)
{
- if (dword != (h * 2))
+ if(dword != (h * 2))
{
- h = dword / 2;
+ h = dword / 2;
diff_size = 1;
}
}
- if (diff_size)
+ if(diff_size)
{
DALI_LOG_WARNING("Broken ICO file!\n");
}
// Set up the surface as soon as we have the width and height, so we have a black image if there are any further errors.
- surface.Resize( w * h * 4 );
- memset( &surface[0], 0, w * h * 4 );
+ surface.Resize(w * h * 4);
+ memset(&surface[0], 0, w * h * 4);
- if (!read_ushort(&map[0], fsize, &position, &word))
+ if(!read_ushort(&map[0], fsize, &position, &word))
{
return false; // planes
}
//planes2 = word;
- if (!read_ushort(&map[0], fsize, &position, &word))
+ if(!read_ushort(&map[0], fsize, &position, &word))
{
return false; // bitcount
}
unsigned int bitcount = word;
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // compression
}
//compression = dword;
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // imagesize
}
//imagesize = dword;
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // z pixels per m
}
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // y pizels per m
}
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // colors used
}
//colorsused = dword;
- if (!read_uint(&map[0], fsize, &position, &dword))
+ if(!read_uint(&map[0], fsize, &position, &dword))
{
return false; // colors important
}
- for( unsigned int i = 0; i < cols ; i ++ )
+ for(unsigned int i = 0; i < cols; i++)
{
unsigned char a, r, g, b;
- if (!read_uchar(&map[0], fsize, &position, &b))
+ if(!read_uchar(&map[0], fsize, &position, &b))
{
return false;
}
- if (!read_uchar(&map[0], fsize, &position, &g))
+ if(!read_uchar(&map[0], fsize, &position, &g))
{
return false;
}
- if (!read_uchar(&map[0], fsize, &position, &r))
+ if(!read_uchar(&map[0], fsize, &position, &r))
{
return false;
}
- if (!read_uchar(&map[0], fsize, &position, &a))
+ if(!read_uchar(&map[0], fsize, &position, &a))
{
return false;
}
- pal[i] = ARGB_JOIN( 0xff, b, g, r );
+ pal[i] = ARGB_JOIN(0xff, b, g, r);
}
// This is the reference way of calculating the total number of bytes necessary to store one row of pixels.
- unsigned int stride = ( ( ( bitcount * w ) + 31 ) / 32 ) * 4;
- unsigned int bitStride = ( ( w + 31 ) / 32 ) * 4;
+ unsigned int stride = (((bitcount * w) + 31) / 32) * 4;
+ unsigned int bitStride = ((w + 31) / 32) * 4;
// Pixbuf only ever contains one scanline worth of data.
- pixbuf.Resize( stride );
- maskbuf.Resize( bitStride * h );
+ pixbuf.Resize(stride);
+ maskbuf.Resize(bitStride * h);
// Handle different bits-per-pixel.
if(!HandleBitsPerPixel(bitcount, map, pix, surface, w, h, fsize, position, pixbuf, stride, pal))
}
// From the spec: If bpp is less than 32, there will be a 1bpp mask bitmap also.
- if(( bitcount < 32 ) && !ApplyMask(map, fsize, position, maskbuf, bitStride, w, h, pix, surface))
+ if((bitcount < 32) && !ApplyMask(map, fsize, position, maskbuf, bitStride, w, h, pix, surface))
{
// Return false if not able to apply mask when the bpp is less than 32
return false;
}
- bitmap = Dali::Devel::PixelBuffer::New(w, h, Pixel::Format::RGBA8888);
+ bitmap = Dali::Devel::PixelBuffer::New(w, h, Pixel::Format::RGBA8888);
auto pixels = bitmap.GetBuffer();
- memcpy( pixels, &surface[0], w * h * 4 );
+ memcpy(pixels, &surface[0], w * h * 4);
return true;
}
-}
+} // namespace TizenPlatform
-}
+} // namespace Dali
/*
- * Copyright (c) 2017 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.
*
*/
- // CLASS HEADER
+// CLASS HEADER
#include <dali/internal/imaging/common/loader-jpeg.h>
// EXTERNAL HEADERS
-#include <functional>
-#include <array>
-#include <utility>
-#include <memory>
+#include <jpeglib.h>
#include <libexif/exif-data.h>
#include <libexif/exif-loader.h>
#include <libexif/exif-tag.h>
+#include <setjmp.h>
#include <turbojpeg.h>
-#include <jpeglib.h>
+#include <array>
#include <cstring>
-#include <setjmp.h>
+#include <functional>
+#include <memory>
+#include <utility>
-#include <dali/public-api/object/property-map.h>
-#include <dali/public-api/object/property-array.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
-
+#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL HEADERS
-#include <dali/internal/legacy/tizen/platform-capabilities.h>
-#include <dali/internal/imaging/common/image-operations.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/internal/imaging/common/image-operations.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
+#include <dali/internal/legacy/tizen/platform-capabilities.h>
namespace
{
using Dali::Vector;
-namespace Pixel = Dali::Pixel;
-using PixelArray = unsigned char*;
-const unsigned int DECODED_L8 = 1;
-const unsigned int DECODED_RGB888 = 3;
+namespace Pixel = Dali::Pixel;
+using PixelArray = unsigned char*;
+const unsigned int DECODED_L8 = 1;
+const unsigned int DECODED_RGB888 = 3;
const unsigned int DECODED_RGBA8888 = 4;
/** Transformations that can be applied to decoded pixels to respect exif orientation
* codes in image headers */
enum class JpegTransform
{
- NONE, //< no transformation 0th-Row = top & 0th-Column = left
- FLIP_HORIZONTAL, //< horizontal flip 0th-Row = top & 0th-Column = right
- FLIP_VERTICAL, //< vertical flip 0th-Row = bottom & 0th-Column = right
- TRANSPOSE, //< transpose across UL-to-LR axis 0th-Row = bottom & 0th-Column = left
- TRANSVERSE, //< transpose across UR-to-LL axis 0th-Row = left & 0th-Column = top
- ROTATE_90, //< 90-degree clockwise rotation 0th-Row = right & 0th-Column = top
- ROTATE_180, //< 180-degree rotation 0th-Row = right & 0th-Column = bottom
- ROTATE_270, //< 270-degree clockwise (or 90 ccw) 0th-Row = left & 0th-Column = bottom
+ NONE, //< no transformation 0th-Row = top & 0th-Column = left
+ FLIP_HORIZONTAL, //< horizontal flip 0th-Row = top & 0th-Column = right
+ FLIP_VERTICAL, //< vertical flip 0th-Row = bottom & 0th-Column = right
+ TRANSPOSE, //< transpose across UL-to-LR axis 0th-Row = bottom & 0th-Column = left
+ TRANSVERSE, //< transpose across UR-to-LL axis 0th-Row = left & 0th-Column = top
+ ROTATE_90, //< 90-degree clockwise rotation 0th-Row = right & 0th-Column = top
+ ROTATE_180, //< 180-degree rotation 0th-Row = right & 0th-Column = bottom
+ ROTATE_270, //< 270-degree clockwise (or 90 ccw) 0th-Row = left & 0th-Column = bottom
};
/**
struct JpegErrorState
{
struct jpeg_error_mgr errorManager;
- jmp_buf jumpBuffer;
+ jmp_buf jumpBuffer;
};
/**
* @brief Called by the JPEG library when it hits an error.
* We jump out of the library so our loader code can return an error.
*/
-void JpegErrorHandler ( j_common_ptr cinfo )
+void JpegErrorHandler(j_common_ptr cinfo)
{
- DALI_LOG_ERROR( "JpegErrorHandler(): libjpeg-turbo fatal error in JPEG decoding.\n" );
+ DALI_LOG_ERROR("JpegErrorHandler(): libjpeg-turbo fatal error in JPEG decoding.\n");
/* cinfo->err really points to a JpegErrorState struct, so coerce pointer */
- JpegErrorState * myerr = reinterpret_cast<JpegErrorState *>( cinfo->err );
+ JpegErrorState* myerr = reinterpret_cast<JpegErrorState*>(cinfo->err);
/* Return control to the setjmp point */
- longjmp( myerr->jumpBuffer, 1 );
+ longjmp(myerr->jumpBuffer, 1);
}
-void JpegOutputMessageHandler( j_common_ptr cinfo )
+void JpegOutputMessageHandler(j_common_ptr cinfo)
{
/* Stop libjpeg from printing to stderr - Do Nothing */
}
* LibJPEG Turbo tjDecompress2 API doesn't distinguish between errors that still allow
* the JPEG to be displayed and fatal errors.
*/
-bool IsJpegErrorFatal( const std::string& errorMessage )
+bool IsJpegErrorFatal(const std::string& errorMessage)
{
- if( ( errorMessage.find("Corrupt JPEG data") != std::string::npos ) ||
- ( errorMessage.find("Invalid SOS parameters") != std::string::npos ) ||
- ( errorMessage.find("Invalid JPEG file structure") != std::string::npos ) ||
- ( errorMessage.find("Unsupported JPEG process") != std::string::npos ) ||
- ( errorMessage.find("Unsupported marker type") != std::string::npos ) ||
- ( errorMessage.find("Bogus marker length") != std::string::npos ) ||
- ( errorMessage.find("Bogus DQT index") != std::string::npos ) ||
- ( errorMessage.find("Bogus Huffman table definition") != std::string::npos ))
+ if((errorMessage.find("Corrupt JPEG data") != std::string::npos) ||
+ (errorMessage.find("Invalid SOS parameters") != std::string::npos) ||
+ (errorMessage.find("Invalid JPEG file structure") != std::string::npos) ||
+ (errorMessage.find("Unsupported JPEG process") != std::string::npos) ||
+ (errorMessage.find("Unsupported marker type") != std::string::npos) ||
+ (errorMessage.find("Bogus marker length") != std::string::npos) ||
+ (errorMessage.find("Bogus DQT index") != std::string::npos) ||
+ (errorMessage.find("Bogus Huffman table definition") != std::string::npos))
{
return false;
}
UniquePointerSetter(std::unique_ptr<T, Deleter>& uniquePointer)
: mUniquePointer(uniquePointer),
mRawPointer(nullptr)
- {}
+ {
+ }
/// @brief Pointer to Pointer cast operator
- operator T** () { return &mRawPointer; }
+ operator T**()
+ {
+ return &mRawPointer;
+ }
/// @brief Destructor, reset the unique_ptr
- ~UniquePointerSetter() { mUniquePointer.reset(mRawPointer); }
+ ~UniquePointerSetter()
+ {
+ mUniquePointer.reset(mRawPointer);
+ }
private:
std::unique_ptr<T, Deleter>& mUniquePointer;
- T* mRawPointer;
+ T* mRawPointer;
};
template<typename T, typename Deleter>
return UniquePointerSetter<T, Deleter>{uniquePointer};
}
-using TransformFunction = std::function<void(PixelArray,unsigned, unsigned)>;
+using TransformFunction = std::function<void(PixelArray, unsigned, unsigned)>;
using TransformFunctionArray = std::array<TransformFunction, 3>; // 1, 3 and 4 bytes per pixel
/// @brief Select the transform function depending on the pixel format
TransformFunction GetTransformFunction(const TransformFunctionArray& functions,
- Pixel::Format pixelFormat)
+ Pixel::Format pixelFormat)
{
auto function = TransformFunction{};
int decodedPixelSize = Pixel::GetBytesPerPixel(pixelFormat);
- switch( decodedPixelSize )
+ switch(decodedPixelSize)
{
case DECODED_L8:
{
// Storing Exif fields as properties
template<class R, class V>
-R ConvertExifNumeric( const ExifEntry& entry )
+R ConvertExifNumeric(const ExifEntry& entry)
{
return static_cast<R>((*reinterpret_cast<V*>(entry.data)));
}
-void AddExifFieldPropertyMap( Dali::Property::Map& out, const ExifEntry& entry, ExifIfd ifd )
+void AddExifFieldPropertyMap(Dali::Property::Map& out, const ExifEntry& entry, ExifIfd ifd)
{
- auto shortName = std::string(exif_tag_get_name_in_ifd(entry.tag, ifd ));
- switch( entry.format )
+ auto shortName = std::string(exif_tag_get_name_in_ifd(entry.tag, ifd));
+ switch(entry.format)
{
case EXIF_FORMAT_ASCII:
{
- out.Insert( shortName, std::string( reinterpret_cast<char *>(entry.data), entry.size ) );
+ out.Insert(shortName, std::string(reinterpret_cast<char*>(entry.data), entry.size));
break;
}
case EXIF_FORMAT_SHORT:
{
- out.Insert( shortName, ConvertExifNumeric<int, uint16_t>(entry) );
+ out.Insert(shortName, ConvertExifNumeric<int, uint16_t>(entry));
break;
}
case EXIF_FORMAT_LONG:
{
- out.Insert( shortName, ConvertExifNumeric<int, uint32_t>(entry) );
+ out.Insert(shortName, ConvertExifNumeric<int, uint32_t>(entry));
break;
}
case EXIF_FORMAT_SSHORT:
{
- out.Insert( shortName, ConvertExifNumeric<int, int16_t>(entry) );
+ out.Insert(shortName, ConvertExifNumeric<int, int16_t>(entry));
break;
}
case EXIF_FORMAT_SLONG:
{
- out.Insert( shortName, ConvertExifNumeric<int, int32_t>(entry) );
+ out.Insert(shortName, ConvertExifNumeric<int, int32_t>(entry));
break;
}
case EXIF_FORMAT_FLOAT:
{
- out.Insert (shortName, ConvertExifNumeric<float, float>(entry) );
+ out.Insert(shortName, ConvertExifNumeric<float, float>(entry));
break;
}
case EXIF_FORMAT_DOUBLE:
{
- out.Insert( shortName, ConvertExifNumeric<float, double>(entry) );
+ out.Insert(shortName, ConvertExifNumeric<float, double>(entry));
break;
}
case EXIF_FORMAT_RATIONAL:
{
- auto values = reinterpret_cast<unsigned int*>( entry.data );
+ auto values = reinterpret_cast<unsigned int*>(entry.data);
Dali::Property::Array array;
- array.Add( static_cast<int>(values[0]) );
- array.Add( static_cast<int>(values[1]) );
+ array.Add(static_cast<int>(values[0]));
+ array.Add(static_cast<int>(values[1]));
out.Insert(shortName, array);
break;
}
}
case EXIF_FORMAT_SRATIONAL:
{
- auto values = reinterpret_cast<int*>( entry.data );
+ auto values = reinterpret_cast<int*>(entry.data);
Dali::Property::Array array;
array.Add(values[0]);
array.Add(values[1]);
{
std::stringstream ss;
ss << "EXIF_FORMAT_UNDEFINED, size: " << entry.size << ", components: " << entry.components;
- out.Insert( shortName, ss.str());
+ out.Insert(shortName, ss.str());
}
}
}
/// @brief Apply a transform to a buffer
bool Transform(const TransformFunctionArray& transformFunctions,
- PixelArray buffer,
- int width,
- int height,
- Pixel::Format pixelFormat )
+ PixelArray buffer,
+ int width,
+ int height,
+ Pixel::Format pixelFormat)
{
auto transformFunction = GetTransformFunction(transformFunctions, pixelFormat);
if(transformFunction)
void FlipVertical(PixelArray buffer, int width, int height)
{
// Destination pixel, set as the first pixel of screen
- auto to = reinterpret_cast<PixelType<N>*>( buffer );
+ auto to = reinterpret_cast<PixelType<N>*>(buffer);
// Source pixel, as the image is flipped horizontally and vertically,
// the source pixel is the end of the buffer of size width * height
auto from = reinterpret_cast<PixelType<N>*>(buffer) + width * height - 1;
- for (auto ix = 0, endLoop = (width * height) / 2; ix < endLoop; ++ix, ++to, --from)
+ for(auto ix = 0, endLoop = (width * height) / 2; ix < endLoop; ++ix, ++to, --from)
{
std::swap(*from, *to);
}
{
for(auto ix = 0; ix < width; ++ix)
{
- auto to = reinterpret_cast<PixelType<N>*>(buffer) + iy * width + ix;
+ auto to = reinterpret_cast<PixelType<N>*>(buffer) + iy * width + ix;
auto from = reinterpret_cast<PixelType<N>*>(buffer) + (height - 1 - iy) * width + ix;
std::swap(*from, *to);
}
{
using PixelT = PixelType<N>;
Vector<PixelT> data;
- data.Resize( width * height );
+ data.Resize(width * height);
auto dataPtr = data.Begin();
auto original = reinterpret_cast<PixelT*>(buffer);
std::copy(original, original + width * height, dataPtr);
auto to = original;
- for( auto iy = 0; iy < width; ++iy )
+ for(auto iy = 0; iy < width; ++iy)
{
- for( auto ix = 0; ix < height; ++ix, ++to )
+ for(auto ix = 0; ix < height; ++ix, ++to)
{
auto from = dataPtr + ix * width + iy;
- *to = *from;
+ *to = *from;
}
}
}
-
template<size_t N>
void Rotate90(PixelArray buffer, int width, int height)
{
std::swap(width, height);
auto hw = width * height;
- hw = - hw - 1;
+ hw = -hw - 1;
- auto to = original + width - 1;
+ auto to = original + width - 1;
auto from = dataPtr;
for(auto ix = width; --ix >= 0;)
std::copy(original, original + width * height, dataPtr);
auto to = original;
- for( auto iy = 0; iy < width; iy++ )
+ for(auto iy = 0; iy < width; iy++)
{
- for( auto ix = 0; ix < height; ix++ )
+ for(auto ix = 0; ix < height; ix++)
{
auto from = dataPtr + (height - ix) * width - 1 - iy;
- *to = *from;
+ *to = *from;
++to;
}
}
}
-
template<size_t N>
void Rotate270(PixelArray buffer, int width, int height)
{
std::swap(width, height);
auto hw = width * height;
- auto* to = original + hw - width;
+ auto* to = original + hw - width;
auto* from = dataPtr;
- w = -w;
- hw = hw + 1;
+ w = -w;
+ hw = hw + 1;
for(auto ix = width; --ix >= 0;)
{
for(auto iy = height; --iy >= 0;)
namespace Dali
{
-
namespace TizenPlatform
{
-
JpegTransform ConvertExifOrientation(ExifData* exifData);
-bool TransformSize( int requiredWidth, int requiredHeight,
- FittingMode::Type fittingMode, SamplingMode::Type samplingMode,
- JpegTransform transform,
- int& preXformImageWidth, int& preXformImageHeight,
- int& postXformImageWidth, int& postXformImageHeight );
+bool TransformSize(int requiredWidth, int requiredHeight, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, JpegTransform transform, int& preXformImageWidth, int& preXformImageHeight, int& postXformImageWidth, int& postXformImageHeight);
-bool LoadJpegHeader( FILE *fp, unsigned int &width, unsigned int &height )
+bool LoadJpegHeader(FILE* fp, unsigned int& width, unsigned int& height)
{
// using libjpeg API to avoid having to read the whole file in a buffer
struct jpeg_decompress_struct cinfo;
- struct JpegErrorState jerr;
- cinfo.err = jpeg_std_error( &jerr.errorManager );
+ struct JpegErrorState jerr;
+ cinfo.err = jpeg_std_error(&jerr.errorManager);
jerr.errorManager.output_message = JpegOutputMessageHandler;
- jerr.errorManager.error_exit = JpegErrorHandler;
+ jerr.errorManager.error_exit = JpegErrorHandler;
// On error exit from the JPEG lib, control will pass via JpegErrorHandler
// into this branch body for cleanup and error return:
// jpeg_create_decompress internally uses C casts
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
- jpeg_create_decompress( &cinfo );
+ jpeg_create_decompress(&cinfo);
#pragma GCC diagnostic pop
- jpeg_stdio_src( &cinfo, fp );
+ jpeg_stdio_src(&cinfo, fp);
// Check header to see if it is JPEG file
- if( jpeg_read_header( &cinfo, TRUE ) != JPEG_HEADER_OK )
+ if(jpeg_read_header(&cinfo, TRUE) != JPEG_HEADER_OK)
{
width = height = 0;
- jpeg_destroy_decompress( &cinfo );
+ jpeg_destroy_decompress(&cinfo);
return false;
}
- width = cinfo.image_width;
+ width = cinfo.image_width;
height = cinfo.image_height;
- jpeg_destroy_decompress( &cinfo );
+ jpeg_destroy_decompress(&cinfo);
return true;
}
-bool LoadBitmapFromJpeg( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromJpeg(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
- const int flags= 0;
- FILE* const fp = input.file;
+ const int flags = 0;
+ FILE* const fp = input.file;
- if( fseek(fp,0,SEEK_END) )
+ if(fseek(fp, 0, SEEK_END))
{
DALI_LOG_ERROR("Error seeking to end of file\n");
return false;
}
- long positionIndicator = ftell(fp);
- unsigned int jpegBufferSize = 0u;
- if( positionIndicator > -1L )
+ long positionIndicator = ftell(fp);
+ unsigned int jpegBufferSize = 0u;
+ if(positionIndicator > -1L)
{
jpegBufferSize = static_cast<unsigned int>(positionIndicator);
}
- if( 0u == jpegBufferSize )
+ if(0u == jpegBufferSize)
{
return false;
}
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking to start of file\n");
return false;
Vector<unsigned char> jpegBuffer;
try
{
- jpegBuffer.Resize( jpegBufferSize );
+ jpegBuffer.Resize(jpegBufferSize);
}
catch(...)
{
- DALI_LOG_ERROR( "Could not allocate temporary memory to hold JPEG file of size %uMB.\n", jpegBufferSize / 1048576U );
+ DALI_LOG_ERROR("Could not allocate temporary memory to hold JPEG file of size %uMB.\n", jpegBufferSize / 1048576U);
return false;
}
- unsigned char * const jpegBufferPtr = jpegBuffer.Begin();
+ unsigned char* const jpegBufferPtr = jpegBuffer.Begin();
// Pull the compressed JPEG image bytes out of a file and into memory:
- if( fread( jpegBufferPtr, 1, jpegBufferSize, fp ) != jpegBufferSize )
+ if(fread(jpegBufferPtr, 1, jpegBufferSize, fp) != jpegBufferSize)
{
DALI_LOG_WARNING("Error on image file read.\n");
return false;
}
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking to start of file\n");
}
// extract exif data
auto exifData = MakeExifDataFromData(jpegBufferPtr, jpegBufferSize);
- if( exifData && input.reorientationRequested )
+ if(exifData && input.reorientationRequested)
{
transform = ConvertExifOrientation(exifData.get());
}
std::unique_ptr<Property::Map> exifMap;
- exifMap.reset( new Property::Map() );
+ exifMap.reset(new Property::Map());
- for( auto k = 0u; k < EXIF_IFD_COUNT; ++k )
+ for(auto k = 0u; k < EXIF_IFD_COUNT; ++k)
{
auto content = exifData->ifd[k];
- for (auto i = 0u; i < content->count; ++i)
+ for(auto i = 0u; i < content->count; ++i)
{
- auto &&tag = content->entries[i];
- const char *shortName = exif_tag_get_name_in_ifd(tag->tag, static_cast<ExifIfd>(k));
+ auto&& tag = content->entries[i];
+ const char* shortName = exif_tag_get_name_in_ifd(tag->tag, static_cast<ExifIfd>(k));
if(shortName)
{
AddExifFieldPropertyMap(*exifMap, *tag, static_cast<ExifIfd>(k));
// Temporarily separate Ubuntu and other profiles.
#ifndef DALI_PROFILE_UBUNTU
int jpegColorspace = -1;
- if( tjDecompressHeader3( jpeg.get(), jpegBufferPtr, jpegBufferSize, &preXformImageWidth, &preXformImageHeight, &chrominanceSubsampling, &jpegColorspace ) == -1 )
+ if(tjDecompressHeader3(jpeg.get(), jpegBufferPtr, jpegBufferSize, &preXformImageWidth, &preXformImageHeight, &chrominanceSubsampling, &jpegColorspace) == -1)
{
DALI_LOG_ERROR("%s\n", tjGetErrorStr());
// Do not set width and height to 0 or return early as this sometimes fails only on determining subsampling type.
}
#else
- if( tjDecompressHeader2( jpeg.get(), jpegBufferPtr, jpegBufferSize, &preXformImageWidth, &preXformImageHeight, &chrominanceSubsampling ) == -1 )
+ if(tjDecompressHeader2(jpeg.get(), jpegBufferPtr, jpegBufferSize, &preXformImageWidth, &preXformImageHeight, &chrominanceSubsampling) == -1)
{
DALI_LOG_ERROR("%s\n", tjGetErrorStr());
// Do not set width and height to 0 or return early as this sometimes fails only on determining subsampling type.
// If transform is a 90 or 270 degree rotation, the logical width and height
// request from the client needs to be adjusted to account by effectively
// rotating that too, and the final width and height need to be swapped:
- int postXformImageWidth = preXformImageWidth;
+ int postXformImageWidth = preXformImageWidth;
int postXformImageHeight = preXformImageHeight;
-
int scaledPreXformWidth = preXformImageWidth;
int scaledPreXformHeight = preXformImageHeight;
int scaledPostXformWidth = postXformImageWidth;
int scaledPostXformHeight = postXformImageHeight;
- TransformSize( requiredWidth, requiredHeight,
- input.scalingParameters.scalingMode,
- input.scalingParameters.samplingMode,
- transform,
- scaledPreXformWidth, scaledPreXformHeight,
- scaledPostXformWidth, scaledPostXformHeight );
-
+ TransformSize(requiredWidth, requiredHeight, input.scalingParameters.scalingMode, input.scalingParameters.samplingMode, transform, scaledPreXformWidth, scaledPreXformHeight, scaledPostXformWidth, scaledPostXformHeight);
// Colorspace conversion options
- TJPF pixelLibJpegType = TJPF_RGB;
- Pixel::Format pixelFormat = Pixel::RGB888;
+ TJPF pixelLibJpegType = TJPF_RGB;
+ Pixel::Format pixelFormat = Pixel::RGB888;
#ifndef DALI_PROFILE_UBUNTU
- switch (jpegColorspace)
+ switch(jpegColorspace)
{
case TJCS_RGB:
// YCbCr is not an absolute colorspace but rather a mathematical transformation of RGB designed solely for storage and transmission.
case TJCS_YCbCr:
{
pixelLibJpegType = TJPF_RGB;
- pixelFormat = Pixel::RGB888;
+ pixelFormat = Pixel::RGB888;
break;
}
case TJCS_GRAY:
{
pixelLibJpegType = TJPF_GRAY;
- pixelFormat = Pixel::L8;
+ pixelFormat = Pixel::L8;
break;
}
case TJCS_CMYK:
case TJCS_YCCK:
{
pixelLibJpegType = TJPF_CMYK;
- pixelFormat = Pixel::RGBA8888;
+ pixelFormat = Pixel::RGBA8888;
break;
}
default:
{
pixelLibJpegType = TJPF_RGB;
- pixelFormat = Pixel::RGB888;
+ pixelFormat = Pixel::RGB888;
break;
}
}
bitmap = Dali::Devel::PixelBuffer::New(scaledPostXformWidth, scaledPostXformHeight, pixelFormat);
// set metadata
- GetImplementation(bitmap).SetMetadata( std::move(exifMap) );
+ GetImplementation(bitmap).SetMetadata(std::move(exifMap));
auto bitmapPixelBuffer = bitmap.GetBuffer();
- if( tjDecompress2( jpeg.get(), jpegBufferPtr, jpegBufferSize, reinterpret_cast<unsigned char*>( bitmapPixelBuffer ), scaledPreXformWidth, 0, scaledPreXformHeight, pixelLibJpegType, flags ) == -1 )
+ if(tjDecompress2(jpeg.get(), jpegBufferPtr, jpegBufferSize, reinterpret_cast<unsigned char*>(bitmapPixelBuffer), scaledPreXformWidth, 0, scaledPreXformHeight, pixelLibJpegType, flags) == -1)
{
std::string errorString = tjGetErrorStr();
- if( IsJpegErrorFatal( errorString ) )
+ if(IsJpegErrorFatal(errorString))
{
- DALI_LOG_ERROR("%s\n", errorString.c_str() );
- return false;
+ DALI_LOG_ERROR("%s\n", errorString.c_str());
+ return false;
}
else
{
- DALI_LOG_WARNING("%s\n", errorString.c_str() );
+ DALI_LOG_WARNING("%s\n", errorString.c_str());
}
}
- const unsigned int bufferWidth = GetTextureDimension( scaledPreXformWidth );
- const unsigned int bufferHeight = GetTextureDimension( scaledPreXformHeight );
+ const unsigned int bufferWidth = GetTextureDimension(scaledPreXformWidth);
+ const unsigned int bufferHeight = GetTextureDimension(scaledPreXformHeight);
bool result = false;
switch(transform)
// 3 orientation changes for a camera held perpendicular to the ground or upside-down:
case JpegTransform::ROTATE_180:
{
- static auto rotate180Functions = TransformFunctionArray {
+ static auto rotate180Functions = TransformFunctionArray{
&Rotate180<1>,
&Rotate180<3>,
&Rotate180<4>,
};
- result = Transform(rotate180Functions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(rotate180Functions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
case JpegTransform::ROTATE_270:
{
- static auto rotate270Functions = TransformFunctionArray {
+ static auto rotate270Functions = TransformFunctionArray{
&Rotate270<1>,
&Rotate270<3>,
&Rotate270<4>,
};
- result = Transform(rotate270Functions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(rotate270Functions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
case JpegTransform::ROTATE_90:
{
- static auto rotate90Functions = TransformFunctionArray {
+ static auto rotate90Functions = TransformFunctionArray{
&Rotate90<1>,
&Rotate90<3>,
&Rotate90<4>,
};
- result = Transform(rotate90Functions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(rotate90Functions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
case JpegTransform::FLIP_VERTICAL:
{
- static auto flipVerticalFunctions = TransformFunctionArray {
+ static auto flipVerticalFunctions = TransformFunctionArray{
&FlipVertical<1>,
&FlipVertical<3>,
&FlipVertical<4>,
};
- result = Transform(flipVerticalFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(flipVerticalFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
// Less-common orientation changes, since they don't correspond to a camera's physical orientation:
case JpegTransform::FLIP_HORIZONTAL:
{
- static auto flipHorizontalFunctions = TransformFunctionArray {
+ static auto flipHorizontalFunctions = TransformFunctionArray{
&FlipHorizontal<1>,
&FlipHorizontal<3>,
&FlipHorizontal<4>,
};
- result = Transform(flipHorizontalFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(flipHorizontalFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
case JpegTransform::TRANSPOSE:
{
- static auto transposeFunctions = TransformFunctionArray {
+ static auto transposeFunctions = TransformFunctionArray{
&Transpose<1>,
&Transpose<3>,
&Transpose<4>,
};
- result = Transform(transposeFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(transposeFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
case JpegTransform::TRANSVERSE:
{
- static auto transverseFunctions = TransformFunctionArray {
+ static auto transverseFunctions = TransformFunctionArray{
&Transverse<1>,
&Transverse<3>,
&Transverse<4>,
};
- result = Transform(transverseFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat );
+ result = Transform(transverseFunctions, bitmapPixelBuffer, bufferWidth, bufferHeight, pixelFormat);
break;
}
default:
{
- DALI_LOG_ERROR( "Unsupported JPEG Orientation transformation: %x.\n", transform );
+ DALI_LOG_ERROR("Unsupported JPEG Orientation transformation: %x.\n", transform);
break;
}
}
return result;
}
-bool EncodeToJpeg( const unsigned char* const pixelBuffer, Vector< unsigned char >& encodedPixels,
- const std::size_t width, const std::size_t height, const Pixel::Format pixelFormat, unsigned quality )
+bool EncodeToJpeg(const unsigned char* const pixelBuffer, Vector<unsigned char>& encodedPixels, const std::size_t width, const std::size_t height, const Pixel::Format pixelFormat, unsigned quality)
{
-
- if( !pixelBuffer )
+ if(!pixelBuffer)
{
DALI_LOG_ERROR("Null input buffer\n");
return false;
// Translate pixel format enum:
int jpegPixelFormat = -1;
- switch( pixelFormat )
+ switch(pixelFormat)
{
case Pixel::RGB888:
{
}
default:
{
- DALI_LOG_ERROR( "Unsupported pixel format for encoding to JPEG.\n" );
+ DALI_LOG_ERROR("Unsupported pixel format for encoding to JPEG.\n");
return false;
}
}
// Assert quality is in the documented allowable range of the jpeg-turbo lib:
- DALI_ASSERT_DEBUG( quality >= 1 );
- DALI_ASSERT_DEBUG( quality <= 100 );
- if( quality < 1 )
+ DALI_ASSERT_DEBUG(quality >= 1);
+ DALI_ASSERT_DEBUG(quality <= 100);
+ if(quality < 1)
{
quality = 1;
}
- if( quality > 100 )
+ if(quality > 100)
{
quality = 100;
}
// Initialise a JPEG codec:
{
auto jpeg = MakeJpegCompressor();
- if( !jpeg )
+ if(!jpeg)
{
- DALI_LOG_ERROR( "JPEG Compressor init failed: %s\n", tjGetErrorStr() );
+ DALI_LOG_ERROR("JPEG Compressor init failed: %s\n", tjGetErrorStr());
return false;
}
-
// Safely wrap the jpeg codec's buffer in case we are about to throw, then
// save the pixels to a persistent buffer that we own and let our cleaner
// class clean up the buffer as it goes out of scope:
// Run the compressor:
unsigned long dstBufferSize = 0;
- const int flags = 0;
-
- if( tjCompress2( jpeg.get(),
- const_cast<unsigned char*>(pixelBuffer),
- width, 0, height,
- jpegPixelFormat, SetPointer(dstBuffer), &dstBufferSize,
- TJSAMP_444, quality, flags ) )
+ const int flags = 0;
+
+ if(tjCompress2(jpeg.get(),
+ const_cast<unsigned char*>(pixelBuffer),
+ width,
+ 0,
+ height,
+ jpegPixelFormat,
+ SetPointer(dstBuffer),
+ &dstBufferSize,
+ TJSAMP_444,
+ quality,
+ flags))
{
DALI_LOG_ERROR("JPEG Compression failed: %s\n", tjGetErrorStr());
return false;
}
- encodedPixels.Resize( dstBufferSize );
- memcpy( encodedPixels.Begin(), dstBuffer.get(), dstBufferSize );
+ encodedPixels.Resize(dstBufferSize);
+ memcpy(encodedPixels.Begin(), dstBuffer.get(), dstBufferSize);
}
return true;
}
-
JpegTransform ConvertExifOrientation(ExifData* exifData)
{
- auto transform = JpegTransform::NONE;
- ExifEntry * const entry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION);
- int orientation = 0;
- if( entry )
+ auto transform = JpegTransform::NONE;
+ ExifEntry* const entry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION);
+ int orientation = 0;
+ if(entry)
{
orientation = exif_get_short(entry->data, exif_data_get_byte_order(entry->parent->parent));
- switch( orientation )
+ switch(orientation)
{
case 1:
{
default:
{
// Try to keep loading the file, but let app developer know there was something fishy:
- DALI_LOG_WARNING( "Incorrect/Unknown Orientation setting found in EXIF header of JPEG image (%x). Orientation setting will be ignored.\n", entry );
+ DALI_LOG_WARNING("Incorrect/Unknown Orientation setting found in EXIF header of JPEG image (%x). Orientation setting will be ignored.\n", entry);
break;
}
}
return transform;
}
-bool TransformSize( int requiredWidth, int requiredHeight,
- FittingMode::Type fittingMode, SamplingMode::Type samplingMode,
- JpegTransform transform,
- int& preXformImageWidth, int& preXformImageHeight,
- int& postXformImageWidth, int& postXformImageHeight )
+bool TransformSize(int requiredWidth, int requiredHeight, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, JpegTransform transform, int& preXformImageWidth, int& preXformImageHeight, int& postXformImageWidth, int& postXformImageHeight)
{
bool success = true;
- if( transform == JpegTransform::ROTATE_90 || transform == JpegTransform::ROTATE_270 || transform == JpegTransform::ROTATE_180 || transform == JpegTransform::TRANSVERSE)
+ if(transform == JpegTransform::ROTATE_90 || transform == JpegTransform::ROTATE_270 || transform == JpegTransform::ROTATE_180 || transform == JpegTransform::TRANSVERSE)
{
- std::swap( requiredWidth, requiredHeight );
- std::swap( postXformImageWidth, postXformImageHeight );
+ std::swap(requiredWidth, requiredHeight);
+ std::swap(postXformImageWidth, postXformImageHeight);
}
// Apply the special rules for when there are one or two zeros in requested dimensions:
- const ImageDimensions correctedDesired = Internal::Platform::CalculateDesiredDimensions( ImageDimensions( postXformImageWidth, postXformImageHeight), ImageDimensions( requiredWidth, requiredHeight ) );
- requiredWidth = correctedDesired.GetWidth();
- requiredHeight = correctedDesired.GetHeight();
+ const ImageDimensions correctedDesired = Internal::Platform::CalculateDesiredDimensions(ImageDimensions(postXformImageWidth, postXformImageHeight), ImageDimensions(requiredWidth, requiredHeight));
+ requiredWidth = correctedDesired.GetWidth();
+ requiredHeight = correctedDesired.GetHeight();
// Rescale image during decode using one of the decoder's built-in rescaling
// ratios (expected to be powers of 2), keeping the final image at least as
// wide and high as was requested:
- int numFactors = 0;
- tjscalingfactor* factors = tjGetScalingFactors( &numFactors );
- if( factors == NULL )
+ int numFactors = 0;
+ tjscalingfactor* factors = tjGetScalingFactors(&numFactors);
+ if(factors == NULL)
{
DALI_LOG_WARNING("TurboJpeg tjGetScalingFactors error!\n");
success = false;
// apply it if the application requested one of those:
// (use a switch case here so this code will fail to compile if other modes are added)
bool downscale = true;
- switch( samplingMode )
+ switch(samplingMode)
{
case SamplingMode::BOX:
case SamplingMode::BOX_THEN_NEAREST:
}
}
- int scaleFactorIndex( 0 );
- if( downscale )
+ int scaleFactorIndex(0);
+ if(downscale)
{
// Find nearest supported scaling factor (factors are in sequential order, getting smaller)
- for( int i = 1; i < numFactors; ++i )
+ for(int i = 1; i < numFactors; ++i)
{
- bool widthLessRequired = TJSCALED( postXformImageWidth, factors[i]) < requiredWidth;
- bool heightLessRequired = TJSCALED( postXformImageHeight, factors[i]) < requiredHeight;
+ bool widthLessRequired = TJSCALED(postXformImageWidth, factors[i]) < requiredWidth;
+ bool heightLessRequired = TJSCALED(postXformImageHeight, factors[i]) < requiredHeight;
// If either scaled dimension is smaller than the desired one, we were done at the last iteration
- if ( (fittingMode == FittingMode::SCALE_TO_FILL) && (widthLessRequired || heightLessRequired) )
+ if((fittingMode == FittingMode::SCALE_TO_FILL) && (widthLessRequired || heightLessRequired))
{
break;
}
// If both dimensions are smaller than the desired one, we were done at the last iteration:
- if ( (fittingMode == FittingMode::SHRINK_TO_FIT) && ( widthLessRequired && heightLessRequired ) )
+ if((fittingMode == FittingMode::SHRINK_TO_FIT) && (widthLessRequired && heightLessRequired))
{
break;
}
// If the width is smaller than the desired one, we were done at the last iteration:
- if ( fittingMode == FittingMode::FIT_WIDTH && widthLessRequired )
+ if(fittingMode == FittingMode::FIT_WIDTH && widthLessRequired)
{
break;
}
// If the width is smaller than the desired one, we were done at the last iteration:
- if ( fittingMode == FittingMode::FIT_HEIGHT && heightLessRequired )
+ if(fittingMode == FittingMode::FIT_HEIGHT && heightLessRequired)
{
break;
}
}
// Regardless of requested size, downscale to avoid exceeding the maximum texture size:
- for( int i = scaleFactorIndex; i < numFactors; ++i )
+ for(int i = scaleFactorIndex; i < numFactors; ++i)
{
// Continue downscaling to below maximum texture size (if possible)
scaleFactorIndex = i;
- if( TJSCALED(postXformImageWidth, (factors[i])) < static_cast< int >( Dali::GetMaxTextureSize() ) &&
- TJSCALED(postXformImageHeight, (factors[i])) < static_cast< int >( Dali::GetMaxTextureSize() ) )
+ if(TJSCALED(postXformImageWidth, (factors[i])) < static_cast<int>(Dali::GetMaxTextureSize()) &&
+ TJSCALED(postXformImageHeight, (factors[i])) < static_cast<int>(Dali::GetMaxTextureSize()))
{
// Current scale-factor downscales to below maximum texture size
break;
}
// We have finally chosen the scale-factor, return width/height values
- if( scaleFactorIndex > 0 )
+ if(scaleFactorIndex > 0)
{
- preXformImageWidth = TJSCALED(preXformImageWidth, (factors[scaleFactorIndex]));
- preXformImageHeight = TJSCALED(preXformImageHeight, (factors[scaleFactorIndex]));
- postXformImageWidth = TJSCALED(postXformImageWidth, (factors[scaleFactorIndex]));
+ preXformImageWidth = TJSCALED(preXformImageWidth, (factors[scaleFactorIndex]));
+ preXformImageHeight = TJSCALED(preXformImageHeight, (factors[scaleFactorIndex]));
+ postXformImageWidth = TJSCALED(postXformImageWidth, (factors[scaleFactorIndex]));
postXformImageHeight = TJSCALED(postXformImageHeight, (factors[scaleFactorIndex]));
}
}
return success;
}
-ExifHandle LoadExifData( FILE* fp )
+ExifHandle LoadExifData(FILE* fp)
{
- auto exifData = MakeNullExifData();
+ auto exifData = MakeNullExifData();
unsigned char dataBuffer[1024];
- if( fseek( fp, 0, SEEK_SET ) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking to start of file\n");
}
else
{
auto exifLoader = std::unique_ptr<ExifLoader, decltype(exif_loader_unref)*>{
- exif_loader_new(), exif_loader_unref };
+ exif_loader_new(), exif_loader_unref};
- while( !feof(fp) )
+ while(!feof(fp))
{
- int size = fread( dataBuffer, 1, sizeof( dataBuffer ), fp );
- if( size <= 0 )
+ int size = fread(dataBuffer, 1, sizeof(dataBuffer), fp);
+ if(size <= 0)
{
break;
}
- if( ! exif_loader_write( exifLoader.get(), dataBuffer, size ) )
+ if(!exif_loader_write(exifLoader.get(), dataBuffer, size))
{
break;
}
}
- exifData.reset( exif_loader_get_data( exifLoader.get() ) );
+ exifData.reset(exif_loader_get_data(exifLoader.get()));
}
return exifData;
}
-bool LoadJpegHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadJpegHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
unsigned int requiredWidth = input.scalingParameters.dimensions.GetWidth();
unsigned int requiredHeight = input.scalingParameters.dimensions.GetHeight();
- FILE* const fp = input.file;
+ FILE* const fp = input.file;
bool success = false;
- if( requiredWidth == 0 && requiredHeight == 0 )
+ if(requiredWidth == 0 && requiredHeight == 0)
{
- success = LoadJpegHeader( fp, width, height );
+ success = LoadJpegHeader(fp, width, height);
}
else
{
// Double check we get the same width/height from the header
unsigned int headerWidth;
unsigned int headerHeight;
- if( LoadJpegHeader( fp, headerWidth, headerHeight ) )
+ if(LoadJpegHeader(fp, headerWidth, headerHeight))
{
auto transform = JpegTransform::NONE;
- if( input.reorientationRequested )
+ if(input.reorientationRequested)
{
- auto exifData = LoadExifData( fp );
- if( exifData )
+ auto exifData = LoadExifData(fp);
+ if(exifData)
{
transform = ConvertExifOrientation(exifData.get());
}
- int preXformImageWidth = headerWidth;
- int preXformImageHeight = headerHeight;
- int postXformImageWidth = headerWidth;
+ int preXformImageWidth = headerWidth;
+ int preXformImageHeight = headerHeight;
+ int postXformImageWidth = headerWidth;
int postXformImageHeight = headerHeight;
- success = TransformSize( requiredWidth, requiredHeight, input.scalingParameters.scalingMode, input.scalingParameters.samplingMode, transform, preXformImageWidth, preXformImageHeight, postXformImageWidth, postXformImageHeight );
+ success = TransformSize(requiredWidth, requiredHeight, input.scalingParameters.scalingMode, input.scalingParameters.samplingMode, transform, preXformImageWidth, preXformImageHeight, postXformImageWidth, postXformImageHeight);
if(success)
{
- width = postXformImageWidth;
+ width = postXformImageWidth;
height = postXformImageHeight;
}
}
else
{
success = true;
- width = headerWidth;
- height = headerHeight;
+ width = headerWidth;
+ height = headerHeight;
}
}
}
return success;
}
-
} // namespace TizenPlatform
} // namespace Dali
/*
- * 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.
#include <dali/internal/imaging/common/loader-ktx.h>
// EXTERNAL INCLUDES
-#include <cstring>
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/debug.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
+#include <cstring>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace
{
-
/** Max width or height of an image. */
const unsigned MAX_TEXTURE_DIMENSION = 4096;
/** Max bytes of image data allowed. Not a precise number, just a sanity check. */
typedef uint8_t Byte;
const Byte FileIdentifier[] = {
- 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
-};
-
+ 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A};
/** The formats we support inside a KTX file container.
* Currently only compressed formats are allowed as we'd rather
KTX_NOTEXIST = 0,
// GLES 2 Extension formats:
- KTX_ETC1_RGB8_OES = 0x8D64,
- KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
+ KTX_ETC1_RGB8_OES = 0x8D64,
+ KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
// GLES 3 Standard compressed formats (values same as in gl3.h):
- KTX_COMPRESSED_R11_EAC = 0x9270,
- KTX_COMPRESSED_SIGNED_R11_EAC = 0x9271,
- KTX_COMPRESSED_RG11_EAC = 0x9272,
- KTX_COMPRESSED_SIGNED_RG11_EAC = 0x9273,
- KTX_COMPRESSED_RGB8_ETC2 = 0x9274,
- KTX_COMPRESSED_SRGB8_ETC2 = 0x9275,
- KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
- KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
- KTX_COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
- KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
+ KTX_COMPRESSED_R11_EAC = 0x9270,
+ KTX_COMPRESSED_SIGNED_R11_EAC = 0x9271,
+ KTX_COMPRESSED_RG11_EAC = 0x9272,
+ KTX_COMPRESSED_SIGNED_RG11_EAC = 0x9273,
+ KTX_COMPRESSED_RGB8_ETC2 = 0x9274,
+ KTX_COMPRESSED_SRGB8_ETC2 = 0x9275,
+ KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
+ KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
+ KTX_COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
// GLES 3.1 compressed formats:
- KTX_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0,
- KTX_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1,
- KTX_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2,
- KTX_COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3,
- KTX_COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4,
- KTX_COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5,
- KTX_COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6,
- KTX_COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7,
- KTX_COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8,
- KTX_COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9,
- KTX_COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA,
- KTX_COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB,
- KTX_COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC,
- KTX_COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD,
+ KTX_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0,
+ KTX_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1,
+ KTX_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2,
+ KTX_COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3,
+ KTX_COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4,
+ KTX_COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5,
+ KTX_COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6,
+ KTX_COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7,
+ KTX_COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8,
+ KTX_COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9,
+ KTX_COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA,
+ KTX_COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB,
+ KTX_COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC,
+ KTX_COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD,
// Uncompressed Alpha format
- KTX_UNCOMPRESSED_ALPHA8 = 0x1906,
+ KTX_UNCOMPRESSED_ALPHA8 = 0x1906,
KTX_SENTINEL = ~0u
};
const unsigned KtxInternalFormats[] =
-{
- // GLES 2 Extension formats:
- KTX_ETC1_RGB8_OES,
- KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
-
- // GLES 3 Standard compressed formats:
- KTX_COMPRESSED_R11_EAC,
- KTX_COMPRESSED_SIGNED_R11_EAC,
- KTX_COMPRESSED_RG11_EAC,
- KTX_COMPRESSED_SIGNED_RG11_EAC,
- KTX_COMPRESSED_RGB8_ETC2,
- KTX_COMPRESSED_SRGB8_ETC2,
- KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
- KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
- KTX_COMPRESSED_RGBA8_ETC2_EAC,
- KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
-
- // GLES 3.1 Compressed formats:
- KTX_COMPRESSED_RGBA_ASTC_4x4_KHR,
- KTX_COMPRESSED_RGBA_ASTC_5x4_KHR,
- KTX_COMPRESSED_RGBA_ASTC_5x5_KHR,
- KTX_COMPRESSED_RGBA_ASTC_6x5_KHR,
- KTX_COMPRESSED_RGBA_ASTC_6x6_KHR,
- KTX_COMPRESSED_RGBA_ASTC_8x5_KHR,
- KTX_COMPRESSED_RGBA_ASTC_8x6_KHR,
- KTX_COMPRESSED_RGBA_ASTC_8x8_KHR,
- KTX_COMPRESSED_RGBA_ASTC_10x5_KHR,
- KTX_COMPRESSED_RGBA_ASTC_10x6_KHR,
- KTX_COMPRESSED_RGBA_ASTC_10x8_KHR,
- KTX_COMPRESSED_RGBA_ASTC_10x10_KHR,
- KTX_COMPRESSED_RGBA_ASTC_12x10_KHR,
- KTX_COMPRESSED_RGBA_ASTC_12x12_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
- KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
+ {
+ // GLES 2 Extension formats:
+ KTX_ETC1_RGB8_OES,
+ KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
+
+ // GLES 3 Standard compressed formats:
+ KTX_COMPRESSED_R11_EAC,
+ KTX_COMPRESSED_SIGNED_R11_EAC,
+ KTX_COMPRESSED_RG11_EAC,
+ KTX_COMPRESSED_SIGNED_RG11_EAC,
+ KTX_COMPRESSED_RGB8_ETC2,
+ KTX_COMPRESSED_SRGB8_ETC2,
+ KTX_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
+ KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
+ KTX_COMPRESSED_RGBA8_ETC2_EAC,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
+
+ // GLES 3.1 Compressed formats:
+ KTX_COMPRESSED_RGBA_ASTC_4x4_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_5x4_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_5x5_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_6x5_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_6x6_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_8x5_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_8x6_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_8x8_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_10x5_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_10x6_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_10x8_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_10x10_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_12x10_KHR,
+ KTX_COMPRESSED_RGBA_ASTC_12x12_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
+ KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
- // Uncompressed Alpha format
- KTX_UNCOMPRESSED_ALPHA8,
+ // Uncompressed Alpha format
+ KTX_UNCOMPRESSED_ALPHA8,
- KTX_SENTINEL
-};
+ KTX_SENTINEL};
struct KtxFileHeader
{
- Byte identifier[12];
+ Byte identifier[12];
uint32_t endianness;
uint32_t glType;
uint32_t glTypeSize;
uint32_t numberOfFaces;
uint32_t numberOfMipmapLevels;
uint32_t bytesOfKeyValueData;
-} __attribute__ ( (__packed__));
+} __attribute__((__packed__));
// Packed attribute stops the structure from being aligned to compiler defaults
// so we can be sure of reading the whole thing from file in one call to fread.
* @param[out] header The structure we want to store our information in
* @return true, if read successful, false otherwise
*/
-inline bool ReadHeader( FILE* filePointer, KtxFileHeader& header )
+inline bool ReadHeader(FILE* filePointer, KtxFileHeader& header)
{
- const unsigned int readLength = sizeof( KtxFileHeader );
+ const unsigned int readLength = sizeof(KtxFileHeader);
// Load the information directly into our structure
- if( fread( &header, 1, readLength, filePointer ) != readLength )
+ if(fread(&header, 1, readLength, filePointer) != readLength)
{
return false;
}
/** Check whether the array passed in is the right size and matches the magic
* values defined to be at the start of a KTX file by the specification.*/
template<int BYTES_IN_SIGNATURE>
-bool CheckFileIdentifier(const Byte * const signature)
+bool CheckFileIdentifier(const Byte* const signature)
{
- const unsigned signatureSize = BYTES_IN_SIGNATURE;
+ const unsigned signatureSize = BYTES_IN_SIGNATURE;
const unsigned identifierSize = sizeof(FileIdentifier);
static_assert(signatureSize == identifierSize);
- const bool signatureGood = 0 == memcmp( signature, FileIdentifier, std::min( signatureSize, identifierSize ) );
+ const bool signatureGood = 0 == memcmp(signature, FileIdentifier, std::min(signatureSize, identifierSize));
return signatureGood;
}
default:
{
- return false;
+ return false;
}
}
return true;
}
-bool LoadKtxHeader( FILE * const fp, unsigned int& width, unsigned int& height, KtxFileHeader& fileHeader )
+bool LoadKtxHeader(FILE* const fp, unsigned int& width, unsigned int& height, KtxFileHeader& fileHeader)
{
// Pull the bytes of the file header in as a block:
- if ( !ReadHeader( fp, fileHeader ) )
+ if(!ReadHeader(fp, fileHeader))
{
return false;
}
- width = fileHeader.pixelWidth;
+ width = fileHeader.pixelWidth;
height = fileHeader.pixelHeight;
- if ( width > MAX_TEXTURE_DIMENSION || height > MAX_TEXTURE_DIMENSION )
+ if(width > MAX_TEXTURE_DIMENSION || height > MAX_TEXTURE_DIMENSION)
{
return false;
}
const bool glFormatCompatibleWithCompressedTex = fileHeader.glFormat == 0;
const bool glInternalFormatIsSupportedCompressedTex = ValidInternalFormat(fileHeader.glInternalFormat);
// Ignore glBaseInternalFormat
- const bool textureIsNot3D = fileHeader.pixelDepth == 0 || fileHeader.pixelDepth == 1;
- const bool textureIsNotAnArray = fileHeader.numberOfArrayElements == 0 || fileHeader.numberOfArrayElements == 1;
- const bool textureIsNotACubemap = fileHeader.numberOfFaces == 0 || fileHeader.numberOfFaces == 1;
- const bool textureHasNoMipmapLevels = fileHeader.numberOfMipmapLevels == 0 || fileHeader.numberOfMipmapLevels == 1;
- const bool keyValueDataNotTooLarge = fileHeader.bytesOfKeyValueData <= MAX_BYTES_OF_KEYVALUE_DATA;
+ const bool textureIsNot3D = fileHeader.pixelDepth == 0 || fileHeader.pixelDepth == 1;
+ const bool textureIsNotAnArray = fileHeader.numberOfArrayElements == 0 || fileHeader.numberOfArrayElements == 1;
+ const bool textureIsNotACubemap = fileHeader.numberOfFaces == 0 || fileHeader.numberOfFaces == 1;
+ const bool textureHasNoMipmapLevels = fileHeader.numberOfMipmapLevels == 0 || fileHeader.numberOfMipmapLevels == 1;
+ const bool keyValueDataNotTooLarge = fileHeader.bytesOfKeyValueData <= MAX_BYTES_OF_KEYVALUE_DATA;
bool headerIsValid = signatureGood && fileEndiannessMatchesSystemEndianness &&
- glTypeSizeCompatibleWithCompressedTex && textureIsNot3D && textureIsNotAnArray &&
- textureIsNotACubemap && textureHasNoMipmapLevels && keyValueDataNotTooLarge;
+ glTypeSizeCompatibleWithCompressedTex && textureIsNot3D && textureIsNotAnArray &&
+ textureIsNotACubemap && textureHasNoMipmapLevels && keyValueDataNotTooLarge;
- if( !glTypeIsCompressed ) // check for uncompressed Alpha
+ if(!glTypeIsCompressed) // check for uncompressed Alpha
{
- const bool isAlpha = ( ( fileHeader.glBaseInternalFormat == KTX_UNCOMPRESSED_ALPHA8 ) && ( fileHeader.glFormat == KTX_UNCOMPRESSED_ALPHA8 ) &&
- ( fileHeader.glInternalFormat == KTX_UNCOMPRESSED_ALPHA8 ) );
- headerIsValid = headerIsValid && isAlpha;
+ const bool isAlpha = ((fileHeader.glBaseInternalFormat == KTX_UNCOMPRESSED_ALPHA8) && (fileHeader.glFormat == KTX_UNCOMPRESSED_ALPHA8) &&
+ (fileHeader.glInternalFormat == KTX_UNCOMPRESSED_ALPHA8));
+ headerIsValid = headerIsValid && isAlpha;
}
else
{
headerIsValid = headerIsValid && glFormatCompatibleWithCompressedTex && glInternalFormatIsSupportedCompressedTex;
}
- if( !headerIsValid )
+ if(!headerIsValid)
{
- DALI_LOG_ERROR( "KTX file invalid or using unsupported features. Header tests: sig: %d, endian: %d, gl_type: %d, gl_type_size: %d, gl_format: %d, internal_format: %d, depth: %d, array: %d, faces: %d, mipmap: %d, vey-vals: %d.\n", 0+signatureGood, 0+fileEndiannessMatchesSystemEndianness, 0+glTypeIsCompressed, 0+glTypeSizeCompatibleWithCompressedTex, 0+glFormatCompatibleWithCompressedTex, 0+glInternalFormatIsSupportedCompressedTex, 0+textureIsNot3D, 0+textureIsNotAnArray, 0+textureIsNotACubemap, 0+textureHasNoMipmapLevels, 0+keyValueDataNotTooLarge);
+ DALI_LOG_ERROR("KTX file invalid or using unsupported features. Header tests: sig: %d, endian: %d, gl_type: %d, gl_type_size: %d, gl_format: %d, internal_format: %d, depth: %d, array: %d, faces: %d, mipmap: %d, vey-vals: %d.\n", 0 + signatureGood, 0 + fileEndiannessMatchesSystemEndianness, 0 + glTypeIsCompressed, 0 + glTypeSizeCompatibleWithCompressedTex, 0 + glFormatCompatibleWithCompressedTex, 0 + glInternalFormatIsSupportedCompressedTex, 0 + textureIsNot3D, 0 + textureIsNotAnArray, 0 + textureIsNotACubemap, 0 + textureHasNoMipmapLevels, 0 + keyValueDataNotTooLarge);
}
// Warn if there is space wasted in the file:
- if( fileHeader.bytesOfKeyValueData > 0U )
+ if(fileHeader.bytesOfKeyValueData > 0U)
{
DALI_LOG_WARNING("Loading of KTX file with key/value header data requested. This should be stripped in application asset/resource build.\n");
}
return headerIsValid;
}
-
} // unnamed namespace
// File loading API entry-point:
-bool LoadKtxHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadKtxHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
KtxFileHeader fileHeader;
- FILE* const fp = input.file;
+ FILE* const fp = input.file;
bool ret = LoadKtxHeader(fp, width, height, fileHeader);
return ret;
}
// File loading API entry-point:
-bool LoadBitmapFromKtx( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromKtx(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
static_assert(sizeof(Byte) == 1);
static_assert(sizeof(uint32_t) == 4);
FILE* const fp = input.file;
- if( fp == NULL )
+ if(fp == NULL)
{
- DALI_LOG_ERROR( "Null file handle passed to KTX compressed bitmap file loader.\n" );
+ DALI_LOG_ERROR("Null file handle passed to KTX compressed bitmap file loader.\n");
return false;
}
KtxFileHeader fileHeader;
// Load the header info
unsigned int width, height;
- if (!LoadKtxHeader(fp, width, height, fileHeader))
+ if(!LoadKtxHeader(fp, width, height, fileHeader))
{
- return false;
+ return false;
}
// Skip the key-values:
const long int imageSizeOffset = sizeof(KtxFileHeader) + fileHeader.bytesOfKeyValueData;
if(fseek(fp, imageSizeOffset, SEEK_SET))
{
- DALI_LOG_ERROR( "Seek past key/vals in KTX compressed bitmap file failed.\n" );
+ DALI_LOG_ERROR("Seek past key/vals in KTX compressed bitmap file failed.\n");
return false;
}
// Load the size of the image data:
uint32_t imageByteCount = 0;
- if ( fread( &imageByteCount, 1, 4, fp ) != 4 )
+ if(fread(&imageByteCount, 1, 4, fp) != 4)
{
- DALI_LOG_ERROR( "Read of image size failed.\n" );
+ DALI_LOG_ERROR("Read of image size failed.\n");
return false;
}
// Sanity-check the image size:
- if( imageByteCount > MAX_IMAGE_DATA_SIZE ||
- // A compressed texture should certainly be less than 2 bytes per texel:
- imageByteCount > width * height * 2)
+ if(imageByteCount > MAX_IMAGE_DATA_SIZE ||
+ // A compressed texture should certainly be less than 2 bytes per texel:
+ imageByteCount > width * height * 2)
{
- DALI_LOG_ERROR( "KTX file with too-large image-data field.\n" );
+ DALI_LOG_ERROR("KTX file with too-large image-data field.\n");
return false;
}
Pixel::Format pixelFormat;
- const bool pixelFormatKnown = ConvertPixelFormat(fileHeader.glInternalFormat, pixelFormat);
+ const bool pixelFormatKnown = ConvertPixelFormat(fileHeader.glInternalFormat, pixelFormat);
if(!pixelFormatKnown)
{
- DALI_LOG_ERROR( "No internal pixel format supported for KTX file pixel format.\n" );
+ DALI_LOG_ERROR("No internal pixel format supported for KTX file pixel format.\n");
return false;
}
// Compressed format won't allocate the buffer
auto pixels = bitmap.GetBuffer();
- if( !pixels )
+ if(!pixels)
{
// allocate buffer manually
- auto &impl = GetImplementation(bitmap);
+ auto& impl = GetImplementation(bitmap);
impl.AllocateFixedSize(imageByteCount);
pixels = bitmap.GetBuffer();
}
if(!pixels)
{
- DALI_LOG_ERROR( "Unable to reserve a pixel buffer to load the requested bitmap into.\n" );
+ DALI_LOG_ERROR("Unable to reserve a pixel buffer to load the requested bitmap into.\n");
return false;
}
const size_t bytesRead = fread(pixels, 1, imageByteCount, fp);
if(bytesRead != imageByteCount)
{
- DALI_LOG_ERROR( "Read of image pixel data failed.\n" );
+ DALI_LOG_ERROR("Read of image pixel data failed.\n");
return false;
}
/*
- * 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.
#include <cstring>
-#include <zlib.h>
#include <png.h>
+#include <zlib.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/legacy/tizen/platform-capabilities.h>
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
namespace Dali
{
namespace TizenPlatform
{
-
namespace
{
-
// simple class to enforce clean-up of PNG structures
struct auto_png
{
}
png_structp& png;
- png_infop& info;
+ png_infop& info;
}; // struct auto_png;
-bool LoadPngHeader(FILE *fp, unsigned int &width, unsigned int &height, png_structp &png, png_infop &info)
+bool LoadPngHeader(FILE* fp, unsigned int& width, unsigned int& height, png_structp& png, png_infop& info)
{
- png_byte header[8] = { 0 };
+ png_byte header[8] = {0};
// Check header to see if it is a PNG file
size_t size = fread(header, 1, 8, fp);
png_read_info(png, info);
// dimensions
- width = png_get_image_width(png, info);
+ width = png_get_image_width(png, info);
height = png_get_image_height(png, info);
return true;
}
-} // namespace - anonymous
+} // namespace
-bool LoadPngHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadPngHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
- png_structp png = NULL;
- png_infop info = NULL;
- auto_png autoPng(png, info);
+ png_structp png = NULL;
+ png_infop info = NULL;
+ auto_png autoPng(png, info);
- bool success = LoadPngHeader( input.file, width, height, png, info );
+ bool success = LoadPngHeader(input.file, width, height, png, info);
return success;
}
-bool LoadBitmapFromPng( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
- png_structp png = NULL;
- png_infop info = NULL;
- auto_png autoPng(png, info);
+ png_structp png = NULL;
+ png_infop info = NULL;
+ auto_png autoPng(png, info);
/// @todo: consider parameters
unsigned int y;
unsigned int width, height;
- png_bytep *rows;
- unsigned int bpp = 0; // bytes per pixel
- bool valid = false;
+ png_bytep* rows;
+ unsigned int bpp = 0; // bytes per pixel
+ bool valid = false;
// Load info from the header
- if( !LoadPngHeader( input.file, width, height, png, info ) )
+ if(!LoadPngHeader(input.file, width, height, png, info))
{
return false;
}
unsigned int colordepth = png_get_bit_depth(png, info);
// Ask PNGLib to convert high precision images into something we can use:
- if (colordepth == 16)
+ if(colordepth == 16)
{
png_set_strip_16(png);
colordepth = 8;
png_byte colortype = png_get_color_type(png, info);
- if( colortype == PNG_COLOR_TYPE_GRAY ||
- colortype == PNG_COLOR_TYPE_GRAY_ALPHA )
+ if(colortype == PNG_COLOR_TYPE_GRAY ||
+ colortype == PNG_COLOR_TYPE_GRAY_ALPHA)
{
- if( colortype == PNG_COLOR_TYPE_GRAY )
+ if(colortype == PNG_COLOR_TYPE_GRAY)
{
pixelFormat = Pixel::L8;
- if( png_get_valid(png, info, PNG_INFO_tRNS) )
+ if(png_get_valid(png, info, PNG_INFO_tRNS))
{
colortype = PNG_COLOR_TYPE_GRAY_ALPHA;
/* expand transparency entry -> alpha channel if present */
pixelFormat = Pixel::LA88;
}
- if( colordepth < 8 )
+ if(colordepth < 8)
{
/* expand gray (w/reduced bits) -> 8-bit RGB if necessary */
png_set_expand_gray_1_2_4_to_8(png);
}
valid = true;
}
- else if(colortype == PNG_COLOR_TYPE_RGB )
+ else if(colortype == PNG_COLOR_TYPE_RGB)
{
switch(colordepth)
{
case 8:
{
pixelFormat = Pixel::RGB888;
- valid = true;
+ valid = true;
break;
}
- case 5: /// @todo is this correct for RGB16 5-6-5 ?
+ case 5: /// @todo is this correct for RGB16 5-6-5 ?
{
pixelFormat = Pixel::RGB565;
- valid = true;
+ valid = true;
break;
}
default:
case 8:
{
pixelFormat = Pixel::RGBA8888;
- valid = true;
+ valid = true;
break;
}
default:
case 1:
{
pixelFormat = Pixel::LA88;
- valid = true;
+ valid = true;
break;
}
if(png_get_valid(png, info, PNG_INFO_tRNS) == 0x10)
{
pixelFormat = Pixel::RGBA8888;
- valid = true;
+ valid = true;
}
else
{
}
}
- if( !valid )
+ if(!valid)
{
- DALI_LOG_WARNING( "Unsupported png format\n" );
+ DALI_LOG_WARNING("Unsupported png format\n");
return false;
}
unsigned int rowBytes = png_get_rowbytes(png, info);
- unsigned int bufferWidth = GetTextureDimension(width);
- unsigned int bufferHeight = GetTextureDimension(height);
- unsigned int stride = bufferWidth*bpp;
+ unsigned int bufferWidth = GetTextureDimension(width);
+ unsigned int bufferHeight = GetTextureDimension(height);
+ unsigned int stride = bufferWidth * bpp;
// not sure if this ever happens
- if( rowBytes > stride )
+ if(rowBytes > stride)
{
stride = GetTextureDimension(rowBytes);
default:
break;
}
-
}
// decode the whole image into bitmap buffer
auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat)).GetBuffer();
DALI_ASSERT_DEBUG(pixels);
- rows = reinterpret_cast< png_bytep* >( malloc(sizeof(png_bytep) * height) );
- for(y=0; y<height; y++)
+ rows = reinterpret_cast<png_bytep*>(malloc(sizeof(png_bytep) * height));
+ for(y = 0; y < height; y++)
{
rows[y] = pixels + y * stride;
}
}
png_structp& png;
- png_infop& info;
+ png_infop& info;
}; // struct AutoPngWrite;
namespace
{
- // Custom libpng write callbacks that buffer to a vector instead of a file:
+// Custom libpng write callbacks that buffer to a vector instead of a file:
- /**
+/**
* extern "C" linkage is used because this is a callback that we pass to a C
* library which is part of the underlying platform and so potentially compiled
* as C rather than C++.
* @see http://stackoverflow.com/a/2594222
* */
- extern "C" void WriteData(png_structp png_ptr, png_bytep data, png_size_t length)
+extern "C" void WriteData(png_structp png_ptr, png_bytep data, png_size_t length)
+{
+ DALI_ASSERT_DEBUG(png_ptr && data);
+ if(!png_ptr || !data)
{
- DALI_ASSERT_DEBUG(png_ptr && data);
- if(!png_ptr || !data)
- {
- return;
- }
- // Make sure we don't try to propagate a C++ exception up the call stack of a pure C library:
- try
+ return;
+ }
+ // Make sure we don't try to propagate a C++ exception up the call stack of a pure C library:
+ try
+ {
+ // Recover our buffer for writing into:
+ Vector<unsigned char>* const encoded_img = static_cast<Vector<unsigned char>*>(png_get_io_ptr(png_ptr));
+ if(encoded_img)
{
- // Recover our buffer for writing into:
- Vector<unsigned char>* const encoded_img = static_cast< Vector<unsigned char>* >( png_get_io_ptr(png_ptr) );
- if(encoded_img)
- {
- const Vector<unsigned char>::SizeType bufferSize = encoded_img->Count();
- encoded_img->Resize( bufferSize + length ); //< Can throw OOM.
- unsigned char* const bufferBack = encoded_img->Begin() + bufferSize;
- memcpy(bufferBack, data, length);
- }
- else
- {
- DALI_LOG_ERROR("PNG buffer for write to memory was passed from libpng as null.\n");
- }
+ const Vector<unsigned char>::SizeType bufferSize = encoded_img->Count();
+ encoded_img->Resize(bufferSize + length); //< Can throw OOM.
+ unsigned char* const bufferBack = encoded_img->Begin() + bufferSize;
+ memcpy(bufferBack, data, length);
}
- catch(...)
+ else
{
- DALI_LOG_ERROR("C++ Exception caught\n");
+ DALI_LOG_ERROR("PNG buffer for write to memory was passed from libpng as null.\n");
}
}
-
- /** Override the flush with a NOP to prevent libpng trying cstdlib file io. */
- extern "C" void FlushData(png_structp png_ptr)
+ catch(...)
{
+ DALI_LOG_ERROR("C++ Exception caught\n");
+ }
+}
+
+/** Override the flush with a NOP to prevent libpng trying cstdlib file io. */
+extern "C" void FlushData(png_structp png_ptr)
+{
#ifdef DEBUG_ENABLED
- Debug::LogMessage(Debug::DebugInfo, "PNG Flush");
+ Debug::LogMessage(Debug::DebugInfo, "PNG Flush");
#endif // DEBUG_ENABLED
- }
}
+} // namespace
/**
* Potential improvements:
* 7. If caller asks for no compression, bypass libpng and blat raw data to
* disk, topped and tailed with header/tail blocks.
*/
-bool EncodeToPng( const unsigned char* const pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat )
+bool EncodeToPng(const unsigned char* const pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat)
{
// Translate pixel format enum:
- int pngPixelFormat = -1;
- unsigned pixelBytes = 0;
- bool rgbaOrder = true;
+ int pngPixelFormat = -1;
+ unsigned pixelBytes = 0;
+ bool rgbaOrder = true;
// Account for RGB versus BGR and presence of alpha in input pixels:
- switch( pixelFormat )
+ switch(pixelFormat)
{
case Pixel::RGB888:
{
pngPixelFormat = PNG_COLOR_TYPE_RGB;
- pixelBytes = 3;
+ pixelBytes = 3;
break;
}
case Pixel::BGRA8888:
case Pixel::RGBA8888:
{
pngPixelFormat = PNG_COLOR_TYPE_RGB_ALPHA;
- pixelBytes = 4;
+ pixelBytes = 4;
break;
}
default:
{
- DALI_LOG_ERROR( "Unsupported pixel format for encoding to PNG.\n" );
+ DALI_LOG_ERROR("Unsupported pixel format for encoding to PNG.\n");
return false;
}
}
return false;
}
/* Allocate/initialize the image information data. REQUIRED */
- png_infop info_ptr = png_create_info_struct( png_ptr );
+ png_infop info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr)
{
png_destroy_write_struct(&png_ptr, NULL);
// Explicitly limit the number of filters used per scanline to speed us up:
// png_set_filter(png_ptr, 0, PNG_FILTER_NONE); ///!ToDo: Try this once baseline profile is in place.
- // PNG_FILTER_SUB |
- // PNG_FILTER_UP |
- // PNG_FILTER_AVE |
- // PNG_FILTER_PAETH |
- // PNG_ALL_FILTERS);
+ // PNG_FILTER_SUB |
+ // PNG_FILTER_UP |
+ // PNG_FILTER_AVE |
+ // PNG_FILTER_PAETH |
+ // PNG_ALL_FILTERS);
// Play with Zlib parameters in optimisation phase:
- // png_set_compression_mem_level(png_ptr, 8);
- // png_set_compression_strategy(png_ptr,
- // Z_DEFAULT_STRATEGY);
- // png_set_compression_window_bits(png_ptr, 15);
- // png_set_compression_method(png_ptr, 8);
- // png_set_compression_buffer_size(png_ptr, 8192)
+ // png_set_compression_mem_level(png_ptr, 8);
+ // png_set_compression_strategy(png_ptr,
+ // Z_DEFAULT_STRATEGY);
+ // png_set_compression_window_bits(png_ptr, 15);
+ // png_set_compression_method(png_ptr, 8);
+ // png_set_compression_buffer_size(png_ptr, 8192)
// Let lib_png know if the pixel bytes are in BGR(A) order:
if(!rgbaOrder)
{
- png_set_bgr( png_ptr );
+ png_set_bgr(png_ptr);
}
// Set the image information:
- png_set_IHDR(png_ptr, info_ptr, width, height, 8,
- pngPixelFormat, interlace,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+ png_set_IHDR(png_ptr, info_ptr, width, height, 8, pngPixelFormat, interlace, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
// Start to output the PNG data to our buffer:
png_write_info(png_ptr, info_ptr);
// Walk the rows:
- const unsigned row_step = width * pixelBytes;
- png_bytep row_ptr = const_cast<png_bytep>(pixelBuffer);
- const png_bytep row_end = row_ptr + height * row_step;
+ const unsigned row_step = width * pixelBytes;
+ png_bytep row_ptr = const_cast<png_bytep>(pixelBuffer);
+ const png_bytep row_end = row_ptr + height * row_step;
for(; row_ptr < row_end; row_ptr += row_step)
{
png_write_row(png_ptr, row_ptr);
/*
- * Copyright (c) 2017 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.
#include <cstring>
// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_LOADER_WBMP");
#endif
#define IMG_MAX_SIZE 65536
-#define IMG_TOO_BIG(w, h) \
- ((((unsigned long long)w) * ((unsigned long long)h)) >= \
- ((1ULL << (29)) - 2048))
-
+#define IMG_TOO_BIG(w, h) \
+ ((((unsigned long long)w) * ((unsigned long long)h)) >= \
+ ((1ULL << (29)) - 2048))
//extract multiple bytes integer , and saved in *data
-int extractMultiByteInteger(unsigned int *data, void *map, size_t length, size_t *position)
+int extractMultiByteInteger(unsigned int* data, void* map, size_t length, size_t* position)
{
// the header field contains an image type indentifier of multi-byte length(TypeField), an octet of general header info(FixHeaderField)
//, a multi-byte width field(Width) and a multi-byte height field(Height) and so on.
// The actual organisation of the image data depends on the image type
// for Ext Headers flag (7th bit), 1 = More will follow, 0 = Last octet
// so in the for loop, if(buf & 0x80 == 0), loop will be exited
- int targetMultiByteInteger = 0, readBufCount;
+ int targetMultiByteInteger = 0, readBufCount;
unsigned char buf;
- for (readBufCount = 0;;)
+ for(readBufCount = 0;;)
{
// readBufCount means the count that fetched data from map
// extractMultiByteInteger() is to fetch wbmp type , width, and height
// for general width and height, if(buf & 0x80) == 0, then the next byte does not need to fetch again
// first step, readBufCount = 1 , read int(4 bytes) to buf, if buf & 0x80 !=0, the buf need to continue to fetch
// second step, readBufCount = 2, read next( 4 bytes) to buf, if buf & 0x80 == 0, then assigned the buf to target
- if ((readBufCount ++) == 4)
+ if((readBufCount++) == 4)
{
return -1;
}
- if (*position > length)
+ if(*position > length)
{
return -1;
}
- buf = reinterpret_cast< unsigned char * >( map )[(*position)++];
+ buf = reinterpret_cast<unsigned char*>(map)[(*position)++];
targetMultiByteInteger = (targetMultiByteInteger << 7) | (buf & 0x7f);
- if ((buf & 0x80) == 0)
+ if((buf & 0x80) == 0)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "position: %d, readBufCount: %d\n", *position, readBufCount);
break;
return 0;
}
-}// end unnamed namespace
+} // end unnamed namespace
-bool LoadBitmapFromWbmp( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap )
+bool LoadBitmapFromWbmp(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap)
{
FILE* const fp = input.file;
if(fp == NULL)
return false;
}
Dali::Vector<unsigned char> map;
- Dali::Vector<unsigned char> surface;//unsigned int
- size_t position = 0;
+ Dali::Vector<unsigned char> surface; //unsigned int
+ size_t position = 0;
- unsigned int w, h;
- unsigned int type;
- unsigned int line_length;
- unsigned char *line = NULL;
- unsigned int cur = 0, x, y;
+ unsigned int w, h;
+ unsigned int type;
+ unsigned int line_length;
+ unsigned char* line = NULL;
+ unsigned int cur = 0, x, y;
- if( fseek(fp,0,SEEK_END) )
+ if(fseek(fp, 0, SEEK_END))
{
DALI_LOG_ERROR("Error seeking WBMP data\n");
return false;
}
long positionIndicator = ftell(fp);
- unsigned int fsize( 0u );
- if( positionIndicator > -1L )
+ unsigned int fsize(0u);
+ if(positionIndicator > -1L)
{
fsize = static_cast<unsigned int>(positionIndicator);
}
- if( 0u == fsize )
+ if(0u == fsize)
{
DALI_LOG_ERROR("Error: filesize is 0!\n");
return false;
}
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking WBMP data\n");
return false;
return false;
}
- if (extractMultiByteInteger(&type, &map[0], fsize, &position) < 0)
+ if(extractMultiByteInteger(&type, &map[0], fsize, &position) < 0)
{
return false;
}
position++; /* skipping one byte */
- if (extractMultiByteInteger(&w, &map[0], fsize, &position) < 0)
+ if(extractMultiByteInteger(&w, &map[0], fsize, &position) < 0)
{
return false;
}
- if (extractMultiByteInteger(&h, &map[0], fsize, &position) < 0)
+ if(extractMultiByteInteger(&h, &map[0], fsize, &position) < 0)
{
return false;
}
return false;
}
- if ((w < 1) || (h < 1) || (w > IMG_MAX_SIZE) || (h > IMG_MAX_SIZE))
+ if((w < 1) || (h < 1) || (w > IMG_MAX_SIZE) || (h > IMG_MAX_SIZE))
{
return false;
}
- surface.Resize(w* h );//(w * h * 4);
- memset(&surface[0], 0, w * h ); // w * h * 4
+ surface.Resize(w * h); //(w * h * 4);
+ memset(&surface[0], 0, w * h); // w * h * 4
line_length = (w + 7) >> 3;
- for (y = 0; y < h; y ++)
+ for(y = 0; y < h; y++)
{
- if (position + line_length > fsize)
+ if(position + line_length > fsize)
{
return false;
}
line = &map[0] + position;
position += line_length;
- for (x = 0; x < w; x++)
+ for(x = 0; x < w; x++)
{
- int idx = x >> 3;
+ int idx = x >> 3;
int offset = 1 << (0x07 - (x & 0x07));
- if (line[idx] & offset)
+ if(line[idx] & offset)
{
- surface[cur] = 0xff;//0xffffffff;
+ surface[cur] = 0xff; //0xffffffff;
}
else
{
- surface[cur] = 0x00;//0xff000000;
+ surface[cur] = 0x00; //0xff000000;
}
cur++;
}
}
auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(w, h, Pixel::L8)).GetBuffer();
- memcpy( pixels, &surface[0], w * h ); //w * h * 4
+ memcpy(pixels, &surface[0], w * h); //w * h * 4
return true;
}
-
-bool LoadWbmpHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height )
+bool LoadWbmpHeader(const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int& height)
{
FILE* const fp = input.file;
if(fp == NULL)
return false;
}
Dali::Vector<unsigned char> map;
- size_t position = 0;
+ size_t position = 0;
- unsigned int w, h;
+ unsigned int w, h;
unsigned int type;
- if( fseek(fp,0,SEEK_END) )
+ if(fseek(fp, 0, SEEK_END))
{
DALI_LOG_ERROR("Error seeking WBMP data\n");
return false;
}
long positionIndicator = ftell(fp);
- unsigned int fsize( 0u );
- if( positionIndicator > -1L )
+ unsigned int fsize(0u);
+ if(positionIndicator > -1L)
{
fsize = static_cast<unsigned int>(positionIndicator);
}
- if( 0u == fsize )
+ if(0u == fsize)
{
return false;
}
- if( fseek(fp, 0, SEEK_SET) )
+ if(fseek(fp, 0, SEEK_SET))
{
DALI_LOG_ERROR("Error seeking WBMP data\n");
return false;
}
// type(1 byte) + fixedheader(1 byte) + width(uint) + height(uint)
- unsigned int headerSize = 1 + 1 + 4 + 4;// 8 + 8 + 32 + 32;
- headerSize = std::min(headerSize, fsize);
+ unsigned int headerSize = 1 + 1 + 4 + 4; // 8 + 8 + 32 + 32;
+ headerSize = std::min(headerSize, fsize);
map.Resize(headerSize);
if(fread(&map[0], 1, headerSize, fp) != headerSize)
return false;
}
- if (extractMultiByteInteger(&type, &map[0], headerSize, &position) < 0)
+ if(extractMultiByteInteger(&type, &map[0], headerSize, &position) < 0)
{
DALI_LOG_ERROR("Error: unable to read type!\n");
return false;
DALI_LOG_ERROR("Error: unknown format!\n");
return false;
}
- if (extractMultiByteInteger(&w, &map[0], headerSize, &position) < 0)
+ if(extractMultiByteInteger(&w, &map[0], headerSize, &position) < 0)
{
DALI_LOG_ERROR("Error: can not read width!\n");
return false;
}
- if (extractMultiByteInteger(&h, &map[0], headerSize, &position) < 0)
+ if(extractMultiByteInteger(&h, &map[0], headerSize, &position) < 0)
{
DALI_LOG_ERROR("Error: can not read height!\n");
return false;
}
- if ((w < 1) || (h < 1) || (w > IMG_MAX_SIZE) || (h > IMG_MAX_SIZE) )
+ if((w < 1) || (h < 1) || (w > IMG_MAX_SIZE) || (h > IMG_MAX_SIZE))
{
DALI_LOG_ERROR("Error: file size is not supported!\n");
return false;
}
- width = w;
+ width = w;
height = h;
return true;
}
-}
-}
+} // namespace TizenPlatform
+} // namespace Dali
#include <dali/internal/imaging/common/native-bitmap-buffer-impl.h>
// EXTERNAL HEADERS
-#include <dali/integration-api/debug.h>
#include <dali/integration-api/bitmap.h>
+#include <dali/integration-api/debug.h>
// INTERNAL HEADERS
-#include <dali/internal/graphics/gles/gl-implementation.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/gles/gl-implementation.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-NativeBitmapBuffer::NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pFormat )
-: mGlAbstraction( nullptr),
+NativeBitmapBuffer::NativeBitmapBuffer(Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pFormat)
+: mGlAbstraction(nullptr),
mWidth(width),
mHeight(height),
mPixelFormat(pFormat),
mLastReadBuffer(NULL)
{
- DALI_ASSERT_ALWAYS( adaptor );
- mBuffer = new Integration::LocklessBuffer( width * height * Pixel::GetBytesPerPixel(pFormat) );
+ DALI_ASSERT_ALWAYS(adaptor);
+ mBuffer = new Integration::LocklessBuffer(width * height * Pixel::GetBytesPerPixel(pFormat));
- GraphicsInterface* graphics = &(adaptor->GetGraphicsInterface());
- auto eglGraphics = static_cast<EglGraphics *>(graphics);
- mGlAbstraction = &(eglGraphics->GetGlAbstraction());
+ GraphicsInterface* graphics = &(adaptor->GetGraphicsInterface());
+ auto eglGraphics = static_cast<EglGraphics*>(graphics);
+ mGlAbstraction = &(eglGraphics->GetGlAbstraction());
}
NativeBitmapBuffer::~NativeBitmapBuffer()
void NativeBitmapBuffer::PrepareTexture()
{
- DALI_ASSERT_ALWAYS( mBuffer );
- GLenum pixelFormat = GL_RGBA;
+ DALI_ASSERT_ALWAYS(mBuffer);
+ GLenum pixelFormat = GL_RGBA;
GLenum pixelDataType = GL_UNSIGNED_BYTE;
- Integration::ConvertToGlFormat( mPixelFormat, pixelDataType, pixelFormat );
+ Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
const unsigned char* buf = mBuffer->Read();
- if( buf && buf != mLastReadBuffer ) // Prevent same buffer being uploaded multiple times
+ if(buf && buf != mLastReadBuffer) // Prevent same buffer being uploaded multiple times
{
mLastReadBuffer = buf;
// The active texture has already been set to a sampler and bound.
- mGlAbstraction->TexImage2D( GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, buf );
+ mGlAbstraction->TexImage2D(GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, buf);
}
}
-void NativeBitmapBuffer::Write( const unsigned char *src, size_t size )
+void NativeBitmapBuffer::Write(const unsigned char* src, size_t size)
{
- mBuffer->Write( src, size ); // Write will cause LocklessBuffer to switch to the other buffer
+ mBuffer->Write(src, size); // Write will cause LocklessBuffer to switch to the other buffer
}
bool NativeBitmapBuffer::CreateResource()
bool NativeBitmapBuffer::RequiresBlending() const
{
- return Pixel::HasAlpha( mPixelFormat );
+ return Pixel::HasAlpha(mPixelFormat);
}
int NativeBitmapBuffer::GetTextureTarget() const
/*
- * Copyright (c) 2018 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.
#include <cstring>
// INTERNAL INCLUDES
-#include <dali/internal/imaging/common/pixel-manipulation.h>
#include <dali/internal/imaging/common/alpha-mask.h>
#include <dali/internal/imaging/common/gaussian-blur.h>
#include <dali/internal/imaging/common/image-operations.h>
+#include <dali/internal/imaging/common/pixel-manipulation.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
const float TWO_PI = 2.f * Math::PI; ///< 360 degrees in radians
} // namespace
-PixelBuffer::PixelBuffer( unsigned char* buffer,
- unsigned int bufferSize,
- unsigned int width,
- unsigned int height,
- Dali::Pixel::Format pixelFormat )
+PixelBuffer::PixelBuffer(unsigned char* buffer,
+ unsigned int bufferSize,
+ unsigned int width,
+ unsigned int height,
+ Dali::Pixel::Format pixelFormat)
: mMetadata(),
- mBuffer( buffer ),
- mBufferSize( bufferSize ),
- mWidth( width ),
- mHeight( height ),
- mPixelFormat( pixelFormat ),
- mPreMultiplied( false )
+ mBuffer(buffer),
+ mBufferSize(bufferSize),
+ mWidth(width),
+ mHeight(height),
+ mPixelFormat(pixelFormat),
+ mPreMultiplied(false)
{
}
ReleaseBuffer();
}
-PixelBufferPtr PixelBuffer::New( unsigned int width,
- unsigned int height,
- Dali::Pixel::Format pixelFormat )
+PixelBufferPtr PixelBuffer::New(unsigned int width,
+ unsigned int height,
+ Dali::Pixel::Format pixelFormat)
{
- unsigned int bufferSize = width * height * Dali::Pixel::GetBytesPerPixel( pixelFormat );
- unsigned char* buffer = NULL;
- if( bufferSize > 0 )
+ unsigned int bufferSize = width * height * Dali::Pixel::GetBytesPerPixel(pixelFormat);
+ unsigned char* buffer = NULL;
+ if(bufferSize > 0)
{
- buffer = static_cast<unsigned char*>( malloc ( bufferSize ) );
+ buffer = static_cast<unsigned char*>(malloc(bufferSize));
}
- return new PixelBuffer( buffer, bufferSize, width, height, pixelFormat );
+ return new PixelBuffer(buffer, bufferSize, width, height, pixelFormat);
}
-PixelBufferPtr PixelBuffer::New( unsigned char* buffer,
- unsigned int bufferSize,
- unsigned int width,
- unsigned int height,
- Dali::Pixel::Format pixelFormat )
+PixelBufferPtr PixelBuffer::New(unsigned char* buffer,
+ unsigned int bufferSize,
+ unsigned int width,
+ unsigned int height,
+ Dali::Pixel::Format pixelFormat)
{
- return new PixelBuffer( buffer, bufferSize, width, height, pixelFormat );
+ return new PixelBuffer(buffer, bufferSize, width, height, pixelFormat);
}
-Dali::PixelData PixelBuffer::Convert( PixelBuffer& pixelBuffer )
+Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer)
{
- Dali::PixelData pixelData = Dali::PixelData::New( pixelBuffer.mBuffer,
- pixelBuffer.mBufferSize,
- pixelBuffer.mWidth,
- pixelBuffer.mHeight,
- pixelBuffer.mPixelFormat,
- Dali::PixelData::FREE );
- pixelBuffer.mBuffer = NULL;
- pixelBuffer.mWidth = 0;
- pixelBuffer.mHeight = 0;
- pixelBuffer.mBufferSize = 0;
+ Dali::PixelData pixelData = Dali::PixelData::New(pixelBuffer.mBuffer,
+ pixelBuffer.mBufferSize,
+ pixelBuffer.mWidth,
+ pixelBuffer.mHeight,
+ pixelBuffer.mPixelFormat,
+ Dali::PixelData::FREE);
+ pixelBuffer.mBuffer = NULL;
+ pixelBuffer.mWidth = 0;
+ pixelBuffer.mHeight = 0;
+ pixelBuffer.mBufferSize = 0;
return pixelData;
}
{
unsigned char* destBuffer = NULL;
- if( mBufferSize > 0 )
+ if(mBufferSize > 0)
{
- destBuffer = static_cast<unsigned char*>( malloc( mBufferSize ) );
- memcpy( destBuffer, mBuffer, mBufferSize );
+ destBuffer = static_cast<unsigned char*>(malloc(mBufferSize));
+ memcpy(destBuffer, mBuffer, mBufferSize);
}
- Dali::PixelData pixelData = Dali::PixelData::New( destBuffer, mBufferSize,
- mWidth, mHeight,
- mPixelFormat,
- Dali::PixelData::FREE );
+ Dali::PixelData pixelData = Dali::PixelData::New(destBuffer, mBufferSize, mWidth, mHeight, mPixelFormat, Dali::PixelData::FREE);
return pixelData;
}
-void PixelBuffer::ApplyMask( const PixelBuffer& inMask, float contentScale, bool cropToMask )
+void PixelBuffer::ApplyMask(const PixelBuffer& inMask, float contentScale, bool cropToMask)
{
- if( cropToMask )
+ if(cropToMask)
{
// First scale this buffer by the contentScale, and crop to the mask size
// If it's too small, then scale the mask to match the image size
// Then apply the mask
- ScaleAndCrop( contentScale, ImageDimensions( inMask.GetWidth(), inMask.GetHeight() ) );
+ ScaleAndCrop(contentScale, ImageDimensions(inMask.GetWidth(), inMask.GetHeight()));
- if( inMask.mWidth > mWidth || inMask.mHeight > mHeight )
+ if(inMask.mWidth > mWidth || inMask.mHeight > mHeight)
{
- PixelBufferPtr mask = NewResize( inMask, ImageDimensions( mWidth, mHeight ) );
- ApplyMaskInternal( *mask );
+ PixelBufferPtr mask = NewResize(inMask, ImageDimensions(mWidth, mHeight));
+ ApplyMaskInternal(*mask);
}
else
{
- ApplyMaskInternal( inMask );
+ ApplyMaskInternal(inMask);
}
}
else
{
// First, scale the mask to match the image size,
// then apply the mask.
- PixelBufferPtr mask = NewResize( inMask, ImageDimensions( mWidth, mHeight ) );
- ApplyMaskInternal( *mask );
+ PixelBufferPtr mask = NewResize(inMask, ImageDimensions(mWidth, mHeight));
+ ApplyMaskInternal(*mask);
}
}
-void PixelBuffer::ApplyMaskInternal( const PixelBuffer& mask )
+void PixelBuffer::ApplyMaskInternal(const PixelBuffer& mask)
{
- int byteOffset=0;
- int bitMask=0;
+ int byteOffset = 0;
+ int bitMask = 0;
Dali::Pixel::GetAlphaOffsetAndMask(mPixelFormat, byteOffset, bitMask);
- if( Dali::Pixel::HasAlpha( mPixelFormat ) && bitMask == 255 )
+ if(Dali::Pixel::HasAlpha(mPixelFormat) && bitMask == 255)
{
- ApplyMaskToAlphaChannel( *this, mask );
+ ApplyMaskToAlphaChannel(*this, mask);
}
else
{
- PixelBufferPtr newPixelBuffer = CreateNewMaskedBuffer( *this, mask );
- TakeOwnershipOfBuffer( *newPixelBuffer );
+ PixelBufferPtr newPixelBuffer = CreateNewMaskedBuffer(*this, mask);
+ TakeOwnershipOfBuffer(*newPixelBuffer);
// On leaving scope, newPixelBuffer will get destroyed.
}
}
-void PixelBuffer::TakeOwnershipOfBuffer( PixelBuffer& pixelBuffer )
+void PixelBuffer::TakeOwnershipOfBuffer(PixelBuffer& pixelBuffer)
{
ReleaseBuffer();
// Take ownership of new buffer
- mBuffer = pixelBuffer.mBuffer;
+ mBuffer = pixelBuffer.mBuffer;
pixelBuffer.mBuffer = NULL;
- mBufferSize = pixelBuffer.mBufferSize;
- mWidth = pixelBuffer.mWidth;
- mHeight = pixelBuffer.mHeight;
- mPixelFormat = pixelBuffer.mPixelFormat;
+ mBufferSize = pixelBuffer.mBufferSize;
+ mWidth = pixelBuffer.mWidth;
+ mHeight = pixelBuffer.mHeight;
+ mPixelFormat = pixelBuffer.mPixelFormat;
}
void PixelBuffer::ReleaseBuffer()
{
- if( mBuffer )
+ if(mBuffer)
{
- free( mBuffer );
+ free(mBuffer);
}
}
-void PixelBuffer::AllocateFixedSize( uint32_t size )
+void PixelBuffer::AllocateFixedSize(uint32_t size)
{
ReleaseBuffer();
- mBuffer = reinterpret_cast<unsigned char*>(malloc( size ));
+ mBuffer = reinterpret_cast<unsigned char*>(malloc(size));
mBufferSize = size;
}
-bool PixelBuffer::Rotate( Degree angle )
+bool PixelBuffer::Rotate(Degree angle)
{
// Check first if Rotate() can perform the operation in the current pixel buffer.
bool validPixelFormat = false;
- switch( mPixelFormat )
+ switch(mPixelFormat)
{
case Pixel::A8:
case Pixel::L8:
}
}
- if( !validPixelFormat )
+ if(!validPixelFormat)
{
// Can't rotate the pixel buffer with the current pixel format.
- DALI_LOG_ERROR( "Can't rotate the pixel buffer with the current pixel format\n" );
+ DALI_LOG_ERROR("Can't rotate the pixel buffer with the current pixel format\n");
return false;
}
- float radians = Radian( angle ).radian;
+ float radians = Radian(angle).radian;
// Transform the input angle into the range [0..2PI]
- radians = fmod( radians, TWO_PI );
- radians += ( radians < 0.f ) ? TWO_PI : 0.f;
+ radians = fmod(radians, TWO_PI);
+ radians += (radians < 0.f) ? TWO_PI : 0.f;
- if( radians < Dali::Math::MACHINE_EPSILON_10 )
+ if(radians < Dali::Math::MACHINE_EPSILON_10)
{
// Nothing to do if the angle is zero.
return true;
}
- const unsigned int pixelSize = Pixel::GetBytesPerPixel( mPixelFormat );
+ const unsigned int pixelSize = Pixel::GetBytesPerPixel(mPixelFormat);
uint8_t* pixelsOut = nullptr;
- Platform::RotateByShear( mBuffer,
- mWidth,
- mHeight,
- pixelSize,
- radians,
- pixelsOut,
- mWidth,
- mHeight );
+ Platform::RotateByShear(mBuffer,
+ mWidth,
+ mHeight,
+ pixelSize,
+ radians,
+ pixelsOut,
+ mWidth,
+ mHeight);
// Check whether the rotation succedded and set the new pixel buffer data.
const bool success = nullptr != pixelsOut;
- if( success )
+ if(success)
{
// Release the memory of the current pixel buffer.
ReleaseBuffer();
// Set the new pixel buffer.
- mBuffer = pixelsOut;
- pixelsOut = nullptr;
+ mBuffer = pixelsOut;
+ pixelsOut = nullptr;
mBufferSize = mWidth * mHeight * pixelSize;
}
return success;
}
-void PixelBuffer::ScaleAndCrop( float scaleFactor, ImageDimensions cropDimensions )
+void PixelBuffer::ScaleAndCrop(float scaleFactor, ImageDimensions cropDimensions)
{
- ImageDimensions outDimensions( float(mWidth) * scaleFactor,
- float(mHeight) * scaleFactor );
+ ImageDimensions outDimensions(float(mWidth) * scaleFactor,
+ float(mHeight) * scaleFactor);
- if( outDimensions.GetWidth() != mWidth || outDimensions.GetHeight() != mHeight )
+ if(outDimensions.GetWidth() != mWidth || outDimensions.GetHeight() != mHeight)
{
- Resize( outDimensions );
+ Resize(outDimensions);
}
ImageDimensions postCropDimensions(
std::min(cropDimensions.GetWidth(), outDimensions.GetWidth()),
std::min(cropDimensions.GetHeight(), outDimensions.GetHeight()));
- if( postCropDimensions.GetWidth() < outDimensions.GetWidth() ||
- postCropDimensions.GetHeight() < outDimensions.GetHeight() )
+ if(postCropDimensions.GetWidth() < outDimensions.GetWidth() ||
+ postCropDimensions.GetHeight() < outDimensions.GetHeight())
{
- uint16_t x = ( outDimensions.GetWidth() - postCropDimensions.GetWidth() ) / 2;
- uint16_t y = ( outDimensions.GetHeight() - postCropDimensions.GetHeight() ) / 2;
- Crop( x, y, postCropDimensions );
+ uint16_t x = (outDimensions.GetWidth() - postCropDimensions.GetWidth()) / 2;
+ uint16_t y = (outDimensions.GetHeight() - postCropDimensions.GetHeight()) / 2;
+ Crop(x, y, postCropDimensions);
}
}
-void PixelBuffer::Crop( uint16_t x, uint16_t y, ImageDimensions cropDimensions )
+void PixelBuffer::Crop(uint16_t x, uint16_t y, ImageDimensions cropDimensions)
{
- PixelBufferPtr outBuffer = NewCrop( *this, x, y, cropDimensions );
- TakeOwnershipOfBuffer( *outBuffer );
+ PixelBufferPtr outBuffer = NewCrop(*this, x, y, cropDimensions);
+ TakeOwnershipOfBuffer(*outBuffer);
}
-PixelBufferPtr PixelBuffer::NewCrop( const PixelBuffer& inBuffer, uint16_t x, uint16_t y, ImageDimensions cropDimensions )
+PixelBufferPtr PixelBuffer::NewCrop(const PixelBuffer& inBuffer, uint16_t x, uint16_t y, ImageDimensions cropDimensions)
{
- PixelBufferPtr outBuffer = PixelBuffer::New( cropDimensions.GetWidth(), cropDimensions.GetHeight(), inBuffer.GetPixelFormat() );
- int bytesPerPixel = Pixel::GetBytesPerPixel( inBuffer.mPixelFormat );
- int srcStride = inBuffer.mWidth * bytesPerPixel;
- int destStride = cropDimensions.GetWidth() * bytesPerPixel;
+ PixelBufferPtr outBuffer = PixelBuffer::New(cropDimensions.GetWidth(), cropDimensions.GetHeight(), inBuffer.GetPixelFormat());
+ int bytesPerPixel = Pixel::GetBytesPerPixel(inBuffer.mPixelFormat);
+ int srcStride = inBuffer.mWidth * bytesPerPixel;
+ int destStride = cropDimensions.GetWidth() * bytesPerPixel;
// Clamp crop to right edge
- if( x + cropDimensions.GetWidth() > inBuffer.mWidth )
+ if(x + cropDimensions.GetWidth() > inBuffer.mWidth)
{
- destStride = ( inBuffer.mWidth - x ) * bytesPerPixel;
+ destStride = (inBuffer.mWidth - x) * bytesPerPixel;
}
- int srcOffset = x * bytesPerPixel + y * srcStride;
- int destOffset = 0;
+ int srcOffset = x * bytesPerPixel + y * srcStride;
+ int destOffset = 0;
unsigned char* destBuffer = outBuffer->mBuffer;
// Clamp crop to last row
unsigned int endRow = y + cropDimensions.GetHeight();
- if( endRow > inBuffer.mHeight )
+ if(endRow > inBuffer.mHeight)
{
- endRow = inBuffer.mHeight - 1 ;
+ endRow = inBuffer.mHeight - 1;
}
- for( uint16_t row = y; row < endRow; ++row )
+ for(uint16_t row = y; row < endRow; ++row)
{
- memcpy(destBuffer + destOffset, inBuffer.mBuffer + srcOffset, destStride );
+ memcpy(destBuffer + destOffset, inBuffer.mBuffer + srcOffset, destStride);
srcOffset += srcStride;
destOffset += destStride;
}
return outBuffer;
-
}
-void PixelBuffer::SetMetadata( const Property::Map& map )
+void PixelBuffer::SetMetadata(const Property::Map& map)
{
mMetadata.reset(new Property::Map(map));
}
bool PixelBuffer::GetMetadata(Property::Map& outMetadata) const
{
- if( !mMetadata )
+ if(!mMetadata)
{
return false;
}
mMetadata = std::move(metadata);
}
-void PixelBuffer::Resize( ImageDimensions outDimensions )
+void PixelBuffer::Resize(ImageDimensions outDimensions)
{
- if( mWidth != outDimensions.GetWidth() || mHeight != outDimensions.GetHeight() )
+ if(mWidth != outDimensions.GetWidth() || mHeight != outDimensions.GetHeight())
{
- PixelBufferPtr outBuffer = NewResize( *this, outDimensions );
- TakeOwnershipOfBuffer( *outBuffer );
+ PixelBufferPtr outBuffer = NewResize(*this, outDimensions);
+ TakeOwnershipOfBuffer(*outBuffer);
}
}
-PixelBufferPtr PixelBuffer::NewResize( const PixelBuffer& inBuffer, ImageDimensions outDimensions )
+PixelBufferPtr PixelBuffer::NewResize(const PixelBuffer& inBuffer, ImageDimensions outDimensions)
{
- PixelBufferPtr outBuffer = PixelBuffer::New( outDimensions.GetWidth(), outDimensions.GetHeight(), inBuffer.GetPixelFormat() );
- ImageDimensions inDimensions( inBuffer.mWidth, inBuffer.mHeight );
+ PixelBufferPtr outBuffer = PixelBuffer::New(outDimensions.GetWidth(), outDimensions.GetHeight(), inBuffer.GetPixelFormat());
+ ImageDimensions inDimensions(inBuffer.mWidth, inBuffer.mHeight);
- bool hasAlpha = Pixel::HasAlpha( inBuffer.mPixelFormat );
- int bytesPerPixel = Pixel::GetBytesPerPixel( inBuffer.mPixelFormat );
+ bool hasAlpha = Pixel::HasAlpha(inBuffer.mPixelFormat);
+ int bytesPerPixel = Pixel::GetBytesPerPixel(inBuffer.mPixelFormat);
Resampler::Filter filterType = Resampler::LANCZOS4;
- if( inDimensions.GetWidth() < outDimensions.GetWidth() && inDimensions.GetHeight() < outDimensions.GetHeight() )
+ if(inDimensions.GetWidth() < outDimensions.GetWidth() && inDimensions.GetHeight() < outDimensions.GetHeight())
{
filterType = Resampler::MITCHELL;
}
// This method only really works for 8 bit wide channels.
// (But could be expanded to work)
- if( inBuffer.mPixelFormat == Pixel::A8 ||
- inBuffer.mPixelFormat == Pixel::L8 ||
- inBuffer.mPixelFormat == Pixel::LA88 ||
- inBuffer.mPixelFormat == Pixel::RGB888 ||
- inBuffer.mPixelFormat == Pixel::RGB8888 ||
- inBuffer.mPixelFormat == Pixel::BGR8888 ||
- inBuffer.mPixelFormat == Pixel::RGBA8888 ||
- inBuffer.mPixelFormat == Pixel::BGRA8888 )
+ if(inBuffer.mPixelFormat == Pixel::A8 ||
+ inBuffer.mPixelFormat == Pixel::L8 ||
+ inBuffer.mPixelFormat == Pixel::LA88 ||
+ inBuffer.mPixelFormat == Pixel::RGB888 ||
+ inBuffer.mPixelFormat == Pixel::RGB8888 ||
+ inBuffer.mPixelFormat == Pixel::BGR8888 ||
+ inBuffer.mPixelFormat == Pixel::RGBA8888 ||
+ inBuffer.mPixelFormat == Pixel::BGRA8888)
{
- Dali::Internal::Platform::Resample( inBuffer.mBuffer, inDimensions,
- outBuffer->GetBuffer(), outDimensions,
- filterType, bytesPerPixel, hasAlpha );
+ Dali::Internal::Platform::Resample(inBuffer.mBuffer, inDimensions, outBuffer->GetBuffer(), outDimensions, filterType, bytesPerPixel, hasAlpha);
}
else
{
- DALI_LOG_ERROR( "Trying to resize an image with too narrow a channel width" );
+ DALI_LOG_ERROR("Trying to resize an image with too narrow a channel width");
}
return outBuffer;
}
-void PixelBuffer::ApplyGaussianBlur( const float blurRadius )
+void PixelBuffer::ApplyGaussianBlur(const float blurRadius)
{
// This method only works for pixel buffer in RGBA format.
- if( mWidth > 0 && mHeight > 0 && mPixelFormat == Pixel::RGBA8888 )
+ if(mWidth > 0 && mHeight > 0 && mPixelFormat == Pixel::RGBA8888)
{
- if ( blurRadius > Math::MACHINE_EPSILON_1 )
+ if(blurRadius > Math::MACHINE_EPSILON_1)
{
- PerformGaussianBlurRGBA( *this, blurRadius );
+ PerformGaussianBlurRGBA(*this, blurRadius);
}
}
else
{
- DALI_LOG_ERROR( "Trying to apply gaussian blur to an empty pixel buffer or a pixel buffer not in RGBA format" );
+ DALI_LOG_ERROR("Trying to apply gaussian blur to an empty pixel buffer or a pixel buffer not in RGBA format");
}
}
void PixelBuffer::MultiplyColorByAlpha()
{
- auto bytesPerPixel = Pixel::GetBytesPerPixel( mPixelFormat );
+ auto bytesPerPixel = Pixel::GetBytesPerPixel(mPixelFormat);
// Compressed textures have unknown size of the pixel. Alpha premultiplication
// must be skipped in such case
- if( Pixel::GetBytesPerPixel(mPixelFormat) && Pixel::HasAlpha(mPixelFormat) )
+ if(Pixel::GetBytesPerPixel(mPixelFormat) && Pixel::HasAlpha(mPixelFormat))
{
- unsigned char* pixel = mBuffer;
+ unsigned char* pixel = mBuffer;
const unsigned int bufferSize = mWidth * mHeight;
- for( unsigned int i=0; i<bufferSize; ++i )
+ for(unsigned int i = 0; i < bufferSize; ++i)
{
- unsigned int alpha = ReadChannel( pixel, mPixelFormat, Adaptor::ALPHA );
+ unsigned int alpha = ReadChannel(pixel, mPixelFormat, Adaptor::ALPHA);
{
- auto red = ReadChannel( pixel, mPixelFormat, Adaptor::RED);
- auto green = ReadChannel( pixel, mPixelFormat, Adaptor::GREEN);
- auto blue = ReadChannel( pixel, mPixelFormat, Adaptor::BLUE);
- auto luminance = ReadChannel( pixel, mPixelFormat, Adaptor::LUMINANCE);
- WriteChannel( pixel, mPixelFormat, Adaptor::RED, red*alpha / 255 );
- WriteChannel( pixel, mPixelFormat, Adaptor::GREEN, green*alpha/255 );
- WriteChannel( pixel, mPixelFormat, Adaptor::BLUE, blue*alpha/255 );
- WriteChannel( pixel, mPixelFormat, Adaptor::LUMINANCE, luminance*alpha/255 );
+ auto red = ReadChannel(pixel, mPixelFormat, Adaptor::RED);
+ auto green = ReadChannel(pixel, mPixelFormat, Adaptor::GREEN);
+ auto blue = ReadChannel(pixel, mPixelFormat, Adaptor::BLUE);
+ auto luminance = ReadChannel(pixel, mPixelFormat, Adaptor::LUMINANCE);
+ WriteChannel(pixel, mPixelFormat, Adaptor::RED, red * alpha / 255);
+ WriteChannel(pixel, mPixelFormat, Adaptor::GREEN, green * alpha / 255);
+ WriteChannel(pixel, mPixelFormat, Adaptor::BLUE, blue * alpha / 255);
+ WriteChannel(pixel, mPixelFormat, Adaptor::LUMINANCE, luminance * alpha / 255);
}
pixel += bytesPerPixel;
}
return mPreMultiplied;
}
-}// namespace Adaptor
-}// namespace Internal
-}// namespace Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/imaging/common/pixel-manipulation.h>
// INTERNAL HEADERS
-#include <dali/public-api/images/pixel.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/images/pixel.h>
namespace Dali
{
{
namespace Adaptor
{
-
namespace
{
-
constexpr Channel ALPHA_CHANNEL_ONLY[] = {ALPHA};
constexpr Channel LUMINANCE_CHANNEL_ONLY[] = {LUMINANCE};
constexpr Channel LUMINANCE_ALPHA_CHANNELS[] = {LUMINANCE, ALPHA};
template<size_t NumberOfChannels>
unsigned int ReadChannel(unsigned char* pixelData, Channel channel, const Channel (&channels)[NumberOfChannels])
{
- auto num = 0u;
+ auto num = 0u;
auto retVal = 0u;
for(auto current : channels)
{
- if( channel == current )
+ if(channel == current)
{
retVal = static_cast<unsigned int>(*(pixelData + num));
break;
void WriteChannel(unsigned char* pixelData, Channel channel, unsigned int channelValue, const Channel (&channels)[NumberOfChannels])
{
auto num = 0u;
- for( auto current : channels )
+ for(auto current : channels)
{
- if( channel == current )
+ if(channel == current)
{
- *(pixelData + num) = static_cast<unsigned char>( channelValue & 0xFF );
+ *(pixelData + num) = static_cast<unsigned char>(channelValue & 0xFF);
break;
}
++num;
*/
unsigned int ReadChannel565(unsigned char* pixelData, Channel channel, Channel one, Channel two, Channel three)
{
- if( channel == one )
+ if(channel == one)
{
return (static_cast<unsigned int>(*pixelData) & 0xF8) >> 3;
}
- else if( channel == two )
+ else if(channel == two)
{
return ((static_cast<unsigned int>(*pixelData) & 0x07) << 3) |
- ((static_cast<unsigned int>(*(pixelData+1)) & 0xE0) >> 5);
+ ((static_cast<unsigned int>(*(pixelData + 1)) & 0xE0) >> 5);
}
- else if( channel == three )
+ else if(channel == three)
{
- return static_cast<unsigned int>(*(pixelData+1)) & 0x1F;
+ return static_cast<unsigned int>(*(pixelData + 1)) & 0x1F;
}
return 0u;
}
*/
void WriteChannel565(unsigned char* pixelData, Channel channel, unsigned int channelValue, Channel one, Channel two, Channel three)
{
- if( channel == one )
+ if(channel == one)
{
- *pixelData &= static_cast<unsigned char>( ~0xF8 );
- *pixelData |= static_cast<unsigned char>( (channelValue << 3) & 0xF8 );
+ *pixelData &= static_cast<unsigned char>(~0xF8);
+ *pixelData |= static_cast<unsigned char>((channelValue << 3) & 0xF8);
}
- else if( channel == two )
+ else if(channel == two)
{
- *pixelData &= static_cast<unsigned char>( ~0x07 );
- *pixelData |= static_cast<unsigned char>( (channelValue >> 3) & 0x07 );
+ *pixelData &= static_cast<unsigned char>(~0x07);
+ *pixelData |= static_cast<unsigned char>((channelValue >> 3) & 0x07);
- *(pixelData+1) &= static_cast<unsigned char>( ~0xE0 );
- *(pixelData+1) |= static_cast<unsigned char>( (channelValue << 5) & 0xE0 );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0xE0);
+ *(pixelData + 1) |= static_cast<unsigned char>((channelValue << 5) & 0xE0);
}
- else if( channel == three )
+ else if(channel == three)
{
- *(pixelData+1) &= static_cast<unsigned char>( ~0x1F );
- *(pixelData+1) |= static_cast<unsigned char>( channelValue & 0x1F );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0x1F);
+ *(pixelData + 1) |= static_cast<unsigned char>(channelValue & 0x1F);
}
}
*/
unsigned int ReadChannel4444(unsigned char* pixelData, Channel channel, Channel one, Channel two, Channel three, Channel four)
{
- if( channel == one )
+ if(channel == one)
{
return (static_cast<unsigned int>(*pixelData) & 0xF0) >> 4;
}
- else if( channel == two )
+ else if(channel == two)
{
return (static_cast<unsigned int>(*pixelData) & 0x0F);
}
- else if( channel == three )
+ else if(channel == three)
{
- return (static_cast<unsigned int>(*(pixelData+1)) & 0xF0) >> 4;
+ return (static_cast<unsigned int>(*(pixelData + 1)) & 0xF0) >> 4;
}
- else if( channel == four )
+ else if(channel == four)
{
- return (static_cast<unsigned int>(*(pixelData+1)) & 0x0F);
+ return (static_cast<unsigned int>(*(pixelData + 1)) & 0x0F);
}
return 0u;
}
*/
void WriteChannel4444(unsigned char* pixelData, Channel channel, unsigned int channelValue, Channel one, Channel two, Channel three, Channel four)
{
- if( channel == one )
+ if(channel == one)
{
- *pixelData &= static_cast<unsigned char>( ~0xF0 );
- *pixelData |= static_cast<unsigned char>( (channelValue << 4) & 0xF0 );
+ *pixelData &= static_cast<unsigned char>(~0xF0);
+ *pixelData |= static_cast<unsigned char>((channelValue << 4) & 0xF0);
}
- else if( channel == two )
+ else if(channel == two)
{
- *pixelData &= static_cast<unsigned char>( ~0x0F );
- *pixelData |= static_cast<unsigned char>( channelValue & 0x0F );
+ *pixelData &= static_cast<unsigned char>(~0x0F);
+ *pixelData |= static_cast<unsigned char>(channelValue & 0x0F);
}
- else if( channel == three )
+ else if(channel == three)
{
- *(pixelData+1) &= static_cast<unsigned char>( ~0xF0 );
- *(pixelData+1) |= static_cast<unsigned char>( (channelValue << 4) & 0xF0 );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0xF0);
+ *(pixelData + 1) |= static_cast<unsigned char>((channelValue << 4) & 0xF0);
}
- else if( channel == four )
+ else if(channel == four)
{
- *(pixelData+1) &= static_cast<unsigned char>( ~0x0F );
- *(pixelData+1) |= static_cast<unsigned char>( channelValue & 0x0F );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0x0F);
+ *(pixelData + 1) |= static_cast<unsigned char>(channelValue & 0x0F);
}
}
*/
unsigned int ReadChannel5551(unsigned char* pixelData, Channel channel, Channel one, Channel two, Channel three, Channel four)
{
- if( channel == one )
+ if(channel == one)
{
return (static_cast<unsigned int>(*pixelData) & 0xF8) >> 3;
}
- else if( channel == two )
+ else if(channel == two)
{
return ((static_cast<unsigned int>(*pixelData) & 0x07) << 2) |
- ((static_cast<unsigned int>(*(pixelData+1)) & 0xC0) >> 6);
+ ((static_cast<unsigned int>(*(pixelData + 1)) & 0xC0) >> 6);
}
- else if( channel == three )
+ else if(channel == three)
{
- return (static_cast<unsigned int>(*(pixelData+1)) & 0x3E) >> 1;
+ return (static_cast<unsigned int>(*(pixelData + 1)) & 0x3E) >> 1;
}
- else if( channel == four )
+ else if(channel == four)
{
- return static_cast<unsigned int>(*(pixelData+1)) & 0x01;
+ return static_cast<unsigned int>(*(pixelData + 1)) & 0x01;
}
return 0u;
}
{
// 11111222 22333334
// F8 7 C0 3E 1
- if( channel == one )
+ if(channel == one)
{
- *pixelData &= static_cast<unsigned char>( ~0xF8 );
- *pixelData |= static_cast<unsigned char>( (channelValue << 3) & 0xF8 );
+ *pixelData &= static_cast<unsigned char>(~0xF8);
+ *pixelData |= static_cast<unsigned char>((channelValue << 3) & 0xF8);
}
- else if( channel == two )
+ else if(channel == two)
{
- *pixelData &= static_cast<unsigned char>( ~0x07 );
- *pixelData |= static_cast<unsigned char>( (channelValue >> 2) & 0x07 );
+ *pixelData &= static_cast<unsigned char>(~0x07);
+ *pixelData |= static_cast<unsigned char>((channelValue >> 2) & 0x07);
- *(pixelData+1) &= static_cast<unsigned char>( ~0xC0 );
- *(pixelData+1) |= static_cast<unsigned char>( (channelValue << 6) & 0xC0 );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0xC0);
+ *(pixelData + 1) |= static_cast<unsigned char>((channelValue << 6) & 0xC0);
}
- else if( channel == three )
+ else if(channel == three)
{
- *(pixelData+1) &= static_cast<unsigned char>( ~0x3E );
- *(pixelData+1) |= static_cast<unsigned char>( (channelValue << 1) & 0x3E );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0x3E);
+ *(pixelData + 1) |= static_cast<unsigned char>((channelValue << 1) & 0x3E);
}
- else if( channel == four )
+ else if(channel == four)
{
- *(pixelData+1) &= static_cast<unsigned char>( ~0x01 );
- *(pixelData+1) |= static_cast<unsigned char>( channelValue & 0x01 );
+ *(pixelData + 1) &= static_cast<unsigned char>(~0x01);
+ *(pixelData + 1) |= static_cast<unsigned char>(channelValue & 0x01);
}
}
{
unsigned int bitShift;
unsigned int bitMask;
- bool available;
+ bool available;
};
struct Locations
Location blue;
};
-
-bool HasChannel( Dali::Pixel::Format pixelFormat, Channel channel )
+bool HasChannel(Dali::Pixel::Format pixelFormat, Channel channel)
{
- switch (pixelFormat)
+ switch(pixelFormat)
{
case Dali::Pixel::A8:
{
}
case Dali::Pixel::LA88:
{
- return ( channel == LUMINANCE || channel == ALPHA );
+ return (channel == LUMINANCE || channel == ALPHA);
}
case Dali::Pixel::RGB565:
case Dali::Pixel::BGR565:
case Dali::Pixel::RGB16F:
case Dali::Pixel::RGB32F:
{
- return ( channel == RED || channel == GREEN || channel == BLUE );
+ return (channel == RED || channel == GREEN || channel == BLUE);
}
case Dali::Pixel::RGBA8888:
case Dali::Pixel::RGBA5551:
case Dali::Pixel::BGRA5551:
{
- return ( channel == RED || channel == GREEN || channel == BLUE || channel == ALPHA );
+ return (channel == RED || channel == GREEN || channel == BLUE || channel == ALPHA);
}
case Dali::Pixel::DEPTH_UNSIGNED_INT:
case Dali::Pixel::DEPTH_FLOAT:
{
- return ( channel == DEPTH );
+ return (channel == DEPTH);
}
case Dali::Pixel::DEPTH_STENCIL:
{
- return ( channel == DEPTH || channel == STENCIL );
+ return (channel == DEPTH || channel == STENCIL);
}
case Dali::Pixel::INVALID:
return false;
}
-unsigned int ReadChannel( unsigned char* pixelData,
- Dali::Pixel::Format pixelFormat,
- Channel channel )
+unsigned int ReadChannel(unsigned char* pixelData,
+ Dali::Pixel::Format pixelFormat,
+ Channel channel)
{
- switch (pixelFormat)
+ switch(pixelFormat)
{
case Dali::Pixel::A8:
{
}
}
-void WriteChannel( unsigned char* pixelData,
- Dali::Pixel::Format pixelFormat,
- Channel channel,
- unsigned int channelValue )
+void WriteChannel(unsigned char* pixelData,
+ Dali::Pixel::Format pixelFormat,
+ Channel channel,
+ unsigned int channelValue)
{
- switch (pixelFormat)
+ switch(pixelFormat)
{
case Dali::Pixel::A8:
{
}
void ConvertColorChannelsToRGBA8888(
- unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat,
- unsigned char* destPixel, int destOffset )
+ unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat, unsigned char* destPixel, int destOffset)
{
- int red = ReadChannel(srcPixel+srcOffset, srcFormat, RED );
- int green = ReadChannel(srcPixel+srcOffset, srcFormat, GREEN );
- int blue = ReadChannel(srcPixel+srcOffset, srcFormat, BLUE );
- switch( srcFormat )
+ int red = ReadChannel(srcPixel + srcOffset, srcFormat, RED);
+ int green = ReadChannel(srcPixel + srcOffset, srcFormat, GREEN);
+ int blue = ReadChannel(srcPixel + srcOffset, srcFormat, BLUE);
+ switch(srcFormat)
{
case Dali::Pixel::RGB565:
case Dali::Pixel::BGR565:
{
- red = (red<<3) | (red & 0x07);
+ red = (red << 3) | (red & 0x07);
green = (green << 2) | (green & 0x03);
- blue = (blue<<3) | (blue & 0x07);
+ blue = (blue << 3) | (blue & 0x07);
break;
}
case Dali::Pixel::RGBA4444:
case Dali::Pixel::BGRA4444:
{
- red = (red<<4) | (red&0x0F);
- green = (green<<4) | (green&0x0F);
- blue = (blue<<4) | (blue&0x0F);
+ red = (red << 4) | (red & 0x0F);
+ green = (green << 4) | (green & 0x0F);
+ blue = (blue << 4) | (blue & 0x0F);
break;
}
case Dali::Pixel::RGBA5551:
case Dali::Pixel::BGRA5551:
{
- red = (red<<3) | (red&0x07);
- green = (green<<3) | (green&0x07);
- blue = (blue<<3) | (blue&0x07);
+ red = (red << 3) | (red & 0x07);
+ green = (green << 3) | (green & 0x07);
+ blue = (blue << 3) | (blue & 0x07);
break;
}
default:
break;
}
- WriteChannel(destPixel+destOffset, Dali::Pixel::RGBA8888, RED, red);
- WriteChannel(destPixel+destOffset, Dali::Pixel::RGBA8888, GREEN, green);
- WriteChannel(destPixel+destOffset, Dali::Pixel::RGBA8888, BLUE, blue);
+ WriteChannel(destPixel + destOffset, Dali::Pixel::RGBA8888, RED, red);
+ WriteChannel(destPixel + destOffset, Dali::Pixel::RGBA8888, GREEN, green);
+ WriteChannel(destPixel + destOffset, Dali::Pixel::RGBA8888, BLUE, blue);
}
-
-int ConvertAlphaChannelToA8( unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat )
+int ConvertAlphaChannelToA8(unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat)
{
- int alpha = ReadChannel(srcPixel+srcOffset, srcFormat, ALPHA );
+ int alpha = ReadChannel(srcPixel + srcOffset, srcFormat, ALPHA);
int destAlpha = alpha;
- switch( srcFormat )
+ switch(srcFormat)
{
case Pixel::RGBA5551:
case Pixel::BGRA5551:
{
- destAlpha = (alpha==0)?0:255;
+ destAlpha = (alpha == 0) ? 0 : 255;
break;
}
case Pixel::RGBA4444:
case Pixel::BGRA4444:
{
- destAlpha = (alpha<<4) | (alpha&0x0F);
+ destAlpha = (alpha << 4) | (alpha & 0x0F);
break;
}
default:
return destAlpha;
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/integration-api/debug.h>
#include <dali/public-api/images/pixel-data.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <dali/internal/imaging/common/file-download.h>
+#include <dali/internal/system/common/file-reader.h>
#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <cstring>
-#include <dali/internal/imaging/common/file-download.h>
-#include <dali/internal/system/common/file-reader.h>
typedef unsigned char WebPByteType;
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter *gWebPLoadingLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_GIF_LOADING" );
+Debug::Filter* gWebPLoadingLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_GIF_LOADING");
#endif
-constexpr size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024;
+constexpr size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024;
-}
+} // namespace
struct WebPLoading::Impl
{
public:
- Impl( const std::string& url, bool isLocalResource )
- : mUrl( url )
+ Impl(const std::string& url, bool isLocalResource)
+ : mUrl(url)
{
#ifdef DALI_WEBP_ENABLED
- if( ReadWebPInformation( isLocalResource ) )
+ if(ReadWebPInformation(isLocalResource))
{
WebPAnimDecoderOptions webPAnimDecoderOptions;
- WebPAnimDecoderOptionsInit( &webPAnimDecoderOptions );
+ WebPAnimDecoderOptionsInit(&webPAnimDecoderOptions);
webPAnimDecoderOptions.color_mode = MODE_RGBA;
- mWebPAnimDecoder = WebPAnimDecoderNew( &mWebPData, &webPAnimDecoderOptions );
- WebPAnimDecoderGetInfo( mWebPAnimDecoder, &mWebPAnimInfo );
- mTimeStamp.assign( mWebPAnimInfo.frame_count, 0 );
+ mWebPAnimDecoder = WebPAnimDecoderNew(&mWebPData, &webPAnimDecoderOptions);
+ WebPAnimDecoderGetInfo(mWebPAnimDecoder, &mWebPAnimInfo);
+ mTimeStamp.assign(mWebPAnimInfo.frame_count, 0);
}
#endif
}
- bool ReadWebPInformation( bool isLocalResource )
+ bool ReadWebPInformation(bool isLocalResource)
{
#ifdef DALI_WEBP_ENABLED
- WebPDataInit( &mWebPData );
- if( isLocalResource )
+ WebPDataInit(&mWebPData);
+ if(isLocalResource)
{
- Internal::Platform::FileReader fileReader( mUrl );
- FILE *fp = fileReader.GetFile();
- if( fp == NULL )
+ Internal::Platform::FileReader fileReader(mUrl);
+ FILE* fp = fileReader.GetFile();
+ if(fp == NULL)
{
return false;
}
- if( fseek( fp, 0, SEEK_END ) <= -1 )
+ if(fseek(fp, 0, SEEK_END) <= -1)
{
return false;
}
- mWebPData.size = ftell( fp );
- if( ( ! fseek( fp, 0, SEEK_SET ) ) )
+ mWebPData.size = ftell(fp);
+ if((!fseek(fp, 0, SEEK_SET)))
{
- unsigned char *WebPDataBuffer;
- WebPDataBuffer = reinterpret_cast<WebPByteType*>( malloc(sizeof( WebPByteType ) * mWebPData.size ) );
- mWebPData.size = fread( WebPDataBuffer, sizeof( WebPByteType ), mWebPData.size, fp );
+ unsigned char* WebPDataBuffer;
+ WebPDataBuffer = reinterpret_cast<WebPByteType*>(malloc(sizeof(WebPByteType) * mWebPData.size));
+ mWebPData.size = fread(WebPDataBuffer, sizeof(WebPByteType), mWebPData.size, fp);
mWebPData.bytes = WebPDataBuffer;
}
else
else
{
// remote file
- bool succeeded;
+ bool succeeded;
Dali::Vector<uint8_t> dataBuffer;
- size_t dataSize;
+ size_t dataSize;
- succeeded = TizenPlatform::Network::DownloadRemoteFileIntoMemory( mUrl, dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE );
- if( succeeded )
+ succeeded = TizenPlatform::Network::DownloadRemoteFileIntoMemory(mUrl, dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE);
+ if(succeeded)
{
size_t blobSize = dataBuffer.Size();
- if( blobSize > 0U )
+ if(blobSize > 0U)
{
// Open a file handle on the memory buffer:
- Dali::Internal::Platform::FileReader fileReader( dataBuffer, blobSize );
- FILE * const fp = fileReader.GetFile();
- if ( NULL != fp )
+ Dali::Internal::Platform::FileReader fileReader(dataBuffer, blobSize);
+ FILE* const fp = fileReader.GetFile();
+ if(NULL != fp)
{
- if( ( ! fseek( fp, 0, SEEK_SET ) ) )
+ if((!fseek(fp, 0, SEEK_SET)))
{
- unsigned char *WebPDataBuffer;
- WebPDataBuffer = reinterpret_cast<WebPByteType*>( malloc(sizeof( WebPByteType ) * blobSize ) );
- mWebPData.size = fread( WebPDataBuffer, sizeof( WebPByteType ), mWebPData.size, fp );
+ unsigned char* WebPDataBuffer;
+ WebPDataBuffer = reinterpret_cast<WebPByteType*>(malloc(sizeof(WebPByteType) * blobSize));
+ mWebPData.size = fread(WebPDataBuffer, sizeof(WebPByteType), mWebPData.size, fp);
mWebPData.bytes = WebPDataBuffer;
}
else
{
- DALI_LOG_ERROR( "Error seeking within file\n" );
+ DALI_LOG_ERROR("Error seeking within file\n");
}
}
else
{
- DALI_LOG_ERROR( "Error reading file\n" );
+ DALI_LOG_ERROR("Error reading file\n");
}
}
}
// Moveable but not copyable
- Impl( const Impl& ) = delete;
- Impl& operator=( const Impl& ) = delete;
- Impl( Impl&& ) = default;
- Impl& operator=( Impl&& ) = default;
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+ Impl(Impl&&) = default;
+ Impl& operator=(Impl&&) = default;
~Impl()
{
#ifdef DALI_WEBP_ENABLED
- if( &mWebPData != NULL )
+ if(&mWebPData != NULL)
{
- free( (void*)mWebPData.bytes );
+ free((void*)mWebPData.bytes);
mWebPData.bytes = nullptr;
- WebPDataInit( &mWebPData );
+ WebPDataInit(&mWebPData);
}
- if( mWebPAnimDecoder )
+ if(mWebPAnimDecoder)
{
WebPAnimDecoderDelete(mWebPAnimDecoder);
}
#endif
}
- std::string mUrl;
+ std::string mUrl;
std::vector<uint32_t> mTimeStamp;
- uint32_t mLoadingFrame{0};
+ uint32_t mLoadingFrame{0};
#ifdef DALI_WEBP_ENABLED
- WebPData mWebPData{0};
+ WebPData mWebPData{0};
WebPAnimDecoder* mWebPAnimDecoder{nullptr};
- WebPAnimInfo mWebPAnimInfo{0};
+ WebPAnimInfo mWebPAnimInfo{0};
#endif
};
-AnimatedImageLoadingPtr WebPLoading::New( const std::string &url, bool isLocalResource )
+AnimatedImageLoadingPtr WebPLoading::New(const std::string& url, bool isLocalResource)
{
#ifndef DALI_WEBP_ENABLED
- DALI_LOG_ERROR( "The system does not support Animated WebP format.\n" );
+ DALI_LOG_ERROR("The system does not support Animated WebP format.\n");
#endif
- return AnimatedImageLoadingPtr( new WebPLoading( url, isLocalResource ) );
+ return AnimatedImageLoadingPtr(new WebPLoading(url, isLocalResource));
}
-WebPLoading::WebPLoading( const std::string &url, bool isLocalResource )
-: mImpl( new WebPLoading::Impl( url, isLocalResource ) )
+WebPLoading::WebPLoading(const std::string& url, bool isLocalResource)
+: mImpl(new WebPLoading::Impl(url, isLocalResource))
{
}
delete mImpl;
}
-bool WebPLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData> &pixelData )
+bool WebPLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData)
{
#ifdef DALI_WEBP_ENABLED
- if( frameStartIndex >= mImpl->mWebPAnimInfo.frame_count )
+ if(frameStartIndex >= mImpl->mWebPAnimInfo.frame_count)
{
return false;
}
- DALI_LOG_INFO( gWebPLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameStartIndex:%d, count:%d )\n", frameStartIndex, count );
+ DALI_LOG_INFO(gWebPLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameStartIndex:%d, count:%d )\n", frameStartIndex, count);
- if( mImpl->mLoadingFrame > frameStartIndex )
+ if(mImpl->mLoadingFrame > frameStartIndex)
{
mImpl->mLoadingFrame = 0;
- WebPAnimDecoderReset( mImpl->mWebPAnimDecoder );
+ WebPAnimDecoderReset(mImpl->mWebPAnimDecoder);
}
- for( ; mImpl->mLoadingFrame < frameStartIndex ; ++mImpl->mLoadingFrame )
+ for(; mImpl->mLoadingFrame < frameStartIndex; ++mImpl->mLoadingFrame)
{
uint8_t* frameBuffer;
- int timestamp;
- WebPAnimDecoderGetNext( mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp );
+ int timestamp;
+ WebPAnimDecoderGetNext(mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp);
mImpl->mTimeStamp[mImpl->mLoadingFrame] = timestamp;
}
- for( int i = 0; i < count; ++i )
+ for(int i = 0; i < count; ++i)
{
- const int bufferSize = mImpl->mWebPAnimInfo.canvas_width * mImpl->mWebPAnimInfo.canvas_height * sizeof( uint32_t );
- uint8_t* frameBuffer;
- int timestamp;
- WebPAnimDecoderGetNext( mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp );
+ const int bufferSize = mImpl->mWebPAnimInfo.canvas_width * mImpl->mWebPAnimInfo.canvas_height * sizeof(uint32_t);
+ uint8_t* frameBuffer;
+ int timestamp;
+ WebPAnimDecoderGetNext(mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp);
- auto pixelBuffer = new uint8_t[ bufferSize ];
- memcpy( pixelBuffer, frameBuffer, bufferSize );
+ auto pixelBuffer = new uint8_t[bufferSize];
+ memcpy(pixelBuffer, frameBuffer, bufferSize);
mImpl->mTimeStamp[mImpl->mLoadingFrame] = timestamp;
- if( pixelBuffer )
+ if(pixelBuffer)
{
- pixelData.push_back( Dali::PixelData::New( pixelBuffer, bufferSize,
- mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height,
- Dali::Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY) );
+ pixelData.push_back(Dali::PixelData::New(pixelBuffer, bufferSize, mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height, Dali::Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY));
}
mImpl->mLoadingFrame++;
- if( mImpl->mLoadingFrame >= mImpl->mWebPAnimInfo.frame_count )
+ if(mImpl->mLoadingFrame >= mImpl->mWebPAnimInfo.frame_count)
{
mImpl->mLoadingFrame = 0;
- WebPAnimDecoderReset( mImpl->mWebPAnimDecoder );
+ WebPAnimDecoderReset(mImpl->mWebPAnimDecoder);
}
}
#endif
}
-Dali::Devel::PixelBuffer WebPLoading::LoadFrame( uint32_t frameIndex )
+Dali::Devel::PixelBuffer WebPLoading::LoadFrame(uint32_t frameIndex)
{
Dali::Devel::PixelBuffer pixelBuffer;
#ifdef DALI_WEBP_ENABLED
- if( frameIndex >= mImpl->mWebPAnimInfo.frame_count )
+ if(frameIndex >= mImpl->mWebPAnimInfo.frame_count)
{
return pixelBuffer;
}
- DALI_LOG_INFO( gWebPLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameIndex:%d )\n", frameIndex );
+ DALI_LOG_INFO(gWebPLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameIndex:%d )\n", frameIndex);
- if( mImpl->mLoadingFrame > frameIndex )
+ if(mImpl->mLoadingFrame > frameIndex)
{
mImpl->mLoadingFrame = 0;
- WebPAnimDecoderReset( mImpl->mWebPAnimDecoder );
+ WebPAnimDecoderReset(mImpl->mWebPAnimDecoder);
}
- for( ; mImpl->mLoadingFrame < frameIndex ; ++mImpl->mLoadingFrame )
+ for(; mImpl->mLoadingFrame < frameIndex; ++mImpl->mLoadingFrame)
{
uint8_t* frameBuffer;
- int timestamp;
- WebPAnimDecoderGetNext( mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp );
+ int timestamp;
+ WebPAnimDecoderGetNext(mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp);
mImpl->mTimeStamp[mImpl->mLoadingFrame] = timestamp;
}
- const int bufferSize = mImpl->mWebPAnimInfo.canvas_width * mImpl->mWebPAnimInfo.canvas_height * sizeof( uint32_t );
- uint8_t* frameBuffer;
- int timestamp;
- WebPAnimDecoderGetNext( mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp );
+ const int bufferSize = mImpl->mWebPAnimInfo.canvas_width * mImpl->mWebPAnimInfo.canvas_height * sizeof(uint32_t);
+ uint8_t* frameBuffer;
+ int timestamp;
+ WebPAnimDecoderGetNext(mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp);
- pixelBuffer = Dali::Devel::PixelBuffer::New( mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height, Dali::Pixel::RGBA8888 );
- memcpy( pixelBuffer.GetBuffer(), frameBuffer, bufferSize );
+ pixelBuffer = Dali::Devel::PixelBuffer::New(mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height, Dali::Pixel::RGBA8888);
+ memcpy(pixelBuffer.GetBuffer(), frameBuffer, bufferSize);
mImpl->mTimeStamp[mImpl->mLoadingFrame] = timestamp;
mImpl->mLoadingFrame++;
- if( mImpl->mLoadingFrame >= mImpl->mWebPAnimInfo.frame_count )
+ if(mImpl->mLoadingFrame >= mImpl->mWebPAnimInfo.frame_count)
{
mImpl->mLoadingFrame = 0;
- WebPAnimDecoderReset( mImpl->mWebPAnimDecoder );
+ WebPAnimDecoderReset(mImpl->mWebPAnimDecoder);
}
#endif
return pixelBuffer;
ImageDimensions WebPLoading::GetImageSize() const
{
#ifdef DALI_WEBP_ENABLED
- return ImageDimensions( mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height );
+ return ImageDimensions(mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height);
#else
return ImageDimensions();
#endif
#endif
}
-uint32_t WebPLoading::GetFrameInterval( uint32_t frameIndex ) const
+uint32_t WebPLoading::GetFrameInterval(uint32_t frameIndex) const
{
- if( frameIndex >= GetImageCount() )
+ if(frameIndex >= GetImageCount())
{
return 0u;
}
else
{
- if( frameIndex > 0 )
+ if(frameIndex > 0)
{
return mImpl->mTimeStamp[frameIndex] - mImpl->mTimeStamp[frameIndex - 1];
}
/*
- * Copyright (c) 2018 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.
#include <dali/internal/imaging/macos/native-image-source-factory-mac.h>
// INTERNAL HEADERS
-#include <dali/internal/imaging/macos/native-image-source-impl-mac.h>
#include <dali/internal/imaging/common/native-image-source-queue-impl.h>
+#include <dali/internal/imaging/macos/native-image-source-impl-mac.h>
namespace Dali::Internal::Adaptor
{
-
-std::unique_ptr< NativeImageSource >
+std::unique_ptr<NativeImageSource>
NativeImageSourceFactoryCocoa::CreateNativeImageSource(
- unsigned int width,
- unsigned int height,
+ unsigned int width,
+ unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource
-)
+ Any nativeImageSource)
{
- return std::unique_ptr< NativeImageSource >( NativeImageSourceCocoa::New(
+ return std::unique_ptr<NativeImageSource>(NativeImageSourceCocoa::New(
width,
height,
depth,
- nativeImageSource
- ));
+ nativeImageSource));
}
-std::unique_ptr< NativeImageSourceQueue >
+std::unique_ptr<NativeImageSourceQueue>
NativeImageSourceFactoryCocoa::CreateNativeImageSourceQueue(
- unsigned int width,
- unsigned int height,
+ unsigned int width,
+ unsigned int height,
Dali::NativeImageSourceQueue::ColorDepth depth,
- Any nativeImageSourceQueue
-)
+ Any nativeImageSourceQueue)
{
- return std::unique_ptr< NativeImageSourceQueue >( nullptr );
+ return std::unique_ptr<NativeImageSourceQueue>(nullptr);
}
// this should be created from somewhere
-std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
{
// returns native image source factory
- return std::unique_ptr< NativeImageSourceFactoryCocoa >( new NativeImageSourceFactoryCocoa() );
+ return std::unique_ptr<NativeImageSourceFactoryCocoa>(new NativeImageSourceFactoryCocoa());
}
-} // Dali::Internal::Adaptor
+} // namespace Dali::Internal::Adaptor
/*
- * 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.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
namespace Dali::Internal::Adaptor
{
-
using Dali::Integration::PixelBuffer;
NativeImageSourceCocoa* NativeImageSourceCocoa::New(
- unsigned int width,
- unsigned int height,
+ unsigned int width,
+ unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource
-)
+ Any nativeImageSource)
{
- return new NativeImageSourceCocoa( width, height, depth, nativeImageSource );
+ return new NativeImageSourceCocoa(width, height, depth, nativeImageSource);
}
NativeImageSourceCocoa::NativeImageSourceCocoa(
- unsigned int width,
- unsigned int height,
+ unsigned int width,
+ unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource
-)
+ Any nativeImageSource)
: mImage(MakeRef<CGImageRef>(nullptr))
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
- DALI_ASSERT_ALWAYS( nativeImageSource.Empty() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
+ DALI_ASSERT_ALWAYS(nativeImageSource.Empty());
- CFStringRef colorSpaceName;
+ CFStringRef colorSpaceName;
CGImageAlphaInfo alphaInfo;
- std::size_t bitsPerPixel;
+ std::size_t bitsPerPixel;
- switch (depth)
+ switch(depth)
{
case Dali::NativeImageSource::COLOR_DEPTH_8:
colorSpaceName = kCGColorSpaceGenericGray;
- alphaInfo = kCGImageAlphaNone;
- bitsPerPixel = 8;
+ alphaInfo = kCGImageAlphaNone;
+ bitsPerPixel = 8;
break;
case Dali::NativeImageSource::COLOR_DEPTH_16:
colorSpaceName = kCGColorSpaceSRGB;
- alphaInfo = kCGImageAlphaNone;
- bitsPerPixel = 16;
+ alphaInfo = kCGImageAlphaNone;
+ bitsPerPixel = 16;
break;
case Dali::NativeImageSource::COLOR_DEPTH_24:
colorSpaceName = kCGColorSpaceSRGB;
- alphaInfo = kCGImageAlphaNone;
- bitsPerPixel = 24;
+ alphaInfo = kCGImageAlphaNone;
+ bitsPerPixel = 24;
break;
case Dali::NativeImageSource::COLOR_DEPTH_32:
default:
colorSpaceName = kCGColorSpaceSRGB;
- alphaInfo = kCGImageAlphaLast;
- bitsPerPixel = 32;
+ alphaInfo = kCGImageAlphaLast;
+ bitsPerPixel = 32;
break;
}
// round to next 16 bytes boundary
std::size_t bytesPerRow = width & ~0xf;
- bytesPerRow = bytesPerRow ? bytesPerRow + 16 : width;
+ bytesPerRow = bytesPerRow ? bytesPerRow + 16 : width;
auto dataProvider = MakeRef(CGDataProviderCreateWithData(nullptr, nullptr, 0, nullptr));
- auto colorSpace = MakeRef(CGColorSpaceCreateWithName(colorSpaceName));
- mImage = MakeRef(CGImageCreate(
+ auto colorSpace = MakeRef(CGColorSpaceCreateWithName(colorSpaceName));
+ mImage = MakeRef(CGImageCreate(
width,
height,
8,
dataProvider.get(),
nullptr,
true,
- kCGRenderingIntentDefault
- ));
+ kCGRenderingIntentDefault));
- if (mImage)
+ if(mImage)
{
colorSpace.release();
dataProvider.release();
bool NativeImageSourceCocoa::GetPixels(
std::vector<uint8_t>& pixbuf,
- unsigned& width, unsigned& height,
- Pixel::Format& pixelFormat
-) const
+ unsigned& width,
+ unsigned& height,
+ Pixel::Format& pixelFormat) const
{
width = CGImageGetWidth(mImage.get());
height = CGImageGetHeight(mImage.get());
return true;
}
-void NativeImageSourceCocoa::SetSource( Any source )
+void NativeImageSourceCocoa::SetSource(Any source)
{
}
-bool NativeImageSourceCocoa::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceCocoa::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
{
return true;
}
bool NativeImageSourceCocoa::RequiresBlending() const
{
const auto alphaInfo = CGImageGetAlphaInfo(mImage.get());
- return
- alphaInfo != kCGImageAlphaNone
- && alphaInfo != kCGImageAlphaNoneSkipFirst
- && alphaInfo != kCGImageAlphaNoneSkipLast;
+ return alphaInfo != kCGImageAlphaNone && alphaInfo != kCGImageAlphaNoneSkipFirst && alphaInfo != kCGImageAlphaNoneSkipLast;
}
bool NativeImageSourceCocoa::SourceChanged() const
return false;
}
-uint8_t* NativeImageSourceCocoa::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+uint8_t* NativeImageSourceCocoa::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
{
return nullptr;
}
-
bool NativeImageSourceCocoa::ReleaseBuffer()
{
return false;
/*
- * Copyright (c) 2018 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.
{
namespace Adaptor
{
-
-std::unique_ptr< NativeImageSource > NativeImageSourceFactoryTizen::CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+std::unique_ptr<NativeImageSource> NativeImageSourceFactoryTizen::CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- return std::unique_ptr< NativeImageSource >( NativeImageSourceTizen::New( width, height, depth, nativeImageSource ) );
+ return std::unique_ptr<NativeImageSource>(NativeImageSourceTizen::New(width, height, depth, nativeImageSource));
}
-std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryTizen::CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+std::unique_ptr<NativeImageSourceQueue> NativeImageSourceFactoryTizen::CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- return std::unique_ptr< NativeImageSourceQueue >( NativeImageSourceQueueTizen::New( width, height, depth, nativeImageSourceQueue ) );
+ return std::unique_ptr<NativeImageSourceQueue>(NativeImageSourceQueueTizen::New(width, height, depth, nativeImageSourceQueue));
}
// this should be created from somewhere
-std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
{
// returns native image source factory
- return std::unique_ptr< NativeImageSourceFactoryTizen >( new NativeImageSourceFactoryTizen() );
+ return std::unique_ptr<NativeImageSourceFactoryTizen>(new NativeImageSourceFactoryTizen());
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/integration-api/gl-defines.h>
-#include <cstring>
#include <tbm_surface_internal.h>
+#include <cstring>
// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
const char* FRAGMENT_PREFIX = "#extension GL_OES_EGL_image_external:require\n";
-const char* SAMPLER_TYPE = "samplerExternalOES";
+const char* SAMPLER_TYPE = "samplerExternalOES";
+// clang-format off
tbm_format FORMATS_BLENDING_REQUIRED[] = {
TBM_FORMAT_ARGB4444, TBM_FORMAT_ABGR4444,
TBM_FORMAT_RGBA4444, TBM_FORMAT_BGRA4444,
TBM_FORMAT_ARGB2101010, TBM_FORMAT_ABGR2101010,
TBM_FORMAT_RGBA1010102, TBM_FORMAT_BGRA1010102
};
+// clang-format on
const int NUM_FORMATS_BLENDING_REQUIRED = 18;
-}
+} // namespace
using Dali::Integration::PixelBuffer;
-NativeImageSourceTizen* NativeImageSourceTizen::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen* NativeImageSourceTizen::New(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- NativeImageSourceTizen* image = new NativeImageSourceTizen( width, height, depth, nativeImageSource );
- DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
+ NativeImageSourceTizen* image = new NativeImageSourceTizen(width, height, depth, nativeImageSource);
+ DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed.");
- if( image )
+ if(image)
{
image->Initialize();
}
return image;
}
-NativeImageSourceTizen::NativeImageSourceTizen( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
- mHeight( height ),
- mOwnTbmSurface( false ),
- mTbmSurface( NULL ),
- mTbmFormat( 0 ),
- mBlendingRequired( false ),
- mColorDepth( depth ),
- mEglImageKHR( NULL ),
- mEglGraphics( NULL ),
- mEglImageExtensions( NULL ),
- mSetSource( false ),
+NativeImageSourceTizen::NativeImageSourceTizen(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+: mWidth(width),
+ mHeight(height),
+ mOwnTbmSurface(false),
+ mTbmSurface(NULL),
+ mTbmFormat(0),
+ mBlendingRequired(false),
+ mColorDepth(depth),
+ mEglImageKHR(NULL),
+ mEglGraphics(NULL),
+ mEglImageExtensions(NULL),
+ mSetSource(false),
mMutex(),
- mIsBufferAcquired( false )
+ mIsBufferAcquired(false)
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- mEglGraphics = static_cast<EglGraphics *>(graphics);
+ GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ mEglGraphics = static_cast<EglGraphics*>(graphics);
- mTbmSurface = GetSurfaceFromAny( nativeImageSource );
+ mTbmSurface = GetSurfaceFromAny(nativeImageSource);
- if( mTbmSurface != NULL )
+ if(mTbmSurface != NULL)
{
- tbm_surface_internal_ref( mTbmSurface );
- mBlendingRequired = CheckBlending( tbm_surface_get_format( mTbmSurface ) );
- mWidth = tbm_surface_get_width( mTbmSurface );
- mHeight = tbm_surface_get_height( mTbmSurface );
+ tbm_surface_internal_ref(mTbmSurface);
+ mBlendingRequired = CheckBlending(tbm_surface_get_format(mTbmSurface));
+ mWidth = tbm_surface_get_width(mTbmSurface);
+ mHeight = tbm_surface_get_height(mTbmSurface);
}
}
void NativeImageSourceTizen::Initialize()
{
- if( mTbmSurface != NULL || mWidth == 0 || mHeight == 0 )
+ if(mTbmSurface != NULL || mWidth == 0 || mHeight == 0)
{
return;
}
tbm_format format = TBM_FORMAT_RGB888;
- int depth = 0;
+ int depth = 0;
- switch( mColorDepth )
+ switch(mColorDepth)
{
case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
{
format = TBM_FORMAT_ARGB8888;
- depth = 32;
+ depth = 32;
break;
}
case Dali::NativeImageSource::COLOR_DEPTH_8:
{
format = TBM_FORMAT_C8;
- depth = 8;
+ depth = 8;
break;
}
case Dali::NativeImageSource::COLOR_DEPTH_16:
{
format = TBM_FORMAT_RGB565;
- depth = 16;
+ depth = 16;
break;
}
case Dali::NativeImageSource::COLOR_DEPTH_24:
{
format = TBM_FORMAT_RGB888;
- depth = 24;
+ depth = 24;
break;
}
case Dali::NativeImageSource::COLOR_DEPTH_32:
{
format = TBM_FORMAT_ARGB8888;
- depth = 32;
+ depth = 32;
break;
}
default:
{
- DALI_LOG_WARNING( "Wrong color depth.\n" );
+ DALI_LOG_WARNING("Wrong color depth.\n");
return;
}
}
If depth = 8, Pixel::A8;
If depth = 16, Pixel::RGB565;
If depth = 32, Pixel::RGBA8888 */
- mBlendingRequired = ( depth == 32 || depth == 8 );
+ mBlendingRequired = (depth == 32 || depth == 8);
- mTbmSurface = tbm_surface_create( mWidth, mHeight, format );
+ mTbmSurface = tbm_surface_create(mWidth, mHeight, format);
mOwnTbmSurface = true;
}
-tbm_surface_h NativeImageSourceTizen::GetSurfaceFromAny( Any source ) const
+tbm_surface_h NativeImageSourceTizen::GetSurfaceFromAny(Any source) const
{
- if( source.Empty() )
+ if(source.Empty())
{
return NULL;
}
- if( source.GetType() == typeid( tbm_surface_h ) )
+ if(source.GetType() == typeid(tbm_surface_h))
{
- return AnyCast< tbm_surface_h >( source );
+ return AnyCast<tbm_surface_h>(source);
}
else
{
void NativeImageSourceTizen::DestroySurface()
{
- if( mTbmSurface )
+ if(mTbmSurface)
{
- if( mIsBufferAcquired )
+ if(mIsBufferAcquired)
{
ReleaseBuffer();
}
- if( mOwnTbmSurface )
+ if(mOwnTbmSurface)
{
- if( tbm_surface_destroy( mTbmSurface ) != TBM_SURFACE_ERROR_NONE )
+ if(tbm_surface_destroy(mTbmSurface) != TBM_SURFACE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Failed to destroy tbm_surface\n" );
+ DALI_LOG_ERROR("Failed to destroy tbm_surface\n");
}
}
else
{
- tbm_surface_internal_unref( mTbmSurface );
+ tbm_surface_internal_unref(mTbmSurface);
}
}
}
Any NativeImageSourceTizen::GetNativeImageSource() const
{
- return Any( mTbmSurface );
+ return Any(mTbmSurface);
}
bool NativeImageSourceTizen::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
{
- Dali::Mutex::ScopedLock lock( mMutex );
- if( mTbmSurface != NULL )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ if(mTbmSurface != NULL)
{
tbm_surface_info_s surface_info;
- if( tbm_surface_map( mTbmSurface, TBM_SURF_OPTION_READ, &surface_info) != TBM_SURFACE_ERROR_NONE )
+ if(tbm_surface_map(mTbmSurface, TBM_SURF_OPTION_READ, &surface_info) != TBM_SURFACE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Fail to map tbm_surface\n" );
+ DALI_LOG_ERROR("Fail to map tbm_surface\n");
- width = 0;
+ width = 0;
height = 0;
return false;
}
- tbm_format format = surface_info.format;
- uint32_t stride = surface_info.planes[0].stride;
- unsigned char* ptr = surface_info.planes[0].ptr;
+ tbm_format format = surface_info.format;
+ uint32_t stride = surface_info.planes[0].stride;
+ unsigned char* ptr = surface_info.planes[0].ptr;
- width = mWidth;
+ width = mWidth;
height = mHeight;
size_t lineSize;
size_t offset;
size_t cOffset;
- switch( format )
+ switch(format)
{
case TBM_FORMAT_RGB888:
{
- lineSize = width*3;
+ lineSize = width * 3;
pixelFormat = Pixel::RGB888;
- pixbuf.resize( lineSize*height );
+ pixbuf.resize(lineSize * height);
unsigned char* bufptr = &pixbuf[0];
- for( unsigned int r = 0; r < height; ++r, bufptr += lineSize )
+ for(unsigned int r = 0; r < height; ++r, bufptr += lineSize)
{
- for( unsigned int c = 0; c < width; ++c )
+ for(unsigned int c = 0; c < width; ++c)
{
- cOffset = c*3;
- offset = cOffset + r*stride;
- *(bufptr+cOffset) = ptr[offset+2];
- *(bufptr+cOffset+1) = ptr[offset+1];
- *(bufptr+cOffset+2) = ptr[offset];
+ cOffset = c * 3;
+ offset = cOffset + r * stride;
+ *(bufptr + cOffset) = ptr[offset + 2];
+ *(bufptr + cOffset + 1) = ptr[offset + 1];
+ *(bufptr + cOffset + 2) = ptr[offset];
}
}
break;
}
case TBM_FORMAT_RGBA8888:
{
- lineSize = width*4;
+ lineSize = width * 4;
pixelFormat = Pixel::RGBA8888;
- pixbuf.resize( lineSize*height );
+ pixbuf.resize(lineSize * height);
unsigned char* bufptr = &pixbuf[0];
- for( unsigned int r = 0; r < height; ++r, bufptr += lineSize )
+ for(unsigned int r = 0; r < height; ++r, bufptr += lineSize)
{
- for( unsigned int c = 0; c < width; ++c )
+ for(unsigned int c = 0; c < width; ++c)
{
- cOffset = c*4;
- offset = cOffset + r*stride;
- *(bufptr+cOffset) = ptr[offset+3];
- *(bufptr+cOffset+1) = ptr[offset+2];
- *(bufptr+cOffset+2) = ptr[offset+1];
- *(bufptr+cOffset+3) = ptr[offset];
+ cOffset = c * 4;
+ offset = cOffset + r * stride;
+ *(bufptr + cOffset) = ptr[offset + 3];
+ *(bufptr + cOffset + 1) = ptr[offset + 2];
+ *(bufptr + cOffset + 2) = ptr[offset + 1];
+ *(bufptr + cOffset + 3) = ptr[offset];
}
}
break;
}
case TBM_FORMAT_ARGB8888:
{
- lineSize = width*4;
+ lineSize = width * 4;
pixelFormat = Pixel::RGBA8888;
- pixbuf.resize( lineSize*height );
+ pixbuf.resize(lineSize * height);
unsigned char* bufptr = &pixbuf[0];
- for( unsigned int r = 0; r < height; ++r, bufptr += lineSize )
+ for(unsigned int r = 0; r < height; ++r, bufptr += lineSize)
{
- for( unsigned int c = 0; c < width; ++c )
+ for(unsigned int c = 0; c < width; ++c)
{
- cOffset = c*4;
- offset = cOffset + r*stride;
- *(bufptr+cOffset) = ptr[offset+2];
- *(bufptr+cOffset+1) = ptr[offset+1];
- *(bufptr+cOffset+2) = ptr[offset];
- *(bufptr+cOffset+3) = ptr[offset+3];
+ cOffset = c * 4;
+ offset = cOffset + r * stride;
+ *(bufptr + cOffset) = ptr[offset + 2];
+ *(bufptr + cOffset + 1) = ptr[offset + 1];
+ *(bufptr + cOffset + 2) = ptr[offset];
+ *(bufptr + cOffset + 3) = ptr[offset + 3];
}
}
break;
}
default:
{
- DALI_ASSERT_ALWAYS( 0 && "Tbm surface has unsupported pixel format.\n" );
+ DALI_ASSERT_ALWAYS(0 && "Tbm surface has unsupported pixel format.\n");
return false;
}
}
- if( tbm_surface_unmap( mTbmSurface ) != TBM_SURFACE_ERROR_NONE )
+ if(tbm_surface_unmap(mTbmSurface) != TBM_SURFACE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Fail to unmap tbm_surface\n" );
+ DALI_LOG_ERROR("Fail to unmap tbm_surface\n");
}
return true;
}
- DALI_LOG_WARNING( "TBM surface does not exist.\n" );
+ DALI_LOG_WARNING("TBM surface does not exist.\n");
- width = 0;
+ width = 0;
height = 0;
return false;
}
-void NativeImageSourceTizen::SetSource( Any source )
+void NativeImageSourceTizen::SetSource(Any source)
{
- Dali::Mutex::ScopedLock lock( mMutex );
+ Dali::Mutex::ScopedLock lock(mMutex);
DestroySurface();
mOwnTbmSurface = false;
- mTbmSurface = GetSurfaceFromAny( source );
+ mTbmSurface = GetSurfaceFromAny(source);
- if( mTbmSurface != NULL )
+ if(mTbmSurface != NULL)
{
mSetSource = true;
- tbm_surface_internal_ref( mTbmSurface );
- mBlendingRequired = CheckBlending( tbm_surface_get_format( mTbmSurface ) );
- mWidth = tbm_surface_get_width( mTbmSurface );
- mHeight = tbm_surface_get_height( mTbmSurface );
+ tbm_surface_internal_ref(mTbmSurface);
+ mBlendingRequired = CheckBlending(tbm_surface_get_format(mTbmSurface));
+ mWidth = tbm_surface_get_width(mTbmSurface);
+ mHeight = tbm_surface_get_height(mTbmSurface);
}
}
-bool NativeImageSourceTizen::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceTizen::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
{
- uint32_t* formats;
- uint32_t formatNum;
+ uint32_t* formats;
+ uint32_t formatNum;
tbm_format format = TBM_FORMAT_RGB888;
- switch( colorDepth )
+ switch(colorDepth)
{
case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
{
}
}
- if( tbm_surface_query_formats( &formats, &formatNum ) )
+ if(tbm_surface_query_formats(&formats, &formatNum))
{
- for( unsigned int i = 0; i < formatNum; i++ )
+ for(unsigned int i = 0; i < formatNum; i++)
{
- if( formats[i] == format )
+ if(formats[i] == format)
{
- free( formats );
+ free(formats);
return true;
}
}
}
- free( formats );
+ free(formats);
return false;
}
{
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
- EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer >(mTbmSurface);
- if( !eglBuffer || !tbm_surface_internal_is_valid( mTbmSurface ) )
+ EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mTbmSurface);
+ if(!eglBuffer || !tbm_surface_internal_is_valid(mTbmSurface))
{
return false;
}
mEglImageExtensions = mEglGraphics->GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
- mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
+ mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
return mEglImageKHR != NULL;
}
void NativeImageSourceTizen::DestroyResource()
{
- Dali::Mutex::ScopedLock lock( mMutex );
- if( mEglImageKHR )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ if(mEglImageKHR)
{
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
void NativeImageSourceTizen::PrepareTexture()
{
- Dali::Mutex::ScopedLock lock( mMutex );
- if( mSetSource )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ if(mSetSource)
{
void* eglImage = mEglImageKHR;
- if( CreateResource() )
+ if(CreateResource())
{
TargetTexture();
}
- mEglImageExtensions->DestroyImageKHR( eglImage );
+ mEglImageExtensions->DestroyImageKHR(eglImage);
mSetSource = false;
}
return false;
}
-bool NativeImageSourceTizen::CheckBlending( tbm_format format )
+bool NativeImageSourceTizen::CheckBlending(tbm_format format)
{
- if( mTbmFormat != format )
+ if(mTbmFormat != format)
{
for(int i = 0; i < NUM_FORMATS_BLENDING_REQUIRED; ++i)
{
- if( format == FORMATS_BLENDING_REQUIRED[i] )
+ if(format == FORMATS_BLENDING_REQUIRED[i])
{
mBlendingRequired = true;
break;
return mBlendingRequired;
}
-uint8_t* NativeImageSourceTizen::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+uint8_t* NativeImageSourceTizen::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
{
- Dali::Mutex::ScopedLock lock( mMutex );
- if( mTbmSurface != NULL )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ if(mTbmSurface != NULL)
{
tbm_surface_info_s info;
- if( tbm_surface_map( mTbmSurface, TBM_SURF_OPTION_READ, &info) != TBM_SURFACE_ERROR_NONE )
+ if(tbm_surface_map(mTbmSurface, TBM_SURF_OPTION_READ, &info) != TBM_SURFACE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Fail to map tbm_surface\n" );
+ DALI_LOG_ERROR("Fail to map tbm_surface\n");
- width = 0;
+ width = 0;
height = 0;
return NULL;
}
- tbm_surface_internal_ref( mTbmSurface );
+ tbm_surface_internal_ref(mTbmSurface);
mIsBufferAcquired = true;
stride = info.planes[0].stride;
- width = mWidth;
+ width = mWidth;
height = mHeight;
return info.planes[0].ptr;
return NULL;
}
-
bool NativeImageSourceTizen::ReleaseBuffer()
{
- Dali::Mutex::ScopedLock lock( mMutex );
- bool ret = false;
- if( mTbmSurface != NULL )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ bool ret = false;
+ if(mTbmSurface != NULL)
{
- ret = ( tbm_surface_unmap( mTbmSurface ) == TBM_SURFACE_ERROR_NONE );
- if( !ret )
+ ret = (tbm_surface_unmap(mTbmSurface) == TBM_SURFACE_ERROR_NONE);
+ if(!ret)
{
- DALI_LOG_ERROR( "Fail to unmap tbm_surface\n" );
+ DALI_LOG_ERROR("Fail to unmap tbm_surface\n");
}
- tbm_surface_internal_unref( mTbmSurface );
+ tbm_surface_internal_unref(mTbmSurface);
mIsBufferAcquired = false;
}
return ret;
}
-
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 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.
#include <tbm_surface_internal.h>
// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-#define TBM_SURFACE_QUEUE_SIZE 3
+#define TBM_SURFACE_QUEUE_SIZE 3
const char* FRAGMENT_PREFIX = "#extension GL_OES_EGL_image_external:require\n";
-const char* SAMPLER_TYPE = "samplerExternalOES";
+const char* SAMPLER_TYPE = "samplerExternalOES";
+// clang-format off
int FORMATS_BLENDING_REQUIRED[] = {
TBM_FORMAT_ARGB4444, TBM_FORMAT_ABGR4444,
TBM_FORMAT_RGBA4444, TBM_FORMAT_BGRA4444,
TBM_FORMAT_ARGB2101010, TBM_FORMAT_ABGR2101010,
TBM_FORMAT_RGBA1010102, TBM_FORMAT_BGRA1010102
};
+// clang-format on
const int NUM_FORMATS_BLENDING_REQUIRED = 18;
-}
+} // namespace
-NativeImageSourceQueueTizen* NativeImageSourceQueueTizen::New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueTizen* NativeImageSourceQueueTizen::New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- NativeImageSourceQueueTizen* image = new NativeImageSourceQueueTizen( width, height, depth, nativeImageSourceQueue );
- DALI_ASSERT_DEBUG( image && "NativeImageSourceQueueTizen allocation failed." );
+ NativeImageSourceQueueTizen* image = new NativeImageSourceQueueTizen(width, height, depth, nativeImageSourceQueue);
+ DALI_ASSERT_DEBUG(image && "NativeImageSourceQueueTizen allocation failed.");
- if( image )
+ if(image)
{
- image->Initialize( depth );
+ image->Initialize(depth);
}
return image;
}
-NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueTizen::NativeImageSourceQueueTizen(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
: mMutex(),
- mWidth( width ),
- mHeight( height ),
- mTbmQueue( NULL ),
- mConsumeSurface( NULL ),
+ mWidth(width),
+ mHeight(height),
+ mTbmQueue(NULL),
+ mConsumeSurface(NULL),
mEglImages(),
- mEglGraphics( NULL ),
- mEglImageExtensions( NULL ),
- mOwnTbmQueue( false ),
- mBlendingRequired( false )
+ mEglGraphics(NULL),
+ mEglImageExtensions(NULL),
+ mOwnTbmQueue(false),
+ mBlendingRequired(false)
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- mEglGraphics = static_cast<EglGraphics *>(graphics);
+ GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ mEglGraphics = static_cast<EglGraphics*>(graphics);
- mTbmQueue = GetSurfaceFromAny( nativeImageSourceQueue );
+ mTbmQueue = GetSurfaceFromAny(nativeImageSourceQueue);
- if( mTbmQueue != NULL )
+ if(mTbmQueue != NULL)
{
- mBlendingRequired = CheckBlending( tbm_surface_queue_get_format( mTbmQueue ) );
- mWidth = tbm_surface_queue_get_width( mTbmQueue );
- mHeight = tbm_surface_queue_get_height( mTbmQueue );
+ mBlendingRequired = CheckBlending(tbm_surface_queue_get_format(mTbmQueue));
+ mWidth = tbm_surface_queue_get_width(mTbmQueue);
+ mHeight = tbm_surface_queue_get_height(mTbmQueue);
}
}
NativeImageSourceQueueTizen::~NativeImageSourceQueueTizen()
{
- if( mOwnTbmQueue )
+ if(mOwnTbmQueue)
{
- if( mTbmQueue != NULL )
+ if(mTbmQueue != NULL)
{
- tbm_surface_queue_destroy( mTbmQueue );
+ tbm_surface_queue_destroy(mTbmQueue);
}
}
}
-void NativeImageSourceQueueTizen::Initialize( Dali::NativeImageSourceQueue::ColorDepth depth )
+void NativeImageSourceQueueTizen::Initialize(Dali::NativeImageSourceQueue::ColorDepth depth)
{
- if( mWidth == 0 || mHeight == 0 )
+ if(mWidth == 0 || mHeight == 0)
{
return;
}
- if( mTbmQueue == NULL )
+ if(mTbmQueue == NULL)
{
int format = TBM_FORMAT_ARGB8888;
- switch( depth )
+ switch(depth)
{
case Dali::NativeImageSourceQueue::COLOR_DEPTH_DEFAULT:
case Dali::NativeImageSourceQueue::COLOR_DEPTH_32:
{
- format = TBM_FORMAT_ARGB8888;
+ format = TBM_FORMAT_ARGB8888;
mBlendingRequired = true;
break;
}
case Dali::NativeImageSourceQueue::COLOR_DEPTH_24:
{
- format = TBM_FORMAT_RGB888;
+ format = TBM_FORMAT_RGB888;
mBlendingRequired = false;
break;
}
default:
{
- DALI_LOG_WARNING( "Wrong color depth.\n" );
+ DALI_LOG_WARNING("Wrong color depth.\n");
return;
}
}
- mTbmQueue = tbm_surface_queue_create( TBM_SURFACE_QUEUE_SIZE, mWidth, mHeight, format, 0 );
- if( !mTbmQueue )
+ mTbmQueue = tbm_surface_queue_create(TBM_SURFACE_QUEUE_SIZE, mWidth, mHeight, format, 0);
+ if(!mTbmQueue)
{
- DALI_LOG_ERROR( "NativeImageSourceQueueTizen::Initialize: tbm_surface_queue_create is failed! [%p]\n", mTbmQueue );
+ DALI_LOG_ERROR("NativeImageSourceQueueTizen::Initialize: tbm_surface_queue_create is failed! [%p]\n", mTbmQueue);
return;
}
}
}
-tbm_surface_queue_h NativeImageSourceQueueTizen::GetSurfaceFromAny( Any source ) const
+tbm_surface_queue_h NativeImageSourceQueueTizen::GetSurfaceFromAny(Any source) const
{
- if( source.Empty() )
+ if(source.Empty())
{
return NULL;
}
- if( source.GetType() == typeid( tbm_surface_queue_h ) )
+ if(source.GetType() == typeid(tbm_surface_queue_h))
{
- return AnyCast< tbm_surface_queue_h >( source );
+ return AnyCast<tbm_surface_queue_h>(source);
}
else
{
Any NativeImageSourceQueueTizen::GetNativeImageSourceQueue() const
{
- return Any( mTbmQueue );
+ return Any(mTbmQueue);
}
-void NativeImageSourceQueueTizen::SetSize( uint32_t width, uint32_t height )
+void NativeImageSourceQueueTizen::SetSize(uint32_t width, uint32_t height)
{
- Dali::Mutex::ScopedLock lock( mMutex );
+ Dali::Mutex::ScopedLock lock(mMutex);
- tbm_surface_queue_reset( mTbmQueue, width, height, tbm_surface_queue_get_format( mTbmQueue ) );
+ tbm_surface_queue_reset(mTbmQueue, width, height, tbm_surface_queue_get_format(mTbmQueue));
- mWidth = width;
+ mWidth = width;
mHeight = height;
ResetEglImageList();
void NativeImageSourceQueueTizen::IgnoreSourceImage()
{
- Dali::Mutex::ScopedLock lock( mMutex );
- tbm_surface_h surface;
+ Dali::Mutex::ScopedLock lock(mMutex);
+ tbm_surface_h surface;
- if( tbm_surface_queue_can_acquire( mTbmQueue, 0 ) )
+ if(tbm_surface_queue_can_acquire(mTbmQueue, 0))
{
- if( tbm_surface_queue_acquire( mTbmQueue, &surface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
+ if(tbm_surface_queue_acquire(mTbmQueue, &surface) != TBM_SURFACE_QUEUE_ERROR_NONE)
{
- DALI_LOG_ERROR( "NativeImageSourceQueueTizen::IgnoreSourceImage: Failed to aquire a tbm_surface\n" );
+ DALI_LOG_ERROR("NativeImageSourceQueueTizen::IgnoreSourceImage: Failed to aquire a tbm_surface\n");
return;
}
- if( tbm_surface_internal_is_valid( surface ) )
+ if(tbm_surface_internal_is_valid(surface))
{
- tbm_surface_queue_release( mTbmQueue, surface );
+ tbm_surface_queue_release(mTbmQueue, surface);
}
}
}
bool NativeImageSourceQueueTizen::CreateResource()
{
mEglImageExtensions = mEglGraphics->GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
return true;
}
void NativeImageSourceQueueTizen::DestroyResource()
{
- Dali::Mutex::ScopedLock lock( mMutex );
+ Dali::Mutex::ScopedLock lock(mMutex);
ResetEglImageList();
}
void NativeImageSourceQueueTizen::PrepareTexture()
{
- Dali::Mutex::ScopedLock lock( mMutex );
+ Dali::Mutex::ScopedLock lock(mMutex);
tbm_surface_h oldSurface = mConsumeSurface;
- if( tbm_surface_queue_can_acquire( mTbmQueue, 0 ) )
+ if(tbm_surface_queue_can_acquire(mTbmQueue, 0))
{
- if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
+ if(tbm_surface_queue_acquire(mTbmQueue, &mConsumeSurface) != TBM_SURFACE_QUEUE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Failed to aquire a tbm_surface\n" );
+ DALI_LOG_ERROR("Failed to aquire a tbm_surface\n");
return;
}
- if( oldSurface )
+ if(oldSurface)
{
- if( tbm_surface_internal_is_valid( oldSurface ) )
+ if(tbm_surface_internal_is_valid(oldSurface))
{
- tbm_surface_queue_release( mTbmQueue, oldSurface );
+ tbm_surface_queue_release(mTbmQueue, oldSurface);
}
}
- if( mConsumeSurface )
+ if(mConsumeSurface)
{
bool existing = false;
- for( auto&& iter : mEglImages )
+ for(auto&& iter : mEglImages)
{
- if( iter.first == mConsumeSurface )
+ if(iter.first == mConsumeSurface)
{
// Find the surface in the existing list
existing = true;
- mEglImageExtensions->TargetTextureKHR( iter.second );
+ mEglImageExtensions->TargetTextureKHR(iter.second);
break;
}
}
- if( !existing )
+ if(!existing)
{
// Push the surface
- tbm_surface_internal_ref( mConsumeSurface );
+ tbm_surface_internal_ref(mConsumeSurface);
- void* eglImageKHR = mEglImageExtensions->CreateImageKHR( reinterpret_cast< EGLClientBuffer >( mConsumeSurface ) );
- mEglImageExtensions->TargetTextureKHR( eglImageKHR );
+ void* eglImageKHR = mEglImageExtensions->CreateImageKHR(reinterpret_cast<EGLClientBuffer>(mConsumeSurface));
+ mEglImageExtensions->TargetTextureKHR(eglImageKHR);
- mEglImages.push_back( EglImagePair( mConsumeSurface, eglImageKHR) );
+ mEglImages.push_back(EglImagePair(mConsumeSurface, eglImageKHR));
}
}
}
return false;
}
-
-
void NativeImageSourceQueueTizen::ResetEglImageList()
{
- if( mConsumeSurface )
+ if(mConsumeSurface)
{
- if( tbm_surface_internal_is_valid( mConsumeSurface ) )
+ if(tbm_surface_internal_is_valid(mConsumeSurface))
{
- tbm_surface_queue_release( mTbmQueue, mConsumeSurface );
+ tbm_surface_queue_release(mTbmQueue, mConsumeSurface);
}
mConsumeSurface = NULL;
}
- for( auto&& iter : mEglImages )
+ for(auto&& iter : mEglImages)
{
- mEglImageExtensions->DestroyImageKHR( iter.second );
+ mEglImageExtensions->DestroyImageKHR(iter.second);
- tbm_surface_internal_unref( iter.first );
+ tbm_surface_internal_unref(iter.first);
}
mEglImages.clear();
}
-bool NativeImageSourceQueueTizen::CheckBlending( int format )
+bool NativeImageSourceQueueTizen::CheckBlending(int format)
{
- for( int i = 0; i < NUM_FORMATS_BLENDING_REQUIRED; ++i )
+ for(int i = 0; i < NUM_FORMATS_BLENDING_REQUIRED; ++i)
{
- if( format == FORMATS_BLENDING_REQUIRED[i] )
+ if(format == FORMATS_BLENDING_REQUIRED[i])
{
return true;
}
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 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.
{
namespace Adaptor
{
-
-std::unique_ptr< NativeImageSource > NativeImageSourceFactoryX::CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+std::unique_ptr<NativeImageSource> NativeImageSourceFactoryX::CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- return std::unique_ptr< NativeImageSource >( NativeImageSourceX::New( width, height, depth, nativeImageSource ) );
+ return std::unique_ptr<NativeImageSource>(NativeImageSourceX::New(width, height, depth, nativeImageSource));
}
-std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryX::CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+std::unique_ptr<NativeImageSourceQueue> NativeImageSourceFactoryX::CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- return std::unique_ptr< NativeImageSourceQueue >( NativeImageSourceQueueX::New( width, height, depth, nativeImageSourceQueue ) );
+ return std::unique_ptr<NativeImageSourceQueue>(NativeImageSourceQueueX::New(width, height, depth, nativeImageSourceQueue));
}
// this should be created from somewhere
-std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
{
// returns native image source factory
- return std::unique_ptr< NativeImageSourceFactoryX >( new NativeImageSourceFactoryX() );
+ return std::unique_ptr<NativeImageSourceFactoryX>(new NativeImageSourceFactoryX());
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h>
// EXTERNAL INCLUDES
-#include <dali/internal/system/linux/dali-ecore-x.h>
-#include <X11/Xutil.h>
#include <X11/Xlib.h>
+#include <X11/Xutil.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/linux/dali-ecore-x.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
using Dali::Integration::PixelBuffer;
// Pieces needed to save compressed images (temporary location while plumbing):
namespace
{
-
- /**
+/**
* Free an allocated XImage on destruction.
*/
- struct XImageJanitor
+struct XImageJanitor
+{
+ XImageJanitor(XImage* const pXImage)
+ : mXImage(pXImage)
{
- XImageJanitor( XImage* const pXImage ) : mXImage( pXImage )
- {
- DALI_ASSERT_DEBUG(pXImage != 0 && "Null pointer to XImage.");
- }
+ DALI_ASSERT_DEBUG(pXImage != 0 && "Null pointer to XImage.");
+ }
- ~XImageJanitor()
+ ~XImageJanitor()
+ {
+ if(mXImage)
{
- if( mXImage )
+ if(!XDestroyImage(mXImage))
{
- if( !XDestroyImage(mXImage) )
- {
- DALI_LOG_ERROR("XImage deallocation failure");
- }
+ DALI_LOG_ERROR("XImage deallocation failure");
}
}
- XImage* const mXImage;
- private:
- XImageJanitor( const XImageJanitor& rhs );
- XImageJanitor& operator = ( const XImageJanitor& rhs );
- };
-}
+ }
+ XImage* const mXImage;
-NativeImageSourceX* NativeImageSourceX::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+private:
+ XImageJanitor(const XImageJanitor& rhs);
+ XImageJanitor& operator=(const XImageJanitor& rhs);
+};
+} // namespace
+
+NativeImageSourceX* NativeImageSourceX::New(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- NativeImageSourceX* image = new NativeImageSourceX( width, height, depth, nativeImageSource );
- DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
+ NativeImageSourceX* image = new NativeImageSourceX(width, height, depth, nativeImageSource);
+ DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed.");
// 2nd phase construction
if(image) //< Defensive in case we ever compile without exceptions.
return image;
}
-NativeImageSourceX::NativeImageSourceX( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
- mHeight( height ),
- mOwnPixmap( true ),
- mPixmap( 0 ),
- mBlendingRequired( false ),
- mColorDepth( depth ),
- mEglImageKHR( NULL ),
- mEglImageExtensions( NULL )
+NativeImageSourceX::NativeImageSourceX(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+: mWidth(width),
+ mHeight(height),
+ mOwnPixmap(true),
+ mPixmap(0),
+ mBlendingRequired(false),
+ mColorDepth(depth),
+ mEglImageKHR(NULL),
+ mEglImageExtensions(NULL)
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- auto eglGraphics = static_cast<EglGraphics *>(graphics);
+ GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ auto eglGraphics = static_cast<EglGraphics*>(graphics);
mEglImageExtensions = eglGraphics->GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
// assign the pixmap
mPixmap = GetPixmapFromAny(nativeImageSource);
void NativeImageSourceX::Initialize()
{
// if pixmap has been created outside of X11 Image we can return
- if (mPixmap)
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
If depth = 8, Pixel::A8;
If depth = 16, Pixel::RGB565;
If depth = 32, Pixel::RGBA8888 */
- mBlendingRequired = ( depth == 32 || depth == 8 );
+ mBlendingRequired = (depth == 32 || depth == 8);
- mPixmap = ecore_x_pixmap_new( 0, mWidth, mHeight, depth );
+ mPixmap = ecore_x_pixmap_new(0, mWidth, mHeight, depth);
ecore_x_sync();
}
NativeImageSourceX::~NativeImageSourceX()
{
- if (mOwnPixmap && mPixmap)
+ if(mOwnPixmap && mPixmap)
{
// Temporarily disable this as this causes a crash with EFL Version 1.24.0
//ecore_x_pixmap_free(mPixmap);
{
DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
bool success = false;
- width = mWidth;
- height = mHeight;
+ width = mWidth;
+ height = mHeight;
// Open a display connection
- Display* displayConnection = XOpenDisplay( 0 );
-
- XImageJanitor xImageJanitor( XGetImage( displayConnection,
- mPixmap,
- 0, 0, // x,y of subregion to extract.
- width, height, // of subregion to extract.
- 0xFFFFFFFF,
- ZPixmap ) );
- XImage* const pXImage = xImageJanitor.mXImage;
+ Display* displayConnection = XOpenDisplay(0);
+
+ XImageJanitor xImageJanitor(XGetImage(displayConnection,
+ mPixmap,
+ 0,
+ 0, // x,y of subregion to extract.
+ width,
+ height, // of subregion to extract.
+ 0xFFFFFFFF,
+ ZPixmap));
+ XImage* const pXImage = xImageJanitor.mXImage;
DALI_ASSERT_DEBUG(pXImage && "XImage (from pixmap) could not be retrieved from the server");
if(!pXImage)
{
case 24:
{
pixelFormat = Pixel::RGB888;
- pixbuf.resize(width*height*3);
+ pixbuf.resize(width * height * 3);
unsigned char* bufPtr = &pixbuf[0];
for(unsigned y = 0; y < height; ++y)
{
- for(unsigned x = 0; x < width; ++x, bufPtr+=3)
+ for(unsigned x = 0; x < width; ++x, bufPtr += 3)
{
- const unsigned pixel = XGetPixel(pXImage,x,y);
+ const unsigned pixel = XGetPixel(pXImage, x, y);
// store as RGB
- const unsigned blue = pixel & 0xFFU;
- const unsigned green = (pixel >> 8) & 0xFFU;
+ const unsigned blue = pixel & 0xFFU;
+ const unsigned green = (pixel >> 8) & 0xFFU;
const unsigned red = (pixel >> 16) & 0xFFU;
- *bufPtr = red;
- *(bufPtr+1) = green;
- *(bufPtr+2) = blue;
+ *bufPtr = red;
+ *(bufPtr + 1) = green;
+ *(bufPtr + 2) = blue;
}
}
success = true;
{
// Sweep through the image, doing a vertical flip, but handling each scanline as
// an inlined intrinsic/builtin memcpy (should be fast):
- pixbuf.resize(width*height*4);
- unsigned * bufPtr = reinterpret_cast<unsigned *>(&pixbuf[0]);
+ pixbuf.resize(width * height * 4);
+ unsigned* bufPtr = reinterpret_cast<unsigned*>(&pixbuf[0]);
const unsigned xDataLineSkip = pXImage->bytes_per_line;
- const size_t copy_count = static_cast< size_t >( width ) * 4;
- pixelFormat = Pixel::BGRA8888;
+ const size_t copy_count = static_cast<size_t>(width) * 4;
+ pixelFormat = Pixel::BGRA8888;
for(unsigned y = 0; y < height; ++y, bufPtr += width)
{
- const char * const in = pXImage->data + xDataLineSkip * y;
+ const char* const in = pXImage->data + xDataLineSkip * y;
// Copy a whole scanline at a time:
- DALI_ASSERT_DEBUG( size_t( bufPtr ) >= size_t( &pixbuf[0] ));
- DALI_ASSERT_DEBUG( reinterpret_cast<size_t>( bufPtr ) + copy_count <= reinterpret_cast<size_t>( &pixbuf[pixbuf.size()] ) );
- DALI_ASSERT_DEBUG( in >= pXImage->data );
- DALI_ASSERT_DEBUG( in + copy_count <= pXImage->data + xDataLineSkip * height );
- __builtin_memcpy( bufPtr, in, copy_count );
+ DALI_ASSERT_DEBUG(size_t(bufPtr) >= size_t(&pixbuf[0]));
+ DALI_ASSERT_DEBUG(reinterpret_cast<size_t>(bufPtr) + copy_count <= reinterpret_cast<size_t>(&pixbuf[pixbuf.size()]));
+ DALI_ASSERT_DEBUG(in >= pXImage->data);
+ DALI_ASSERT_DEBUG(in + copy_count <= pXImage->data + xDataLineSkip * height);
+ __builtin_memcpy(bufPtr, in, copy_count);
}
success = true;
}
{
DALI_LOG_ERROR("Failed to get pixels from NativeImageSource.\n");
pixbuf.resize(0);
- width = 0;
+ width = 0;
height = 0;
}
// Close the display connection
- XCloseDisplay( displayConnection );
+ XCloseDisplay(displayConnection);
return success;
}
-void NativeImageSourceX::SetSource( Any source )
+void NativeImageSourceX::SetSource(Any source)
{
- mPixmap = GetPixmapFromAny( source );
+ mPixmap = GetPixmapFromAny(source);
- if (mPixmap)
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
}
}
-bool NativeImageSourceX::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceX::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
{
return true;
}
bool NativeImageSourceX::CreateResource()
{
// if the image existed previously delete it.
- if (mEglImageKHR != NULL)
+ if(mEglImageKHR != NULL)
{
DestroyResource();
}
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
- EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
+ EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mPixmap);
- mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
+ mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
return mEglImageKHR != NULL;
}
int NativeImageSourceX::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
{
- switch (depth)
+ switch(depth)
{
case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
{
Ecore_X_Pixmap NativeImageSourceX::GetPixmapFromAny(Any pixmap) const
{
- if (pixmap.Empty())
+ if(pixmap.Empty())
{
return 0;
}
// see if it is of type x11 pixmap
- if (pixmap.GetType() == typeid (Pixmap))
+ if(pixmap.GetType() == typeid(Pixmap))
{
// get the x pixmap type
Pixmap xpixmap = AnyCast<Pixmap>(pixmap);
int x, y;
// get the width, height and depth
- ecore_x_pixmap_geometry_get( mPixmap, &x, &y, reinterpret_cast< int* >( &mWidth ), reinterpret_cast< int* >( &mHeight ) );
+ ecore_x_pixmap_geometry_get(mPixmap, &x, &y, reinterpret_cast<int*>(&mWidth), reinterpret_cast<int*>(&mHeight));
// set whether blending is required according to pixel format based on the depth
/* default pixel format is RGB888
If depth = 8, Pixel::A8;
If depth = 16, Pixel::RGB565;
If depth = 32, Pixel::RGBA8888 */
- int depth = ecore_x_pixmap_depth_get(mPixmap);
- mBlendingRequired = ( depth == 32 || depth == 8 );
+ int depth = ecore_x_pixmap_depth_get(mPixmap);
+ mBlendingRequired = (depth == 32 || depth == 8);
}
-uint8_t* NativeImageSourceX::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+uint8_t* NativeImageSourceX::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
{
return NULL;
}
-
bool NativeImageSourceX::ReleaseBuffer()
{
return false;
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 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.
#include <dali/integration-api/gl-defines.h>
// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-#define TBM_SURFACE_QUEUE_SIZE 3
+#define TBM_SURFACE_QUEUE_SIZE 3
const char* FRAGMENT_PREFIX = "\n";
-const char* SAMPLER_TYPE = "sampler2D";
+const char* SAMPLER_TYPE = "sampler2D";
-}
+} // namespace
-NativeImageSourceQueueX* NativeImageSourceQueueX::New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+NativeImageSourceQueueX* NativeImageSourceQueueX::New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- NativeImageSourceQueueX* image = new NativeImageSourceQueueX( width, height, depth, nativeImageSourceQueue );
+ NativeImageSourceQueueX* image = new NativeImageSourceQueueX(width, height, depth, nativeImageSourceQueue);
return image;
}
-NativeImageSourceQueueX::NativeImageSourceQueueX( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
-: mWidth( width ),
- mHeight( height )
+NativeImageSourceQueueX::NativeImageSourceQueueX(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
+: mWidth(width),
+ mHeight(height)
{
- DALI_LOG_ERROR( "NativeImageSourceQueueX::NativeImageSourceQueueX: Not supported\n" );
+ DALI_LOG_ERROR("NativeImageSourceQueueX::NativeImageSourceQueueX: Not supported\n");
}
NativeImageSourceQueueX::~NativeImageSourceQueueX()
return Any();
}
-void NativeImageSourceQueueX::SetSize( uint32_t width, uint32_t height )
+void NativeImageSourceQueueX::SetSize(uint32_t width, uint32_t height)
{
- mWidth = width;
+ mWidth = width;
mHeight = height;
}
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*\r
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*/\r
\r
// EXTERNAL INCLUDES\r
-#include <string>\r
#include <curl/curl.h>\r
+#include <string>\r
\r
#undef TRANSPARENT\r
#undef CopyMemory\r
\r
// INTERNAL INCLUDES\r
-#include <dali/internal/imaging/common/file-download.h>\r
#include <dali/integration-api/debug.h>\r
+#include <dali/internal/imaging/common/file-download.h>\r
#include <dali/internal/system/common/file-closer.h>\r
#include <dali/internal/window-system/windows/platform-implement-win.h>\r
\r
namespace Dali\r
{\r
-\r
namespace TizenPlatform\r
{\r
-\r
-const int CONNECTION_TIMEOUT_SECONDS( 30L );\r
-const long VERBOSE_MODE = 0L; // 0 == off, 1 == on\r
-const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on\r
-const long EXCLUDE_HEADER = 0L;\r
-const long INCLUDE_HEADER = 1L;\r
-const long INCLUDE_BODY = 0L;\r
-const long EXCLUDE_BODY = 1L;\r
+const int CONNECTION_TIMEOUT_SECONDS(30L);\r
+const long VERBOSE_MODE = 0L; // 0 == off, 1 == on\r
+const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on\r
+const long EXCLUDE_HEADER = 0L;\r
+const long INCLUDE_HEADER = 1L;\r
+const long INCLUDE_BODY = 0L;\r
+const long EXCLUDE_BODY = 1L;\r
\r
namespace Network\r
{\r
-\r
-}\r
-}\r
}\r
+} // namespace TizenPlatform\r
+} // namespace Dali\r
/*
- * Copyright (c) 2018 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.
#include <dali/internal/imaging/common/file-download.h>
// EXTERNAL INCLUDES
+#include <curl/curl.h>
#include <dali/integration-api/debug.h>
#include <pthread.h>
#include <cstring>
-#include <curl/curl.h>
// INTERNAL INCLUDES
#include <dali/internal/system/common/file-writer.h>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace // unnamed namespace
{
-
-const int CONNECTION_TIMEOUT_SECONDS( 30L );
-const long VERBOSE_MODE = 0L; // 0 == off, 1 == on
-const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on
-const long EXCLUDE_HEADER = 0L;
-const long INCLUDE_HEADER = 1L;
-const long INCLUDE_BODY = 0L;
-const long EXCLUDE_BODY = 1L;
+const int CONNECTION_TIMEOUT_SECONDS(30L);
+const long VERBOSE_MODE = 0L; // 0 == off, 1 == on
+const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on
+const long EXCLUDE_HEADER = 0L;
+const long INCLUDE_HEADER = 1L;
+const long INCLUDE_BODY = 0L;
+const long EXCLUDE_BODY = 1L;
/**
* Curl library environment. Direct initialize ensures it's constructed before adaptor
// Without a write function or a buffer (file descriptor) to write to, curl will pump out
// header/body contents to stdout
-size_t __cdecl DummyWrite(char *ptr, size_t size, size_t nmemb, void *userdata)
+size_t __cdecl DummyWrite(char* ptr, size_t size, size_t nmemb, void* userdata)
{
return size * nmemb;
}
struct ChunkData
{
- std::vector< uint8_t > data;
+ std::vector<uint8_t> data;
};
-size_t __cdecl ChunkLoader(char *ptr, size_t size, size_t nmemb, void *userdata)
+size_t __cdecl ChunkLoader(char* ptr, size_t size, size_t nmemb, void* userdata)
{
- std::vector<ChunkData>* chunks = static_cast<std::vector<ChunkData>*>( userdata );
- int numBytes = size*nmemb;
- if( chunks != nullptr )
+ std::vector<ChunkData>* chunks = static_cast<std::vector<ChunkData>*>(userdata);
+ int numBytes = size * nmemb;
+ if(chunks != nullptr)
{
- chunks->push_back( ChunkData() );
- ChunkData& chunkData = (*chunks)[chunks->size()-1];
- chunkData.data.reserve( numBytes );
- memcpy( chunkData.data.data(), ptr, numBytes );
+ chunks->push_back(ChunkData());
+ ChunkData& chunkData = (*chunks)[chunks->size() - 1];
+ chunkData.data.reserve(numBytes);
+ memcpy(chunkData.data.data(), ptr, numBytes);
}
return numBytes;
}
-static size_t __cdecl WriteFunction( void *input, size_t uSize, size_t uCount, void *avg )
+static size_t __cdecl WriteFunction(void* input, size_t uSize, size_t uCount, void* avg)
{
- fwrite( (const char*)input, uSize, uCount, (FILE*)avg );
+ fwrite((const char*)input, uSize, uCount, (FILE*)avg);
return uSize * uCount;
}
-void InitWriteFunction( void* curlHandle )
+void InitWriteFunction(void* curlHandle)
{
- curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, WriteFunction );
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, WriteFunction);
}
-CURLcode DownloadFileDataWithSize( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t dataSize )
+CURLcode DownloadFileDataWithSize(CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t dataSize)
{
- CURLcode result( CURLE_OK );
+ CURLcode result(CURLE_OK);
// create
- Dali::Internal::Platform::FileWriter fileWriter( dataBuffer, dataSize );
- FILE* dataBufferFilePointer = fileWriter.GetFile();
- if( nullptr != dataBufferFilePointer )
+ Dali::Internal::Platform::FileWriter fileWriter(dataBuffer, dataSize);
+ FILE* dataBufferFilePointer = fileWriter.GetFile();
+ if(nullptr != dataBufferFilePointer)
{
// we only want the body which contains the file data
- curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
- curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+ curl_easy_setopt(curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER);
+ curl_easy_setopt(curlHandle, CURLOPT_NOBODY, INCLUDE_BODY);
// disable the write callback, and get curl to write directly into our data buffer
- InitWriteFunction( curlHandle );
+ InitWriteFunction(curlHandle);
- curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer );
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer);
// synchronous request of the body data
- result = curl_easy_perform( curlHandle );
+ result = curl_easy_perform(curlHandle);
}
return result;
}
-CURLcode DownloadFileDataByChunk( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize )
+CURLcode DownloadFileDataByChunk(CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize)
{
// create
- std::vector< ChunkData > chunks;
+ std::vector<ChunkData> chunks;
// we only want the body which contains the file data
- curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
- curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+ curl_easy_setopt(curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER);
+ curl_easy_setopt(curlHandle, CURLOPT_NOBODY, INCLUDE_BODY);
// Enable the write callback.
- curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader );
- curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, &chunks );
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader);
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, &chunks);
// synchronous request of the body data
- CURLcode result = curl_easy_perform( curlHandle );
+ CURLcode result = curl_easy_perform(curlHandle);
// chunks should now contain all of the chunked data. Reassemble into a single vector
dataSize = 0;
- for( size_t i=0; i<chunks.size() ; ++i )
+ for(size_t i = 0; i < chunks.size(); ++i)
{
dataSize += chunks[i].data.capacity();
}
dataBuffer.Resize(dataSize);
size_t offset = 0;
- for( size_t i=0; i<chunks.size() ; ++i )
+ for(size_t i = 0; i < chunks.size(); ++i)
{
- memcpy( &dataBuffer[offset], chunks[i].data.data(), chunks[i].data.capacity() );
+ memcpy(&dataBuffer[offset], chunks[i].data.data(), chunks[i].data.capacity());
offset += chunks[i].data.capacity();
}
return result;
}
-void ConfigureCurlOptions( void* curlHandle, const std::string& url )
+void ConfigureCurlOptions(void* curlHandle, const std::string& url)
{
- curl_easy_setopt( curlHandle, CURLOPT_URL, url.c_str() );
+ curl_easy_setopt(curlHandle, CURLOPT_URL, url.c_str());
//curl_easy_setopt( curlHandle, CURLOPT_VERBOSE, VERBOSE_MODE );
- curl_easy_setopt( curlHandle, CURLOPT_PROXY, "109.123.100.31:3128" );
+ curl_easy_setopt(curlHandle, CURLOPT_PROXY, "109.123.100.31:3128");
// CURLOPT_FAILONERROR is not fail-safe especially when authentication is involved ( see manual )
// Removed CURLOPT_FAILONERROR option
- curl_easy_setopt( curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS );
- curl_easy_setopt( curlHandle, CURLOPT_HEADER, INCLUDE_HEADER );
- curl_easy_setopt( curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY );
+ curl_easy_setopt(curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS);
+ curl_easy_setopt(curlHandle, CURLOPT_HEADER, INCLUDE_HEADER);
+ curl_easy_setopt(curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY);
}
-bool DownloadFile( CURL* curlHandle,
- const std::string& url,
- Dali::Vector<uint8_t>& dataBuffer,
- size_t& dataSize,
- size_t maximumAllowedSizeBytes )
+bool DownloadFile(CURL* curlHandle,
+ const std::string& url,
+ Dali::Vector<uint8_t>& dataBuffer,
+ size_t& dataSize,
+ size_t maximumAllowedSizeBytes)
{
- CURLcode result( CURLE_OK );
- double size(0);
+ CURLcode result(CURLE_OK);
+ double size(0);
// setup curl to download just the header so we can extract the content length
- ConfigureCurlOptions( curlHandle, url );
+ ConfigureCurlOptions(curlHandle, url);
- curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, DummyWrite);
+ curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, DummyWrite);
// perform the request to get the header
- result = curl_easy_perform( curlHandle );
+ result = curl_easy_perform(curlHandle);
- if( result != CURLE_OK)
+ if(result != CURLE_OK)
{
- DALI_LOG_ERROR( "Failed to download http header for \"%s\" with error code %d\n", url.c_str(), result );
+ DALI_LOG_ERROR("Failed to download http header for \"%s\" with error code %d\n", url.c_str(), result);
return false;
}
// get the content length, -1 == size is not known
- curl_easy_getinfo( curlHandle,CURLINFO_CONTENT_LENGTH_DOWNLOAD , &size );
+ curl_easy_getinfo(curlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &size);
-
- if( size >= maximumAllowedSizeBytes )
+ if(size >= maximumAllowedSizeBytes)
{
- DALI_LOG_ERROR( "File content length %f > max allowed %zu \"%s\" \n", size, maximumAllowedSizeBytes, url.c_str() );
+ DALI_LOG_ERROR("File content length %f > max allowed %zu \"%s\" \n", size, maximumAllowedSizeBytes, url.c_str());
return false;
}
- else if( size > 0 )
+ else if(size > 0)
{
// If we know the size up front, allocate once and avoid chunk copies.
- dataSize = static_cast<size_t>( size );
- result = DownloadFileDataWithSize( curlHandle, dataBuffer, dataSize );
+ dataSize = static_cast<size_t>(size);
+ result = DownloadFileDataWithSize(curlHandle, dataBuffer, dataSize);
}
else
{
- result = DownloadFileDataByChunk( curlHandle, dataBuffer, dataSize );
+ result = DownloadFileDataByChunk(curlHandle, dataBuffer, dataSize);
}
- if( result != CURLE_OK )
+ if(result != CURLE_OK)
{
- DALI_LOG_ERROR( "Failed to download image file \"%s\" with error code %d\n", url.c_str(), result );
+ DALI_LOG_ERROR("Failed to download image file \"%s\" with error code %d\n", url.c_str(), result);
return false;
}
return true;
}
-
} // unnamed namespace
-
namespace Network
{
-
CurlEnvironment::CurlEnvironment()
{
// Must be called before we attempt any loads. e.g. by using curl_easy_init()
curl_global_cleanup();
}
-bool DownloadRemoteFileIntoMemory( const std::string& url,
- Dali::Vector<uint8_t>& dataBuffer,
- size_t& dataSize,
- size_t maximumAllowedSizeBytes )
+bool DownloadRemoteFileIntoMemory(const std::string& url,
+ Dali::Vector<uint8_t>& dataBuffer,
+ size_t& dataSize,
+ size_t maximumAllowedSizeBytes)
{
- if( url.empty() )
+ if(url.empty())
{
DALI_LOG_WARNING("empty url requested \n");
return false;
CURL* curlHandle = curl_easy_init();
- bool result = DownloadFile( curlHandle, url, dataBuffer, dataSize, maximumAllowedSizeBytes);
+ bool result = DownloadFile(curlHandle, url, dataBuffer, dataSize, maximumAllowedSizeBytes);
// clean up session
- curl_easy_cleanup( curlHandle );
+ curl_easy_cleanup(curlHandle);
return result;
}
/*
- * Copyright (c) 2018 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.
#include <dali/internal/imaging/windows/native-image-source-factory-win.h>
// INTERNAL HEADERS
-#include <dali/internal/imaging/windows/native-image-source-impl-win.h>
#include <dali/internal/imaging/common/native-image-source-queue-impl.h>
+#include <dali/internal/imaging/windows/native-image-source-impl-win.h>
namespace Dali
{
{
namespace Adaptor
{
-
-std::unique_ptr< NativeImageSource > NativeImageSourceFactoryWin::CreateNativeImageSource( unsigned int width, unsigned int height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+std::unique_ptr<NativeImageSource> NativeImageSourceFactoryWin::CreateNativeImageSource(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- return std::unique_ptr< NativeImageSource >( NativeImageSourceWin::New( width, height, depth, nativeImageSource ) );
+ return std::unique_ptr<NativeImageSource>(NativeImageSourceWin::New(width, height, depth, nativeImageSource));
}
-std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryWin::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+std::unique_ptr<NativeImageSourceQueue> NativeImageSourceFactoryWin::CreateNativeImageSourceQueue(unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue)
{
- return std::unique_ptr< NativeImageSourceQueue >( nullptr );
+ return std::unique_ptr<NativeImageSourceQueue>(nullptr);
}
// this should be created from somewhere
-std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
{
// returns native image source factory
- return std::unique_ptr< NativeImageSourceFactoryWin >( new NativeImageSourceFactoryWin() );
+ return std::unique_ptr<NativeImageSourceFactoryWin>(new NativeImageSourceFactoryWin());
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/window-system/windows/platform-implement-win.h>
-#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
using Dali::Integration::PixelBuffer;
-NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
{
- NativeImageSourceWin* image = new NativeImageSourceWin( width, height, depth, nativeImageSource );
- DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
+ NativeImageSourceWin* image = new NativeImageSourceWin(width, height, depth, nativeImageSource);
+ DALI_ASSERT_DEBUG(image && "NativeImageSource allocation failed.");
// 2nd phase construction
if(image) //< Defensive in case we ever compile without exceptions.
return image;
}
-NativeImageSourceWin::NativeImageSourceWin( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
-: mWidth( width ),
- mHeight( height ),
- mOwnPixmap( true ),
- mPixmap( 0 ),
- mBlendingRequired( false ),
- mColorDepth( depth ),
- mEglImageKHR( NULL ),
- mEglImageExtensions( NULL )
+NativeImageSourceWin::NativeImageSourceWin(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
+: mWidth(width),
+ mHeight(height),
+ mOwnPixmap(true),
+ mPixmap(0),
+ mBlendingRequired(false),
+ mColorDepth(depth),
+ mEglImageKHR(NULL),
+ mEglImageExtensions(NULL)
{
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- auto eglGraphics = static_cast<EglGraphics *>(graphics);
+ GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+ auto eglGraphics = static_cast<EglGraphics*>(graphics);
mEglImageExtensions = eglGraphics->GetImageExtensions();
- DALI_ASSERT_DEBUG( mEglImageExtensions );
+ DALI_ASSERT_DEBUG(mEglImageExtensions);
// assign the pixmap
mPixmap = GetPixmapFromAny(nativeImageSource);
void NativeImageSourceWin::Initialize()
{
// if pixmap has been created outside of Windows Image we can return
- if (mPixmap)
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
If depth = 8, Pixel::A8;
If depth = 16, Pixel::RGB565;
If depth = 32, Pixel::RGBA8888 */
- mBlendingRequired = ( depth == 32 || depth == 8 );
+ mBlendingRequired = (depth == 32 || depth == 8);
}
NativeImageSourceWin::~NativeImageSourceWin()
{
DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
bool success = false;
- width = mWidth;
- height = mHeight;
+ width = mWidth;
+ height = mHeight;
return success;
}
-void NativeImageSourceWin::SetSource( Any source )
+void NativeImageSourceWin::SetSource(Any source)
{
- mPixmap = GetPixmapFromAny( source );
+ mPixmap = GetPixmapFromAny(source);
- if (mPixmap)
+ if(mPixmap)
{
// we don't own the pixmap
mOwnPixmap = false;
}
}
-bool NativeImageSourceWin::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceWin::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
{
return true;
}
bool NativeImageSourceWin::CreateResource()
{
// if the image existed previously delete it.
- if (mEglImageKHR != NULL)
+ if(mEglImageKHR != NULL)
{
DestroyResource();
}
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
- EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
+ EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mPixmap);
- mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
+ mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
return mEglImageKHR != NULL;
}
int NativeImageSourceWin::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
{
- switch (depth)
+ switch(depth)
{
case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
{
unsigned int NativeImageSourceWin::GetPixmapFromAny(Any pixmap) const
{
- if (pixmap.Empty())
+ if(pixmap.Empty())
{
return 0;
}
// see if it is of type Windows pixmap
- if (pixmap.GetType() == typeid ( unsigned int ))
+ if(pixmap.GetType() == typeid(unsigned int))
{
// get the Windows pixmap type
unsigned int xpixmap = AnyCast<unsigned int>(pixmap);
return false;
}
-uint8_t* NativeImageSourceWin::AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride )
+uint8_t* NativeImageSourceWin::AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride)
{
return NULL;
}
-
bool NativeImageSourceWin::ReleaseBuffer()
{
return false;
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 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.
*
*/
-#include <dali/internal/input/common/input-method-context-impl.h>
+#include <dali/devel-api/common/singleton-service.h>
#include <dali/internal/input/common/input-method-context-factory.h>
+#include <dali/internal/input/common/input-method-context-impl.h>
#include <dali/internal/system/common/locale-utils.h>
-#include <dali/devel-api/common/singleton-service.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
-InputMethodContextPtr InputMethodContext::New( Dali::Actor actor )
+InputMethodContextPtr InputMethodContext::New(Dali::Actor actor)
{
- return Dali::Internal::Adaptor::InputMethodContextFactory::CreateInputMethodContext( actor );
+ return Dali::Internal::Adaptor::InputMethodContextFactory::CreateInputMethodContext(actor);
}
const std::string& InputMethodContext::GetSurroundingText() const
}
InputMethodContext::InputMethodContext()
-: mBackupOperations( Operation::MAX_COUNT )
+: mBackupOperations(Operation::MAX_COUNT)
{
}
// Items in mBackupOperations will be changed while the iteration
OperationList copiedList = mBackupOperations;
- for( auto& operation : copiedList )
+ for(auto& operation : copiedList)
{
- if( operation )
+ if(operation)
{
operation();
}
}
}
-}
-}
-}
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace KeyGrab
{
-
-bool GrabKeyTopmost( Window window, Dali::KEY daliKey )
+bool GrabKeyTopmost(Window window, Dali::KEY daliKey)
{
- Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( window );
- return windowImpl.GrabKey( daliKey, TOPMOST );
+ Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+ return windowImpl.GrabKey(daliKey, TOPMOST);
}
-bool UngrabKeyTopmost( Window window, Dali::KEY daliKey )
+bool UngrabKeyTopmost(Window window, Dali::KEY daliKey)
{
- Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( window );
- return windowImpl.UngrabKey( daliKey );
+ Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+ return windowImpl.UngrabKey(daliKey);
}
-bool GrabKey( Window window, Dali::KEY daliKey, KeyGrabMode grabMode )
+bool GrabKey(Window window, Dali::KEY daliKey, KeyGrabMode grabMode)
{
- Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( window );
- return windowImpl.GrabKey( daliKey, grabMode );
+ Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+ return windowImpl.GrabKey(daliKey, grabMode);
}
-
-bool UngrabKey( Window window, Dali::KEY daliKey )
+bool UngrabKey(Window window, Dali::KEY daliKey)
{
- Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( window );
- return windowImpl.UngrabKey( daliKey );
+ Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+ return windowImpl.UngrabKey(daliKey);
}
-
-bool GrabKeyList( Window window, const Dali::Vector<Dali::KEY>& daliKeyVector, const Dali::Vector<KeyGrabMode>& grabModeVector, Dali::Vector<bool>& returnVector)
+bool GrabKeyList(Window window, const Dali::Vector<Dali::KEY>& daliKeyVector, const Dali::Vector<KeyGrabMode>& grabModeVector, Dali::Vector<bool>& returnVector)
{
- Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( window );
- return windowImpl.GrabKeyList( daliKeyVector, grabModeVector, returnVector );
+ Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+ return windowImpl.GrabKeyList(daliKeyVector, grabModeVector, returnVector);
}
-bool UngrabKeyList( Window window, const Dali::Vector<Dali::KEY>& daliKeyVector, Dali::Vector<bool>& returnVector)
+bool UngrabKeyList(Window window, const Dali::Vector<Dali::KEY>& daliKeyVector, Dali::Vector<bool>& returnVector)
{
- Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( window );
- return windowImpl.UngrabKeyList( daliKeyVector, returnVector );
+ Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+ return windowImpl.UngrabKeyList(daliKeyVector, returnVector);
}
} // namespace KeyGrab
} // namespace Dali
-
/*
- * 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.
// EXTERNAL INCLUDES
#include <dlfcn.h>
-#include <map>
#include <string.h>
#include <iostream>
+#include <map>
#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace KeyLookup
{
-
namespace
{
#if defined(DEBUG_ENABLED)
#endif
// Path for loading extension keys
-const char* KEY_EXTENSION_PLUGIN_SO( "libdali2-key-extension.so" );
+const char* KEY_EXTENSION_PLUGIN_SO("libdali2-key-extension.so");
class KeyMap
{
- public:
-
- KeyMap():
- mExtensionKeyLookupTable(NULL),
- mPlugin(NULL),
- mHandle(NULL),
- mCreateKeyExtensionPluginPtr(NULL),
- mDestroyKeyExtensionPluginPtr(NULL),
- mLookup( cmpString ),
- mExtensionLookup( cmpString ),
- mExtensionLookupCount(0),
- mIsLookupTableInitialized( false ),
- mIsExtensionLookupTableInitialized( false )
+public:
+ KeyMap()
+ : mExtensionKeyLookupTable(NULL),
+ mPlugin(NULL),
+ mHandle(NULL),
+ mCreateKeyExtensionPluginPtr(NULL),
+ mDestroyKeyExtensionPluginPtr(NULL),
+ mLookup(cmpString),
+ mExtensionLookup(cmpString),
+ mExtensionLookupCount(0),
+ mIsLookupTableInitialized(false),
+ mIsExtensionLookupTableInitialized(false)
{
}
~KeyMap()
{
- if( mHandle != NULL )
+ if(mHandle != NULL)
{
- if( mDestroyKeyExtensionPluginPtr != NULL )
+ if(mDestroyKeyExtensionPluginPtr != NULL)
{
- mDestroyKeyExtensionPluginPtr( mPlugin );
+ mDestroyKeyExtensionPluginPtr(mPlugin);
}
- dlclose( mHandle );
+ dlclose(mHandle);
}
}
- int GetDaliKeyEnum( const char* keyName )
+ int GetDaliKeyEnum(const char* keyName)
{
// If lookup table is not initialized, initialize lookup table
- if( !mIsLookupTableInitialized )
+ if(!mIsLookupTableInitialized)
{
InitializeLookupTable();
}
- Lookup::const_iterator i = mLookup.find( keyName );
+ Lookup::const_iterator i = mLookup.find(keyName);
- if( i == mLookup.end() )
+ if(i == mLookup.end())
{
// If cannot find target, find it at the extension
// If extension lookup table is not initialized, initialize extension lookup table
- if( !mIsExtensionLookupTableInitialized )
+ if(!mIsExtensionLookupTableInitialized)
{
InitializeExtensionLookupTable();
}
// Find at extension
- i = mExtensionLookup.find( keyName );
+ i = mExtensionLookup.find(keyName);
- if( i == mExtensionLookup.end() )
+ if(i == mExtensionLookup.end())
{
return -1;
}
}
}
- const char* GetKeyName( int daliKeyCode )
+ const char* GetKeyName(int daliKeyCode)
{
// If lookup table is not initialized, initialize lookup table
- if( !mIsLookupTableInitialized )
+ if(!mIsLookupTableInitialized)
{
InitializeLookupTable();
}
- for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
+ for(size_t i = 0; i < KEY_LOOKUP_COUNT; ++i)
{
- if( KeyLookupTable[i].daliKeyCode == daliKeyCode )
+ if(KeyLookupTable[i].daliKeyCode == daliKeyCode)
{
return KeyLookupTable[i].keyName;
}
}
// If extension lookup table is not initialized, initialize extension lookup table
- if( !mIsExtensionLookupTableInitialized )
+ if(!mIsExtensionLookupTableInitialized)
{
InitializeExtensionLookupTable();
}
- for( size_t i = 0; i < mExtensionLookupCount ; ++i )
+ for(size_t i = 0; i < mExtensionLookupCount; ++i)
{
- if( mExtensionKeyLookupTable[i].daliKeyCode == daliKeyCode )
+ if(mExtensionKeyLookupTable[i].daliKeyCode == daliKeyCode)
{
return mExtensionKeyLookupTable[i].keyName;
}
return NULL;
}
- bool IsDeviceButton( const char* keyName )
+ bool IsDeviceButton(const char* keyName)
{
// If lookup table is not initialized, initialize lookup table
- if( !mIsLookupTableInitialized )
+ if(!mIsLookupTableInitialized)
{
InitializeLookupTable();
}
- Lookup::const_iterator i = mLookup.find( keyName );
- if( i == mLookup.end() )
+ Lookup::const_iterator i = mLookup.find(keyName);
+ if(i == mLookup.end())
{
// If cannot find target, find it at the extension.
// If extension lookup table is not initialized, initialize extension lookup table
- if( !mIsExtensionLookupTableInitialized )
+ if(!mIsExtensionLookupTableInitialized)
{
InitializeExtensionLookupTable();
}
// Find at extension
- i = mExtensionLookup.find( keyName );
+ i = mExtensionLookup.find(keyName);
- if( i == mExtensionLookup.end() )
+ if(i == mExtensionLookup.end())
{
return false;
}
return false;
}
-
- private:
-
+private:
void InitializeLookupTable()
{
// create the lookup
- for( size_t i = 0; i < KEY_LOOKUP_COUNT ; ++i )
+ for(size_t i = 0; i < KEY_LOOKUP_COUNT; ++i)
{
- mLookup[ KeyLookupTable[i].keyName ] = DaliKeyType( KeyLookupTable[i].daliKeyCode, KeyLookupTable[i].deviceButton );
+ mLookup[KeyLookupTable[i].keyName] = DaliKeyType(KeyLookupTable[i].daliKeyCode, KeyLookupTable[i].deviceButton);
}
mIsLookupTableInitialized = true;
{
// Try to load extension keys
char* error = NULL;
- mHandle = dlopen( KEY_EXTENSION_PLUGIN_SO, RTLD_NOW );
- error = dlerror();
+ mHandle = dlopen(KEY_EXTENSION_PLUGIN_SO, RTLD_NOW);
+ error = dlerror();
- if( mHandle == NULL )
+ if(mHandle == NULL)
{
- DALI_LOG_INFO( gKeyExtensionLogFilter, Debug::General, "Failed to get handle from libdali2-key-extension.so\n" );
+ DALI_LOG_INFO(gKeyExtensionLogFilter, Debug::General, "Failed to get handle from libdali2-key-extension.so\n");
return;
}
- if( error != NULL )
+ if(error != NULL)
{
- DALI_LOG_INFO( gKeyExtensionLogFilter, Debug::General, "dlopen got error: %s \n", error );
+ DALI_LOG_INFO(gKeyExtensionLogFilter, Debug::General, "dlopen got error: %s \n", error);
return;
}
- mCreateKeyExtensionPluginPtr = reinterpret_cast< CreateKeyExtensionPluginFunction >( dlsym( mHandle, "CreateKeyExtensionPlugin" ) );
- if( mCreateKeyExtensionPluginPtr == NULL )
+ mCreateKeyExtensionPluginPtr = reinterpret_cast<CreateKeyExtensionPluginFunction>(dlsym(mHandle, "CreateKeyExtensionPlugin"));
+ if(mCreateKeyExtensionPluginPtr == NULL)
{
- DALI_LOG_INFO( gKeyExtensionLogFilter, Debug::General, "Failed to get CreateKeyExtensionPlugin function\n" );
+ DALI_LOG_INFO(gKeyExtensionLogFilter, Debug::General, "Failed to get CreateKeyExtensionPlugin function\n");
return;
}
mPlugin = mCreateKeyExtensionPluginPtr();
- if( mPlugin == NULL )
+ if(mPlugin == NULL)
{
- DALI_LOG_INFO( gKeyExtensionLogFilter, Debug::General, "Failed to create plugin object\n" );
+ DALI_LOG_INFO(gKeyExtensionLogFilter, Debug::General, "Failed to create plugin object\n");
return;
}
- mDestroyKeyExtensionPluginPtr = reinterpret_cast< DestroyKeyExtensionPluginFunction >( dlsym( mHandle, "DestroyKeyExtensionPlugin" ) );
- if( mDestroyKeyExtensionPluginPtr == NULL )
+ mDestroyKeyExtensionPluginPtr = reinterpret_cast<DestroyKeyExtensionPluginFunction>(dlsym(mHandle, "DestroyKeyExtensionPlugin"));
+ if(mDestroyKeyExtensionPluginPtr == NULL)
{
- DALI_LOG_INFO( gKeyExtensionLogFilter, Debug::General, "Failed to get DestroyKeyExtensionPlugin function\n" );
+ DALI_LOG_INFO(gKeyExtensionLogFilter, Debug::General, "Failed to get DestroyKeyExtensionPlugin function\n");
return;
}
mExtensionKeyLookupTable = mPlugin->GetKeyLookupTable();
- mExtensionLookupCount = mPlugin->GetKeyLookupTableCount();
+ mExtensionLookupCount = mPlugin->GetKeyLookupTableCount();
// Add extension keys to lookup
- for( size_t i = 0; i < mExtensionLookupCount ; ++i )
+ for(size_t i = 0; i < mExtensionLookupCount; ++i)
{
- mExtensionLookup[ mExtensionKeyLookupTable[i].keyName ] = DaliKeyType( mExtensionKeyLookupTable[i].daliKeyCode, mExtensionKeyLookupTable[i].deviceButton );
+ mExtensionLookup[mExtensionKeyLookupTable[i].keyName] = DaliKeyType(mExtensionKeyLookupTable[i].daliKeyCode, mExtensionKeyLookupTable[i].deviceButton);
}
mIsExtensionLookupTableInitialized = true;
/**
* compare function, to compare string by pointer
*/
- static bool cmpString( const char* a, const char* b)
+ static bool cmpString(const char* a, const char* b)
{
return strcmp(a, b) < 0;
}
- KeyExtensionPlugin::KeyLookup* mExtensionKeyLookupTable; ///< Lookup table for extension keys
- Dali::KeyExtensionPlugin* mPlugin; ///< Key extension plugin handle
- void* mHandle; ///< Handle for the loaded library
- typedef Dali::KeyExtensionPlugin* (*CreateKeyExtensionPluginFunction)(); ///< Type of function pointer to get KeyExtensionPlugin object
- typedef void (*DestroyKeyExtensionPluginFunction)( Dali::KeyExtensionPlugin* plugin ); ///< Type of function pointer to delete KeyExtensionPlugin object
- CreateKeyExtensionPluginFunction mCreateKeyExtensionPluginPtr; ///< Function pointer to get KeyExtensionPlugin object
- DestroyKeyExtensionPluginFunction mDestroyKeyExtensionPluginPtr; ///< Function pointer to delete KeyExtensionPlugin object
+ KeyExtensionPlugin::KeyLookup* mExtensionKeyLookupTable; ///< Lookup table for extension keys
+ Dali::KeyExtensionPlugin* mPlugin; ///< Key extension plugin handle
+ void* mHandle; ///< Handle for the loaded library
+ typedef Dali::KeyExtensionPlugin* (*CreateKeyExtensionPluginFunction)(); ///< Type of function pointer to get KeyExtensionPlugin object
+ typedef void (*DestroyKeyExtensionPluginFunction)(Dali::KeyExtensionPlugin* plugin); ///< Type of function pointer to delete KeyExtensionPlugin object
+ CreateKeyExtensionPluginFunction mCreateKeyExtensionPluginPtr; ///< Function pointer to get KeyExtensionPlugin object
+ DestroyKeyExtensionPluginFunction mDestroyKeyExtensionPluginPtr; ///< Function pointer to delete KeyExtensionPlugin object
+
+ typedef std::pair<int, bool> DaliKeyType;
+
+ typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool (*)(char const* a, char const* b)> Lookup;
- typedef std::pair< int, bool > DaliKeyType;
- typedef std::map<const char* /* key name */, DaliKeyType /* key code */, bool(*) ( char const* a, char const* b) > Lookup;
Lookup mLookup;
Lookup mExtensionLookup;
- size_t mExtensionLookupCount; ///< count of extension lookup table
- bool mIsLookupTableInitialized; ///< flag for basic lookup table initialization
- bool mIsExtensionLookupTableInitialized; ///< flag for extension lookup table initialization
+ size_t mExtensionLookupCount; ///< count of extension lookup table
+ bool mIsLookupTableInitialized; ///< flag for basic lookup table initialization
+ bool mIsExtensionLookupTableInitialized; ///< flag for extension lookup table initialization
};
KeyMap globalKeyLookup;
-} // un-named name space
+} // namespace
-bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
+bool IsKey(const Dali::KeyEvent& keyEvent, Dali::KEY daliKey)
{
- int key = globalKeyLookup.GetDaliKeyEnum( keyEvent.GetKeyName().c_str() );
+ int key = globalKeyLookup.GetDaliKeyEnum(keyEvent.GetKeyName().c_str());
return daliKey == key;
}
-bool IsDeviceButton( const char* keyName )
+bool IsDeviceButton(const char* keyName)
{
- return globalKeyLookup.IsDeviceButton( keyName );
+ return globalKeyLookup.IsDeviceButton(keyName);
}
-const char* GetKeyName( Dali::KEY daliKey )
+const char* GetKeyName(Dali::KEY daliKey)
{
- return globalKeyLookup.GetKeyName( daliKey );
+ return globalKeyLookup.GetKeyName(daliKey);
}
-int GetDaliKeyCode( const char* keyName )
+int GetDaliKeyCode(const char* keyName)
{
- return globalKeyLookup.GetDaliKeyEnum( keyName );
+ return globalKeyLookup.GetDaliKeyEnum(keyName);
}
} // namespace KeyLookup
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Keyboard
{
-
-bool SetRepeatInfo( float rate, float delay )
+bool SetRepeatInfo(float rate, float delay)
{
- return Dali::Internal::Adaptor::WindowSystem::SetKeyboardRepeatInfo( rate, delay );
+ return Dali::Internal::Adaptor::WindowSystem::SetKeyboardRepeatInfo(rate, delay);
}
-bool GetRepeatInfo( float& rate, float& delay )
+bool GetRepeatInfo(float& rate, float& delay)
{
- return Dali::Internal::Adaptor::WindowSystem::GetKeyboardRepeatInfo( rate, delay );
+ return Dali::Internal::Adaptor::WindowSystem::GetKeyboardRepeatInfo(rate, delay);
}
} // namespace Keyboard
} // namespace Dali
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
Dali::PhysicalKeyboard PhysicalKeyboard::New()
{
Dali::PhysicalKeyboard keyboardHandle;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
- keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
- service.Register( typeid( keyboardHandle ), keyboardHandle );
+ keyboardHandle = Dali::PhysicalKeyboard(new PhysicalKeyboard());
+ service.Register(typeid(keyboardHandle), keyboardHandle);
}
return keyboardHandle;
Dali::PhysicalKeyboard keyboardHandle;
Dali::SingletonService service = SingletonService::Get();
- if ( service )
+ if(service)
{
- BaseHandle handle = service.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
- if( handle )
+ BaseHandle handle = service.GetSingleton(typeid(Dali::PhysicalKeyboard));
+ if(handle)
{
// If so, downcast the handle of singleton to focus manager
- keyboardHandle = Dali::PhysicalKeyboard( dynamic_cast< PhysicalKeyboard* >( handle.GetObjectPtr() ) );
+ keyboardHandle = Dali::PhysicalKeyboard(dynamic_cast<PhysicalKeyboard*>(handle.GetObjectPtr()));
}
}
return mAttached;
}
-void PhysicalKeyboard::KeyReceived( bool fromPhysicalKeyboard )
+void PhysicalKeyboard::KeyReceived(bool fromPhysicalKeyboard)
{
- if ( mAttached != fromPhysicalKeyboard )
+ if(mAttached != fromPhysicalKeyboard)
{
mAttached = fromPhysicalKeyboard;
- Dali::PhysicalKeyboard handle( this );
- mStatusChangedSignal.Emit( handle );
+ Dali::PhysicalKeyboard handle(this);
+ mStatusChangedSignal.Emit(handle);
}
}
}
PhysicalKeyboard::PhysicalKeyboard()
-: mAttached( false )
+: mAttached(false)
{
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class InputMethodContext;
namespace InputMethodContextFactory
{
-
// InputMethodContext Factory to be implemented by the platform
-InputMethodContextPtr CreateInputMethodContext( Dali::Actor actor )
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor)
{
- return Dali::Internal::Adaptor::InputMethodContextGeneric::New( actor );
+ return Dali::Internal::Adaptor::InputMethodContextGeneric::New(actor);
}
-}
+} // namespace InputMethodContextFactory
-}
+} // namespace Adaptor
-}
+} // namespace Internal
-}
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");
#endif
-}
+} // namespace
-InputMethodContextPtr InputMethodContextGeneric::New( Dali::Actor actor )
+InputMethodContextPtr InputMethodContextGeneric::New(Dali::Actor actor)
{
InputMethodContextPtr manager;
- if( actor && Dali::Adaptor::IsAvailable() )
+ if(actor && Dali::Adaptor::IsAvailable())
{
- manager = new InputMethodContextGeneric( actor );
+ manager = new InputMethodContextGeneric(actor);
}
return manager;
void InputMethodContextGeneric::Finalize()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::Finalize\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::Finalize\n");
DisconnectCallbacks();
}
-InputMethodContextGeneric::InputMethodContextGeneric( Dali::Actor actor )
+InputMethodContextGeneric::InputMethodContextGeneric(Dali::Actor actor)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::InputMethodContextGeneric\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::InputMethodContextGeneric\n");
Initialize();
}
void InputMethodContextGeneric::Initialize()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::Initialize\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::Initialize\n");
}
void InputMethodContextGeneric::ConnectCallbacks()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::ConnectCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::ConnectCallbacks\n");
}
void InputMethodContextGeneric::DisconnectCallbacks()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::DisconnectCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::DisconnectCallbacks\n");
}
void InputMethodContextGeneric::Activate()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::Activate\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::Activate\n");
}
void InputMethodContextGeneric::Deactivate()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::Deactivate\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::Deactivate\n");
}
void InputMethodContextGeneric::Reset()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::Reset\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::Reset\n");
}
ImfContext* InputMethodContextGeneric::GetContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetContext\n");
return nullptr;
}
bool InputMethodContextGeneric::RestoreAfterFocusLost() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::RestoreAfterFocusLost\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::RestoreAfterFocusLost\n");
return false;
}
-void InputMethodContextGeneric::SetRestoreAfterFocusLost( bool toggle )
+void InputMethodContextGeneric::SetRestoreAfterFocusLost(bool toggle)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetRestoreAfterFocusLost\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetRestoreAfterFocusLost\n");
}
-void InputMethodContextGeneric::PreEditChanged( void*, ImfContext* imfContext, void* event_info )
+void InputMethodContextGeneric::PreEditChanged(void*, ImfContext* imfContext, void* event_info)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::PreEditChanged\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::PreEditChanged\n");
}
-void InputMethodContextGeneric::CommitReceived( void*, ImfContext* imfContext, void* event_info )
+void InputMethodContextGeneric::CommitReceived(void*, ImfContext* imfContext, void* event_info)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::CommitReceived\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::CommitReceived\n");
}
-bool InputMethodContextGeneric::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )
+bool InputMethodContextGeneric::RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::RetrieveSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::RetrieveSurrounding\n");
return false;
}
-void InputMethodContextGeneric::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info )
+void InputMethodContextGeneric::DeleteSurrounding(void* data, ImfContext* imfContext, void* event_info)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::DeleteSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::DeleteSurrounding\n");
}
-void InputMethodContextGeneric::SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextGeneric::SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SendPrivateCommand\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SendPrivateCommand\n");
}
-void InputMethodContextGeneric::SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextGeneric::SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SendCommitContent\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SendCommitContent\n");
}
void InputMethodContextGeneric::NotifyCursorPosition()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::NotifyCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::NotifyCursorPosition\n");
}
-void InputMethodContextGeneric::SetCursorPosition( unsigned int cursorPosition )
+void InputMethodContextGeneric::SetCursorPosition(unsigned int cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetCursorPosition\n");
}
unsigned int InputMethodContextGeneric::GetCursorPosition() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetCursorPosition\n");
return 0;
}
-void InputMethodContextGeneric::SetSurroundingText( const std::string& text )
+void InputMethodContextGeneric::SetSurroundingText(const std::string& text)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetSurroundingText\n");
}
const std::string& InputMethodContextGeneric::GetSurroundingText() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetSurroundingText\n");
return "";
}
-void InputMethodContextGeneric::NotifyTextInputMultiLine( bool multiLine )
+void InputMethodContextGeneric::NotifyTextInputMultiLine(bool multiLine)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::NotifyTextInputMultiLine\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::NotifyTextInputMultiLine\n");
}
Dali::InputMethodContext::TextDirection InputMethodContextGeneric::GetTextDirection()
{
- Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT );
+ Dali::InputMethodContext::TextDirection direction(Dali::InputMethodContext::LEFT_TO_RIGHT);
return direction;
}
Rect<int> InputMethodContextGeneric::GetInputMethodArea()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputMethodArea\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputMethodArea\n");
int xPos, yPos, width, height;
width = height = xPos = yPos = 0;
- return Rect<int>(xPos,yPos,width,height);
+ return Rect<int>(xPos, yPos, width, height);
}
-void InputMethodContextGeneric::ApplyOptions( const InputMethodOptions& options )
+void InputMethodContextGeneric::ApplyOptions(const InputMethodOptions& options)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::ApplyOptions\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::ApplyOptions\n");
}
-void InputMethodContextGeneric::SetInputPanelData( const std::string& data )
+void InputMethodContextGeneric::SetInputPanelData(const std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetInputPanelData\n");
}
-void InputMethodContextGeneric::GetInputPanelData( std::string& data )
+void InputMethodContextGeneric::GetInputPanelData(std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputPanelData\n");
- data.assign( "" );
+ data.assign("");
}
Dali::InputMethodContext::State InputMethodContextGeneric::GetInputPanelState()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputPanelState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputPanelState\n");
return Dali::InputMethodContext::DEFAULT;
}
-void InputMethodContextGeneric::SetReturnKeyState( bool visible )
+void InputMethodContextGeneric::SetReturnKeyState(bool visible)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetReturnKeyState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetReturnKeyState\n");
}
-void InputMethodContextGeneric::AutoEnableInputPanel( bool enabled )
+void InputMethodContextGeneric::AutoEnableInputPanel(bool enabled)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::AutoEnableInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::AutoEnableInputPanel\n");
}
void InputMethodContextGeneric::ShowInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::ShowInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::ShowInputPanel\n");
}
void InputMethodContextGeneric::HideInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::HideInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::HideInputPanel\n");
}
Dali::InputMethodContext::KeyboardType InputMethodContextGeneric::GetKeyboardType()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetKeyboardType\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetKeyboardType\n");
return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD;
}
std::string InputMethodContextGeneric::GetInputPanelLocale()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputPanelLocale\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::GetInputPanelLocale\n");
std::string locale = "";
return locale;
}
-void InputMethodContextGeneric::SetContentMIMETypes( const std::string& mimeTypes )
+void InputMethodContextGeneric::SetContentMIMETypes(const std::string& mimeTypes)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetContentMIMETypes\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetContentMIMETypes\n");
}
-bool InputMethodContextGeneric::FilterEventKey( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextGeneric::FilterEventKey(const Dali::KeyEvent& keyEvent)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::FilterEventKey\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::FilterEventKey\n");
return false;
}
-void InputMethodContextGeneric::AllowTextPrediction( bool prediction )
+void InputMethodContextGeneric::AllowTextPrediction(bool prediction)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::AllowTextPrediction\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::AllowTextPrediction\n");
}
bool InputMethodContextGeneric::IsTextPredictionAllowed() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::IsTextPredictionAllowed\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::IsTextPredictionAllowed\n");
return false;
}
-void InputMethodContextGeneric::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )
+void InputMethodContextGeneric::SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextGeneric::SetInputPanelLanguage\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextGeneric::SetInputPanelLanguage\n");
}
Dali::InputMethodContext::InputPanelLanguage InputMethodContextGeneric::GetInputPanelLanguage() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLanguage\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLanguage\n");
return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
}
-void InputMethodContextGeneric::SetInputPanelPosition( unsigned int x, unsigned int y )
+void InputMethodContextGeneric::SetInputPanelPosition(unsigned int x, unsigned int y)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelPosition\n");
}
-void InputMethodContextGeneric::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const
+void InputMethodContextGeneric::GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n");
// Do Nothing
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace KeyLookup
{
-
// matches a DALI_KEY enum, to a key name
+// clang-format off
KeyLookup KeyLookupTable[]=
{
// more than one key name can be assigned to a single dali-key code
{ "Control_R", static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_RIGHT ), false },
{ "Return", static_cast<Dali::KEY>( DevelKey::DALI_KEY_RETURN ), false }
};
+// clang-format on
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup ));
+const std::size_t KEY_LOOKUP_COUNT = (sizeof(KeyLookupTable)) / (sizeof(KeyLookup));
} // namespace KeyLookup
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace VirtualKeyboard
{
-
namespace
{
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");
#endif
-}
+} // namespace
void Show()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::Show\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::Show\n");
}
void Hide()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::Hide\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::Hide\n");
}
bool IsVisible()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::IsVisible\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::IsVisible\n");
return false;
}
-void ApplySettings( const Property::Map& settingsMap )
+void ApplySettings(const Property::Map& settingsMap)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::ApplySettings\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::ApplySettings\n");
}
-void SetReturnKeyType( const InputMethod::ButtonAction::Type type )
+void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::SetReturnKeyType\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::SetReturnKeyType\n");
}
Dali::InputMethod::ButtonAction::Type GetReturnKeyType()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::GetReturnKeyType\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::GetReturnKeyType\n");
return Dali::InputMethod::ButtonAction::DEFAULT;
}
-void EnablePrediction( const bool enable )
+void EnablePrediction(const bool enable)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::EnablePrediction\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::EnablePrediction\n");
}
bool IsPredictionEnabled()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::IsPredictionEnabled\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::IsPredictionEnabled\n");
return false;
}
Rect<int> GetSizeAndPosition()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::GetSizeAndPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::GetSizeAndPosition\n");
Rect<int> ret;
return ret;
void RotateTo(int angle)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::RotateTo\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::RotateTo\n");
}
Dali::VirtualKeyboard::TextDirection GetTextDirection()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VirtualKeyboard::GetTextDirection\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VirtualKeyboard::GetTextDirection\n");
return Dali::VirtualKeyboard::LEFT_TO_RIGHT;
}
/*
- * Copyright (c) 2018 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.
*
*/
-#include <memory>
#include <dali/internal/input/common/input-method-context-factory.h>
#include <dali/internal/input/macos/input-method-context-impl-mac.h>
+#include <memory>
namespace Dali
{
namespace InputMethodContextFactory
{
-
// InputMethodContext Factory to be implemented by the platform
-InputMethodContextPtr CreateInputMethodContext( Dali::Actor actor )
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor)
{
- return Dali::Internal::Adaptor::InputMethodContextCocoa::New( actor );
+ return Dali::Internal::Adaptor::InputMethodContextCocoa::New(actor);
}
-}
+} // namespace InputMethodContextFactory
-}
+} // namespace Adaptor
-
-
-}
-}
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/input/macos/input-method-context-impl-mac.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/key.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/input/common/key-impl.h>
#include <dali/internal/input/common/virtual-keyboard-impl.h>
#include <dali/internal/system/common/locale-utils.h>
+#include <dali/public-api/adaptor-framework/key.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
#if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");
#endif
-}
+} // namespace
-InputMethodContextPtr InputMethodContextCocoa::New( Dali::Actor actor )
+InputMethodContextPtr InputMethodContextCocoa::New(Dali::Actor actor)
{
InputMethodContextPtr manager;
- if ( actor && Adaptor::IsAvailable() )
+ if(actor && Adaptor::IsAvailable())
{
- manager = new InputMethodContextCocoa( actor );
+ manager = new InputMethodContextCocoa(actor);
}
return manager;
{
}
-InputMethodContextCocoa::InputMethodContextCocoa( Dali::Actor actor )
-: mIMFCursorPosition( 0 ),
+InputMethodContextCocoa::InputMethodContextCocoa(Dali::Actor actor)
+: mIMFCursorPosition(0),
mSurroundingText(),
- mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false )
+ mRestoreAfterFocusLost(false),
+ mIdleCallbackConnected(false)
{
-
- actor.OnSceneSignal().Connect( this, &InputMethodContextCocoa::OnStaged );
+ actor.OnSceneSignal().Connect(this, &InputMethodContextCocoa::OnStaged);
}
InputMethodContextCocoa::~InputMethodContextCocoa()
void InputMethodContextCocoa::Reset()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::Reset\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::Reset\n");
}
ImfContext* InputMethodContextCocoa::GetContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetContext\n");
return NULL;
}
return mRestoreAfterFocusLost;
}
-void InputMethodContextCocoa::SetRestoreAfterFocusLost( bool toggle )
+void InputMethodContextCocoa::SetRestoreAfterFocusLost(bool toggle)
{
mRestoreAfterFocusLost = toggle;
}
* We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks
* the user wants to type.
*/
-void InputMethodContextCocoa::PreEditChanged( void*, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextCocoa::PreEditChanged(void*, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::PreEditChanged\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::PreEditChanged\n");
}
-void InputMethodContextCocoa::CommitReceived( void*, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextCocoa::CommitReceived(void*, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::CommitReceived\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::CommitReceived\n");
- if ( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- const std::string keyString( static_cast<char*>( eventInfo ) );
+ const std::string keyString(static_cast<char*>(eventInfo));
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::EventData eventData(Dali::InputMethodContext::COMMIT, keyString, 0, 0);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, eventData);
- if( callbackData.update )
+ if(callbackData.update)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
NotifyCursorPosition();
}
* Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is
* We need to signal the application to tell us this information.
*/
-bool InputMethodContextCocoa::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )
+bool InputMethodContextCocoa::RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::RetrieveSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::RetrieveSurrounding\n");
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0);
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, imfData);
- if( callbackData.update )
+ if(callbackData.update)
{
- if( text )
+ if(text)
{
- *text = strdup( callbackData.currentText.c_str() );
+ *text = strdup(callbackData.currentText.c_str());
}
- if( cursorPosition )
+ if(cursorPosition)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
- *cursorPosition = mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
+ *cursorPosition = mIMFCursorPosition;
}
}
* Called when an InputMethodContext delete surrounding event is received.
* Here we tell the application that it should delete a certain range.
*/
-void InputMethodContextCocoa::DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextCocoa::DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::DeleteSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::DeleteSurrounding\n");
}
void InputMethodContextCocoa::NotifyCursorPosition()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::NotifyCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::NotifyCursorPosition\n");
}
-void InputMethodContextCocoa::SetCursorPosition( unsigned int cursorPosition )
+void InputMethodContextCocoa::SetCursorPosition(unsigned int cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetCursorPosition\n");
- mIMFCursorPosition = static_cast<int>( cursorPosition );
+ mIMFCursorPosition = static_cast<int>(cursorPosition);
}
unsigned int InputMethodContextCocoa::GetCursorPosition() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetCursorPosition\n");
- return static_cast<unsigned int>( mIMFCursorPosition );
+ return static_cast<unsigned int>(mIMFCursorPosition);
}
-void InputMethodContextCocoa::SetSurroundingText( const std::string& text )
+void InputMethodContextCocoa::SetSurroundingText(const std::string& text)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetSurroundingText\n");
mSurroundingText = text;
}
const std::string& InputMethodContextCocoa::GetSurroundingText() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetSurroundingText\n");
return mSurroundingText;
}
-void InputMethodContextCocoa::NotifyTextInputMultiLine( bool multiLine )
+void InputMethodContextCocoa::NotifyTextInputMultiLine(bool multiLine)
{
}
Dali::InputMethodContext::TextDirection InputMethodContextCocoa::GetTextDirection()
{
- Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT);
+ Dali::InputMethodContext::TextDirection direction(Dali::InputMethodContext::LEFT_TO_RIGHT);
return direction;
}
width = height = xPos = yPos = 0;
- return Rect<int>(xPos,yPos,width,height);
+ return Rect<int>(xPos, yPos, width, height);
}
-void InputMethodContextCocoa::ApplyOptions( const InputMethodOptions& options )
+void InputMethodContextCocoa::ApplyOptions(const InputMethodOptions& options)
{
using namespace Dali::InputMethod::Category;
int index;
- if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
+ if(mOptions.CompareAndSet(PANEL_LAYOUT, options, index))
{
}
- if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )
+ if(mOptions.CompareAndSet(BUTTON_ACTION, options, index))
{
}
- if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )
+ if(mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index))
{
}
- if ( mOptions.CompareAndSet(VARIATION, options, index) )
+ if(mOptions.CompareAndSet(VARIATION, options, index))
{
}
}
-void InputMethodContextCocoa::SetInputPanelData( const std::string& data )
+void InputMethodContextCocoa::SetInputPanelData(const std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelData\n");
}
-void InputMethodContextCocoa::GetInputPanelData( std::string& data )
+void InputMethodContextCocoa::GetInputPanelData(std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelData\n");
}
Dali::InputMethodContext::State InputMethodContextCocoa::GetInputPanelState()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelState\n");
return Dali::InputMethodContext::DEFAULT;
}
-void InputMethodContextCocoa::SetReturnKeyState( bool visible )
+void InputMethodContextCocoa::SetReturnKeyState(bool visible)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetReturnKeyState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetReturnKeyState\n");
}
-void InputMethodContextCocoa::AutoEnableInputPanel( bool enabled )
+void InputMethodContextCocoa::AutoEnableInputPanel(bool enabled)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::AutoEnableInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::AutoEnableInputPanel\n");
}
void InputMethodContextCocoa::ShowInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::ShowInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::ShowInputPanel\n");
}
void InputMethodContextCocoa::HideInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::HideInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::HideInputPanel\n");
}
Dali::InputMethodContext::KeyboardType InputMethodContextCocoa::GetKeyboardType()
std::string InputMethodContextCocoa::GetInputPanelLocale()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelLocale\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelLocale\n");
std::string locale = "";
return locale;
}
-void InputMethodContextCocoa::SetContentMIMETypes( const std::string& mimeTypes )
+void InputMethodContextCocoa::SetContentMIMETypes(const std::string& mimeTypes)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetContentMIMETypes\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetContentMIMETypes\n");
}
-bool InputMethodContextCocoa::FilterEventKey( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextCocoa::FilterEventKey(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
+ bool eventHandled(false);
- if ( ! KeyLookup::IsDeviceButton( keyEvent.GetKeyName().c_str() ))
+ if(!KeyLookup::IsDeviceButton(keyEvent.GetKeyName().c_str()))
{
//check whether it's key down or key up event
- if ( keyEvent.GetState() == Dali::KeyEvent::DOWN )
+ if(keyEvent.GetState() == Dali::KeyEvent::DOWN)
{
- eventHandled = ProcessEventKeyDown( keyEvent );
+ eventHandled = ProcessEventKeyDown(keyEvent);
}
- else if ( keyEvent.GetState() == Dali::KeyEvent::UP )
+ else if(keyEvent.GetState() == Dali::KeyEvent::UP)
{
- eventHandled = ProcessEventKeyUp( keyEvent );
+ eventHandled = ProcessEventKeyUp(keyEvent);
}
}
return eventHandled;
}
-void InputMethodContextCocoa::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )
+void InputMethodContextCocoa::SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelLanguage\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelLanguage\n");
}
Dali::InputMethodContext::InputPanelLanguage InputMethodContextCocoa::GetInputPanelLanguage() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelLanguage\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelLanguage\n");
return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
}
-void InputMethodContextCocoa::SetInputPanelPosition( unsigned int x, unsigned int y )
+void InputMethodContextCocoa::SetInputPanelPosition(unsigned int x, unsigned int y)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelPosition\n");
}
-void InputMethodContextCocoa::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const
+void InputMethodContextCocoa::GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextCocoa::GetPreeditStyle\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetPreeditStyle\n");
attrs = mPreeditAttrs;
}
-bool InputMethodContextCocoa::ProcessEventKeyDown( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextCocoa::ProcessEventKeyDown(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
+ bool eventHandled(false);
return eventHandled;
}
-bool InputMethodContextCocoa::ProcessEventKeyUp( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextCocoa::ProcessEventKeyUp(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
+ bool eventHandled(false);
return eventHandled;
}
-void InputMethodContextCocoa::OnStaged( Dali::Actor actor )
+void InputMethodContextCocoa::OnStaged(Dali::Actor actor)
{
// Reset
Finalize();
Initialize();
}
-} // Adaptor
-
-} // Internal
+} // namespace Adaptor
-} // Dali
+} // namespace Internal
+} // namespace Dali
/*
- * Copyright (c) 2018 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.
namespace Dali::Internal::Adaptor::KeyLookup
{
-
// matches a DALI_KEY enum, to key name
+// clang-format off
KeyLookup KeyLookupTable[]=
{
{ "Escape", DALI_KEY_ESCAPE, false },
{ "Delete", static_cast<Dali::KEY>( DevelKey::DALI_KEY_DELETE ), false },
{ "Control", static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_LEFT ), false },
};
+// clang-format on
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup ));
+const std::size_t KEY_LOOKUP_COUNT = (sizeof(KeyLookupTable)) / (sizeof(KeyLookup));
-}
+} // namespace Dali::Internal::Adaptor::KeyLookup
/*
- * Copyright (c) 2018 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.
namespace Dali::Internal::Adaptor::VirtualKeyboard
{
-
void Show()
{
}
void Hide()
{
-
}
bool IsVisible()
return false;
}
-void ApplySettings( const Property::Map& settingsMap )
+void ApplySettings(const Property::Map& settingsMap)
{
-
}
-void EnablePrediction( const bool enable )
+void EnablePrediction(const bool enable)
{
-
}
bool IsPredictionEnabled()
{
}
-void SetReturnKeyType( const InputMethod::ButtonAction::Type type )
+void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
{
}
/*
- * Copyright (c) 2019 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.
#include <dali/internal/input/common/virtual-keyboard-impl.h>
// EXTERNAL INCLUDES
-#include <algorithm>
#include <dali/integration-api/debug.h>
+#include <algorithm>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/adaptor.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace VirtualKeyboard
{
-
namespace
{
#if defined(DEBUG_ENABLED)
#define TOKEN_STRING(x) #x
//forward declarations
-void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value );
-void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value );
+void InputPanelGeometryChangedCallback(void* data, Ecore_IMF_Context* context, int value);
+void InputPanelLanguageChangeCallback(void* data, Ecore_IMF_Context* context, int value);
// Signals
Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal;
Dali::VirtualKeyboard::VoidSignalType gKeyboardResizeSignal;
Dali::VirtualKeyboard::VoidSignalType gKeyboardLanguageChangedSignal;
-void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
+void InputPanelStateChangeCallback(void* data, Ecore_IMF_Context* context, int value)
{
- switch (value)
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n");
- gKeyboardStatusSignal.Emit( true );
+ gKeyboardStatusSignal.Emit(true);
break;
}
case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n");
- gKeyboardStatusSignal.Emit( false );
+ gKeyboardStatusSignal.Emit(false);
break;
}
}
}
-void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
+void InputPanelLanguageChangeCallback(void* data, Ecore_IMF_Context* context, int value)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback\n");
// Emit the signal that the language has changed
gKeyboardLanguageChangedSignal.Emit();
}
-void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
+void InputPanelGeometryChangedCallback(void* data, Ecore_IMF_Context* context, int value)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n");
// Emit signal that the keyboard is resized
gKeyboardResizeSignal.Emit();
} // unnamed namespace
-void ConnectCallbacks( Ecore_IMF_Context *imfContext )
+void ConnectCallbacks(Ecore_IMF_Context* imfContext)
{
- if( imfContext )
+ if(imfContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n");
- ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL );
- ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL );
- ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL );
+ ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL);
+ ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL);
+ ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL);
}
}
-void DisconnectCallbacks( Ecore_IMF_Context *imfContext )
+void DisconnectCallbacks(Ecore_IMF_Context* imfContext)
{
- if( imfContext )
+ if(imfContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n");
- ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
- ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
- ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
+ ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback);
+ ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback);
+ ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback);
}
}
void Show()
{
- DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Show() is deprecated and will be removed from next release. Use InputMethodContext.Activate() instead.\n" );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Show() is deprecated and will be removed from next release. Use InputMethodContext.Activate() instead.\n");
}
void Hide()
{
- DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Hide() is deprecated and will be removed from next release. Use InputMethodContext.Deactivate() instead.\n" );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Hide() is deprecated and will be removed from next release. Use InputMethodContext.Deactivate() instead.\n");
}
bool IsVisible()
{
- DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsVisible() is deprecated and will be removed from next release.\n" );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsVisible() is deprecated and will be removed from next release.\n");
return false;
}
-void ApplySettings( const Property::Map& settingsMap )
+void ApplySettings(const Property::Map& settingsMap)
{
using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING.
- for ( unsigned long i = 0, count = settingsMap.Count(); i < count; ++i )
+ for(unsigned long i = 0, count = settingsMap.Count(); i < count; ++i)
{
- Property::Key key = settingsMap.GetKeyAt( i );
- if( key.type == Property::Key::INDEX )
+ Property::Key key = settingsMap.GetKeyAt(i);
+ if(key.type == Property::Key::INDEX)
{
continue;
}
Property::Value item = settingsMap.GetValue(i);
- if ( key == TOKEN_STRING( BUTTON_ACTION ) )
+ if(key == TOKEN_STRING(BUTTON_ACTION))
{
- if ( item.GetType() == Property::INTEGER )
+ if(item.GetType() == Property::INTEGER)
{
- int value = item.Get< int >();
- VirtualKeyboard::SetReturnKeyType( static_cast<InputMethod::ButtonAction::Type>(value) );
+ int value = item.Get<int>();
+ VirtualKeyboard::SetReturnKeyType(static_cast<InputMethod::ButtonAction::Type>(value));
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "Provided Settings Key not supported\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Provided Settings Key not supported\n");
}
}
}
{
int xPos, yPos, width, height;
- DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSizeAndPosition() is deprecated and will be removed from next release. Use InputMethodContext.GetInputMethodArea() instead.\n" );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSizeAndPosition() is deprecated and will be removed from next release. Use InputMethodContext.GetInputMethodArea() instead.\n");
width = height = xPos = yPos = 0;
- return Rect<int>(xPos,yPos,width,height);
+ return Rect<int>(xPos, yPos, width, height);
}
Dali::VirtualKeyboard::TextDirection GetTextDirection()
{
- Dali::VirtualKeyboard::TextDirection direction ( Dali::VirtualKeyboard::LEFT_TO_RIGHT );
+ Dali::VirtualKeyboard::TextDirection direction(Dali::VirtualKeyboard::LEFT_TO_RIGHT);
return direction;
}
/*
- * Copyright (c) 2017 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.
*
*/
-#include <memory>
#include <dali/internal/input/common/input-method-context-factory.h>
#include <dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.h>
+#include <memory>
namespace Dali
{
namespace InputMethodContextFactory
{
-
// InputMethodContext Factory to be implemented by the platform
-InputMethodContextPtr CreateInputMethodContext( Dali::Actor actor )
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor)
{
- return Dali::Internal::Adaptor::InputMethodContextEcoreWl::New( actor );
-}
-
-}
-
+ return Dali::Internal::Adaptor::InputMethodContextEcoreWl::New(actor);
}
+} // namespace InputMethodContextFactory
+} // namespace Adaptor
-}
-}
\ No newline at end of file
+} // namespace Internal
+} // namespace Dali
\ No newline at end of file
/*
- * 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.
#include <Ecore_Wayland.h>
#endif
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/adaptor-framework/key.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/adaptor-framework/key.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/input-method.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/scene-holder.h>
#include <dali/internal/input/common/key-impl.h>
#include <dali/internal/system/common/locale-utils.h>
#include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/public-api/adaptor-framework/input-method.h>
Ecore_IMF_Input_Panel_Layout panelLayoutMap[] =
-{
- ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL,
- ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER,
- ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL,
- ECORE_IMF_INPUT_PANEL_LAYOUT_URL,
- ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER,
- ECORE_IMF_INPUT_PANEL_LAYOUT_IP,
- ECORE_IMF_INPUT_PANEL_LAYOUT_MONTH,
- ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY,
- ECORE_IMF_INPUT_PANEL_LAYOUT_HEX,
- ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL,
- ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD,
- ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME,
- ECORE_IMF_INPUT_PANEL_LAYOUT_EMOTICON,
- ECORE_IMF_INPUT_PANEL_LAYOUT_VOICE
-};
+ {
+ ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_URL,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_IP,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_MONTH,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_HEX,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_EMOTICON,
+ ECORE_IMF_INPUT_PANEL_LAYOUT_VOICE};
Ecore_IMF_Autocapital_Type autoCapitalMap[] =
-{
- ECORE_IMF_AUTOCAPITAL_TYPE_NONE,
- ECORE_IMF_AUTOCAPITAL_TYPE_WORD,
- ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE,
- ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER,
+ {
+ ECORE_IMF_AUTOCAPITAL_TYPE_NONE,
+ ECORE_IMF_AUTOCAPITAL_TYPE_WORD,
+ ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE,
+ ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER,
};
Ecore_IMF_Input_Panel_Return_Key_Type returnKeyTypeMap[] =
-{
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND,
- ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN
-};
+ {
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND,
+ ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN};
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
#if defined(DEBUG_ENABLED)
{
size_t length = 0;
- if( ( leadByte & 0x80 ) == 0 ) //ASCII character (lead bit zero)
+ if((leadByte & 0x80) == 0) //ASCII character (lead bit zero)
{
length = 1;
}
- else if( ( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ else if((leadByte & 0xe0) == 0xc0) //110x xxxx
{
length = 2;
}
- else if( ( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ else if((leadByte & 0xf0) == 0xe0) //1110 xxxx
{
length = 3;
}
- else if( ( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ else if((leadByte & 0xf8) == 0xf0) //1111 0xxx
{
length = 4;
}
- else if( ( leadByte & 0xfc ) == 0xf8 ) //1111 10xx
+ else if((leadByte & 0xfc) == 0xf8) //1111 10xx
{
length = 5;
}
- else if( ( leadByte & 0xfe ) == 0xfc ) //1111 110x
+ else if((leadByte & 0xfe) == 0xfc) //1111 110x
{
length = 6;
}
}
// Static function calls used by ecore 'c' style callback registration
-void Commit( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void Commit(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- inputMethodContext->CommitReceived( data, imfContext, eventInfo );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ inputMethodContext->CommitReceived(data, imfContext, eventInfo);
}
}
-void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void PreEdit(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- inputMethodContext->PreEditChanged( data, imfContext, eventInfo );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ inputMethodContext->PreEditChanged(data, imfContext, eventInfo);
}
}
-Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+Eina_Bool ImfRetrieveSurrounding(void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition)
{
- if ( data )
+ if(data)
{
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- return inputMethodContext->RetrieveSurrounding( data, imfContext, text, cursorPosition );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ return inputMethodContext->RetrieveSurrounding(data, imfContext, text, cursorPosition);
}
else
{
}
}
-void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
+void InputPanelStateChangeCallback(void* data, Ecore_IMF_Context* context, int value)
{
- if (!data)
+ if(!data)
{
return;
}
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- switch (value)
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
{
- inputMethodContext->StatusChangedSignal().Emit( true );
+ inputMethodContext->StatusChangedSignal().Emit(true);
break;
}
case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
{
- inputMethodContext->StatusChangedSignal().Emit( false );
+ inputMethodContext->StatusChangedSignal().Emit(false);
break;
}
}
}
-void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
+void InputPanelLanguageChangeCallback(void* data, Ecore_IMF_Context* context, int value)
{
- if (!data)
+ if(!data)
{
return;
}
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
// Emit the signal that the language has changed
inputMethodContext->LanguageChangedSignal().Emit(value);
}
-void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
+void InputPanelGeometryChangedCallback(void* data, Ecore_IMF_Context* context, int value)
{
- if (!data)
+ if(!data)
{
return;
}
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
// Emit signal that the keyboard is resized
inputMethodContext->ResizedSignal().Emit(value);
}
-void InputPanelKeyboardTypeChangedCallback( void *data, Ecore_IMF_Context *context, int value )
+void InputPanelKeyboardTypeChangedCallback(void* data, Ecore_IMF_Context* context, int value)
{
- if( !data )
+ if(!data)
{
return;
}
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- switch (value)
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
{
// Emit Signal that the keyboard type is changed to Software Keyboard
- inputMethodContext->KeyboardTypeChangedSignal().Emit( Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD );
+ inputMethodContext->KeyboardTypeChangedSignal().Emit(Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD);
break;
}
case ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE:
{
// Emit Signal that the keyboard type is changed to Hardware Keyboard
- inputMethodContext->KeyboardTypeChangedSignal().Emit( Dali::InputMethodContext::KeyboardType::HARDWARE_KEYBOARD );
+ inputMethodContext->KeyboardTypeChangedSignal().Emit(Dali::InputMethodContext::KeyboardType::HARDWARE_KEYBOARD);
break;
}
}
* Called when an IMF delete surrounding event is received.
* Here we tell the application that it should delete a certain range.
*/
-void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void ImfDeleteSurrounding(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- inputMethodContext->DeleteSurrounding( data, imfContext, eventInfo );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ inputMethodContext->DeleteSurrounding(data, imfContext, eventInfo);
}
}
/**
* Called when the input method sends a private command.
*/
-void PrivateCommand( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void PrivateCommand(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- inputMethodContext->SendPrivateCommand( data, imfContext, eventInfo );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ inputMethodContext->SendPrivateCommand(data, imfContext, eventInfo);
}
}
/**
* Called when the input method commits content, such as an image.
*/
-void CommitContent( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void CommitContent(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextEcoreWl* inputMethodContext = static_cast< InputMethodContextEcoreWl* >( data );
- inputMethodContext->SendCommitContent( data, imfContext, eventInfo );
+ InputMethodContextEcoreWl* inputMethodContext = static_cast<InputMethodContextEcoreWl*>(data);
+ inputMethodContext->SendCommitContent(data, imfContext, eventInfo);
}
}
-int GetWindowIdFromActor( Dali::Actor actor )
+int GetWindowIdFromActor(Dali::Actor actor)
{
int windowId = kUninitializedWindowId;
- if( actor.GetProperty< bool >( Dali::Actor::Property::CONNECTED_TO_SCENE ) )
+ if(actor.GetProperty<bool>(Dali::Actor::Property::CONNECTED_TO_SCENE))
{
- Any nativeWindowHandle = Dali::Integration::SceneHolder::Get( actor ).GetNativeHandle();
+ Any nativeWindowHandle = Dali::Integration::SceneHolder::Get(actor).GetNativeHandle();
#ifdef ECORE_WAYLAND2
- windowId = ecore_wl2_window_id_get( AnyCast< Ecore_Wl2_Window* >( nativeWindowHandle ) );
+ windowId = ecore_wl2_window_id_get(AnyCast<Ecore_Wl2_Window*>(nativeWindowHandle));
#else
- windowId = ecore_wl_window_id_get( AnyCast< Ecore_Wl_Window* >( nativeWindowHandle ) );
+ windowId = ecore_wl_window_id_get(AnyCast<Ecore_Wl_Window*>(nativeWindowHandle));
#endif
}
BaseHandle Create()
{
- return Dali::InputMethodContext::New( Dali::Actor() );
+ return Dali::InputMethodContext::New(Dali::Actor());
}
-Dali::TypeRegistration type( typeid(Dali::InputMethodContext), typeid(Dali::BaseHandle), Create );
+Dali::TypeRegistration type(typeid(Dali::InputMethodContext), typeid(Dali::BaseHandle), Create);
} // unnamed namespace
-InputMethodContextPtr InputMethodContextEcoreWl::New( Dali::Actor actor )
+InputMethodContextPtr InputMethodContextEcoreWl::New(Dali::Actor actor)
{
InputMethodContextPtr inputMethodContext;
// Create instance only if the adaptor is available and the valid actor exists
- if ( actor && Dali::Adaptor::IsAvailable() )
+ if(actor && Dali::Adaptor::IsAvailable())
{
- inputMethodContext = new InputMethodContextEcoreWl( actor );
+ inputMethodContext = new InputMethodContextEcoreWl(actor);
}
return inputMethodContext;
}
void InputMethodContextEcoreWl::Finalize()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext::Finalize\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContext::Finalize\n");
DisconnectCallbacks();
DeleteContext();
}
-InputMethodContextEcoreWl::InputMethodContextEcoreWl( Dali::Actor actor )
+InputMethodContextEcoreWl::InputMethodContextEcoreWl(Dali::Actor actor)
: mIMFContext(),
- mIMFCursorPosition( 0 ),
+ mIMFCursorPosition(0),
mSurroundingText(),
- mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false ),
- mWindowId( GetWindowIdFromActor( actor ) )
+ mRestoreAfterFocusLost(false),
+ mIdleCallbackConnected(false),
+ mWindowId(GetWindowIdFromActor(actor))
{
ecore_imf_init();
- actor.OnSceneSignal().Connect( this, &InputMethodContextEcoreWl::OnStaged );
+ actor.OnSceneSignal().Connect(this, &InputMethodContextEcoreWl::OnStaged);
}
InputMethodContextEcoreWl::~InputMethodContextEcoreWl()
void InputMethodContextEcoreWl::CreateContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext::CreateContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContext::CreateContext\n");
- if( mWindowId == kUninitializedWindowId )
+ if(mWindowId == kUninitializedWindowId)
{
return;
}
- const char *contextId = ecore_imf_context_default_id_get();
- if( contextId )
+ const char* contextId = ecore_imf_context_default_id_get();
+ if(contextId)
{
- mIMFContext = ecore_imf_context_add( contextId );
+ mIMFContext = ecore_imf_context_add(contextId);
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast< void* >( mWindowId ) );
+ ecore_imf_context_client_window_set(mIMFContext, reinterpret_cast<void*>(mWindowId));
}
else
{
- DALI_LOG_WARNING( "InputMethodContext Unable to get IMFContext\n" );
+ DALI_LOG_WARNING("InputMethodContext Unable to get IMFContext\n");
}
}
else
{
- DALI_LOG_WARNING( "InputMethodContext Unable to get IMFContext\n" );
+ DALI_LOG_WARNING("InputMethodContext Unable to get IMFContext\n");
}
}
void InputMethodContextEcoreWl::DeleteContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::DeleteContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::DeleteContext\n");
- if ( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_del( mIMFContext );
+ ecore_imf_context_del(mIMFContext);
mIMFContext = NULL;
}
}
// Callbacks for predicitive text support.
void InputMethodContextEcoreWl::ConnectCallbacks()
{
- if ( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::ConnectCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::ConnectCallbacks\n");
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT_CONTENT, CommitContent, this );
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this);
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this);
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this);
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand, this);
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_COMMIT_CONTENT, CommitContent, this);
- ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, this );
- ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, this );
- ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, this );
- ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback, this );
+ ecore_imf_context_input_panel_event_callback_add(mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, this);
+ ecore_imf_context_input_panel_event_callback_add(mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, this);
+ ecore_imf_context_input_panel_event_callback_add(mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, this);
+ ecore_imf_context_input_panel_event_callback_add(mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback, this);
- ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
+ ecore_imf_context_retrieve_surrounding_callback_set(mIMFContext, ImfRetrieveSurrounding, this);
}
}
void InputMethodContextEcoreWl::DisconnectCallbacks()
{
- if ( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::DisconnectCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::DisconnectCallbacks\n");
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT_CONTENT, CommitContent );
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit);
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit);
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding);
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand);
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_COMMIT_CONTENT, CommitContent);
- ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
- ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
- ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
- ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback );
+ ecore_imf_context_input_panel_event_callback_del(mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback);
+ ecore_imf_context_input_panel_event_callback_del(mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback);
+ ecore_imf_context_input_panel_event_callback_del(mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback);
+ ecore_imf_context_input_panel_event_callback_del(mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback);
// We do not need to unset the retrieve surrounding callback.
}
// Reset mIdleCallbackConnected
mIdleCallbackConnected = false;
- if ( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::Activate\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::Activate\n");
- ecore_imf_context_focus_in( mIMFContext );
+ ecore_imf_context_focus_in(mIMFContext);
// emit keyboard activated signal
- Dali::InputMethodContext handle( this );
- mActivatedSignal.Emit( handle );
+ Dali::InputMethodContext handle(this);
+ mActivatedSignal.Emit(handle);
}
}
void InputMethodContextEcoreWl::Deactivate()
{
- if( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::Deactivate\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::Deactivate\n");
Reset();
- ecore_imf_context_focus_out( mIMFContext );
+ ecore_imf_context_focus_out(mIMFContext);
}
// Reset mIdleCallbackConnected
void InputMethodContextEcoreWl::Reset()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::Reset\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::Reset\n");
- if ( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_reset( mIMFContext );
+ ecore_imf_context_reset(mIMFContext);
}
}
ImfContext* InputMethodContextEcoreWl::GetContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetContext\n");
return mIMFContext;
}
return mRestoreAfterFocusLost;
}
-void InputMethodContextEcoreWl::SetRestoreAfterFocusLost( bool toggle )
+void InputMethodContextEcoreWl::SetRestoreAfterFocusLost(bool toggle)
{
mRestoreAfterFocusLost = toggle;
}
* We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks
* the user wants to type.
*/
-void InputMethodContextEcoreWl::PreEditChanged( void*, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextEcoreWl::PreEditChanged(void*, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::PreEditChanged\n" );
- auto context = static_cast<Ecore_IMF_Context*>( imfContext );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::PreEditChanged\n");
+ auto context = static_cast<Ecore_IMF_Context*>(imfContext);
- char* preEditString( NULL );
- int cursorPosition( 0 );
+ char* preEditString(NULL);
+ int cursorPosition(0);
Eina_List* attrs = NULL;
- Eina_List* l = NULL;
+ Eina_List* l = NULL;
Ecore_IMF_Preedit_Attr* attr;
// Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
// the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
- ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition );
+ ecore_imf_context_preedit_string_with_attributes_get(context, &preEditString, &attrs, &cursorPosition);
- if ( attrs )
+ if(attrs)
{
// iterate through the list of attributes getting the type, start and end position.
- for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
+ for(l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>(eina_list_data_get(l))); l; l = eina_list_next(l), (attr = static_cast<Ecore_IMF_Preedit_Attr*>(eina_list_data_get(l))))
{
Dali::InputMethodContext::PreeditAttributeData data;
data.startIndex = 0;
- data.endIndex = 0;
+ data.endIndex = 0;
size_t visualCharacterIndex = 0;
- size_t byteIndex = 0;
+ size_t byteIndex = 0;
// iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
char leadByte = preEditString[byteIndex];
- while( leadByte != '\0' )
+ while(leadByte != '\0')
{
leadByte = preEditString[byteIndex]; // Update the character to get the number of its byte
// attr->end_index is provided as a byte position not character and we need to know the character position.
- const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
- if( byteIndex <= attr->start_index )
+ const size_t currentSequenceLength = Utf8SequenceLength(leadByte); // returns number of bytes used to represent character.
+ if(byteIndex <= attr->start_index)
{
- data.startIndex = visualCharacterIndex;
+ data.startIndex = visualCharacterIndex;
}
- if( byteIndex >= attr->end_index )
+ if(byteIndex >= attr->end_index)
{
data.endIndex = visualCharacterIndex;
break;
else
{
byteIndex += currentSequenceLength; // jump to next character
- visualCharacterIndex++; // increment character count so we know our position for when we get a match
+ visualCharacterIndex++; // increment character count so we know our position for when we get a match
}
}
- switch( attr->preedit_type )
+ switch(attr->preedit_type)
{
case ECORE_IMF_PREEDIT_TYPE_NONE:
{
break;
}
}
- mPreeditAttrs.PushBack( data );
+ mPreeditAttrs.PushBack(data);
}
}
- if ( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0 );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::EventData eventData(Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, eventData);
- if ( callbackData.update )
+ if(callbackData.update)
{
- SetCursorPosition( callbackData.cursorPosition );
- SetSurroundingText( callbackData.currentText );
+ SetCursorPosition(callbackData.cursorPosition);
+ SetSurroundingText(callbackData.currentText);
NotifyCursorPosition();
}
- if ( callbackData.preeditResetRequired )
+ if(callbackData.preeditResetRequired)
{
Reset();
}
}
- free( preEditString );
+ free(preEditString);
}
-void InputMethodContextEcoreWl::CommitReceived( void*, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextEcoreWl::CommitReceived(void*, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::CommitReceived\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::CommitReceived\n");
- if ( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- const std::string keyString( static_cast<char*>( eventInfo ) );
+ const std::string keyString(static_cast<char*>(eventInfo));
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::EventData eventData(Dali::InputMethodContext::COMMIT, keyString, 0, 0);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, eventData);
- if( callbackData.update )
+ if(callbackData.update)
{
- SetCursorPosition( callbackData.cursorPosition );
- SetSurroundingText( callbackData.currentText );
+ SetCursorPosition(callbackData.cursorPosition);
+ SetSurroundingText(callbackData.currentText);
NotifyCursorPosition();
}
* Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is
* We need to signal the application to tell us this information.
*/
-bool InputMethodContextEcoreWl::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )
+bool InputMethodContextEcoreWl::RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::RetrieveSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::RetrieveSurrounding\n");
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0);
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, imfData);
- if( callbackData.update )
+ if(callbackData.update)
{
- if( cursorPosition )
+ if(cursorPosition)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
- *cursorPosition = mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
+ *cursorPosition = mIMFCursorPosition;
}
- if( text )
+ if(text)
{
const char* plainText = callbackData.currentText.c_str();
- if( plainText )
+ if(plainText)
{
// The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally.
- *text = strdup( plainText );
+ *text = strdup(plainText);
// If the current input panel is password mode, dali should replace the plain text with '*' (Asterisk) character.
- if( ( ecore_imf_context_input_hint_get( mIMFContext ) & ECORE_IMF_INPUT_HINT_SENSITIVE_DATA ) && *text )
+ if((ecore_imf_context_input_hint_get(mIMFContext) & ECORE_IMF_INPUT_HINT_SENSITIVE_DATA) && *text)
{
- for( char* iter = *text; *iter; ++iter )
+ for(char* iter = *text; *iter; ++iter)
{
*iter = '*';
}
* Called when an InputMethodContext delete surrounding event is received.
* Here we tell the application that it should delete a certain range.
*/
-void InputMethodContextEcoreWl::DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextEcoreWl::DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::DeleteSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::DeleteSurrounding\n");
- if( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( eventInfo );
+ Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
- Dali::InputMethodContext handle( this );
- mEventSignal.Emit( handle, imfData );
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars);
+ Dali::InputMethodContext handle(this);
+ mEventSignal.Emit(handle, imfData);
}
}
/**
* Called when the input method sends a private command.
*/
-void InputMethodContextEcoreWl::SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextEcoreWl::SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendPrivateCommand\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendPrivateCommand\n");
- if( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- const char* privateCommandSendEvent = static_cast<const char*>( eventInfo );
+ const char* privateCommandSendEvent = static_cast<const char*>(eventInfo);
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::PRIVATE_COMMAND, privateCommandSendEvent, 0, 0 );
- Dali::InputMethodContext handle( this );
- mEventSignal.Emit( handle, imfData );
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::PRIVATE_COMMAND, privateCommandSendEvent, 0, 0);
+ Dali::InputMethodContext handle(this);
+ mEventSignal.Emit(handle, imfData);
}
}
/**
* Called when the input method commits content, such as an image.
*/
-void InputMethodContextEcoreWl::SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextEcoreWl::SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendCommitContent\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendCommitContent\n");
- if( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- Ecore_IMF_Event_Commit_Content* commitContent = static_cast<Ecore_IMF_Event_Commit_Content *>( eventInfo );
- if( commitContent )
+ Ecore_IMF_Event_Commit_Content* commitContent = static_cast<Ecore_IMF_Event_Commit_Content*>(eventInfo);
+ if(commitContent)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendCommitContent commit content : %s, description : %s, mime type : %s\n",
- commitContent->content_uri, commitContent->description, commitContent->mime_types );
- mContentReceivedSignal.Emit( commitContent->content_uri, commitContent->description, commitContent->mime_types );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SendCommitContent commit content : %s, description : %s, mime type : %s\n", commitContent->content_uri, commitContent->description, commitContent->mime_types);
+ mContentReceivedSignal.Emit(commitContent->content_uri, commitContent->description, commitContent->mime_types);
}
}
}
void InputMethodContextEcoreWl::NotifyCursorPosition()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::NotifyCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::NotifyCursorPosition\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
+ ecore_imf_context_cursor_position_set(mIMFContext, mIMFCursorPosition);
}
}
-void InputMethodContextEcoreWl::SetCursorPosition( unsigned int cursorPosition )
+void InputMethodContextEcoreWl::SetCursorPosition(unsigned int cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetCursorPosition\n");
- mIMFCursorPosition = static_cast<int>( cursorPosition );
+ mIMFCursorPosition = static_cast<int>(cursorPosition);
}
unsigned int InputMethodContextEcoreWl::GetCursorPosition() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetCursorPosition\n");
- return static_cast<unsigned int>( mIMFCursorPosition );
+ return static_cast<unsigned int>(mIMFCursorPosition);
}
-void InputMethodContextEcoreWl::SetSurroundingText( const std::string& text )
+void InputMethodContextEcoreWl::SetSurroundingText(const std::string& text)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetSurroundingText\n");
mSurroundingText = text;
}
const std::string& InputMethodContextEcoreWl::GetSurroundingText() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetSurroundingText\n");
return mSurroundingText;
}
-void InputMethodContextEcoreWl::NotifyTextInputMultiLine( bool multiLine )
+void InputMethodContextEcoreWl::NotifyTextInputMultiLine(bool multiLine)
{
- if( mIMFContext )
+ if(mIMFContext)
{
Ecore_IMF_Input_Hints currentHint = ecore_imf_context_input_hint_get(mIMFContext);
- ecore_imf_context_input_hint_set( mIMFContext,
- static_cast< Ecore_IMF_Input_Hints >( multiLine ?
- (currentHint | ECORE_IMF_INPUT_HINT_MULTILINE) :
- (currentHint & ~ECORE_IMF_INPUT_HINT_MULTILINE)));
+ ecore_imf_context_input_hint_set(mIMFContext,
+ static_cast<Ecore_IMF_Input_Hints>(multiLine ? (currentHint | ECORE_IMF_INPUT_HINT_MULTILINE) : (currentHint & ~ECORE_IMF_INPUT_HINT_MULTILINE)));
}
- mBackupOperations[Operation::NOTIFY_TEXT_INPUT_MULTILINE] = std::bind( &InputMethodContextEcoreWl::NotifyTextInputMultiLine, this, multiLine );
+ mBackupOperations[Operation::NOTIFY_TEXT_INPUT_MULTILINE] = std::bind(&InputMethodContextEcoreWl::NotifyTextInputMultiLine, this, multiLine);
}
Dali::InputMethodContext::TextDirection InputMethodContextEcoreWl::GetTextDirection()
{
- Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT );
+ Dali::InputMethodContext::TextDirection direction(Dali::InputMethodContext::LEFT_TO_RIGHT);
- if ( mIMFContext )
- {
- char* locale( NULL );
- ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
+ if(mIMFContext)
+ {
+ char* locale(NULL);
+ ecore_imf_context_input_panel_language_locale_get(mIMFContext, &locale);
- if ( locale )
- {
- direction = static_cast< Dali::InputMethodContext::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
- free( locale );
- }
+ if(locale)
+ {
+ direction = static_cast<Dali::InputMethodContext::TextDirection>(Locale::GetDirection(std::string(locale)));
+ free(locale);
}
+ }
return direction;
}
width = height = xPos = yPos = 0;
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
+ ecore_imf_context_input_panel_geometry_get(mIMFContext, &xPos, &yPos, &width, &height);
}
else
{
DALI_LOG_WARNING("VKB Unable to get IMFContext so GetSize unavailable\n");
- // return 0 as real size unknown.
+ // return 0 as real size unknown.
}
- return Rect<int>(xPos,yPos,width,height);
+ return Rect<int>(xPos, yPos, width, height);
}
-void InputMethodContextEcoreWl::ApplyOptions( const InputMethodOptions& options )
+void InputMethodContextEcoreWl::ApplyOptions(const InputMethodOptions& options)
{
using namespace Dali::InputMethod::Category;
int index;
- if( mIMFContext == NULL )
+ if(mIMFContext == NULL)
{
DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
return;
}
- if( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
+ if(mOptions.CompareAndSet(PANEL_LAYOUT, options, index))
{
- ecore_imf_context_input_panel_layout_set( mIMFContext, panelLayoutMap[index] );
+ ecore_imf_context_input_panel_layout_set(mIMFContext, panelLayoutMap[index]);
// Sets the input hint which allows input methods to fine-tune their behavior.
- if( panelLayoutMap[index] == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD )
+ if(panelLayoutMap[index] == ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD)
{
- ecore_imf_context_input_hint_set( mIMFContext, static_cast< Ecore_IMF_Input_Hints >( ecore_imf_context_input_hint_get( mIMFContext ) | ECORE_IMF_INPUT_HINT_SENSITIVE_DATA ) );
+ ecore_imf_context_input_hint_set(mIMFContext, static_cast<Ecore_IMF_Input_Hints>(ecore_imf_context_input_hint_get(mIMFContext) | ECORE_IMF_INPUT_HINT_SENSITIVE_DATA));
}
else
{
- ecore_imf_context_input_hint_set( mIMFContext, static_cast< Ecore_IMF_Input_Hints >( ecore_imf_context_input_hint_get( mIMFContext ) & ~ECORE_IMF_INPUT_HINT_SENSITIVE_DATA ) );
+ ecore_imf_context_input_hint_set(mIMFContext, static_cast<Ecore_IMF_Input_Hints>(ecore_imf_context_input_hint_get(mIMFContext) & ~ECORE_IMF_INPUT_HINT_SENSITIVE_DATA));
}
}
- if( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )
+ if(mOptions.CompareAndSet(BUTTON_ACTION, options, index))
{
- ecore_imf_context_input_panel_return_key_type_set( mIMFContext, returnKeyTypeMap[index] );
+ ecore_imf_context_input_panel_return_key_type_set(mIMFContext, returnKeyTypeMap[index]);
}
- if( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )
+ if(mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index))
{
- ecore_imf_context_autocapital_type_set( mIMFContext, autoCapitalMap[index] );
+ ecore_imf_context_autocapital_type_set(mIMFContext, autoCapitalMap[index]);
}
- if( mOptions.CompareAndSet(VARIATION, options, index) )
+ if(mOptions.CompareAndSet(VARIATION, options, index))
{
- ecore_imf_context_input_panel_layout_variation_set( mIMFContext, index );
+ ecore_imf_context_input_panel_layout_variation_set(mIMFContext, index);
}
}
-void InputMethodContextEcoreWl::SetInputPanelData( const std::string& data )
+void InputMethodContextEcoreWl::SetInputPanelData(const std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetInputPanelData\n");
- if( mIMFContext )
+ if(mIMFContext)
{
int length = data.length();
- ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
+ ecore_imf_context_input_panel_imdata_set(mIMFContext, data.c_str(), length);
}
- mBackupOperations[Operation::SET_INPUT_PANEL_DATA] = std::bind( &InputMethodContextEcoreWl::SetInputPanelData, this, data );
+ mBackupOperations[Operation::SET_INPUT_PANEL_DATA] = std::bind(&InputMethodContextEcoreWl::SetInputPanelData, this, data);
}
-void InputMethodContextEcoreWl::GetInputPanelData( std::string& data )
+void InputMethodContextEcoreWl::GetInputPanelData(std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelData\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- int length = 4096; // The max length is 4096 bytes
- Dali::Vector< char > buffer;
- buffer.Resize( length );
- ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );
- data = std::string( buffer.Begin(), buffer.End() );
+ int length = 4096; // The max length is 4096 bytes
+ Dali::Vector<char> buffer;
+ buffer.Resize(length);
+ ecore_imf_context_input_panel_imdata_get(mIMFContext, &buffer[0], &length);
+ data = std::string(buffer.Begin(), buffer.End());
}
}
Dali::InputMethodContext::State InputMethodContextEcoreWl::GetInputPanelState()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelState\n");
- if( mIMFContext )
+ if(mIMFContext)
{
int value;
- value = ecore_imf_context_input_panel_state_get( mIMFContext );
+ value = ecore_imf_context_input_panel_state_get(mIMFContext);
- switch (value)
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
{
return Dali::InputMethodContext::DEFAULT;
}
-void InputMethodContextEcoreWl::SetReturnKeyState( bool visible )
+void InputMethodContextEcoreWl::SetReturnKeyState(bool visible)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetReturnKeyState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetReturnKeyState\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
+ ecore_imf_context_input_panel_return_key_disabled_set(mIMFContext, !visible);
}
- mBackupOperations[Operation::SET_RETURN_KEY_STATE] = std::bind( &InputMethodContextEcoreWl::SetReturnKeyState, this, visible );
+ mBackupOperations[Operation::SET_RETURN_KEY_STATE] = std::bind(&InputMethodContextEcoreWl::SetReturnKeyState, this, visible);
}
-void InputMethodContextEcoreWl::AutoEnableInputPanel( bool enabled )
+void InputMethodContextEcoreWl::AutoEnableInputPanel(bool enabled)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::AutoEnableInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::AutoEnableInputPanel\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
+ ecore_imf_context_input_panel_enabled_set(mIMFContext, enabled);
}
- mBackupOperations[Operation::AUTO_ENABLE_INPUT_PANEL] = std::bind( &InputMethodContextEcoreWl::AutoEnableInputPanel, this, enabled );
+ mBackupOperations[Operation::AUTO_ENABLE_INPUT_PANEL] = std::bind(&InputMethodContextEcoreWl::AutoEnableInputPanel, this, enabled);
}
void InputMethodContextEcoreWl::ShowInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::ShowInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::ShowInputPanel\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_show( mIMFContext );
+ ecore_imf_context_input_panel_show(mIMFContext);
}
}
void InputMethodContextEcoreWl::HideInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::HideInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::HideInputPanel\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_hide( mIMFContext );
+ ecore_imf_context_input_panel_hide(mIMFContext);
}
}
Dali::InputMethodContext::KeyboardType InputMethodContextEcoreWl::GetKeyboardType()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetKeyboardType\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetKeyboardType\n");
- if( mIMFContext )
+ if(mIMFContext)
{
int value;
- value = ecore_imf_context_keyboard_mode_get( mIMFContext );
+ value = ecore_imf_context_keyboard_mode_get(mIMFContext);
- switch (value)
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
{
std::string InputMethodContextEcoreWl::GetInputPanelLocale()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelLocale\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelLocale\n");
std::string locale = "";
- if( mIMFContext )
+ if(mIMFContext)
{
char* value = NULL;
- ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
+ ecore_imf_context_input_panel_language_locale_get(mIMFContext, &value);
- if( value )
+ if(value)
{
- std::string valueCopy( value );
+ std::string valueCopy(value);
locale = valueCopy;
// The locale string retrieved must be freed with free().
- free( value );
+ free(value);
}
}
return locale;
}
-void InputMethodContextEcoreWl::SetContentMIMETypes( const std::string& mimeTypes )
+void InputMethodContextEcoreWl::SetContentMIMETypes(const std::string& mimeTypes)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetContentMIMETypes\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetContentMIMETypes\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_mime_type_accept_set( mIMFContext, mimeTypes.c_str() );
+ ecore_imf_context_mime_type_accept_set(mIMFContext, mimeTypes.c_str());
}
- mBackupOperations[Operation::SET_CONTENT_MIME_TYPES] = std::bind( &InputMethodContextEcoreWl::SetContentMIMETypes, this, mimeTypes );
+ mBackupOperations[Operation::SET_CONTENT_MIME_TYPES] = std::bind(&InputMethodContextEcoreWl::SetContentMIMETypes, this, mimeTypes);
}
-bool InputMethodContextEcoreWl::FilterEventKey( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextEcoreWl::FilterEventKey(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
+ bool eventHandled(false);
// If a device key then skip ecore_imf_context_filter_event.
- if ( ! KeyLookup::IsDeviceButton( keyEvent.GetKeyName().c_str() ))
+ if(!KeyLookup::IsDeviceButton(keyEvent.GetKeyName().c_str()))
{
//check whether it's key down or key up event
- if ( keyEvent.GetState() == Dali::KeyEvent::DOWN )
+ if(keyEvent.GetState() == Dali::KeyEvent::DOWN)
{
- eventHandled = ProcessEventKeyDown( keyEvent );
+ eventHandled = ProcessEventKeyDown(keyEvent);
}
- else if ( keyEvent.GetState() == Dali::KeyEvent::UP )
+ else if(keyEvent.GetState() == Dali::KeyEvent::UP)
{
- eventHandled = ProcessEventKeyUp( keyEvent );
+ eventHandled = ProcessEventKeyUp(keyEvent);
}
}
return eventHandled;
}
-void InputMethodContextEcoreWl::AllowTextPrediction( bool prediction )
+void InputMethodContextEcoreWl::AllowTextPrediction(bool prediction)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::AllowTextPrediction\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::AllowTextPrediction\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_prediction_allow_set( mIMFContext, prediction );
+ ecore_imf_context_prediction_allow_set(mIMFContext, prediction);
}
- mBackupOperations[Operation::ALLOW_TEXT_PREDICTION] = std::bind( &InputMethodContextEcoreWl::AllowTextPrediction, this, prediction );
+ mBackupOperations[Operation::ALLOW_TEXT_PREDICTION] = std::bind(&InputMethodContextEcoreWl::AllowTextPrediction, this, prediction);
}
bool InputMethodContextEcoreWl::IsTextPredictionAllowed() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::IsTextPredictionAllowed\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::IsTextPredictionAllowed\n");
bool prediction = false;
- if( mIMFContext )
+ if(mIMFContext)
{
- prediction = ecore_imf_context_prediction_allow_get( mIMFContext );
+ prediction = ecore_imf_context_prediction_allow_get(mIMFContext);
}
return prediction;
}
-void InputMethodContextEcoreWl::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )
+void InputMethodContextEcoreWl::SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetInputPanelLanguage\n" );
- if( mIMFContext )
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetInputPanelLanguage\n");
+ if(mIMFContext)
{
- switch (language)
+ switch(language)
{
case Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC:
{
- ecore_imf_context_input_panel_language_set( mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC );
+ ecore_imf_context_input_panel_language_set(mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC);
break;
}
case Dali::InputMethodContext::InputPanelLanguage::ALPHABET:
{
- ecore_imf_context_input_panel_language_set( mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET );
+ ecore_imf_context_input_panel_language_set(mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
break;
}
}
}
- mBackupOperations[Operation::SET_INPUT_PANEL_LANGUAGE] = std::bind( &InputMethodContextEcoreWl::SetInputPanelLanguage, this, language );
+ mBackupOperations[Operation::SET_INPUT_PANEL_LANGUAGE] = std::bind(&InputMethodContextEcoreWl::SetInputPanelLanguage, this, language);
}
Dali::InputMethodContext::InputPanelLanguage InputMethodContextEcoreWl::GetInputPanelLanguage() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelLanguage\n" );
- if( mIMFContext )
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetInputPanelLanguage\n");
+ if(mIMFContext)
{
int value;
- value = ecore_imf_context_input_panel_language_get( mIMFContext );
+ value = ecore_imf_context_input_panel_language_get(mIMFContext);
- switch (value)
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC:
{
return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
}
-void InputMethodContextEcoreWl::SetInputPanelPosition( unsigned int x, unsigned int y )
+void InputMethodContextEcoreWl::SetInputPanelPosition(unsigned int x, unsigned int y)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetInputPanelPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::SetInputPanelPosition\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_position_set( mIMFContext, x, y );
+ ecore_imf_context_input_panel_position_set(mIMFContext, x, y);
}
- mBackupOperations[Operation::SET_INPUT_PANEL_POSITION] = std::bind( &InputMethodContextEcoreWl::SetInputPanelPosition, this, x, y );
+ mBackupOperations[Operation::SET_INPUT_PANEL_POSITION] = std::bind(&InputMethodContextEcoreWl::SetInputPanelPosition, this, x, y);
}
-void InputMethodContextEcoreWl::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const
+void InputMethodContextEcoreWl::GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetPreeditStyle\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetPreeditStyle\n");
attrs = mPreeditAttrs;
}
-bool InputMethodContextEcoreWl::ProcessEventKeyDown( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextEcoreWl::ProcessEventKeyDown(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
- if ( mIMFContext )
+ bool eventHandled(false);
+ if(mIMFContext)
{
- Integration::KeyEvent integKeyEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
- std::string key = integKeyEvent.logicalKey;
+ Integration::KeyEvent integKeyEvent(keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast<Integration::KeyEvent::State>(keyEvent.GetState()), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass());
+ std::string key = integKeyEvent.logicalKey;
- std::string compose = integKeyEvent.compose;
+ std::string compose = integKeyEvent.compose;
std::string deviceName = integKeyEvent.deviceName;
// We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.
Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
- ecoreKeyDownEvent.keyname = integKeyEvent.keyName.c_str();
- ecoreKeyDownEvent.key = key.c_str();
- ecoreKeyDownEvent.string = integKeyEvent.keyString.c_str();
- ecoreKeyDownEvent.compose = compose.c_str();
- ecoreKeyDownEvent.timestamp = integKeyEvent.time;
- ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( integKeyEvent.keyModifier );
- ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( integKeyEvent.keyModifier );
- ecoreKeyDownEvent.dev_name = deviceName.c_str();
- ecoreKeyDownEvent.dev_class = static_cast<Ecore_IMF_Device_Class> ( integKeyEvent.deviceClass );//ECORE_IMF_DEVICE_CLASS_KEYBOARD;
- ecoreKeyDownEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass> ( integKeyEvent.deviceSubclass );//ECORE_IMF_DEVICE_SUBCLASS_NONE;
+ ecoreKeyDownEvent.keyname = integKeyEvent.keyName.c_str();
+ ecoreKeyDownEvent.key = key.c_str();
+ ecoreKeyDownEvent.string = integKeyEvent.keyString.c_str();
+ ecoreKeyDownEvent.compose = compose.c_str();
+ ecoreKeyDownEvent.timestamp = integKeyEvent.time;
+ ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier(integKeyEvent.keyModifier);
+ ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock(integKeyEvent.keyModifier);
+ ecoreKeyDownEvent.dev_name = deviceName.c_str();
+ ecoreKeyDownEvent.dev_class = static_cast<Ecore_IMF_Device_Class>(integKeyEvent.deviceClass); //ECORE_IMF_DEVICE_CLASS_KEYBOARD;
+ ecoreKeyDownEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>(integKeyEvent.deviceSubclass); //ECORE_IMF_DEVICE_SUBCLASS_NONE;
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 22)
ecoreKeyDownEvent.keycode = integKeyEvent.keyCode; // Ecore_IMF_Event structure has added 'keycode' variable since ecore_imf 1.22 version.
-#endif // Since ecore_imf 1.22 version
+#endif // Since ecore_imf 1.22 version
// If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor.
- if ((integKeyEvent.deviceName == "ime") && ((!strncmp(integKeyEvent.keyName.c_str(), "Left", 4)) ||
- (!strncmp(integKeyEvent.keyName.c_str(), "Right", 5)) ||
- (!strncmp(integKeyEvent.keyName.c_str(), "Up", 2)) ||
- (!strncmp(integKeyEvent.keyName.c_str(), "Down", 4))))
+ if((integKeyEvent.deviceName == "ime") && ((!strncmp(integKeyEvent.keyName.c_str(), "Left", 4)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Right", 5)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Up", 2)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Down", 4))))
{
eventHandled = 0;
}
{
eventHandled = ecore_imf_context_filter_event(mIMFContext,
ECORE_IMF_EVENT_KEY_DOWN,
- reinterpret_cast<Ecore_IMF_Event *>( &ecoreKeyDownEvent ) );
+ reinterpret_cast<Ecore_IMF_Event*>(&ecoreKeyDownEvent));
}
// If the event has not been handled by InputMethodContext then check if we should reset our input method context
- if (!eventHandled)
+ if(!eventHandled)
{
- if (!strcmp(integKeyEvent.keyName.c_str(), "Escape") ||
- !strcmp(integKeyEvent.keyName.c_str(), "Return") ||
- !strcmp(integKeyEvent.keyName.c_str(), "KP_Enter"))
+ if(!strcmp(integKeyEvent.keyName.c_str(), "Escape") ||
+ !strcmp(integKeyEvent.keyName.c_str(), "Return") ||
+ !strcmp(integKeyEvent.keyName.c_str(), "KP_Enter"))
{
ecore_imf_context_reset(mIMFContext);
}
return eventHandled;
}
-bool InputMethodContextEcoreWl::ProcessEventKeyUp( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextEcoreWl::ProcessEventKeyUp(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
- if( mIMFContext )
+ bool eventHandled(false);
+ if(mIMFContext)
{
- Integration::KeyEvent integKeyEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
- std::string key = integKeyEvent.logicalKey;
+ Integration::KeyEvent integKeyEvent(keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast<Integration::KeyEvent::State>(keyEvent.GetState()), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass());
+ std::string key = integKeyEvent.logicalKey;
- std::string compose = integKeyEvent.compose;
+ std::string compose = integKeyEvent.compose;
std::string deviceName = integKeyEvent.deviceName;
// We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.
Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
- ecoreKeyUpEvent.keyname = integKeyEvent.keyName.c_str();
- ecoreKeyUpEvent.key = key.c_str();
- ecoreKeyUpEvent.string = integKeyEvent.keyString.c_str();
- ecoreKeyUpEvent.compose = compose.c_str();
- ecoreKeyUpEvent.timestamp = integKeyEvent.time;
- ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( integKeyEvent.keyModifier );
- ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( integKeyEvent.keyModifier );
- ecoreKeyUpEvent.dev_name = deviceName.c_str();
- ecoreKeyUpEvent.dev_class = static_cast<Ecore_IMF_Device_Class> ( integKeyEvent.deviceClass );//ECORE_IMF_DEVICE_CLASS_KEYBOARD;
- ecoreKeyUpEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass> ( integKeyEvent.deviceSubclass );//ECORE_IMF_DEVICE_SUBCLASS_NONE;
+ ecoreKeyUpEvent.keyname = integKeyEvent.keyName.c_str();
+ ecoreKeyUpEvent.key = key.c_str();
+ ecoreKeyUpEvent.string = integKeyEvent.keyString.c_str();
+ ecoreKeyUpEvent.compose = compose.c_str();
+ ecoreKeyUpEvent.timestamp = integKeyEvent.time;
+ ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier(integKeyEvent.keyModifier);
+ ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock(integKeyEvent.keyModifier);
+ ecoreKeyUpEvent.dev_name = deviceName.c_str();
+ ecoreKeyUpEvent.dev_class = static_cast<Ecore_IMF_Device_Class>(integKeyEvent.deviceClass); //ECORE_IMF_DEVICE_CLASS_KEYBOARD;
+ ecoreKeyUpEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>(integKeyEvent.deviceSubclass); //ECORE_IMF_DEVICE_SUBCLASS_NONE;
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 22)
ecoreKeyUpEvent.keycode = integKeyEvent.keyCode; // Ecore_IMF_Event structure has added 'keycode' variable since ecore_imf 1.22 version.
-#endif // Since ecore_imf 1.22 version
+#endif // Since ecore_imf 1.22 version
eventHandled = ecore_imf_context_filter_event(mIMFContext,
ECORE_IMF_EVENT_KEY_UP,
- reinterpret_cast<Ecore_IMF_Event *>( &ecoreKeyUpEvent ) );
+ reinterpret_cast<Ecore_IMF_Event*>(&ecoreKeyUpEvent));
}
return eventHandled;
}
-Ecore_IMF_Keyboard_Modifiers InputMethodContextEcoreWl::EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier )
+Ecore_IMF_Keyboard_Modifiers InputMethodContextEcoreWl::EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
{
- unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
+ unsigned int modifier(ECORE_IMF_KEYBOARD_MODIFIER_NONE); // If no other matches returns NONE.
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT) // enums from ecore_input/Ecore_Input.h
{
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_ALT)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_CTRL)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_WIN)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
}
- return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
+ return static_cast<Ecore_IMF_Keyboard_Modifiers>(modifier);
}
-Ecore_IMF_Keyboard_Locks InputMethodContextEcoreWl::EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
+Ecore_IMF_Keyboard_Locks InputMethodContextEcoreWl::EcoreInputModifierToEcoreIMFLock(unsigned int modifier)
{
- unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
+ unsigned int lock(ECORE_IMF_KEYBOARD_LOCK_NONE); // If no other matches, returns NONE.
- if( modifier & ECORE_EVENT_LOCK_NUM )
- {
- lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
- }
+ if(modifier & ECORE_EVENT_LOCK_NUM)
+ {
+ lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
+ }
- if( modifier & ECORE_EVENT_LOCK_CAPS )
- {
- lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
- }
+ if(modifier & ECORE_EVENT_LOCK_CAPS)
+ {
+ lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
+ }
- if( modifier & ECORE_EVENT_LOCK_SCROLL )
- {
- lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
- }
+ if(modifier & ECORE_EVENT_LOCK_SCROLL)
+ {
+ lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
+ }
- return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
+ return static_cast<Ecore_IMF_Keyboard_Locks>(lock);
}
-void InputMethodContextEcoreWl::OnStaged( Dali::Actor actor )
+void InputMethodContextEcoreWl::OnStaged(Dali::Actor actor)
{
- int windowId = GetWindowIdFromActor( actor );
+ int windowId = GetWindowIdFromActor(actor);
- if( mWindowId != windowId )
+ if(mWindowId != windowId)
{
mWindowId = windowId;
}
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace KeyLookup
{
-
// matches a DALI_KEY enum, to a key name
+// clang-format off
KeyLookup KeyLookupTable[]=
{
// more than one key name can be assigned to a single dali-key code
{ "Control_R", static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_RIGHT ), false },
{ "Return", static_cast<Dali::KEY>( DevelKey::DALI_KEY_RETURN ), false }
};
+// clang-format on
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup ));
+const std::size_t KEY_LOOKUP_COUNT = (sizeof(KeyLookupTable)) / (sizeof(KeyLookup));
} // namespace KeyLookup
/*
- * Copyright (c) 2019 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.
#include <dali/internal/input/common/virtual-keyboard-impl.h>
// EXTERNAL INCLUDES
-#include <algorithm>
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <algorithm>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/adaptor.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace VirtualKeyboard
{
-
Dali::InputMethod::ButtonAction::Type gButtonActionFunction = Dali::InputMethod::ButtonAction::DEFAULT;
-Ecore_IMF_Input_Panel_Return_Key_Type buttonActionMapping(Dali::InputMethod::ButtonAction::Type buttonAction )
+Ecore_IMF_Input_Panel_Return_Key_Type buttonActionMapping(Dali::InputMethod::ButtonAction::Type buttonAction)
{
- switch( buttonAction )
+ switch(buttonAction)
{
- case InputMethod::ButtonAction::DEFAULT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
- case InputMethod::ButtonAction::DONE: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
- case InputMethod::ButtonAction::GO: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
- case InputMethod::ButtonAction::JOIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
- case InputMethod::ButtonAction::LOGIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
- case InputMethod::ButtonAction::NEXT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
- case InputMethod::ButtonAction::SEARCH: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
- case InputMethod::ButtonAction::SEND: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
- case InputMethod::ButtonAction::SIGNIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
- default: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+ case InputMethod::ButtonAction::DEFAULT:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+ case InputMethod::ButtonAction::DONE:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
+ case InputMethod::ButtonAction::GO:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
+ case InputMethod::ButtonAction::JOIN:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
+ case InputMethod::ButtonAction::LOGIN:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
+ case InputMethod::ButtonAction::NEXT:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
+ case InputMethod::ButtonAction::SEARCH:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
+ case InputMethod::ButtonAction::SEND:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
+ case InputMethod::ButtonAction::SIGNIN:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
+ default:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
}
}
{
}
-void SetReturnKeyType( const InputMethod::ButtonAction::Type type )
+void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
{
}
/*
- * Copyright (c) 2018 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.
*
*/
-#include <memory>
#include <dali/internal/input/common/input-method-context-factory.h>
#include <dali/internal/input/ubuntu-x11/input-method-context-impl-x.h>
+#include <memory>
namespace Dali
{
namespace InputMethodContextFactory
{
-
// InputMethodContext Factory to be implemented by the platform
-InputMethodContextPtr CreateInputMethodContext( Dali::Actor actor )
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor)
{
- return Dali::Internal::Adaptor::InputMethodContextX::New( actor );
-}
-
-}
-
+ return Dali::Internal::Adaptor::InputMethodContextX::New(actor);
}
+} // namespace InputMethodContextFactory
+} // namespace Adaptor
-}
-}
\ No newline at end of file
+} // namespace Internal
+} // namespace Dali
\ No newline at end of file
/*
- * 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.
#include <dali/internal/input/ubuntu-x11/input-method-context-impl-x.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/key.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/input/common/key-impl.h>
#include <dali/internal/input/ubuntu-x11/dali-ecore-input.h>
#include <dali/internal/system/common/locale-utils.h>
#include <dali/internal/system/linux/dali-ecore.h>
+#include <dali/public-api/adaptor-framework/key.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
#if defined(DEBUG_ENABLED)
{
size_t length = 0;
- if( ( leadByte & 0x80 ) == 0 ) //ASCII character (lead bit zero)
+ if((leadByte & 0x80) == 0) //ASCII character (lead bit zero)
{
length = 1;
}
- else if( ( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
+ else if((leadByte & 0xe0) == 0xc0) //110x xxxx
{
length = 2;
}
- else if( ( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
+ else if((leadByte & 0xf0) == 0xe0) //1110 xxxx
{
length = 3;
}
- else if( ( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
+ else if((leadByte & 0xf8) == 0xf0) //1111 0xxx
{
length = 4;
}
- else if( ( leadByte & 0xfc ) == 0xf8 ) //1111 10xx
+ else if((leadByte & 0xfc) == 0xf8) //1111 10xx
{
length = 5;
}
- else if( ( leadByte & 0xfe ) == 0xfc ) //1111 110x
+ else if((leadByte & 0xfe) == 0xfc) //1111 110x
{
length = 6;
}
}
// Static function calls used by ecore 'c' style callback registration
-void Commit( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void Commit(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextX* inputMethodContext = static_cast< InputMethodContextX* >( data );
- inputMethodContext->CommitReceived( data, imfContext, eventInfo );
+ InputMethodContextX* inputMethodContext = static_cast<InputMethodContextX*>(data);
+ inputMethodContext->CommitReceived(data, imfContext, eventInfo);
}
}
-void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void PreEdit(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextX* inputMethodContext = static_cast< InputMethodContextX* >( data );
- inputMethodContext->PreEditChanged( data, imfContext, eventInfo );
+ InputMethodContextX* inputMethodContext = static_cast<InputMethodContextX*>(data);
+ inputMethodContext->PreEditChanged(data, imfContext, eventInfo);
}
}
-Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
+Eina_Bool ImfRetrieveSurrounding(void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition)
{
- if ( data )
+ if(data)
{
- InputMethodContextX* inputMethodContext = static_cast< InputMethodContextX* >( data );
- return inputMethodContext->RetrieveSurrounding( data, imfContext, text, cursorPosition );
+ InputMethodContextX* inputMethodContext = static_cast<InputMethodContextX*>(data);
+ return inputMethodContext->RetrieveSurrounding(data, imfContext, text, cursorPosition);
}
else
{
* Called when an InputMethodContext delete surrounding event is received.
* Here we tell the application that it should delete a certain range.
*/
-void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *eventInfo )
+void ImfDeleteSurrounding(void* data, Ecore_IMF_Context* imfContext, void* eventInfo)
{
- if ( data )
+ if(data)
{
- InputMethodContextX* inputMethodContext = static_cast< InputMethodContextX* >( data );
- inputMethodContext->DeleteSurrounding( data, imfContext, eventInfo );
+ InputMethodContextX* inputMethodContext = static_cast<InputMethodContextX*>(data);
+ inputMethodContext->DeleteSurrounding(data, imfContext, eventInfo);
}
}
} // unnamed namespace
-InputMethodContextPtr InputMethodContextX::New( Dali::Actor actor )
+InputMethodContextPtr InputMethodContextX::New(Dali::Actor actor)
{
InputMethodContextPtr manager;
- if( actor && Dali::Adaptor::IsAvailable() )
+ if(actor && Dali::Adaptor::IsAvailable())
{
- manager = new InputMethodContextX( actor );
+ manager = new InputMethodContextX(actor);
}
return manager;
void InputMethodContextX::Finalize()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Finalize\n" );
- VirtualKeyboard::DisconnectCallbacks( mIMFContext );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::Finalize\n");
+ VirtualKeyboard::DisconnectCallbacks(mIMFContext);
DisconnectCallbacks();
DeleteContext();
}
-InputMethodContextX::InputMethodContextX( Dali::Actor actor )
+InputMethodContextX::InputMethodContextX(Dali::Actor actor)
: mIMFContext(),
- mEcoreXwin( 0 ),
- mIMFCursorPosition( 0 ),
+ mEcoreXwin(0),
+ mIMFCursorPosition(0),
mSurroundingText(),
- mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false )
+ mRestoreAfterFocusLost(false),
+ mIdleCallbackConnected(false)
{
ecore_imf_init();
- actor.OnSceneSignal().Connect( this, &InputMethodContextX::OnStaged );
+ actor.OnSceneSignal().Connect(this, &InputMethodContextX::OnStaged);
}
InputMethodContextX::~InputMethodContextX()
{
CreateContext();
ConnectCallbacks();
- VirtualKeyboard::ConnectCallbacks( mIMFContext );
+ VirtualKeyboard::ConnectCallbacks(mIMFContext);
}
void InputMethodContextX::CreateContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::CreateContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::CreateContext\n");
- if( !mEcoreXwin )
+ if(!mEcoreXwin)
{
return;
}
- const char *contextId = ecore_imf_context_default_id_get();
- if( contextId )
+ const char* contextId = ecore_imf_context_default_id_get();
+ if(contextId)
{
- mIMFContext = ecore_imf_context_add( contextId );
+ mIMFContext = ecore_imf_context_add(contextId);
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast<void*>( mEcoreXwin ) );
+ ecore_imf_context_client_window_set(mIMFContext, reinterpret_cast<void*>(mEcoreXwin));
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n");
}
}
void InputMethodContextX::DeleteContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::DeleteContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::DeleteContext\n");
- if ( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_del( mIMFContext );
+ ecore_imf_context_del(mIMFContext);
mIMFContext = NULL;
}
}
// Callbacks for predicitive text support.
void InputMethodContextX::ConnectCallbacks()
{
- if ( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::ConnectCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::ConnectCallbacks\n");
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
- ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this);
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this);
+ ecore_imf_context_event_callback_add(mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this);
- ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
+ ecore_imf_context_retrieve_surrounding_callback_set(mIMFContext, ImfRetrieveSurrounding, this);
}
}
void InputMethodContextX::DisconnectCallbacks()
{
- if ( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::DisconnectCallbacks\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::DisconnectCallbacks\n");
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
- ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit);
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit);
+ ecore_imf_context_event_callback_del(mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding);
// We do not need to unset the retrieve surrounding callback.
}
// Reset mIdleCallbackConnected
mIdleCallbackConnected = false;
- if ( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Activate\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::Activate\n");
- ecore_imf_context_focus_in( mIMFContext );
+ ecore_imf_context_focus_in(mIMFContext);
// emit keyboard activated signal
- Dali::InputMethodContext handle( this );
- mActivatedSignal.Emit( handle );
+ Dali::InputMethodContext handle(this);
+ mActivatedSignal.Emit(handle);
}
}
void InputMethodContextX::Deactivate()
{
- if( mIMFContext )
+ if(mIMFContext)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Deactivate\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::Deactivate\n");
Reset();
- ecore_imf_context_focus_out( mIMFContext );
+ ecore_imf_context_focus_out(mIMFContext);
}
// Reset mIdleCallbackConnected
void InputMethodContextX::Reset()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::Reset\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::Reset\n");
- if ( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_reset( mIMFContext );
+ ecore_imf_context_reset(mIMFContext);
}
}
ImfContext* InputMethodContextX::GetContext()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetContext\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetContext\n");
return mIMFContext;
}
return mRestoreAfterFocusLost;
}
-void InputMethodContextX::SetRestoreAfterFocusLost( bool toggle )
+void InputMethodContextX::SetRestoreAfterFocusLost(bool toggle)
{
mRestoreAfterFocusLost = toggle;
}
* We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks
* the user wants to type.
*/
-void InputMethodContextX::PreEditChanged( void*, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextX::PreEditChanged(void*, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::PreEditChanged\n" );
- auto context = static_cast<Ecore_IMF_Context*>( imfContext );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::PreEditChanged\n");
+ auto context = static_cast<Ecore_IMF_Context*>(imfContext);
- char* preEditString( NULL );
- int cursorPosition( 0 );
+ char* preEditString(NULL);
+ int cursorPosition(0);
Eina_List* attrs = NULL;
- Eina_List* l = NULL;
+ Eina_List* l = NULL;
Ecore_IMF_Preedit_Attr* attr;
// Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
// the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
- ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition );
+ ecore_imf_context_preedit_string_with_attributes_get(context, &preEditString, &attrs, &cursorPosition);
- if ( attrs )
+ if(attrs)
{
// iterate through the list of attributes getting the type, start and end position.
- for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
+ for(l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>(eina_list_data_get(l))); l; l = eina_list_next(l), (attr = static_cast<Ecore_IMF_Preedit_Attr*>(eina_list_data_get(l))))
{
Dali::InputMethodContext::PreeditAttributeData data;
data.startIndex = 0;
- data.endIndex = 0;
+ data.endIndex = 0;
size_t visualCharacterIndex = 0;
- size_t byteIndex = 0;
+ size_t byteIndex = 0;
// iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
char leadByte = preEditString[byteIndex];
- while( leadByte != '\0' )
+ while(leadByte != '\0')
{
leadByte = preEditString[byteIndex]; // Update the character to get the number of its byte
// attr->end_index is provided as a byte position not character and we need to know the character position.
- const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
- if( byteIndex <= attr->start_index )
+ const size_t currentSequenceLength = Utf8SequenceLength(leadByte); // returns number of bytes used to represent character.
+ if(byteIndex <= attr->start_index)
{
- data.startIndex = visualCharacterIndex;
+ data.startIndex = visualCharacterIndex;
}
- if( byteIndex >= attr->end_index )
+ if(byteIndex >= attr->end_index)
{
data.endIndex = visualCharacterIndex;
break;
else
{
byteIndex += currentSequenceLength; // jump to next character
- visualCharacterIndex++; // increment character count so we know our position for when we get a match
+ visualCharacterIndex++; // increment character count so we know our position for when we get a match
}
}
- switch( attr->preedit_type )
+ switch(attr->preedit_type)
{
case ECORE_IMF_PREEDIT_TYPE_NONE:
{
break;
}
}
- mPreeditAttrs.PushBack( data );
+ mPreeditAttrs.PushBack(data);
}
}
- if ( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0 );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::EventData eventData(Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, eventData);
- if( callbackData.update )
+ if(callbackData.update)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
NotifyCursorPosition();
}
- if( callbackData.preeditResetRequired )
+ if(callbackData.preeditResetRequired)
{
Reset();
}
}
- free( preEditString );
+ free(preEditString);
}
-void InputMethodContextX::CommitReceived( void*, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextX::CommitReceived(void*, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::CommitReceived\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::CommitReceived\n");
- if ( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- const std::string keyString( static_cast<char*>( eventInfo ) );
+ const std::string keyString(static_cast<char*>(eventInfo));
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::EventData eventData(Dali::InputMethodContext::COMMIT, keyString, 0, 0);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, eventData);
- if( callbackData.update )
+ if(callbackData.update)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
NotifyCursorPosition();
}
* Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is
* We need to signal the application to tell us this information.
*/
-bool InputMethodContextX::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )
+bool InputMethodContextX::RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::RetrieveSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::RetrieveSurrounding\n");
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0);
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, imfData);
- if( callbackData.update )
+ if(callbackData.update)
{
- if( text )
+ if(text)
{
- *text = strdup( callbackData.currentText.c_str() );
+ *text = strdup(callbackData.currentText.c_str());
}
- if( cursorPosition )
+ if(cursorPosition)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
- *cursorPosition = mIMFCursorPosition;
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
+ *cursorPosition = mIMFCursorPosition;
}
}
* Called when an InputMethodContext delete surrounding event is received.
* Here we tell the application that it should delete a certain range.
*/
-void InputMethodContextX::DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo )
+void InputMethodContextX::DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::DeleteSurrounding\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::DeleteSurrounding\n");
- if( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
- Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( eventInfo );
+ Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>(eventInfo);
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
- Dali::InputMethodContext handle( this );
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars);
+ Dali::InputMethodContext handle(this);
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, imfData);
- if( callbackData.update )
+ if(callbackData.update)
{
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
NotifyCursorPosition();
}
void InputMethodContextX::NotifyCursorPosition()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::NotifyCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::NotifyCursorPosition\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
+ ecore_imf_context_cursor_position_set(mIMFContext, mIMFCursorPosition);
}
}
-void InputMethodContextX::SetCursorPosition( unsigned int cursorPosition )
+void InputMethodContextX::SetCursorPosition(unsigned int cursorPosition)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetCursorPosition\n");
- mIMFCursorPosition = static_cast<int>( cursorPosition );
+ mIMFCursorPosition = static_cast<int>(cursorPosition);
}
unsigned int InputMethodContextX::GetCursorPosition() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetCursorPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetCursorPosition\n");
- return static_cast<unsigned int>( mIMFCursorPosition );
+ return static_cast<unsigned int>(mIMFCursorPosition);
}
-void InputMethodContextX::SetSurroundingText( const std::string& text )
+void InputMethodContextX::SetSurroundingText(const std::string& text)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetSurroundingText\n");
mSurroundingText = text;
}
const std::string& InputMethodContextX::GetSurroundingText() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetSurroundingText\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetSurroundingText\n");
return mSurroundingText;
}
-void InputMethodContextX::NotifyTextInputMultiLine( bool multiLine )
+void InputMethodContextX::NotifyTextInputMultiLine(bool multiLine)
{
}
Dali::InputMethodContext::TextDirection InputMethodContextX::GetTextDirection()
{
- Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT );
+ Dali::InputMethodContext::TextDirection direction(Dali::InputMethodContext::LEFT_TO_RIGHT);
- if ( mIMFContext )
- {
- char* locale( NULL );
- ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
+ if(mIMFContext)
+ {
+ char* locale(NULL);
+ ecore_imf_context_input_panel_language_locale_get(mIMFContext, &locale);
- if ( locale )
- {
- direction = static_cast< Dali::InputMethodContext::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
- free( locale );
- }
+ if(locale)
+ {
+ direction = static_cast<Dali::InputMethodContext::TextDirection>(Locale::GetDirection(std::string(locale)));
+ free(locale);
}
+ }
return direction;
}
width = height = xPos = yPos = 0;
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
+ ecore_imf_context_input_panel_geometry_get(mIMFContext, &xPos, &yPos, &width, &height);
}
else
{
DALI_LOG_WARNING("VKB Unable to get InputMethodContext Context so GetSize unavailable\n");
}
- return Rect<int>(xPos,yPos,width,height);
+ return Rect<int>(xPos, yPos, width, height);
}
-void InputMethodContextX::ApplyOptions( const InputMethodOptions& options )
+void InputMethodContextX::ApplyOptions(const InputMethodOptions& options)
{
using namespace Dali::InputMethod::Category;
int index;
- if (mIMFContext == NULL)
+ if(mIMFContext == NULL)
{
DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
return;
}
- if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
+ if(mOptions.CompareAndSet(PANEL_LAYOUT, options, index))
{
}
- if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )
+ if(mOptions.CompareAndSet(BUTTON_ACTION, options, index))
{
}
- if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )
+ if(mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index))
{
}
- if ( mOptions.CompareAndSet(VARIATION, options, index) )
+ if(mOptions.CompareAndSet(VARIATION, options, index))
{
}
}
-void InputMethodContextX::SetInputPanelData( const std::string& data )
+void InputMethodContextX::SetInputPanelData(const std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelData\n");
- if( mIMFContext )
+ if(mIMFContext)
{
int length = data.length();
- ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
+ ecore_imf_context_input_panel_imdata_set(mIMFContext, data.c_str(), length);
}
}
-void InputMethodContextX::GetInputPanelData( std::string& data )
+void InputMethodContextX::GetInputPanelData(std::string& data)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelData\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelData\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- int length = 4096; // The max length is 4096 bytes
- Dali::Vector< char > buffer;
- buffer.Resize( length );
- ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );
- data = std::string( buffer.Begin(), buffer.End() );
+ int length = 4096; // The max length is 4096 bytes
+ Dali::Vector<char> buffer;
+ buffer.Resize(length);
+ ecore_imf_context_input_panel_imdata_get(mIMFContext, &buffer[0], &length);
+ data = std::string(buffer.Begin(), buffer.End());
}
}
Dali::InputMethodContext::State InputMethodContextX::GetInputPanelState()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelState\n");
- if( mIMFContext )
+ if(mIMFContext)
{
int value;
- value = ecore_imf_context_input_panel_state_get( mIMFContext );
+ value = ecore_imf_context_input_panel_state_get(mIMFContext);
- switch (value)
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
{
return Dali::InputMethodContext::DEFAULT;
}
-void InputMethodContextX::SetReturnKeyState( bool visible )
+void InputMethodContextX::SetReturnKeyState(bool visible)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetReturnKeyState\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetReturnKeyState\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
+ ecore_imf_context_input_panel_return_key_disabled_set(mIMFContext, !visible);
}
}
-void InputMethodContextX::AutoEnableInputPanel( bool enabled )
+void InputMethodContextX::AutoEnableInputPanel(bool enabled)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::AutoEnableInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::AutoEnableInputPanel\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
+ ecore_imf_context_input_panel_enabled_set(mIMFContext, enabled);
}
}
void InputMethodContextX::ShowInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::ShowInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::ShowInputPanel\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_show( mIMFContext );
+ ecore_imf_context_input_panel_show(mIMFContext);
}
}
void InputMethodContextX::HideInputPanel()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::HideInputPanel\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::HideInputPanel\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_input_panel_hide( mIMFContext );
+ ecore_imf_context_input_panel_hide(mIMFContext);
}
}
std::string InputMethodContextX::GetInputPanelLocale()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLocale\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLocale\n");
std::string locale = "";
- if( mIMFContext )
+ if(mIMFContext)
{
char* value = NULL;
- ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
+ ecore_imf_context_input_panel_language_locale_get(mIMFContext, &value);
- if( value )
+ if(value)
{
- std::string valueCopy( value );
+ std::string valueCopy(value);
locale = valueCopy;
// The locale string retrieved must be freed with free().
- free( value );
+ free(value);
}
}
return locale;
}
-void InputMethodContextX::SetContentMIMETypes( const std::string& mimeTypes )
+void InputMethodContextX::SetContentMIMETypes(const std::string& mimeTypes)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetContentMIMETypes\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetContentMIMETypes\n");
// ecore_imf_context_mime_type_accept_set() is supported from ecore-imf 1.20.0 version.
}
-bool InputMethodContextX::FilterEventKey( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextX::FilterEventKey(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
+ bool eventHandled(false);
// If a device key then skip ecore_imf_context_filter_event.
- if ( ! KeyLookup::IsDeviceButton( keyEvent.GetKeyName().c_str() ))
+ if(!KeyLookup::IsDeviceButton(keyEvent.GetKeyName().c_str()))
{
//check whether it's key down or key up event
- if ( keyEvent.GetState() == Dali::KeyEvent::DOWN )
+ if(keyEvent.GetState() == Dali::KeyEvent::DOWN)
{
- eventHandled = ProcessEventKeyDown( keyEvent );
+ eventHandled = ProcessEventKeyDown(keyEvent);
}
- else if ( keyEvent.GetState() == Dali::KeyEvent::UP )
+ else if(keyEvent.GetState() == Dali::KeyEvent::UP)
{
- eventHandled = ProcessEventKeyUp( keyEvent );
+ eventHandled = ProcessEventKeyUp(keyEvent);
}
}
return eventHandled;
}
-void InputMethodContextX::AllowTextPrediction( bool prediction )
+void InputMethodContextX::AllowTextPrediction(bool prediction)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::AllowTextPrediction\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::AllowTextPrediction\n");
- if( mIMFContext )
+ if(mIMFContext)
{
- ecore_imf_context_prediction_allow_set( mIMFContext, prediction );
+ ecore_imf_context_prediction_allow_set(mIMFContext, prediction);
}
}
bool InputMethodContextX::IsTextPredictionAllowed() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::IsTextPredictionAllowed\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::IsTextPredictionAllowed\n");
bool prediction = false;
- if( mIMFContext )
+ if(mIMFContext)
{
- prediction = ecore_imf_context_prediction_allow_get( mIMFContext );
+ prediction = ecore_imf_context_prediction_allow_get(mIMFContext);
}
return prediction;
}
-void InputMethodContextX::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )
+void InputMethodContextX::SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelLanguage\n" );
- if( mIMFContext )
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelLanguage\n");
+ if(mIMFContext)
{
- switch (language)
+ switch(language)
{
case Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC:
{
- ecore_imf_context_input_panel_language_set( mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC );
+ ecore_imf_context_input_panel_language_set(mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC);
break;
}
case Dali::InputMethodContext::InputPanelLanguage::ALPHABET:
{
- ecore_imf_context_input_panel_language_set( mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET );
+ ecore_imf_context_input_panel_language_set(mIMFContext, ECORE_IMF_INPUT_PANEL_LANG_ALPHABET);
break;
}
}
Dali::InputMethodContext::InputPanelLanguage InputMethodContextX::GetInputPanelLanguage() const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLanguage\n" );
- if( mIMFContext )
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetInputPanelLanguage\n");
+ if(mIMFContext)
{
int value;
- value = ecore_imf_context_input_panel_language_get( mIMFContext );
+ value = ecore_imf_context_input_panel_language_get(mIMFContext);
- switch (value)
+ switch(value)
{
case ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC:
{
return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
}
-void InputMethodContextX::SetInputPanelPosition( unsigned int x, unsigned int y )
+void InputMethodContextX::SetInputPanelPosition(unsigned int x, unsigned int y)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelPosition\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelPosition\n");
// ecore_imf_context_input_panel_position_set() is supported from ecore-imf 1.21.0 version.
}
-void InputMethodContextX::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const
+void InputMethodContextX::GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n");
attrs = mPreeditAttrs;
}
-bool InputMethodContextX::ProcessEventKeyDown( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextX::ProcessEventKeyDown(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
- if ( mIMFContext )
+ bool eventHandled(false);
+ if(mIMFContext)
{
- Integration::KeyEvent integKeyEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
- std::string key = integKeyEvent.logicalKey;
+ Integration::KeyEvent integKeyEvent(keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast<Integration::KeyEvent::State>(keyEvent.GetState()), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass());
+ std::string key = integKeyEvent.logicalKey;
std::string compose = integKeyEvent.compose;
// We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well.
Ecore_IMF_Event_Key_Down ecoreKeyDownEvent;
- ecoreKeyDownEvent.keyname = integKeyEvent.keyName.c_str();
- ecoreKeyDownEvent.key = key.c_str();
- ecoreKeyDownEvent.string = integKeyEvent.keyString.c_str();
- ecoreKeyDownEvent.compose = compose.c_str();
+ ecoreKeyDownEvent.keyname = integKeyEvent.keyName.c_str();
+ ecoreKeyDownEvent.key = key.c_str();
+ ecoreKeyDownEvent.string = integKeyEvent.keyString.c_str();
+ ecoreKeyDownEvent.compose = compose.c_str();
ecoreKeyDownEvent.timestamp = integKeyEvent.time;
- ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( integKeyEvent.keyModifier );
- ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( integKeyEvent.keyModifier );
+ ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier(integKeyEvent.keyModifier);
+ ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock(integKeyEvent.keyModifier);
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR)
-#if (ECORE_VERSION_MINOR >= 14)
- ecoreKeyDownEvent.dev_name = "";
- ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
+#if(ECORE_VERSION_MINOR >= 14)
+ ecoreKeyDownEvent.dev_name = "";
+ ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
#endif // Since ecore_imf 1.14 version
-#if (ECORE_VERSION_MINOR >= 22)
+#if(ECORE_VERSION_MINOR >= 22)
ecoreKeyDownEvent.keycode = integKeyEvent.keyCode;
#endif // Since ecore_imf 1.22 version
#endif // Since ecore_imf Version 1
// If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor.
- if ((integKeyEvent.deviceName == "ime") && ((!strncmp(integKeyEvent.keyName.c_str(), "Left", 4)) ||
- (!strncmp(integKeyEvent.keyName.c_str(), "Right", 5)) ||
- (!strncmp(integKeyEvent.keyName.c_str(), "Up", 2)) ||
- (!strncmp(integKeyEvent.keyName.c_str(), "Down", 4))))
+ if((integKeyEvent.deviceName == "ime") && ((!strncmp(integKeyEvent.keyName.c_str(), "Left", 4)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Right", 5)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Up", 2)) ||
+ (!strncmp(integKeyEvent.keyName.c_str(), "Down", 4))))
{
eventHandled = 0;
}
{
eventHandled = ecore_imf_context_filter_event(mIMFContext,
ECORE_IMF_EVENT_KEY_DOWN,
- reinterpret_cast<Ecore_IMF_Event *>( &ecoreKeyDownEvent ));
+ reinterpret_cast<Ecore_IMF_Event*>(&ecoreKeyDownEvent));
}
// If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext
- if (!eventHandled)
+ if(!eventHandled)
{
- if (!strcmp(integKeyEvent.keyName.c_str(), "Escape") ||
- !strcmp(integKeyEvent.keyName.c_str(), "Return") ||
- !strcmp(integKeyEvent.keyName.c_str(), "KP_Enter"))
+ if(!strcmp(integKeyEvent.keyName.c_str(), "Escape") ||
+ !strcmp(integKeyEvent.keyName.c_str(), "Return") ||
+ !strcmp(integKeyEvent.keyName.c_str(), "KP_Enter"))
{
ecore_imf_context_reset(mIMFContext);
}
return eventHandled;
}
-bool InputMethodContextX::ProcessEventKeyUp( const Dali::KeyEvent& keyEvent )
+bool InputMethodContextX::ProcessEventKeyUp(const Dali::KeyEvent& keyEvent)
{
- bool eventHandled( false );
- if( mIMFContext )
+ bool eventHandled(false);
+ if(mIMFContext)
{
- Integration::KeyEvent integKeyEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() );
+ Integration::KeyEvent integKeyEvent(keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast<Integration::KeyEvent::State>(keyEvent.GetState()), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass());
std::string key = integKeyEvent.logicalKey;
// We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well.
Ecore_IMF_Event_Key_Up ecoreKeyUpEvent;
- ecoreKeyUpEvent.keyname = integKeyEvent.keyName.c_str();
- ecoreKeyUpEvent.key = key.c_str();
- ecoreKeyUpEvent.string = integKeyEvent.keyString.c_str();
- ecoreKeyUpEvent.compose = compose.c_str();
+ ecoreKeyUpEvent.keyname = integKeyEvent.keyName.c_str();
+ ecoreKeyUpEvent.key = key.c_str();
+ ecoreKeyUpEvent.string = integKeyEvent.keyString.c_str();
+ ecoreKeyUpEvent.compose = compose.c_str();
ecoreKeyUpEvent.timestamp = integKeyEvent.time;
- ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( integKeyEvent.keyModifier );
- ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( integKeyEvent.keyModifier );
+ ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier(integKeyEvent.keyModifier);
+ ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock(integKeyEvent.keyModifier);
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR)
-#if (ECORE_VERSION_MINOR >= 14)
- ecoreKeyUpEvent.dev_name = "";
+#if(ECORE_VERSION_MINOR >= 14)
+ ecoreKeyUpEvent.dev_name = "";
#endif // Since ecore_imf 1.14 version
-#if (ECORE_VERSION_MINOR >= 22)
+#if(ECORE_VERSION_MINOR >= 22)
ecoreKeyUpEvent.keycode = integKeyEvent.keyCode;
#endif // Since ecore_imf 1.22 version
#endif // Since ecore_imf Version 1
eventHandled = ecore_imf_context_filter_event(mIMFContext,
ECORE_IMF_EVENT_KEY_UP,
- reinterpret_cast<Ecore_IMF_Event *>( &ecoreKeyUpEvent ));
+ reinterpret_cast<Ecore_IMF_Event*>(&ecoreKeyUpEvent));
}
return eventHandled;
}
-Ecore_IMF_Keyboard_Modifiers InputMethodContextX::EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier )
+Ecore_IMF_Keyboard_Modifiers InputMethodContextX::EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
{
- unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE.
+ unsigned int modifier(ECORE_IMF_KEYBOARD_MODIFIER_NONE); // If no other matches returns NONE.
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT) // enums from ecore_input/Ecore_Input.h
{
- modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
+ modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_ALT)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_CTRL)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_WIN)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
}
- if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR )
+ if(ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR)
{
modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR;
}
- return static_cast<Ecore_IMF_Keyboard_Modifiers>( modifier );
+ return static_cast<Ecore_IMF_Keyboard_Modifiers>(modifier);
}
-Ecore_IMF_Keyboard_Locks InputMethodContextX::EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
+Ecore_IMF_Keyboard_Locks InputMethodContextX::EcoreInputModifierToEcoreIMFLock(unsigned int modifier)
{
- unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
+ unsigned int lock(ECORE_IMF_KEYBOARD_LOCK_NONE); // If no other matches, returns NONE.
- if( modifier & ECORE_EVENT_LOCK_NUM )
- {
- lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
- }
+ if(modifier & ECORE_EVENT_LOCK_NUM)
+ {
+ lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
+ }
- if( modifier & ECORE_EVENT_LOCK_CAPS )
- {
- lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
- }
+ if(modifier & ECORE_EVENT_LOCK_CAPS)
+ {
+ lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
+ }
- if( modifier & ECORE_EVENT_LOCK_SCROLL )
- {
- lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
- }
+ if(modifier & ECORE_EVENT_LOCK_SCROLL)
+ {
+ lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
+ }
- return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
+ return static_cast<Ecore_IMF_Keyboard_Locks>(lock);
}
-void InputMethodContextX::OnStaged( Dali::Actor actor )
+void InputMethodContextX::OnStaged(Dali::Actor actor)
{
- Ecore_X_Window ecoreXwin( AnyCast< Ecore_X_Window >( Dali::Integration::SceneHolder::Get( actor ).GetNativeHandle() ) );
+ Ecore_X_Window ecoreXwin(AnyCast<Ecore_X_Window>(Dali::Integration::SceneHolder::Get(actor).GetNativeHandle()));
- if( mEcoreXwin != ecoreXwin )
+ if(mEcoreXwin != ecoreXwin)
{
mEcoreXwin = ecoreXwin;
}
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace KeyLookup
{
-
// matches a DALI_KEY enum, to a key name
+// clang-format off
KeyLookup KeyLookupTable[]=
{
// more than one key name can be assigned to a single dali-key code
{ "Control_R", static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_RIGHT ), false },
{ "Return", static_cast<Dali::KEY>( DevelKey::DALI_KEY_RETURN ), false }
};
+// clang-format on
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup ));
+const std::size_t KEY_LOOKUP_COUNT = (sizeof(KeyLookupTable)) / (sizeof(KeyLookup));
} // namespace KeyLookup
/*
- * Copyright (c) 2019 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.
#include <dali/internal/input/common/virtual-keyboard-impl.h>
// EXTERNAL INCLUDES
-#include <algorithm>
#include <X11/Xlib.h>
#include <dali/integration-api/debug.h>
+#include <algorithm>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/adaptor.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace VirtualKeyboard
{
-
Dali::InputMethod::ButtonAction::Type gButtonActionFunction = Dali::InputMethod::ButtonAction::DEFAULT;
-Ecore_IMF_Input_Panel_Return_Key_Type buttonActionMapping(Dali::InputMethod::ButtonAction::Type buttonAction )
+Ecore_IMF_Input_Panel_Return_Key_Type buttonActionMapping(Dali::InputMethod::ButtonAction::Type buttonAction)
{
- switch( buttonAction )
+ switch(buttonAction)
{
- case InputMethod::ButtonAction::DEFAULT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
- case InputMethod::ButtonAction::DONE: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
- case InputMethod::ButtonAction::GO: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
- case InputMethod::ButtonAction::JOIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
- case InputMethod::ButtonAction::LOGIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
- case InputMethod::ButtonAction::NEXT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
- case InputMethod::ButtonAction::SEARCH: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
- case InputMethod::ButtonAction::SEND: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
- case InputMethod::ButtonAction::SIGNIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
- default: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+ case InputMethod::ButtonAction::DEFAULT:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
+ case InputMethod::ButtonAction::DONE:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE;
+ case InputMethod::ButtonAction::GO:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO;
+ case InputMethod::ButtonAction::JOIN:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN;
+ case InputMethod::ButtonAction::LOGIN:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN;
+ case InputMethod::ButtonAction::NEXT:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT;
+ case InputMethod::ButtonAction::SEARCH:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH;
+ case InputMethod::ButtonAction::SEND:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND;
+ case InputMethod::ButtonAction::SIGNIN:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN;
+ default:
+ return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
}
}
{
// Get focus window used by Keyboard and rotate it
Display* display = XOpenDisplay(0);
- if (display)
+ if(display)
{
::Window focusWindow;
- int revert;
+ int revert;
// Get Focus window
XGetInputFocus(display, &focusWindow, &revert);
- ecore_x_window_prop_property_set( static_cast<Ecore_X_Window>( focusWindow ),
- ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
- ECORE_X_ATOM_CARDINAL, 32, &angle, 1 );
+ ecore_x_window_prop_property_set(static_cast<Ecore_X_Window>(focusWindow),
+ ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
+ ECORE_X_ATOM_CARDINAL,
+ 32,
+ &angle,
+ 1);
XCloseDisplay(display);
}
}
-void SetReturnKeyType( const InputMethod::ButtonAction::Type type )
+void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
{
}
/*
- * Copyright (c) 2018 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.
*
*/
-#include <memory>
#include <dali/internal/input/common/input-method-context-factory.h>
#include <dali/internal/input/windows/input-method-context-impl-win.h>
+#include <memory>
namespace Dali
{
namespace InputMethodContextFactory
{
-
// InputMethodContext Factory to be implemented by the platform
-InputMethodContextPtr CreateInputMethodContext( Dali::Actor actor )
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor)
{
- return Dali::Internal::Adaptor::InputMethodContextWin::New( actor );
-}
-
-}
-
+ return Dali::Internal::Adaptor::InputMethodContextWin::New(actor);
}
+} // namespace InputMethodContextFactory
+} // namespace Adaptor
-}
-}
\ No newline at end of file
+} // namespace Internal
+} // namespace Dali
\ No newline at end of file
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
#include <dali/internal/input/windows/input-method-context-impl-win.h>\r
\r
// EXTERNAL INCLUDES\r
-#include <dali/public-api/events/key-event.h>\r
-#include <dali/public-api/object/type-registry.h>\r
#include <dali/devel-api/common/singleton-service.h>\r
#include <dali/integration-api/debug.h>\r
+#include <dali/public-api/events/key-event.h>\r
+#include <dali/public-api/object/type-registry.h>\r
\r
// INTERNAL INCLUDES\r
-#include <dali/public-api/adaptor-framework/key.h>\r
#include <dali/integration-api/adaptor-framework/adaptor.h>\r
#include <dali/internal/adaptor/common/adaptor-impl.h>\r
#include <dali/internal/input/common/key-impl.h>\r
#include <dali/internal/input/common/virtual-keyboard-impl.h>\r
#include <dali/internal/system/common/locale-utils.h>\r
+#include <dali/public-api/adaptor-framework/key.h>\r
\r
namespace Dali\r
{\r
-\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
namespace\r
{\r
#if defined(DEBUG_ENABLED)\r
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT" );\r
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT");\r
#endif\r
-}\r
+} // namespace\r
\r
-InputMethodContextPtr InputMethodContextWin::New( Dali::Actor actor )\r
+InputMethodContextPtr InputMethodContextWin::New(Dali::Actor actor)\r
{\r
InputMethodContextPtr manager;\r
\r
- if ( actor && Adaptor::IsAvailable() )\r
+ if(actor && Adaptor::IsAvailable())\r
{\r
- manager = new InputMethodContextWin( actor );\r
+ manager = new InputMethodContextWin(actor);\r
}\r
\r
return manager;\r
{\r
}\r
\r
-InputMethodContextWin::InputMethodContextWin( Dali::Actor actor )\r
-: mWin32Window( 0 ),\r
- mIMFCursorPosition( 0 ),\r
+InputMethodContextWin::InputMethodContextWin(Dali::Actor actor)\r
+: mWin32Window(0),\r
+ mIMFCursorPosition(0),\r
mSurroundingText(),\r
- mRestoreAfterFocusLost( false ),\r
- mIdleCallbackConnected( false )\r
+ mRestoreAfterFocusLost(false),\r
+ mIdleCallbackConnected(false)\r
{\r
-\r
- actor.OnSceneSignal().Connect( this, &InputMethodContextWin::OnStaged );\r
+ actor.OnSceneSignal().Connect(this, &InputMethodContextWin::OnStaged);\r
}\r
\r
InputMethodContextWin::~InputMethodContextWin()\r
\r
void InputMethodContextWin::Initialize()\r
{\r
- CreateContext( mWin32Window );\r
+ CreateContext(mWin32Window);\r
ConnectCallbacks();\r
}\r
\r
-void InputMethodContextWin::CreateContext( WinWindowHandle winHandle )\r
+void InputMethodContextWin::CreateContext(WinWindowHandle winHandle)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CreateContext\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::CreateContext\n");\r
}\r
\r
void InputMethodContextWin::DeleteContext()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteContext\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::DeleteContext\n");\r
}\r
\r
// Callbacks for predicitive text support.\r
\r
void InputMethodContextWin::Reset()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Reset\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::Reset\n");\r
}\r
\r
ImfContext* InputMethodContextWin::GetContext()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetContext\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetContext\n");\r
\r
return NULL;\r
}\r
return mRestoreAfterFocusLost;\r
}\r
\r
-void InputMethodContextWin::SetRestoreAfterFocusLost( bool toggle )\r
+void InputMethodContextWin::SetRestoreAfterFocusLost(bool toggle)\r
{\r
mRestoreAfterFocusLost = toggle;\r
}\r
* We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks\r
* the user wants to type.\r
*/\r
-void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* eventInfo )\r
+void InputMethodContextWin::PreEditChanged(void*, ImfContext* imfContext, void* eventInfo)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n");\r
}\r
\r
-void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* eventInfo )\r
+void InputMethodContextWin::CommitReceived(void*, ImfContext* imfContext, void* eventInfo)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n");\r
\r
- if ( Dali::Adaptor::IsAvailable() )\r
+ if(Dali::Adaptor::IsAvailable())\r
{\r
- const std::string keyString( static_cast<char*>( eventInfo ) );\r
+ const std::string keyString(static_cast<char*>(eventInfo));\r
\r
- Dali::InputMethodContext handle( this );\r
- Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );\r
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );\r
+ Dali::InputMethodContext handle(this);\r
+ Dali::InputMethodContext::EventData eventData(Dali::InputMethodContext::COMMIT, keyString, 0, 0);\r
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, eventData);\r
\r
- if( callbackData.update )\r
+ if(callbackData.update)\r
{\r
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);\r
\r
NotifyCursorPosition();\r
}\r
* Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is\r
* We need to signal the application to tell us this information.\r
*/\r
-bool InputMethodContextWin::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )\r
+bool InputMethodContextWin::RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::RetrieveSurrounding\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::RetrieveSurrounding\n");\r
\r
- Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );\r
- Dali::InputMethodContext handle( this );\r
- Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );\r
+ Dali::InputMethodContext::EventData imfData(Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0);\r
+ Dali::InputMethodContext handle(this);\r
+ Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit(handle, imfData);\r
\r
- if( callbackData.update )\r
+ if(callbackData.update)\r
{\r
- if( text )\r
+ if(text)\r
{\r
- *text = strdup( callbackData.currentText.c_str() );\r
+ *text = strdup(callbackData.currentText.c_str());\r
}\r
\r
- if( cursorPosition )\r
+ if(cursorPosition)\r
{\r
- mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
- *cursorPosition = mIMFCursorPosition;\r
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);\r
+ *cursorPosition = mIMFCursorPosition;\r
}\r
}\r
\r
* Called when an InputMethodContext delete surrounding event is received.\r
* Here we tell the application that it should delete a certain range.\r
*/\r
-void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo )\r
+void InputMethodContextWin::DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n");\r
}\r
\r
void InputMethodContextWin::NotifyCursorPosition()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::NotifyCursorPosition\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::NotifyCursorPosition\n");\r
}\r
\r
-void InputMethodContextWin::SetCursorPosition( unsigned int cursorPosition )\r
+void InputMethodContextWin::SetCursorPosition(unsigned int cursorPosition)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetCursorPosition\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetCursorPosition\n");\r
\r
- mIMFCursorPosition = static_cast<int>( cursorPosition );\r
+ mIMFCursorPosition = static_cast<int>(cursorPosition);\r
}\r
\r
unsigned int InputMethodContextWin::GetCursorPosition() const\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetCursorPosition\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetCursorPosition\n");\r
\r
- return static_cast<unsigned int>( mIMFCursorPosition );\r
+ return static_cast<unsigned int>(mIMFCursorPosition);\r
}\r
\r
-void InputMethodContextWin::SetSurroundingText( const std::string& text )\r
+void InputMethodContextWin::SetSurroundingText(const std::string& text)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetSurroundingText\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetSurroundingText\n");\r
\r
mSurroundingText = text;\r
}\r
\r
const std::string& InputMethodContextWin::GetSurroundingText() const\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetSurroundingText\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetSurroundingText\n");\r
\r
return mSurroundingText;\r
}\r
\r
-void InputMethodContextWin::NotifyTextInputMultiLine( bool multiLine )\r
+void InputMethodContextWin::NotifyTextInputMultiLine(bool multiLine)\r
{\r
}\r
\r
Dali::InputMethodContext::TextDirection InputMethodContextWin::GetTextDirection()\r
{\r
- Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LEFT_TO_RIGHT );\r
+ Dali::InputMethodContext::TextDirection direction(Dali::InputMethodContext::LEFT_TO_RIGHT);\r
\r
return direction;\r
}\r
\r
width = height = xPos = yPos = 0;\r
\r
- return Rect<int>(xPos,yPos,width,height);\r
+ return Rect<int>(xPos, yPos, width, height);\r
}\r
\r
-void InputMethodContextWin::ApplyOptions( const InputMethodOptions& options )\r
+void InputMethodContextWin::ApplyOptions(const InputMethodOptions& options)\r
{\r
using namespace Dali::InputMethod::Category;\r
\r
int index;\r
\r
- if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )\r
+ if(mOptions.CompareAndSet(PANEL_LAYOUT, options, index))\r
{\r
}\r
- if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )\r
+ if(mOptions.CompareAndSet(BUTTON_ACTION, options, index))\r
{\r
}\r
- if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )\r
+ if(mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index))\r
{\r
}\r
- if ( mOptions.CompareAndSet(VARIATION, options, index) )\r
+ if(mOptions.CompareAndSet(VARIATION, options, index))\r
{\r
}\r
}\r
\r
-void InputMethodContextWin::SetInputPanelData( const std::string& data )\r
+void InputMethodContextWin::SetInputPanelData(const std::string& data)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelData\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelData\n");\r
}\r
\r
-void InputMethodContextWin::GetInputPanelData( std::string& data )\r
+void InputMethodContextWin::GetInputPanelData(std::string& data)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelData\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelData\n");\r
}\r
\r
Dali::InputMethodContext::State InputMethodContextWin::GetInputPanelState()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelState\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelState\n");\r
return Dali::InputMethodContext::DEFAULT;\r
}\r
\r
-void InputMethodContextWin::SetReturnKeyState( bool visible )\r
+void InputMethodContextWin::SetReturnKeyState(bool visible)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetReturnKeyState\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetReturnKeyState\n");\r
}\r
\r
-void InputMethodContextWin::AutoEnableInputPanel( bool enabled )\r
+void InputMethodContextWin::AutoEnableInputPanel(bool enabled)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::AutoEnableInputPanel\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::AutoEnableInputPanel\n");\r
}\r
\r
void InputMethodContextWin::ShowInputPanel()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ShowInputPanel\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::ShowInputPanel\n");\r
}\r
\r
void InputMethodContextWin::HideInputPanel()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::HideInputPanel\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::HideInputPanel\n");\r
}\r
\r
Dali::InputMethodContext::KeyboardType InputMethodContextWin::GetKeyboardType()\r
\r
std::string InputMethodContextWin::GetInputPanelLocale()\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLocale\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLocale\n");\r
\r
std::string locale = "";\r
return locale;\r
}\r
\r
-void InputMethodContextWin::SetContentMIMETypes( const std::string& mimeTypes )\r
+void InputMethodContextWin::SetContentMIMETypes(const std::string& mimeTypes)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetContentMIMETypes\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetContentMIMETypes\n");\r
}\r
\r
-bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent )\r
+bool InputMethodContextWin::FilterEventKey(const Dali::KeyEvent& keyEvent)\r
{\r
- bool eventHandled( false );\r
+ bool eventHandled(false);\r
\r
- if ( ! KeyLookup::IsDeviceButton( keyEvent.GetKeyName().c_str() ))\r
+ if(!KeyLookup::IsDeviceButton(keyEvent.GetKeyName().c_str()))\r
{\r
//check whether it's key down or key up event\r
- if ( keyEvent.GetState() == Dali::KeyEvent::DOWN )\r
+ if(keyEvent.GetState() == Dali::KeyEvent::DOWN)\r
{\r
- eventHandled = ProcessEventKeyDown( keyEvent );\r
+ eventHandled = ProcessEventKeyDown(keyEvent);\r
}\r
- else if ( keyEvent.GetState() == Dali::KeyEvent::UP )\r
+ else if(keyEvent.GetState() == Dali::KeyEvent::UP)\r
{\r
- eventHandled = ProcessEventKeyUp( keyEvent );\r
+ eventHandled = ProcessEventKeyUp(keyEvent);\r
}\r
}\r
\r
return eventHandled;\r
}\r
\r
-void InputMethodContextWin::SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language )\r
+void InputMethodContextWin::SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelLanguage\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelLanguage\n");\r
}\r
\r
Dali::InputMethodContext::InputPanelLanguage InputMethodContextWin::GetInputPanelLanguage() const\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLanguage\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLanguage\n");\r
return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;\r
}\r
\r
-void InputMethodContextWin::SetInputPanelPosition( unsigned int x, unsigned int y )\r
+void InputMethodContextWin::SetInputPanelPosition(unsigned int x, unsigned int y)\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelPosition\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelPosition\n");\r
}\r
\r
-void InputMethodContextWin::GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const\r
+void InputMethodContextWin::GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const\r
{\r
- DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetPreeditStyle\n" );\r
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextWin::GetPreeditStyle\n");\r
attrs = mPreeditAttrs;\r
}\r
\r
-bool InputMethodContextWin::ProcessEventKeyDown( const Dali::KeyEvent& keyEvent )\r
+bool InputMethodContextWin::ProcessEventKeyDown(const Dali::KeyEvent& keyEvent)\r
{\r
- bool eventHandled( false );\r
+ bool eventHandled(false);\r
return eventHandled;\r
}\r
\r
-bool InputMethodContextWin::ProcessEventKeyUp( const Dali::KeyEvent& keyEvent )\r
+bool InputMethodContextWin::ProcessEventKeyUp(const Dali::KeyEvent& keyEvent)\r
{\r
- bool eventHandled( false );\r
+ bool eventHandled(false);\r
return eventHandled;\r
}\r
\r
-void InputMethodContextWin::OnStaged( Dali::Actor actor )\r
+void InputMethodContextWin::OnStaged(Dali::Actor actor)\r
{\r
- WinWindowHandle winWindow( AnyCast< WinWindowHandle >( Dali::Integration::SceneHolder::Get( actor ).GetNativeHandle() ) );\r
+ WinWindowHandle winWindow(AnyCast<WinWindowHandle>(Dali::Integration::SceneHolder::Get(actor).GetNativeHandle()));\r
\r
- if( mWin32Window != winWindow )\r
+ if(mWin32Window != winWindow)\r
{\r
mWin32Window = winWindow;\r
\r
}\r
}\r
\r
-} // Adaptor\r
-\r
-} // Internal\r
+} // namespace Adaptor\r
\r
-} // Dali\r
+} // namespace Internal\r
\r
+} // namespace Dali\r
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace KeyLookup
{
-
// matches a DALI_KEY enum, to key name
+// clang-format off
KeyLookup KeyLookupTable[]=
{
// more than one key name can be assigned to a single dali-key code
{ "Control_L", static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_LEFT ), false },
{ "Control_R", static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_RIGHT ), false }
};
+// clang-format on
-const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup ));
+const std::size_t KEY_LOOKUP_COUNT = (sizeof(KeyLookupTable)) / (sizeof(KeyLookup));
} // namespace KeyLookup
/*
- * 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace VirtualKeyboard
{
void Show()
void Hide()
{
-
}
bool IsVisible()
return false;
}
-void ApplySettings( const Property::Map& settingsMap )
+void ApplySettings(const Property::Map& settingsMap)
{
-
}
-void EnablePrediction( const bool enable )
+void EnablePrediction(const bool enable)
{
-
}
bool IsPredictionEnabled()
{
}
-void SetReturnKeyType( const InputMethod::ButtonAction::Type type )
+void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
{
}
/*
- * Copyright (c) 2019 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.
#include <dali/internal/legacy/common/tizen-platform-abstraction.h>
// EXTERNAL INCLUDES
-#include <dirent.h>
-#include <fstream>
-#include <algorithm>
-#include <dali/integration-api/debug.h>
#include <dali/integration-api/bitmap.h>
+#include <dali/integration-api/debug.h>
#include <dali/integration-api/resource-types.h>
#include <dali/public-api/signals/callback.h>
+#include <dirent.h>
+#include <algorithm>
+#include <fstream>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/imaging/common/image-loader.h>
-#include <dali/internal/system/common/file-reader.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
-#include <dali/devel-api/adaptor-framework/file-loader.h>
+#include <dali/internal/system/common/file-reader.h>
namespace Dali
{
-
namespace TizenPlatform
{
-
struct TizenPlatformAbstraction::TimerCallback : ConnectionTracker
{
- Dali::Timer mTimer;
- TizenPlatformAbstraction* mOwner;
- std::unique_ptr< CallbackBase > mCallback;
- const uint32_t mIdNumber;
+ Dali::Timer mTimer;
+ TizenPlatformAbstraction* mOwner;
+ std::unique_ptr<CallbackBase> mCallback;
+ const uint32_t mIdNumber;
static uint32_t sNextTimerId;
TimerCallback(TizenPlatformAbstraction* owner, CallbackBase* callback, uint32_t ms)
: mTimer(Dali::Timer::New(ms)),
mOwner(owner),
- mCallback( std::unique_ptr< CallbackBase >( callback ) ),
+ mCallback(std::unique_ptr<CallbackBase>(callback)),
mIdNumber(++sNextTimerId)
{
- mTimer.TickSignal().Connect( this, &TimerCallback::Tick );
+ mTimer.TickSignal().Connect(this, &TimerCallback::Tick);
mTimer.Start();
}
~TimerCallback()
uint32_t TizenPlatformAbstraction::TimerCallback::sNextTimerId = 0;
TizenPlatformAbstraction::TizenPlatformAbstraction()
-: mDataStoragePath( "" ),
+: mDataStoragePath(""),
mTimerPairsWaiting(),
mTimerPairsSpent()
{
}
-ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( const std::string& filename,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection )
+ImageDimensions TizenPlatformAbstraction::GetClosestImageSize(const std::string& filename,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection)
{
- return ImageLoader::GetClosestImageSize( filename, size, fittingMode, samplingMode, orientationCorrection );
+ return ImageLoader::GetClosestImageSize(filename, size, fittingMode, samplingMode, orientationCorrection);
}
-ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection )
+ImageDimensions TizenPlatformAbstraction::GetClosestImageSize(Integration::ResourcePointer resourceBuffer,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection)
{
- return ImageLoader::GetClosestImageSize( resourceBuffer, size, fittingMode, samplingMode, orientationCorrection );
+ return ImageLoader::GetClosestImageSize(resourceBuffer, size, fittingMode, samplingMode, orientationCorrection);
}
Integration::ResourcePointer TizenPlatformAbstraction::LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& resourcePath)
{
- return ImageLoader::LoadImageSynchronously( resource, resourcePath );
+ return ImageLoader::LoadImageSynchronously(resource, resourcePath);
}
-Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration::BitmapResourceType& resource, uint8_t * buffer, size_t size )
+Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer(const Integration::BitmapResourceType& resource, uint8_t* buffer, size_t size)
{
- Integration::BitmapPtr resultBitmap;
+ Integration::BitmapPtr resultBitmap;
Dali::Devel::PixelBuffer bitmap;
- Dali::Internal::Platform::FileReader fileReader( buffer, size );
- FILE * const fp = fileReader.GetFile();
- if( fp )
+ Dali::Internal::Platform::FileReader fileReader(buffer, size);
+ FILE* const fp = fileReader.GetFile();
+ if(fp)
{
- bool result = ImageLoader::ConvertStreamToBitmap( resource, "", fp, bitmap );
- if ( !result || !bitmap )
+ bool result = ImageLoader::ConvertStreamToBitmap(resource, "", fp, bitmap);
+ if(!result || !bitmap)
{
bitmap.Reset();
- DALI_LOG_WARNING( "Unable to decode bitmap supplied as in-memory blob.\n" );
+ DALI_LOG_WARNING("Unable to decode bitmap supplied as in-memory blob.\n");
}
else
{
auto retval = Integration::Bitmap::New(profile, Dali::ResourcePolicy::OWNED_DISCARD);
retval->GetPackedPixelsProfile()->ReserveBuffer(
- bitmap.GetPixelFormat(),
- bitmap.GetWidth(),
- bitmap.GetHeight(),
- bitmap.GetWidth(),
- bitmap.GetHeight()
- );
+ bitmap.GetPixelFormat(),
+ bitmap.GetWidth(),
+ bitmap.GetHeight(),
+ bitmap.GetWidth(),
+ bitmap.GetHeight());
auto& impl = Dali::GetImplementation(bitmap);
- std::copy( impl.GetBuffer(), impl.GetBuffer()+impl.GetBufferSize(), retval->GetBuffer());
+ std::copy(impl.GetBuffer(), impl.GetBuffer() + impl.GetBufferSize(), retval->GetBuffer());
resultBitmap.Reset(retval);
}
}
return resultBitmap;
}
-bool TizenPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
+bool TizenPlatformAbstraction::LoadShaderBinaryFile(const std::string& filename, Dali::Vector<unsigned char>& buffer) const
{
bool result = false;
// First check the system location where shaders are stored at install time:
path = DALI_SHADERBIN_DIR;
path += filename;
- result = Dali::FileLoader::ReadFile( path, buffer );
+ result = Dali::FileLoader::ReadFile(path, buffer);
// Fallback to the cache of shaders stored after previous runtime compilations:
// On desktop this looks in the current working directory that the app was launched from.
- if( result == false )
+ if(result == false)
{
path = mDataStoragePath;
path += filename;
- result = Dali::FileLoader::ReadFile( path, buffer );
+ result = Dali::FileLoader::ReadFile(path, buffer);
}
#endif
return result;
}
-bool TizenPlatformAbstraction::SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const
+bool TizenPlatformAbstraction::SaveShaderBinaryFile(const std::string& filename, const unsigned char* buffer, unsigned int numBytes) const
{
bool result = false;
// On desktop this looks in the current working directory that the app was launched from.
std::string path = mDataStoragePath;
path += filename;
- result = SaveFile( path, buffer, numBytes );
+ result = SaveFile(path, buffer, numBytes);
#endif
return result;
}
-void TizenPlatformAbstraction::SetDataStoragePath( const std::string& path )
+void TizenPlatformAbstraction::SetDataStoragePath(const std::string& path)
{
mDataStoragePath = path;
}
-uint32_t TizenPlatformAbstraction::StartTimer( uint32_t milliseconds, CallbackBase* callback )
+uint32_t TizenPlatformAbstraction::StartTimer(uint32_t milliseconds, CallbackBase* callback)
{
TimerCallback* timerCallbackPtr = new TimerCallback(this, callback, milliseconds);
// Stick it in the list
- mTimerPairsWaiting.push_back( std::unique_ptr< TimerCallback >( timerCallbackPtr ) );
+ mTimerPairsWaiting.push_back(std::unique_ptr<TimerCallback>(timerCallbackPtr));
return timerCallbackPtr->mIdNumber;
}
-void TizenPlatformAbstraction::CancelTimer ( uint32_t timerId )
+void TizenPlatformAbstraction::CancelTimer(uint32_t timerId)
{
auto iter = std::remove_if(
- mTimerPairsWaiting.begin(), mTimerPairsWaiting.end(),
- [&timerId]( std::unique_ptr< TimerCallback >& timerCallbackPtr )
- {
- if( timerCallbackPtr->mIdNumber == timerId )
+ mTimerPairsWaiting.begin(), mTimerPairsWaiting.end(), [&timerId](std::unique_ptr<TimerCallback>& timerCallbackPtr) {
+ if(timerCallbackPtr->mIdNumber == timerId)
{
timerCallbackPtr->mTimer.Stop();
return true;
{
return false;
}
- }
- );
+ });
- mTimerPairsWaiting.erase( iter, mTimerPairsWaiting.end() );
+ mTimerPairsWaiting.erase(iter, mTimerPairsWaiting.end());
}
void TizenPlatformAbstraction::RunTimerFunction(TimerCallback& timerPtr)
{
- CallbackBase::Execute( *timerPtr.mCallback );
+ CallbackBase::Execute(*timerPtr.mCallback);
- std::vector< std::unique_ptr< TimerCallback > >::iterator timerIter = std::find_if( mTimerPairsWaiting.begin(), mTimerPairsWaiting.end(),
- [&]( std::unique_ptr< TimerCallback >& p )
- { return p.get() == &timerPtr;} );
+ std::vector<std::unique_ptr<TimerCallback> >::iterator timerIter = std::find_if(mTimerPairsWaiting.begin(), mTimerPairsWaiting.end(), [&](std::unique_ptr<TimerCallback>& p) { return p.get() == &timerPtr; });
- if( timerIter == std::end(mTimerPairsWaiting) )
+ if(timerIter == std::end(mTimerPairsWaiting))
{
DALI_ASSERT_DEBUG(false);
}
// ...and move it
- std::move(timerIter, timerIter+1, std::back_inserter(mTimerPairsSpent));
+ std::move(timerIter, timerIter + 1, std::back_inserter(mTimerPairsSpent));
- mTimerPairsWaiting.erase(timerIter, timerIter+1);
+ mTimerPairsWaiting.erase(timerIter, timerIter + 1);
- Dali::Adaptor::Get().AddIdle( MakeCallback( this, &TizenPlatformAbstraction::CleanupTimers ), false );
+ Dali::Adaptor::Get().AddIdle(MakeCallback(this, &TizenPlatformAbstraction::CleanupTimers), false);
}
-
void TizenPlatformAbstraction::CleanupTimers()
{
mTimerPairsSpent.clear();
}
-
TizenPlatformAbstraction* CreatePlatformAbstraction()
{
return new TizenPlatformAbstraction();
}
-bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes )
+bool SaveFile(const std::string& filename, const unsigned char* buffer, unsigned int numBytes)
{
- DALI_ASSERT_DEBUG( 0 != filename.length());
+ DALI_ASSERT_DEBUG(0 != filename.length());
bool result = false;
std::filebuf buf;
buf.open(filename.c_str(), std::ios::out | std::ios_base::trunc | std::ios::binary);
- if( buf.is_open() )
+ if(buf.is_open())
{
std::ostream stream(&buf);
// write contents of buffer to the file
stream.write(reinterpret_cast<const char*>(buffer), length);
- if( !stream.bad() )
+ if(!stream.bad())
{
result = true;
}
return result;
}
-} // namespace TizenPlatform
+} // namespace TizenPlatform
-} // namespace Dali
+} // namespace Dali
{
namespace DataCompression
{
-
std::size_t GetMaximumRleCompressedSize(const std::size_t inputLength)
{
// RLE has worst case scenerio of double the input data
// we also encode the original size into the stream to check
// the decode buffers are big enough and for corruption
- return (inputLength * 2) + 4; // 4 bytes is space for size
-
+ return (inputLength * 2) + 4; // 4 bytes is space for size
}
// Run length encode a byte stream, consisting of byte values.
// 2, 5
// First 4 bytes are the size of the decoded data
//
-void EncodeRle( const unsigned char* input,
- const std::size_t inputLength,
- unsigned char* output,
- const std::size_t outputLength,
- std::size_t& encodedSize)
+void EncodeRle(const unsigned char* input,
+ const std::size_t inputLength,
+ unsigned char* output,
+ const std::size_t outputLength,
+ std::size_t& encodedSize)
{
- DALI_ASSERT_DEBUG( outputLength >= GetMaximumRleCompressedSize( inputLength ));
+ DALI_ASSERT_DEBUG(outputLength >= GetMaximumRleCompressedSize(inputLength));
unsigned int index(0);
unsigned int runLength(0);
encodedSize = 0;
// encode the input length in the first 4 bytes.
- output[ encodedSize++ ] = inputLength & 0xFF;
- output[ encodedSize++ ] = (inputLength >> 8) & 0xFF;
- output[ encodedSize++ ] = (inputLength >> 16) & 0xFF;
- output[ encodedSize++ ] = (inputLength >> 24) & 0xFF;
+ output[encodedSize++] = inputLength & 0xFF;
+ output[encodedSize++] = (inputLength >> 8) & 0xFF;
+ output[encodedSize++] = (inputLength >> 16) & 0xFF;
+ output[encodedSize++] = (inputLength >> 24) & 0xFF;
- while( index < inputLength )
+ while(index < inputLength)
{
- unsigned char curChar = input[ index ];
- runLength = 1;
+ unsigned char curChar = input[index];
+ runLength = 1;
- if( ( (index + 1) == inputLength ) // is more data available
- || input[index + 1] != curChar ) // character doesn't match
+ if(((index + 1) == inputLength) // is more data available
+ || input[index + 1] != curChar) // character doesn't match
{
// we out of data, or the next character doesn't match (run of zero)
index++;
}
else
{
- while( ( (index+1) < inputLength ) &&
- ( input[index + 1] == curChar ) &&
- ( runLength < 0xFF ) )
+ while(((index + 1) < inputLength) &&
+ (input[index + 1] == curChar) &&
+ (runLength < 0xFF))
{
runLength++;
index++;
}
index++;
}
- output[ encodedSize++ ] = runLength;
- output[ encodedSize++ ] = curChar;
-
+ output[encodedSize++] = runLength;
+ output[encodedSize++] = curChar;
}
}
-bool DecodeRle( const unsigned char* input,
- const std::size_t inputLength,
- unsigned char* output,
- const std::size_t outputLength,
- std::size_t& decodedSize)
+bool DecodeRle(const unsigned char* input,
+ const std::size_t inputLength,
+ unsigned char* output,
+ const std::size_t outputLength,
+ std::size_t& decodedSize)
{
unsigned int index(0);
unsigned int outputIndex(0);
// there should be at least 4 bytes for the size field
- if( inputLength < 4)
+ if(inputLength < 4)
{
DALI_LOG_ERROR("input buffer too small\n");
return false;
}
- decodedSize = input[ index++ ] ;
- decodedSize|= input[ index++ ]<<8 ;
- decodedSize|= input[ index++ ]<<16 ;
- decodedSize|= input[ index++ ]<<24 ;
+ decodedSize = input[index++];
+ decodedSize |= input[index++] << 8;
+ decodedSize |= input[index++] << 16;
+ decodedSize |= input[index++] << 24;
// check the decoded data will fit in to
- if( outputLength < decodedSize )
+ if(outputLength < decodedSize)
{
- DALI_LOG_ERROR("buffer too small, buffer size =%d, data size = %d \n",outputLength, decodedSize);
+ DALI_LOG_ERROR("buffer too small, buffer size =%d, data size = %d \n", outputLength, decodedSize);
return false;
}
- while( (index+1)< inputLength )
+ while((index + 1) < inputLength)
{
// read the value and the run length
- unsigned char runLength = input[ index++ ];
- unsigned char value = input[ index++ ];
+ unsigned char runLength = input[index++];
+ unsigned char value = input[index++];
- if( (runLength + outputIndex) > decodedSize)
+ if((runLength + outputIndex) > decodedSize)
{
- DALI_LOG_ERROR( "corrupted RLE data\n" );
+ DALI_LOG_ERROR("corrupted RLE data\n");
// corrupted
return false;
}
// set the value run Length times
- memset( &output[ outputIndex ], value, runLength * sizeof( unsigned char) );
- outputIndex+= runLength;
+ memset(&output[outputIndex], value, runLength * sizeof(unsigned char));
+ outputIndex += runLength;
}
- if( outputIndex != decodedSize)
+ if(outputIndex != decodedSize)
{
DALI_LOG_ERROR(" RLE data size missmatch\n");
return false;
return true;
}
-} // DataCompression
+} // namespace DataCompression
} // namespace TizenPlatform
/*
- * Copyright (c) 2018 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.
#include <dali/internal/network/common/automation.h>
// EXTERNAL INCLUDES
-#include <sstream>
-#include <iomanip>
-#include <stdio.h>
-#include <dali/public-api/dali-core.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/dali-core.h>
+#include <stdio.h>
+#include <iomanip>
+#include <sstream>
-using Dali::Property;
using Dali::Matrix;
using Dali::Matrix3;
+using Dali::Property;
-namespace // un-named namespace
+namespace // un-named namespace
{
-
const unsigned int MAX_SET_PROPERTY_STRING_LENGTH = 256; ///< maximum length of a set property command
class JsonPropertyValue
{
public:
- JsonPropertyValue( const std::string& str )
+ JsonPropertyValue(const std::string& str)
{
std::size_t strLength = str.length();
- mString.reserve( strLength );
- for( std::size_t i = 0; i < strLength; ++i )
+ mString.reserve(strLength);
+ for(std::size_t i = 0; i < strLength; ++i)
{
const char c = str[i];
- if( (c != '[') && c != ']')
+ if((c != '[') && c != ']')
{
- mString.push_back( c );
+ mString.push_back(c);
}
}
-
}
std::string GetString() const
{
}
float GetFloat() const
{
- return atof( mString.c_str() );
+ return atof(mString.c_str());
}
int GetInt()
{
- return atoi( mString.c_str() );
+ return atoi(mString.c_str());
}
bool GetBoolean()
{
{
Dali::Vector2 vec2;
- int count = sscanf( mString.c_str(),"%f,%f",&vec2.x,&vec2.y );
- if( count != 2 )
+ int count = sscanf(mString.c_str(), "%f,%f", &vec2.x, &vec2.y);
+ if(count != 2)
{
DALI_LOG_ERROR("Bad format\n");
}
{
Dali::Vector3 vec3;
- int count = sscanf( mString.c_str(),"%f,%f,%f",&vec3.x,&vec3.y,&vec3.z );
- if( count != 3 )
+ int count = sscanf(mString.c_str(), "%f,%f,%f", &vec3.x, &vec3.y, &vec3.z);
+ if(count != 3)
{
DALI_LOG_ERROR("Bad format\n");
}
{
Dali::Vector4 vec4;
- int count = sscanf( mString.c_str(),"%f,%f,%f,%f", &vec4.x, &vec4.y, &vec4.z, &vec4.w );
- if( count != 4 )
+ int count = sscanf(mString.c_str(), "%f,%f,%f,%f", &vec4.x, &vec4.y, &vec4.z, &vec4.w);
+ if(count != 4)
{
DALI_LOG_ERROR("Bad format\n");
}
private:
std::string mString;
-
};
-void SetProperty( Dali::Handle handle, int propertyId, JsonPropertyValue& propertyValue )
+void SetProperty(Dali::Handle handle, int propertyId, JsonPropertyValue& propertyValue)
{
- Dali::Property::Type type = handle.GetPropertyType( propertyId );
- switch( type )
- {
- case Dali::Property::FLOAT:
+ Dali::Property::Type type = handle.GetPropertyType(propertyId);
+ switch(type)
{
- float val = propertyValue.GetFloat();
- handle.SetProperty( propertyId, Dali::Property::Value( val ) );
- break;
- }
- case Dali::Property::INTEGER:
- {
- int val = propertyValue.GetInt();
- handle.SetProperty( propertyId, Dali::Property::Value( val ) );
- break;
- }
- case Dali::Property::BOOLEAN:
- {
- bool val = propertyValue.GetBoolean();
- handle.SetProperty( propertyId, Dali::Property::Value( val ) );
- break;
- }
- case Dali::Property::STRING:
- {
- std::string str = propertyValue.GetString();
- handle.SetProperty( propertyId, Dali::Property::Value( str ) );
- break;
- }
- case Dali::Property::VECTOR2:
- {
- Dali::Vector2 val = propertyValue.GetVector2();
- handle.SetProperty( propertyId, Dali::Property::Value( val ) );
- break;
- }
- case Dali::Property::VECTOR3:
- {
- Dali::Vector3 val = propertyValue.GetVector3();
- handle.SetProperty( propertyId, Dali::Property::Value( val ) );
- break;
- }
- case Dali::Property::VECTOR4:
- {
- Dali::Vector4 val = propertyValue.GetVector4();
- handle.SetProperty( propertyId, Dali::Property::Value( val ) );
- break;
- }
- default:
- {
- break;
- }
+ case Dali::Property::FLOAT:
+ {
+ float val = propertyValue.GetFloat();
+ handle.SetProperty(propertyId, Dali::Property::Value(val));
+ break;
+ }
+ case Dali::Property::INTEGER:
+ {
+ int val = propertyValue.GetInt();
+ handle.SetProperty(propertyId, Dali::Property::Value(val));
+ break;
+ }
+ case Dali::Property::BOOLEAN:
+ {
+ bool val = propertyValue.GetBoolean();
+ handle.SetProperty(propertyId, Dali::Property::Value(val));
+ break;
+ }
+ case Dali::Property::STRING:
+ {
+ std::string str = propertyValue.GetString();
+ handle.SetProperty(propertyId, Dali::Property::Value(str));
+ break;
+ }
+ case Dali::Property::VECTOR2:
+ {
+ Dali::Vector2 val = propertyValue.GetVector2();
+ handle.SetProperty(propertyId, Dali::Property::Value(val));
+ break;
+ }
+ case Dali::Property::VECTOR3:
+ {
+ Dali::Vector3 val = propertyValue.GetVector3();
+ handle.SetProperty(propertyId, Dali::Property::Value(val));
+ break;
+ }
+ case Dali::Property::VECTOR4:
+ {
+ Dali::Vector4 val = propertyValue.GetVector4();
+ handle.SetProperty(propertyId, Dali::Property::Value(val));
+ break;
+ }
+ default:
+ {
+ break;
+ }
}
}
-int SetProperties( const std::string& setPropertyMessage )
+int SetProperties(const std::string& setPropertyMessage)
{
- std::istringstream iss( setPropertyMessage );
- std::string token;
- getline( iss, token, '|' ); // swallow command name
- while( getline( iss, token, '|' ) )
+ std::istringstream iss(setPropertyMessage);
+ std::string token;
+ getline(iss, token, '|'); // swallow command name
+ while(getline(iss, token, '|'))
{
std::string actorId, propName, propValue;
- if( token.compare( "---" ) != 0 )
+ if(token.compare("---") != 0)
{
- std::istringstream propss( token );
- getline( propss, actorId, ';' );
- getline( propss, propName, ';' );
- getline( propss, propValue );
+ std::istringstream propss(token);
+ getline(propss, actorId, ';');
+ getline(propss, propName, ';');
+ getline(propss, propValue);
Dali::Actor root = Dali::Stage::GetCurrent().GetRootLayer();
- int id = atoi( actorId.c_str() );
- Dali::Actor a = root.FindChildById( id );
- if( a )
+ int id = atoi(actorId.c_str());
+ Dali::Actor a = root.FindChildById(id);
+ if(a)
{
// lookup by name for custom properties
- int propId = a.GetPropertyIndex( propName );
- if( propId > 0 )
+ int propId = a.GetPropertyIndex(propName);
+ if(propId > 0)
{
- JsonPropertyValue pv( propValue );
- SetProperty( a, propId, pv );
+ JsonPropertyValue pv(propValue);
+ SetProperty(a, propId, pv);
}
-
}
}
}
return 0;
}
-
-void MatrixToStream( Property::Value value, std::ostream& o )
+void MatrixToStream(Property::Value value, std::ostream& o)
{
- Matrix m4(false);
+ Matrix m4(false);
Matrix3 m3;
- if( value.Get(m4) )
+ if(value.Get(m4))
{
float* matrix = m4.AsFloat();
- o << "[ [" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << ", " << matrix[3] << "], "
- << "[" << matrix[4] << ", " << matrix[5] << ", " << matrix[6] << ", " << matrix[7] << "], "
+ o << "[ [" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << ", " << matrix[3] << "], "
+ << "[" << matrix[4] << ", " << matrix[5] << ", " << matrix[6] << ", " << matrix[7] << "], "
<< "[" << matrix[8] << ", " << matrix[9] << ", " << matrix[10] << ", " << matrix[11] << "], "
<< "[" << matrix[12] << ", " << matrix[13] << ", " << matrix[14] << ", " << matrix[15] << "] ]";
}
- else if( value.Get(m3) )
+ else if(value.Get(m3))
{
float* matrix = m3.AsFloat();
- o << "[ [" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << "], "
- << "[" << matrix[3] << ", " << matrix[4] << ", " << matrix[5] << "], "
- << "[" << matrix[6] << ", " << matrix[7] << ", " << matrix[8] << "] ]";
+ o << "[ [" << matrix[0] << ", " << matrix[1] << ", " << matrix[2] << "], "
+ << "[" << matrix[3] << ", " << matrix[4] << ", " << matrix[5] << "], "
+ << "[" << matrix[6] << ", " << matrix[7] << ", " << matrix[8] << "] ]";
}
}
+}; // namespace
-}; // un-named namespace
-
-inline std::string Quote( const std::string& in )
+inline std::string Quote(const std::string& in)
{
- return (std::string( "\"" ) + in + std::string( "\"" ));
+ return (std::string("\"") + in + std::string("\""));
}
template<class T>
-std::string ToString( T i )
+std::string ToString(T i)
{
std::stringstream ss;
- std::string s;
+ std::string s;
ss << i;
s = ss.str();
return s;
}
-std::string GetPropertyValueString( Dali::Handle handle, int propertyIndex )
+std::string GetPropertyValueString(Dali::Handle handle, int propertyIndex)
{
std::ostringstream valueStream;
- if( propertyIndex != Dali::Property::INVALID_INDEX )
+ if(propertyIndex != Dali::Property::INVALID_INDEX)
{
- Dali::Property::Value value = handle.GetProperty( propertyIndex );
+ Dali::Property::Value value = handle.GetProperty(propertyIndex);
- if( value.GetType() == Dali::Property::STRING )
+ if(value.GetType() == Dali::Property::STRING)
{
// Escape the string (to ensure valid json)
// Write out quotes, escapes and control characters using unicode syntax \uXXXX
std::ostringstream unescapedValue;
unescapedValue << value;
- std::string valueString = unescapedValue.str();
+ std::string valueString = unescapedValue.str();
std::ostringstream escapedValue;
- for( std::string::iterator c = valueString.begin() ; c != valueString.end(); ++c )
+ for(std::string::iterator c = valueString.begin(); c != valueString.end(); ++c)
{
- if( *c == '"' )
+ if(*c == '"')
{
escapedValue << "\\\"";
}
- else if( *c == '\\' )
+ else if(*c == '\\')
{
escapedValue << "\\\\";
}
- else if( '\x00' <= *c && *c <= '\x1f' )
+ else if('\x00' <= *c && *c <= '\x1f')
{
escapedValue << "\\u" << std::hex << std::setw(4) << std::setfill('0') << int(*c);
}
}
valueStream << escapedValue.str();
}
- else if( value.GetType() == Dali::Property::MATRIX || value.GetType() == Dali::Property::MATRIX3 )
+ else if(value.GetType() == Dali::Property::MATRIX || value.GetType() == Dali::Property::MATRIX3)
{
- MatrixToStream( value, valueStream );
+ MatrixToStream(value, valueStream);
}
else
{
}
// currently rotations are output in Euler format ( may change)
-void AppendPropertyNameAndValue( Dali::Handle handle, int propertyIndex, std::ostringstream& outputStream)
+void AppendPropertyNameAndValue(Dali::Handle handle, int propertyIndex, std::ostringstream& outputStream)
{
// get the property name and the value as a string
- std::string propertyName( handle.GetPropertyName( propertyIndex ) );
+ std::string propertyName(handle.GetPropertyName(propertyIndex));
// Apply quotes around the property name
- outputStream << "\"" << propertyName << "\"" << ",";
+ outputStream << "\"" << propertyName << "\""
+ << ",";
// Convert value to a string
- std::string valueString = GetPropertyValueString( handle, propertyIndex );
+ std::string valueString = GetPropertyValueString(handle, propertyIndex);
outputStream << "\"" << valueString << "\"";
}
-void AppendRendererPropertyNameAndValue( Dali::Renderer renderer, int rendererIndex, const std::string& name, std::ostringstream& outputStream)
+void AppendRendererPropertyNameAndValue(Dali::Renderer renderer, int rendererIndex, const std::string& name, std::ostringstream& outputStream)
{
- outputStream << ",[\"renderer[" << rendererIndex << "]." << name << "\"" << ",";
- std::string valueString = GetPropertyValueString( renderer, renderer.GetPropertyIndex( name ) );
+ outputStream << ",[\"renderer[" << rendererIndex << "]." << name << "\""
+ << ",";
+ std::string valueString = GetPropertyValueString(renderer, renderer.GetPropertyIndex(name));
outputStream << "\"" << valueString << "\"]";
}
-bool ExcludeProperty( int propIndex )
+bool ExcludeProperty(int propIndex)
{
- return (propIndex == Dali::Actor::Property::NAME ||
-
- // all of these are repeat properties of values in vectors....
- // We don't really need these in the UI
- propIndex == Dali::Actor::Property::ANCHOR_POINT_X || propIndex == Dali::Actor::Property::ANCHOR_POINT_Y || propIndex == Dali::Actor::Property::ANCHOR_POINT_Z || propIndex == Dali::Actor::Property::PARENT_ORIGIN_X
- || propIndex == Dali::Actor::Property::PARENT_ORIGIN_Y || propIndex == Dali::Actor::Property::PARENT_ORIGIN_Z || propIndex == Dali::Actor::Property::COLOR_RED || propIndex == Dali::Actor::Property::COLOR_GREEN
- || propIndex == Dali::Actor::Property::COLOR_BLUE || propIndex == Dali::Actor::Property::COLOR_ALPHA|| propIndex == Dali::Actor::Property::POSITION_X || propIndex == Dali::Actor::Property::POSITION_Y
- || propIndex == Dali::Actor::Property::POSITION_Z|| propIndex == Dali::Actor::Property::SIZE_WIDTH|| propIndex == Dali::Actor::Property::SIZE_HEIGHT || propIndex == Dali::Actor::Property::SCALE_X || propIndex == Dali::Actor::Property::SCALE_Y
- || propIndex == Dali::Actor::Property::SCALE_Z || propIndex == Dali::Actor::Property::SIZE_DEPTH);
+ // all of these are repeat properties of values in vectors....
+ // We don't really need these in the UI
+ return (propIndex == Dali::Actor::Property::NAME ||
+ propIndex == Dali::Actor::Property::ANCHOR_POINT_X ||
+ propIndex == Dali::Actor::Property::ANCHOR_POINT_Y ||
+ propIndex == Dali::Actor::Property::ANCHOR_POINT_Z ||
+ propIndex == Dali::Actor::Property::PARENT_ORIGIN_X ||
+ propIndex == Dali::Actor::Property::PARENT_ORIGIN_Y ||
+ propIndex == Dali::Actor::Property::PARENT_ORIGIN_Z ||
+ propIndex == Dali::Actor::Property::COLOR_RED ||
+ propIndex == Dali::Actor::Property::COLOR_GREEN ||
+ propIndex == Dali::Actor::Property::COLOR_BLUE ||
+ propIndex == Dali::Actor::Property::COLOR_ALPHA ||
+ propIndex == Dali::Actor::Property::POSITION_X ||
+ propIndex == Dali::Actor::Property::POSITION_Y ||
+ propIndex == Dali::Actor::Property::POSITION_Z ||
+ propIndex == Dali::Actor::Property::SIZE_WIDTH ||
+ propIndex == Dali::Actor::Property::SIZE_HEIGHT ||
+ propIndex == Dali::Actor::Property::SCALE_X ||
+ propIndex == Dali::Actor::Property::SCALE_Y ||
+ propIndex == Dali::Actor::Property::SCALE_Z ||
+ propIndex == Dali::Actor::Property::SIZE_DEPTH);
}
-std::string DumpJson( Dali::Actor actor, int level )
+std::string DumpJson(Dali::Actor actor, int level)
{
// All the information about this actor
std::ostringstream msg;
- msg << "{ " << Quote( "Name" ) << " : " << Quote( actor.GetProperty< std::string >( Actor::Property::NAME ) ) << ", " << Quote( "level" ) << " : " << level << ", " << Quote( "id" ) << " : " << actor.GetId() << ", " << Quote( "IsVisible" )
- << " : " << actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) << ", " << Quote( "IsSensitive" ) << " : " << actor.GetProperty< bool >( Actor::Property::SENSITIVE );
+ msg << "{ " << Quote("Name") << " : " << Quote(actor.GetProperty<std::string>(Actor::Property::NAME)) << ", " << Quote("level") << " : " << level << ", " << Quote("id") << " : " << actor.GetId() << ", " << Quote("IsVisible")
+ << " : " << actor.GetCurrentProperty<bool>(Actor::Property::VISIBLE) << ", " << Quote("IsSensitive") << " : " << actor.GetProperty<bool>(Actor::Property::SENSITIVE);
- msg << ", " << Quote( "properties" ) << ": [ ";
+ msg << ", " << Quote("properties") << ": [ ";
Dali::Property::IndexContainer indices;
- actor.GetPropertyIndices( indices );
+ actor.GetPropertyIndices(indices);
- Dali::Property::IndexContainer::Iterator iter = indices.Begin();
- int numCustom = 0;
- for( ; iter != indices.End() ; iter++ )
+ Dali::Property::IndexContainer::Iterator iter = indices.Begin();
+ int numCustom = 0;
+ for(; iter != indices.End(); iter++)
{
int i = *iter;
- if( !ExcludeProperty( i ) )
+ if(!ExcludeProperty(i))
{
- if( numCustom++ != 0 )
+ if(numCustom++ != 0)
{
msg << ", ";
}
msg << "[";
- AppendPropertyNameAndValue( actor, i,msg );
+ AppendPropertyNameAndValue(actor, i, msg);
msg << "]";
}
}
- if( actor.GetRendererCount() > 0 )
+ if(actor.GetRendererCount() > 0)
{
- for( unsigned int i=0; i<actor.GetRendererCount(); ++i )
+ for(unsigned int i = 0; i < actor.GetRendererCount(); ++i)
{
- auto renderer = actor.GetRendererAt( i );
- AppendRendererPropertyNameAndValue( renderer, i, "offset", msg );
- AppendRendererPropertyNameAndValue( renderer, i, "size", msg );
- AppendRendererPropertyNameAndValue( renderer, i, "offsetSizeMode", msg );
- AppendRendererPropertyNameAndValue( renderer, i, "origin", msg );
- AppendRendererPropertyNameAndValue( renderer, i, "anchorPoint", msg );
+ auto renderer = actor.GetRendererAt(i);
+ AppendRendererPropertyNameAndValue(renderer, i, "offset", msg);
+ AppendRendererPropertyNameAndValue(renderer, i, "size", msg);
+ AppendRendererPropertyNameAndValue(renderer, i, "offsetSizeMode", msg);
+ AppendRendererPropertyNameAndValue(renderer, i, "origin", msg);
+ AppendRendererPropertyNameAndValue(renderer, i, "anchorPoint", msg);
}
}
msg << "]";
- msg << ", " << Quote( "children" ) << " : [ ";
+ msg << ", " << Quote("children") << " : [ ";
// Recursively dump all the children as well
- for( unsigned int i = 0 ; i < actor.GetChildCount() ; ++i )
+ for(unsigned int i = 0; i < actor.GetChildCount(); ++i)
{
- if( i )
+ if(i)
{
msg << " , ";
}
- msg << DumpJson( actor.GetChildAt( i ), level + 1 );
+ msg << DumpJson(actor.GetChildAt(i), level + 1);
}
msg << "] }";
std::string GetActorTree()
{
Dali::Actor actor = Dali::Stage::GetCurrent().GetRootLayer();
- std::string str = DumpJson( actor, 0 );
+ std::string str = DumpJson(actor, 0);
return str;
}
-
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace Automation
{
-
-void SetProperty( const std::string& message )
+void SetProperty(const std::string& message)
{
// check the set property length is within range
- if( message.length() > MAX_SET_PROPERTY_STRING_LENGTH )
+ if(message.length() > MAX_SET_PROPERTY_STRING_LENGTH)
{
DALI_LOG_ERROR("SetProperty message length too long, size = %ul\n", message.length());
return;
}
- SetProperties( message );
+ SetProperties(message);
}
-void DumpScene( unsigned int clientId, ClientSendDataInterface* sendData )
+void DumpScene(unsigned int clientId, ClientSendDataInterface* sendData)
{
- char buf[32];
- std::string json = GetActorTree();
- int length = json.length();
- snprintf( buf, 32, "%d\n", length );
- std::string header( buf );
+ char buf[32];
+ std::string json = GetActorTree();
+ int length = json.length();
+ snprintf(buf, 32, "%d\n", length);
+ std::string header(buf);
json = buf + json;
- sendData->SendData( json.c_str(), json.length(), clientId );
+ sendData->SendData(json.c_str(), json.length(), clientId);
}
} // namespace Automation
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
/*
- * Copyright (c) 2018 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.
#include <string>
// INTERNAL INCLUDES
-#include <dali/internal/network/common/socket-interface.h>
-#include <dali/internal/network/common/network-performance-protocol.h>
#include <dali/internal/network/common/automation.h>
-
+#include <dali/internal/network/common/network-performance-protocol.h>
+#include <dali/internal/network/common/socket-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
const float MICROSECONDS_TO_SECOND = 1e-6;
-const char UNKNOWN_CMD[]= "Command or parameter invalid, type help for list of commands\n";
-
+const char UNKNOWN_CMD[] = "Command or parameter invalid, type help for list of commands\n";
/**
* helper class to store data along with the automation callback.
*/
-class AutomationCallback: public CallbackBase
+class AutomationCallback : public CallbackBase
{
public:
-
/**
* instead of using templates, or having different callback classes for each callback
* we use a command id that decides which static function to call on the Automation class.
DUMP_SCENE
};
- AutomationCallback( unsigned int clientId, ClientSendDataInterface& sendDataInterface )
- :CallbackBase( reinterpret_cast< void* >( this ),
+ AutomationCallback(unsigned int clientId, ClientSendDataInterface& sendDataInterface)
+ : CallbackBase(reinterpret_cast<void*>(this),
NULL, // we get the dispatcher to call function directly
- reinterpret_cast< CallbackBase::Dispatcher>( &AutomationCallback::Dispatcher) ),
- mSendDataInterface( sendDataInterface ),
- mCommandId( UNKNOWN_COMMAND ),
- mClientId( clientId )
- {}
+ reinterpret_cast<CallbackBase::Dispatcher>(&AutomationCallback::Dispatcher)),
+ mSendDataInterface(sendDataInterface),
+ mCommandId(UNKNOWN_COMMAND),
+ mClientId(clientId)
+ {
+ }
- void AssignSetPropertyCommand( std::string setPropertyCommand )
+ void AssignSetPropertyCommand(std::string setPropertyCommand)
{
- mCommandId = SET_PROPERTY;
+ mCommandId = SET_PROPERTY;
mPropertyCommand = setPropertyCommand;
}
void AssignDumpSceneCommand()
{
- mCommandId = DUMP_SCENE;
+ mCommandId = DUMP_SCENE;
}
void RunCallback()
{
- switch( mCommandId )
+ switch(mCommandId)
{
case SET_PROPERTY:
{
- Automation::SetProperty( mPropertyCommand );
+ Automation::SetProperty(mPropertyCommand);
break;
}
case DUMP_SCENE:
{
- Automation::DumpScene( mClientId, &mSendDataInterface);
+ Automation::DumpScene(mClientId, &mSendDataInterface);
break;
}
default:
{
- DALI_ASSERT_DEBUG( 0 && "Unknown command");
+ DALI_ASSERT_DEBUG(0 && "Unknown command");
break;
}
}
}
- static void Dispatcher( CallbackBase& base )
+ static void Dispatcher(CallbackBase& base)
{
- AutomationCallback& automationCallback( static_cast< AutomationCallback& >( base) );
+ AutomationCallback& automationCallback(static_cast<AutomationCallback&>(base));
automationCallback.RunCallback();
}
private:
-
- std::string mPropertyCommand; ///< property command
- ClientSendDataInterface& mSendDataInterface; ///< Abstract client send data interface
- CommandId mCommandId; ///< command id
- const unsigned int mClientId; ///< client id
+ std::string mPropertyCommand; ///< property command
+ ClientSendDataInterface& mSendDataInterface; ///< Abstract client send data interface
+ CommandId mCommandId; ///< command id
+ const unsigned int mClientId; ///< client id
};
} // unnamed namespace
-NetworkPerformanceClient::NetworkPerformanceClient( pthread_t* thread,
- SocketInterface *socket,
- unsigned int clientId,
- ClientSendDataInterface& sendDataInterface,
- SocketFactoryInterface& socketFactory )
-: mThread( thread ),
- mSocket( socket ),
- mMarkerBitmask( PerformanceMarker::FILTERING_DISABLED ),
- mSendDataInterface( sendDataInterface ),
- mSocketFactoryInterface( socketFactory ),
- mClientId( clientId ),
+NetworkPerformanceClient::NetworkPerformanceClient(pthread_t* thread,
+ SocketInterface* socket,
+ unsigned int clientId,
+ ClientSendDataInterface& sendDataInterface,
+ SocketFactoryInterface& socketFactory)
+: mThread(thread),
+ mSocket(socket),
+ mMarkerBitmask(PerformanceMarker::FILTERING_DISABLED),
+ mSendDataInterface(sendDataInterface),
+ mSocketFactoryInterface(socketFactory),
+ mClientId(clientId),
mConsoleClient(false)
{
-
}
NetworkPerformanceClient::~NetworkPerformanceClient()
{
- if( mSocket->SocketIsOpen() )
+ if(mSocket->SocketIsOpen())
{
mSocket->CloseSocket();
}
- mSocketFactoryInterface.DestroySocket( mSocket );
+ mSocketFactoryInterface.DestroySocket(mSocket);
}
unsigned int NetworkPerformanceClient::GetId() const
return *mSocket;
}
-bool NetworkPerformanceClient::WriteSocket( const void* buffer, unsigned int bufferSizeInBytes )
+bool NetworkPerformanceClient::WriteSocket(const void* buffer, unsigned int bufferSizeInBytes)
{
- return mSocket->Write( buffer, bufferSizeInBytes );
+ return mSocket->Write(buffer, bufferSizeInBytes);
}
-bool NetworkPerformanceClient::TransmitMarker( const PerformanceMarker& marker, const char* const description )
+bool NetworkPerformanceClient::TransmitMarker(const PerformanceMarker& marker, const char* const description)
{
- if( ! marker.IsFilterEnabled( mMarkerBitmask ) )
+ if(!marker.IsFilterEnabled(mMarkerBitmask))
{
return true;
}
- if( mConsoleClient )
+ if(mConsoleClient)
{
// write out the time stamp
- char buffer[64];
+ char buffer[64];
double usec = marker.GetTimeStamp().microseconds;
- int size = snprintf( buffer, sizeof(buffer),"%.6f (seconds), %s\n",
- usec * MICROSECONDS_TO_SECOND,
- description );
-
- return mSocket->Write( buffer, size );
+ int size = snprintf(buffer, sizeof(buffer), "%.6f (seconds), %s\n", usec * MICROSECONDS_TO_SECOND, description);
+ return mSocket->Write(buffer, size);
}
-
// todo serialize the data
return false;
}
return mThread;
}
-void NetworkPerformanceClient::ProcessCommand( char* buffer, unsigned int bufferSizeInBytes )
+void NetworkPerformanceClient::ProcessCommand(char* buffer, unsigned int bufferSizeInBytes)
{
// if connected via console, then strip off the carriage return, and switch to console mode
- if( buffer[ bufferSizeInBytes - 1] == '\n')
+ if(buffer[bufferSizeInBytes - 1] == '\n')
{
- buffer[ bufferSizeInBytes - 1] = 0;
- mConsoleClient = true;
+ buffer[bufferSizeInBytes - 1] = 0;
+ mConsoleClient = true;
}
- unsigned int param(0);
- std::string stringParam;
- PerformanceProtocol::CommandId commandId( PerformanceProtocol::UNKNOWN_COMMAND );
+ unsigned int param(0);
+ std::string stringParam;
+ PerformanceProtocol::CommandId commandId(PerformanceProtocol::UNKNOWN_COMMAND);
- bool ok = PerformanceProtocol::GetCommandId( buffer, bufferSizeInBytes, commandId, param, stringParam );
- if( !ok )
+ bool ok = PerformanceProtocol::GetCommandId(buffer, bufferSizeInBytes, commandId, param, stringParam);
+ if(!ok)
{
- WriteSocket( UNKNOWN_CMD, sizeof(UNKNOWN_CMD) );
+ WriteSocket(UNKNOWN_CMD, sizeof(UNKNOWN_CMD));
return;
}
std::string response;
- switch( commandId )
+ switch(commandId)
{
case PerformanceProtocol::HELP_MESSAGE:
{
case PerformanceProtocol::ENABLE_TIME_MARKER_BIT_MASK:
{
- mMarkerBitmask = static_cast< PerformanceMarker::MarkerFilter >( param );
- response = "enable time marker ";
+ mMarkerBitmask = static_cast<PerformanceMarker::MarkerFilter>(param);
+ response = "enable time marker ";
break;
}
case PerformanceProtocol::DUMP_SCENE_GRAPH:
{
// this needs to be run on the main thread, use the trigger event....
- AutomationCallback* callback = new AutomationCallback( mClientId, mSendDataInterface );
+ AutomationCallback* callback = new AutomationCallback(mClientId, mSendDataInterface);
callback->AssignDumpSceneCommand();
// create a trigger event that automatically deletes itself after the callback has run in the main thread
- TriggerEventInterface *interface = TriggerEventFactory::CreateTriggerEvent( callback, TriggerEventInterface::DELETE_AFTER_TRIGGER );
+ TriggerEventInterface* interface = TriggerEventFactory::CreateTriggerEvent(callback, TriggerEventInterface::DELETE_AFTER_TRIGGER);
// asynchronous call, the call back will be run sometime later on the main thread
interface->Trigger();
case PerformanceProtocol::SET_PROPERTIES:
{
// this needs to be run on the main thread, use the trigger event....
- AutomationCallback* callback = new AutomationCallback( mClientId, mSendDataInterface );
- callback->AssignSetPropertyCommand( stringParam );
+ AutomationCallback* callback = new AutomationCallback(mClientId, mSendDataInterface);
+ callback->AssignSetPropertyCommand(stringParam);
// create a trigger event that automatically deletes itself after the callback has run in the main thread
- TriggerEventInterface *interface = TriggerEventFactory::CreateTriggerEvent( callback, TriggerEventInterface::DELETE_AFTER_TRIGGER );
+ TriggerEventInterface* interface = TriggerEventFactory::CreateTriggerEvent(callback, TriggerEventInterface::DELETE_AFTER_TRIGGER);
// asynchronous call, the call back will be run sometime later on the main thread
interface->Trigger();
case PerformanceProtocol::ENABLE_METRIC:
case PerformanceProtocol::DISABLE_METRIC:
{
- response="Metrics currently not supported";
+ response = "Metrics currently not supported";
break;
}
default:
break;
}
}
- if( ! response.empty() )
+ if(!response.empty())
{
// add a carriage return for console clients
- if( mConsoleClient )
+ if(mConsoleClient)
{
- response+="\n";
+ response += "\n";
}
- WriteSocket( response.c_str(), response.length() );
+ WriteSocket(response.c_str(), response.length());
}
}
-
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
/*
- * Copyright (c) 2018 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.
#include <dali/internal/network/common/network-performance-protocol.h>
// EXTERNAL INCLUDES
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
namespace Dali
{
-
namespace PerformanceProtocol
{
-
namespace
{
-
/**
* Command parameter type
*/
*/
struct CommandInfo
{
- CommandId cmdId;
- CommandString cmdString;
+ CommandId cmdId;
+ CommandString cmdString;
PARAMETER_TYPE paramType;
};
/**
* Command lookup table
*/
+// clang-format off
CommandInfo CommandLookup[]=
{
- { HELP_MESSAGE , "help" ,NO_PARAMS },
- { ENABLE_METRIC , "enable_metric" ,UNSIGNED_INT },
- { DISABLE_METRIC , "disable_metric" ,UNSIGNED_INT },
- { LIST_METRICS_AVAILABLE , "list_metrics" ,NO_PARAMS },
- { ENABLE_TIME_MARKER_BIT_MASK, "set_marker", UNSIGNED_INT },
- { DUMP_SCENE_GRAPH , "dump_scene" ,NO_PARAMS },
- { SET_PROPERTIES , "set_properties" ,STRING },
- { UNKNOWN_COMMAND , "unknown" ,NO_PARAMS }
+ {HELP_MESSAGE, "help", NO_PARAMS },
+ {ENABLE_METRIC, "enable_metric", UNSIGNED_INT},
+ {DISABLE_METRIC, "disable_metric", UNSIGNED_INT},
+ {LIST_METRICS_AVAILABLE, "list_metrics", NO_PARAMS },
+ {ENABLE_TIME_MARKER_BIT_MASK, "set_marker", UNSIGNED_INT},
+ {DUMP_SCENE_GRAPH, "dump_scene", NO_PARAMS },
+ {SET_PROPERTIES, "set_properties", STRING },
+ {UNKNOWN_COMMAND, "unknown", NO_PARAMS }
};
-const unsigned int CommandLookupLength = sizeof( CommandLookup ) /sizeof( CommandInfo );
+// clang-format on
+const unsigned int CommandLookupLength = sizeof(CommandLookup) / sizeof(CommandInfo);
-#define GREEN "\033[01;32m"
-#define NORMAL "\e[m"
+#define GREEN "\033[01;32m"
+#define NORMAL "\e[m"
#define PARAM "\033[22;32m"
#define YELLOW "\033[01;33m"
+// clang-format off
const char* const helpMsg =
YELLOW
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
GREEN " set_properties " PARAM "|178;Size;[ 144.0, 144.0, 144.0 ]|178;Color;[ 1.0, 1,0, 1.0 ]|\n"
"\n"
GREEN " dump_scene" NORMAL " - dump the current scene in json format\n";
-
+// clang-format off
} // un-named namespace
bool GetCommandId( const char* const commandString, unsigned int lengthInBytes, CommandId& commandId, unsigned int& intParam, std::string& stringParam )
/*
- * Copyright (c) 2018 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.
// CLASS HEADER
#include <dali/internal/network/common/network-performance-server.h>
-
// INTERNAL INCLUDES
#include <dali/internal/system/common/performance-marker.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // un-named namespace
{
-const unsigned int SERVER_PORT = 3031;
-const unsigned int MAXIMUM_PORTS_TO_TRY = 10; ///< if port in use, try up to SERVER_PORT + 10
-const unsigned int CONNECTION_BACKLOG = 2; ///< maximum length of the queue of pending connections.
-const unsigned int SOCKET_READ_BUFFER_SIZE = 4096;
-typedef Vector< NetworkPerformanceClient*> ClientList;
+const unsigned int SERVER_PORT = 3031;
+const unsigned int MAXIMUM_PORTS_TO_TRY = 10; ///< if port in use, try up to SERVER_PORT + 10
+const unsigned int CONNECTION_BACKLOG = 2; ///< maximum length of the queue of pending connections.
+const unsigned int SOCKET_READ_BUFFER_SIZE = 4096;
+typedef Vector<NetworkPerformanceClient*> ClientList;
/**
* POD passed to client thread on startup
NetworkPerformanceServer* server;
NetworkPerformanceClient* client;
};
-}
-
-NetworkPerformanceServer::NetworkPerformanceServer( AdaptorInternalServices& adaptorServices,
- const EnvironmentOptions& logOptions )
-: mSocketFactory( adaptorServices.GetSocketFactoryInterface() ),
- mLogOptions( logOptions ),
- mServerThread( 0 ),
- mListeningSocket( NULL ),
- mClientUniqueId( 0 ),
- mClientCount( 0 ),
- mLogFunctionInstalled( false )
+} // namespace
+
+NetworkPerformanceServer::NetworkPerformanceServer(AdaptorInternalServices& adaptorServices,
+ const EnvironmentOptions& logOptions)
+: mSocketFactory(adaptorServices.GetSocketFactoryInterface()),
+ mLogOptions(logOptions),
+ mServerThread(0),
+ mListeningSocket(NULL),
+ mClientUniqueId(0),
+ mClientCount(0),
+ mLogFunctionInstalled(false)
{
}
{
Stop();
- if( mLogFunctionInstalled )
+ if(mLogFunctionInstalled)
{
mLogOptions.UnInstallLogFunction();
}
void NetworkPerformanceServer::Start()
{
// start a thread to listen for incoming connection requests
- if (! mServerThread )
+ if(!mServerThread)
{
- if( mListeningSocket )
+ if(mListeningSocket)
{
- mSocketFactory.DestroySocket( mListeningSocket );
+ mSocketFactory.DestroySocket(mListeningSocket);
}
- mListeningSocket = mSocketFactory.NewSocket( SocketInterface::TCP);
- mListeningSocket->ReuseAddress( true );
+ mListeningSocket = mSocketFactory.NewSocket(SocketInterface::TCP);
+ mListeningSocket->ReuseAddress(true);
- bool bound = false;
+ bool bound = false;
unsigned int basePort = 0;
// try a small range of ports, so if multiple Dali apps are running you can select
// which one to connect to
- while( !bound && ( basePort < MAXIMUM_PORTS_TO_TRY ))
+ while(!bound && (basePort < MAXIMUM_PORTS_TO_TRY))
{
- bound = mListeningSocket->Bind( SERVER_PORT + basePort );
- if( !bound )
+ bound = mListeningSocket->Bind(SERVER_PORT + basePort);
+ if(!bound)
{
basePort++;
}
}
- if(!bound )
+ if(!bound)
{
DALI_LOG_ERROR("Failed to bind to a port \n");
return;
}
- mListeningSocket->Listen( CONNECTION_BACKLOG );
+ mListeningSocket->Listen(CONNECTION_BACKLOG);
// start a thread which will block waiting for new connections
- int error = pthread_create( &mServerThread, NULL, ConnectionListenerFunc, this );
- DALI_ASSERT_ALWAYS( !error && "pthread create failed" );
-
- Dali::Integration::Log::LogMessage(Integration::Log::DebugInfo, "~~~ NetworkPerformanceServer started on port %d ~~~ \n", SERVER_PORT + basePort);
+ int error = pthread_create(&mServerThread, NULL, ConnectionListenerFunc, this);
+ DALI_ASSERT_ALWAYS(!error && "pthread create failed");
+ Dali::Integration::Log::LogMessage(Integration::Log::DebugInfo, "~~~ NetworkPerformanceServer started on port %d ~~~ \n", SERVER_PORT + basePort);
}
}
void NetworkPerformanceServer::Stop()
{
- if( !mServerThread )
+ if(!mServerThread)
{
return;
}
- if( mListeningSocket )
+ if(mListeningSocket)
{
// close the server thread to prevent any new connections
mListeningSocket->ExitSelect();
// wait for the thread to exit.
void* exitValue;
- pthread_join( mServerThread, &exitValue );
+ pthread_join(mServerThread, &exitValue);
- if( mListeningSocket )
+ if(mListeningSocket)
{
// close the socket
mListeningSocket->CloseSocket();
}
- mSocketFactory.DestroySocket( mListeningSocket );
+ mSocketFactory.DestroySocket(mListeningSocket);
mListeningSocket = NULL;
// this will tell all client threads to quit
StopClients();
-
}
bool NetworkPerformanceServer::IsRunning() const
{
- if (mServerThread )
+ if(mServerThread)
{
return true;
}
return false;
}
-void NetworkPerformanceServer::ClientThread( NetworkPerformanceClient* client )
+void NetworkPerformanceServer::ClientThread(NetworkPerformanceClient* client)
{
mClientCount++;
- SocketInterface& socket( client->GetSocket() );
+ SocketInterface& socket(client->GetSocket());
- for( ;; )
+ for(;;)
{
SocketInterface::SelectReturn ret = socket.Select();
- if( ret == SocketInterface::DATA_AVAILABLE )
+ if(ret == SocketInterface::DATA_AVAILABLE)
{
- // Read
- char buffer[ SOCKET_READ_BUFFER_SIZE ];
- unsigned int bytesRead;
+ // Read
+ char buffer[SOCKET_READ_BUFFER_SIZE];
+ unsigned int bytesRead;
- bool ok = socket.Read( buffer, sizeof( buffer ) , bytesRead);
- if( ok && ( bytesRead > 0) )
+ bool ok = socket.Read(buffer, sizeof(buffer), bytesRead);
+ if(ok && (bytesRead > 0))
{
- client->ProcessCommand( buffer, bytesRead );
+ client->ProcessCommand(buffer, bytesRead);
}
- else // if bytesRead == 0, then client closed connection, if ok == false then an error
+ else // if bytesRead == 0, then client closed connection, if ok == false then an error
{
- DeleteClient( client );
+ DeleteClient(client);
return;
}
}
else // ret == QUIT or ERROR
{
- DeleteClient( client);
+ DeleteClient(client);
return;
}
}
void NetworkPerformanceServer::ConnectionListener()
{
// install Dali logging function for this thread
- if( !mLogFunctionInstalled )
+ if(!mLogFunctionInstalled)
{
mLogOptions.InstallLogFunction();
mLogFunctionInstalled = true;
}
- for( ;; )
+ for(;;)
{
// this will block, waiting for a client to connect
// or for mListeningSocket->ExitSelect() to be called
SocketInterface::SelectReturn ret = mListeningSocket->Select();
- if( ret == SocketInterface::DATA_AVAILABLE )
+ if(ret == SocketInterface::DATA_AVAILABLE)
{
SocketInterface* clientSocket = mListeningSocket->Accept();
// new connection made, spawn a thread to handle it
pthread_t* clientThread = new pthread_t();
- NetworkPerformanceClient* client = AddClient( clientSocket, clientThread );
+ NetworkPerformanceClient* client = AddClient(clientSocket, clientThread);
ClientThreadInfo* info = new ClientThreadInfo;
- info->client = client;
- info->server = this;
-
- int error = pthread_create( clientThread, NULL, ClientThreadFunc, info );
- DALI_ASSERT_ALWAYS( !error && "pthread create failed" );
+ info->client = client;
+ info->server = this;
+ int error = pthread_create(clientThread, NULL, ClientThreadFunc, info);
+ DALI_ASSERT_ALWAYS(!error && "pthread create failed");
}
else // ret == SocketInterface::QUIT or SocketInterface::ERROR
{
}
}
-void* NetworkPerformanceServer::ClientThreadFunc( void* data )
+void* NetworkPerformanceServer::ClientThreadFunc(void* data)
{
- ClientThreadInfo* info = static_cast<ClientThreadInfo*>( data );
- info->server->ClientThread( info->client );
+ ClientThreadInfo* info = static_cast<ClientThreadInfo*>(data);
+ info->server->ClientThread(info->client);
delete info;
return NULL;
}
-NetworkPerformanceClient* NetworkPerformanceServer::AddClient( SocketInterface* clientSocket, pthread_t* clientThread )
+NetworkPerformanceClient* NetworkPerformanceServer::AddClient(SocketInterface* clientSocket, pthread_t* clientThread)
{
// This function is only called from the listening thread
- NetworkPerformanceClient* client= new NetworkPerformanceClient( clientThread,
+ NetworkPerformanceClient* client = new NetworkPerformanceClient(clientThread,
clientSocket,
mClientUniqueId++,
*this,
mSocketFactory);
// protect the mClients list which can be accessed from multiple threads.
- Mutex::ScopedLock lock( mClientListMutex );
+ Mutex::ScopedLock lock(mClientListMutex);
- mClients.PushBack( client );
+ mClients.PushBack(client);
return client;
}
-void NetworkPerformanceServer::DeleteClient( NetworkPerformanceClient* client )
+void NetworkPerformanceServer::DeleteClient(NetworkPerformanceClient* client)
{
// protect the mClients list while modifying
- Mutex::ScopedLock lock( mClientListMutex );
+ Mutex::ScopedLock lock(mClientListMutex);
// remove from the list, and delete it
- for( ClientList::Iterator iter = mClients.Begin(); iter != mClients.End() ; ++iter )
+ for(ClientList::Iterator iter = mClients.Begin(); iter != mClients.End(); ++iter)
{
- if( (*iter) == client )
+ if((*iter) == client)
{
- mClients.Erase( iter );
+ mClients.Erase(iter);
delete client;
// if there server is shutting down, it waits for client count to hit zero
}
}
-void NetworkPerformanceServer::SendData( const char* const data, unsigned int bufferSizeInBytes,unsigned int clientId )
+void NetworkPerformanceServer::SendData(const char* const data, unsigned int bufferSizeInBytes, unsigned int clientId)
{
- if( ! mClientCount )
+ if(!mClientCount)
{
return;
}
// prevent clients been added / deleted while transmiting data
- Mutex::ScopedLock lock( mClientListMutex );
+ Mutex::ScopedLock lock(mClientListMutex);
- for( ClientList::Iterator iter = mClients.Begin(); iter != mClients.End() ; ++iter )
+ for(ClientList::Iterator iter = mClients.Begin(); iter != mClients.End(); ++iter)
{
NetworkPerformanceClient* client = (*iter);
- if( client->GetId() == clientId )
+ if(client->GetId() == clientId)
{
- client->WriteSocket(data ,bufferSizeInBytes);
+ client->WriteSocket(data, bufferSizeInBytes);
return;
}
}
}
-void NetworkPerformanceServer::TransmitMarker( const PerformanceMarker& marker, const char* const description )
+void NetworkPerformanceServer::TransmitMarker(const PerformanceMarker& marker, const char* const description)
{
- if( ! IsRunning() )
+ if(!IsRunning())
{
return;
}
// prevent clients been added / deleted while transmiting data
- Mutex::ScopedLock lock( mClientListMutex );
+ Mutex::ScopedLock lock(mClientListMutex);
- for( ClientList::Iterator iter = mClients.Begin(); iter != mClients.End() ; ++iter )
+ for(ClientList::Iterator iter = mClients.Begin(); iter != mClients.End(); ++iter)
{
NetworkPerformanceClient* client = (*iter);
- client->TransmitMarker( marker, description );
+ client->TransmitMarker(marker, description);
}
}
-
void NetworkPerformanceServer::StopClients()
{
// prevent clients been added / deleted while stopping all clients
- Mutex::ScopedLock lock( mClientListMutex );
+ Mutex::ScopedLock lock(mClientListMutex);
- for( ClientList::Iterator iter = mClients.Begin(); iter != mClients.End() ; ++iter )
+ for(ClientList::Iterator iter = mClients.Begin(); iter != mClients.End(); ++iter)
{
NetworkPerformanceClient* client = (*iter);
// stop the client from waiting for new commands, and exit from it's thread
}
}
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-SocketInterface* SocketFactory::NewSocket( SocketInterface::Protocol protocol )
+SocketInterface* SocketFactory::NewSocket(SocketInterface::Protocol protocol)
{
- return new Socket( protocol );
+ return new Socket(protocol);
}
-void SocketFactory::DestroySocket( SocketInterface* socketInterface )
+void SocketFactory::DestroySocket(SocketInterface* socketInterface)
{
- Socket* socket( static_cast<Socket* >( socketInterface ));
+ Socket* socket(static_cast<Socket*>(socketInterface));
delete socket;
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2017 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.
#include <dali/internal/network/common/socket-impl.h>
// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <errno.h>
+#include <netinet/in.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <errno.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <dali/integration-api/debug.h>
// Sockets enums like INADDR_ANY use C-Casts
#pragma GCC diagnostic push
{
namespace Adaptor
{
-
namespace
{
-const unsigned int MAX_SOCKET_DATA_WRITE_SIZE = 1024 * 1024 * 10 ; // limit maximum size to write to 10 MB
+const unsigned int MAX_SOCKET_DATA_WRITE_SIZE = 1024 * 1024 * 10; // limit maximum size to write to 10 MB
}
-Socket::Socket( Protocol protocol , int fileDescriptor )
-:mSocketFileDescriptor( fileDescriptor ),
- mBound(false),
- mListening(false),
- mQuitPipeCreated(false),
- mBlocked(false)
+Socket::Socket(Protocol protocol, int fileDescriptor)
+: mSocketFileDescriptor(fileDescriptor),
+ mBound(false),
+ mListening(false),
+ mQuitPipeCreated(false),
+ mBlocked(false)
{
- int addressFamily( AF_INET );
- int netProtocol( IPPROTO_TCP );
- int type( SOCK_STREAM ); // for TCP
+ int addressFamily(AF_INET);
+ int netProtocol(IPPROTO_TCP);
+ int type(SOCK_STREAM); // for TCP
- if( protocol == UDP )
+ if(protocol == UDP)
{
- type = SOCK_DGRAM;
+ type = SOCK_DGRAM;
netProtocol = IPPROTO_UDP;
}
- if( mSocketFileDescriptor == -1)
+ if(mSocketFileDescriptor == -1)
{
- mSocketFileDescriptor = socket( addressFamily,type, netProtocol);
- if( mSocketFileDescriptor == -1 )
+ mSocketFileDescriptor = socket(addressFamily, type, netProtocol);
+ if(mSocketFileDescriptor == -1)
{
- DALI_LOG_ERROR( "Unable to create socket\n" );
+ DALI_LOG_ERROR("Unable to create socket\n");
}
}
else
Socket::~Socket()
{
- if( SocketIsOpen() )
+ if(SocketIsOpen())
{
CloseSocket();
}
bool Socket::CloseSocket()
{
-
- if( ! SocketIsOpen() )
+ if(!SocketIsOpen())
{
DALI_LOG_ERROR("Socket already closed or is invalid \n");
return false;
}
- int ret = close( mSocketFileDescriptor );
+ int ret = close(mSocketFileDescriptor);
mSocketFileDescriptor = -1;
- mListening = false;
- mBound = false;
+ mListening = false;
+ mBound = false;
- if( ret == -1 )
+ if(ret == -1)
{
DALI_LOG_ERROR("Socket close failed\n");
return false;
return true;
}
-bool Socket::Bind( uint16_t port )
+bool Socket::Bind(uint16_t port)
{
- if( ! SocketIsOpen() || mBound )
+ if(!SocketIsOpen() || mBound)
{
- DALI_LOG_ERROR("Socket is invalid, or already bound\n");
- return false;
+ DALI_LOG_ERROR("Socket is invalid, or already bound\n");
+ return false;
}
struct sockaddr_in serverAddress;
- memset( &serverAddress, 0, sizeof(serverAddress) );
- serverAddress.sin_family = AF_INET; // internet
- serverAddress.sin_port = htons( port ); // host-to-net short (16-bit) translation
- serverAddress.sin_addr.s_addr = htonl( INADDR_ANY ); // binds the socket to all available interfaces
+ memset(&serverAddress, 0, sizeof(serverAddress));
+ serverAddress.sin_family = AF_INET; // internet
+ serverAddress.sin_port = htons(port); // host-to-net short (16-bit) translation
+ serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); // binds the socket to all available interfaces
- int ret = bind( mSocketFileDescriptor,
- reinterpret_cast< struct sockaddr* >( &serverAddress ),
- sizeof(serverAddress));
+ int ret = bind(mSocketFileDescriptor,
+ reinterpret_cast<struct sockaddr*>(&serverAddress),
+ sizeof(serverAddress));
- if( ret == -1 )
+ if(ret == -1)
{
char buf[512];
- DALI_LOG_ERROR( "bind failed for port %d %s \n", port, strerror_r( errno, buf, 512 ) );
+ DALI_LOG_ERROR("bind failed for port %d %s \n", port, strerror_r(errno, buf, 512));
return false;
}
return true;
}
-bool Socket::Listen( int blacklog)
+bool Socket::Listen(int blacklog)
{
- if( ! mBound || mListening )
+ if(!mBound || mListening)
{
DALI_LOG_ERROR("socket is not bound, or already opened for listening\n");
return false;
}
- int ret = listen( mSocketFileDescriptor, blacklog);
+ int ret = listen(mSocketFileDescriptor, blacklog);
- if( ret == -1 )
+ if(ret == -1)
{
DALI_LOG_ERROR("Listen failed\n");
return false;
SocketInterface* Socket::Accept() const
{
- if( !mListening )
+ if(!mListening)
{
DALI_LOG_ERROR("socket is not being listened to\n");
return NULL;
socklen_t addressLength(sizeof(sockaddr_in));
- int clientFileDescriptor = accept( mSocketFileDescriptor, &clientAddress, &addressLength);
- if( clientFileDescriptor == -1 )
+ int clientFileDescriptor = accept(mSocketFileDescriptor, &clientAddress, &addressLength);
+ if(clientFileDescriptor == -1)
{
- DALI_LOG_ERROR("Accept failed\n");
- return NULL;
+ DALI_LOG_ERROR("Accept failed\n");
+ return NULL;
}
// create a new socket, only TCP supports connections
- Socket* client = new Socket( TCP, clientFileDescriptor );
+ Socket* client = new Socket(TCP, clientFileDescriptor);
return client;
}
bool Socket::CreateQuitPipe()
{
- if( !mQuitPipeCreated )
+ if(!mQuitPipeCreated)
{
// create a pipe file descriptor to be able to break from the Select statement
//
- int ret = pipe( mQuitPipe );
- if( ret != 0)
+ int ret = pipe(mQuitPipe);
+ if(ret != 0)
{
DALI_LOG_ERROR("Pipe creation failed\n");
return false;
}
void Socket::DeleteQuitPipe()
{
- if( mQuitPipeCreated )
+ if(mQuitPipeCreated)
{
- close( mQuitPipe[0] );
- close( mQuitPipe[1] );
+ close(mQuitPipe[0]);
+ close(mQuitPipe[1]);
}
}
SocketInterface::SelectReturn Socket::Select()
{
bool ok = CreateQuitPipe();
- if( !ok )
+ if(!ok)
{
return ERROR;
}
- fd_set readFileDescriptors, exceptFileDescriptors;
+ fd_set readFileDescriptors, exceptFileDescriptors;
FD_ZERO(&readFileDescriptors);
FD_ZERO(&exceptFileDescriptors);
- FD_SET(mSocketFileDescriptor,&readFileDescriptors );
- FD_SET(mQuitPipe[0],&readFileDescriptors );
+ FD_SET(mSocketFileDescriptor, &readFileDescriptors);
+ FD_SET(mQuitPipe[0], &readFileDescriptors);
- FD_SET(mSocketFileDescriptor,&exceptFileDescriptors);
+ FD_SET(mSocketFileDescriptor, &exceptFileDescriptors);
- unsigned int maxFd = mQuitPipe[0] > mSocketFileDescriptor ? mQuitPipe[0]: mSocketFileDescriptor;
+ unsigned int maxFd = mQuitPipe[0] > mSocketFileDescriptor ? mQuitPipe[0] : mSocketFileDescriptor;
- for( ;; )
+ for(;;)
{
// this will block waiting for file descriptors
- int ret = select( maxFd+1, &readFileDescriptors, NULL, &exceptFileDescriptors, NULL );
- if( ret == -1 )
+ int ret = select(maxFd + 1, &readFileDescriptors, NULL, &exceptFileDescriptors, NULL);
+ if(ret == -1)
{
DALI_LOG_ERROR("select failed\n");
return ERROR;
}
- else if ( FD_ISSET( mQuitPipe[0] , &readFileDescriptors ))
+ else if(FD_ISSET(mQuitPipe[0], &readFileDescriptors))
{
// ExitSelect() called
return QUIT;
}
- else if ( FD_ISSET( mSocketFileDescriptor, &readFileDescriptors ))
+ else if(FD_ISSET(mSocketFileDescriptor, &readFileDescriptors))
{
// socket data received
return DATA_AVAILABLE;
void Socket::ExitSelect()
{
- if( mQuitPipeCreated )
+ if(mQuitPipeCreated)
{
// write a single character to the pipe (can be anything)
- char c = ' ';
- int ret = write( mQuitPipe[1], &c, 1);
- if( ret < 1 )
+ char c = ' ';
+ int ret = write(mQuitPipe[1], &c, 1);
+ if(ret < 1)
{
DALI_LOG_ERROR("ExitSelect failed!\n");
}
}
}
-bool Socket::ReuseAddress( bool reUse )
+bool Socket::ReuseAddress(bool reUse)
{
- if( ! SocketIsOpen() | mBound )
+ if(!SocketIsOpen() | mBound)
{
DALI_LOG_ERROR("Socket is invalid or already bound \n");
return false;
int reUseInteger = reUse; // convert it to an int
- int ret = setsockopt( mSocketFileDescriptor, SOL_SOCKET, SO_REUSEADDR, &reUseInteger, sizeof(reUseInteger));
- if( ret == -1 )
+ int ret = setsockopt(mSocketFileDescriptor, SOL_SOCKET, SO_REUSEADDR, &reUseInteger, sizeof(reUseInteger));
+ if(ret == -1)
{
char buf[512];
- DALI_LOG_ERROR( "SO_REUSEADDR option failed %s \n", strerror_r( errno, buf, 512 ) );
+ DALI_LOG_ERROR("SO_REUSEADDR option failed %s \n", strerror_r(errno, buf, 512));
return false;
}
return true;
}
-bool Socket::SetBufferSize( SocketInterface::BufferType type, unsigned int size )
+bool Socket::SetBufferSize(SocketInterface::BufferType type, unsigned int size)
{
- if( ! SocketIsOpen() || mBound )
+ if(!SocketIsOpen() || mBound)
{
DALI_LOG_ERROR("Socket is invalid or already bound \n");
return false;
}
int option = SO_RCVBUF;
- if( type == SocketInterface::SEND_BUFFER )
+ if(type == SocketInterface::SEND_BUFFER)
{
option = SO_SNDBUF;
}
- int ret = setsockopt( mSocketFileDescriptor, SOL_SOCKET,option,&size,sizeof(size));
- if( ret == -1 )
+ int ret = setsockopt(mSocketFileDescriptor, SOL_SOCKET, option, &size, sizeof(size));
+ if(ret == -1)
{
DALI_LOG_ERROR("SO_RCVBUF / SO_SNDBUF option failed \n");
return false;
return true;
}
-bool Socket::Read( void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead )
+bool Socket::Read(void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead)
{
bytesRead = 0;
- if( !SocketIsOpen() )
+ if(!SocketIsOpen())
{
DALI_LOG_ERROR("Socket is invalid \n");
return false;
}
- bytesRead = read( mSocketFileDescriptor, buffer, bufferSizeInBytes );
+ bytesRead = read(mSocketFileDescriptor, buffer, bufferSizeInBytes);
return true;
}
-bool Socket::Write( const void* buffer, unsigned int bufferSizeInBytes )
+bool Socket::Write(const void* buffer, unsigned int bufferSizeInBytes)
{
- if( !SocketIsOpen() )
+ if(!SocketIsOpen())
{
DALI_LOG_ERROR("Socket is invalid \n");
return false;
}
// check we don't try to write more than 10MB ( this can be increased if required)
- if( bufferSizeInBytes > MAX_SOCKET_DATA_WRITE_SIZE )
+ if(bufferSizeInBytes > MAX_SOCKET_DATA_WRITE_SIZE)
{
DALI_LOG_ERROR("Writing %d bytes exceeds MAX_SOCKET_DATA_WRITE_SIZE of %d bytes \n", bufferSizeInBytes, MAX_SOCKET_DATA_WRITE_SIZE);
return false;
// write isn't guaranteed to write the entire buffer in one go
- while( bytesWritten != static_cast< int>(bufferSizeInBytes))
+ while(bytesWritten != static_cast<int>(bufferSizeInBytes))
{
- const char* byteBuffer = static_cast<const char *>( buffer );
- byteBuffer+=bytesWritten;
+ const char* byteBuffer = static_cast<const char*>(buffer);
+ byteBuffer += bytesWritten;
- int ret = write( mSocketFileDescriptor, byteBuffer, bufferSizeInBytes - bytesWritten );
- if( ret < 1)
+ int ret = write(mSocketFileDescriptor, byteBuffer, bufferSizeInBytes - bytesWritten);
+ if(ret < 1)
{
DALI_LOG_ERROR("Socket writer error \n");
return false;
return true;
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#pragma GCC diagnostic pop
/*
- * 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.
#include <dali/internal/offscreen/common/offscreen-application-impl.h>
// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/offscreen/common/offscreen-window-impl.h>
-#include <dali/internal/adaptor/common/thread-controller-interface.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/native-render-surface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/thread-controller-interface.h>
+#include <dali/internal/offscreen/common/offscreen-window-impl.h>
namespace Dali
{
-
namespace Internal
{
-
using RenderMode = Dali::OffscreenApplication::RenderMode;
-IntrusivePtr< OffscreenApplication > OffscreenApplication::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
+IntrusivePtr<OffscreenApplication> OffscreenApplication::New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode)
{
- IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode );
+ IntrusivePtr<OffscreenApplication> offscreenApplication = new OffscreenApplication(width, height, surface, isTranslucent, renderMode);
return offscreenApplication;
}
-OffscreenApplication::OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode )
+OffscreenApplication::OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode)
{
// Generate a default window
- IntrusivePtr< Internal::OffscreenWindow > impl = Internal::OffscreenWindow::New( width, height, surface, isTranslucent );
- mDefaultWindow = Dali::OffscreenWindow( impl.Get() );
+ IntrusivePtr<Internal::OffscreenWindow> impl = Internal::OffscreenWindow::New(width, height, surface, isTranslucent);
+ mDefaultWindow = Dali::OffscreenWindow(impl.Get());
- mAdaptor.reset( Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( impl.Get() ), impl->GetSurface(), NULL,
- renderMode == RenderMode::AUTO ? Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED ) );
+ mAdaptor.reset(Dali::Internal::Adaptor::Adaptor::New(Dali::Integration::SceneHolder(impl.Get()), impl->GetSurface(), NULL, renderMode == RenderMode::AUTO ? Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED));
// Initialize default window
- impl->Initialize( true );
+ impl->Initialize(true);
}
void OffscreenApplication::Start()
// Start the adaptor
mAdaptor->Start();
- Dali::OffscreenApplication handle( this );
+ Dali::OffscreenApplication handle(this);
mInitSignal.Emit();
mAdaptor->NotifySceneCreated();
}
// Stop the adaptor
mAdaptor->Stop();
- Dali::OffscreenApplication handle( this );
+ Dali::OffscreenApplication handle(this);
mTerminateSignal.Emit();
}
/*
- * 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.
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/adaptor.h>
-#include <dali/integration-api/adaptor-framework/native-render-surface.h>
#include <dali/integration-api/adaptor-framework/native-render-surface-factory.h>
+#include <dali/integration-api/adaptor-framework/native-render-surface.h>
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
#include <dali/internal/offscreen/common/offscreen-application-impl.h>
namespace Dali
{
-
namespace Internal
{
-
-OffscreenWindow* OffscreenWindow::New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent )
+OffscreenWindow* OffscreenWindow::New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent)
{
- OffscreenWindow* window = new OffscreenWindow( width, height, surface, isTranslucent );
+ OffscreenWindow* window = new OffscreenWindow(width, height, surface, isTranslucent);
return window;
}
-OffscreenWindow::OffscreenWindow( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent )
+OffscreenWindow::OffscreenWindow(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent)
: mRenderNotification()
{
// Create surface
- mSurface = std::unique_ptr< RenderSurfaceInterface >( CreateNativeSurface( SurfaceSize( width, height ), surface, isTranslucent ) );
+ mSurface = std::unique_ptr<RenderSurfaceInterface>(CreateNativeSurface(SurfaceSize(width, height), surface, isTranslucent));
}
-void OffscreenWindow::Initialize( bool isDefaultWindow )
+void OffscreenWindow::Initialize(bool isDefaultWindow)
{
- if( isDefaultWindow )
+ if(isDefaultWindow)
{
Initialize();
return;
}
- Dali::Integration::SceneHolder sceneHolderHandler = Dali::Integration::SceneHolder( this );
- Dali::Adaptor::Get().AddWindow( sceneHolderHandler );
+ Dali::Integration::SceneHolder sceneHolderHandler = Dali::Integration::SceneHolder(this);
+ Dali::Adaptor::Get().AddWindow(sceneHolderHandler);
Initialize();
}
// Connect callback to be notified when the surface is rendered
TriggerEventFactory triggerEventFactory;
- mRenderNotification = std::unique_ptr< TriggerEventInterface >( triggerEventFactory.CreateTriggerEvent( MakeCallback( this, &OffscreenWindow::OnPostRender ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ) );
+ mRenderNotification = std::unique_ptr<TriggerEventInterface>(triggerEventFactory.CreateTriggerEvent(MakeCallback(this, &OffscreenWindow::OnPostRender), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER));
NativeRenderSurface* surface = GetNativeRenderSurface();
- if( !surface )
+ if(!surface)
{
return;
}
- surface->SetRenderNotification( mRenderNotification.get() );
+ surface->SetRenderNotification(mRenderNotification.get());
}
OffscreenWindow::~OffscreenWindow()
{
NativeRenderSurface* surface = GetNativeRenderSurface();
- if( surface )
+ if(surface)
{
// To prevent notification triggering in NativeRenderSurface::PostRender while deleting SceneHolder
- surface->SetRenderNotification( nullptr );
+ surface->SetRenderNotification(nullptr);
}
}
return mScene.GetLayerCount();
}
-Dali::Layer OffscreenWindow::GetLayer( uint32_t depth ) const
+Dali::Layer OffscreenWindow::GetLayer(uint32_t depth) const
{
- return mScene.GetLayer( depth );
+ return mScene.GetLayer(depth);
}
OffscreenWindow::WindowSize OffscreenWindow::GetSize() const
{
Size size = mScene.GetSize();
- return OffscreenWindow::WindowSize( static_cast<uint16_t>( size.width ), static_cast<uint16_t>( size.height ) );
+ return OffscreenWindow::WindowSize(static_cast<uint16_t>(size.width), static_cast<uint16_t>(size.height));
}
Dali::Any OffscreenWindow::GetNativeHandle() const
{
NativeRenderSurface* surface = GetNativeRenderSurface();
- DALI_ASSERT_ALWAYS( surface && "surface handle is empty" );
+ DALI_ASSERT_ALWAYS(surface && "surface handle is empty");
return surface->GetNativeRenderable();
}
NativeRenderSurface* OffscreenWindow::GetNativeRenderSurface() const
{
- return dynamic_cast< NativeRenderSurface* >( mSurface.get() );
+ return dynamic_cast<NativeRenderSurface*>(mSurface.get());
}
void OffscreenWindow::OnPostRender()
{
- Dali::OffscreenWindow handle( this );
- mPostRenderSignal.Emit( handle, GetNativeHandle() );
+ Dali::OffscreenWindow handle(this);
+ mPostRenderSignal.Emit(handle, GetNativeHandle());
}
OffscreenWindow::PostRenderSignalType& OffscreenWindow::PostRenderSignal()
/*
- * Copyright (c) 2017 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.
*
*/
+#include <dali/devel-api/common/singleton-service.h>
#include <dali/internal/sensor/common/tilt-sensor-factory.h>
#include <dali/internal/sensor/common/tilt-sensor-impl.h>
-#include <dali/devel-api/common/singleton-service.h>
namespace Dali
{
{
namespace Adaptor
{
-
namespace TiltSensorFactory
{
__attribute__((weak)) Dali::Internal::Adaptor::TiltSensor* Create()
Dali::SingletonService service(SingletonService::Get());
- if (service)
+ if(service)
{
// Check whether the keyboard focus manager is already created
Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TiltSensor));
- if (handle)
+ if(handle)
{
// If so, downcast the handle of singleton to keyboard focus manager
- sensor = Dali::TiltSensor(dynamic_cast< TiltSensor * >( handle.GetObjectPtr()));
+ sensor = Dali::TiltSensor(dynamic_cast<TiltSensor*>(handle.GetObjectPtr()));
}
else
{
}
return sensor;
}
-}
+} // namespace TiltSensorFactory
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
TiltSensor::TiltSensor() = default;
TiltSensor::~TiltSensor() = default;
void TiltSensor::Stop()
{
-
}
bool TiltSensor::IsStarted() const
return Quaternion::IDENTITY;
}
-
TiltSensor::TiltedSignalType& TiltSensor::TiltedSignal()
{
static TiltSensor::TiltedSignalType signal;
return signal;
}
-
void TiltSensor::SetUpdateFrequency(float frequencyHertz)
{
-
}
float TiltSensor::GetUpdateFrequency() const
void TiltSensor::SetRotationThreshold(Radian rotationThreshold)
{
-
}
/**
* @return True if the signal was connected.
* @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
*/
-bool TiltSensor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool TiltSensor::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
return false;
}
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace TiltSensorFactory
{
-
Dali::Internal::Adaptor::TiltSensor* Create()
{
return Dali::Internal::Adaptor::TiltSensorTizen::New();
}
-} // TiltSensorFactory
+} // namespace TiltSensorFactory
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
\ No newline at end of file
+} // namespace Dali
\ No newline at end of file
/*
- * Copyright (c) 2017 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.
*/
// CLASS HEADER
-#include <dali/internal/sensor/tizen/tilt-sensor-impl-tizen.h>
#include <dali/internal/sensor/common/tilt-sensor-factory.h>
+#include <dali/internal/sensor/tizen/tilt-sensor-impl-tizen.h>
// EXTERNAL INCLUDES
-#include <cmath>
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+#include <cmath>
namespace // unnamed namespace
{
const char* const SIGNAL_TILTED = "tilted";
-const float MAX_ORIENTATION_ROLL_VALUE = 90.f;
+const float MAX_ORIENTATION_ROLL_VALUE = 90.f;
const float MAX_ORIENTATION_PITCH_VALUE = 180.f;
-const float MAX_ACCELEROMETER_VALUE = 9.8f;
+const float MAX_ACCELEROMETER_VALUE = 9.8f;
// Type Registration
Dali::BaseHandle Create()
return Dali::Internal::Adaptor::TiltSensorFactory::Get();
}
-Dali::TypeRegistration typeRegistration( typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), Create );
+Dali::TypeRegistration typeRegistration(typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), Create);
-Dali::SignalConnectorType signalConnector1( typeRegistration, SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal );
+Dali::SignalConnectorType signalConnector1(typeRegistration, SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal);
} // unnamed namespace
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
#ifdef SENSOR_ENABLED
-static void sensor_changed_cb (sensor_h sensor, sensor_event_s *event, void *user_data)
+static void sensor_changed_cb(sensor_h sensor, sensor_event_s* event, void* user_data)
{
- TiltSensorTizen* tiltSensor = reinterpret_cast< TiltSensorTizen* >( user_data );
+ TiltSensorTizen* tiltSensor = reinterpret_cast<TiltSensorTizen*>(user_data);
if(tiltSensor)
{
Disconnect();
}
- const int interval = 1000/mFrequencyHertz;
+ const int interval = 1000 / mFrequencyHertz;
- int ret = 0;
+ int ret = 0;
bool isSupported = false;
// try to use Orientation sensor at first for less power consumption.
sensor_listener_stop(mSensorListener);
sensor_destroy_listener(mSensorListener);
#endif
- mSensor = NULL;
+ mSensor = NULL;
mSensorListener = NULL;
- mState = DISCONNECTED;
+ mState = DISCONNECTED;
}
}
}
bool TiltSensorTizen::Start()
{
- if( mSensorListener && ( mState == CONNECTED || mState == STOPPED ) )
+ if(mSensorListener && (mState == CONNECTED || mState == STOPPED))
{
#ifdef SENSOR_ENABLED
int ret = 0;
- ret = sensor_listener_start(mSensorListener);
+ ret = sensor_listener_start(mSensorListener);
if(ret != SENSOR_ERROR_NONE)
{
DALI_LOG_ERROR("sensor_listener_start() failed : %s\n", get_sensor_error_string(ret).c_str());
}
else
{
- if( mState == STARTED )
+ if(mState == STARTED)
{
DALI_LOG_ERROR("TiltSensor is already started. Current state [%d]\n", mState);
}
#ifdef SENSOR_ENABLED
if(mSensorListener && mState == STARTED)
{
- sensor_listener_stop( mSensorListener );
+ sensor_listener_stop(mSensorListener);
mState = STOPPED;
}
#endif
bool TiltSensorTizen::IsStarted() const
{
- return ( mSensorListener && mState == STARTED );
+ return (mSensorListener && mState == STARTED);
}
float TiltSensorTizen::GetRoll() const
return mTiltedSignal;
}
-void TiltSensorTizen::SetUpdateFrequency( float frequencyHertz )
+void TiltSensorTizen::SetUpdateFrequency(float frequencyHertz)
{
- DALI_ASSERT_ALWAYS( frequencyHertz > 0.0f && "Frequency must have a positive value" );
+ DALI_ASSERT_ALWAYS(frequencyHertz > 0.0f && "Frequency must have a positive value");
- if ( fabsf(mFrequencyHertz - frequencyHertz) >= GetRangedEpsilon(mFrequencyHertz, frequencyHertz) )
+ if(fabsf(mFrequencyHertz - frequencyHertz) >= GetRangedEpsilon(mFrequencyHertz, frequencyHertz))
{
mFrequencyHertz = frequencyHertz;
#ifdef SENSOR_ENABLED
if(mSensorListener)
{
- const int interval = 1000/mFrequencyHertz;
+ const int interval = 1000 / mFrequencyHertz;
sensor_listener_set_interval(mSensorListener, interval);
}
#endif
return mRotationThreshold;
}
-bool TiltSensorTizen::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool TiltSensorTizen::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- TiltSensor* sensor = dynamic_cast<TiltSensor*>( object );
+ bool connected(true);
+ TiltSensor* sensor = dynamic_cast<TiltSensor*>(object);
- if( sensor && SIGNAL_TILTED == signalName )
+ if(sensor && SIGNAL_TILTED == signalName)
{
- sensor->TiltedSignal().Connect( tracker, functor );
+ sensor->TiltedSignal().Connect(tracker, functor);
}
else
{
TiltSensorTizen::TiltSensorTizen()
: mState(DISCONNECTED),
- mFrequencyHertz( Dali::TiltSensor::DEFAULT_UPDATE_FREQUENCY ),
- mSensor( NULL ),
- mSensorListener( NULL ),
- mRoll( 0.0f ),
- mPitch( 0.0f ),
- mRotation( Radian(0.0f), Vector3::YAXIS ),
- mRotationThreshold( 0.0f )
+ mFrequencyHertz(Dali::TiltSensor::DEFAULT_UPDATE_FREQUENCY),
+ mSensor(NULL),
+ mSensorListener(NULL),
+ mRoll(0.0f),
+ mPitch(0.0f),
+ mRotation(Radian(0.0f), Vector3::YAXIS),
+ mRotationThreshold(0.0f)
{
// connect sensor
Connect();
}
#ifdef SENSOR_ENABLED
-void TiltSensorTizen::Update(sensor_event_s *event)
+void TiltSensorTizen::Update(sensor_event_s* event)
{
- Radian newRoll( 0.0f );
- Radian newPitch( 0.0f );
+ Radian newRoll(0.0f);
+ Radian newPitch(0.0f);
Quaternion newRotation;
if(mSensorType == SENSOR_ORIENTATION)
{
- newRoll = Clamp( float(event->values[2] / MAX_ORIENTATION_ROLL_VALUE) /* -90 < roll < 90 */, -1.0f/*min*/, 1.0f/*max*/ );
- newPitch = Clamp( float(event->values[1] / MAX_ORIENTATION_PITCH_VALUE) /* -180 < pitch < 180 */, -1.0f/*min*/, 1.0f/*max*/ );
+ newRoll = Clamp(float(event->values[2] / MAX_ORIENTATION_ROLL_VALUE) /* -90 < roll < 90 */, -1.0f /*min*/, 1.0f /*max*/);
+ newPitch = Clamp(float(event->values[1] / MAX_ORIENTATION_PITCH_VALUE) /* -180 < pitch < 180 */, -1.0f /*min*/, 1.0f /*max*/);
}
else if(mSensorType == SENSOR_ACCELEROMETER)
{
- newRoll = Clamp( float(event->values[0] / MAX_ACCELEROMETER_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
- newPitch = Clamp( float(event->values[1] / MAX_ACCELEROMETER_VALUE), -1.0f/*min*/, 1.0f/*max*/ );
+ newRoll = Clamp(float(event->values[0] / MAX_ACCELEROMETER_VALUE), -1.0f /*min*/, 1.0f /*max*/);
+ newPitch = Clamp(float(event->values[1] / MAX_ACCELEROMETER_VALUE), -1.0f /*min*/, 1.0f /*max*/);
}
else
{
return;
}
- newRotation = Quaternion( Radian( newRoll * Math::PI * -0.5f ), Vector3::YAXIS ) *
- Quaternion( Radian( newPitch * Math::PI * -0.5f ), Vector3::XAXIS );
+ newRotation = Quaternion(Radian(newRoll * Math::PI * -0.5f), Vector3::YAXIS) *
+ Quaternion(Radian(newPitch * Math::PI * -0.5f), Vector3::XAXIS);
Radian angle(Quaternion::AngleBetween(newRotation, mRotation));
// If the change in value is more than the threshold then emit tilted signal.
- if( angle >= mRotationThreshold )
+ if(angle >= mRotationThreshold)
{
- mRoll = newRoll;
- mPitch = newPitch;
+ mRoll = newRoll;
+ mPitch = newPitch;
mRotation = newRotation;
// emit signal
- if ( !mTiltedSignal.Empty() )
+ if(!mTiltedSignal.Empty())
{
- Dali::TiltSensor handle( this );
- mTiltedSignal.Emit( handle );
+ Dali::TiltSensor handle(this);
+ mTiltedSignal.Emit(handle);
}
}
}
{
namespace TiltSensorFactory
{
-
Dali::Internal::Adaptor::TiltSensor* Create()
{
return Dali::Internal::Adaptor::TiltSensorUbuntu::New();
}
-} // TiltSensorFactory
+} // namespace TiltSensorFactory
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
\ No newline at end of file
+} // namespace Dali
\ No newline at end of file
*/
// CLASS HEADER
-#include <dali/internal/sensor/ubuntu/tilt-sensor-impl-ubuntu.h>
#include <dali/internal/sensor/common/tilt-sensor-factory.h>
+#include <dali/internal/sensor/ubuntu/tilt-sensor-impl-ubuntu.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
namespace // unnamed namespace
{
-
const char* const SIGNAL_TILTED = "tilted";
const int NUMBER_OF_SAMPLES = 10;
return Dali::Internal::Adaptor::TiltSensorFactory::Get();
}
-Dali::TypeRegistration typeRegistration( typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), GetInstance );
+Dali::TypeRegistration typeRegistration(typeid(Dali::TiltSensor), typeid(Dali::BaseHandle), GetInstance);
-Dali::SignalConnectorType signalConnector1( typeRegistration, SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal );
+Dali::SignalConnectorType signalConnector1(typeRegistration, SIGNAL_TILTED, Dali::Internal::Adaptor::TiltSensor::DoConnectSignal);
} // unnamed namespace
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
TiltSensorUbuntu* TiltSensorUbuntu::New()
{
return new TiltSensorUbuntu();
// Make sure sensor API is responding
bool success = Update();
- if ( success )
+ if(success)
{
- if ( !mTimer )
+ if(!mTimer)
{
- mTimer = Dali::Timer::New( 1000.0f / mFrequencyHertz );
- mTimer.TickSignal().Connect( mTimerSlot, &TiltSensorUbuntu::Update );
+ mTimer = Dali::Timer::New(1000.0f / mFrequencyHertz);
+ mTimer.TickSignal().Connect(mTimerSlot, &TiltSensorUbuntu::Update);
}
- if ( mTimer &&
- !mTimer.IsRunning() )
+ if(mTimer &&
+ !mTimer.IsRunning())
{
mTimer.Start();
}
void TiltSensorUbuntu::Stop()
{
- if ( mTimer )
+ if(mTimer)
{
mTimer.Stop();
mTimer.Reset();
bool TiltSensorUbuntu::IsStarted() const
{
- return ( mTimer && mTimer.IsRunning() );
+ return (mTimer && mTimer.IsRunning());
}
float TiltSensorUbuntu::GetRoll() const
return mTiltedSignal;
}
-void TiltSensorUbuntu::SetUpdateFrequency( float frequencyHertz )
+void TiltSensorUbuntu::SetUpdateFrequency(float frequencyHertz)
{
- DALI_ASSERT_ALWAYS( frequencyHertz > 0.0f && "Frequency must have a positive value" );
+ DALI_ASSERT_ALWAYS(frequencyHertz > 0.0f && "Frequency must have a positive value");
- if ( fabsf(mFrequencyHertz - frequencyHertz) >= GetRangedEpsilon(mFrequencyHertz, frequencyHertz) )
+ if(fabsf(mFrequencyHertz - frequencyHertz) >= GetRangedEpsilon(mFrequencyHertz, frequencyHertz))
{
mFrequencyHertz = frequencyHertz;
- if ( mTimer )
+ if(mTimer)
{
- mTimer.SetInterval( 1000.0f / mFrequencyHertz );
+ mTimer.SetInterval(1000.0f / mFrequencyHertz);
}
}
}
return mRotationThreshold;
}
-bool TiltSensorUbuntu::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool TiltSensorUbuntu::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- TiltSensor* sensor = dynamic_cast<TiltSensor*>( object );
+ bool connected(true);
+ TiltSensor* sensor = dynamic_cast<TiltSensor*>(object);
- if( sensor && ( SIGNAL_TILTED == signalName ) )
+ if(sensor && (SIGNAL_TILTED == signalName))
{
- sensor->TiltedSignal().Connect( tracker, functor );
+ sensor->TiltedSignal().Connect(tracker, functor);
}
else
{
}
TiltSensorUbuntu::TiltSensorUbuntu()
-: mFrequencyHertz( Dali::TiltSensor::DEFAULT_UPDATE_FREQUENCY ),
- mTimerSlot( this ),
- mSensorFrameworkHandle( -1 ),
- mRoll( 0.0f ),
- mPitch( 0.0f ),
- mRotation( Dali::ANGLE_0, Vector3::YAXIS ),
- mRotationThreshold( 0.0f )
+: mFrequencyHertz(Dali::TiltSensor::DEFAULT_UPDATE_FREQUENCY),
+ mTimerSlot(this),
+ mSensorFrameworkHandle(-1),
+ mRoll(0.0f),
+ mPitch(0.0f),
+ mRotation(Dali::ANGLE_0, Vector3::YAXIS),
+ mRotationThreshold(0.0f)
{
- mRollValues.resize( NUMBER_OF_SAMPLES, 0.0f );
- mPitchValues.resize( NUMBER_OF_SAMPLES, 0.0f );
+ mRollValues.resize(NUMBER_OF_SAMPLES, 0.0f);
+ mPitchValues.resize(NUMBER_OF_SAMPLES, 0.0f);
}
bool TiltSensorUbuntu::Update()
{
- float newRoll = 0.0f;
- float newPitch = 0.0f;
+ float newRoll = 0.0f;
+ float newPitch = 0.0f;
Quaternion newRotation;
Radian angle(Quaternion::AngleBetween(newRotation, mRotation));
// If the change in value is more than the threshold then emit tilted signal.
- if( angle > mRotationThreshold )
+ if(angle > mRotationThreshold)
{
- mRoll = newRoll;
- mPitch = newPitch;
+ mRoll = newRoll;
+ mPitch = newPitch;
mRotation = newRotation;
- if ( !mTiltedSignal.Empty() )
+ if(!mTiltedSignal.Empty())
{
- Dali::TiltSensor handle( this );
- mTiltedSignal.Emit( handle );
+ Dali::TiltSensor handle(this);
+ mTiltedSignal.Emit(handle);
}
}
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/devel-api/common/singleton-service.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
// INTERNAL INCLUDES
#include <dali/internal/adaptor/common/adaptor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_STYLE_MONITOR");
#endif
* @param[in] fontClient handle to font client
* @param[out] fontFamily string representing font family
*/
-void GetSystemDefaultFontFamily( TextAbstraction::FontClient& fontClient, std::string& fontFamily )
+void GetSystemDefaultFontFamily(TextAbstraction::FontClient& fontClient, std::string& fontFamily)
{
TextAbstraction::FontDescription defaultFontDescription;
- if ( fontClient )
+ if(fontClient)
{
- fontClient.GetDefaultPlatformFontDescription( defaultFontDescription );
+ fontClient.GetDefaultPlatformFontDescription(defaultFontDescription);
fontFamily = defaultFontDescription.family;
}
}
{
Dali::StyleMonitor styleMonitor;
- Dali::SingletonService service( SingletonService::Get() );
- if( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::StyleMonitor ) );
- if( handle )
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::StyleMonitor));
+ if(handle)
{
// If so, downcast the handle
- styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
+ styleMonitor = Dali::StyleMonitor(dynamic_cast<StyleMonitor*>(handle.GetObjectPtr()));
}
else
{
- styleMonitor = Dali::StyleMonitor( new StyleMonitor() );
- service.Register( typeid( styleMonitor ), styleMonitor );
+ styleMonitor = Dali::StyleMonitor(new StyleMonitor());
+ service.Register(typeid(styleMonitor), styleMonitor);
}
}
: mDefaultFontSize(-1)
{
mFontClient = TextAbstraction::FontClient::Get();
- GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() );
+ GetSystemDefaultFontFamily(mFontClient, mDefaultFontFamily);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str());
mDefaultFontSize = mFontClient.GetDefaultFontSize();
}
{
}
-void StyleMonitor::StyleChanged( StyleChange::Type styleChange )
+void StyleMonitor::StyleChanged(StyleChange::Type styleChange)
{
- switch ( styleChange )
+ switch(styleChange)
{
case StyleChange::DEFAULT_FONT_CHANGE:
{
- if ( mFontClient )
+ if(mFontClient)
{
mFontClient.ResetSystemDefaults();
- GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily );
+ GetSystemDefaultFontFamily(mFontClient, mDefaultFontFamily);
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleChanged::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "StyleMonitor::StyleChanged::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str());
break;
}
void StyleMonitor::SetTheme(const std::string& path)
{
mUserDefinedThemeFilePath = path;
- EmitStyleChangeSignal( StyleChange::THEME_CHANGE );
+ EmitStyleChangeSignal(StyleChange::THEME_CHANGE);
}
-bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output )
+bool StyleMonitor::LoadThemeFile(const std::string& filename, std::string& output)
{
- bool retval( false );
+ bool retval(false);
- std::streampos bufferSize = 0;
+ std::streampos bufferSize = 0;
Dali::Vector<char> fileBuffer;
- if( Dali::FileLoader::ReadFile( filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY ) )
+ if(Dali::FileLoader::ReadFile(filename, bufferSize, fileBuffer, FileLoader::FileType::BINARY))
{
- output.assign( &fileBuffer[0], bufferSize );
+ output.assign(&fileBuffer[0], bufferSize);
retval = true;
}
return mStyleChangeSignal;
}
-void StyleMonitor::EmitStyleChangeSignal( StyleChange::Type styleChange )
+void StyleMonitor::EmitStyleChangeSignal(StyleChange::Type styleChange)
{
- if( !mStyleChangeSignal.Empty() )
+ if(!mStyleChangeSignal.Empty())
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::EmitStyleChangeSignal\n" );
- Dali::StyleMonitor handle( this );
- mStyleChangeSignal.Emit( handle, styleChange );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "StyleMonitor::EmitStyleChangeSignal\n");
+ Dali::StyleMonitor handle(this);
+ mStyleChangeSignal.Emit(handle, styleChange);
}
}
/*
- * Copyright (c) 2019 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.
#include <dali/internal/system/android/callback-manager-android.h>
// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
+#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/framework.h>
#include <dali/internal/adaptor/android/android-framework-impl.h>
+#include <dali/internal/adaptor/common/framework.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Structure contains the callback function and control options
*/
struct CallbackData
{
-
/**
* Constructor
*/
- CallbackData( CallbackBase* callback, bool hasReturnValue )
- : mIdleId( 0 ),
- mCallback( callback ),
- mRemoveFromContainerFunction( NULL ),
- mHasReturnValue( hasReturnValue )
+ CallbackData(CallbackBase* callback, bool hasReturnValue)
+ : mIdleId(0),
+ mCallback(callback),
+ mRemoveFromContainerFunction(NULL),
+ mHasReturnValue(hasReturnValue)
{
}
/**
delete mRemoveFromContainerFunction;
}
- unsigned int mIdleId;
- CallbackBase* mCallback; ///< call back
- CallbackBase* mRemoveFromContainerFunction; ///< Called to remove the callbackdata from the callback container
- bool mHasReturnValue; ///< true if the callback function has a return value.
+ unsigned int mIdleId;
+ CallbackBase* mCallback; ///< call back
+ CallbackBase* mRemoveFromContainerFunction; ///< Called to remove the callbackdata from the callback container
+ bool mHasReturnValue; ///< true if the callback function has a return value.
};
namespace
{
-
/**
* Called from the main thread while idle.
*/
-bool IdleCallback(void *data)
+bool IdleCallback(void* data)
{
- bool ret = false;
- CallbackData *callbackData = static_cast< CallbackData * >( data );
+ bool ret = false;
+ CallbackData* callbackData = static_cast<CallbackData*>(data);
- if( callbackData->mHasReturnValue )
+ if(callbackData->mHasReturnValue)
{
// run the function
- bool retValue = CallbackBase::ExecuteReturn< bool >( *callbackData->mCallback );
- if( retValue )
+ bool retValue = CallbackBase::ExecuteReturn<bool>(*callbackData->mCallback);
+ if(retValue)
{
// keep the callback
ret = true;
else
{
// remove callback data from the container
- CallbackBase::Execute( *callbackData->mRemoveFromContainerFunction, callbackData );
+ CallbackBase::Execute(*callbackData->mRemoveFromContainerFunction, callbackData);
// delete our data
delete callbackData;
else
{
// remove callback data from the container
- CallbackBase::Execute( *callbackData->mRemoveFromContainerFunction, callbackData );
+ CallbackBase::Execute(*callbackData->mRemoveFromContainerFunction, callbackData);
// run the function
- CallbackBase::Execute( *callbackData->mCallback );
+ CallbackBase::Execute(*callbackData->mCallback);
// delete our data
delete callbackData;
} // unnamed namespace
AndroidCallbackManager::AndroidCallbackManager()
- : mRunning( false )
+: mRunning(false)
{
}
-
void AndroidCallbackManager::Start()
{
- DALI_ASSERT_DEBUG( mRunning == false );
+ DALI_ASSERT_DEBUG(mRunning == false);
mRunning = true;
}
void AndroidCallbackManager::Stop()
{
// make sure we're not called twice
- DALI_ASSERT_DEBUG( mRunning == true );
+ DALI_ASSERT_DEBUG(mRunning == true);
RemoveAllCallbacks();
mRunning = false;
-
}
-bool AndroidCallbackManager::AddIdleCallback( CallbackBase* callback, bool hasReturnValue )
+bool AndroidCallbackManager::AddIdleCallback(CallbackBase* callback, bool hasReturnValue)
{
- if( !mRunning )
+ if(!mRunning)
{
return false;
}
- CallbackData* callbackData = new CallbackData( callback, hasReturnValue );
- callbackData->mRemoveFromContainerFunction = MakeCallback( this, &AndroidCallbackManager::RemoveCallbackFromContainer );
- callbackData->mIdleId = AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).AddIdle( 0, callbackData, IdleCallback );
+ CallbackData* callbackData = new CallbackData(callback, hasReturnValue);
+ callbackData->mRemoveFromContainerFunction = MakeCallback(this, &AndroidCallbackManager::RemoveCallbackFromContainer);
+ callbackData->mIdleId = AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).AddIdle(0, callbackData, IdleCallback);
// add the call back to the container
- mCallbackContainer.push_front( callbackData );
+ mCallbackContainer.push_front(callbackData);
return true;
}
-void AndroidCallbackManager::RemoveIdleCallback( CallbackBase* callback )
+void AndroidCallbackManager::RemoveIdleCallback(CallbackBase* callback)
{
- for( CallbackList::iterator it = mCallbackContainer.begin(),
- endIt = mCallbackContainer.end();
- it != endIt;
- ++it )
+ for(CallbackList::iterator it = mCallbackContainer.begin(),
+ endIt = mCallbackContainer.end();
+ it != endIt;
+ ++it)
{
CallbackData* data = *it;
- if( data->mCallback == callback )
+ if(data->mCallback == callback)
{
// remove callback data from the container.
- CallbackBase::Execute( *data->mRemoveFromContainerFunction, data );
- AndroidFramework::GetFramework( AndroidFramework::Get() ).RemoveIdle( data->mIdleId );
+ CallbackBase::Execute(*data->mRemoveFromContainerFunction, data);
+ AndroidFramework::GetFramework(AndroidFramework::Get()).RemoveIdle(data->mIdleId);
return;
}
}
// @todo To be implemented.
}
-bool AndroidCallbackManager::AddIdleEntererCallback( CallbackBase* callback )
+bool AndroidCallbackManager::AddIdleEntererCallback(CallbackBase* callback)
{
- if( !mRunning )
+ if(!mRunning)
{
return false;
}
- CallbackData* callbackData = new CallbackData( callback, true );
+ CallbackData* callbackData = new CallbackData(callback, true);
- callbackData->mRemoveFromContainerFunction = MakeCallback( this, &AndroidCallbackManager::RemoveCallbackFromContainer );
- callbackData->mIdleId = AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).AddIdle( 0, callbackData, IdleCallback );
+ callbackData->mRemoveFromContainerFunction = MakeCallback(this, &AndroidCallbackManager::RemoveCallbackFromContainer);
+ callbackData->mIdleId = AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).AddIdle(0, callbackData, IdleCallback);
// add the call back to the container
- mCallbackContainer.push_front( callbackData );
+ mCallbackContainer.push_front(callbackData);
return true;
}
-void AndroidCallbackManager::RemoveIdleEntererCallback( CallbackBase* callback )
+void AndroidCallbackManager::RemoveIdleEntererCallback(CallbackBase* callback)
{
- for( CallbackList::iterator it = mCallbackContainer.begin(),
- endIt = mCallbackContainer.end();
- it != endIt;
- ++it )
+ for(CallbackList::iterator it = mCallbackContainer.begin(),
+ endIt = mCallbackContainer.end();
+ it != endIt;
+ ++it)
{
CallbackData* data = *it;
- if( data->mCallback == callback )
+ if(data->mCallback == callback)
{
// remove callback data from the container.
- CallbackBase::Execute( *data->mRemoveFromContainerFunction, data );
- AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).RemoveIdle( data->mIdleId );
+ CallbackBase::Execute(*data->mRemoveFromContainerFunction, data);
+ AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).RemoveIdle(data->mIdleId);
return;
}
}
}
-void AndroidCallbackManager::RemoveCallbackFromContainer( CallbackData *callbackData )
+void AndroidCallbackManager::RemoveCallbackFromContainer(CallbackData* callbackData)
{
- mCallbackContainer.remove( callbackData );
+ mCallbackContainer.remove(callbackData);
}
void AndroidCallbackManager::RemoveAllCallbacks()
{
// always called from main thread
- for( CallbackList::iterator iter = mCallbackContainer.begin(); iter != mCallbackContainer.end(); ++iter )
+ for(CallbackList::iterator iter = mCallbackContainer.begin(); iter != mCallbackContainer.end(); ++iter)
{
CallbackData* data = (*iter);
- AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).RemoveIdle( data->mIdleId );
+ AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).RemoveIdle(data->mIdleId);
delete data;
}
mCallbackContainer.clear();
} // namespace Internal
} // namespace Dali
-
-
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Using Impl to hide away Android specific members
*/
struct FileDescriptorMonitor::Impl
{
// Construction
- Impl( int fileDescriptor, CallbackBase* callback, int eventBitmask )
- : mCallback( callback ),
- mFileDescriptor( fileDescriptor ),
- mEventsToMonitor( eventBitmask )
+ Impl(int fileDescriptor, CallbackBase* callback, int eventBitmask)
+ : mCallback(callback),
+ mFileDescriptor(fileDescriptor),
+ mEventsToMonitor(eventBitmask)
{
}
// Data
CallbackBase* mCallback;
- int mFileDescriptor;
- int mEventsToMonitor;
+ int mFileDescriptor;
+ int mEventsToMonitor;
// Static Methods
/**
* Called when the file descriptor receives an event.
*/
- static int EventDispatch( int fd, int events, void* data )
+ static int EventDispatch(int fd, int events, void* data)
{
Impl* impl = reinterpret_cast<Impl*>(data);
// if we want read events, check to see if a read event is available
int type = FileDescriptorMonitor::FD_NO_EVENT;
- if( impl->mEventsToMonitor & ALOOPER_EVENT_INPUT )
+ if(impl->mEventsToMonitor & ALOOPER_EVENT_INPUT)
{
-
type = FileDescriptorMonitor::FD_READABLE;
-
}
// check if we want write events
- if( impl->mEventsToMonitor & ALOOPER_EVENT_OUTPUT )
+ if(impl->mEventsToMonitor & ALOOPER_EVENT_OUTPUT)
{
-
type |= FileDescriptorMonitor::FD_WRITABLE;
-
}
// if there is an event, execute the callback
- if( type != FileDescriptorMonitor::FD_NO_EVENT )
+ if(type != FileDescriptorMonitor::FD_NO_EVENT)
{
- CallbackBase::Execute( *impl->mCallback, static_cast< FileDescriptorMonitor::EventType >( type ), impl->mFileDescriptor );
+ CallbackBase::Execute(*impl->mCallback, static_cast<FileDescriptorMonitor::EventType>(type), impl->mFileDescriptor);
}
return 1; // Continue receiving callbacks
}
};
-FileDescriptorMonitor::FileDescriptorMonitor( int fileDescriptor, CallbackBase* callback, int eventBitmask )
+FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask)
{
mImpl = new Impl(fileDescriptor, callback, eventBitmask);
- if (fileDescriptor >= 0)
+ if(fileDescriptor >= 0)
{
int events = 0;
- if( eventBitmask & FD_READABLE)
+ if(eventBitmask & FD_READABLE)
{
events = ALOOPER_EVENT_INPUT;
}
- if( eventBitmask & FD_WRITABLE)
+ if(eventBitmask & FD_WRITABLE)
{
events |= ALOOPER_EVENT_OUTPUT;
}
mImpl->mEventsToMonitor = events;
ALooper* looper = ALooper_forThread();
- if( looper )
+ if(looper)
{
- ALooper_addFd( looper, fileDescriptor, ALOOPER_POLL_CALLBACK, events, &Impl::EventDispatch, mImpl );
+ ALooper_addFd(looper, fileDescriptor, ALOOPER_POLL_CALLBACK, events, &Impl::EventDispatch, mImpl);
}
}
}
FileDescriptorMonitor::~FileDescriptorMonitor()
{
- if( mImpl->mFileDescriptor )
+ if(mImpl->mFileDescriptor)
{
ALooper* looper = ALooper_forThread();
- if( looper )
+ if(looper)
{
- ALooper_removeFd( looper, mImpl->mFileDescriptor );
+ ALooper_removeFd(looper, mImpl->mFileDescriptor);
}
}
} // namespace Internal
} // namespace Dali
-
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace TizenPlatform
{
-
void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
{
const char* DALI_TAG = "DALI";
/*
- * Copyright (c) 2019 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.
#include <dali/internal/system/common/shared-file.h>
// EXTERNAL INCLUDES
-#include <fcntl.h>
#include <bits/ioctl.h>
+#include <fcntl.h>
#include <include/linux/ashmem.h>
#include <sys/mman.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-int SharedFile::Open( const char* filename, int size, int oflag, mode_t mode )
+int SharedFile::Open(const char* filename, int size, int oflag, mode_t mode)
{
- int fileDescriptor = open( ASHMEM_NAME_DEF, oflag );
- if( mFileDescriptor >= 0 )
+ int fileDescriptor = open(ASHMEM_NAME_DEF, oflag);
+ if(mFileDescriptor >= 0)
{
- ioctl( mFileDescriptor, ASHMEM_SET_NAME, filename );
- ioctl( mFileDescriptor, ASHMEM_SET_SIZE, size );
+ ioctl(mFileDescriptor, ASHMEM_SET_NAME, filename);
+ ioctl(mFileDescriptor, ASHMEM_SET_SIZE, size);
}
return mFileDescriptor;
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
int GetElmAccessActionOver()
{
return 0;
}
-int GetLongPressTime( int defaultTime )
+int GetLongPressTime(int defaultTime)
{
return defaultTime;
}
/*
- * Copyright (c) 2019 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.
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
// INTERNAL INCLUDES
+#include <dali/internal/adaptor/android/android-framework-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/adaptor/common/framework.h>
-#include <dali/internal/adaptor/android/android-framework-impl.h>
#include <dali/public-api/dali-adaptor-common.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
// Copied from x server
static unsigned int GetCurrentMilliSeconds()
{
struct timeval tv;
- struct timespec tp;
+ struct timespec tp;
static clockid_t clockid;
- if (!clockid)
+ if(!clockid)
{
#ifdef CLOCK_MONOTONIC_COARSE
- if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
- (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+ if(clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+ (tp.tv_nsec / 1000) <= 1000 && clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
{
clockid = CLOCK_MONOTONIC_COARSE;
}
else
#endif
- if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+ if(clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
{
clockid = CLOCK_MONOTONIC;
}
clockid = ~0L;
}
}
- if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
+ if(clockid != ~0L && clock_gettime(clockid, &tp) == 0)
{
return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
}
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
-}
+} // namespace
struct Timer::Impl
{
- Impl( unsigned int milliSec )
- : mInterval( milliSec ),
- mStartTimestamp( 0 ),
- mPauseTimestamp( 0 ),
- mRunning( false ),
- mId( 0 )
+ Impl(unsigned int milliSec)
+ : mInterval(milliSec),
+ mStartTimestamp(0),
+ mPauseTimestamp(0),
+ mRunning(false),
+ mId(0)
{
}
unsigned int mInterval;
unsigned int mStartTimestamp;
unsigned int mPauseTimestamp;
- bool mRunning;
+ bool mRunning;
unsigned int mId;
};
-TimerPtr Timer::New( unsigned int milliSec )
+TimerPtr Timer::New(unsigned int milliSec)
{
- TimerPtr timer( new Timer( milliSec ) );
+ TimerPtr timer(new Timer(milliSec));
return timer;
}
-Timer::Timer( unsigned int milliSec )
-: mImpl( new Impl( milliSec ) )
+Timer::Timer(unsigned int milliSec)
+: mImpl(new Impl(milliSec))
{
}
delete mImpl;
}
-bool TimerCallback( void *data )
+bool TimerCallback(void* data)
{
- Timer* timer = static_cast<Timer*>( data );
- if( timer->IsRunning() )
+ Timer* timer = static_cast<Timer*>(data);
+ if(timer->IsRunning())
{
return timer->Tick();
}
void Timer::Start()
{
// Timer should be used in the event thread
- DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+ DALI_ASSERT_DEBUG(Adaptor::IsAvailable());
- if( mImpl->mRunning )
+ if(mImpl->mRunning)
{
Stop();
}
- mImpl->mId = AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).AddIdle( mImpl->mInterval, this, TimerCallback );
- mImpl->mRunning = true;
+ mImpl->mId = AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).AddIdle(mImpl->mInterval, this, TimerCallback);
+ mImpl->mRunning = true;
mImpl->mStartTimestamp = GetCurrentMilliSeconds();
}
void Timer::Stop()
{
// Timer should be used in the event thread
- DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+ DALI_ASSERT_DEBUG(Adaptor::IsAvailable());
- if( mImpl->mId != 0 )
+ if(mImpl->mId != 0)
{
- AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).RemoveIdle( mImpl->mId );
+ AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).RemoveIdle(mImpl->mId);
mImpl->mStartTimestamp = 0;
mImpl->mPauseTimestamp = 0;
}
void Timer::Pause()
{
// Timer should be used in the event thread
- DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+ DALI_ASSERT_DEBUG(Adaptor::IsAvailable());
- if( mImpl->mRunning )
+ if(mImpl->mRunning)
{
mImpl->mPauseTimestamp = GetCurrentMilliSeconds();
- AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).RemoveIdle( mImpl->mId );
+ AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).RemoveIdle(mImpl->mId);
mImpl->mId = 0;
}
}
void Timer::Resume()
{
// Timer should be used in the event thread
- DALI_ASSERT_DEBUG( Adaptor::IsAvailable() );
+ DALI_ASSERT_DEBUG(Adaptor::IsAvailable());
- if( mImpl->mRunning && mImpl->mId == 0 )
+ if(mImpl->mRunning && mImpl->mId == 0)
{
unsigned int newInterval = 0;
unsigned int runningTime = mImpl->mPauseTimestamp - mImpl->mStartTimestamp;
- if( mImpl->mInterval > runningTime )
+ if(mImpl->mInterval > runningTime)
{
newInterval = mImpl->mInterval - runningTime;
}
mImpl->mStartTimestamp = GetCurrentMilliSeconds() - runningTime;
mImpl->mPauseTimestamp = 0;
- mImpl->mId = AndroidFramework::GetFramework( Dali::Integration::AndroidFramework::Get() ).AddIdle( newInterval, this, TimerCallback );
+ mImpl->mId = AndroidFramework::GetFramework(Dali::Integration::AndroidFramework::Get()).AddIdle(newInterval, this, TimerCallback);
}
}
-void Timer::SetInterval( unsigned int interval, bool restart )
+void Timer::SetInterval(unsigned int interval, bool restart)
{
// stop existing timer
Stop();
mImpl->mInterval = interval;
- if( restart )
+ if(restart)
{
// start new tick
Start();
bool Timer::Tick()
{
// Guard against destruction during signal emission
- Dali::Timer handle( this );
+ Dali::Timer handle(this);
- bool retVal( false );
+ bool retVal(false);
// Override with new signal if used
- if( !mTickSignal.Empty() )
+ if(!mTickSignal.Empty())
{
retVal = mTickSignal.Emit();
// Timer stops if return value is false
- if (retVal == false)
+ if(retVal == false)
{
Stop();
}
else
{
- retVal = true; // continue emission
+ retVal = true; // continue emission
}
}
else // no callbacks registered
void Timer::ResetTimerData()
{
mImpl->mRunning = false;
- mImpl->mId = 0;
+ mImpl->mId = 0;
}
bool Timer::IsRunning() const
/*
- * Copyright (c) 2019 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.
*/
// CLASS HEADER
-#include <dali/internal/system/android/widget-application-impl-android.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/android/widget-application-impl-android.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WidgetApplicationPtr WidgetApplicationAndroid::New(
- int* argc,
- char **argv[],
+ int* argc,
+ char** argv[],
const std::string& stylesheet)
{
- return new WidgetApplicationAndroid(argc, argv, stylesheet );
+ return new WidgetApplicationAndroid(argc, argv, stylesheet);
}
-WidgetApplicationAndroid::WidgetApplicationAndroid( int* argc, char** argv[], const std::string& stylesheet )
+WidgetApplicationAndroid::WidgetApplicationAndroid(int* argc, char** argv[], const std::string& stylesheet)
: WidgetApplication(argc, argv, stylesheet)
{
DALI_LOG_ERROR("WidgetApplication is not implemented in Android profile.\n");
WidgetApplicationAndroid::~WidgetApplicationAndroid() = default;
-void WidgetApplicationAndroid::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+void WidgetApplicationAndroid::RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction)
{
}
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
-WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet )
+WidgetApplicationPtr Create(int* argc, char** argv[], const std::string& stylesheet)
{
- return WidgetApplicationAndroid::New( argc, argv, stylesheet );
+ return WidgetApplicationAndroid::New(argc, argv, stylesheet);
}
-} // namespace Factory
+} // namespace WidgetApplicationFactory
} // namespace Adaptor
{
namespace Adaptor
{
-
AbortHandler* AbortHandler::gInstance(NULL);
-AbortHandler::AbortHandler( CallbackBase* callback )
-: mSignalMask( 0 ),
- mCallback( callback )
+AbortHandler::AbortHandler(CallbackBase* callback)
+: mSignalMask(0),
+ mCallback(callback)
{
- DALI_ASSERT_ALWAYS( gInstance == NULL && "Only one instance of abort handler allowed" );
+ DALI_ASSERT_ALWAYS(gInstance == NULL && "Only one instance of abort handler allowed");
gInstance = this;
- memset( mSignalOldHandlers, 0, sizeof(SignalHandlerFuncPtr) * (_NSIG-1));
+ memset(mSignalOldHandlers, 0, sizeof(SignalHandlerFuncPtr) * (_NSIG - 1));
}
AbortHandler::~AbortHandler()
delete mCallback;
int signum;
- for ( signum = 1; signum < _NSIG; signum++ )
+ for(signum = 1; signum < _NSIG; signum++)
{
- if ( mSignalMask & (1ULL << (signum-1) ) )
+ if(mSignalMask & (1ULL << (signum - 1)))
{
// set signals back to default handling
- signal( signum, mSignalOldHandlers[signum-1] );
+ signal(signum, mSignalOldHandlers[signum - 1]);
}
}
gInstance = NULL;
}
-bool AbortHandler::AbortOnSignal( int signum )
+bool AbortHandler::AbortOnSignal(int signum)
{
bool status = false;
- if ( signum < _NSIG )
+ if(signum < _NSIG)
{
- SignalHandlerFuncPtr signalHandlerPrevious = signal( signum, &AbortHandler::SignalHandler );
+ SignalHandlerFuncPtr signalHandlerPrevious = signal(signum, &AbortHandler::SignalHandler);
// SIG_ERR is a macro with C cast
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
- if ( SIG_ERR != signalHandlerPrevious )
+ if(SIG_ERR != signalHandlerPrevious)
{
- mSignalOldHandlers[signum-1] = signalHandlerPrevious;
- mSignalMask |= ( 1ULL << (signum-1) );
+ mSignalOldHandlers[signum - 1] = signalHandlerPrevious;
+ mSignalMask |= (1ULL << (signum - 1));
status = true;
}
}
return status;
}
-void AbortHandler::SignalHandler( int signum )
+void AbortHandler::SignalHandler(int signum)
{
- if( gInstance )
+ if(gInstance)
{
- if( gInstance->mCallback )
+ if(gInstance->mCallback)
{
- CallbackBase::Execute( *gInstance->mCallback );
+ CallbackBase::Execute(*gInstance->mCallback);
}
}
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/system/common/capture-impl.h>
// EXTERNAL INCLUDES
-#include <fstream>
-#include <string.h>
+#include <dali/integration-api/debug.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/integration-api/debug.h>
+#include <string.h>
+#include <fstream>
// INTERNAL INCLUDES
-#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/devel-api/adaptor-framework/native-image-source-devel.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
namespace
{
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
Capture::Capture()
-: mQuality( DEFAULT_QUALITY ),
+: mQuality(DEFAULT_QUALITY),
mTimer(),
mPath(),
- mNativeImageSourcePtr( NULL ),
- mFileSave( false )
+ mNativeImageSourcePtr(NULL),
+ mFileSave(false)
{
}
-Capture::Capture( Dali::CameraActor cameraActor )
-: mQuality( DEFAULT_QUALITY ),
- mCameraActor( cameraActor ),
+Capture::Capture(Dali::CameraActor cameraActor)
+: mQuality(DEFAULT_QUALITY),
+ mCameraActor(cameraActor),
mTimer(),
mPath(),
- mNativeImageSourcePtr( NULL ),
- mFileSave( false )
+ mNativeImageSourcePtr(NULL),
+ mFileSave(false)
{
}
return pWorker;
}
-CapturePtr Capture::New( Dali::CameraActor cameraActor )
+CapturePtr Capture::New(Dali::CameraActor cameraActor)
{
- CapturePtr pWorker = new Capture( cameraActor );
+ CapturePtr pWorker = new Capture(cameraActor);
return pWorker;
}
-void Capture::Start( Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor, const uint32_t quality )
+void Capture::Start(Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string& path, const Dali::Vector4& clearColor, const uint32_t quality)
{
mQuality = quality;
- Start( source, position, size, path, clearColor );
+ Start(source, position, size, path, clearColor);
}
-void Capture::Start( Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor )
+void Capture::Start(Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string& path, const Dali::Vector4& clearColor)
{
DALI_ASSERT_ALWAYS(path.size() > 4 && "Path is invalid.");
Reference();
mPath = path;
- if( mPath.size() > 0 )
+ if(mPath.size() > 0)
{
mFileSave = true;
}
DALI_ASSERT_ALWAYS(source && "Source is NULL.");
UnsetResources();
- SetupResources( position, size, clearColor, source );
+ SetupResources(position, size, clearColor, source);
}
-void Capture::SetImageQuality( uint32_t quality )
+void Capture::SetImageQuality(uint32_t quality)
{
mQuality = quality;
}
return mFinishedSignal;
}
-void Capture::CreateNativeImageSource( const Vector2& size )
+void Capture::CreateNativeImageSource(const Vector2& size)
{
Dali::Adaptor& adaptor = Dali::Adaptor::Get();
DALI_ASSERT_ALWAYS(!mNativeImageSourcePtr && "NativeImageSource is already created.");
// create the NativeImageSource object with our surface
- mNativeImageSourcePtr = Dali::NativeImageSource::New( size.width, size.height, Dali::NativeImageSource::COLOR_DEPTH_DEFAULT );
+ mNativeImageSourcePtr = Dali::NativeImageSource::New(size.width, size.height, Dali::NativeImageSource::COLOR_DEPTH_DEFAULT);
}
void Capture::DeleteNativeImageSource()
DALI_ASSERT_ALWAYS(!mFrameBuffer && "FrameBuffer is already created.");
- mNativeTexture = Dali::Texture::New( *mNativeImageSourcePtr );
+ mNativeTexture = Dali::Texture::New(*mNativeImageSourcePtr);
// Create a FrameBuffer object with depth attachments.
- mFrameBuffer = Dali::FrameBuffer::New( mNativeTexture.GetWidth(), mNativeTexture.GetHeight(), Dali::FrameBuffer::Attachment::DEPTH );
+ mFrameBuffer = Dali::FrameBuffer::New(mNativeTexture.GetWidth(), mNativeTexture.GetHeight(), Dali::FrameBuffer::Attachment::DEPTH);
// Add a color attachment to the FrameBuffer object.
- mFrameBuffer.AttachColorTexture( mNativeTexture );
+ mFrameBuffer.AttachColorTexture(mNativeTexture);
}
void Capture::DeleteFrameBuffer()
return mFrameBuffer;
}
-void Capture::SetupRenderTask( const Dali::Vector2& position, const Dali::Vector2& size, Dali::Actor source, const Dali::Vector4& clearColor )
+void Capture::SetupRenderTask(const Dali::Vector2& position, const Dali::Vector2& size, Dali::Actor source, const Dali::Vector4& clearColor)
{
DALI_ASSERT_ALWAYS(source && "Source is empty.");
- Dali::Window window = DevelWindow::Get( source );
- if( !window )
+ Dali::Window window = DevelWindow::Get(source);
+ if(!window)
{
DALI_LOG_ERROR("The source is not added on the window\n");
return;
mSource = source;
- if( !mCameraActor )
+ if(!mCameraActor)
{
- mCameraActor = Dali::CameraActor::New( size );
+ mCameraActor = Dali::CameraActor::New(size);
// Because input position and size are for 2 dimentional area,
// default z-directional position of the camera is required to be used for the new camera position.
- float cameraDefaultZPosition = mCameraActor.GetProperty<float>( Dali::Actor::Property::POSITION_Z );
- Vector2 positionTransition = position + size / 2;
- mCameraActor.SetProperty( Dali::Actor::Property::POSITION, Vector3( positionTransition.x, positionTransition.y, cameraDefaultZPosition ) );
- mCameraActor.SetProperty( Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
- mCameraActor.SetProperty( Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+ float cameraDefaultZPosition = mCameraActor.GetProperty<float>(Dali::Actor::Property::POSITION_Z);
+ Vector2 positionTransition = position + size / 2;
+ mCameraActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(positionTransition.x, positionTransition.y, cameraDefaultZPosition));
+ mCameraActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ mCameraActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
}
- window.Add( mCameraActor );
+ window.Add(mCameraActor);
DALI_ASSERT_ALWAYS(mFrameBuffer && "Framebuffer is NULL.");
DALI_ASSERT_ALWAYS(!mRenderTask && "RenderTask is already created.");
Dali::RenderTaskList taskList = window.GetRenderTaskList();
- mRenderTask = taskList.CreateTask();
- mRenderTask.SetRefreshRate( Dali::RenderTask::REFRESH_ONCE );
- mRenderTask.SetSourceActor( source );
- mRenderTask.SetCameraActor( mCameraActor );
- mRenderTask.SetScreenToFrameBufferFunction( Dali::RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
- mRenderTask.SetFrameBuffer( mFrameBuffer );
- mRenderTask.SetClearColor( clearColor );
- mRenderTask.SetClearEnabled( true );
- mRenderTask.SetProperty( Dali::RenderTask::Property::REQUIRES_SYNC, true );
- mRenderTask.FinishedSignal().Connect( this, &Capture::OnRenderFinished );
- mRenderTask.GetCameraActor().SetInvertYAxis( true );
-
- mTimer = Dali::Timer::New( TIME_OUT_DURATION );
- mTimer.TickSignal().Connect( this, &Capture::OnTimeOut );
+ mRenderTask = taskList.CreateTask();
+ mRenderTask.SetRefreshRate(Dali::RenderTask::REFRESH_ONCE);
+ mRenderTask.SetSourceActor(source);
+ mRenderTask.SetCameraActor(mCameraActor);
+ mRenderTask.SetScreenToFrameBufferFunction(Dali::RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION);
+ mRenderTask.SetFrameBuffer(mFrameBuffer);
+ mRenderTask.SetClearColor(clearColor);
+ mRenderTask.SetClearEnabled(true);
+ mRenderTask.SetProperty(Dali::RenderTask::Property::REQUIRES_SYNC, true);
+ mRenderTask.FinishedSignal().Connect(this, &Capture::OnRenderFinished);
+ mRenderTask.GetCameraActor().SetInvertYAxis(true);
+
+ mTimer = Dali::Timer::New(TIME_OUT_DURATION);
+ mTimer.TickSignal().Connect(this, &Capture::OnTimeOut);
mTimer.Start();
}
mCameraActor.Unparent();
mCameraActor.Reset();
- DALI_ASSERT_ALWAYS( mRenderTask && "RenderTask is NULL." );
+ DALI_ASSERT_ALWAYS(mRenderTask && "RenderTask is NULL.");
- Dali::Window window = DevelWindow::Get( mSource );
+ Dali::Window window = DevelWindow::Get(mSource);
Dali::RenderTaskList taskList = window.GetRenderTaskList();
- taskList.RemoveTask( mRenderTask );
+ taskList.RemoveTask(mRenderTask);
mRenderTask.Reset();
mSource.Reset();
}
return mCameraActor && mRenderTask;
}
-void Capture::SetupResources( const Dali::Vector2& position, const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source )
+void Capture::SetupResources(const Dali::Vector2& position, const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source)
{
- CreateNativeImageSource( size );
+ CreateNativeImageSource(size);
CreateFrameBuffer();
- SetupRenderTask( position, size, source, clearColor );
+ SetupRenderTask(position, size, source, clearColor);
}
void Capture::UnsetResources()
{
- if( IsRenderTaskSetup() )
+ if(IsRenderTaskSetup())
{
UnsetRenderTask();
}
- if( IsFrameBufferCreated() )
+ if(IsFrameBufferCreated())
{
DeleteFrameBuffer();
}
}
-void Capture::OnRenderFinished( Dali::RenderTask& task )
+void Capture::OnRenderFinished(Dali::RenderTask& task)
{
Dali::Capture::FinishState state = Dali::Capture::FinishState::SUCCEEDED;
mTimer.Stop();
- if( mFileSave )
+ if(mFileSave)
{
- if( !SaveFile() )
+ if(!SaveFile())
{
state = Dali::Capture::FinishState::FAILED;
- DALI_LOG_ERROR( "Fail to Capture Path[%s]", mPath.c_str() );
+ DALI_LOG_ERROR("Fail to Capture Path[%s]", mPath.c_str());
}
}
- Dali::Capture handle( this );
- mFinishedSignal.Emit( handle, state );
+ Dali::Capture handle(this);
+ mFinishedSignal.Emit(handle, state);
UnsetResources();
{
Dali::Capture::FinishState state = Dali::Capture::FinishState::FAILED;
- Dali::Capture handle( this );
- mFinishedSignal.Emit( handle, state );
+ Dali::Capture handle(this);
+ mFinishedSignal.Emit(handle, state);
UnsetResources();
{
DALI_ASSERT_ALWAYS(mNativeImageSourcePtr && "mNativeImageSourcePtr is NULL");
- return Dali::DevelNativeImageSource::EncodeToFile( *mNativeImageSourcePtr, mPath, mQuality );
+ return Dali::DevelNativeImageSource::EncodeToFile(*mNativeImageSourcePtr, mPath, mQuality);
}
-} // End of namespace Adaptor
+} // End of namespace Adaptor
-} // End of namespace Internal
+} // End of namespace Internal
-} // End of namespace Dali
+} // End of namespace Dali
/*
- * Copyright (c) 2019 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.
#include <dali/internal/system/common/color-controller-impl.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
+#include <dali/devel-api/common/singleton-service.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/common/singleton-service.h>
+#include <dlfcn.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-const char* COLOR_CONTROLLER_PLUGIN_SO( "libdali2-color-controller-plugin.so" );
+const char* COLOR_CONTROLLER_PLUGIN_SO("libdali2-color-controller-plugin.so");
}
Dali::ColorController ColorController::Get()
{
Dali::ColorController colorController;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ColorController ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::ColorController));
if(handle)
{
// If so, downcast the handle
- colorController = Dali::ColorController( dynamic_cast< ColorController* >( handle.GetObjectPtr() ) );
+ colorController = Dali::ColorController(dynamic_cast<ColorController*>(handle.GetObjectPtr()));
}
else
{
- colorController = Dali::ColorController( new ColorController( ) );
- service.Register( typeid( colorController ), colorController );
+ colorController = Dali::ColorController(new ColorController());
+ service.Register(typeid(colorController), colorController);
}
}
}
ColorController::ColorController()
-: mLibHandle( NULL ),
- mPlugin( NULL ),
- mCreateColorControllerPtr( NULL )
+: mLibHandle(NULL),
+ mPlugin(NULL),
+ mCreateColorControllerPtr(NULL)
{
Initialize();
}
ColorController::~ColorController()
{
- if( mPlugin )
+ if(mPlugin)
{
delete mPlugin;
mPlugin = NULL;
- if( mLibHandle && dlclose( mLibHandle ) )
+ if(mLibHandle && dlclose(mLibHandle))
{
- DALI_LOG_ERROR( "Error closing color controller plugin library: %s\n", dlerror() );
+ DALI_LOG_ERROR("Error closing color controller plugin library: %s\n", dlerror());
}
}
}
void ColorController::Initialize()
{
- mLibHandle = dlopen( COLOR_CONTROLLER_PLUGIN_SO, RTLD_LAZY );
+ mLibHandle = dlopen(COLOR_CONTROLLER_PLUGIN_SO, RTLD_LAZY);
char* error = dlerror();
- if( mLibHandle == NULL || error != NULL )
+ if(mLibHandle == NULL || error != NULL)
{
- DALI_LOG_ERROR( "ColorController::Initialize: dlopen error [%s]\n", error );
+ DALI_LOG_ERROR("ColorController::Initialize: dlopen error [%s]\n", error);
return;
}
// load plugin
- mCreateColorControllerPtr = reinterpret_cast< CreateColorControllerFunction >( dlsym( mLibHandle, "CreateColorControllerPlugin" ) );
+ mCreateColorControllerPtr = reinterpret_cast<CreateColorControllerFunction>(dlsym(mLibHandle, "CreateColorControllerPlugin"));
error = dlerror();
- if( mCreateColorControllerPtr == NULL || error != NULL )
+ if(mCreateColorControllerPtr == NULL || error != NULL)
{
- DALI_LOG_ERROR( "ColorController::Initialize: Cannot load symbol CreateColorControllerPlugin(): %s\n", error );
+ DALI_LOG_ERROR("ColorController::Initialize: Cannot load symbol CreateColorControllerPlugin(): %s\n", error);
return;
}
mPlugin = mCreateColorControllerPtr();
- if( !mPlugin )
+ if(!mPlugin)
{
DALI_LOG_ERROR("ColorController::Initialize: Plugin creation failed\n");
return;
}
}
-bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
+bool ColorController::RetrieveColor(const std::string& colorCode, Vector4& colorValue)
{
- if( mPlugin )
+ if(mPlugin)
{
- return mPlugin->RetrieveColor( colorCode, colorValue );
+ return mPlugin->RetrieveColor(colorCode, colorValue);
}
return false;
}
-bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
+bool ColorController::RetrieveColor(const std::string& colorCode, Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
{
- if( mPlugin )
+ if(mPlugin)
{
- return mPlugin->RetrieveColor( colorCode, textColor, textOutlineColor, textShadowColor );
+ return mPlugin->RetrieveColor(colorCode, textColor, textOutlineColor, textShadowColor);
}
return false;
}
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
struct Argument
{
- const char * const opt;
- const char * const optDescription;
+ const char* const opt;
+ const char* const optDescription;
void Print()
{
const std::ios_base::fmtflags flags = std::cout.flags();
std::cout << std::left << " --";
- std::cout.width( 18 );
+ std::cout.width(18);
std::cout << opt;
std::cout << optDescription;
std::cout << std::endl;
- std::cout.flags( flags );
+ std::cout.flags(flags);
}
};
Argument EXPECTED_ARGS[] =
-{
- { "width", "Stage Width" },
- { "height", "Stage Height" },
- { "dpi", "Emulated DPI" },
- { "help", "Help" },
- { NULL, NULL }
-};
+ {
+ {"width", "Stage Width"},
+ {"height", "Stage Height"},
+ {"dpi", "Emulated DPI"},
+ {"help", "Help"},
+ {NULL, NULL}};
enum Option
{
OPTION_HELP
};
-typedef Dali::Vector< int32_t > UnhandledContainer;
+typedef Dali::Vector<int32_t> UnhandledContainer;
void ShowHelp()
{
std::cout << "Available options:" << std::endl;
Argument* arg = EXPECTED_ARGS;
- while ( arg->opt )
+ while(arg->opt)
{
arg->Print();
++arg;
} // unnamed namespace
-CommandLineOptions::CommandLineOptions(int32_t *argc, char **argv[])
+CommandLineOptions::CommandLineOptions(int32_t* argc, char** argv[])
: stageWidth(0),
stageHeight(0)
{
// Exit gracefully if no arguments provided
- if ( !argc || !argv )
+ if(!argc || !argv)
{
return;
}
- if ( *argc > 1 )
+ if(*argc > 1)
{
// We do not want to print out errors.
- int32_t origOptErrValue( opterr );
+ int32_t origOptErrValue(opterr);
opterr = 0;
- int32_t help( 0 );
+ int32_t help(0);
- const struct option options[]=
- {
- { EXPECTED_ARGS[OPTION_STAGE_WIDTH].opt, required_argument, NULL, 'w' }, // "--width"
- { EXPECTED_ARGS[OPTION_STAGE_HEIGHT].opt, required_argument, NULL, 'h' }, // "--height"
- { EXPECTED_ARGS[OPTION_DPI].opt, required_argument, NULL, 'd' }, // "--dpi"
- { EXPECTED_ARGS[OPTION_HELP].opt, no_argument, &help, '?' }, // "--help"
- { 0, 0, 0, 0 } // end of options
- };
+ const struct option options[] =
+ {
+ {EXPECTED_ARGS[OPTION_STAGE_WIDTH].opt, required_argument, NULL, 'w'}, // "--width"
+ {EXPECTED_ARGS[OPTION_STAGE_HEIGHT].opt, required_argument, NULL, 'h'}, // "--height"
+ {EXPECTED_ARGS[OPTION_DPI].opt, required_argument, NULL, 'd'}, // "--dpi"
+ {EXPECTED_ARGS[OPTION_HELP].opt, no_argument, &help, '?'}, // "--help"
+ {0, 0, 0, 0} // end of options
+ };
- int32_t shortOption( 0 );
- int32_t optionIndex( 0 );
+ int32_t shortOption(0);
+ int32_t optionIndex(0);
const char* optString = "-w:h:d:"; // The '-' ensures that argv is NOT permuted
- bool optionProcessed( false );
+ bool optionProcessed(false);
UnhandledContainer unhandledOptions; // We store indices of options we do not handle here
do
{
- shortOption = getopt_long( *argc, *argv, optString, options, &optionIndex );
+ shortOption = getopt_long(*argc, *argv, optString, options, &optionIndex);
- switch ( shortOption )
+ switch(shortOption)
{
case 0:
{
// Check if we want help
- if ( help )
+ if(help)
{
ShowHelp();
optionProcessed = true;
case 'w':
{
- if ( optarg )
+ if(optarg)
{
- stageWidth = atoi( optarg );
+ stageWidth = atoi(optarg);
optionProcessed = true;
}
break;
case 'h':
{
- if ( optarg )
+ if(optarg)
{
- stageHeight = atoi( optarg );
+ stageHeight = atoi(optarg);
optionProcessed = true;
}
break;
case 'd':
{
- if ( optarg )
+ if(optarg)
{
- stageDPI.assign( optarg );
+ stageDPI.assign(optarg);
optionProcessed = true;
}
break;
default:
{
- unhandledOptions.PushBack( optind - 1 );
+ unhandledOptions.PushBack(optind - 1);
break;
}
}
- } while ( shortOption != -1 );
+ } while(shortOption != -1);
// Take out the options we have processed
- if ( optionProcessed )
+ if(optionProcessed)
{
- if ( unhandledOptions.Count() > 0 )
+ if(unhandledOptions.Count() > 0)
{
- int32_t index( 1 );
+ int32_t index(1);
// Overwrite the argv with the values from the unhandled indices
const UnhandledContainer::ConstIterator endIter = unhandledOptions.End();
- for ( UnhandledContainer::Iterator iter = unhandledOptions.Begin(); iter != endIter; ++iter )
+ for(UnhandledContainer::Iterator iter = unhandledOptions.Begin(); iter != endIter; ++iter)
{
- (*argv)[ index++ ] = (*argv)[ *iter ];
+ (*argv)[index++] = (*argv)[*iter];
}
*argc = unhandledOptions.Count() + 1; // +1 for the program name
}
if(stream.rdbuf()->in_avail())
{
std::string line;
- while( std::getline( stream, line ) )
+ while(std::getline(stream, line))
{
- line.erase( line.find_last_not_of( " \t\r\n" ) + 1 );
- line.erase( 0, line.find_first_not_of( " \t\r\n" ) );
- if( '#' == *( line.cbegin() ) || line == "" )
+ line.erase(line.find_last_not_of(" \t\r\n") + 1);
+ line.erase(0, line.find_first_not_of(" \t\r\n"));
+ if('#' == *(line.cbegin()) || line == "")
{
continue;
}
std::istringstream subStream(line);
- std::string name;
- std::string value;
+ std::string name;
+ std::string value;
std::getline(subStream, name, ' ');
if(!mMaxTextureSizeCached && name == DALI_ENV_MAX_TEXTURE_SIZE)
{
}
// Query from graphics and save the cache
- mShaderLanguageVersion = mGraphics->GetShaderLanguageVersion();
+ mShaderLanguageVersion = mGraphics->GetShaderLanguageVersion();
mShaderLanguageVersionCached = true;
Dali::FileStream configFile(mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT);
/*
- * 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.
#include <dali/internal/system/common/environment-options.h>
// EXTERNAL INCLUDES
-#include <cstdlib>
-#include <functional>
#include <dali/integration-api/render-controller.h>
#include <dali/public-api/math/math-utils.h>
+#include <cstdlib>
+#include <functional>
// INTERNAL INCLUDES
-#include <dali/internal/trace/common/trace-factory.h>
#include <dali/internal/system/common/environment-variables.h>
+#include <dali/internal/trace/common/trace-factory.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-const unsigned int DEFAULT_STATISTICS_LOG_FREQUENCY = 2;
-const int DEFAULT_MULTI_SAMPLING_LEVEL = -1;
-const bool DEFAULT_DEPTH_BUFFER_REQUIRED_SETTING = true;
-const bool DEFAULT_STENCIL_BUFFER_REQUIRED_SETTING = true;
-const bool DEFAULT_PARTIAL_UPDATE_REQUIRED_SETTING = true;
+const unsigned int DEFAULT_STATISTICS_LOG_FREQUENCY = 2;
+const int DEFAULT_MULTI_SAMPLING_LEVEL = -1;
+const bool DEFAULT_DEPTH_BUFFER_REQUIRED_SETTING = true;
+const bool DEFAULT_STENCIL_BUFFER_REQUIRED_SETTING = true;
+const bool DEFAULT_PARTIAL_UPDATE_REQUIRED_SETTING = true;
-unsigned int GetEnvironmentVariable( const char* variable, unsigned int defaultValue )
+unsigned int GetEnvironmentVariable(const char* variable, unsigned int defaultValue)
{
const char* variableParameter = std::getenv(variable);
return intValue;
}
-bool GetEnvironmentVariable( const char* variable, int& intValue )
+bool GetEnvironmentVariable(const char* variable, int& intValue)
{
const char* variableParameter = std::getenv(variable);
- if( !variableParameter )
+ if(!variableParameter)
{
return false;
}
return true;
}
-bool GetEnvironmentVariable( const char* variable, float& floatValue )
+bool GetEnvironmentVariable(const char* variable, float& floatValue)
{
const char* variableParameter = std::getenv(variable);
- if( !variableParameter )
+ if(!variableParameter)
{
return false;
}
void SetFromEnvironmentVariable(const char* variable, std::string& stringValue)
{
- const char * charValue = std::getenv( variable );
+ const char* charValue = std::getenv(variable);
if(charValue)
{
stringValue = charValue;
void operator()(float value)
{
- value = Clamp(value, 0.0f, 1.0f);
+ value = Clamp(value, 0.0f, 1.0f);
mMemberValue = value;
}
}
unsigned int& mMemberValue;
- const int mGreaterThanValue;
+ const int mGreaterThanValue;
};
/// Provides a functor which sets the member to 1 if if the environment variable value is not zero
struct EnableIfNonZero
{
- EnableIfNonZero(int& memberValue) : mMemberValue(memberValue) {}
+ EnableIfNonZero(int& memberValue)
+ : mMemberValue(memberValue)
+ {
+ }
void operator()(int value)
{
- mMemberValue = ( value == 0 ) ? 0 : 1;
+ mMemberValue = (value == 0) ? 0 : 1;
}
int& mMemberValue;
/// Provides a functor which sets the member to false if the environment variable value is not zero
struct DisableIfNonZero
{
- DisableIfNonZero(bool& memberValue) : mMemberValue(memberValue) {}
+ DisableIfNonZero(bool& memberValue)
+ : mMemberValue(memberValue)
+ {
+ }
void operator()(int value)
{
- if( value > 0 )
+ if(value > 0)
{
mMemberValue = false;
}
bool& mMemberValue;
};
-
} // unnamed namespace
EnvironmentOptions::EnvironmentOptions()
-: mLogFunction( NULL ),
+: mLogFunction(NULL),
mWindowName(),
mWindowClassName(),
- mNetworkControl( 0 ),
- mFpsFrequency( 0 ),
- mUpdateStatusFrequency( 0 ),
- mObjectProfilerInterval( 0 ),
- mPerformanceStatsLevel( 0 ),
- mPerformanceStatsFrequency( DEFAULT_STATISTICS_LOG_FREQUENCY ),
- mPerformanceTimeStampOutput( 0 ),
- mPanGestureLoggingLevel( 0 ),
- mWindowWidth( 0u ),
- mWindowHeight( 0u ),
- mRenderRefreshRate( 1u ),
- mMaxTextureSize( 0 ),
- mRenderToFboInterval( 0u ),
- mPanGesturePredictionMode( -1 ),
- mPanGesturePredictionAmount( -1 ), ///< only sets value in pan gesture if greater than 0
- mPanGestureMaxPredictionAmount( -1 ),
- mPanGestureMinPredictionAmount( -1 ),
- mPanGesturePredictionAmountAdjustment( -1 ),
- mPanGestureSmoothingMode( -1 ),
- mPanGestureSmoothingAmount( -1.0f ),
- mPanGestureUseActualTimes( -1 ),
- mPanGestureInterpolationTimeRange( -1 ),
- mPanGestureScalarOnlyPredictionEnabled( -1 ),
- mPanGestureTwoPointPredictionEnabled( -1 ),
- mPanGestureTwoPointInterpolatePastTime( -1 ),
- mPanGestureTwoPointVelocityBias( -1.0f ),
- mPanGestureTwoPointAccelerationBias( -1.0f ),
- mPanGestureMultitapSmoothingRange( -1 ),
- mPanMinimumDistance( -1 ),
- mPanMinimumEvents( -1 ),
- mPinchMinimumDistance( -1.0f ),
- mPinchMinimumTouchEvents( -1 ),
- mPinchMinimumTouchEventsAfterStart( -1 ),
- mRotationMinimumTouchEvents( -1 ),
- mRotationMinimumTouchEventsAfterStart( -1 ),
- mLongPressMinimumHoldingTime( -1 ),
- mGlesCallTime( 0 ),
- mMultiSamplingLevel( DEFAULT_MULTI_SAMPLING_LEVEL ),
- mThreadingMode( ThreadingMode::COMBINED_UPDATE_RENDER ),
- mGlesCallAccumulate( false ),
- mDepthBufferRequired( DEFAULT_DEPTH_BUFFER_REQUIRED_SETTING ),
- mStencilBufferRequired( DEFAULT_STENCIL_BUFFER_REQUIRED_SETTING ),
- mPartialUpdateRequired( DEFAULT_PARTIAL_UPDATE_REQUIRED_SETTING )
+ mNetworkControl(0),
+ mFpsFrequency(0),
+ mUpdateStatusFrequency(0),
+ mObjectProfilerInterval(0),
+ mPerformanceStatsLevel(0),
+ mPerformanceStatsFrequency(DEFAULT_STATISTICS_LOG_FREQUENCY),
+ mPerformanceTimeStampOutput(0),
+ mPanGestureLoggingLevel(0),
+ mWindowWidth(0u),
+ mWindowHeight(0u),
+ mRenderRefreshRate(1u),
+ mMaxTextureSize(0),
+ mRenderToFboInterval(0u),
+ mPanGesturePredictionMode(-1),
+ mPanGesturePredictionAmount(-1), ///< only sets value in pan gesture if greater than 0
+ mPanGestureMaxPredictionAmount(-1),
+ mPanGestureMinPredictionAmount(-1),
+ mPanGesturePredictionAmountAdjustment(-1),
+ mPanGestureSmoothingMode(-1),
+ mPanGestureSmoothingAmount(-1.0f),
+ mPanGestureUseActualTimes(-1),
+ mPanGestureInterpolationTimeRange(-1),
+ mPanGestureScalarOnlyPredictionEnabled(-1),
+ mPanGestureTwoPointPredictionEnabled(-1),
+ mPanGestureTwoPointInterpolatePastTime(-1),
+ mPanGestureTwoPointVelocityBias(-1.0f),
+ mPanGestureTwoPointAccelerationBias(-1.0f),
+ mPanGestureMultitapSmoothingRange(-1),
+ mPanMinimumDistance(-1),
+ mPanMinimumEvents(-1),
+ mPinchMinimumDistance(-1.0f),
+ mPinchMinimumTouchEvents(-1),
+ mPinchMinimumTouchEventsAfterStart(-1),
+ mRotationMinimumTouchEvents(-1),
+ mRotationMinimumTouchEventsAfterStart(-1),
+ mLongPressMinimumHoldingTime(-1),
+ mGlesCallTime(0),
+ mMultiSamplingLevel(DEFAULT_MULTI_SAMPLING_LEVEL),
+ mThreadingMode(ThreadingMode::COMBINED_UPDATE_RENDER),
+ mGlesCallAccumulate(false),
+ mDepthBufferRequired(DEFAULT_DEPTH_BUFFER_REQUIRED_SETTING),
+ mStencilBufferRequired(DEFAULT_STENCIL_BUFFER_REQUIRED_SETTING),
+ mPartialUpdateRequired(DEFAULT_PARTIAL_UPDATE_REQUIRED_SETTING)
{
ParseEnvironmentOptions();
}
{
}
-void EnvironmentOptions::CreateTraceManager( PerformanceInterface* performanceInterface )
+void EnvironmentOptions::CreateTraceManager(PerformanceInterface* performanceInterface)
{
- mTraceManager = TraceManagerFactory::CreateTraceFactory( performanceInterface );
+ mTraceManager = TraceManagerFactory::CreateTraceFactory(performanceInterface);
}
void EnvironmentOptions::InstallTraceFunction() const
{
- if( mTraceManager )
+ if(mTraceManager)
{
mTraceManager->Initialise();
}
}
-void EnvironmentOptions::SetLogFunction( const Dali::Integration::Log::LogFunction& logFunction )
+void EnvironmentOptions::SetLogFunction(const Dali::Integration::Log::LogFunction& logFunction)
{
mLogFunction = logFunction;
}
void EnvironmentOptions::InstallLogFunction() const
{
- Dali::Integration::Log::InstallLogFunction( mLogFunction );
+ Dali::Integration::Log::InstallLogFunction(mLogFunction);
}
void EnvironmentOptions::UnInstallLogFunction() const
bool EnvironmentOptions::PerformanceServerRequired() const
{
- return ( ( GetPerformanceStatsLoggingOptions() > 0) ||
- ( GetPerformanceTimeStampOutput() > 0 ) ||
- ( GetNetworkControlMode() > 0) );
+ return ((GetPerformanceStatsLoggingOptions() > 0) ||
+ (GetPerformanceTimeStampOutput() > 0) ||
+ (GetNetworkControlMode() > 0));
}
bool EnvironmentOptions::DepthBufferRequired() const
void EnvironmentOptions::ParseEnvironmentOptions()
{
// get logging options
- mFpsFrequency = GetEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
- mUpdateStatusFrequency = GetEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
- mObjectProfilerInterval = GetEnvironmentVariable( DALI_ENV_OBJECT_PROFILER_INTERVAL, 0 );
- mPerformanceStatsLevel = GetEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
- mPerformanceStatsFrequency = GetEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
- mPerformanceTimeStampOutput = GetEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
- mNetworkControl = GetEnvironmentVariable( DALI_ENV_NETWORK_CONTROL, 0 );
- mPanGestureLoggingLevel = GetEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
+ mFpsFrequency = GetEnvironmentVariable(DALI_ENV_FPS_TRACKING, 0);
+ mUpdateStatusFrequency = GetEnvironmentVariable(DALI_ENV_UPDATE_STATUS_INTERVAL, 0);
+ mObjectProfilerInterval = GetEnvironmentVariable(DALI_ENV_OBJECT_PROFILER_INTERVAL, 0);
+ mPerformanceStatsLevel = GetEnvironmentVariable(DALI_ENV_LOG_PERFORMANCE_STATS, 0);
+ mPerformanceStatsFrequency = GetEnvironmentVariable(DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0);
+ mPerformanceTimeStampOutput = GetEnvironmentVariable(DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0);
+ mNetworkControl = GetEnvironmentVariable(DALI_ENV_NETWORK_CONTROL, 0);
+ mPanGestureLoggingLevel = GetEnvironmentVariable(DALI_ENV_LOG_PAN_GESTURE, 0);
SetFromEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, mPanGesturePredictionMode);
SetFromEnvironmentVariable<int>(DALI_ENV_PAN_PREDICTION_AMOUNT, MinimumZero(mPanGesturePredictionAmount));
SetFromEnvironmentVariable<int>(DALI_ENV_PAN_MIN_PREDICTION_AMOUNT, MinimumZero(mPanGestureMinPredictionAmount));
SetFromEnvironmentVariable<int>(DALI_ENV_PAN_MAX_PREDICTION_AMOUNT,
- [&](int maxPredictionAmount)
- {
- if( mPanGestureMinPredictionAmount > -1 && maxPredictionAmount < mPanGestureMinPredictionAmount )
+ [&](int maxPredictionAmount) {
+ if(mPanGestureMinPredictionAmount > -1 && maxPredictionAmount < mPanGestureMinPredictionAmount)
{
// maximum amount should not be smaller than minimum amount
maxPredictionAmount = mPanGestureMinPredictionAmount;
SetFromEnvironmentVariable<int>(DALI_GLES_CALL_ACCUMULATE, [&](int glesCallAccumulate) { mGlesCallAccumulate = glesCallAccumulate != 0; });
int windowWidth(0), windowHeight(0);
- if ( GetEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
+ if(GetEnvironmentVariable(DALI_WINDOW_WIDTH, windowWidth) && GetEnvironmentVariable(DALI_WINDOW_HEIGHT, windowHeight))
{
- mWindowWidth = windowWidth;
+ mWindowWidth = windowWidth;
mWindowHeight = windowHeight;
}
- SetFromEnvironmentVariable(DALI_WINDOW_NAME, mWindowName );
+ SetFromEnvironmentVariable(DALI_WINDOW_NAME, mWindowName);
SetFromEnvironmentVariable(DALI_WINDOW_CLASS_NAME, mWindowClassName);
SetFromEnvironmentVariable<int>(DALI_THREADING_MODE,
- [&](int threadingMode)
- {
- switch( threadingMode )
+ [&](int threadingMode) {
+ switch(threadingMode)
{
case ThreadingMode::COMBINED_UPDATE_RENDER:
{
- mThreadingMode = static_cast< ThreadingMode::Type >( threadingMode );
+ mThreadingMode = static_cast<ThreadingMode::Type>(threadingMode);
break;
}
}
SetFromEnvironmentVariable<int>(DALI_ENV_MAX_TEXTURE_SIZE, GreaterThan(mMaxTextureSize, 0));
- mRenderToFboInterval = GetEnvironmentVariable( DALI_RENDER_TO_FBO, 0u );
+ mRenderToFboInterval = GetEnvironmentVariable(DALI_RENDER_TO_FBO, 0u);
SetFromEnvironmentVariable<int>(DALI_ENV_DISABLE_DEPTH_BUFFER,
- [&](int depthBufferRequired)
- {
- if( depthBufferRequired > 0 )
+ [&](int depthBufferRequired) {
+ if(depthBufferRequired > 0)
{
- mDepthBufferRequired = false;
+ mDepthBufferRequired = false;
mStencilBufferRequired = false; // Disable stencil buffer as well
}
});
SetFromEnvironmentVariable<int>(DALI_ENV_DISABLE_PARTIAL_UPDATE, DisableIfNonZero(mPartialUpdateRequired));
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#include <dali/internal/system/common/fps-tracker.h>
// EXTERNAL INCLUDES
-#include <cstdio>
-#include <cmath>
#include <sys/stat.h>
+#include <cmath>
+#include <cstdio>
// INTERNAL INCLUDES
#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-const char* DALI_TEMP_UPDATE_FPS_FILE( "/tmp/dalifps.txt" );
+const char* DALI_TEMP_UPDATE_FPS_FILE("/tmp/dalifps.txt");
} // unnamed namespace
-FpsTracker::FpsTracker( const EnvironmentOptions& environmentOptions )
-: mFpsTrackingSeconds( fabsf( environmentOptions.GetFrameRateLoggingFrequency() ) ),
- mFrameCount( 0.0f ),
- mElapsedTime( 0.0f )
+FpsTracker::FpsTracker(const EnvironmentOptions& environmentOptions)
+: mFpsTrackingSeconds(fabsf(environmentOptions.GetFrameRateLoggingFrequency())),
+ mFrameCount(0.0f),
+ mElapsedTime(0.0f)
{
}
FpsTracker::~FpsTracker()
{
- if( mFpsTrackingSeconds > 0.f )
+ if(mFpsTrackingSeconds > 0.f)
{
OutputFPSRecord();
}
}
-void FpsTracker::Track( float secondsFromLastFrame )
+void FpsTracker::Track(float secondsFromLastFrame)
{
- if( mFpsTrackingSeconds > 0.f )
+ if(mFpsTrackingSeconds > 0.f)
{
- if ( mElapsedTime < mFpsTrackingSeconds )
+ if(mElapsedTime < mFpsTrackingSeconds)
{
mElapsedTime += secondsFromLastFrame;
mFrameCount += 1.f;
else
{
OutputFPSRecord();
- mFrameCount = 0.f;
+ mFrameCount = 0.f;
mElapsedTime = 0.f;
}
}
void FpsTracker::OutputFPSRecord()
{
float fps = mFrameCount / mElapsedTime;
- DALI_LOG_FPS("Frame count %.0f, elapsed time %.1fs, FPS: %.2f\n", mFrameCount, mElapsedTime, fps );
+ DALI_LOG_FPS("Frame count %.0f, elapsed time %.1fs, FPS: %.2f\n", mFrameCount, mElapsedTime, fps);
struct stat fileStat;
// Check file path
- if( lstat( DALI_TEMP_UPDATE_FPS_FILE, &fileStat ) != 0 )
+ if(lstat(DALI_TEMP_UPDATE_FPS_FILE, &fileStat) != 0)
{
return;
}
- if( !S_ISREG( fileStat.st_mode ) )
+ if(!S_ISREG(fileStat.st_mode))
{
return;
}
// Dumps out the frame rate.
- FILE* outfile = fopen( DALI_TEMP_UPDATE_FPS_FILE, "w" );
- if( outfile )
+ FILE* outfile = fopen(DALI_TEMP_UPDATE_FPS_FILE, "w");
+ if(outfile)
{
char fpsString[10];
- snprintf(fpsString,sizeof(fpsString),"%.2f \n", fps );
- fputs( fpsString, outfile ); // ignore the error on purpose
- fclose( outfile );
+ snprintf(fpsString, sizeof(fpsString), "%.2f \n", fps);
+ fputs(fpsString, outfile); // ignore the error on purpose
+ fclose(outfile);
}
}
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
FrameTimeStamp::FrameTimeStamp()
: frame(0),
microseconds(0),
FrameTimeStamp::FrameTimeStamp(unsigned int frame,
uint64_t microseconds,
unsigned int bufferIndex)
-: frame( frame ),
- microseconds( microseconds ),
- bufferIndex( bufferIndex )
+: frame(frame),
+ microseconds(microseconds),
+ bufferIndex(bufferIndex)
{
}
-FrameTimeStamp::FrameTimeStamp( unsigned int bufferIndex )
-: frame( 0 ),
- microseconds( 0 ),
- bufferIndex( bufferIndex )
+FrameTimeStamp::FrameTimeStamp(unsigned int bufferIndex)
+: frame(0),
+ microseconds(0),
+ bufferIndex(bufferIndex)
{
}
-unsigned int FrameTimeStamp::MicrosecondDiff( const FrameTimeStamp& start,const FrameTimeStamp& end )
+unsigned int FrameTimeStamp::MicrosecondDiff(const FrameTimeStamp& start, const FrameTimeStamp& end)
{
return end.microseconds - start.microseconds;
}
} // namespace Internal
} // namespace Dali
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-const float EPSILON = 0.9f; // rolling average = (average * epsilon) + (current * epsilon)
+const float EPSILON = 0.9f; // rolling average = (average * epsilon) + (current * epsilon)
const float ONE_OVER_MICROSECONDS_TO_SECONDS = 1.f / 1000000.f; ///< microseconds per second
-}
+} // namespace
FrameTimeStats::FrameTimeStats()
-: mTotal( 0.f)
+: mTotal(0.f)
{
- mSamples.Reserve( 16 ); // Fill out a little to avoid early reallocations
+ mSamples.Reserve(16); // Fill out a little to avoid early reallocations
Reset();
}
{
}
-void FrameTimeStats::StartTime( const FrameTimeStamp& timeStamp )
+void FrameTimeStats::StartTime(const FrameTimeStamp& timeStamp)
{
// check to make sure we don't get 2 start times in a row
- if( mTimeState != WAITING_FOR_START_TIME )
+ if(mTimeState != WAITING_FOR_START_TIME)
{
Reset();
}
- mStart = timeStamp;
+ mStart = timeStamp;
mTimeState = WAITING_FOR_END_TIME;
}
-void FrameTimeStats::EndTime( const FrameTimeStamp& timeStamp )
+void FrameTimeStats::EndTime(const FrameTimeStamp& timeStamp)
{
- if( mTimeState != WAITING_FOR_END_TIME )
+ if(mTimeState != WAITING_FOR_END_TIME)
{
Reset();
return;
mRunCount++;
// frame time in seconds
- unsigned int elapsedTime = FrameTimeStamp::MicrosecondDiff( mStart, timeStamp);
+ unsigned int elapsedTime = FrameTimeStamp::MicrosecondDiff(mStart, timeStamp);
- mSamples.PushBack( elapsedTime );
+ mSamples.PushBack(elapsedTime);
// if the min and max times haven't been set, do that now.
- if( !mMinMaxTimeSet )
+ if(!mMinMaxTimeSet)
{
- mMin = elapsedTime;
- mMax = elapsedTime;
+ mMin = elapsedTime;
+ mMax = elapsedTime;
mMinMaxTimeSet = true;
}
else
{
- if (elapsedTime < mMin)
+ if(elapsedTime < mMin)
{
- mMin= elapsedTime;
+ mMin = elapsedTime;
}
- else if (elapsedTime > mMax)
+ else if(elapsedTime > mMax)
{
mMax = elapsedTime;
}
void FrameTimeStats::Reset()
{
- mTimeState = WAITING_FOR_START_TIME;
+ mTimeState = WAITING_FOR_START_TIME;
mMinMaxTimeSet = false;
- mMin = 0.f;
- mMax = 0.f;
- mRunCount = 0;
- mStart = FrameTimeStamp();
+ mMin = 0.f;
+ mMax = 0.f;
+ mRunCount = 0;
+ mStart = FrameTimeStamp();
mSamples.Clear();
}
return mRunCount;
}
-void FrameTimeStats::CalculateMean( float& meanOut, float& standardDeviationOut ) const
+void FrameTimeStats::CalculateMean(float& meanOut, float& standardDeviationOut) const
{
- if( mSamples.Size() > 0 )
+ if(mSamples.Size() > 0)
{
// Mean
unsigned int sum = 0;
- for( Samples::ConstIterator it = mSamples.Begin(), itEnd = mSamples.End(); it != itEnd; ++it )
+ for(Samples::ConstIterator it = mSamples.Begin(), itEnd = mSamples.End(); it != itEnd; ++it)
{
unsigned int value = *it;
// Variance
float variance = 0.0f;
- for( Samples::ConstIterator it = mSamples.Begin(), itEnd = mSamples.End(); it != itEnd; ++it )
+ for(Samples::ConstIterator it = mSamples.Begin(), itEnd = mSamples.End(); it != itEnd; ++it)
{
unsigned int value = *it;
variance /= mSamples.Size();
// Standard deviation
- standardDeviationOut = sqrtf( variance );
+ standardDeviationOut = sqrtf(variance);
meanOut *= ONE_OVER_MICROSECONDS_TO_SECONDS;
standardDeviationOut *= ONE_OVER_MICROSECONDS_TO_SECONDS;
}
else
{
- meanOut = 0.0f;
+ meanOut = 0.0f;
standardDeviationOut = 0.0f;
}
}
-
} // namespace Adaptor
} // namespace Internal
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
const char* TRACE_MARKER_FILE = "/sys/kernel/debug/tracing/trace_marker";
-const char* SPI_PREFIX = "SPI_EV_DALI_"; ///< prefix to let the SPI tool know it should read the trace
-}// un-named name space
+const char* SPI_PREFIX = "SPI_EV_DALI_"; ///< prefix to let the SPI tool know it should read the trace
+} // namespace
KernelTrace::KernelTrace()
-: mFileDescriptor( 0 ),
- mLoggedError( false )
+: mFileDescriptor(0),
+ mLoggedError(false)
{
}
KernelTrace::~KernelTrace()
{
- if( mFileDescriptor )
+ if(mFileDescriptor)
{
- close( mFileDescriptor );
+ close(mFileDescriptor);
}
}
// If the message did not get added to the trace, then check you have write permissions to the trace_marker file.
//
//
-void KernelTrace::Trace( const PerformanceMarker& marker, const std::string& traceMessage )
+void KernelTrace::Trace(const PerformanceMarker& marker, const std::string& traceMessage)
{
// Open the trace_marker file
- if( mFileDescriptor == 0 )
+ if(mFileDescriptor == 0)
{
- mFileDescriptor = open( TRACE_MARKER_FILE , O_WRONLY);
- if( mFileDescriptor == -1 )
+ mFileDescriptor = open(TRACE_MARKER_FILE, O_WRONLY);
+ if(mFileDescriptor == -1)
{
// we want to keep trying to open it, so it will start working if someone fixes
// the permissions on the trace marker
mFileDescriptor = 0;
// first time we fail to open the file, log an error
- if( !mLoggedError )
+ if(!mLoggedError)
{
mLoggedError = true;
DALI_LOG_ERROR("Failed to open /sys/kernel/debug/tracing/trace_marker for writing please check file permissions.\n");
}
-
}
}
- if( mFileDescriptor > 0 )
+ if(mFileDescriptor > 0)
{
- std::string msg( SPI_PREFIX );
- msg+=traceMessage;
+ std::string msg(SPI_PREFIX);
+ msg += traceMessage;
- int ret = write( mFileDescriptor, msg.c_str(), msg.length() );
- // if it failed then close the file description and try again next time we trace
- if( ret < 0 )
- {
- close( mFileDescriptor );
- mFileDescriptor = 0;
- }
+ int ret = write(mFileDescriptor, msg.c_str(), msg.length());
+ // if it failed then close the file description and try again next time we trace
+ if(ret < 0)
+ {
+ close(mFileDescriptor);
+ mFileDescriptor = 0;
+ }
}
}
-} // namespace Internal
-
} // namespace Adaptor
-} // namespace Dali
+} // namespace Internal
+} // namespace Dali
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace Locale
{
-
namespace
{
-
struct LocaleDirectionInfo
{
- const char * locale;
- const char * name;
+ const char* locale;
+ const char* name;
Locale::Direction direction;
};
+// clang-format off
const LocaleDirectionInfo LOCALE_DIRECTION_LOOKUP_TABLE[] =
{
{ "af", "Afrikaans", Locale::LEFT_TO_RIGHT },
{ NULL, NULL, Locale::LEFT_TO_RIGHT }
};
+// clang-format on
} // unnamed namespace
-Locale::Direction GetDirection( const std::string& locale )
+Locale::Direction GetDirection(const std::string& locale)
{
- Locale::Direction direction( Locale::LEFT_TO_RIGHT );
+ Locale::Direction direction(Locale::LEFT_TO_RIGHT);
- if ( !locale.empty() && locale.size() > 2 )
+ if(!locale.empty() && locale.size() > 2)
{
- for ( const LocaleDirectionInfo* iter = &LOCALE_DIRECTION_LOOKUP_TABLE[0]; iter->locale; ++iter )
+ for(const LocaleDirectionInfo* iter = &LOCALE_DIRECTION_LOOKUP_TABLE[0]; iter->locale; ++iter)
{
- if ( !locale.compare( 0, 2, iter->locale ) )
+ if(!locale.compare(0, 2, iter->locale))
{
direction = iter->direction;
break;
/*
- * Copyright (c) 20207 Samsung Electronics Co., Ltd.
+ * Copyright (c) 20217 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/internal/system/common/object-profiler.h>
// EXTERNAL INCLUDES
-#include <stdlib.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/profiling.h>
-#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/object/type-registry.h>
+#include <stdlib.h>
using std::string;
using namespace Dali::Integration::Profiling;
{
namespace Adaptor
{
-
-ObjectProfiler::ObjectProfiler( Dali::ObjectRegistry objectRegistry, uint32_t timeInterval )
-: mObjectRegistry( objectRegistry )
+ObjectProfiler::ObjectProfiler(Dali::ObjectRegistry objectRegistry, uint32_t timeInterval)
+: mObjectRegistry(objectRegistry)
{
// This class must be created after the Stage; this means it doesn't count the initial objects
// that are created by the stage (base layer, default camera actor)
- mTimer = Dali::Timer::New( timeInterval * 1000 );
- mTimer.TickSignal().Connect( this, &ObjectProfiler::OnTimeout );
+ mTimer = Dali::Timer::New(timeInterval * 1000);
+ mTimer.TickSignal().Connect(this, &ObjectProfiler::OnTimeout);
mTimer.Start();
- mObjectRegistry.ObjectCreatedSignal().Connect( this, &ObjectProfiler::OnObjectCreated );
- mObjectRegistry.ObjectDestroyedSignal().Connect( this, &ObjectProfiler::OnObjectDestroyed );
+ mObjectRegistry.ObjectCreatedSignal().Connect(this, &ObjectProfiler::OnObjectCreated);
+ mObjectRegistry.ObjectDestroyedSignal().Connect(this, &ObjectProfiler::OnObjectDestroyed);
}
ObjectProfiler::~ObjectProfiler()
void ObjectProfiler::DisplayInstanceCounts()
{
- for( auto&& element : mInstanceCountContainer )
+ for(auto&& element : mInstanceCountContainer)
{
- std::size_t memorySize = GetMemorySize( element.first, element.second );
- if( memorySize > 0 )
+ std::size_t memorySize = GetMemorySize(element.first, element.second);
+ if(memorySize > 0)
{
- LogMessage( Debug::DebugInfo, "%-30s: % 4d Memory MemorySize: ~% 6.1f kB\n",
- element.first.c_str(), element.second, memorySize / 1024.0f );
+ LogMessage(Debug::DebugInfo, "%-30s: % 4d Memory MemorySize: ~% 6.1f kB\n", element.first.c_str(), element.second, memorySize / 1024.0f);
}
else
{
- LogMessage( Debug::DebugInfo, "%-30s: % 4d\n",
- element.first.c_str(), element.second );
+ LogMessage(Debug::DebugInfo, "%-30s: % 4d\n", element.first.c_str(), element.second);
}
}
LogMessage(Debug::DebugInfo, "\n");
void ObjectProfiler::OnObjectCreated(BaseHandle handle)
{
string theType = handle.GetTypeName();
- if( theType.empty() )
+ if(theType.empty())
{
DALI_LOG_ERROR("Object created from an unregistered type\n");
theType = "<Unregistered>";
mInstanceTypes.push_back(InstanceTypePair(&handle.GetBaseObject(), theType));
bool found = false;
- for( auto&& element : mInstanceCountContainer )
+ for(auto&& element : mInstanceCountContainer)
{
- if( element.first == theType )
+ if(element.first == theType)
{
element.second++;
found = true;
}
}
- if( !found )
+ if(!found)
{
- InstanceCountPair instanceCount( theType, 1 );
- mInstanceCountContainer.emplace_back( instanceCount );
+ InstanceCountPair instanceCount(theType, 1);
+ mInstanceCountContainer.emplace_back(instanceCount);
}
}
const BaseObject* baseObject = static_cast<const BaseObject*>(object);
const auto end = mInstanceTypes.end();
- for( auto iter = mInstanceTypes.begin(); iter != end; ++iter )
+ for(auto iter = mInstanceTypes.begin(); iter != end; ++iter)
{
- if( iter->first == baseObject )
+ if(iter->first == baseObject)
{
const auto& theType = iter->second;
- if( !theType.empty() )
+ if(!theType.empty())
{
- auto&& countIter = std::find_if( mInstanceCountContainer.begin(),
- mInstanceCountContainer.end(),
- [theType] ( const InstanceCountPair& instance )
- { return instance.first == theType; } );
- if( countIter != mInstanceCountContainer.end() )
+ auto&& countIter = std::find_if(mInstanceCountContainer.begin(),
+ mInstanceCountContainer.end(),
+ [theType](const InstanceCountPair& instance) { return instance.first == theType; });
+ if(countIter != mInstanceCountContainer.end())
{
(*countIter).second--;
}
}
- mInstanceTypes.erase( iter );
+ mInstanceTypes.erase(iter);
return;
}
}
}
-std::size_t ObjectProfiler::GetMemorySize( const std::string& name, uint32_t count )
+std::size_t ObjectProfiler::GetMemorySize(const std::string& name, uint32_t count)
{
struct MemoryMemorySize
{
};
MemoryMemorySize memoryMemorySizes[] =
{
- { "Animation", ANIMATION_MEMORY_SIZE },
- { "Constraint", CONSTRAINT_MEMORY_SIZE },
- { "Actor", ACTOR_MEMORY_SIZE },
- { "Layer", LAYER_MEMORY_SIZE },
- { "CameraActor", CAMERA_ACTOR_MEMORY_SIZE },
- { "Renderer", RENDERER_MEMORY_SIZE },
- { "Geometry", GEOMETRY_MEMORY_SIZE },
- { "PropertyBuffer", PROPERTY_BUFFER_MEMORY_SIZE },
- { "TextureSet", TEXTURE_SET_MEMORY_SIZE },
- { "Sampler", SAMPLER_MEMORY_SIZE },
- { "Shader", SHADER_MEMORY_SIZE },
+ {"Animation", ANIMATION_MEMORY_SIZE},
+ {"Constraint", CONSTRAINT_MEMORY_SIZE},
+ {"Actor", ACTOR_MEMORY_SIZE},
+ {"Layer", LAYER_MEMORY_SIZE},
+ {"CameraActor", CAMERA_ACTOR_MEMORY_SIZE},
+ {"Renderer", RENDERER_MEMORY_SIZE},
+ {"Geometry", GEOMETRY_MEMORY_SIZE},
+ {"PropertyBuffer", PROPERTY_BUFFER_MEMORY_SIZE},
+ {"TextureSet", TEXTURE_SET_MEMORY_SIZE},
+ {"Sampler", SAMPLER_MEMORY_SIZE},
+ {"Shader", SHADER_MEMORY_SIZE},
};
- for( size_t i=0; i<sizeof(memoryMemorySizes)/sizeof(MemoryMemorySize); i++ )
+ for(size_t i = 0; i < sizeof(memoryMemorySizes) / sizeof(MemoryMemorySize); i++)
{
- if( memoryMemorySizes[i].name.compare(name) == 0 )
+ if(memoryMemorySizes[i].name.compare(name) == 0)
{
return count * memoryMemorySizes[i].memorySize;
}
return 0;
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
PerformanceInterface* PerformanceInterfaceFactory::CreateInterface(
- AdaptorInternalServices& adaptorServices,
- const EnvironmentOptions& environmentOptions )
+ AdaptorInternalServices& adaptorServices,
+ const EnvironmentOptions& environmentOptions)
{
- return new PerformanceServer( adaptorServices, environmentOptions );
+ return new PerformanceServer(adaptorServices, environmentOptions);
}
-
-
} // namespace Adaptor
} // namespace Internal
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
PerformanceInterface* GetPerformanceInterface()
{
- if( Adaptor::IsAvailable() )
+ if(Adaptor::IsAvailable())
{
- return Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetPerformanceInterface();
+ return Internal::Adaptor::Adaptor::GetImplementation(Adaptor::Get()).GetPerformanceInterface();
}
return NULL;
} // Anonymous namespace
-PerformanceLoggerPtr PerformanceLogger::New( const char* name )
+PerformanceLoggerPtr PerformanceLogger::New(const char* name)
{
- PerformanceLoggerPtr logger = new PerformanceLogger( name );
+ PerformanceLoggerPtr logger = new PerformanceLogger(name);
return logger;
}
-PerformanceLogger::PerformanceLogger( const char* name )
-: mContext( 0 )
+PerformanceLogger::PerformanceLogger(const char* name)
+: mContext(0)
{
PerformanceInterface* performance = GetPerformanceInterface();
- if( performance )
+ if(performance)
{
- mContext = performance->AddContext( name );
+ mContext = performance->AddContext(name);
}
}
PerformanceLogger::~PerformanceLogger()
{
PerformanceInterface* performance = GetPerformanceInterface();
- if( performance )
+ if(performance)
{
- performance->RemoveContext( mContext );
+ performance->RemoveContext(mContext);
}
}
-void PerformanceLogger::AddMarker( Dali::PerformanceLogger::Marker markerType )
+void PerformanceLogger::AddMarker(Dali::PerformanceLogger::Marker markerType)
{
PerformanceInterface* performance = GetPerformanceInterface();
- if( performance )
+ if(performance)
{
PerformanceInterface::MarkerType newMarkerType = PerformanceInterface::START;
- switch( markerType )
+ switch(markerType)
{
case Dali::PerformanceLogger::START_EVENT:
{
}
}
- performance->AddMarker( newMarkerType, mContext );
+ performance->AddMarker(newMarkerType, mContext);
}
}
-void PerformanceLogger::SetLoggingFrequency( unsigned int logFrequency)
+void PerformanceLogger::SetLoggingFrequency(unsigned int logFrequency)
{
PerformanceInterface* performance = GetPerformanceInterface();
- if( performance )
+ if(performance)
{
- performance->SetLoggingFrequency( logFrequency, mContext );
+ performance->SetLoggingFrequency(logFrequency, mContext);
}
}
-void PerformanceLogger::EnableLogging( bool enable )
+void PerformanceLogger::EnableLogging(bool enable)
{
PerformanceInterface* performance = GetPerformanceInterface();
- if( performance )
+ if(performance)
{
- performance->EnableLogging( enable, mContext );
+ performance->EnableLogging(enable, mContext);
}
}
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
struct NamePair
{
- PerformanceInterface::MarkerType type;
- const char* const name;
- PerformanceMarker::MarkerFilter group;
+ PerformanceInterface::MarkerType type;
+ const char* const name;
+ PerformanceMarker::MarkerFilter group;
PerformanceMarker::MarkerEventType eventType;
};
+// clang-format off
const NamePair MARKER_LOOKUP[] =
{
// timed event names must be postfixed with with _START and _END
// this is to allow tracers to extract the event name by removing the _START, _END strings
//
- { PerformanceInterface::VSYNC , "V_SYNC" , PerformanceMarker::V_SYNC_EVENTS, PerformanceMarker::SINGLE_EVENT },
- { PerformanceInterface::UPDATE_START , "UPDATE_START" , PerformanceMarker::UPDATE, PerformanceMarker::START_TIMED_EVENT },
- { PerformanceInterface::UPDATE_END , "UPDATE_END" , PerformanceMarker::UPDATE, PerformanceMarker::END_TIMED_EVENT },
- { PerformanceInterface::RENDER_START , "RENDER_START" , PerformanceMarker::RENDER, PerformanceMarker::START_TIMED_EVENT },
- { PerformanceInterface::RENDER_END , "RENDER_END" , PerformanceMarker::RENDER, PerformanceMarker::END_TIMED_EVENT },
- { PerformanceInterface::SWAP_START , "SWAP_START" , PerformanceMarker::SWAP_BUFFERS, PerformanceMarker::START_TIMED_EVENT },
- { PerformanceInterface::SWAP_END , "SWAP_END" , PerformanceMarker::SWAP_BUFFERS, PerformanceMarker::END_TIMED_EVENT },
- { PerformanceInterface::PROCESS_EVENTS_START, "PROCESS_EVENT_START" , PerformanceMarker::EVENT_PROCESS, PerformanceMarker::START_TIMED_EVENT },
- { PerformanceInterface::PROCESS_EVENTS_END, "PROCESS_EVENT_END" , PerformanceMarker::EVENT_PROCESS, PerformanceMarker::END_TIMED_EVENT },
- { PerformanceInterface::PAUSED , "PAUSED" , PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT },
- { PerformanceInterface::RESUME , "RESUMED" , PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT },
- { PerformanceInterface::START , "START" , PerformanceMarker::CUSTOM_EVENTS, PerformanceMarker::START_TIMED_EVENT },
- { PerformanceInterface::END , "END" , PerformanceMarker::CUSTOM_EVENTS, PerformanceMarker::END_TIMED_EVENT }
+ {PerformanceInterface::VSYNC, "V_SYNC", PerformanceMarker::V_SYNC_EVENTS, PerformanceMarker::SINGLE_EVENT },
+ {PerformanceInterface::UPDATE_START, "UPDATE_START", PerformanceMarker::UPDATE, PerformanceMarker::START_TIMED_EVENT},
+ {PerformanceInterface::UPDATE_END, "UPDATE_END", PerformanceMarker::UPDATE, PerformanceMarker::END_TIMED_EVENT },
+ {PerformanceInterface::RENDER_START, "RENDER_START", PerformanceMarker::RENDER, PerformanceMarker::START_TIMED_EVENT},
+ {PerformanceInterface::RENDER_END, "RENDER_END", PerformanceMarker::RENDER, PerformanceMarker::END_TIMED_EVENT },
+ {PerformanceInterface::SWAP_START, "SWAP_START", PerformanceMarker::SWAP_BUFFERS, PerformanceMarker::START_TIMED_EVENT},
+ {PerformanceInterface::SWAP_END, "SWAP_END", PerformanceMarker::SWAP_BUFFERS, PerformanceMarker::END_TIMED_EVENT },
+ {PerformanceInterface::PROCESS_EVENTS_START, "PROCESS_EVENT_START", PerformanceMarker::EVENT_PROCESS, PerformanceMarker::START_TIMED_EVENT},
+ {PerformanceInterface::PROCESS_EVENTS_END, "PROCESS_EVENT_END", PerformanceMarker::EVENT_PROCESS, PerformanceMarker::END_TIMED_EVENT },
+ {PerformanceInterface::PAUSED, "PAUSED", PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT },
+ {PerformanceInterface::RESUME, "RESUMED", PerformanceMarker::LIFE_CYCLE_EVENTS, PerformanceMarker::SINGLE_EVENT },
+ {PerformanceInterface::START, "START", PerformanceMarker::CUSTOM_EVENTS, PerformanceMarker::START_TIMED_EVENT},
+ {PerformanceInterface::END, "END", PerformanceMarker::CUSTOM_EVENTS, PerformanceMarker::END_TIMED_EVENT }
};
-} // un-named namespace
-
-
+// clang-format on
+} // namespace
-PerformanceMarker::PerformanceMarker( PerformanceInterface::MarkerType type )
-:mType(type)
+PerformanceMarker::PerformanceMarker(PerformanceInterface::MarkerType type)
+: mType(type)
{
}
-PerformanceMarker::PerformanceMarker( PerformanceInterface::MarkerType type, FrameTimeStamp frameInfo )
-:mType(type),
- mTimeStamp(frameInfo)
+PerformanceMarker::PerformanceMarker(PerformanceInterface::MarkerType type, FrameTimeStamp frameInfo)
+: mType(type),
+ mTimeStamp(frameInfo)
{
}
-const char* PerformanceMarker::GetName( ) const
+const char* PerformanceMarker::GetName() const
{
- return MARKER_LOOKUP[ mType ].name;
+ return MARKER_LOOKUP[mType].name;
}
PerformanceMarker::MarkerEventType PerformanceMarker::GetEventType() const
{
- return MARKER_LOOKUP[ mType ].eventType;
+ return MARKER_LOOKUP[mType].eventType;
}
PerformanceMarker::MarkerFilter PerformanceMarker::GetFilterType() const
{
- return MARKER_LOOKUP[ mType ].group;
+ return MARKER_LOOKUP[mType].group;
}
-unsigned int PerformanceMarker::MicrosecondDiff( const PerformanceMarker& start,const PerformanceMarker& end )
+unsigned int PerformanceMarker::MicrosecondDiff(const PerformanceMarker& start, const PerformanceMarker& end)
{
- return FrameTimeStamp::MicrosecondDiff( start.mTimeStamp, end.mTimeStamp );
+ return FrameTimeStamp::MicrosecondDiff(start.mTimeStamp, end.mTimeStamp);
}
-bool PerformanceMarker::IsFilterEnabled( MarkerFilter filter ) const
+bool PerformanceMarker::IsFilterEnabled(MarkerFilter filter) const
{
- return (filter & MARKER_LOOKUP[ mType ].group);
+ return (filter & MARKER_LOOKUP[mType].group);
}
-
} // namespace Adaptor
} // namespace Internal
} // namespace Dali
-
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
const unsigned int NANOSECONDS_PER_MICROSECOND = 1000u;
-const float MICROSECONDS_TO_SECOND = 1e-6;
+const float MICROSECONDS_TO_SECOND = 1e-6;
} // unnamed namespace
-PerformanceServer::PerformanceServer( AdaptorInternalServices& adaptorServices,
- const EnvironmentOptions& environmentOptions)
-: mEnvironmentOptions( environmentOptions ),
- mKernelTrace( adaptorServices.GetKernelTraceInterface() ),
- mSystemTrace( adaptorServices.GetSystemTraceInterface() ),
+PerformanceServer::PerformanceServer(AdaptorInternalServices& adaptorServices,
+ const EnvironmentOptions& environmentOptions)
+: mEnvironmentOptions(environmentOptions),
+ mKernelTrace(adaptorServices.GetKernelTraceInterface()),
+ mSystemTrace(adaptorServices.GetSystemTraceInterface()),
mLogMutex(),
#if defined(NETWORK_LOGGING_ENABLED)
- mNetworkServer( adaptorServices, environmentOptions ),
- mNetworkControlEnabled( mEnvironmentOptions.GetNetworkControlMode()),
+ mNetworkServer(adaptorServices, environmentOptions),
+ mNetworkControlEnabled(mEnvironmentOptions.GetNetworkControlMode()),
#endif
- mStatContextManager( *this ),
- mStatisticsLogBitmask( 0 ),
- mPerformanceOutputBitmask( 0 ),
- mLoggingEnabled( false ),
- mLogFunctionInstalled( false )
+ mStatContextManager(*this),
+ mStatisticsLogBitmask(0),
+ mPerformanceOutputBitmask(0),
+ mLoggingEnabled(false),
+ mLogFunctionInstalled(false)
{
- SetLogging( mEnvironmentOptions.GetPerformanceStatsLoggingOptions(),
- mEnvironmentOptions.GetPerformanceTimeStampOutput(),
- mEnvironmentOptions.GetPerformanceStatsLoggingFrequency());
+ SetLogging(mEnvironmentOptions.GetPerformanceStatsLoggingOptions(),
+ mEnvironmentOptions.GetPerformanceTimeStampOutput(),
+ mEnvironmentOptions.GetPerformanceStatsLoggingFrequency());
#if defined(NETWORK_LOGGING_ENABLED)
- if( mNetworkControlEnabled )
+ if(mNetworkControlEnabled)
{
- mLoggingEnabled = true;
+ mLoggingEnabled = true;
mNetworkServer.Start();
}
#endif
PerformanceServer::~PerformanceServer()
{
#if defined(NETWORK_LOGGING_ENABLED)
- if( mNetworkControlEnabled )
+ if(mNetworkControlEnabled)
{
mNetworkServer.Stop();
}
#endif
- if( mLogFunctionInstalled )
+ if(mLogFunctionInstalled)
{
mEnvironmentOptions.UnInstallLogFunction();
}
}
-void PerformanceServer::SetLogging( unsigned int statisticsLogOptions,
- unsigned int timeStampOutput,
- unsigned int logFrequency )
+void PerformanceServer::SetLogging(unsigned int statisticsLogOptions,
+ unsigned int timeStampOutput,
+ unsigned int logFrequency)
{
- mStatisticsLogBitmask = statisticsLogOptions;
+ mStatisticsLogBitmask = statisticsLogOptions;
mPerformanceOutputBitmask = timeStampOutput;
- mStatContextManager.SetLoggingLevel( mStatisticsLogBitmask, logFrequency);
+ mStatContextManager.SetLoggingLevel(mStatisticsLogBitmask, logFrequency);
- if( ( mStatisticsLogBitmask == 0) && ( mPerformanceOutputBitmask == 0 ))
+ if((mStatisticsLogBitmask == 0) && (mPerformanceOutputBitmask == 0))
{
mLoggingEnabled = false;
}
}
}
-void PerformanceServer::SetLoggingFrequency( unsigned int logFrequency, ContextId contextId )
+void PerformanceServer::SetLoggingFrequency(unsigned int logFrequency, ContextId contextId)
{
- mStatContextManager.SetLoggingFrequency( logFrequency, contextId );
+ mStatContextManager.SetLoggingFrequency(logFrequency, contextId);
}
-void PerformanceServer::EnableLogging( bool enable, ContextId contextId )
+void PerformanceServer::EnableLogging(bool enable, ContextId contextId)
{
- mStatContextManager.EnableLogging( enable, contextId );
+ mStatContextManager.EnableLogging(enable, contextId);
}
-PerformanceInterface::ContextId PerformanceServer::AddContext( const char* name )
+PerformanceInterface::ContextId PerformanceServer::AddContext(const char* name)
{
// for adding custom contexts
- return mStatContextManager.AddContext( name, PerformanceMarker::CUSTOM_EVENTS );
+ return mStatContextManager.AddContext(name, PerformanceMarker::CUSTOM_EVENTS);
}
-void PerformanceServer::RemoveContext( ContextId contextId )
+void PerformanceServer::RemoveContext(ContextId contextId)
{
- mStatContextManager.RemoveContext( contextId );
+ mStatContextManager.RemoveContext(contextId);
}
-void PerformanceServer::AddMarker( MarkerType markerType, ContextId contextId )
+void PerformanceServer::AddMarker(MarkerType markerType, ContextId contextId)
{
// called only for custom markers
- if( !mLoggingEnabled )
+ if(!mLoggingEnabled)
{
return;
}
// Get the time stamp
uint64_t timeStamp = 0;
- TimeService::GetNanoseconds( timeStamp );
+ TimeService::GetNanoseconds(timeStamp);
timeStamp /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
// Create a marker
- PerformanceMarker marker( markerType, FrameTimeStamp( 0, timeStamp ) );
+ PerformanceMarker marker(markerType, FrameTimeStamp(0, timeStamp));
// get the marker description for this context, e.g SIZE_NEGOTIATION_START
- const char* const description = mStatContextManager.GetMarkerDescription( markerType, contextId );
+ const char* const description = mStatContextManager.GetMarkerDescription(markerType, contextId);
// log it
- LogMarker( marker, description );
+ LogMarker(marker, description);
// Add custom marker to statistics context manager
- mStatContextManager.AddCustomMarker( marker, contextId );
+ mStatContextManager.AddCustomMarker(marker, contextId);
}
-void PerformanceServer::AddMarker( MarkerType markerType )
+void PerformanceServer::AddMarker(MarkerType markerType)
{
// called only for internal markers
- if( !mLoggingEnabled )
+ if(!mLoggingEnabled)
{
return;
}
- if( markerType == VSYNC )
+ if(markerType == VSYNC)
{
// make sure log function is installed, note this will be called only from v-sync thread
// if the v-sync thread has already installed one, it won't make any difference.
- if( ! mLogFunctionInstalled )
+ if(!mLogFunctionInstalled)
{
mEnvironmentOptions.InstallLogFunction();
mLogFunctionInstalled = true;
// Get the time
uint64_t timeStamp = 0;
- TimeService::GetNanoseconds( timeStamp );
+ TimeService::GetNanoseconds(timeStamp);
timeStamp /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
// Create a marker
- PerformanceMarker marker( markerType, FrameTimeStamp( 0, timeStamp ) );
+ PerformanceMarker marker(markerType, FrameTimeStamp(0, timeStamp));
// log it
- LogMarker(marker, marker.GetName() );
+ LogMarker(marker, marker.GetName());
// Add internal marker to statistics context manager
- mStatContextManager.AddInternalMarker( marker );
-
+ mStatContextManager.AddInternalMarker(marker);
}
-void PerformanceServer::LogContextStatistics( const char* const text )
+void PerformanceServer::LogContextStatistics(const char* const text)
{
- Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, text );
+ Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, text);
}
-void PerformanceServer::LogMarker( const PerformanceMarker& marker, const char* const description )
+void PerformanceServer::LogMarker(const PerformanceMarker& marker, const char* const description)
{
#if defined(NETWORK_LOGGING_ENABLED)
// log to the network ( this is thread safe )
- if( mNetworkControlEnabled )
+ if(mNetworkControlEnabled)
{
- mNetworkServer.TransmitMarker( marker, description );
+ mNetworkServer.TransmitMarker(marker, description);
}
#endif
// log to kernel trace
- if( mPerformanceOutputBitmask & OUTPUT_KERNEL_TRACE )
+ if(mPerformanceOutputBitmask & OUTPUT_KERNEL_TRACE)
{
// Kernel tracing implementation may not be thread safe
- Mutex::ScopedLock lock( mLogMutex );
+ Mutex::ScopedLock lock(mLogMutex);
// description will be something like UPDATE_START or UPDATE_END
- mKernelTrace.Trace( marker, description );
+ mKernelTrace.Trace(marker, description);
}
// log to system trace
- if( mPerformanceOutputBitmask & OUTPUT_SYSTEM_TRACE )
+ if(mPerformanceOutputBitmask & OUTPUT_SYSTEM_TRACE)
{
// System tracing implementation may not be thread safe
- Mutex::ScopedLock lock( mLogMutex );
+ Mutex::ScopedLock lock(mLogMutex);
- mSystemTrace.Trace( marker, description );
+ mSystemTrace.Trace(marker, description);
}
// log to Dali log ( this is thread safe )
- if ( mPerformanceOutputBitmask & OUTPUT_DALI_LOG )
+ if(mPerformanceOutputBitmask & OUTPUT_DALI_LOG)
{
- Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo,
- "%.6f (seconds), %s\n",
- float( marker.GetTimeStamp().microseconds ) * MICROSECONDS_TO_SECOND,
- description );
-
+ Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo,
+ "%.6f (seconds), %s\n",
+ float(marker.GetTimeStamp().microseconds) * MICROSECONDS_TO_SECOND,
+ description);
}
}
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#include <dali/internal/system/common/shared-file.h>
// EXTERNAL INCLUDES
-#include <sys/types.h>
-#include <unistd.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <sys/file.h>
#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <cstring>
-
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-
SharedFile* SharedFile::New(const char* filename, int size, bool isSystem)
{
- SharedFile *sf = NULL;
+ SharedFile* sf = NULL;
sf = new SharedFile;
- bool opened = sf->OpenFile( filename, size, isSystem );
- if( !opened )
+ bool opened = sf->OpenFile(filename, size, isSystem);
+ if(!opened)
{
delete sf;
sf = NULL;
void SharedFile::Close()
{
- if( mAddress != NULL )
+ if(mAddress != NULL)
{
- munmap( mAddress, mSize );
+ munmap(mAddress, mSize);
mAddress = NULL;
}
- if( mFileDescriptor >= 0 )
+ if(mFileDescriptor >= 0)
{
- close( mFileDescriptor );
+ close(mFileDescriptor);
mFileDescriptor = -1;
}
}
unsigned char* SharedFile::GetAddress()
{
- return static_cast<unsigned char *>( mAddress );
+ return static_cast<unsigned char*>(mAddress);
}
bool SharedFile::OpenFile(const char* filename, int size, bool isSystem)
mode_t mode;
mode = S_IRUSR | S_IWUSR;
- if( isSystem )
+ if(isSystem)
{
mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
}
- mFileDescriptor = Open( filename, size, O_RDONLY, mode );
+ mFileDescriptor = Open(filename, size, O_RDONLY, mode);
- if( mFileDescriptor >= 0 )
+ if(mFileDescriptor >= 0)
{
mFilename = filename;
- mSize = size;
- mAddress = mmap( NULL, mSize, PROT_READ, MAP_SHARED, mFileDescriptor, 0 );
+ mSize = size;
+ mAddress = mmap(NULL, mSize, PROT_READ, MAP_SHARED, mFileDescriptor, 0);
// MAP_FAILED is a macro with C cast
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
- if( mAddress != MAP_FAILED )
+ if(mAddress != MAP_FAILED)
{
opened = true;
}
return opened;
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#include <dali/internal/system/common/sound-player-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/public-api/object/type-registry.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-
const char* const SIGNAL_SOUND_PLAY_FINISHED = "soundPlayFinished";
// Type Registration
return SoundPlayer::Get();
}
-Dali::TypeRegistration SOUND_PLAYER_TYPE( typeid(Dali::SoundPlayer), typeid(Dali::BaseHandle), GetInstance );
+Dali::TypeRegistration SOUND_PLAYER_TYPE(typeid(Dali::SoundPlayer), typeid(Dali::BaseHandle), GetInstance);
-Dali::SignalConnectorType SIGNAL_CONNECTOR_1( SOUND_PLAYER_TYPE, SIGNAL_SOUND_PLAY_FINISHED, Dali::Internal::Adaptor::SoundPlayer::DoConnectSignal );
+Dali::SignalConnectorType SIGNAL_CONNECTOR_1(SOUND_PLAYER_TYPE, SIGNAL_SOUND_PLAY_FINISHED, Dali::Internal::Adaptor::SoundPlayer::DoConnectSignal);
} // unnamed namespace
Dali::SoundPlayer SoundPlayer::New()
{
- Dali::SoundPlayer player = Dali::SoundPlayer( new SoundPlayer() );
+ Dali::SoundPlayer player = Dali::SoundPlayer(new SoundPlayer());
return player;
}
{
Dali::SoundPlayer player;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::SoundPlayer ) );
- if ( handle )
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::SoundPlayer));
+ if(handle)
{
// If so, downcast the handle
- player = Dali::SoundPlayer( dynamic_cast< SoundPlayer* >( handle.GetObjectPtr() ) );
+ player = Dali::SoundPlayer(dynamic_cast<SoundPlayer*>(handle.GetObjectPtr()));
}
else
{
- player = Dali::SoundPlayer( New() );
- service.Register( typeid( player ), player );
+ player = Dali::SoundPlayer(New());
+ service.Register(typeid(player), player);
}
}
return player;
}
-int SoundPlayer::PlaySound( const std::string fileName )
+int SoundPlayer::PlaySound(const std::string fileName)
{
- return mPlugin.PlaySound( fileName );
+ return mPlugin.PlaySound(fileName);
}
-void SoundPlayer::Stop( int handle )
+void SoundPlayer::Stop(int handle)
{
- mPlugin.StopSound( handle );
+ mPlugin.StopSound(handle);
}
SoundPlayer::SoundPlayFinishedSignalType& SoundPlayer::SoundPlayFinishedSignal()
return mSoundPlayFinishedSignal;
}
-bool SoundPlayer::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool SoundPlayer::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
{
- bool connected( true );
- SoundPlayer* player = dynamic_cast<SoundPlayer*>( object );
+ bool connected(true);
+ SoundPlayer* player = dynamic_cast<SoundPlayer*>(object);
- if( player && ( SIGNAL_SOUND_PLAY_FINISHED == signalName ) )
+ if(player && (SIGNAL_SOUND_PLAY_FINISHED == signalName))
{
- player->SoundPlayFinishedSignal().Connect( tracker, functor );
+ player->SoundPlayFinishedSignal().Connect(tracker, functor);
}
else
{
}
SoundPlayer::SoundPlayer()
-: mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
+: mPlugin(FeedbackPluginProxy::DEFAULT_OBJECT_NAME)
{
}
{
// Emit SoundPlayFinished signal
- if ( !mSoundPlayFinishedSignal.Empty() )
+ if(!mSoundPlayFinishedSignal.Empty())
{
- Dali::SoundPlayer handle( this );
- mSoundPlayFinishedSignal.Emit( handle );
+ Dali::SoundPlayer handle(this);
+ mSoundPlayFinishedSignal.Emit(handle);
}
}
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-const char* const UPDATE_CONTEXT_NAME = "Update";
-const char* const RENDER_CONTEXT_NAME = "Render";
-const char* const EVENT_CONTEXT_NAME = "Event";
+const char* const UPDATE_CONTEXT_NAME = "Update";
+const char* const RENDER_CONTEXT_NAME = "Render";
+const char* const EVENT_CONTEXT_NAME = "Event";
const unsigned int DEFAULT_LOG_FREQUENCY = 2;
-}
+} // namespace
-StatContextManager::StatContextManager( StatContextLogInterface& logInterface )
-: mLogInterface( logInterface ),
- mNextContextId( 0 ),
+StatContextManager::StatContextManager(StatContextLogInterface& logInterface)
+: mLogInterface(logInterface),
+ mNextContextId(0),
mStatisticsLogBitmask(0),
- mLogFrequency( DEFAULT_LOG_FREQUENCY )
+ mLogFrequency(DEFAULT_LOG_FREQUENCY)
{
-
mStatContexts.Reserve(4); // intially reserve enough for 3 internal + 1 custom
// Add defaults
- mUpdateStats = AddContext( UPDATE_CONTEXT_NAME, PerformanceMarker::UPDATE );
- mRenderStats = AddContext( RENDER_CONTEXT_NAME, PerformanceMarker::RENDER );
- mEventStats = AddContext( EVENT_CONTEXT_NAME, PerformanceMarker::EVENT_PROCESS );
-
+ mUpdateStats = AddContext(UPDATE_CONTEXT_NAME, PerformanceMarker::UPDATE);
+ mRenderStats = AddContext(RENDER_CONTEXT_NAME, PerformanceMarker::RENDER);
+ mEventStats = AddContext(EVENT_CONTEXT_NAME, PerformanceMarker::EVENT_PROCESS);
}
StatContextManager::~StatContextManager()
{
- for( StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it )
+ for(StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it)
{
StatContext* context = *it;
delete context;
}
mStatContexts.Clear();
}
-PerformanceInterface::ContextId StatContextManager::AddContext( const char* const name,
- PerformanceMarker::MarkerFilter type )
+PerformanceInterface::ContextId StatContextManager::AddContext(const char* const name,
+ PerformanceMarker::MarkerFilter type)
{
unsigned int contextId = mNextContextId++;
- DALI_ASSERT_DEBUG( NULL == GetContext( contextId ) );
+ DALI_ASSERT_DEBUG(NULL == GetContext(contextId));
// logging enabled by default
- StatContext* statContext = new StatContext( contextId, name, type, mLogFrequency , mLogInterface );
+ StatContext* statContext = new StatContext(contextId, name, type, mLogFrequency, mLogInterface);
// check to see if custom markers are enabled
- if( ! ( mStatisticsLogBitmask & PerformanceInterface::LOG_CUSTOM_MARKERS ) )
+ if(!(mStatisticsLogBitmask & PerformanceInterface::LOG_CUSTOM_MARKERS))
{
- statContext->EnableLogging( false );
+ statContext->EnableLogging(false);
}
- mStatContexts.PushBack( statContext );
+ mStatContexts.PushBack(statContext);
return contextId;
}
-void StatContextManager::AddInternalMarker( const PerformanceMarker& marker )
+void StatContextManager::AddInternalMarker(const PerformanceMarker& marker)
{
// log to the stat contexts, can be called from multiple threads so we
// protect the data
- Mutex::ScopedLock lock( mDataMutex );
- for( StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it )
+ Mutex::ScopedLock lock(mDataMutex);
+ for(StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it)
{
StatContext* context = *it;
- context->ProcessInternalMarker( marker );
+ context->ProcessInternalMarker(marker);
}
}
-void StatContextManager::AddCustomMarker( const PerformanceMarker& marker, PerformanceInterface::ContextId contextId )
+void StatContextManager::AddCustomMarker(const PerformanceMarker& marker, PerformanceInterface::ContextId contextId)
{
// log to the stat contexts, can be called from multiple threads so we
// protect the data
- Mutex::ScopedLock lock( mDataMutex );
- StatContext* context = GetContext( contextId );
- if( context )
+ Mutex::ScopedLock lock(mDataMutex);
+ StatContext* context = GetContext(contextId);
+ if(context)
{
- context->ProcessCustomMarker( marker );
+ context->ProcessCustomMarker(marker);
}
}
-void StatContextManager::RemoveContext(PerformanceInterface::ContextId contextId )
+void StatContextManager::RemoveContext(PerformanceInterface::ContextId contextId)
{
- for( StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it )
+ for(StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it)
{
StatContext* context = *it;
- if( context->GetId() == contextId )
+ if(context->GetId() == contextId)
{
delete context;
- mStatContexts.Erase( it );
+ mStatContexts.Erase(it);
return;
}
}
}
-
-void StatContextManager::EnableLogging( bool enable, PerformanceInterface::ContextId contextId )
+void StatContextManager::EnableLogging(bool enable, PerformanceInterface::ContextId contextId)
{
- StatContext* context = GetContext( contextId );
- if( context )
+ StatContext* context = GetContext(contextId);
+ if(context)
{
- context->EnableLogging( enable );
+ context->EnableLogging(enable);
}
}
-void StatContextManager::SetLoggingLevel( unsigned int statisticsLogOptions, unsigned int logFrequency)
+void StatContextManager::SetLoggingLevel(unsigned int statisticsLogOptions, unsigned int logFrequency)
{
mStatisticsLogBitmask = statisticsLogOptions;
- if( mStatisticsLogBitmask == PerformanceInterface::LOG_EVERYTHING )
+ if(mStatisticsLogBitmask == PerformanceInterface::LOG_EVERYTHING)
{
mStatisticsLogBitmask = 0xFFFFFFFF; // enable everything
}
// currently uses DALI_LOG_PERFORMANCE_STATS_FREQ environment variable to determine to log frequency
// if it's not set it will be zero
- if( mLogFrequency == 0 )
+ if(mLogFrequency == 0)
{
mLogFrequency = DEFAULT_LOG_FREQUENCY;
}
- EnableLogging( mStatisticsLogBitmask & PerformanceInterface::LOG_UPDATE_RENDER, mUpdateStats );
- EnableLogging( mStatisticsLogBitmask & PerformanceInterface::LOG_UPDATE_RENDER, mRenderStats );
- EnableLogging( mStatisticsLogBitmask & PerformanceInterface::LOG_EVENT_PROCESS, mEventStats );
+ EnableLogging(mStatisticsLogBitmask & PerformanceInterface::LOG_UPDATE_RENDER, mUpdateStats);
+ EnableLogging(mStatisticsLogBitmask & PerformanceInterface::LOG_UPDATE_RENDER, mRenderStats);
+ EnableLogging(mStatisticsLogBitmask & PerformanceInterface::LOG_EVENT_PROCESS, mEventStats);
- for( StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it )
+ for(StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it)
{
- StatContext* context = *it;
- context->SetLogFrequency( mLogFrequency );
+ StatContext* context = *it;
+ context->SetLogFrequency(mLogFrequency);
}
}
-void StatContextManager::SetLoggingFrequency( unsigned int logFrequency,
- PerformanceInterface::ContextId contextId )
+void StatContextManager::SetLoggingFrequency(unsigned int logFrequency,
+ PerformanceInterface::ContextId contextId)
{
- StatContext* context = GetContext( contextId );
- if( context )
+ StatContext* context = GetContext(contextId);
+ if(context)
{
- if( logFrequency == 0 )
+ if(logFrequency == 0)
{
logFrequency = DEFAULT_LOG_FREQUENCY;
}
- context->SetLogFrequency( logFrequency );
+ context->SetLogFrequency(logFrequency);
}
}
const char* StatContextManager::GetContextName(PerformanceInterface::ContextId contextId) const
{
StatContext* context = GetContext(contextId);
- if( context )
+ if(context)
{
return context->GetName();
}
return "context not found";
}
-const char* StatContextManager::GetMarkerDescription( PerformanceInterface::MarkerType type, PerformanceInterface::ContextId contextId ) const
+const char* StatContextManager::GetMarkerDescription(PerformanceInterface::MarkerType type, PerformanceInterface::ContextId contextId) const
{
StatContext* context = GetContext(contextId);
- if( context )
+ if(context)
{
- return context->GetMarkerDescription( type );
+ return context->GetMarkerDescription(type);
}
return "context not found";
}
-
-StatContext* StatContextManager::GetContext( PerformanceInterface::ContextId contextId ) const
+StatContext* StatContextManager::GetContext(PerformanceInterface::ContextId contextId) const
{
- for( StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it )
+ for(StatContexts::Iterator it = mStatContexts.Begin(), itEnd = mStatContexts.End(); it != itEnd; ++it)
{
StatContext* context = *it;
- if( context->GetId() == contextId )
+ if(context->GetId() == contextId)
{
return context;
}
return NULL;
}
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
-
-
*
*/
-
// CLASS HEADER
#include <dali/internal/system/common/stat-context.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
#define TIME_FMT "%0.2f ms" // 2 decimal places, e.g. 5.34 ms
#define TOTAL_TIME_FMT "%0.1f secs" // 1 decimal place, e.g. 4.5 seconds
namespace
{
-const unsigned int MILLISECONDS_PER_SECOND = 1000; ///< 1000 milliseconds per second
-const char* const UNKNOWN_CONTEXT_NAME = "UNKNOWN_CONTEXT_NAME";
+const unsigned int MILLISECONDS_PER_SECOND = 1000; ///< 1000 milliseconds per second
+const char* const UNKNOWN_CONTEXT_NAME = "UNKNOWN_CONTEXT_NAME";
const unsigned int MICROSECONDS_PER_SECOND = 1000000; ///< 1000000 microseconds per second
-const unsigned int CONTEXT_LOG_SIZE = 120;
+const unsigned int CONTEXT_LOG_SIZE = 120;
-}
+} // namespace
-StatContext::StatContext( unsigned int id,
- const char* const contextName,
- PerformanceMarker::MarkerFilter contextType,
- unsigned int logFrequencySeconds,
- StatContextLogInterface& logInterface )
+StatContext::StatContext(unsigned int id,
+ const char* const contextName,
+ PerformanceMarker::MarkerFilter contextType,
+ unsigned int logFrequencySeconds,
+ StatContextLogInterface& logInterface)
: mInitialMarker(PerformanceInterface::VSYNC),
- mName( contextName ),
- mLogInterface( logInterface ),
- mNamePlusStart( std::string(contextName) + "_START" ),
- mNamePlusEnd( std::string(contextName) + "_END" ),
- mId( id ),
- mLogFrequencyMicroseconds( logFrequencySeconds * MICROSECONDS_PER_SECOND ),
- mFilterType( contextType ),
- mLoggingEnabled( true ),
- mInitialMarkerSet( false )
-{
- mTempLogBuffer = new char[ CONTEXT_LOG_SIZE ];
+ mName(contextName),
+ mLogInterface(logInterface),
+ mNamePlusStart(std::string(contextName) + "_START"),
+ mNamePlusEnd(std::string(contextName) + "_END"),
+ mId(id),
+ mLogFrequencyMicroseconds(logFrequencySeconds * MICROSECONDS_PER_SECOND),
+ mFilterType(contextType),
+ mLoggingEnabled(true),
+ mInitialMarkerSet(false)
+{
+ mTempLogBuffer = new char[CONTEXT_LOG_SIZE];
}
StatContext::~StatContext()
{
- delete []mTempLogBuffer;
+ delete[] mTempLogBuffer;
}
unsigned int StatContext::GetId() const
{
return mName;
}
-const char* StatContext::GetMarkerDescription( PerformanceInterface::MarkerType type ) const
+const char* StatContext::GetMarkerDescription(PerformanceInterface::MarkerType type) const
{
- if( type == PerformanceInterface::START )
+ if(type == PerformanceInterface::START)
{
return mNamePlusStart.c_str();
}
- else if( type == PerformanceInterface::END )
+ else if(type == PerformanceInterface::END)
{
return mNamePlusEnd.c_str();
}
return UNKNOWN_CONTEXT_NAME;
}
-void StatContext::SetLogFrequency( unsigned int logFrequencySeconds )
+void StatContext::SetLogFrequency(unsigned int logFrequencySeconds)
{
mLogFrequencyMicroseconds = logFrequencySeconds * MICROSECONDS_PER_SECOND;
}
-void StatContext::EnableLogging( bool enableLogging )
+void StatContext::EnableLogging(bool enableLogging)
{
mLoggingEnabled = enableLogging;
}
-void StatContext::ProcessCustomMarker( const PerformanceMarker& marker )
+void StatContext::ProcessCustomMarker(const PerformanceMarker& marker)
{
// this marker has come from the application PerformanceLogger API
- RecordMarker( marker);
+ RecordMarker(marker);
}
-void StatContext::ProcessInternalMarker( const PerformanceMarker& marker )
+void StatContext::ProcessInternalMarker(const PerformanceMarker& marker)
{
// this marker has come from DALi internal not the application
// see if this context is for update, render or event
- if( marker.IsFilterEnabled( mFilterType ))
- {
- RecordMarker( marker );
- }
- // V_SYNC is always processed
- if( marker.GetType() == PerformanceInterface::VSYNC )
- {
- FrameTick( marker );
- }
+ if(marker.IsFilterEnabled(mFilterType))
+ {
+ RecordMarker(marker);
+ }
+ // V_SYNC is always processed
+ if(marker.GetType() == PerformanceInterface::VSYNC)
+ {
+ FrameTick(marker);
+ }
}
-void StatContext::RecordMarker( const PerformanceMarker& marker )
+void StatContext::RecordMarker(const PerformanceMarker& marker)
{
- if( marker.GetEventType() == PerformanceMarker::START_TIMED_EVENT )
+ if(marker.GetEventType() == PerformanceMarker::START_TIMED_EVENT)
{
- mStats.StartTime( marker.GetTimeStamp() );
+ mStats.StartTime(marker.GetTimeStamp());
}
- else if( marker.GetEventType() == PerformanceMarker::END_TIMED_EVENT )
+ else if(marker.GetEventType() == PerformanceMarker::END_TIMED_EVENT)
{
- mStats.EndTime( marker.GetTimeStamp() );
+ mStats.EndTime(marker.GetTimeStamp());
}
}
-void StatContext::FrameTick( const PerformanceMarker& marker )
+void StatContext::FrameTick(const PerformanceMarker& marker)
{
// wait until we've got some data
- if( ! mInitialMarkerSet )
+ if(!mInitialMarkerSet)
{
- mInitialMarker = marker;
+ mInitialMarker = marker;
mInitialMarkerSet = true;
return;
}
// log out every mLogFrequency.
// check difference between first and last frame
- unsigned int microseconds = PerformanceMarker::MicrosecondDiff( mInitialMarker, marker );
+ unsigned int microseconds = PerformanceMarker::MicrosecondDiff(mInitialMarker, marker);
- if( microseconds < mLogFrequencyMicroseconds )
+ if(microseconds < mLogFrequencyMicroseconds)
{
return;
}
- if( mLoggingEnabled )
+ if(mLoggingEnabled)
{
LogMarker();
}
- mStats.Reset(); // reset data for statistics
- mInitialMarkerSet = false; // need to restart the timer
-
+ mStats.Reset(); // reset data for statistics
+ mInitialMarkerSet = false; // need to restart the timer
}
void StatContext::LogMarker()
{
float mean, standardDeviation;
- mStats.CalculateMean( mean, standardDeviation );
-
- snprintf( mTempLogBuffer, CONTEXT_LOG_SIZE, "%s, min " TIME_FMT ", max " TIME_FMT ", total (" TOTAL_TIME_FMT "), avg " TIME_FMT ", std dev " TIME_FMT "\n",
- mName ? mName : UNKNOWN_CONTEXT_NAME,
- mStats.GetMinTime() * MILLISECONDS_PER_SECOND,
- mStats.GetMaxTime() * MILLISECONDS_PER_SECOND,
- mStats.GetTotalTime(),
- mean * MILLISECONDS_PER_SECOND,
- standardDeviation * MILLISECONDS_PER_SECOND );
-
- mLogInterface.LogContextStatistics( mTempLogBuffer );
-
+ mStats.CalculateMean(mean, standardDeviation);
+
+ snprintf(mTempLogBuffer,
+ CONTEXT_LOG_SIZE,
+ "%s, min " TIME_FMT ", max " TIME_FMT ", total (" TOTAL_TIME_FMT "), avg " TIME_FMT ", std dev " TIME_FMT "\n",
+ mName ? mName : UNKNOWN_CONTEXT_NAME,
+ mStats.GetMinTime() * MILLISECONDS_PER_SECOND,
+ mStats.GetMaxTime() * MILLISECONDS_PER_SECOND,
+ mStats.GetTotalTime(),
+ mean * MILLISECONDS_PER_SECOND,
+ standardDeviation * MILLISECONDS_PER_SECOND);
+
+ mLogInterface.LogContextStatistics(mTempLogBuffer);
}
-
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#include <dali/internal/system/common/system-trace.h>
// EXTERNAL HEADERS
-#include <string>
#include <dali/devel-api/common/hash.h>
+#include <string>
// INTERNAL HEADERS
#include <dali/integration-api/debug.h>
{
const int TTRACE_TAG_GRAPHICS = 1;
-void traceAsyncBegin(int tag, int cookie, const char *name, ...)
+void traceAsyncBegin(int tag, int cookie, const char* name, ...)
{
- Debug::LogMessage(Debug::DebugInfo, "AsyncBegin: %s : cookie %d\n", name, cookie );
+ Debug::LogMessage(Debug::DebugInfo, "AsyncBegin: %s : cookie %d\n", name, cookie);
}
-void traceAsyncEnd(int tag, int cookie, const char *name, ...)
+void traceAsyncEnd(int tag, int cookie, const char* name, ...)
{
- Debug::LogMessage(Debug::DebugInfo, "AsyncEnd: %s : cookie %d\n", name, cookie );
+ Debug::LogMessage(Debug::DebugInfo, "AsyncEnd: %s : cookie %d\n", name, cookie);
}
-void traceMark(int tag, const char *name, ...)
+void traceMark(int tag, const char* name, ...)
{
Debug::LogMessage(Debug::DebugInfo, "Marker: %s \n", name);
}
-} // un-named namespace
+} // namespace
#endif
namespace
{
-
-int GetCookie( const std::string& description, std::string& markerName )
+int GetCookie(const std::string& description, std::string& markerName)
{
// description holds the marker name and postfix of _START or _END
std::size_t pos = description.find("_START");
- if( pos == std::string::npos )
+ if(pos == std::string::npos)
{
pos = description.find("_END");
}
- if( !pos )
+ if(!pos)
{
// if this asserts then check the postfix strings in StatContext.cpp for
// custom markers and performance-marker.cpp for built-in markers
DALI_ASSERT_DEBUG(0);
}
- markerName = description.substr( 0, pos );
+ markerName = description.substr(0, pos);
- std::size_t hash = Dali::CalculateHash( markerName.c_str() );
- return static_cast<int>( hash );
-}
+ std::size_t hash = Dali::CalculateHash(markerName.c_str());
+ return static_cast<int>(hash);
}
+} // namespace
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
SystemTrace::SystemTrace()
{
}
{
}
-void SystemTrace::Trace( const PerformanceMarker& marker, const std::string& traceMessage )
+void SystemTrace::Trace(const PerformanceMarker& marker, const std::string& traceMessage)
{
PerformanceMarker::MarkerEventType eventType = marker.GetEventType();
- if( eventType == PerformanceMarker::SINGLE_EVENT )
+ if(eventType == PerformanceMarker::SINGLE_EVENT)
{
- traceMark( TTRACE_TAG_GRAPHICS, traceMessage.c_str() );
+ traceMark(TTRACE_TAG_GRAPHICS, traceMessage.c_str());
return;
}
// DALi is multi-threaded so timed events will occur asynchronously
std::string markerName;
- int cookie = GetCookie(traceMessage, markerName );
+ int cookie = GetCookie(traceMessage, markerName);
- if( eventType == PerformanceMarker::START_TIMED_EVENT )
+ if(eventType == PerformanceMarker::START_TIMED_EVENT)
{
- traceAsyncBegin( TTRACE_TAG_GRAPHICS, cookie, markerName.c_str() );
+ traceAsyncBegin(TTRACE_TAG_GRAPHICS, cookie, markerName.c_str());
}
else
{
- traceAsyncEnd( TTRACE_TAG_GRAPHICS, cookie, markerName.c_str() );
+ traceAsyncEnd(TTRACE_TAG_GRAPHICS, cookie, markerName.c_str());
}
}
-} // namespace Internal
-
} // namespace Adaptor
-} // namespace Dali
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/system/common/thread-controller.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/environment-options.h>
-#include <dali/internal/adaptor/common/thread-controller-interface.h>
#include <dali/internal/adaptor/common/combined-update-render-controller.h>
+#include <dali/internal/adaptor/common/thread-controller-interface.h>
+#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-ThreadController::ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode )
-: mThreadControllerInterface( NULL )
+ThreadController::ThreadController(AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode)
+: mThreadControllerInterface(NULL)
{
- switch( environmentOptions.GetThreadingMode() )
+ switch(environmentOptions.GetThreadingMode())
{
case ThreadingMode::COMBINED_UPDATE_RENDER:
{
- mThreadControllerInterface = new CombinedUpdateRenderController( adaptorInterfaces, environmentOptions, threadMode );
+ mThreadControllerInterface = new CombinedUpdateRenderController(adaptorInterfaces, environmentOptions, threadMode);
break;
}
}
mThreadControllerInterface->RequestUpdate();
}
-void ThreadController::RequestUpdateOnce( UpdateMode updateMode )
+void ThreadController::RequestUpdateOnce(UpdateMode updateMode)
{
- mThreadControllerInterface->RequestUpdateOnce( updateMode );
+ mThreadControllerInterface->RequestUpdateOnce(updateMode);
}
-void ThreadController::ReplaceSurface( Dali::RenderSurfaceInterface* newSurface )
+void ThreadController::ReplaceSurface(Dali::RenderSurfaceInterface* newSurface)
{
- mThreadControllerInterface->ReplaceSurface( newSurface );
+ mThreadControllerInterface->ReplaceSurface(newSurface);
}
-void ThreadController::DeleteSurface( Dali::RenderSurfaceInterface* surface )
+void ThreadController::DeleteSurface(Dali::RenderSurfaceInterface* surface)
{
- mThreadControllerInterface->DeleteSurface( surface );
+ mThreadControllerInterface->DeleteSurface(surface);
}
void ThreadController::ResizeSurface()
mThreadControllerInterface->WaitForGraphicsInitialization();
}
-void ThreadController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender )
+void ThreadController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
{
- mThreadControllerInterface->SetRenderRefreshRate( numberOfVSyncsPerRender );
+ mThreadControllerInterface->SetRenderRefreshRate(numberOfVSyncsPerRender);
}
-void ThreadController::SetPreRenderCallback( CallbackBase* callback )
+void ThreadController::SetPreRenderCallback(CallbackBase* callback)
{
- mThreadControllerInterface->SetPreRenderCallback( callback );
+ mThreadControllerInterface->SetPreRenderCallback(callback);
}
-void ThreadController::AddSurface( Dali::RenderSurfaceInterface* newSurface )
+void ThreadController::AddSurface(Dali::RenderSurfaceInterface* newSurface)
{
- mThreadControllerInterface->AddSurface( newSurface );
+ mThreadControllerInterface->AddSurface(newSurface);
}
} // namespace Adaptor
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace TimeService
{
-
-void GetNanoseconds( uint64_t& timeInNanoseconds )
+void GetNanoseconds(uint64_t& timeInNanoseconds)
{
// Get the time of a monotonic clock since its epoch.
auto epoch = std::chrono::steady_clock::now().time_since_epoch();
return static_cast<uint32_t>(duration.count());
}
-
-void SleepUntil( uint64_t timeInNanoseconds )
+void SleepUntil(uint64_t timeInNanoseconds)
{
- using Clock = std::chrono::steady_clock;
+ using Clock = std::chrono::steady_clock;
using TimePoint = std::chrono::time_point<Clock>;
const Clock::duration duration = std::chrono::nanoseconds(timeInNanoseconds);
- const TimePoint timePoint(duration);
+ const TimePoint timePoint(duration);
std::this_thread::sleep_until(timePoint);
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
-TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options )
+TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options)
{
- return new Internal::Adaptor::TriggerEvent( callback, options );
+ return new Internal::Adaptor::TriggerEvent(callback, options);
}
-void TriggerEventFactory::DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface )
+void TriggerEventFactory::DestroyTriggerEvent(TriggerEventInterface* triggerEventInterface)
{
- Internal::Adaptor::TriggerEvent* triggerEvent( static_cast<Internal::Adaptor::TriggerEvent *>(triggerEventInterface) );
+ Internal::Adaptor::TriggerEvent* triggerEvent(static_cast<Internal::Adaptor::TriggerEvent*>(triggerEventInterface));
delete triggerEvent;
}
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-TriggerEvent::TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options )
-: mFileDescriptorMonitor( NULL ),
- mCallback( callback ),
- mFileDescriptor( -1 ),
- mOptions( options )
+TriggerEvent::TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options)
+: mFileDescriptorMonitor(NULL),
+ mCallback(callback),
+ mFileDescriptor(-1),
+ mOptions(options)
{
// Create accompanying file descriptor.
mFileDescriptor = eventfd(0, EFD_NONBLOCK);
- if (mFileDescriptor >= 0)
+ if(mFileDescriptor >= 0)
{
// Now Monitor the created event file descriptor
- mFileDescriptorMonitor = new FileDescriptorMonitor( mFileDescriptor, MakeCallback( this, &TriggerEvent::Triggered ), FileDescriptorMonitor::FD_READABLE );
+ mFileDescriptorMonitor = new FileDescriptorMonitor(mFileDescriptor, MakeCallback(this, &TriggerEvent::Triggered), FileDescriptorMonitor::FD_READABLE);
}
else
{
delete mFileDescriptorMonitor;
delete mCallback;
- if (mFileDescriptor >= 0)
+ if(mFileDescriptor >= 0)
{
close(mFileDescriptor);
mFileDescriptor = 0;
void TriggerEvent::Trigger()
{
- if (mFileDescriptor >= 0)
+ if(mFileDescriptor >= 0)
{
// Increment event counter by 1.
// Writing to the file descriptor triggers the Dispatch() method in the other thread
// (if in multi-threaded environment).
uint64_t data = 1;
- int size = write(mFileDescriptor, &data, sizeof(uint64_t));
+ int size = write(mFileDescriptor, &data, sizeof(uint64_t));
- if (size != sizeof(uint64_t))
+ if(size != sizeof(uint64_t))
{
DALI_LOG_ERROR("Unable to write to UpdateEvent File descriptor\n");
}
}
}
-void TriggerEvent::Triggered( FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor )
+void TriggerEvent::Triggered(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor)
{
- if( !( eventBitMask & FileDescriptorMonitor::FD_READABLE ) )
+ if(!(eventBitMask & FileDescriptorMonitor::FD_READABLE))
{
- DALI_ASSERT_ALWAYS( 0 && "Trigger event file descriptor error");
+ DALI_ASSERT_ALWAYS(0 && "Trigger event file descriptor error");
return;
}
// Reading from the file descriptor resets the event counter, we can ignore the count.
uint64_t receivedData;
- size_t size;
+ size_t size;
size = read(mFileDescriptor, &receivedData, sizeof(uint64_t));
- if (size != sizeof(uint64_t))
+ if(size != sizeof(uint64_t))
{
DALI_LOG_WARNING("Unable to read to UpdateEvent File descriptor\n");
}
// Call the connected callback
- CallbackBase::Execute( *mCallback );
+ CallbackBase::Execute(*mCallback);
//check if we should delete ourselves after the trigger
- if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER )
+ if(mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER)
{
delete this;
}
#include <dali/internal/system/common/update-status-logger.h>
// EXTERNAL INCLUDES
-#include <string>
#include <dali/integration-api/core.h>
+#include <string>
// INTERNAL INCLUDES
#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-UpdateStatusLogger::UpdateStatusLogger( const EnvironmentOptions& environmentOptions )
-: mStatusLogInterval( environmentOptions.GetUpdateStatusLoggingFrequency() ),
- mStatusLogCount( 0u )
+UpdateStatusLogger::UpdateStatusLogger(const EnvironmentOptions& environmentOptions)
+: mStatusLogInterval(environmentOptions.GetUpdateStatusLoggingFrequency()),
+ mStatusLogCount(0u)
{
}
{
}
-void UpdateStatusLogger::Log( unsigned int keepUpdatingStatus )
+void UpdateStatusLogger::Log(unsigned int keepUpdatingStatus)
{
- if ( mStatusLogInterval )
+ if(mStatusLogInterval)
{
std::string oss;
- if ( !(++mStatusLogCount % mStatusLogInterval) )
+ if(!(++mStatusLogCount % mStatusLogInterval))
{
oss = "UpdateStatusLogging keepUpdating: ";
- oss += (keepUpdatingStatus ? "true":"false");
+ oss += (keepUpdatingStatus ? "true" : "false");
- if ( keepUpdatingStatus )
+ if(keepUpdatingStatus)
{
oss += " because: ";
}
- if ( keepUpdatingStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING )
+ if(keepUpdatingStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING)
{
oss += "<Stage::KeepRendering() used> ";
}
- if ( keepUpdatingStatus & Integration::KeepUpdating::ANIMATIONS_RUNNING )
+ if(keepUpdatingStatus & Integration::KeepUpdating::ANIMATIONS_RUNNING)
{
- oss += "<Animations running> ";
+ oss += "<Animations running> ";
}
- if ( keepUpdatingStatus & Integration::KeepUpdating::MONITORING_PERFORMANCE )
+ if(keepUpdatingStatus & Integration::KeepUpdating::MONITORING_PERFORMANCE)
{
oss += "<Monitoring performance> ";
}
- if ( keepUpdatingStatus & Integration::KeepUpdating::RENDER_TASK_SYNC )
+ if(keepUpdatingStatus & Integration::KeepUpdating::RENDER_TASK_SYNC)
{
oss += "<Render task waiting for completion> ";
}
- DALI_LOG_UPDATE_STATUS( "%s\n", oss.c_str());
+ DALI_LOG_UPDATE_STATUS("%s\n", oss.c_str());
}
}
}
/*
- * Copyright (c) 2017 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.
*/
// CLASS HEADER
-#include <dali/internal/system/common/widget-application-impl.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/common/widget-application-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
// factory function, must be implemented
namespace WidgetApplicationFactory
{
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
-WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet );
+WidgetApplicationPtr Create(int* argc, char** argv[], const std::string& stylesheet);
-} // namespace Factory
+} // namespace WidgetApplicationFactory
WidgetApplicationPtr WidgetApplication::New(
- int* argc,
- char **argv[],
+ int* argc,
+ char** argv[],
const std::string& stylesheet)
{
//WidgetApplicationPtr //widgetApplication( new WidgetApplication (argc, argv, stylesheet ) );
- return WidgetApplicationFactory::Create( argc, argv, stylesheet );
+ return WidgetApplicationFactory::Create(argc, argv, stylesheet);
}
-WidgetApplication::WidgetApplication( int* argc, char** argv[], const std::string& stylesheet )
+WidgetApplication::WidgetApplication(int* argc, char** argv[], const std::string& stylesheet)
: Application(argc, argv, stylesheet, Dali::WidgetApplication::OPAQUE, PositionSize(), Framework::WIDGET)
{
DALI_LOG_ERROR("WidgetApplication is not implemented in UBUNTU profile.\n");
{
}
-void WidgetApplication::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+void WidgetApplication::RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction)
{
}
/*
- * Copyright (c) 2019 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.
#include <dali/internal/system/common/shared-file.h>
// EXTERNAL INCLUDES
-#include <sys/types.h>
#include <sys/mman.h>
+#include <sys/types.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-int SharedFile::Open( const char* filename, int size, int oflag, mode_t mode )
+int SharedFile::Open(const char* filename, int size, int oflag, mode_t mode)
{
- return shm_open( filename, oflag, mode );
+ return shm_open(filename, oflag, mode);
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
// INTERNAL INCLUDES
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Structure contains the callback function and control options
*/
struct CallbackData
{
-
/**
* Constructor
*/
- CallbackData( CallbackBase* callback, bool hasReturnValue )
- : mCallback( callback ),
- mRemoveFromContainerFunction( NULL ),
- mIdler( NULL ),
- mIdleEnterer( NULL ),
- mHasReturnValue( hasReturnValue )
+ CallbackData(CallbackBase* callback, bool hasReturnValue)
+ : mCallback(callback),
+ mRemoveFromContainerFunction(NULL),
+ mIdler(NULL),
+ mIdleEnterer(NULL),
+ mHasReturnValue(hasReturnValue)
{
}
/**
delete mRemoveFromContainerFunction;
}
- CallbackBase* mCallback; ///< call back
- CallbackBase* mRemoveFromContainerFunction; ///< Called to remove the callbackdata from the callback container
- Ecore_Idler* mIdler; ///< ecore idler
- Ecore_Idle_Enterer* mIdleEnterer; ///< ecore idle enterer
- bool mHasReturnValue; ///< true if the callback function has a return value.
+ CallbackBase* mCallback; ///< call back
+ CallbackBase* mRemoveFromContainerFunction; ///< Called to remove the callbackdata from the callback container
+ Ecore_Idler* mIdler; ///< ecore idler
+ Ecore_Idle_Enterer* mIdleEnterer; ///< ecore idle enterer
+ bool mHasReturnValue; ///< true if the callback function has a return value.
};
namespace
{
-
/**
* Called from the main thread while idle.
*/
-Eina_Bool IdleCallback(void *data)
+Eina_Bool IdleCallback(void* data)
{
- Eina_Bool ret = ECORE_CALLBACK_CANCEL; // CALLBACK Cancel will delete the idler so we don't need to call ecore_idler_del
- CallbackData *callbackData = static_cast< CallbackData * >( data );
+ Eina_Bool ret = ECORE_CALLBACK_CANCEL; // CALLBACK Cancel will delete the idler so we don't need to call ecore_idler_del
+ CallbackData* callbackData = static_cast<CallbackData*>(data);
- if( callbackData->mHasReturnValue )
+ if(callbackData->mHasReturnValue)
{
// run the function
- bool retValue = CallbackBase::ExecuteReturn< bool >( *callbackData->mCallback );
- if( retValue )
+ bool retValue = CallbackBase::ExecuteReturn<bool>(*callbackData->mCallback);
+ if(retValue)
{
// keep the callback
ret = ECORE_CALLBACK_RENEW;
else
{
// remove callback data from the container
- CallbackBase::Execute( *callbackData->mRemoveFromContainerFunction, callbackData );
+ CallbackBase::Execute(*callbackData->mRemoveFromContainerFunction, callbackData);
// delete our data
delete callbackData;
else
{
// remove callback data from the container
- CallbackBase::Execute( *callbackData->mRemoveFromContainerFunction, callbackData );
+ CallbackBase::Execute(*callbackData->mRemoveFromContainerFunction, callbackData);
// run the function
- CallbackBase::Execute( *callbackData->mCallback );
+ CallbackBase::Execute(*callbackData->mCallback);
// delete our data
delete callbackData;
} // unnamed namespace
EcoreCallbackManager::EcoreCallbackManager()
-:mRunning(false)
+: mRunning(false)
{
}
-
void EcoreCallbackManager::Start()
{
- DALI_ASSERT_DEBUG( mRunning == false );
+ DALI_ASSERT_DEBUG(mRunning == false);
mRunning = true;
}
void EcoreCallbackManager::Stop()
{
// make sure we're not called twice
- DALI_ASSERT_DEBUG( mRunning == true );
+ DALI_ASSERT_DEBUG(mRunning == true);
RemoveAllCallbacks();
mRunning = false;
-
}
-bool EcoreCallbackManager::AddIdleCallback( CallbackBase* callback, bool hasReturnValue )
+bool EcoreCallbackManager::AddIdleCallback(CallbackBase* callback, bool hasReturnValue)
{
- if( !mRunning )
+ if(!mRunning)
{
return false;
}
- CallbackData* callbackData = new CallbackData( callback, hasReturnValue );
+ CallbackData* callbackData = new CallbackData(callback, hasReturnValue);
- callbackData->mRemoveFromContainerFunction = MakeCallback( this, &EcoreCallbackManager::RemoveCallbackFromContainer );
+ callbackData->mRemoveFromContainerFunction = MakeCallback(this, &EcoreCallbackManager::RemoveCallbackFromContainer);
// add the call back to the container
mCallbackContainer.push_front(callbackData);
// add the idler
- callbackData->mIdler = ecore_idler_add( IdleCallback, callbackData);
+ callbackData->mIdler = ecore_idler_add(IdleCallback, callbackData);
- DALI_ASSERT_ALWAYS( ( callbackData->mIdler != NULL ) && "Idle method not created" );
+ DALI_ASSERT_ALWAYS((callbackData->mIdler != NULL) && "Idle method not created");
return true;
}
-void EcoreCallbackManager::RemoveIdleCallback( CallbackBase* callback )
+void EcoreCallbackManager::RemoveIdleCallback(CallbackBase* callback)
{
- for( CallbackList::iterator it = mCallbackContainer.begin(),
- endIt = mCallbackContainer.end();
- it != endIt;
- ++it )
+ for(CallbackList::iterator it = mCallbackContainer.begin(),
+ endIt = mCallbackContainer.end();
+ it != endIt;
+ ++it)
{
CallbackData* data = *it;
- if( data->mCallback == callback )
+ if(data->mCallback == callback)
{
// remove callback data from the container.
- CallbackBase::Execute( *data->mRemoveFromContainerFunction, data );
+ CallbackBase::Execute(*data->mRemoveFromContainerFunction, data);
- ecore_idler_del( data->mIdler );
+ ecore_idler_del(data->mIdler);
// delete our data
delete data;
// @todo To be implemented.
}
-bool EcoreCallbackManager::AddIdleEntererCallback( CallbackBase* callback )
+bool EcoreCallbackManager::AddIdleEntererCallback(CallbackBase* callback)
{
- if( !mRunning )
+ if(!mRunning)
{
return false;
}
- CallbackData* callbackData = new CallbackData( callback, true );
+ CallbackData* callbackData = new CallbackData(callback, true);
- callbackData->mRemoveFromContainerFunction = MakeCallback( this, &EcoreCallbackManager::RemoveCallbackFromContainer );
+ callbackData->mRemoveFromContainerFunction = MakeCallback(this, &EcoreCallbackManager::RemoveCallbackFromContainer);
// add the call back to the container
- mCallbackContainer.push_front( callbackData );
+ mCallbackContainer.push_front(callbackData);
// add the idler
- callbackData->mIdleEnterer = ecore_idle_enterer_add( IdleCallback, callbackData );
+ callbackData->mIdleEnterer = ecore_idle_enterer_add(IdleCallback, callbackData);
- DALI_ASSERT_ALWAYS( ( callbackData->mIdleEnterer != NULL ) && "Idle method not created" );
+ DALI_ASSERT_ALWAYS((callbackData->mIdleEnterer != NULL) && "Idle method not created");
return true;
}
-void EcoreCallbackManager::RemoveIdleEntererCallback( CallbackBase* callback )
+void EcoreCallbackManager::RemoveIdleEntererCallback(CallbackBase* callback)
{
- for( CallbackList::iterator it = mCallbackContainer.begin(),
- endIt = mCallbackContainer.end();
- it != endIt;
- ++it )
+ for(CallbackList::iterator it = mCallbackContainer.begin(),
+ endIt = mCallbackContainer.end();
+ it != endIt;
+ ++it)
{
CallbackData* data = *it;
- if( data->mCallback == callback )
+ if(data->mCallback == callback)
{
// remove callback data from the container.
- CallbackBase::Execute( *data->mRemoveFromContainerFunction, data );
+ CallbackBase::Execute(*data->mRemoveFromContainerFunction, data);
- ecore_idle_enterer_del( data->mIdleEnterer );
+ ecore_idle_enterer_del(data->mIdleEnterer);
// delete our data
delete data;
}
}
-void EcoreCallbackManager::RemoveCallbackFromContainer(CallbackData *callbackData)
+void EcoreCallbackManager::RemoveCallbackFromContainer(CallbackData* callbackData)
{
mCallbackContainer.remove(callbackData);
}
void EcoreCallbackManager::RemoveAllCallbacks()
{
// always called from main thread
- for( CallbackList::iterator iter = mCallbackContainer.begin(); iter != mCallbackContainer.end(); ++iter)
+ for(CallbackList::iterator iter = mCallbackContainer.begin(); iter != mCallbackContainer.end(); ++iter)
{
CallbackData* data = (*iter);
- if( data->mIdler )
+ if(data->mIdler)
{
- ecore_idler_del( data->mIdler );
+ ecore_idler_del(data->mIdler);
}
- else if( data->mIdleEnterer )
+ else if(data->mIdleEnterer)
{
- ecore_idle_enterer_del( data->mIdleEnterer );
+ ecore_idle_enterer_del(data->mIdleEnterer);
}
delete data;
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Using Impl to hide away EFL specific members
*/
struct FileDescriptorMonitor::Impl
{
// Construction
- Impl( int fileDescriptor, CallbackBase* callback, int eventsToMonitor)
- : mFileDescriptor( fileDescriptor ),
- mEventsToMonitor( eventsToMonitor ),
- mCallback( callback ),
- mHandler( NULL )
+ Impl(int fileDescriptor, CallbackBase* callback, int eventsToMonitor)
+ : mFileDescriptor(fileDescriptor),
+ mEventsToMonitor(eventsToMonitor),
+ mCallback(callback),
+ mHandler(NULL)
{
}
}
// Data
- int mFileDescriptor;
- int mEventsToMonitor; ///< what file descriptor events to monitor
- CallbackBase* mCallback;
+ int mFileDescriptor;
+ int mEventsToMonitor; ///< what file descriptor events to monitor
+ CallbackBase* mCallback;
Ecore_Fd_Handler* mHandler;
// Static Methods
/**
* Called when the file descriptor receives an event.
*/
- static Eina_Bool EventDispatch(void* data, Ecore_Fd_Handler *handler)
+ static Eina_Bool EventDispatch(void* data, Ecore_Fd_Handler* handler)
{
Impl* impl = reinterpret_cast<Impl*>(data);
// if we want read events, check to see if a read event is available
int type = FileDescriptorMonitor::FD_NO_EVENT;
- if( ecore_main_fd_handler_active_get( handler, ECORE_FD_ERROR) )
+ if(ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
{
- CallbackBase::Execute( *impl->mCallback, FileDescriptorMonitor::FD_ERROR, impl->mFileDescriptor );
+ CallbackBase::Execute(*impl->mCallback, FileDescriptorMonitor::FD_ERROR, impl->mFileDescriptor);
DALI_LOG_ERROR("ECORE_FD_ERROR occurred on %d\n", impl->mFileDescriptor);
return ECORE_CALLBACK_CANCEL;
}
- if( impl->mEventsToMonitor & ECORE_FD_READ )
+ if(impl->mEventsToMonitor & ECORE_FD_READ)
{
- if (ecore_main_fd_handler_active_get( handler, ECORE_FD_READ))
+ if(ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
{
type = FileDescriptorMonitor::FD_READABLE;
}
}
// check if we want write events
- if( impl->mEventsToMonitor & ECORE_FD_WRITE )
+ if(impl->mEventsToMonitor & ECORE_FD_WRITE)
{
- if (ecore_main_fd_handler_active_get( handler, ECORE_FD_WRITE))
+ if(ecore_main_fd_handler_active_get(handler, ECORE_FD_WRITE))
{
type |= FileDescriptorMonitor::FD_WRITABLE;
}
}
// if there is an event, execute the callback
- if( type != FileDescriptorMonitor::FD_NO_EVENT )
+ if(type != FileDescriptorMonitor::FD_NO_EVENT)
{
- CallbackBase::Execute( *impl->mCallback, static_cast< FileDescriptorMonitor::EventType >(type ), impl->mFileDescriptor );
+ CallbackBase::Execute(*impl->mCallback, static_cast<FileDescriptorMonitor::EventType>(type), impl->mFileDescriptor);
}
return ECORE_CALLBACK_RENEW;
}
};
-FileDescriptorMonitor::FileDescriptorMonitor( int fileDescriptor, CallbackBase* callback, int eventBitmask)
+FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask)
{
mImpl = new Impl(fileDescriptor, callback, eventBitmask);
- if (fileDescriptor < 1)
+ if(fileDescriptor < 1)
{
- DALI_ASSERT_ALWAYS( 0 && "Invalid File descriptor");
+ DALI_ASSERT_ALWAYS(0 && "Invalid File descriptor");
return;
}
int events = 0;
- if( eventBitmask & FD_READABLE)
+ if(eventBitmask & FD_READABLE)
{
events = ECORE_FD_READ;
}
- if( eventBitmask & FD_WRITABLE)
+ if(eventBitmask & FD_WRITABLE)
{
events |= ECORE_FD_WRITE;
}
mImpl->mEventsToMonitor = events;
- mImpl->mHandler = ecore_main_fd_handler_add( fileDescriptor, static_cast<Ecore_Fd_Handler_Flags >( events ), &Impl::EventDispatch, mImpl, NULL, NULL );
-
+ mImpl->mHandler = ecore_main_fd_handler_add(fileDescriptor, static_cast<Ecore_Fd_Handler_Flags>(events), &Impl::EventDispatch, mImpl, NULL, NULL);
}
FileDescriptorMonitor::~FileDescriptorMonitor()
{
- if (mImpl->mHandler)
+ if(mImpl->mHandler)
{
ecore_main_fd_handler_del(mImpl->mHandler);
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
// LOCAL STUFF
namespace
{
-Eina_Bool TimerSourceFunc (void *data)
+Eina_Bool TimerSourceFunc(void* data)
{
Timer* timer = static_cast<Timer*>(data);
*/
struct Timer::Impl
{
- Impl( unsigned int milliSec )
+ Impl(unsigned int milliSec)
: mId(NULL),
mInterval(milliSec)
{
}
- Ecore_Timer * mId;
+ Ecore_Timer* mId;
unsigned int mInterval;
};
-TimerPtr Timer::New( unsigned int milliSec )
+TimerPtr Timer::New(unsigned int milliSec)
{
- TimerPtr timer( new Timer( milliSec ) );
+ TimerPtr timer(new Timer(milliSec));
return timer;
}
-Timer::Timer( unsigned int milliSec )
+Timer::Timer(unsigned int milliSec)
: mImpl(new Impl(milliSec))
{
}
void Timer::Start()
{
// Timer should be used in the event thread
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
if(mImpl->mId != NULL)
{
Stop();
}
- double interval = static_cast<double> ( mImpl->mInterval ) / 1000.0f;
- mImpl->mId = ecore_timer_add( interval, reinterpret_cast<Ecore_Task_Cb>( TimerSourceFunc ), this );
+ double interval = static_cast<double>(mImpl->mInterval) / 1000.0f;
+ mImpl->mId = ecore_timer_add(interval, reinterpret_cast<Ecore_Task_Cb>(TimerSourceFunc), this);
}
void Timer::Stop()
{
// Timer should be used in the event thread
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
ResetTimerData();
}
void Timer::Pause()
{
// Timer should be used in the event thread
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- if( mImpl->mId != NULL )
+ if(mImpl->mId != NULL)
{
- ecore_timer_freeze( mImpl->mId );
+ ecore_timer_freeze(mImpl->mId);
}
}
void Timer::Resume()
{
// Timer should be used in the event thread
- DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
- if( mImpl->mId != NULL )
+ if(mImpl->mId != NULL)
{
- ecore_timer_thaw( mImpl->mId );
+ ecore_timer_thaw(mImpl->mId);
}
}
-void Timer::SetInterval( unsigned int interval, bool restart )
+void Timer::SetInterval(unsigned int interval, bool restart)
{
// stop existing timer
Stop();
mImpl->mInterval = interval;
- if( restart )
+ if(restart)
{
// start new tick
Start();
bool Timer::Tick()
{
// Guard against destruction during signal emission
- Dali::Timer handle( this );
+ Dali::Timer handle(this);
- bool retVal( false );
+ bool retVal(false);
// Override with new signal if used
- if( !mTickSignal.Empty() )
+ if(!mTickSignal.Empty())
{
retVal = mTickSignal.Emit();
// Timer stops if return value is false
- if (retVal == false)
+ if(retVal == false)
{
Stop();
}
else
{
- retVal = true; // continue emission
+ retVal = true; // continue emission
}
}
else // no callbacks registered
void Timer::ResetTimerData()
{
- if (mImpl->mId != NULL)
+ if(mImpl->mId != NULL)
{
ecore_timer_del(mImpl->mId);
mImpl->mId = NULL;
/*
- * 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.
namespace Dali::Internal::Adaptor
{
-
FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask)
{
DALI_LOG_WARNING("Implementation missing for macOS");
}
FileDescriptorMonitor::~FileDescriptorMonitor()
-{}
+{
+}
-} // Dali::Internal::Adaptor
+} // namespace Dali::Internal::Adaptor
/*
- * 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.
namespace Dali::Internal::Adaptor
{
-
-
/**
* Struct to hide away macOS implementation details
*/
struct Timer::Impl
{
- Impl(Timer *parent, unsigned int milliSec)
- : mTimer(CreateTimer(parent, milliSec)) {}
+ Impl(Timer* parent, unsigned int milliSec)
+ : mTimer(CreateTimer(parent, milliSec))
+ {
+ }
- ~Impl() { Stop(); }
+ ~Impl()
+ {
+ Stop();
+ }
- static void TimerProc(CFRunLoopTimerRef timer, void *info);
+ static void TimerProc(CFRunLoopTimerRef timer, void* info);
void Start();
void Stop();
- void Reset(Timer *parent, unsigned int milliSec);
+ void Reset(Timer* parent, unsigned int milliSec);
unsigned int GetInterval() const noexcept
{
}
private:
- CFRef<CFRunLoopTimerRef> CreateTimer(Timer *parent, unsigned int milliSec);
+ CFRef<CFRunLoopTimerRef> CreateTimer(Timer* parent, unsigned int milliSec);
CFRef<CFRunLoopTimerRef> mTimer;
};
-void Timer::Impl::TimerProc(CFRunLoopTimerRef timer, void *info)
+void Timer::Impl::TimerProc(CFRunLoopTimerRef timer, void* info)
{
- auto *pTimer = static_cast<Timer*>(info);
+ auto* pTimer = static_cast<Timer*>(info);
pTimer->Tick();
}
void Timer::Impl::Start()
{
- if (!IsRunning())
+ if(!IsRunning())
{
auto runLoop = CFRunLoopGetMain();
CFRunLoopAddTimer(runLoop, mTimer.get(), kCFRunLoopDefaultMode);
void Timer::Impl::Stop()
{
- if (IsRunning())
+ if(IsRunning())
{
CFRunLoopTimerContext context;
CFRunLoopTimerGetContext(mTimer.get(), &context);
0,
0,
TimerProc,
- &context
- ));
+ &context));
}
}
-void Timer::Impl::Reset(Timer *parent, unsigned int milliSec)
+void Timer::Impl::Reset(Timer* parent, unsigned int milliSec)
{
Stop();
mTimer = CreateTimer(parent, milliSec);
}
CFRef<CFRunLoopTimerRef>
-Timer::Impl::CreateTimer(Timer *parent, unsigned int milliSec)
+Timer::Impl::CreateTimer(Timer* parent, unsigned int milliSec)
{
- const auto interval = static_cast<CFAbsoluteTime>(milliSec) / 1000;
- const auto fireDate = CFAbsoluteTimeGetCurrent() + interval;
+ const auto interval = static_cast<CFAbsoluteTime>(milliSec) / 1000;
+ const auto fireDate = CFAbsoluteTimeGetCurrent() + interval;
CFRunLoopTimerContext context =
- {
- .version = 0,
- .info = parent,
- .retain = nullptr,
- .release = nullptr,
- };
+ {
+ .version = 0,
+ .info = parent,
+ .retain = nullptr,
+ .release = nullptr,
+ };
return MakeRef(CFRunLoopTimerCreate(
kCFAllocatorDefault,
- fireDate, interval,
+ fireDate,
+ interval,
0,
0,
TimerProc,
- &context
- ));
+ &context));
}
-TimerPtr Timer::New( unsigned int milliSec )
+TimerPtr Timer::New(unsigned int milliSec)
{
- return new Timer( milliSec );
+ return new Timer(milliSec);
}
-Timer::Timer( unsigned int milliSec )
+Timer::Timer(unsigned int milliSec)
: mImpl(new Impl(this, milliSec))
{
}
void Timer::Pause()
{
-
}
void Timer::Resume()
{
-
}
-void Timer::SetInterval( unsigned int interval, bool restart )
+void Timer::SetInterval(unsigned int interval, bool restart)
{
mImpl->Reset(this, interval);
}
bool Timer::Tick()
{
// Guard against destruction during signal emission
- Dali::Timer handle( this );
+ Dali::Timer handle(this);
- bool retVal( false );
+ bool retVal(false);
// Override with new signal if used
- if( !mTickSignal.Empty() )
+ if(!mTickSignal.Empty())
{
retVal = mTickSignal.Emit();
// Timer stops if return value is false
- if (retVal == false)
+ if(retVal == false)
{
Stop();
}
else
{
- retVal = true; // continue emission
+ retVal = true; // continue emission
}
}
else // no callbacks registered
}
} // namespace Dali::Internal::Adaptor
-
/*
- * Copyright (c) 2018 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.
*/
// CLASS HEADER
-#include <dali/internal/system/macos/widget-application-impl-mac.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/macos/widget-application-impl-mac.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WidgetApplicationPtr WidgetApplicationCocoa::New(
- int* argc,
- char **argv[],
+ int* argc,
+ char** argv[],
const std::string& stylesheet)
{
- return new WidgetApplicationCocoa(argc, argv, stylesheet );
+ return new WidgetApplicationCocoa(argc, argv, stylesheet);
}
WidgetApplicationCocoa::WidgetApplicationCocoa(
- int* argc,
- char** argv[],
- const std::string& stylesheet
-)
+ int* argc,
+ char** argv[],
+ const std::string& stylesheet)
: WidgetApplication(argc, argv, stylesheet)
{
DALI_LOG_ERROR("WidgetApplication is not implemented in MACOS profile.\n");
}
void WidgetApplicationCocoa::RegisterWidgetCreatingFunction(
- const std::string& widgetName,
- Dali::WidgetApplication::CreateWidgetFunction createFunction
-)
+ const std::string& widgetName,
+ Dali::WidgetApplication::CreateWidgetFunction createFunction)
{
}
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
-WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet )
+WidgetApplicationPtr Create(int* argc, char** argv[], const std::string& stylesheet)
{
- return WidgetApplicationCocoa::New( argc, argv, stylesheet );
+ return WidgetApplicationCocoa::New(argc, argv, stylesheet);
}
-} // namespace Factory
+} // namespace WidgetApplicationFactory
} // namespace Adaptor
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace TizenPlatform
{
-
void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
{
const char* DALI_TAG = "DALI";
break;
}
#pragma GCC diagnostic pop
-
}
} // namespace TizenPlatform
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-int GetLongPressTime( int defaultTime )
+int GetLongPressTime(int defaultTime)
{
return defaultTime;
}
/*
- * Copyright (c) 2016 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.
namespace Dali
{
-
struct WatchTime::Impl
{
- Impl(void *time_handle)
+ Impl(void* time_handle)
: mTimeHandle(time_handle)
{
}
- void *mTimeHandle;
+ void* mTimeHandle;
};
-WatchTime::WatchTime(void *time_handle)
+WatchTime::WatchTime(void* time_handle)
{
mImpl = new Impl(time_handle);
}
WatchTime::~WatchTime()
{
- if( mImpl )
+ if(mImpl)
{
delete mImpl;
mImpl = NULL;
WatchTime::WatchTime()
{
- watch_time_h watch_time = {0,};
+ watch_time_h watch_time = {
+ 0,
+ };
watch_time_get_current_time(&watch_time);
mImpl = new Impl(watch_time);
#else
WatchTime::WatchTime()
- :mImpl(NULL)
+: mImpl(NULL)
{
}
/*
- * Copyright (c) 2018 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.
#include <dali/internal/system/tizen-wayland/widget-application-impl-tizen.h>
// INTERNAL INCLUDE
-#include <dali/public-api/adaptor-framework/widget.h>
-#include <dali/public-api/adaptor-framework/widget-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/system/common/environment-variables.h>
#include <dali/internal/system/tizen-wayland/widget-controller-tizen.h>
+#include <dali/public-api/adaptor-framework/widget-impl.h>
+#include <dali/public-api/adaptor-framework/widget.h>
// EXTERNAL INCLUDES
#include <bundle.h>
namespace Dali
{
-
namespace Internal
{
-
namespace
{
-
-int OnInstanceInit(widget_base_instance_h instanceHandle, bundle *content, int w, int h, void *classData)
+int OnInstanceInit(widget_base_instance_h instanceHandle, bundle* content, int w, int h, void* classData)
{
- char *id;
+ char* id;
widget_base_context_get_id(instanceHandle, &id);
widget_base_class_on_create(instanceHandle, content, w, h);
Dali::Internal::Adaptor::WidgetApplicationTizen* application = static_cast<Dali::Internal::Adaptor::WidgetApplicationTizen*>(classData);
Dali::Window window;
- if( application->GetWidgetCount() == 0)
+ if(application->GetWidgetCount() == 0)
{
window = application->GetWindow();
- DALI_LOG_RELEASE_INFO("Widget Instance use default Window(win:%p), so it need to bind widget (%dx%d) (id:%s) \n",window, w, h, std::string(id).c_str());
+ DALI_LOG_RELEASE_INFO("Widget Instance use default Window(win:%p), so it need to bind widget (%dx%d) (id:%s) \n", window, w, h, std::string(id).c_str());
}
else
{
- window = Dali::Window::New(PositionSize(0,0,w,h) ,"", false);
- if( window )
+ window = Dali::Window::New(PositionSize(0, 0, w, h), "", false);
+ if(window)
{
DALI_LOG_RELEASE_INFO("Widget Instance create new Window (win:%p, cnt:%d) (%dx%d) (id:%s )\n", window, application->GetWidgetCount(), w, h, std::string(id).c_str());
}
Any nativeHandle = window.GetNativeHandle();
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Window * wlWindow = AnyCast<Ecore_Wl2_Window*>( nativeHandle );
+ Ecore_Wl2_Window* wlWindow = AnyCast<Ecore_Wl2_Window*>(nativeHandle);
#else
- Ecore_Wl_Window * wlWindow = AnyCast<Ecore_Wl_Window*>( nativeHandle );
+ Ecore_Wl_Window* wlWindow = AnyCast<Ecore_Wl_Window*>(nativeHandle);
#endif
- widget_base_context_window_bind( instanceHandle, id, wlWindow );
- window.SetSize( Dali::Window::WindowSize( w, h ) );
+ widget_base_context_window_bind(instanceHandle, id, wlWindow);
+ window.SetSize(Dali::Window::WindowSize(w, h));
- Dali::Internal::Adaptor::WidgetApplication::CreateWidgetFunctionPair pair = application->GetWidgetCreatingFunctionPair(std::string(id));
- Dali::WidgetApplication::CreateWidgetFunction createFunction = pair.second;
+ Dali::Internal::Adaptor::WidgetApplication::CreateWidgetFunctionPair pair = application->GetWidgetCreatingFunctionPair(std::string(id));
+ Dali::WidgetApplication::CreateWidgetFunction createFunction = pair.second;
- Dali::Widget widgetInstance = createFunction( pair.first );
- application->AddWidget( instanceHandle, widgetInstance , window );
+ Dali::Widget widgetInstance = createFunction(pair.first);
+ application->AddWidget(instanceHandle, widgetInstance, window);
- Dali::Internal::Adaptor::Widget::Impl *widgetImpl = new Dali::Internal::Adaptor::WidgetImplTizen(instanceHandle);
- Internal::Adaptor::GetImplementation(widgetInstance).SetImpl( widgetImpl );
+ Dali::Internal::Adaptor::Widget::Impl* widgetImpl = new Dali::Internal::Adaptor::WidgetImplTizen(instanceHandle);
+ Internal::Adaptor::GetImplementation(widgetInstance).SetImpl(widgetImpl);
std::string encodedContentString = "";
- if( bundle_get_count( content ) )
+ if(bundle_get_count(content))
{
- bundle_raw *bundleRaw;
- int len;
+ bundle_raw* bundleRaw;
+ int len;
bundle_encode(content, &bundleRaw, &len);
- char* encodedContent = reinterpret_cast< char* >( bundleRaw );
- encodedContentString = std::string( encodedContent );
+ char* encodedContent = reinterpret_cast<char*>(bundleRaw);
+ encodedContentString = std::string(encodedContent);
free(bundleRaw);
}
- Internal::Adaptor::GetImplementation(widgetInstance).OnCreate( encodedContentString, window );
+ Internal::Adaptor::GetImplementation(widgetInstance).OnCreate(encodedContentString, window);
return 0;
}
-int OnInstanceDestroy(widget_base_instance_h instanceHandle, widget_base_destroy_type_e reason, bundle *content, void *classData)
+int OnInstanceDestroy(widget_base_instance_h instanceHandle, widget_base_destroy_type_e reason, bundle* content, void* classData)
{
Dali::Internal::Adaptor::WidgetApplicationTizen* application = static_cast<Dali::Internal::Adaptor::WidgetApplicationTizen*>(classData);
// Get Dali::Widget instance.
- Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+ Dali::Widget widgetInstance = application->GetWidget(instanceHandle);
Dali::Widget::Termination destroyReason = Dali::Widget::Termination::TEMPORARY;
std::string encodedContentString = "";
- if( bundle_get_count( content ) )
+ if(bundle_get_count(content))
{
- bundle_raw *bundleRaw;
- int len;
+ bundle_raw* bundleRaw;
+ int len;
bundle_encode(content, &bundleRaw, &len);
- char* encodedContent = reinterpret_cast< char* >( bundleRaw );
+ char* encodedContent = reinterpret_cast<char*>(bundleRaw);
encodedContentString = std::string(encodedContent);
free(bundleRaw);
}
- Internal::Adaptor::GetImplementation(widgetInstance).OnTerminate( encodedContentString, destroyReason );
+ Internal::Adaptor::GetImplementation(widgetInstance).OnTerminate(encodedContentString, destroyReason);
widget_base_class_on_destroy(instanceHandle, reason, content);
- application->DeleteWidget( instanceHandle );
+ application->DeleteWidget(instanceHandle);
return 0;
}
-int OnInstancePause(widget_base_instance_h instanceHandle, void *classData)
+int OnInstancePause(widget_base_instance_h instanceHandle, void* classData)
{
widget_base_class_on_pause(instanceHandle);
Dali::Internal::Adaptor::WidgetApplicationTizen* application = static_cast<Dali::Internal::Adaptor::WidgetApplicationTizen*>(classData);
// Get Dali::Widget instance.
- Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+ Dali::Widget widgetInstance = application->GetWidget(instanceHandle);
Internal::Adaptor::GetImplementation(widgetInstance).OnPause();
return 0;
}
-int OnInstanceResume(widget_base_instance_h instanceHandle, void *classData)
+int OnInstanceResume(widget_base_instance_h instanceHandle, void* classData)
{
widget_base_class_on_resume(instanceHandle);
Dali::Internal::Adaptor::WidgetApplicationTizen* application = static_cast<Dali::Internal::Adaptor::WidgetApplicationTizen*>(classData);
// Get Dali::Widget instance.
- Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+ Dali::Widget widgetInstance = application->GetWidget(instanceHandle);
Internal::Adaptor::GetImplementation(widgetInstance).OnResume();
return 0;
}
-int OnInstanceResize(widget_base_instance_h instanceHandle, int w, int h, void *classData)
+int OnInstanceResize(widget_base_instance_h instanceHandle, int w, int h, void* classData)
{
widget_base_class_on_resize(instanceHandle, w, h);
Dali::Internal::Adaptor::WidgetApplicationTizen* application = static_cast<Dali::Internal::Adaptor::WidgetApplicationTizen*>(classData);
// Get Dali::Widget instance.
- Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
- Dali::Window window = application->GetWindowFromWidget( instanceHandle );
- window.SetSize( Dali::Window::WindowSize(w, h) );
+ Dali::Widget widgetInstance = application->GetWidget(instanceHandle);
+ Dali::Window window = application->GetWindowFromWidget(instanceHandle);
+ window.SetSize(Dali::Window::WindowSize(w, h));
Internal::Adaptor::GetImplementation(widgetInstance).OnResize(window);
return 0;
}
-int OnInstanceUpdate(widget_base_instance_h instanceHandle, bundle *content, int force, void *classData)
+int OnInstanceUpdate(widget_base_instance_h instanceHandle, bundle* content, int force, void* classData)
{
widget_base_class_on_update(instanceHandle, content, force);
Dali::Internal::Adaptor::WidgetApplicationTizen* application = static_cast<Dali::Internal::Adaptor::WidgetApplicationTizen*>(classData);
// Get Dali::Widget instance.
- Dali::Widget widgetInstance = application->GetWidget( instanceHandle );
+ Dali::Widget widgetInstance = application->GetWidget(instanceHandle);
std::string encodedContentString = "";
- if( bundle_get_count( content ) )
+ if(bundle_get_count(content))
{
- bundle_raw *bundleRaw;
- int len;
+ bundle_raw* bundleRaw;
+ int len;
bundle_encode(content, &bundleRaw, &len);
- char* encodedContent = reinterpret_cast< char* >( bundleRaw );
+ char* encodedContent = reinterpret_cast<char*>(bundleRaw);
encodedContentString = std::string(encodedContent);
free(bundleRaw);
}
- Internal::Adaptor::GetImplementation(widgetInstance).OnUpdate( encodedContentString, force );
+ Internal::Adaptor::GetImplementation(widgetInstance).OnUpdate(encodedContentString, force);
return 0;
}
unsigned int GetEnvWidgetRenderRefreshRate()
{
- const char* envVariable = std::getenv( DALI_WIDGET_REFRESH_RATE );
+ const char* envVariable = std::getenv(DALI_WIDGET_REFRESH_RATE);
- return envVariable ? std::atoi( envVariable ) : 1u; // Default 60 fps
+ return envVariable ? std::atoi(envVariable) : 1u; // Default 60 fps
}
} // anonymous namespace
namespace Adaptor
{
-
WidgetApplicationPtr WidgetApplicationTizen::New(
- int* argc,
- char **argv[],
+ int* argc,
+ char** argv[],
const std::string& stylesheet)
{
- return new WidgetApplicationTizen(argc, argv, stylesheet );
+ return new WidgetApplicationTizen(argc, argv, stylesheet);
}
-WidgetApplicationTizen::WidgetApplicationTizen( int* argc, char** argv[], const std::string& stylesheet )
-:WidgetApplication(argc, argv, stylesheet)
+WidgetApplicationTizen::WidgetApplicationTizen(int* argc, char** argv[], const std::string& stylesheet)
+: WidgetApplication(argc, argv, stylesheet)
{
}
{
}
-
-void WidgetApplicationTizen::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+void WidgetApplicationTizen::RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction)
{
- AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair(widgetName, createFunction) );
+ AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair(widgetName, createFunction));
// Register widget class to widget framework
widget_base_class cls = widget_base_class_get_default();
- cls.ops.create = OnInstanceInit;
- cls.ops.destroy = OnInstanceDestroy;
- cls.ops.pause = OnInstancePause;
- cls.ops.resume = OnInstanceResume;
- cls.ops.resize = OnInstanceResize;
- cls.ops.update = OnInstanceUpdate;
+ cls.ops.create = OnInstanceInit;
+ cls.ops.destroy = OnInstanceDestroy;
+ cls.ops.pause = OnInstancePause;
+ cls.ops.resume = OnInstanceResume;
+ cls.ops.resize = OnInstanceResize;
+ cls.ops.update = OnInstanceUpdate;
widget_base_class_add(cls, widgetName.c_str(), this);
}
-void WidgetApplicationTizen::AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair pair )
+void WidgetApplicationTizen::AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair pair)
{
- mCreateWidgetFunctionContainer.push_back( pair );
+ mCreateWidgetFunctionContainer.push_back(pair);
}
-WidgetApplicationTizen::CreateWidgetFunctionPair WidgetApplicationTizen::GetWidgetCreatingFunctionPair( const std::string& widgetName )
+WidgetApplicationTizen::CreateWidgetFunctionPair WidgetApplicationTizen::GetWidgetCreatingFunctionPair(const std::string& widgetName)
{
- int idx = widgetName.find(":");
- std::string widgetID = widgetName.substr( idx + 1 );
- for( CreateWidgetFunctionContainer::const_iterator iter = mCreateWidgetFunctionContainer.begin(); iter != mCreateWidgetFunctionContainer.end(); ++iter )
+ int idx = widgetName.find(":");
+ std::string widgetID = widgetName.substr(idx + 1);
+ for(CreateWidgetFunctionContainer::const_iterator iter = mCreateWidgetFunctionContainer.begin(); iter != mCreateWidgetFunctionContainer.end(); ++iter)
{
- if( widgetID.compare((*iter).first) == 0)
+ if(widgetID.compare((*iter).first) == 0)
{
return *iter;
}
}
- return CreateWidgetFunctionPair( "", NULL );
+ return CreateWidgetFunctionPair("", NULL);
}
-void WidgetApplicationTizen::AddWidget( widget_base_instance_h widgetBaseInstance, Dali::Widget widget , Dali::Window window )
+void WidgetApplicationTizen::AddWidget(widget_base_instance_h widgetBaseInstance, Dali::Widget widget, Dali::Window window)
{
- mWidgetInstanceContainer.push_back( WidgetInstancePair(widgetBaseInstance, widget) );
- mWindowInstanceContainer.push_back( WindowInstancePair(widgetBaseInstance, window) );
+ mWidgetInstanceContainer.push_back(WidgetInstancePair(widgetBaseInstance, widget));
+ mWindowInstanceContainer.push_back(WindowInstancePair(widgetBaseInstance, window));
}
-Dali::Widget WidgetApplicationTizen::GetWidget( widget_base_instance_h widgetBaseInstance ) const
+Dali::Widget WidgetApplicationTizen::GetWidget(widget_base_instance_h widgetBaseInstance) const
{
- for( auto&& iter : mWidgetInstanceContainer )
+ for(auto&& iter : mWidgetInstanceContainer)
{
- if( (iter).first == widgetBaseInstance )
+ if((iter).first == widgetBaseInstance)
{
return (iter).second;
}
return Dali::Widget();
}
-void WidgetApplicationTizen::DeleteWidget( widget_base_instance_h widgetBaseInstance )
+void WidgetApplicationTizen::DeleteWidget(widget_base_instance_h widgetBaseInstance)
{
// Delete WidgetInstance
- auto widgetInstance = std::find_if( mWidgetInstanceContainer.begin(),
- mWidgetInstanceContainer.end(),
- [widgetBaseInstance]( WidgetInstancePair pair )
- { return (pair.first == widgetBaseInstance); } );
+ auto widgetInstance = std::find_if(mWidgetInstanceContainer.begin(),
+ mWidgetInstanceContainer.end(),
+ [widgetBaseInstance](WidgetInstancePair pair) { return (pair.first == widgetBaseInstance); });
if(widgetInstance != mWidgetInstanceContainer.end())
{
}
// Delete WindowInstance
- auto windowInstance = std::find_if( mWindowInstanceContainer.begin(),
- mWindowInstanceContainer.end(),
- [widgetBaseInstance]( WindowInstancePair pair )
- { return (pair.first == widgetBaseInstance); } );
+ auto windowInstance = std::find_if(mWindowInstanceContainer.begin(),
+ mWindowInstanceContainer.end(),
+ [widgetBaseInstance](WindowInstancePair pair) { return (pair.first == widgetBaseInstance); });
if(windowInstance != mWindowInstanceContainer.end())
{
}
}
-Dali::Window WidgetApplicationTizen::GetWindowFromWidget( widget_base_instance_h widgetBaseInstance ) const
+Dali::Window WidgetApplicationTizen::GetWindowFromWidget(widget_base_instance_h widgetBaseInstance) const
{
- for( auto&& iter : mWindowInstanceContainer )
+ for(auto&& iter : mWindowInstanceContainer)
{
- if( (iter).first == widgetBaseInstance )
+ if((iter).first == widgetBaseInstance)
{
Dali::Window ret = (iter).second;
return ret;
{
WidgetApplication::OnInit();
- Dali::Adaptor::Get().SetRenderRefreshRate( GetEnvWidgetRenderRefreshRate() );
+ Dali::Adaptor::Get().SetRenderRefreshRate(GetEnvWidgetRenderRefreshRate());
}
// factory function, must be implemented
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
-Dali::Internal::Adaptor::WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet )
+Dali::Internal::Adaptor::WidgetApplicationPtr Create(int* argc, char** argv[], const std::string& stylesheet)
{
- return WidgetApplicationTizen::New( argc, argv, stylesheet );
+ return WidgetApplicationTizen::New(argc, argv, stylesheet);
}
-} // namespace Factory
+} // namespace WidgetApplicationFactory
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-WidgetImplTizen::WidgetImplTizen( widget_base_instance_h instanceHandle )
-: Widget::Impl(), mInstanceHandle( instanceHandle )
+WidgetImplTizen::WidgetImplTizen(widget_base_instance_h instanceHandle)
+: Widget::Impl(),
+ mInstanceHandle(instanceHandle)
{
}
{
}
-void WidgetImplTizen::SetContentInfo( const std::string& contentInfo )
+void WidgetImplTizen::SetContentInfo(const std::string& contentInfo)
{
- bundle *contentBundle;
- bundle_raw *contentBundleRaw = reinterpret_cast< bundle_raw* >( const_cast<char*>(contentInfo.c_str()) );
- int len = contentInfo.length();
- contentBundle = bundle_decode(contentBundleRaw, len);
+ bundle* contentBundle;
+ bundle_raw* contentBundleRaw = reinterpret_cast<bundle_raw*>(const_cast<char*>(contentInfo.c_str()));
+ int len = contentInfo.length();
+ contentBundle = bundle_decode(contentBundleRaw, len);
- widget_base_context_set_content_info( mInstanceHandle, contentBundle );
+ widget_base_context_set_content_info(mInstanceHandle, contentBundle);
- bundle_free( contentBundle );
+ bundle_free(contentBundle);
}
-
} // namespace Adaptor
} // namespace Internal
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace TizenPlatform
{
-
void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
{
const char* DALI_TAG = "DALI";
- const char *format = NULL;
+ const char* format = NULL;
switch(level)
{
case Dali::Integration::Log::DebugInfo:
break;
}
printf(format, DALI_TAG, message.c_str());
-
}
} // namespace TizenPlatform
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
int GetElmAccessActionOver()
{
return 0;
}
-int GetLongPressTime( int defaultTime )
+int GetLongPressTime(int defaultTime)
{
return defaultTime;
}
/*
- * Copyright (c) 2018 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.
*/
// CLASS HEADER
-#include <dali/internal/system/ubuntu-x11/widget-application-impl-x.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/ubuntu-x11/widget-application-impl-x.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WidgetApplicationPtr WidgetApplicationUbuntu::New(
- int* argc,
- char **argv[],
+ int* argc,
+ char** argv[],
const std::string& stylesheet)
{
- return new WidgetApplicationUbuntu(argc, argv, stylesheet );
+ return new WidgetApplicationUbuntu(argc, argv, stylesheet);
}
-WidgetApplicationUbuntu::WidgetApplicationUbuntu( int* argc, char** argv[], const std::string& stylesheet )
+WidgetApplicationUbuntu::WidgetApplicationUbuntu(int* argc, char** argv[], const std::string& stylesheet)
: WidgetApplication(argc, argv, stylesheet)
{
DALI_LOG_ERROR("WidgetApplication is not implemented in UBUNTU profile.\n");
{
}
-
-void WidgetApplicationUbuntu::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+void WidgetApplicationUbuntu::RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction)
{
}
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
-WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet )
+WidgetApplicationPtr Create(int* argc, char** argv[], const std::string& stylesheet)
{
- return WidgetApplicationUbuntu::New( argc, argv, stylesheet );
+ return WidgetApplicationUbuntu::New(argc, argv, stylesheet);
}
-} // namespace Factory
+} // namespace WidgetApplicationFactory
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WidgetImplUbuntu::WidgetImplUbuntu()
{
}
{
}
-void WidgetImplUbuntu::SetContentInfo( const std::string& contentInfo )
+void WidgetImplUbuntu::SetContentInfo(const std::string& contentInfo)
{
}
/*\r
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
#include <dali/internal/system/windows/callback-manager-win.h>\r
\r
// EXTERNAL INCLUDES\r
-#include <dali/integration-api/debug.h>\r
#include <Windows.h>\r
+#include <dali/integration-api/debug.h>\r
\r
// INTERNAL INCLUDES\r
#include <dali/internal/window-system/windows/platform-implement-win.h>\r
\r
namespace Dali\r
{\r
-\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
WinCallbackManager::WinCallbackManager()\r
-:mRunning(false)\r
+: mRunning(false)\r
{\r
}\r
\r
void WinCallbackManager::Start()\r
{\r
- DALI_ASSERT_DEBUG( mRunning == false );\r
+ DALI_ASSERT_DEBUG(mRunning == false);\r
mRunning = true;\r
}\r
\r
void WinCallbackManager::Stop()\r
{\r
// make sure we're not called twice\r
- DALI_ASSERT_DEBUG( mRunning == true );\r
+ DALI_ASSERT_DEBUG(mRunning == true);\r
\r
mRunning = false;\r
}\r
\r
-bool WinCallbackManager::AddIdleCallback( CallbackBase* callback, bool hasReturnValue )\r
+bool WinCallbackManager::AddIdleCallback(CallbackBase* callback, bool hasReturnValue)\r
{\r
- if( !mRunning )\r
+ if(!mRunning)\r
{\r
return false;\r
}\r
\r
mCallbacks.insert(callback);\r
\r
- WindowsPlatform::PostWinThreadMessage( WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>(callback), 0 );\r
+ WindowsPlatform::PostWinThreadMessage(WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>(callback), 0);\r
\r
return true;\r
}\r
\r
-void WinCallbackManager::RemoveIdleCallback( CallbackBase* callback )\r
+void WinCallbackManager::RemoveIdleCallback(CallbackBase* callback)\r
{\r
//Wait for deal\r
}\r
{\r
const bool idleProcessed = !mCallbacks.empty();\r
\r
- for (CallbackBase* cb : mCallbacks)\r
+ for(CallbackBase* cb : mCallbacks)\r
{\r
Dali::CallbackBase::Execute(*cb);\r
}\r
mCallbacks.clear();\r
}\r
\r
-bool WinCallbackManager::AddIdleEntererCallback( CallbackBase* callback )\r
+bool WinCallbackManager::AddIdleEntererCallback(CallbackBase* callback)\r
{\r
- return AddIdleCallback( callback, true );\r
+ return AddIdleCallback(callback, true);\r
}\r
\r
-void WinCallbackManager::RemoveIdleEntererCallback( CallbackBase* callback )\r
+void WinCallbackManager::RemoveIdleEntererCallback(CallbackBase* callback)\r
{\r
-\r
}\r
\r
// Creates a concrete interface for CallbackManager\r
/*
- * 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask)
{
DALI_LOG_WARNING("Implementation missing for MS Windows");
}
FileDescriptorMonitor::~FileDescriptorMonitor()
-{}
+{
+}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace TizenPlatform
{
-
void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
{
const char* DALI_TAG = "DALI";
- const char *format = NULL;
+ const char* format = NULL;
switch(level)
{
case Dali::Integration::Log::DebugInfo:
break;
}
printf(format, DALI_TAG, message.c_str());
-
}
} // namespace TizenPlatform
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
+int GetLongPressTime(int defaultTime)
+{
+ return defaultTime;
+}
-int GetLongPressTime( int defaultTime )\r
-{\r
- return defaultTime;\r
-}\r
-\r
-int GetElmAccessActionOver()\r
-{\r
- return 0;\r
+int GetElmAccessActionOver()
+{
+ return 0;
}
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
// LOCAL STUFF
namespace
{
-bool TimerSourceFunc (void *data)
+bool TimerSourceFunc(void* data)
{
Timer* timer = static_cast<Timer*>(data);
return timer->Tick();
}
-}
+} // namespace
/**
* Struct to hide away Windows implementation details
*/
struct Timer::Impl
{
- Impl( unsigned int milliSec ) :
- mId(-1),
+ Impl(unsigned int milliSec)
+ : mId(-1),
mInterval(milliSec)
{
}
unsigned int mInterval;
};
-TimerPtr Timer::New( unsigned int milliSec )
+TimerPtr Timer::New(unsigned int milliSec)
{
- TimerPtr timer( new Timer( milliSec ) );
+ TimerPtr timer(new Timer(milliSec));
return timer;
}
-Timer::Timer( unsigned int milliSec )
+Timer::Timer(unsigned int milliSec)
: mImpl(new Impl(milliSec))
{
}
void Timer::Start()
{
- if( 0 > mImpl->mId )
+ if(0 > mImpl->mId)
{
- mImpl->mId = WindowsPlatform::SetTimer( mImpl->mInterval, TimerSourceFunc, this );
+ mImpl->mId = WindowsPlatform::SetTimer(mImpl->mInterval, TimerSourceFunc, this);
}
}
void Timer::Stop()
{
- if( 0 <= mImpl->mId )
+ if(0 <= mImpl->mId)
{
- WindowsPlatform::KillTimer( mImpl->mId );
+ WindowsPlatform::KillTimer(mImpl->mId);
mImpl->mId = -1;
}
}
void Timer::Pause()
{
-
}
void Timer::Resume()
{
-
}
-void Timer::SetInterval( unsigned int interval, bool restart )
+void Timer::SetInterval(unsigned int interval, bool restart)
{
- if( true == restart )
+ if(true == restart)
{
// stop existing timer
Stop();
bool Timer::Tick()
{
// Guard against destruction during signal emission
- Dali::Timer handle( this );
+ Dali::Timer handle(this);
- bool retVal( false );
+ bool retVal(false);
// Override with new signal if used
- if( !mTickSignal.Empty() )
+ if(!mTickSignal.Empty())
{
retVal = mTickSignal.Emit();
// Timer stops if return value is false
- if (retVal == false)
+ if(retVal == false)
{
Stop();
}
else
{
- retVal = true; // continue emission
+ retVal = true; // continue emission
}
}
else // no callbacks registered
} // namespace Internal
} // namespace Dali
-
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
-TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options )
+TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options)
{
- return new Internal::Adaptor::TriggerEvent( callback, options );
+ return new Internal::Adaptor::TriggerEvent(callback, options);
}
-void TriggerEventFactory::DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface )
+void TriggerEventFactory::DestroyTriggerEvent(TriggerEventInterface* triggerEventInterface)
{
- Internal::Adaptor::TriggerEvent* triggerEvent( static_cast<Internal::Adaptor::TriggerEvent *>(triggerEventInterface) );
+ Internal::Adaptor::TriggerEvent* triggerEvent(static_cast<Internal::Adaptor::TriggerEvent*>(triggerEventInterface));
delete triggerEvent;
}
/*\r
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
namespace Dali\r
{\r
-\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
-TriggerEvent::TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options )\r
-: mCallback( callback ),\r
- mThreadID( -1 ),\r
- mOptions( options )\r
+TriggerEvent::TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options)\r
+: mCallback(callback),\r
+ mThreadID(-1),\r
+ mOptions(options)\r
{\r
// Create accompanying file descriptor.\r
mThreadID = WindowsPlatform::GetCurrentThreadId();\r
\r
- if ( mThreadID < 0)\r
+ if(mThreadID < 0)\r
{\r
DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n");\r
}\r
\r
- mSelfCallback = MakeCallback( this, &TriggerEvent::Triggered );\r
+ mSelfCallback = MakeCallback(this, &TriggerEvent::Triggered);\r
}\r
\r
TriggerEvent::~TriggerEvent()\r
delete mCallback;\r
delete mSelfCallback;\r
\r
- if ( mThreadID >= 0)\r
+ if(mThreadID >= 0)\r
{\r
mThreadID = 0;\r
}\r
\r
void TriggerEvent::Trigger()\r
{\r
- if ( mThreadID >= 0)\r
+ if(mThreadID >= 0)\r
{\r
// Increment event counter by 1.\r
// Writing to the file descriptor triggers the Dispatch() method in the other thread\r
// (if in multi-threaded environment).\r
- WindowsPlatform::PostWinThreadMessage( WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>( mSelfCallback ), 0, mThreadID );\r
+ WindowsPlatform::PostWinThreadMessage(WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>(mSelfCallback), 0, mThreadID);\r
}\r
else\r
{\r
void TriggerEvent::Triggered()\r
{\r
// Call the connected callback\r
- CallbackBase::Execute( *mCallback );\r
+ CallbackBase::Execute(*mCallback);\r
\r
//check if we should delete ourselves after the trigger\r
- if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER )\r
+ if(mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER)\r
{\r
delete this;\r
}\r
/*
- * Copyright (c) 2018 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.
*/
// CLASS HEADER
-#include <dali/internal/system/windows/widget-application-impl-win.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/windows/widget-application-impl-win.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WidgetApplicationPtr WidgetApplicationWin::New(
- int* argc,
- char **argv[],
+ int* argc,
+ char** argv[],
const std::string& stylesheet)
{
- return new WidgetApplicationWin(argc, argv, stylesheet );
+ return new WidgetApplicationWin(argc, argv, stylesheet);
}
-WidgetApplicationWin::WidgetApplicationWin( int* argc, char** argv[], const std::string& stylesheet )
+WidgetApplicationWin::WidgetApplicationWin(int* argc, char** argv[], const std::string& stylesheet)
: WidgetApplication(argc, argv, stylesheet)
{
DALI_LOG_ERROR("WidgetApplication is not implemented in UBUNTU profile.\n");
{
}
-
-void WidgetApplicationWin::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+void WidgetApplicationWin::RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction)
{
}
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
-WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet )
+WidgetApplicationPtr Create(int* argc, char** argv[], const std::string& stylesheet)
{
- return WidgetApplicationWin::New( argc, argv, stylesheet );
+ return WidgetApplicationWin::New(argc, argv, stylesheet);
}
-} // namespace Factory
+} // namespace WidgetApplicationFactory
} // namespace Adaptor
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WidgetImplWin::WidgetImplWin()
{
}
{
}
-void WidgetImplWin::SetContentInfo( const std::string& contentInfo )
+void WidgetImplWin::SetContentInfo(const std::string& contentInfo)
{
}
#include <dali/internal/text/text-abstraction/bidirectional-support-impl.h>
// EXTERNAL INCLUDES
-#include <memory.h>
-#include <fribidi/fribidi.h>
-#include <dali/integration-api/debug.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/integration-api/debug.h>
+#include <fribidi/fribidi.h>
+#include <memory.h>
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
namespace
{
- typedef unsigned char BidiDirection;
+typedef unsigned char BidiDirection;
- // Internal charcter's direction.
- const BidiDirection LEFT_TO_RIGHT = 0u;
- const BidiDirection NEUTRAL = 1u;
- const BidiDirection RIGHT_TO_LEFT = 2u;
+// Internal charcter's direction.
+const BidiDirection LEFT_TO_RIGHT = 0u;
+const BidiDirection NEUTRAL = 1u;
+const BidiDirection RIGHT_TO_LEFT = 2u;
- /**
+/**
* @param[in] paragraphDirection The FriBiDi paragraph's direction.
*
* @return Whether the paragraph is right to left.
*/
- bool GetBidiParagraphDirection( FriBidiParType paragraphDirection )
+bool GetBidiParagraphDirection(FriBidiParType paragraphDirection)
+{
+ switch(paragraphDirection)
{
- switch( paragraphDirection )
+ case FRIBIDI_PAR_RTL: // Right-To-Left paragraph.
+ case FRIBIDI_PAR_WRTL: // Weak Right To Left paragraph.
{
- case FRIBIDI_PAR_RTL: // Right-To-Left paragraph.
- case FRIBIDI_PAR_WRTL: // Weak Right To Left paragraph.
- {
- return true;
- }
- case FRIBIDI_PAR_LTR: // Left-To-Right paragraph.
- case FRIBIDI_PAR_ON: // DirectiOn-Neutral paragraph.
- case FRIBIDI_PAR_WLTR: // Weak Left To Right paragraph.
- {
- return false;
- }
+ return true;
+ }
+ case FRIBIDI_PAR_LTR: // Left-To-Right paragraph.
+ case FRIBIDI_PAR_ON: // DirectiOn-Neutral paragraph.
+ case FRIBIDI_PAR_WLTR: // Weak Left To Right paragraph.
+ {
+ return false;
}
-
- return false;
}
- BidiDirection GetBidiCharacterDirection( FriBidiCharType characterDirection )
+ return false;
+}
+
+BidiDirection GetBidiCharacterDirection(FriBidiCharType characterDirection)
+{
+ switch(characterDirection)
{
- switch( characterDirection )
+ case FRIBIDI_TYPE_LTR: // Left-To-Right letter.
{
- case FRIBIDI_TYPE_LTR: // Left-To-Right letter.
- {
- return LEFT_TO_RIGHT;
- }
- case FRIBIDI_TYPE_AL: // Arabic Letter.
- case FRIBIDI_TYPE_RTL: // Right-To-Left letter.
- {
- return RIGHT_TO_LEFT;
- }
- case FRIBIDI_TYPE_AN: // Arabic Numeral.
- case FRIBIDI_TYPE_ES: // European number Separator.
- case FRIBIDI_TYPE_ET: // European number Terminator.
- case FRIBIDI_TYPE_EN: // European Numeral.
- default :
- {
- return NEUTRAL;
- }
+ return LEFT_TO_RIGHT;
+ }
+ case FRIBIDI_TYPE_AL: // Arabic Letter.
+ case FRIBIDI_TYPE_RTL: // Right-To-Left letter.
+ {
+ return RIGHT_TO_LEFT;
+ }
+ case FRIBIDI_TYPE_AN: // Arabic Numeral.
+ case FRIBIDI_TYPE_ES: // European number Separator.
+ case FRIBIDI_TYPE_ET: // European number Terminator.
+ case FRIBIDI_TYPE_EN: // European Numeral.
+ default:
+ {
+ return NEUTRAL;
}
}
}
+} // namespace
struct BidirectionalSupport::Plugin
{
*/
struct BidirectionalInfo
{
- FriBidiCharType* characterTypes; ///< The type of each character (right, left, neutral, ...)
- FriBidiLevel* embeddedLevels; ///< Embedded levels.
- FriBidiParType paragraphDirection; ///< The paragraph's direction.
+ FriBidiCharType* characterTypes; ///< The type of each character (right, left, neutral, ...)
+ FriBidiLevel* embeddedLevels; ///< Embedded levels.
+ FriBidiParType paragraphDirection; ///< The paragraph's direction.
};
Plugin()
: mParagraphBidirectionalInfo(),
mFreeIndices()
- {}
+ {
+ }
~Plugin()
{
// free all resources.
- for( Vector<BidirectionalInfo*>::Iterator it = mParagraphBidirectionalInfo.Begin(),
- endIt = mParagraphBidirectionalInfo.End();
- it != endIt;
- ++it )
+ for(Vector<BidirectionalInfo*>::Iterator it = mParagraphBidirectionalInfo.Begin(),
+ endIt = mParagraphBidirectionalInfo.End();
+ it != endIt;
+ ++it)
{
BidirectionalInfo* info = *it;
- free( info->embeddedLevels );
- free( info->characterTypes );
+ free(info->embeddedLevels);
+ free(info->characterTypes);
delete info;
}
}
- BidiInfoIndex CreateInfo( const Character* const paragraph,
- Length numberOfCharacters,
- bool matchSystemLanguageDirection,
- LayoutDirection::Type layoutDirection )
+ BidiInfoIndex CreateInfo(const Character* const paragraph,
+ Length numberOfCharacters,
+ bool matchSystemLanguageDirection,
+ LayoutDirection::Type layoutDirection)
{
// Reserve memory for the paragraph's bidirectional info.
BidirectionalInfo* bidirectionalInfo = new BidirectionalInfo();
- bidirectionalInfo->characterTypes = reinterpret_cast<FriBidiCharType*>( malloc( numberOfCharacters * sizeof( FriBidiCharType ) ) );
- if( !bidirectionalInfo->characterTypes )
+ bidirectionalInfo->characterTypes = reinterpret_cast<FriBidiCharType*>(malloc(numberOfCharacters * sizeof(FriBidiCharType)));
+ if(!bidirectionalInfo->characterTypes)
{
delete bidirectionalInfo;
return 0;
}
- bidirectionalInfo->embeddedLevels = reinterpret_cast<FriBidiLevel*>( malloc( numberOfCharacters * sizeof( FriBidiLevel ) ) );
- if( !bidirectionalInfo->embeddedLevels )
+ bidirectionalInfo->embeddedLevels = reinterpret_cast<FriBidiLevel*>(malloc(numberOfCharacters * sizeof(FriBidiLevel)));
+ if(!bidirectionalInfo->embeddedLevels)
{
- free( bidirectionalInfo->characterTypes );
+ free(bidirectionalInfo->characterTypes);
delete bidirectionalInfo;
return 0;
}
// Retrieve the type of each character..
- fribidi_get_bidi_types( paragraph, numberOfCharacters, bidirectionalInfo->characterTypes );
+ fribidi_get_bidi_types(paragraph, numberOfCharacters, bidirectionalInfo->characterTypes);
// Retrieve the paragraph's direction.
- bidirectionalInfo->paragraphDirection = matchSystemLanguageDirection == true ?
- ( layoutDirection == LayoutDirection::RIGHT_TO_LEFT ? FRIBIDI_PAR_RTL : FRIBIDI_PAR_LTR ) :
- ( fribidi_get_par_direction( bidirectionalInfo->characterTypes, numberOfCharacters ) );
+ bidirectionalInfo->paragraphDirection = matchSystemLanguageDirection == true ? (layoutDirection == LayoutDirection::RIGHT_TO_LEFT ? FRIBIDI_PAR_RTL : FRIBIDI_PAR_LTR) : (fribidi_get_par_direction(bidirectionalInfo->characterTypes, numberOfCharacters));
// Retrieve the embedding levels.
- if (fribidi_get_par_embedding_levels( bidirectionalInfo->characterTypes, numberOfCharacters, &bidirectionalInfo->paragraphDirection, bidirectionalInfo->embeddedLevels ) == 0)
+ if(fribidi_get_par_embedding_levels(bidirectionalInfo->characterTypes, numberOfCharacters, &bidirectionalInfo->paragraphDirection, bidirectionalInfo->embeddedLevels) == 0)
{
- free( bidirectionalInfo->characterTypes );
+ free(bidirectionalInfo->characterTypes);
delete bidirectionalInfo;
return 0;
}
// Store the bidirectional info and return the index.
BidiInfoIndex index = 0u;
- if( 0u != mFreeIndices.Count() )
+ if(0u != mFreeIndices.Count())
{
Vector<BidiInfoIndex>::Iterator it = mFreeIndices.End() - 1u;
index = *it;
- mFreeIndices.Remove( it );
+ mFreeIndices.Remove(it);
- *( mParagraphBidirectionalInfo.Begin() + index ) = bidirectionalInfo;
+ *(mParagraphBidirectionalInfo.Begin() + index) = bidirectionalInfo;
}
else
{
- index = static_cast<BidiInfoIndex>( mParagraphBidirectionalInfo.Count() );
+ index = static_cast<BidiInfoIndex>(mParagraphBidirectionalInfo.Count());
- mParagraphBidirectionalInfo.PushBack( bidirectionalInfo );
+ mParagraphBidirectionalInfo.PushBack(bidirectionalInfo);
}
return index;
}
- void DestroyInfo( BidiInfoIndex bidiInfoIndex )
+ void DestroyInfo(BidiInfoIndex bidiInfoIndex)
{
- if( bidiInfoIndex >= mParagraphBidirectionalInfo.Count() )
+ if(bidiInfoIndex >= mParagraphBidirectionalInfo.Count())
{
return;
}
// Retrieve the paragraph's bidirectional info.
- Vector<BidirectionalInfo*>::Iterator it = mParagraphBidirectionalInfo.Begin() + bidiInfoIndex;
- BidirectionalInfo* bidirectionalInfo = *it;
+ Vector<BidirectionalInfo*>::Iterator it = mParagraphBidirectionalInfo.Begin() + bidiInfoIndex;
+ BidirectionalInfo* bidirectionalInfo = *it;
- if( NULL != bidirectionalInfo )
+ if(NULL != bidirectionalInfo)
{
// Free resources and destroy the container.
- free( bidirectionalInfo->embeddedLevels );
- free( bidirectionalInfo->characterTypes );
+ free(bidirectionalInfo->embeddedLevels);
+ free(bidirectionalInfo->characterTypes);
delete bidirectionalInfo;
*it = NULL;
}
// Add the index to the free indices vector.
- mFreeIndices.PushBack( bidiInfoIndex );
+ mFreeIndices.PushBack(bidiInfoIndex);
}
- void Reorder( BidiInfoIndex bidiInfoIndex,
- CharacterIndex firstCharacterIndex,
- Length numberOfCharacters,
- CharacterIndex* visualToLogicalMap )
+ void Reorder(BidiInfoIndex bidiInfoIndex,
+ CharacterIndex firstCharacterIndex,
+ Length numberOfCharacters,
+ CharacterIndex* visualToLogicalMap)
{
const FriBidiFlags flags = FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC;
// Retrieve the paragraph's bidirectional info.
- const BidirectionalInfo* const bidirectionalInfo = *( mParagraphBidirectionalInfo.Begin() + bidiInfoIndex );
+ const BidirectionalInfo* const bidirectionalInfo = *(mParagraphBidirectionalInfo.Begin() + bidiInfoIndex);
// Initialize the visual to logical mapping table to the identity. Otherwise fribidi_reorder_line fails to retrieve a valid mapping table.
- for( CharacterIndex index = 0u; index < numberOfCharacters; ++index )
+ for(CharacterIndex index = 0u; index < numberOfCharacters; ++index)
{
- visualToLogicalMap[ index ] = index;
+ visualToLogicalMap[index] = index;
}
// Copy embedded levels as fribidi_reorder_line() may change them.
- const uint32_t embeddedLevelsSize = numberOfCharacters * sizeof( FriBidiLevel );
- FriBidiLevel* embeddedLevels = reinterpret_cast<FriBidiLevel*>( malloc( embeddedLevelsSize ) );
- if( embeddedLevels )
+ const uint32_t embeddedLevelsSize = numberOfCharacters * sizeof(FriBidiLevel);
+ FriBidiLevel* embeddedLevels = reinterpret_cast<FriBidiLevel*>(malloc(embeddedLevelsSize));
+ if(embeddedLevels)
{
- memcpy( embeddedLevels, bidirectionalInfo->embeddedLevels + firstCharacterIndex, embeddedLevelsSize );
+ memcpy(embeddedLevels, bidirectionalInfo->embeddedLevels + firstCharacterIndex, embeddedLevelsSize);
// Reorder the line.
- if (fribidi_reorder_line( flags,
- bidirectionalInfo->characterTypes + firstCharacterIndex,
- numberOfCharacters,
- 0u,
- bidirectionalInfo->paragraphDirection,
- embeddedLevels,
- NULL,
- reinterpret_cast<FriBidiStrIndex*>( visualToLogicalMap ) ) == 0)
+ if(fribidi_reorder_line(flags,
+ bidirectionalInfo->characterTypes + firstCharacterIndex,
+ numberOfCharacters,
+ 0u,
+ bidirectionalInfo->paragraphDirection,
+ embeddedLevels,
+ NULL,
+ reinterpret_cast<FriBidiStrIndex*>(visualToLogicalMap)) == 0)
{
DALI_LOG_ERROR("fribidi_reorder_line is failed\n");
}
// Free resources.
- free( embeddedLevels );
+ free(embeddedLevels);
}
}
- bool GetMirroredText( Character* text,
- CharacterDirection* directions,
- Length numberOfCharacters ) const
+ bool GetMirroredText(Character* text,
+ CharacterDirection* directions,
+ Length numberOfCharacters) const
{
bool updated = false;
- for( CharacterIndex index = 0u; index < numberOfCharacters; ++index )
+ for(CharacterIndex index = 0u; index < numberOfCharacters; ++index)
{
// Get a reference to the character inside the text.
- Character& character = *( text + index );
+ Character& character = *(text + index);
// Retrieve the mirrored character.
FriBidiChar mirroredCharacter = character;
- bool mirrored = false;
- if( *( directions + index ) )
+ bool mirrored = false;
+ if(*(directions + index))
{
- mirrored = fribidi_get_mirror_char( character, &mirroredCharacter );
+ mirrored = fribidi_get_mirror_char(character, &mirroredCharacter);
}
updated = updated || mirrored;
return updated;
}
- bool GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const
+ bool GetParagraphDirection(BidiInfoIndex bidiInfoIndex) const
{
// Retrieve the paragraph's bidirectional info.
- const BidirectionalInfo* const bidirectionalInfo = *( mParagraphBidirectionalInfo.Begin() + bidiInfoIndex );
+ const BidirectionalInfo* const bidirectionalInfo = *(mParagraphBidirectionalInfo.Begin() + bidiInfoIndex);
- return GetBidiParagraphDirection( bidirectionalInfo->paragraphDirection );
+ return GetBidiParagraphDirection(bidirectionalInfo->paragraphDirection);
}
- void GetCharactersDirection( BidiInfoIndex bidiInfoIndex,
- CharacterDirection* directions,
- Length numberOfCharacters )
+ void GetCharactersDirection(BidiInfoIndex bidiInfoIndex,
+ CharacterDirection* directions,
+ Length numberOfCharacters)
{
- const BidirectionalInfo* const bidirectionalInfo = *( mParagraphBidirectionalInfo.Begin() + bidiInfoIndex );
+ const BidirectionalInfo* const bidirectionalInfo = *(mParagraphBidirectionalInfo.Begin() + bidiInfoIndex);
- const CharacterDirection paragraphDirection = GetBidiParagraphDirection( bidirectionalInfo->paragraphDirection );
- CharacterDirection previousDirection = paragraphDirection;
+ const CharacterDirection paragraphDirection = GetBidiParagraphDirection(bidirectionalInfo->paragraphDirection);
+ CharacterDirection previousDirection = paragraphDirection;
- for( CharacterIndex index = 0u; index < numberOfCharacters; ++index )
+ for(CharacterIndex index = 0u; index < numberOfCharacters; ++index)
{
- CharacterDirection& characterDirection = *( directions + index );
- CharacterDirection nextDirection = false;
+ CharacterDirection& characterDirection = *(directions + index);
+ CharacterDirection nextDirection = false;
characterDirection = false;
// Get the bidi direction.
- const BidiDirection bidiDirection = GetBidiCharacterDirection( *( bidirectionalInfo->characterTypes + index ) );
+ const BidiDirection bidiDirection = GetBidiCharacterDirection(*(bidirectionalInfo->characterTypes + index));
- if( RIGHT_TO_LEFT == bidiDirection )
+ if(RIGHT_TO_LEFT == bidiDirection)
{
characterDirection = true;
- nextDirection = true;
+ nextDirection = true;
}
- else if( NEUTRAL == bidiDirection )
+ else if(NEUTRAL == bidiDirection)
{
// For neutral characters it check's the next and previous directions.
// If they are equals set that direction. If they are not, sets the paragraph's direction.
// Look for the next non-neutral character.
Length nextIndex = index + 1u;
- for( ; nextIndex < numberOfCharacters; ++nextIndex )
+ for(; nextIndex < numberOfCharacters; ++nextIndex)
{
- BidiDirection nextBidiDirection = GetBidiCharacterDirection( *( bidirectionalInfo->characterTypes + nextIndex ) );
- if( nextBidiDirection != NEUTRAL )
+ BidiDirection nextBidiDirection = GetBidiCharacterDirection(*(bidirectionalInfo->characterTypes + nextIndex));
+ if(nextBidiDirection != NEUTRAL)
{
nextDirection = RIGHT_TO_LEFT == nextBidiDirection;
break;
// The indices from currentIndex + 1u to nextIndex - 1u are neutral characters.
++index;
- for( ; index < nextIndex; ++index )
+ for(; index < nextIndex; ++index)
{
- CharacterDirection& nextCharacterDirection = *( directions + index );
- nextCharacterDirection = characterDirection;
+ CharacterDirection& nextCharacterDirection = *(directions + index);
+ nextCharacterDirection = characterDirection;
}
// Set the direction of the next non-neutral character.
- if( nextIndex < numberOfCharacters )
+ if(nextIndex < numberOfCharacters)
{
- *( directions + nextIndex ) = nextDirection;
+ *(directions + nextIndex) = nextDirection;
}
}
};
BidirectionalSupport::BidirectionalSupport()
-: mPlugin( NULL )
+: mPlugin(NULL)
{
}
{
TextAbstraction::BidirectionalSupport bidirectionalSupportHandle;
- SingletonService service( SingletonService::Get() );
- if( service )
+ SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- BaseHandle handle = service.GetSingleton( typeid( TextAbstraction::BidirectionalSupport ) );
+ BaseHandle handle = service.GetSingleton(typeid(TextAbstraction::BidirectionalSupport));
if(handle)
{
// If so, downcast the handle
- BidirectionalSupport* impl = dynamic_cast< Internal::BidirectionalSupport* >( handle.GetObjectPtr() );
- bidirectionalSupportHandle = TextAbstraction::BidirectionalSupport( impl );
+ BidirectionalSupport* impl = dynamic_cast<Internal::BidirectionalSupport*>(handle.GetObjectPtr());
+ bidirectionalSupportHandle = TextAbstraction::BidirectionalSupport(impl);
}
else // create and register the object
{
- bidirectionalSupportHandle = TextAbstraction::BidirectionalSupport( new BidirectionalSupport );
- service.Register( typeid( bidirectionalSupportHandle ), bidirectionalSupportHandle );
+ bidirectionalSupportHandle = TextAbstraction::BidirectionalSupport(new BidirectionalSupport);
+ service.Register(typeid(bidirectionalSupportHandle), bidirectionalSupportHandle);
}
}
return bidirectionalSupportHandle;
}
-BidiInfoIndex BidirectionalSupport::CreateInfo( const Character* const paragraph,
- Length numberOfCharacters,
- bool matchSystemLanguageDirection,
- Dali::LayoutDirection::Type layoutDirection )
+BidiInfoIndex BidirectionalSupport::CreateInfo(const Character* const paragraph,
+ Length numberOfCharacters,
+ bool matchSystemLanguageDirection,
+ Dali::LayoutDirection::Type layoutDirection)
{
CreatePlugin();
- return mPlugin->CreateInfo( paragraph,
- numberOfCharacters,
- matchSystemLanguageDirection,
- layoutDirection );
+ return mPlugin->CreateInfo(paragraph,
+ numberOfCharacters,
+ matchSystemLanguageDirection,
+ layoutDirection);
}
-void BidirectionalSupport::DestroyInfo( BidiInfoIndex bidiInfoIndex )
+void BidirectionalSupport::DestroyInfo(BidiInfoIndex bidiInfoIndex)
{
CreatePlugin();
- mPlugin->DestroyInfo( bidiInfoIndex );
+ mPlugin->DestroyInfo(bidiInfoIndex);
}
-void BidirectionalSupport::Reorder( BidiInfoIndex bidiInfoIndex,
- CharacterIndex firstCharacterIndex,
- Length numberOfCharacters,
- CharacterIndex* visualToLogicalMap )
+void BidirectionalSupport::Reorder(BidiInfoIndex bidiInfoIndex,
+ CharacterIndex firstCharacterIndex,
+ Length numberOfCharacters,
+ CharacterIndex* visualToLogicalMap)
{
CreatePlugin();
- mPlugin->Reorder( bidiInfoIndex,
- firstCharacterIndex,
- numberOfCharacters,
- visualToLogicalMap );
+ mPlugin->Reorder(bidiInfoIndex,
+ firstCharacterIndex,
+ numberOfCharacters,
+ visualToLogicalMap);
}
-bool BidirectionalSupport::GetMirroredText( Character* text,
- CharacterDirection* directions,
- Length numberOfCharacters )
+bool BidirectionalSupport::GetMirroredText(Character* text,
+ CharacterDirection* directions,
+ Length numberOfCharacters)
{
CreatePlugin();
- return mPlugin->GetMirroredText( text, directions, numberOfCharacters );
+ return mPlugin->GetMirroredText(text, directions, numberOfCharacters);
}
-bool BidirectionalSupport::GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const
+bool BidirectionalSupport::GetParagraphDirection(BidiInfoIndex bidiInfoIndex) const
{
- if( !mPlugin )
+ if(!mPlugin)
{
return false;
}
- return mPlugin->GetParagraphDirection( bidiInfoIndex );
+ return mPlugin->GetParagraphDirection(bidiInfoIndex);
}
-void BidirectionalSupport::GetCharactersDirection( BidiInfoIndex bidiInfoIndex,
- CharacterDirection* directions,
- Length numberOfCharacters )
+void BidirectionalSupport::GetCharactersDirection(BidiInfoIndex bidiInfoIndex,
+ CharacterDirection* directions,
+ Length numberOfCharacters)
{
CreatePlugin();
- mPlugin->GetCharactersDirection( bidiInfoIndex,
- directions,
- numberOfCharacters );
+ mPlugin->GetCharactersDirection(bidiInfoIndex,
+ directions,
+ numberOfCharacters);
}
void BidirectionalSupport::CreatePlugin()
{
- if( !mPlugin )
+ if(!mPlugin)
{
mPlugin = new Plugin();
}
/*
- * 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.
#include <dali/internal/text/text-abstraction/cairo-renderer.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/common/constants.h>
-#include <cairo.h>
#include <cairo-ft.h>
+#include <cairo.h>
+#include <dali/public-api/common/constants.h>
#include <cstring>
#include <memory>
namespace
{
-
const float TO_FLOAT = 1.f / 255.f;
const float TO_UCHAR = 255.f;
-const float TWO_PI = 2.f * Dali::Math::PI; ///< 360 degrees in radians
+const float TWO_PI = 2.f * Dali::Math::PI; ///< 360 degrees in radians
/**
* @brief Run of glyphs that have the same style.
struct GlyphRun
{
GlyphRun()
- : fontFace{ nullptr },
- fontSize{ 0.0 },
- glyphIndex{ 0u },
- numberOfGlyphs{ 0u },
- fontId{ 0u },
- colorIndex{ 0u },
- isItalicRequired{ false },
- isBoldRequired{ false }
- {}
-
- FT_Face fontFace; ///< The font face used by the glyphs in the run.
- double fontSize; ///< The font size used by the glyphs in the run. According the Cairo's documentation this is in user space units. It works if I set the size in pixels.
- unsigned int glyphIndex; ///< Index to the first glyph of the run.
- unsigned int numberOfGlyphs; ///< Number of glyphs in the run.
- unsigned int fontId; ///< The id of the font.
- unsigned int colorIndex; ///< The index to the color of the glyphs.
- bool isItalicRequired:1; ///< Whether the italic style is required.
- bool isBoldRequired:1; ///< Whether the bold style is required.
+ : fontFace{nullptr},
+ fontSize{0.0},
+ glyphIndex{0u},
+ numberOfGlyphs{0u},
+ fontId{0u},
+ colorIndex{0u},
+ isItalicRequired{false},
+ isBoldRequired{false}
+ {
+ }
+
+ FT_Face fontFace; ///< The font face used by the glyphs in the run.
+ double fontSize; ///< The font size used by the glyphs in the run. According the Cairo's documentation this is in user space units. It works if I set the size in pixels.
+ unsigned int glyphIndex; ///< Index to the first glyph of the run.
+ unsigned int numberOfGlyphs; ///< Number of glyphs in the run.
+ unsigned int fontId; ///< The id of the font.
+ unsigned int colorIndex; ///< The index to the color of the glyphs.
+ bool isItalicRequired : 1; ///< Whether the italic style is required.
+ bool isBoldRequired : 1; ///< Whether the bold style is required.
};
/**
DELETE
};
- GlyphBuffer( Dali::TextAbstraction::FontClient::GlyphBufferData& data, DestructorType type )
- : data( data ),
- type( type )
+ GlyphBuffer(Dali::TextAbstraction::FontClient::GlyphBufferData& data, DestructorType type)
+ : data(data),
+ type(type)
{
}
~GlyphBuffer()
{
- switch( type )
+ switch(type)
{
case FREE:
{
- free( data.buffer );
+ free(data.buffer);
break;
}
case DELETE:
}
Dali::TextAbstraction::FontClient::GlyphBufferData& data;
- DestructorType type;
+ DestructorType type;
};
/**
*
* @return The pixel buffer.
*/
-Dali::Devel::PixelBuffer CreateVoidPixelBuffer( const Dali::TextAbstraction::TextRenderer::Parameters& parameters )
+Dali::Devel::PixelBuffer CreateVoidPixelBuffer(const Dali::TextAbstraction::TextRenderer::Parameters& parameters)
{
- Dali::Pixel::Format pixelFormat = parameters.pixelFormat == Dali::TextAbstraction::TextRenderer::Parameters::A8 ? Dali::Pixel::A8 : Dali::Pixel::RGBA8888;
- Dali::Devel::PixelBuffer pixelBuffer = Dali::Devel::PixelBuffer::New( parameters.width,
- parameters.height,
- pixelFormat );
+ Dali::Pixel::Format pixelFormat = parameters.pixelFormat == Dali::TextAbstraction::TextRenderer::Parameters::A8 ? Dali::Pixel::A8 : Dali::Pixel::RGBA8888;
+ Dali::Devel::PixelBuffer pixelBuffer = Dali::Devel::PixelBuffer::New(parameters.width,
+ parameters.height,
+ pixelFormat);
- const unsigned int bufferSize = parameters.width * parameters.height * Dali::Pixel::GetBytesPerPixel( pixelFormat );
- unsigned char* buffer = pixelBuffer.GetBuffer();
- memset( buffer, 0, bufferSize );
+ const unsigned int bufferSize = parameters.width * parameters.height * Dali::Pixel::GetBytesPerPixel(pixelFormat);
+ unsigned char* buffer = pixelBuffer.GetBuffer();
+ memset(buffer, 0, bufferSize);
return pixelBuffer;
}
* @param[in] circularCr The extra cairo context created to layout horizontal text.
* @param[in] parameters The parameters of the circular path.
*/
-void WrapToCircularPath( cairo_t* cr, cairo_t* circularCr, const Dali::TextAbstraction::CircularTextParameters& parameters )
+void WrapToCircularPath(cairo_t* cr, cairo_t* circularCr, const Dali::TextAbstraction::CircularTextParameters& parameters)
{
bool first = true;
// Copy the path to get a cairo_path_t pointer used to iterate through all its items.
- std::unique_ptr<cairo_path_t, void(*)(cairo_path_t*)> path( cairo_copy_path( circularCr ), cairo_path_destroy );
+ std::unique_ptr<cairo_path_t, void (*)(cairo_path_t*)> path(cairo_copy_path(circularCr), cairo_path_destroy);
// Iterates through all the path items and transform each vertex to follow the circle.
// Transformed vertices are added to a new path in the 'cr' context (the one used to render the circular text)
- for( int i = 0; i < path->num_data; i += path->data[i].header.length )
+ for(int i = 0; i < path->num_data; i += path->data[i].header.length)
{
cairo_path_data_t* data = &path->data[i];
- switch( data->header.type )
+ switch(data->header.type)
{
case CAIRO_PATH_MOVE_TO:
{
- if( first )
+ if(first)
{
- cairo_new_path( cr );
+ cairo_new_path(cr);
}
- first = false;
+ first = false;
double x = data[1].point.x;
double y = data[1].point.y;
- Dali::TextAbstraction::TransformToArc( parameters, x, y );
- cairo_move_to( cr, x, y );
+ Dali::TextAbstraction::TransformToArc(parameters, x, y);
+ cairo_move_to(cr, x, y);
break;
}
case CAIRO_PATH_LINE_TO:
{
double x = data[1].point.x;
double y = data[1].point.y;
- Dali::TextAbstraction::TransformToArc( parameters, x, y );
- cairo_line_to( cr, x, y );
+ Dali::TextAbstraction::TransformToArc(parameters, x, y);
+ cairo_line_to(cr, x, y);
break;
}
case CAIRO_PATH_CURVE_TO:
double y2 = data[2].point.y;
double x3 = data[3].point.x;
double y3 = data[3].point.y;
- Dali::TextAbstraction::TransformToArc( parameters, x1, y1 );
- Dali::TextAbstraction::TransformToArc( parameters, x2, y2 );
- Dali::TextAbstraction::TransformToArc( parameters, x3, y3 );
- cairo_curve_to( cr, x1, y1, x2, y2, x3, y3 );
+ Dali::TextAbstraction::TransformToArc(parameters, x1, y1);
+ Dali::TextAbstraction::TransformToArc(parameters, x2, y2);
+ Dali::TextAbstraction::TransformToArc(parameters, x3, y3);
+ cairo_curve_to(cr, x1, y1, x2, y2, x3, y3);
break;
}
case CAIRO_PATH_CLOSE_PATH:
{
- cairo_close_path( cr );
+ cairo_close_path(cr);
break;
}
default:
{
- DALI_LOG_WARNING( "Type of path not handled.\n" );
+ DALI_LOG_WARNING("Type of path not handled.\n");
// Nothing else to do.
break;
}
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
namespace
{
-
/**
* @brief Converts the size so that it can be used by Cairo
* @param[in] fontClient A reference to the font client
* @param[in/out] glyphRuns A vector of glyph-runs
*/
bool ConvertSizeForCairo(
- TextAbstraction::FontClient& fontClient,
- FT_Library& ftLibrary,
- const unsigned int numberOfGlyphs,
- const GlyphInfo* const daliGlyphsBuffer,
- const ColorIndex* const colorIndicesBuffer,
- std::vector<GlyphRun>& glyphRuns)
+ TextAbstraction::FontClient& fontClient,
+ FT_Library& ftLibrary,
+ const unsigned int numberOfGlyphs,
+ const GlyphInfo* const daliGlyphsBuffer,
+ const ColorIndex* const colorIndicesBuffer,
+ std::vector<GlyphRun>& glyphRuns)
{
// The size set in Cairo and FreeType has different units.
// Before the size is set in Cairo it needs to be converted according the formula
// https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html
unsigned int horizontalDpi = 0u;
- unsigned int verticalDpi = 0u;
- fontClient.GetDpi( horizontalDpi, verticalDpi );
- const double dVerticalDpi = static_cast<double>( verticalDpi );
-
- const double FROM_26_DOT_6_TO_PIXELS = dVerticalDpi / ( 64.0 * 72.0 );
+ unsigned int verticalDpi = 0u;
+ fontClient.GetDpi(horizontalDpi, verticalDpi);
+ const double dVerticalDpi = static_cast<double>(verticalDpi);
+ const double FROM_26_DOT_6_TO_PIXELS = dVerticalDpi / (64.0 * 72.0);
GlyphRun currentGlyphRun;
- currentGlyphRun.fontId = 0u;
- currentGlyphRun.colorIndex = 0u;
+ currentGlyphRun.fontId = 0u;
+ currentGlyphRun.colorIndex = 0u;
currentGlyphRun.isItalicRequired = false;
- currentGlyphRun.isBoldRequired = false;
- for( unsigned index = 0u; index < numberOfGlyphs; ++index )
+ currentGlyphRun.isBoldRequired = false;
+ for(unsigned index = 0u; index < numberOfGlyphs; ++index)
{
- const GlyphInfo& daliGlyph = *( daliGlyphsBuffer + index );
- const FontId fontId = daliGlyph.fontId;
- const ColorIndex colorIndex = ( nullptr == colorIndicesBuffer ) ? 0u : *( colorIndicesBuffer + index );
- const bool isItalicRequired = daliGlyph.isItalicRequired;
- const bool isBoldRequired = daliGlyph.isBoldRequired;
-
- if( ( fontId != currentGlyphRun.fontId ) ||
- ( ( 0u == fontId ) && ( 0u != daliGlyph.index ) ) ||
- ( colorIndex != currentGlyphRun.colorIndex ) ||
- ( isItalicRequired != currentGlyphRun.isItalicRequired ) ||
- ( isBoldRequired != currentGlyphRun.isBoldRequired ) )
+ const GlyphInfo& daliGlyph = *(daliGlyphsBuffer + index);
+ const FontId fontId = daliGlyph.fontId;
+ const ColorIndex colorIndex = (nullptr == colorIndicesBuffer) ? 0u : *(colorIndicesBuffer + index);
+ const bool isItalicRequired = daliGlyph.isItalicRequired;
+ const bool isBoldRequired = daliGlyph.isBoldRequired;
+
+ if((fontId != currentGlyphRun.fontId) ||
+ ((0u == fontId) && (0u != daliGlyph.index)) ||
+ (colorIndex != currentGlyphRun.colorIndex) ||
+ (isItalicRequired != currentGlyphRun.isItalicRequired) ||
+ (isBoldRequired != currentGlyphRun.isBoldRequired))
{
// There is a new run. First set the number of glyphs of the previous run and store it.
currentGlyphRun.numberOfGlyphs = index - currentGlyphRun.glyphIndex;
- if( 0u != currentGlyphRun.numberOfGlyphs )
+ if(0u != currentGlyphRun.numberOfGlyphs)
{
- glyphRuns.push_back( currentGlyphRun );
+ glyphRuns.push_back(currentGlyphRun);
}
- currentGlyphRun.fontFace = nullptr;
- currentGlyphRun.fontSize = 0.0;
- currentGlyphRun.glyphIndex = index;
- currentGlyphRun.numberOfGlyphs = 0u;
- currentGlyphRun.fontId = 0u;
- currentGlyphRun.colorIndex = 0u;
+ currentGlyphRun.fontFace = nullptr;
+ currentGlyphRun.fontSize = 0.0;
+ currentGlyphRun.glyphIndex = index;
+ currentGlyphRun.numberOfGlyphs = 0u;
+ currentGlyphRun.fontId = 0u;
+ currentGlyphRun.colorIndex = 0u;
currentGlyphRun.isItalicRequired = false;
- currentGlyphRun.isBoldRequired = false;
+ currentGlyphRun.isBoldRequired = false;
- if( 0u != fontId )
+ if(0u != fontId)
{
// Get the font's path file name from the font Id.
FontDescription fontDescription;
- fontClient.GetDescription( fontId, fontDescription );
+ fontClient.GetDescription(fontId, fontDescription);
- switch( fontDescription.type )
+ switch(fontDescription.type)
{
case FontDescription::FACE_FONT:
{
// Create a FreeType font's face.
- auto error = FT_New_Face( ftLibrary, fontDescription.path.c_str(), 0u, ¤tGlyphRun.fontFace );
- if( error )
+ auto error = FT_New_Face(ftLibrary, fontDescription.path.c_str(), 0u, ¤tGlyphRun.fontFace);
+ if(error)
{
- DALI_LOG_ERROR( "Error in FT while creating a new face\n" );
+ DALI_LOG_ERROR("Error in FT while creating a new face\n");
// Error so just return false
return false;
}
// Set the font's size. It needs to be set in the Freetype font and in the Cairo's context.
- unsigned int fontSize = fontClient.GetPointSize( fontId );
+ unsigned int fontSize = fontClient.GetPointSize(fontId);
// Font's size to be set in the Cairo's context.
- currentGlyphRun.fontSize = FROM_26_DOT_6_TO_PIXELS * static_cast<double>( fontSize );
+ currentGlyphRun.fontSize = FROM_26_DOT_6_TO_PIXELS * static_cast<double>(fontSize);
break;
}
case FontDescription::BITMAP_FONT:
}
}
}
- currentGlyphRun.fontId = fontId;
- currentGlyphRun.colorIndex = colorIndex;
+ currentGlyphRun.fontId = fontId;
+ currentGlyphRun.colorIndex = colorIndex;
currentGlyphRun.isItalicRequired = isItalicRequired;
- currentGlyphRun.isBoldRequired = isBoldRequired;
+ currentGlyphRun.isBoldRequired = isBoldRequired;
}
}
// Calculate the number of glyphs of the last run and store it.
currentGlyphRun.numberOfGlyphs = numberOfGlyphs - currentGlyphRun.glyphIndex;
- if( 0u != currentGlyphRun.numberOfGlyphs )
+ if(0u != currentGlyphRun.numberOfGlyphs)
{
- glyphRuns.push_back( currentGlyphRun );
+ glyphRuns.push_back(currentGlyphRun);
}
return true; // Successfully converted
* @param[in] doBlendWithTextColor Whether to blend with the text color or not)
*/
void CopyImageToSurface(
- const TextAbstraction::TextRenderer::Parameters& parameters,
- const Pixel::Format pixelFormat,
- TextAbstraction::FontClient::GlyphBufferData& data,
- unsigned char * buffer,
- const int rgbaCase,
- const double glyphX,
- const double glyphY,
- const int strideWidth,
- const Vector4& color,
- const bool doBlendWithTextColor)
+ const TextAbstraction::TextRenderer::Parameters& parameters,
+ const Pixel::Format pixelFormat,
+ TextAbstraction::FontClient::GlyphBufferData& data,
+ unsigned char* buffer,
+ const int rgbaCase,
+ const double glyphX,
+ const double glyphY,
+ const int strideWidth,
+ const Vector4& color,
+ const bool doBlendWithTextColor)
{
// Select the cropped source image area to copy into the surface buffer
unsigned int glyphUintX = 0u;
unsigned int glyphUintY = 0u;
- unsigned int srcWidth = data.width;
- unsigned int srcHeight = data.height;
- unsigned int xSrcIndex = 0u;
- unsigned int ySrcIndex = 0u;
- if( glyphX < 0.f )
+ unsigned int srcWidth = data.width;
+ unsigned int srcHeight = data.height;
+ unsigned int xSrcIndex = 0u;
+ unsigned int ySrcIndex = 0u;
+ if(glyphX < 0.f)
{
- xSrcIndex = static_cast<unsigned int>( abs( glyphX ) );
+ xSrcIndex = static_cast<unsigned int>(abs(glyphX));
srcWidth -= xSrcIndex;
}
else
{
- glyphUintX = static_cast<unsigned int>( glyphX );
+ glyphUintX = static_cast<unsigned int>(glyphX);
}
- if( glyphUintX + srcWidth > static_cast<unsigned int>( strideWidth ) )
+ if(glyphUintX + srcWidth > static_cast<unsigned int>(strideWidth))
{
- srcWidth -= ( ( glyphUintX + srcWidth ) - strideWidth );
+ srcWidth -= ((glyphUintX + srcWidth) - strideWidth);
}
- if( glyphY - static_cast<float>( srcHeight ) < 0.f )
+ if(glyphY - static_cast<float>(srcHeight) < 0.f)
{
- ySrcIndex = static_cast<unsigned int>( abs( glyphY - static_cast<float>( srcHeight ) ) );
+ ySrcIndex = static_cast<unsigned int>(abs(glyphY - static_cast<float>(srcHeight)));
srcHeight -= ySrcIndex;
}
else
{
- glyphUintY = static_cast<unsigned int>( glyphY - static_cast<float>( srcHeight ) );
+ glyphUintY = static_cast<unsigned int>(glyphY - static_cast<float>(srcHeight));
}
- if( glyphUintY + srcHeight > parameters.height )
+ if(glyphUintY + srcHeight > parameters.height)
{
- srcHeight -= ( ( glyphUintY + srcHeight ) - parameters.height );
+ srcHeight -= ((glyphUintY + srcHeight) - parameters.height);
}
// Calculate the source and destination indices.
- const unsigned int srcPixelSize = Pixel::GetBytesPerPixel( data.format );
- const unsigned int dstPixelSize = Pixel::GetBytesPerPixel( pixelFormat );
+ const unsigned int srcPixelSize = Pixel::GetBytesPerPixel(data.format);
+ const unsigned int dstPixelSize = Pixel::GetBytesPerPixel(pixelFormat);
- unsigned int srcIndex = srcPixelSize * ( ySrcIndex * srcWidth + xSrcIndex );
- unsigned int dstIndex = dstPixelSize * ( glyphUintY * strideWidth + glyphUintX );
+ unsigned int srcIndex = srcPixelSize * (ySrcIndex * srcWidth + xSrcIndex);
+ unsigned int dstIndex = dstPixelSize * (glyphUintY * strideWidth + glyphUintX);
- const unsigned int srcWidthOffset = srcPixelSize * ( data.width - srcWidth );
- const unsigned int dstWidthOffset = dstPixelSize * ( strideWidth - srcWidth );
+ const unsigned int srcWidthOffset = srcPixelSize * (data.width - srcWidth);
+ const unsigned int dstWidthOffset = dstPixelSize * (strideWidth - srcWidth);
// Copy the image to the surface
- for( unsigned int j = 0; j < srcHeight; ++j )
+ for(unsigned int j = 0; j < srcHeight; ++j)
{
- for( unsigned int i = 0; i < srcWidth; ++i )
+ for(unsigned int i = 0; i < srcWidth; ++i)
{
- switch( rgbaCase )
+ switch(rgbaCase)
{
case 0: // Both the image's buffer and cairo's buffer are A8
{
- const unsigned char alpha = *( data.buffer + srcIndex );
- if( alpha != 0u )
+ const unsigned char alpha = *(data.buffer + srcIndex);
+ if(alpha != 0u)
{
// @todo needs a proper blending!
- *( buffer + dstIndex ) = alpha;
+ *(buffer + dstIndex) = alpha;
}
break;
}
case 1: // The image's buffer is A8 and the cairo's buffer is ARGB
{
- const unsigned char alpha = *( data.buffer + srcIndex );
- if( alpha != 0u )
+ const unsigned char alpha = *(data.buffer + srcIndex);
+ if(alpha != 0u)
{
// @todo needs a proper blending!
- const float srcAlpha = TO_FLOAT * static_cast<float>( alpha );
+ const float srcAlpha = TO_FLOAT * static_cast<float>(alpha);
// Write the RGBA modulated with the given default color.
const float* const colorPtr = color.AsFloat();
- *( buffer + dstIndex + 0u ) = static_cast<unsigned char>( TO_UCHAR * colorPtr[0u] * srcAlpha );
- *( buffer + dstIndex + 1u ) = static_cast<unsigned char>( TO_UCHAR * colorPtr[1u] * srcAlpha );
- *( buffer + dstIndex + 2u ) = static_cast<unsigned char>( TO_UCHAR * colorPtr[2u] * srcAlpha );
- *( buffer + dstIndex + 3u ) = static_cast<unsigned char>( TO_UCHAR * colorPtr[3u] * srcAlpha );
+ *(buffer + dstIndex + 0u) = static_cast<unsigned char>(TO_UCHAR * colorPtr[0u] * srcAlpha);
+ *(buffer + dstIndex + 1u) = static_cast<unsigned char>(TO_UCHAR * colorPtr[1u] * srcAlpha);
+ *(buffer + dstIndex + 2u) = static_cast<unsigned char>(TO_UCHAR * colorPtr[2u] * srcAlpha);
+ *(buffer + dstIndex + 3u) = static_cast<unsigned char>(TO_UCHAR * colorPtr[3u] * srcAlpha);
}
break;
}
case 2: // The image's buffer is RGBA and the cairo's buffer is ARGB
{
const unsigned char alpha = *(data.buffer + srcIndex + 3u);
- if( alpha != 0u )
+ if(alpha != 0u)
{
- if( doBlendWithTextColor )
+ if(doBlendWithTextColor)
{
const float* const colorPtr = color.AsFloat();
const float srcAlpha = TO_FLOAT * static_cast<float>(alpha) * colorPtr[3u];
- *(buffer + dstIndex + 0u) = static_cast<unsigned char>( static_cast<float>( *(data.buffer + srcIndex + 0u) ) * colorPtr[0u] );
- *(buffer + dstIndex + 1u) = static_cast<unsigned char>( static_cast<float>( *(data.buffer + srcIndex + 1u) ) * colorPtr[1u] );
- *(buffer + dstIndex + 2u) = static_cast<unsigned char>( static_cast<float>( *(data.buffer + srcIndex + 2u) ) * colorPtr[2u] );
+ *(buffer + dstIndex + 0u) = static_cast<unsigned char>(static_cast<float>(*(data.buffer + srcIndex + 0u)) * colorPtr[0u]);
+ *(buffer + dstIndex + 1u) = static_cast<unsigned char>(static_cast<float>(*(data.buffer + srcIndex + 1u)) * colorPtr[1u]);
+ *(buffer + dstIndex + 2u) = static_cast<unsigned char>(static_cast<float>(*(data.buffer + srcIndex + 2u)) * colorPtr[2u]);
// Write the alpha.
- *(buffer + dstIndex + 3u) = static_cast<unsigned char>( TO_UCHAR * srcAlpha );
+ *(buffer + dstIndex + 3u) = static_cast<unsigned char>(TO_UCHAR * srcAlpha);
}
else
{
case 3: // The image's buffer is BGRA and the cairo's buffer is ARGB
{
const unsigned char alpha = *(data.buffer + srcIndex + 3u);
- if( alpha != 0u )
+ if(alpha != 0u)
{
- if( doBlendWithTextColor )
+ if(doBlendWithTextColor)
{
const float* const colorPtr = color.AsFloat();
const float srcAlpha = TO_FLOAT * static_cast<float>(alpha) * colorPtr[3u];
- *(buffer + dstIndex + 0u) = static_cast<unsigned char>( static_cast<float>( *(data.buffer + srcIndex + 2u) ) * colorPtr[0u] );
- *(buffer + dstIndex + 1u) = static_cast<unsigned char>( static_cast<float>( *(data.buffer + srcIndex + 1u) ) * colorPtr[1u] );
- *(buffer + dstIndex + 2u) = static_cast<unsigned char>( static_cast<float>( *(data.buffer + srcIndex + 0u) ) * colorPtr[2u] );
+ *(buffer + dstIndex + 0u) = static_cast<unsigned char>(static_cast<float>(*(data.buffer + srcIndex + 2u)) * colorPtr[0u]);
+ *(buffer + dstIndex + 1u) = static_cast<unsigned char>(static_cast<float>(*(data.buffer + srcIndex + 1u)) * colorPtr[1u]);
+ *(buffer + dstIndex + 2u) = static_cast<unsigned char>(static_cast<float>(*(data.buffer + srcIndex + 0u)) * colorPtr[2u]);
// Write the alpha.
- *(buffer + dstIndex + 3u) = static_cast<unsigned char>( TO_UCHAR * srcAlpha );
+ *(buffer + dstIndex + 3u) = static_cast<unsigned char>(TO_UCHAR * srcAlpha);
}
else
{
}
default:
{
- DALI_ASSERT_ALWAYS( !"Cairo Renderer: The accepted values for this switch case are: 0, 1, 2!" );
+ DALI_ASSERT_ALWAYS(!"Cairo Renderer: The accepted values for this switch case are: 0, 1, 2!");
}
} // switch
srcIndex += srcPixelSize;
* @param[in/out] circularTextParameters The circular text parameters
*/
void RenderGlyphs(
- const TextAbstraction::TextRenderer::Parameters& parameters,
- const GlyphRun& run,
- cairo_glyph_t*& cairoGlyphsBuffer,
- cairo_t*& cr,
- cairo_t*& circularCr,
- const bool isCircularText,
- CircularTextParameters& circularTextParameters)
+ const TextAbstraction::TextRenderer::Parameters& parameters,
+ const GlyphRun& run,
+ cairo_glyph_t*& cairoGlyphsBuffer,
+ cairo_t*& cr,
+ cairo_t*& circularCr,
+ const bool isCircularText,
+ CircularTextParameters& circularTextParameters)
{
// Sets the color. The color is actually BGRA
const Vector4& color = parameters.colors[run.colorIndex];
- cairo_set_source_rgba( cr,
- static_cast<double>( color.b ),
- static_cast<double>( color.g ),
- static_cast<double>( color.r ),
- static_cast<double>( color.a ) );
+ cairo_set_source_rgba(cr,
+ static_cast<double>(color.b),
+ static_cast<double>(color.g),
+ static_cast<double>(color.r),
+ static_cast<double>(color.a));
// Create the Cairo's font from the FreeType font.
int options = 0;
- options = CAIRO_HINT_STYLE_SLIGHT;
- std::unique_ptr<cairo_font_face_t, void(*)(cairo_font_face_t*)> fontFacePtr( cairo_ft_font_face_create_for_ft_face( run.fontFace, options ), cairo_font_face_destroy );
- cairo_font_face_t* fontFace = fontFacePtr.get();
+ options = CAIRO_HINT_STYLE_SLIGHT;
+ std::unique_ptr<cairo_font_face_t, void (*)(cairo_font_face_t*)> fontFacePtr(cairo_ft_font_face_create_for_ft_face(run.fontFace, options), cairo_font_face_destroy);
+ cairo_font_face_t* fontFace = fontFacePtr.get();
- static const cairo_user_data_key_t key = { 0 };
- cairo_status_t status = cairo_font_face_set_user_data( fontFace, &key, run.fontFace, reinterpret_cast<cairo_destroy_func_t>( FT_Done_Face ) );
- if( status )
+ static const cairo_user_data_key_t key = {0};
+ cairo_status_t status = cairo_font_face_set_user_data(fontFace, &key, run.fontFace, reinterpret_cast<cairo_destroy_func_t>(FT_Done_Face));
+ if(status)
{
- cairo_font_face_destroy( fontFace );
+ cairo_font_face_destroy(fontFace);
}
unsigned int ftSynthesizeFlag = 0u;
- if( run.isBoldRequired && !( run.fontFace->style_flags & FT_STYLE_FLAG_BOLD ) )
+ if(run.isBoldRequired && !(run.fontFace->style_flags & FT_STYLE_FLAG_BOLD))
{
ftSynthesizeFlag |= CAIRO_FT_SYNTHESIZE_BOLD;
}
- cairo_ft_font_face_set_synthesize( fontFace, ftSynthesizeFlag );
+ cairo_ft_font_face_set_synthesize(fontFace, ftSynthesizeFlag);
- cairo_font_face_reference( fontFace );
+ cairo_font_face_reference(fontFace);
- const bool synthesizeItalic = ( run.isItalicRequired && !( run.fontFace->style_flags & FT_STYLE_FLAG_ITALIC ) );
+ const bool synthesizeItalic = (run.isItalicRequired && !(run.fontFace->style_flags & FT_STYLE_FLAG_ITALIC));
- if( CAIRO_STATUS_SUCCESS != cairo_font_face_status( fontFace ) )
+ if(CAIRO_STATUS_SUCCESS != cairo_font_face_status(fontFace))
{
- DALI_LOG_ERROR( "Failed to load the Freetype Font\n" );
+ DALI_LOG_ERROR("Failed to load the Freetype Font\n");
}
// Sets the font.
- cairo_set_font_face( isCircularText ? circularCr : cr, fontFace );
+ cairo_set_font_face(isCircularText ? circularCr : cr, fontFace);
// Sets the size
- cairo_set_font_size( isCircularText ? circularCr : cr, run.fontSize );
+ cairo_set_font_size(isCircularText ? circularCr : cr, run.fontSize);
// Render the glyphs.
- if( isCircularText )
+ if(isCircularText)
{
circularTextParameters.synthesizeItalic = synthesizeItalic;
const unsigned int glyphJump = circularTextParameters.synthesizeItalic ? 1u : run.numberOfGlyphs;
- for( unsigned int index = 0u; index < run.numberOfGlyphs; index += glyphJump )
+ for(unsigned int index = 0u; index < run.numberOfGlyphs; index += glyphJump)
{
// Clears the current path where the text is laid out on a horizontal straight line.
- cairo_new_path( circularCr );
- cairo_move_to( circularCr, 0.0, 0.0 );
+ cairo_new_path(circularCr);
+ cairo_move_to(circularCr, 0.0, 0.0);
- cairo_glyph_path( circularCr, ( cairoGlyphsBuffer + run.glyphIndex + index ), glyphJump );
+ cairo_glyph_path(circularCr, (cairoGlyphsBuffer + run.glyphIndex + index), glyphJump);
- WrapToCircularPath( cr, circularCr, circularTextParameters );
- cairo_fill( cr );
+ WrapToCircularPath(cr, circularCr, circularTextParameters);
+ cairo_fill(cr);
}
}
else
{
- if( synthesizeItalic )
+ if(synthesizeItalic)
{
// Apply a shear transform to synthesize the italics.
// For a reason Cairo may trim some glyphs if the CAIRO_FT_SYNTHESIZE_OBLIQUE flag is used.
// This is to calculate an offset used to compensate the 'translation' done by the shear transform
// as it's done for the whole render buffer.
double maxY = 0.0;
- for( unsigned int index = run.glyphIndex, endIndex = run.glyphIndex + run.numberOfGlyphs; index < endIndex; ++index )
+ for(unsigned int index = run.glyphIndex, endIndex = run.glyphIndex + run.numberOfGlyphs; index < endIndex; ++index)
{
- maxY = std::max( maxY, (*( cairoGlyphsBuffer + index )).y );
+ maxY = std::max(maxY, (*(cairoGlyphsBuffer + index)).y);
}
cairo_matrix_t matrix;
- cairo_matrix_init( &matrix,
- 1.0, 0.0,
- -TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE, 1.0,
- maxY * TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE, 0.0 );
-
- cairo_transform( cr, &matrix );
+ cairo_matrix_init(&matrix,
+ 1.0,
+ 0.0,
+ -TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE,
+ 1.0,
+ maxY * TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE,
+ 0.0);
+
+ cairo_transform(cr, &matrix);
}
- cairo_show_glyphs( cr, ( cairoGlyphsBuffer + run.glyphIndex ), run.numberOfGlyphs );
+ cairo_show_glyphs(cr, (cairoGlyphsBuffer + run.glyphIndex), run.numberOfGlyphs);
- if( synthesizeItalic )
+ if(synthesizeItalic)
{
// Restore the transform matrix to the identity.
cairo_matrix_t matrix;
- cairo_matrix_init_identity( &matrix );
- cairo_set_matrix( cr, &matrix );
+ cairo_matrix_init_identity(&matrix);
+ cairo_set_matrix(cr, &matrix);
}
- cairo_fill( cr );
+ cairo_fill(cr);
}
}
} // unnamed namespace
-Devel::PixelBuffer RenderTextCairo( const TextAbstraction::TextRenderer::Parameters& parameters )
+Devel::PixelBuffer RenderTextCairo(const TextAbstraction::TextRenderer::Parameters& parameters)
{
const unsigned int numberOfGlyphs = parameters.glyphs.Count();
- if( 0u == numberOfGlyphs )
+ if(0u == numberOfGlyphs)
{
// return a pixel buffer with all pixels set to transparent.
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
// Choose the pixel format to be used.
//
// Here in practice Cairo's ARGB32 is like DALi's RGBA8888.
//
- const bool isDstRgba = TextAbstraction::TextRenderer::Parameters::RGBA8888 == parameters.pixelFormat;
- const Pixel::Format pixelFormat = isDstRgba ? Pixel::Format::RGBA8888 : Pixel::Format::A8;
+ const bool isDstRgba = TextAbstraction::TextRenderer::Parameters::RGBA8888 == parameters.pixelFormat;
+ const Pixel::Format pixelFormat = isDstRgba ? Pixel::Format::RGBA8888 : Pixel::Format::A8;
const cairo_format_t cairoFormat = isDstRgba ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_A8;
- const int bpp = Pixel::GetBytesPerPixel( pixelFormat );
- if( 0u == bpp )
+ const int bpp = Pixel::GetBytesPerPixel(pixelFormat);
+ if(0u == bpp)
{
// return a pixel buffer with all pixels set to transparent.
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
// This function provides a stride value that will respect all alignment requirements of the
// accelerated image-rendering code within cairo.
- const int stride = cairo_format_stride_for_width( cairoFormat,
- static_cast<int>( parameters.width ) );
+ const int stride = cairo_format_stride_for_width(cairoFormat,
+ static_cast<int>(parameters.width));
const int strideWidth = stride / bpp;
// Convert from DALi glyphs to Cairo glyphs.
std::vector<cairo_glyph_t> cairoGlyphs;
- cairoGlyphs.resize( numberOfGlyphs );
+ cairoGlyphs.resize(numberOfGlyphs);
cairo_glyph_t* cairoGlyphsBuffer = &cairoGlyphs[0u];
- const GlyphInfo* const daliGlyphsBuffer = parameters.glyphs.Begin();
- const Vector2* const positionsBuffer = parameters.positions.Begin();
- const ColorIndex* const colorIndicesBuffer = ( 0u == parameters.colorIndices.Count() ) ? nullptr : parameters.colorIndices.Begin();
+ const GlyphInfo* const daliGlyphsBuffer = parameters.glyphs.Begin();
+ const Vector2* const positionsBuffer = parameters.positions.Begin();
+ const ColorIndex* const colorIndicesBuffer = (0u == parameters.colorIndices.Count()) ? nullptr : parameters.colorIndices.Begin();
- for( unsigned index = 0u; index < numberOfGlyphs; ++index )
+ for(unsigned index = 0u; index < numberOfGlyphs; ++index)
{
- const GlyphInfo& daliGlyph = *( daliGlyphsBuffer + index );
- const Vector2& position = *( positionsBuffer + index );
- cairo_glyph_t& cairoGlyph = *( cairoGlyphsBuffer + index );
+ const GlyphInfo& daliGlyph = *(daliGlyphsBuffer + index);
+ const Vector2& position = *(positionsBuffer + index);
+ cairo_glyph_t& cairoGlyph = *(cairoGlyphsBuffer + index);
cairoGlyph.index = daliGlyph.index;
- cairoGlyph.x = round( position.x );
- cairoGlyph.y = round( position.y );
+ cairoGlyph.x = round(position.x);
+ cairoGlyph.y = round(position.y);
}
// Retrieve the FreeType fonts needed by Cairo from the font-client.
Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
FT_Library ftLibrary;
- auto error = FT_Init_FreeType( &ftLibrary );
- if( error )
+ auto error = FT_Init_FreeType(&ftLibrary);
+ if(error)
{
- DALI_LOG_ERROR( "Error initializing FT library\n" );
+ DALI_LOG_ERROR("Error initializing FT library\n");
// return a pixel buffer with all pixels set to transparent.
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
// Vector used to store the FreeType font faces, its size and the run of glyphs that use the font.
std::vector<GlyphRun> glyphRuns;
- glyphRuns.reserve( 8u );
+ glyphRuns.reserve(8u);
- if( ! ConvertSizeForCairo(fontClient, ftLibrary, numberOfGlyphs, daliGlyphsBuffer, colorIndicesBuffer, glyphRuns) )
+ if(!ConvertSizeForCairo(fontClient, ftLibrary, numberOfGlyphs, daliGlyphsBuffer, colorIndicesBuffer, glyphRuns))
{
// return a pixel buffer with all pixels set to transparent.
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
// Creates the pixel buffer and retrieves the buffer pointer used to create the Cairo's surface.
- Devel::PixelBuffer pixelBuffer = Devel::PixelBuffer::New( strideWidth, parameters.height, pixelFormat );
+ Devel::PixelBuffer pixelBuffer = Devel::PixelBuffer::New(strideWidth, parameters.height, pixelFormat);
- unsigned char* buffer = pixelBuffer.GetBuffer();
+ unsigned char* buffer = pixelBuffer.GetBuffer();
const unsigned int bufferSize = stride * parameters.height;
- memset( buffer, 0, bufferSize );
+ memset(buffer, 0, bufferSize);
- std::unique_ptr<cairo_surface_t, void(*)(cairo_surface_t*)> surfacePtr( cairo_image_surface_create_for_data( buffer,
- cairoFormat,
- parameters.width,
- parameters.height,
- stride ),
- cairo_surface_destroy );
- cairo_surface_t* surface = surfacePtr.get();
+ std::unique_ptr<cairo_surface_t, void (*)(cairo_surface_t*)> surfacePtr(cairo_image_surface_create_for_data(buffer,
+ cairoFormat,
+ parameters.width,
+ parameters.height,
+ stride),
+ cairo_surface_destroy);
+ cairo_surface_t* surface = surfacePtr.get();
- if( ( nullptr == surface ) || ( CAIRO_STATUS_SUCCESS != cairo_surface_status( surface ) ) )
+ if((nullptr == surface) || (CAIRO_STATUS_SUCCESS != cairo_surface_status(surface)))
{
- DALI_LOG_ERROR( "Failed to create a cairo's surface\n" );
+ DALI_LOG_ERROR("Failed to create a cairo's surface\n");
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
// Whether the text is circular.
//
// As the glyphs are laid out first in a straight line they may exceed the
// boundaries of the surface in that case cairo ignores them.
- std::unique_ptr<cairo_surface_t, void(*)(cairo_surface_t*)> circularSurfacePtr( nullptr, cairo_surface_destroy );
- cairo_surface_t* circularSurface = nullptr;
- if( isCircularText )
+ std::unique_ptr<cairo_surface_t, void (*)(cairo_surface_t*)> circularSurfacePtr(nullptr, cairo_surface_destroy);
+ cairo_surface_t* circularSurface = nullptr;
+ if(isCircularText)
{
- circularSurfacePtr.reset( cairo_surface_create_similar( surface,
- CAIRO_CONTENT_ALPHA,
- parameters.circularWidth,
- parameters.circularHeight ) );
+ circularSurfacePtr.reset(cairo_surface_create_similar(surface,
+ CAIRO_CONTENT_ALPHA,
+ parameters.circularWidth,
+ parameters.circularHeight));
circularSurface = circularSurfacePtr.get();
- if( ( nullptr == circularSurface ) || ( CAIRO_STATUS_SUCCESS != cairo_surface_status( circularSurface ) ) )
+ if((nullptr == circularSurface) || (CAIRO_STATUS_SUCCESS != cairo_surface_status(circularSurface)))
{
- DALI_LOG_ERROR( "Failed to create a cairo's circular surface\n" );
+ DALI_LOG_ERROR("Failed to create a cairo's circular surface\n");
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
}
- std::unique_ptr<cairo_t, void(*)(cairo_t*)> crPtr( cairo_create( surface ), cairo_destroy );
- cairo_t* cr = crPtr.get();
+ std::unique_ptr<cairo_t, void (*)(cairo_t*)> crPtr(cairo_create(surface), cairo_destroy);
+ cairo_t* cr = crPtr.get();
- if( CAIRO_STATUS_SUCCESS != cairo_status( cr ) )
+ if(CAIRO_STATUS_SUCCESS != cairo_status(cr))
{
- DALI_LOG_ERROR( "Failed to create a cairo context\n" );
+ DALI_LOG_ERROR("Failed to create a cairo context\n");
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
- std::unique_ptr<cairo_t, void(*)(cairo_t*)> circularCrPtr( nullptr, cairo_destroy );
- cairo_t* circularCr = nullptr;
+ std::unique_ptr<cairo_t, void (*)(cairo_t*)> circularCrPtr(nullptr, cairo_destroy);
+ cairo_t* circularCr = nullptr;
- if( isCircularText )
+ if(isCircularText)
{
- circularCrPtr.reset( cairo_create( circularSurface ) );
+ circularCrPtr.reset(cairo_create(circularSurface));
circularCr = circularCrPtr.get();
- if( CAIRO_STATUS_SUCCESS != cairo_status( circularCr ) )
+ if(CAIRO_STATUS_SUCCESS != cairo_status(circularCr))
{
- DALI_LOG_ERROR( "Failed to create a cairo context\n" );
+ DALI_LOG_ERROR("Failed to create a cairo context\n");
- return CreateVoidPixelBuffer( parameters );
+ return CreateVoidPixelBuffer(parameters);
}
}
CircularTextParameters circularTextParameters;
// Render the glyphs.
- if( isCircularText )
+ if(isCircularText)
{
// Set the parameters.
- circularTextParameters.isClockwise = ( TextAbstraction::TextRenderer::Parameters::CLOCKWISE == parameters.circularLayout );
+ circularTextParameters.isClockwise = (TextAbstraction::TextRenderer::Parameters::CLOCKWISE == parameters.circularLayout);
- circularTextParameters.centerX = static_cast<double>( parameters.centerX );
- circularTextParameters.centerY = static_cast<double>( parameters.centerY );
- circularTextParameters.radius = static_cast<double>( parameters.radius );
- circularTextParameters.invRadius = 1.0 / circularTextParameters.radius;
+ circularTextParameters.centerX = static_cast<double>(parameters.centerX);
+ circularTextParameters.centerY = static_cast<double>(parameters.centerY);
+ circularTextParameters.radius = static_cast<double>(parameters.radius);
+ circularTextParameters.invRadius = 1.0 / circularTextParameters.radius;
circularTextParameters.beginAngle = -parameters.beginAngle + Dali::Math::PI_2;
}
- cairo_move_to( cr, 0.0, 0.0 );
+ cairo_move_to(cr, 0.0, 0.0);
- for( const auto& run: glyphRuns )
+ for(const auto& run : glyphRuns)
{
const bool isEmoji = parameters.isEmoji[run.glyphIndex];
- if( isEmoji || ( nullptr == run.fontFace ) )
+ if(isEmoji || (nullptr == run.fontFace))
{
// Retrieve the color for the glyph.
const Vector4& color = parameters.colors[run.colorIndex];
const unsigned int lastGlyphIndex = run.glyphIndex + run.numberOfGlyphs;
- for( unsigned int index = run.glyphIndex; index < lastGlyphIndex; ++index )
+ for(unsigned int index = run.glyphIndex; index < lastGlyphIndex; ++index)
{
// Whether it's a bitmap font.
- const bool doBlendWithTextColor = !isEmoji && ( ColorBlendingMode::MULTIPLY == parameters.blendingMode[index] );
+ const bool doBlendWithTextColor = !isEmoji && (ColorBlendingMode::MULTIPLY == parameters.blendingMode[index]);
// Check if there is an embedded image or a bitmap font image.
const GlyphIndex glyphFontIndex = daliGlyphsBuffer[index].index;
- if( 0u != glyphFontIndex )
+ if(0u != glyphFontIndex)
{
// The embedded image could be A8, RGBA8888 or BGRA8888.
//
// If the embedded image is RGBA8888 or BGRA8888 then the cairo's buffer is ARGB32. It's needed to convert from RGBA or BGRA to ARGB.
// If the embedded image is A8 it's needed to check if the cairo's buffer is A8 or ARGB32 and do the conversion if needed.
- const cairo_glyph_t& glyph = *( cairoGlyphsBuffer + index );
+ const cairo_glyph_t& glyph = *(cairoGlyphsBuffer + index);
// Retrieve the image
TextAbstraction::FontClient::GlyphBufferData data;
- std::unique_ptr<GlyphBuffer> glyphBufferPtr( new GlyphBuffer( data, GlyphBuffer::DELETE ) );
- if( isEmoji )
+ std::unique_ptr<GlyphBuffer> glyphBufferPtr(new GlyphBuffer(data, GlyphBuffer::DELETE));
+ if(isEmoji)
{
- data.width = parameters.glyphs[run.glyphIndex].width;
+ data.width = parameters.glyphs[run.glyphIndex].width;
data.height = parameters.glyphs[run.glyphIndex].height;
}
- fontClient.CreateBitmap( run.fontId, glyphFontIndex, false, false, data, 0u );
+ fontClient.CreateBitmap(run.fontId, glyphFontIndex, false, false, data, 0u);
- if( nullptr == data.buffer )
+ if(nullptr == data.buffer)
{
// nothing else to do if there is no image.
continue;
double glyphX = glyph.x;
double glyphY = glyph.y;
- if( isCircularText )
+ if(isCircularText)
{
// Center of the bitmap.
- const double halfWidth = 0.5 * static_cast<double>( data.width );
- const double halfHeight = 0.5 * static_cast<double>( data.height );
+ const double halfWidth = 0.5 * static_cast<double>(data.width);
+ const double halfHeight = 0.5 * static_cast<double>(data.height);
double centerX = glyph.x + halfWidth;
double centerY = glyph.y - halfHeight;
- float radians = circularTextParameters.beginAngle + ( circularTextParameters.isClockwise ? -1.f : 1.f ) * ( Dali::Math::PI_2 + circularTextParameters.invRadius * centerX );
- radians = fmod( radians, TWO_PI );
- radians += ( radians < 0.f ) ? TWO_PI : 0.f;
-
- TransformToArc( circularTextParameters, centerX, centerY );
-
- uint8_t* pixelsOut = nullptr;
- unsigned int widthOut = data.width;
- unsigned int heightOut = data.height;
- const unsigned int pixelSize = Pixel::GetBytesPerPixel( data.format );
-
- Dali::Internal::Platform::RotateByShear( data.buffer,
- data.width,
- data.height,
- pixelSize,
- radians,
- pixelsOut,
- widthOut,
- heightOut );
- if( nullptr != pixelsOut )
+ float radians = circularTextParameters.beginAngle + (circularTextParameters.isClockwise ? -1.f : 1.f) * (Dali::Math::PI_2 + circularTextParameters.invRadius * centerX);
+ radians = fmod(radians, TWO_PI);
+ radians += (radians < 0.f) ? TWO_PI : 0.f;
+
+ TransformToArc(circularTextParameters, centerX, centerY);
+
+ uint8_t* pixelsOut = nullptr;
+ unsigned int widthOut = data.width;
+ unsigned int heightOut = data.height;
+ const unsigned int pixelSize = Pixel::GetBytesPerPixel(data.format);
+
+ Dali::Internal::Platform::RotateByShear(data.buffer,
+ data.width,
+ data.height,
+ pixelSize,
+ radians,
+ pixelsOut,
+ widthOut,
+ heightOut);
+ if(nullptr != pixelsOut)
{
delete[] data.buffer;
- data.buffer = pixelsOut;
+ data.buffer = pixelsOut;
glyphBufferPtr.get()->type = GlyphBuffer::FREE;
- data.width = widthOut;
- data.height = heightOut;
+ data.width = widthOut;
+ data.height = heightOut;
}
- glyphX = centerX - 0.5 * static_cast<double>( data.width );
- glyphY = centerY + 0.5 * static_cast<double>( data.height );
+ glyphX = centerX - 0.5 * static_cast<double>(data.width);
+ glyphY = centerY + 0.5 * static_cast<double>(data.height);
}
-
- if( ( Pixel::A8 != data.format ) &&
- ( Pixel::L8 != data.format ) &&
- ( Pixel::RGBA8888 != data.format ) &&
- ( Pixel::BGRA8888 != data.format ) )
+ if((Pixel::A8 != data.format) &&
+ (Pixel::L8 != data.format) &&
+ (Pixel::RGBA8888 != data.format) &&
+ (Pixel::BGRA8888 != data.format))
{
- DALI_LOG_ERROR( " Cairo Renderer: The valid pixel format for embedded items are A8 or RGBA8888\n" );
+ DALI_LOG_ERROR(" Cairo Renderer: The valid pixel format for embedded items are A8 or RGBA8888\n");
continue;
}
// Check if the item is out of the buffer.
- if( ( glyphX + static_cast<float>( data.width ) < 0.f ) ||
- ( glyphX > static_cast<float>( strideWidth ) ) ||
- ( glyphY < 0.f ) ||
- ( glyphY - static_cast<float>( data.height ) > static_cast<float>( parameters.height ) ) )
+ if((glyphX + static_cast<float>(data.width) < 0.f) ||
+ (glyphX > static_cast<float>(strideWidth)) ||
+ (glyphY < 0.f) ||
+ (glyphY - static_cast<float>(data.height) > static_cast<float>(parameters.height)))
{
// The embedded item is completely out of the buffer.
continue;
}
- const bool isSrcA = ( Pixel::A8 == data.format ) || ( Pixel::L8 == data.format );
+ const bool isSrcA = (Pixel::A8 == data.format) || (Pixel::L8 == data.format);
const bool isSrcRgba = Pixel::RGBA8888 == data.format;
const bool isSrcBgra = Pixel::BGRA8888 == data.format;
// 2 -> image is RGBA and cairo buffer is ARGB
// 3 -> image is BGRA and cairo buffer is ARGB
int rgbaCase = 0;
- if( isSrcA && isDstRgba )
+ if(isSrcA && isDstRgba)
{
rgbaCase = 1;
}
- else if( isSrcRgba && isDstRgba )
+ else if(isSrcRgba && isDstRgba)
{
rgbaCase = 2;
}
- else if( isSrcBgra && isDstRgba )
+ else if(isSrcBgra && isDstRgba)
{
rgbaCase = 3;
}
- else if( ( isSrcRgba || isSrcBgra ) && !isDstRgba )
+ else if((isSrcRgba || isSrcBgra) && !isDstRgba)
{
- DALI_LOG_ERROR( "Cairo Renderer: The embedded image is RGBA or BGRA and the Cairo's buffer has been creates with A8 format!\n" );
+ DALI_LOG_ERROR("Cairo Renderer: The embedded image is RGBA or BGRA and the Cairo's buffer has been creates with A8 format!\n");
continue;
}
/*
- * Copyright (c) 2017 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.
#if defined(DEBUG_ENABLED)
Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_FONT_CLIENT_VALUE_TO_INDEX");
#endif
-}
+} // namespace
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
-int ValueToIndex( int value, const int* const table, unsigned int maxIndex )
+int ValueToIndex(int value, const int* const table, unsigned int maxIndex)
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->FontClient::Plugin::ValueToIndex value(%d)\n", value);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->FontClient::Plugin::ValueToIndex value(%d)\n", value);
- if( NULL == table )
+ if(NULL == table)
{
// Return an invalid index if there is no table.
return -1;
}
- if( value <= table[0] )
+ if(value <= table[0])
{
return 0;
}
- if( value >= table[maxIndex] )
+ if(value >= table[maxIndex])
{
return maxIndex;
}
- for( unsigned int index = 0u; index < maxIndex; ++index )
+ for(unsigned int index = 0u; index < maxIndex; ++index)
{
- const int v1 = table[index];
+ const int v1 = table[index];
const unsigned int indexPlus = index + 1u;
- const int v2 = table[indexPlus];
- if( ( v1 < value ) && ( value <= v2 ) )
+ const int v2 = table[indexPlus];
+ if((v1 < value) && (value <= v2))
{
- const int result = ( ( v1 > 0 ) && ( ( value - v1 ) < ( v2 - value ) ) ) ? index : indexPlus;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex result(%d)\n", result );
+ const int result = ((v1 > 0) && ((value - v1) < (v2 - value))) ? index : indexPlus;
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex result(%d)\n", result);
return result;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex exit 0 <-- \n");
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "FontClient::Plugin::ValueToIndex exit 0 <-- \n");
return 0;
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
-Dali::TextAbstraction::FontClient FontClient::gPreInitializedFontClient( NULL );
+Dali::TextAbstraction::FontClient FontClient::gPreInitializedFontClient(NULL);
FontClient::FontClient()
-: mPlugin( nullptr ),
- mDpiHorizontal( 0 ),
- mDpiVertical( 0 )
+: mPlugin(nullptr),
+ mDpiHorizontal(0),
+ mDpiVertical(0)
{
}
{
Dali::TextAbstraction::FontClient fontClientHandle;
- Dali::SingletonService service( SingletonService::Get() );
- if ( service )
+ Dali::SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::TextAbstraction::FontClient ) );
+ Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::TextAbstraction::FontClient));
if(handle)
{
// If so, downcast the handle
- FontClient* impl = dynamic_cast< Dali::TextAbstraction::Internal::FontClient* >( handle.GetObjectPtr() );
- fontClientHandle = Dali::TextAbstraction::FontClient( impl );
+ FontClient* impl = dynamic_cast<Dali::TextAbstraction::Internal::FontClient*>(handle.GetObjectPtr());
+ fontClientHandle = Dali::TextAbstraction::FontClient(impl);
}
else // create and register the object
{
- if( gPreInitializedFontClient )
+ if(gPreInitializedFontClient)
{
fontClientHandle = gPreInitializedFontClient;
gPreInitializedFontClient.Reset(); // No longer needed
}
else
{
- fontClientHandle = Dali::TextAbstraction::FontClient( new FontClient );
+ fontClientHandle = Dali::TextAbstraction::FontClient(new FontClient);
}
- service.Register( typeid( fontClientHandle ), fontClientHandle );
+ service.Register(typeid(fontClientHandle), fontClientHandle);
}
}
Dali::TextAbstraction::FontClient FontClient::PreInitialize()
{
- gPreInitializedFontClient = Dali::TextAbstraction::FontClient( new FontClient );
+ gPreInitializedFontClient = Dali::TextAbstraction::FontClient(new FontClient);
// Make DefaultFontDescription cached
Dali::TextAbstraction::FontDescription defaultFontDescription;
- gPreInitializedFontClient.GetDefaultPlatformFontDescription( defaultFontDescription );
+ gPreInitializedFontClient.GetDefaultPlatformFontDescription(defaultFontDescription);
return gPreInitializedFontClient;
}
void FontClient::ClearCache()
{
- if( mPlugin )
+ if(mPlugin)
{
mPlugin->ClearCache();
}
}
-
-void FontClient::SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi )
+void FontClient::SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi)
{
mDpiHorizontal = horizontalDpi;
- mDpiVertical = verticalDpi;
+ mDpiVertical = verticalDpi;
// Allow DPI to be set without loading plugin
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->SetDpi( horizontalDpi, verticalDpi );
+ mPlugin->SetDpi(horizontalDpi, verticalDpi);
}
}
-void FontClient::GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi )
+void FontClient::GetDpi(unsigned int& horizontalDpi, unsigned int& verticalDpi)
{
horizontalDpi = mDpiHorizontal;
- verticalDpi = mDpiVertical;
+ verticalDpi = mDpiVertical;
}
int FontClient::GetDefaultFontSize()
{
- int fontSize( -1 );
+ int fontSize(-1);
#if !(defined(DALI_PROFILE_UBUNTU) || defined(ANDROID) || defined(WIN32) || defined(__APPLE__))
- vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize );
+ vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize);
#endif
return fontSize;
mPlugin->ResetSystemDefaults();
}
-void FontClient::GetDefaultFonts( FontList& defaultFonts )
+void FontClient::GetDefaultFonts(FontList& defaultFonts)
{
CreatePlugin();
- mPlugin->GetDefaultFonts( defaultFonts );
+ mPlugin->GetDefaultFonts(defaultFonts);
}
-void FontClient::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
+void FontClient::GetDefaultPlatformFontDescription(FontDescription& fontDescription)
{
CreatePlugin();
- mPlugin->GetDefaultPlatformFontDescription( fontDescription );
+ mPlugin->GetDefaultPlatformFontDescription(fontDescription);
}
-void FontClient::GetDescription( FontId id, FontDescription& fontDescription )
+void FontClient::GetDescription(FontId id, FontDescription& fontDescription)
{
CreatePlugin();
- mPlugin->GetDescription( id, fontDescription );
+ mPlugin->GetDescription(id, fontDescription);
}
-PointSize26Dot6 FontClient::GetPointSize( FontId id )
+PointSize26Dot6 FontClient::GetPointSize(FontId id)
{
CreatePlugin();
- return mPlugin->GetPointSize( id );
+ return mPlugin->GetPointSize(id);
}
-bool FontClient::IsCharacterSupportedByFont( FontId fontId, Character character )
+bool FontClient::IsCharacterSupportedByFont(FontId fontId, Character character)
{
CreatePlugin();
- return mPlugin->IsCharacterSupportedByFont( fontId, character );
+ return mPlugin->IsCharacterSupportedByFont(fontId, character);
}
-void FontClient::GetSystemFonts( FontList& systemFonts )
+void FontClient::GetSystemFonts(FontList& systemFonts)
{
CreatePlugin();
- mPlugin->GetSystemFonts( systemFonts );
+ mPlugin->GetSystemFonts(systemFonts);
}
-FontId FontClient::FindDefaultFont( Character charcode,
- PointSize26Dot6 requestedPointSize,
- bool preferColor )
+FontId FontClient::FindDefaultFont(Character charcode,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor)
{
CreatePlugin();
- return mPlugin->FindDefaultFont( charcode,
- requestedPointSize,
- preferColor );
+ return mPlugin->FindDefaultFont(charcode,
+ requestedPointSize,
+ preferColor);
}
-FontId FontClient::FindFallbackFont( Character charcode,
- const FontDescription& preferredFontDescription,
- PointSize26Dot6 requestedPointSize,
- bool preferColor )
+FontId FontClient::FindFallbackFont(Character charcode,
+ const FontDescription& preferredFontDescription,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor)
{
CreatePlugin();
- return mPlugin->FindFallbackFont( charcode,
- preferredFontDescription,
- requestedPointSize,
- preferColor );
+ return mPlugin->FindFallbackFont(charcode,
+ preferredFontDescription,
+ requestedPointSize,
+ preferColor);
}
-bool FontClient::IsScalable( const FontPath& path )
+bool FontClient::IsScalable(const FontPath& path)
{
CreatePlugin();
- return mPlugin->IsScalable( path );
+ return mPlugin->IsScalable(path);
}
-bool FontClient::IsScalable( const FontDescription& fontDescription )
+bool FontClient::IsScalable(const FontDescription& fontDescription)
{
CreatePlugin();
- return mPlugin->IsScalable( fontDescription );
+ return mPlugin->IsScalable(fontDescription);
}
-void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
+void FontClient::GetFixedSizes(const FontPath& path, Dali::Vector<PointSize26Dot6>& sizes)
{
CreatePlugin();
- mPlugin->GetFixedSizes( path, sizes );
+ mPlugin->GetFixedSizes(path, sizes);
}
-void FontClient::GetFixedSizes( const FontDescription& fontDescription,
- Dali::Vector< PointSize26Dot6 >& sizes )
+void FontClient::GetFixedSizes(const FontDescription& fontDescription,
+ Dali::Vector<PointSize26Dot6>& sizes)
{
CreatePlugin();
- mPlugin->GetFixedSizes( fontDescription, sizes );
+ mPlugin->GetFixedSizes(fontDescription, sizes);
}
-bool FontClient::HasItalicStyle( FontId fontId ) const
+bool FontClient::HasItalicStyle(FontId fontId) const
{
- if( !mPlugin )
+ if(!mPlugin)
{
return false;
}
- return mPlugin->HasItalicStyle( fontId );
+ return mPlugin->HasItalicStyle(fontId);
}
-FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
+FontId FontClient::GetFontId(const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex)
{
CreatePlugin();
- return mPlugin->GetFontId( path,
- requestedPointSize,
- faceIndex,
- true );
+ return mPlugin->GetFontId(path,
+ requestedPointSize,
+ faceIndex,
+ true);
}
-FontId FontClient::GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex )
+FontId FontClient::GetFontId(const FontDescription& fontDescription,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex)
{
CreatePlugin();
- return mPlugin->GetFontId( fontDescription,
- requestedPointSize,
- faceIndex );
+ return mPlugin->GetFontId(fontDescription,
+ requestedPointSize,
+ faceIndex);
}
-FontId FontClient::GetFontId( const BitmapFont& bitmapFont )
+FontId FontClient::GetFontId(const BitmapFont& bitmapFont)
{
CreatePlugin();
- return mPlugin->GetFontId( bitmapFont );
+ return mPlugin->GetFontId(bitmapFont);
}
-void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
+void FontClient::GetFontMetrics(FontId fontId, FontMetrics& metrics)
{
CreatePlugin();
- mPlugin->GetFontMetrics( fontId, metrics );
+ mPlugin->GetFontMetrics(fontId, metrics);
}
-GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
+GlyphIndex FontClient::GetGlyphIndex(FontId fontId, Character charcode)
{
CreatePlugin();
- return mPlugin->GetGlyphIndex( fontId, charcode );
+ return mPlugin->GetGlyphIndex(fontId, charcode);
}
-bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
+bool FontClient::GetGlyphMetrics(GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal)
{
CreatePlugin();
- return mPlugin->GetGlyphMetrics( array, size, type, horizontal );
+ return mPlugin->GetGlyphMetrics(array, size, type, horizontal);
}
-void FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
+void FontClient::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth)
{
CreatePlugin();
- mPlugin->CreateBitmap( fontId, glyphIndex, isItalicRequired, isBoldRequired, data, outlineWidth );
+ mPlugin->CreateBitmap(fontId, glyphIndex, isItalicRequired, isBoldRequired, data, outlineWidth);
}
-PixelData FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
+PixelData FontClient::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth)
{
CreatePlugin();
- return mPlugin->CreateBitmap( fontId, glyphIndex, outlineWidth );
+ return mPlugin->CreateBitmap(fontId, glyphIndex, outlineWidth);
}
-void FontClient::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
+void FontClient::CreateVectorBlob(FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight)
{
CreatePlugin();
- mPlugin->CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
+ mPlugin->CreateVectorBlob(fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight);
}
-const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
+const GlyphInfo& FontClient::GetEllipsisGlyph(PointSize26Dot6 requestedPointSize)
{
CreatePlugin();
- return mPlugin->GetEllipsisGlyph( requestedPointSize );
+ return mPlugin->GetEllipsisGlyph(requestedPointSize);
}
-bool FontClient::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
+bool FontClient::IsColorGlyph(FontId fontId, GlyphIndex glyphIndex)
{
CreatePlugin();
- return mPlugin->IsColorGlyph( fontId, glyphIndex );
+ return mPlugin->IsColorGlyph(fontId, glyphIndex);
}
GlyphIndex FontClient::CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat)
{
CreatePlugin();
- return mPlugin->CreateEmbeddedItem( description, pixelFormat );
+ return mPlugin->CreateEmbeddedItem(description, pixelFormat);
}
-FT_FaceRec_* FontClient::GetFreetypeFace( FontId fontId )
+FT_FaceRec_* FontClient::GetFreetypeFace(FontId fontId)
{
CreatePlugin();
- return mPlugin->GetFreetypeFace( fontId );
+ return mPlugin->GetFreetypeFace(fontId);
}
-FontDescription::Type FontClient::GetFontType( FontId fontId )
+FontDescription::Type FontClient::GetFontType(FontId fontId)
{
CreatePlugin();
- return mPlugin->GetFontType( fontId );
+ return mPlugin->GetFontType(fontId);
}
-bool FontClient::AddCustomFontDirectory( const FontPath& path )
+bool FontClient::AddCustomFontDirectory(const FontPath& path)
{
CreatePlugin();
- return mPlugin->AddCustomFontDirectory( path );
+ return mPlugin->AddCustomFontDirectory(path);
}
void FontClient::CreatePlugin()
{
- if( !mPlugin )
+ if(!mPlugin)
{
- mPlugin = new Plugin( mDpiHorizontal, mDpiVertical );
+ mPlugin = new Plugin(mDpiHorizontal, mDpiVertical);
}
}
/*
- * Copyright (c) 2019 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.
// INTERNAL INCLUDES
#include <dali/devel-api/text-abstraction/font-list.h>
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/platform-abstraction.h>
-#include <dali/internal/text/text-abstraction/font-client-helper.h>
-#include <dali/internal/imaging/common/image-operations.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/devel-api/adaptor-framework/image-loading.h>
+#include <dali/internal/imaging/common/image-operations.h>
+#include <dali/internal/text/text-abstraction/font-client-helper.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/vector-wrapper.h>
// EXTERNAL INCLUDES
#include <fontconfig/fontconfig.h>
namespace
{
-
#if defined(DEBUG_ENABLED)
Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_FONT_CLIENT");
#endif
/**
* Conversion from Fractional26.6 to float
*/
-const float FROM_266 = 1.0f / 64.0f;
+const float FROM_266 = 1.0f / 64.0f;
const float POINTS_PER_INCH = 72.f;
-const std::string DEFAULT_FONT_FAMILY_NAME( "Tizen" );
-const int DEFAULT_FONT_WIDTH = 100; // normal
-const int DEFAULT_FONT_WEIGHT = 80; // normal
-const int DEFAULT_FONT_SLANT = 0; // normal
+const std::string DEFAULT_FONT_FAMILY_NAME("Tizen");
+const int DEFAULT_FONT_WIDTH = 100; // normal
+const int DEFAULT_FONT_WEIGHT = 80; // normal
+const int DEFAULT_FONT_SLANT = 0; // normal
const uint32_t ELLIPSIS_CHARACTER = 0x2026;
// EXPANDED 125
// EXTRA_EXPANDED 150
// ULTRA_EXPANDED 200
-const int FONT_WIDTH_TYPE_TO_INT[] = { -1, 50, 63, 75, 87, 100, 113, 125, 150, 200 };
-const unsigned int NUM_FONT_WIDTH_TYPE = sizeof( FONT_WIDTH_TYPE_TO_INT ) / sizeof( int );
+const int FONT_WIDTH_TYPE_TO_INT[] = {-1, 50, 63, 75, 87, 100, 113, 125, 150, 200};
+const unsigned int NUM_FONT_WIDTH_TYPE = sizeof(FONT_WIDTH_TYPE_TO_INT) / sizeof(int);
// NONE -1 --> DEFAULT_FONT_WEIGHT (NORMAL) will be used.
// THIN 0
// BOLD 200
// ULTRA_BOLD, EXTRA_BOLD 205
// BLACK, HEAVY, EXTRA_BLACK 210
-const int FONT_WEIGHT_TYPE_TO_INT[] = { -1, 0, 40, 50, 55, 75, 80, 100, 180, 200, 205, 210 };
-const unsigned int NUM_FONT_WEIGHT_TYPE = sizeof( FONT_WEIGHT_TYPE_TO_INT ) / sizeof( int );
+const int FONT_WEIGHT_TYPE_TO_INT[] = {-1, 0, 40, 50, 55, 75, 80, 100, 180, 200, 205, 210};
+const unsigned int NUM_FONT_WEIGHT_TYPE = sizeof(FONT_WEIGHT_TYPE_TO_INT) / sizeof(int);
// NONE -1 --> DEFAULT_FONT_SLANT (NORMAL) will be used.
// NORMAL, ROMAN 0
// ITALIC 100
// OBLIQUE 110
-const int FONT_SLANT_TYPE_TO_INT[] = { -1, 0, 100, 110 };
-const unsigned int NUM_FONT_SLANT_TYPE = sizeof( FONT_SLANT_TYPE_TO_INT ) / sizeof( int );
+const int FONT_SLANT_TYPE_TO_INT[] = {-1, 0, 100, 110};
+const unsigned int NUM_FONT_SLANT_TYPE = sizeof(FONT_SLANT_TYPE_TO_INT) / sizeof(int);
} // namespace
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
/**
* @brief Returns the FontWidth's enum index for the given width value.
*
*
* @return The FontWidth's enum index.
*/
-FontWidth::Type IntToWidthType( int width )
+FontWidth::Type IntToWidthType(int width)
{
- return static_cast<FontWidth::Type>( ValueToIndex( width, FONT_WIDTH_TYPE_TO_INT, NUM_FONT_WIDTH_TYPE - 1u ) );
+ return static_cast<FontWidth::Type>(ValueToIndex(width, FONT_WIDTH_TYPE_TO_INT, NUM_FONT_WIDTH_TYPE - 1u));
}
/**
*
* @return The FontWeight's enum index.
*/
-FontWeight::Type IntToWeightType( int weight )
+FontWeight::Type IntToWeightType(int weight)
{
- return static_cast<FontWeight::Type>( ValueToIndex( weight, FONT_WEIGHT_TYPE_TO_INT, NUM_FONT_WEIGHT_TYPE - 1u ) );
+ return static_cast<FontWeight::Type>(ValueToIndex(weight, FONT_WEIGHT_TYPE_TO_INT, NUM_FONT_WEIGHT_TYPE - 1u));
}
/**
*
* @return The FontSlant's enum index.
*/
-FontSlant::Type IntToSlantType( int slant )
+FontSlant::Type IntToSlantType(int slant)
{
- return static_cast<FontSlant::Type>( ValueToIndex( slant, FONT_SLANT_TYPE_TO_INT, NUM_FONT_SLANT_TYPE - 1u ) );
+ return static_cast<FontSlant::Type>(ValueToIndex(slant, FONT_SLANT_TYPE_TO_INT, NUM_FONT_SLANT_TYPE - 1u));
}
/**
*
* @param[in] characterSets The vector of character sets.
*/
-void DestroyCharacterSets( CharacterSetList& characterSets )
+void DestroyCharacterSets(CharacterSetList& characterSets)
{
- for( auto& item : characterSets )
+ for(auto& item : characterSets)
{
- if( item )
+ if(item)
{
- FcCharSetDestroy( item );
+ FcCharSetDestroy(item);
}
}
}
-FontClient::Plugin::FallbackCacheItem::FallbackCacheItem( FontDescription&& font, FontList* fallbackFonts, CharacterSetList* characterSets )
-: fontDescription{ std::move( font ) },
- fallbackFonts{ fallbackFonts },
- characterSets{ characterSets }
+FontClient::Plugin::FallbackCacheItem::FallbackCacheItem(FontDescription&& font, FontList* fallbackFonts, CharacterSetList* characterSets)
+: fontDescription{std::move(font)},
+ fallbackFonts{fallbackFonts},
+ characterSets{characterSets}
{
}
-FontClient::Plugin::FontDescriptionCacheItem::FontDescriptionCacheItem( const FontDescription& fontDescription,
- FontDescriptionId index )
-: fontDescription{ fontDescription },
- index{ index }
+FontClient::Plugin::FontDescriptionCacheItem::FontDescriptionCacheItem(const FontDescription& fontDescription,
+ FontDescriptionId index)
+: fontDescription{fontDescription},
+ index{index}
{
}
-FontClient::Plugin::FontDescriptionCacheItem::FontDescriptionCacheItem( FontDescription&& fontDescription,
- FontDescriptionId index )
-: fontDescription{ std::move( fontDescription ) },
- index{ index }
+FontClient::Plugin::FontDescriptionCacheItem::FontDescriptionCacheItem(FontDescription&& fontDescription,
+ FontDescriptionId index)
+: fontDescription{std::move(fontDescription)},
+ index{index}
{
}
-FontClient::Plugin::FontDescriptionSizeCacheItem::FontDescriptionSizeCacheItem( FontDescriptionId validatedFontId,
- PointSize26Dot6 requestedPointSize,
- FontId fontId )
-: validatedFontId( validatedFontId ),
- requestedPointSize( requestedPointSize ),
- fontId( fontId )
+FontClient::Plugin::FontDescriptionSizeCacheItem::FontDescriptionSizeCacheItem(FontDescriptionId validatedFontId,
+ PointSize26Dot6 requestedPointSize,
+ FontId fontId)
+: validatedFontId(validatedFontId),
+ requestedPointSize(requestedPointSize),
+ fontId(fontId)
{
}
-FontClient::Plugin::FontFaceCacheItem::FontFaceCacheItem( FT_Face ftFace,
- const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex face,
- const FontMetrics& metrics )
-: mFreeTypeFace( ftFace ),
- mPath( path ),
- mRequestedPointSize( requestedPointSize ),
- mFaceIndex( face ),
- mMetrics( metrics ),
- mCharacterSet( nullptr ),
- mFixedSizeIndex( 0 ),
- mFixedWidthPixels( 0.f ),
- mFixedHeightPixels( 0.f ),
- mVectorFontId( 0u ),
- mFontId( 0u ),
- mIsFixedSizeBitmap( false ),
- mHasColorTables( false )
+FontClient::Plugin::FontFaceCacheItem::FontFaceCacheItem(FT_Face ftFace,
+ const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex face,
+ const FontMetrics& metrics)
+: mFreeTypeFace(ftFace),
+ mPath(path),
+ mRequestedPointSize(requestedPointSize),
+ mFaceIndex(face),
+ mMetrics(metrics),
+ mCharacterSet(nullptr),
+ mFixedSizeIndex(0),
+ mFixedWidthPixels(0.f),
+ mFixedHeightPixels(0.f),
+ mVectorFontId(0u),
+ mFontId(0u),
+ mIsFixedSizeBitmap(false),
+ mHasColorTables(false)
{
}
-FontClient::Plugin::FontFaceCacheItem::FontFaceCacheItem( FT_Face ftFace,
- const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex face,
- const FontMetrics& metrics,
- int fixedSizeIndex,
- float fixedWidth,
- float fixedHeight,
- bool hasColorTables )
-: mFreeTypeFace( ftFace ),
- mPath( path ),
- mRequestedPointSize( requestedPointSize ),
- mFaceIndex( face ),
- mMetrics( metrics ),
- mCharacterSet( nullptr ),
- mFixedSizeIndex( fixedSizeIndex ),
- mFixedWidthPixels( fixedWidth ),
- mFixedHeightPixels( fixedHeight ),
- mVectorFontId( 0u ),
- mFontId( 0u ),
- mIsFixedSizeBitmap( true ),
- mHasColorTables( hasColorTables )
+FontClient::Plugin::FontFaceCacheItem::FontFaceCacheItem(FT_Face ftFace,
+ const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex face,
+ const FontMetrics& metrics,
+ int fixedSizeIndex,
+ float fixedWidth,
+ float fixedHeight,
+ bool hasColorTables)
+: mFreeTypeFace(ftFace),
+ mPath(path),
+ mRequestedPointSize(requestedPointSize),
+ mFaceIndex(face),
+ mMetrics(metrics),
+ mCharacterSet(nullptr),
+ mFixedSizeIndex(fixedSizeIndex),
+ mFixedWidthPixels(fixedWidth),
+ mFixedHeightPixels(fixedHeight),
+ mVectorFontId(0u),
+ mFontId(0u),
+ mIsFixedSizeBitmap(true),
+ mHasColorTables(hasColorTables)
{
}
-FontClient::Plugin::Plugin( unsigned int horizontalDpi,
- unsigned int verticalDpi )
-: mFreeTypeLibrary( nullptr ),
- mDpiHorizontal( horizontalDpi ),
- mDpiVertical( verticalDpi ),
+FontClient::Plugin::Plugin(unsigned int horizontalDpi,
+ unsigned int verticalDpi)
+: mFreeTypeLibrary(nullptr),
+ mDpiHorizontal(horizontalDpi),
+ mDpiVertical(verticalDpi),
mDefaultFontDescription(),
mSystemFonts(),
mDefaultFonts(),
mFontDescriptionCache(),
mCharacterSetCache(),
mFontDescriptionSizeCache(),
- mVectorFontCache( nullptr ),
+ mVectorFontCache(nullptr),
mEllipsisCache(),
mEmbeddedItemCache(),
- mDefaultFontDescriptionCached( false )
+ mDefaultFontDescriptionCached(false)
{
- int error = FT_Init_FreeType( &mFreeTypeLibrary );
- if( FT_Err_Ok != error )
+ int error = FT_Init_FreeType(&mFreeTypeLibrary);
+ if(FT_Err_Ok != error)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FreeType Init error: %d\n", error );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FreeType Init error: %d\n", error);
}
#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
- mVectorFontCache = new VectorFontCache( mFreeTypeLibrary );
+ mVectorFontCache = new VectorFontCache(mFreeTypeLibrary);
#endif
}
FontClient::Plugin::~Plugin()
{
- ClearFallbackCache( mFallbackCache );
+ ClearFallbackCache(mFallbackCache);
// Free the resources allocated by the FcCharSet objects.
- DestroyCharacterSets( mDefaultFontCharacterSets );
- DestroyCharacterSets( mCharacterSetCache );
+ DestroyCharacterSets(mDefaultFontCharacterSets);
+ DestroyCharacterSets(mCharacterSetCache);
ClearCharacterSetFromFontFaceCache();
#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
delete mVectorFontCache;
#endif
- FT_Done_FreeType( mFreeTypeLibrary );
+ FT_Done_FreeType(mFreeTypeLibrary);
}
void FontClient::Plugin::ClearCache()
mSystemFonts.clear();
mDefaultFonts.clear();
- DestroyCharacterSets( mDefaultFontCharacterSets );
+ DestroyCharacterSets(mDefaultFontCharacterSets);
mDefaultFontCharacterSets.Clear();
- ClearFallbackCache( mFallbackCache );
+ ClearFallbackCache(mFallbackCache);
mFallbackCache.clear();
mFontIdCache.Clear();
mValidatedFontCache.clear();
mFontDescriptionCache.clear();
- DestroyCharacterSets( mCharacterSetCache );
+ DestroyCharacterSets(mCharacterSetCache);
mCharacterSetCache.Clear();
mFontDescriptionSizeCache.clear();
mDefaultFontDescriptionCached = false;
}
-void FontClient::Plugin::SetDpi( unsigned int horizontalDpi,
- unsigned int verticalDpi )
+void FontClient::Plugin::SetDpi(unsigned int horizontalDpi,
+ unsigned int verticalDpi)
{
mDpiHorizontal = horizontalDpi;
- mDpiVertical = verticalDpi;
+ mDpiVertical = verticalDpi;
}
void FontClient::Plugin::ResetSystemDefaults()
mDefaultFontDescriptionCached = false;
}
-void FontClient::Plugin::SetFontList( const FontDescription& fontDescription, FontList& fontList, CharacterSetList& characterSetList )
+void FontClient::Plugin::SetFontList(const FontDescription& fontDescription, FontList& fontList, CharacterSetList& characterSetList)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::SetFontList\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::SetFontList\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
fontList.clear();
- FcPattern* fontFamilyPattern = CreateFontFamilyPattern( fontDescription ); // Creates a pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription); // Creates a pattern that needs to be destroyed by calling FcPatternDestroy.
FcResult result = FcResultMatch;
// Match the pattern.
- FcFontSet* fontSet = FcFontSort( nullptr /* use default configure */,
- fontFamilyPattern,
- false /* don't trim */,
- nullptr,
- &result ); // FcFontSort creates a font set that needs to be destroyed by calling FcFontSetDestroy.
+ FcFontSet* fontSet = FcFontSort(nullptr /* use default configure */,
+ fontFamilyPattern,
+ false /* don't trim */,
+ nullptr,
+ &result); // FcFontSort creates a font set that needs to be destroyed by calling FcFontSetDestroy.
- if( nullptr != fontSet )
+ if(nullptr != fontSet)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " number of fonts found : [%d]\n", fontSet->nfont );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " number of fonts found : [%d]\n", fontSet->nfont);
// Reserve some space to avoid reallocations.
- fontList.reserve( fontSet->nfont );
+ fontList.reserve(fontSet->nfont);
- for( int i = 0u; i < fontSet->nfont; ++i )
+ for(int i = 0u; i < fontSet->nfont; ++i)
{
FcPattern* fontPattern = fontSet->fonts[i];
FontPath path;
// Skip fonts with no path
- if( GetFcString( fontPattern, FC_FILE, path ) )
+ if(GetFcString(fontPattern, FC_FILE, path))
{
// Retrieve the character set. Need to call FcCharSetDestroy to free the resources.
FcCharSet* characterSet = nullptr;
- FcPatternGetCharSet( fontPattern, FC_CHARSET, 0u, &characterSet );
+ FcPatternGetCharSet(fontPattern, FC_CHARSET, 0u, &characterSet);
// Increase the reference counter of the character set.
- characterSetList.PushBack( FcCharSetCopy( characterSet ) );
+ characterSetList.PushBack(FcCharSetCopy(characterSet));
- fontList.push_back( FontDescription() );
+ fontList.push_back(FontDescription());
FontDescription& newFontDescription = fontList.back();
- newFontDescription.path = std::move( path );
+ newFontDescription.path = std::move(path);
- int width = 0;
+ int width = 0;
int weight = 0;
- int slant = 0;
- GetFcString( fontPattern, FC_FAMILY, newFontDescription.family );
- GetFcInt( fontPattern, FC_WIDTH, width );
- GetFcInt( fontPattern, FC_WEIGHT, weight );
- GetFcInt( fontPattern, FC_SLANT, slant );
- newFontDescription.width = IntToWidthType( width );
- newFontDescription.weight = IntToWeightType( weight );
- newFontDescription.slant = IntToSlantType( slant );
-
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " description; family : [%s]\n", newFontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", newFontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[newFontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[newFontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[newFontDescription.slant] );
+ int slant = 0;
+ GetFcString(fontPattern, FC_FAMILY, newFontDescription.family);
+ GetFcInt(fontPattern, FC_WIDTH, width);
+ GetFcInt(fontPattern, FC_WEIGHT, weight);
+ GetFcInt(fontPattern, FC_SLANT, slant);
+ newFontDescription.width = IntToWidthType(width);
+ newFontDescription.weight = IntToWeightType(weight);
+ newFontDescription.slant = IntToSlantType(slant);
+
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " description; family : [%s]\n", newFontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", newFontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[newFontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[newFontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[newFontDescription.slant]);
}
}
// Destroys the font set created by FcFontSort.
- FcFontSetDestroy( fontSet );
+ FcFontSetDestroy(fontSet);
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " No fonts found.\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " No fonts found.\n");
}
// Destroys the pattern created by FcPatternCreate in CreateFontFamilyPattern.
- FcPatternDestroy( fontFamilyPattern );
+ FcPatternDestroy(fontFamilyPattern);
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::SetFontList\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::SetFontList\n");
}
-void FontClient::Plugin::GetDefaultFonts( FontList& defaultFonts )
+void FontClient::Plugin::GetDefaultFonts(FontList& defaultFonts)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetDefaultFonts\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetDefaultFonts\n");
- if( mDefaultFonts.empty() )
+ if(mDefaultFonts.empty())
{
FontDescription fontDescription;
- fontDescription.family = DEFAULT_FONT_FAMILY_NAME; // todo This could be set to the Platform font
- fontDescription.width = IntToWidthType( DEFAULT_FONT_WIDTH );
- fontDescription.weight = IntToWeightType( DEFAULT_FONT_WEIGHT );
- fontDescription.slant = IntToSlantType( DEFAULT_FONT_SLANT );
- SetFontList( fontDescription, mDefaultFonts, mDefaultFontCharacterSets );
+ fontDescription.family = DEFAULT_FONT_FAMILY_NAME; // todo This could be set to the Platform font
+ fontDescription.width = IntToWidthType(DEFAULT_FONT_WIDTH);
+ fontDescription.weight = IntToWeightType(DEFAULT_FONT_WEIGHT);
+ fontDescription.slant = IntToSlantType(DEFAULT_FONT_SLANT);
+ SetFontList(fontDescription, mDefaultFonts, mDefaultFontCharacterSets);
}
defaultFonts = mDefaultFonts;
- DALI_LOG_INFO( gLogFilter, Debug::General, " number of default fonts : [%d]\n", mDefaultFonts.size() );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetDefaultFonts\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " number of default fonts : [%d]\n", mDefaultFonts.size());
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetDefaultFonts\n");
}
-void FontClient::Plugin::GetDefaultPlatformFontDescription( FontDescription& fontDescription )
+void FontClient::Plugin::GetDefaultPlatformFontDescription(FontDescription& fontDescription)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetDefaultPlatformFontDescription\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetDefaultPlatformFontDescription\n");
- if( !mDefaultFontDescriptionCached )
+ if(!mDefaultFontDescriptionCached)
{
// Clear any font config stored info in the caches.
// Decrease the reference counter and eventually free the resources allocated by FcCharSet objects.
- DestroyCharacterSets( mDefaultFontCharacterSets );
- DestroyCharacterSets( mCharacterSetCache );
+ DestroyCharacterSets(mDefaultFontCharacterSets);
+ DestroyCharacterSets(mCharacterSetCache);
mDefaultFontCharacterSets.Clear();
mCharacterSetCache.Clear();
- for( auto& item : mFallbackCache )
+ for(auto& item : mFallbackCache)
{
// Decrease the reference counter and eventually free the resources allocated by FcCharSet objects.
- DestroyCharacterSets( *item.characterSets );
+ DestroyCharacterSets(*item.characterSets);
delete item.characterSets;
item.characterSets = nullptr;
FcPattern* matchPattern = FcPatternCreate(); // Creates a pattern that needs to be destroyed by calling FcPatternDestroy.
- if( nullptr != matchPattern )
+ if(nullptr != matchPattern)
{
- FcConfigSubstitute( nullptr, matchPattern, FcMatchPattern );
- FcDefaultSubstitute( matchPattern );
+ FcConfigSubstitute(nullptr, matchPattern, FcMatchPattern);
+ FcDefaultSubstitute(matchPattern);
FcCharSet* characterSet = nullptr;
- MatchFontDescriptionToPattern( matchPattern, mDefaultFontDescription, &characterSet );
+ MatchFontDescriptionToPattern(matchPattern, mDefaultFontDescription, &characterSet);
// Decrease the reference counter of the character set as it's not stored.
- FcCharSetDestroy( characterSet );
+ FcCharSetDestroy(characterSet);
// Destroys the pattern created.
- FcPatternDestroy( matchPattern );
+ FcPatternDestroy(matchPattern);
}
// Create again the character sets as they are not valid after FcInitReinitialize()
- for( const auto& description : mDefaultFonts )
+ for(const auto& description : mDefaultFonts)
{
- mDefaultFontCharacterSets.PushBack( FcCharSetCopy( CreateCharacterSetFromDescription( description ) ) );
+ mDefaultFontCharacterSets.PushBack(FcCharSetCopy(CreateCharacterSetFromDescription(description)));
}
- for( const auto& description : mFontDescriptionCache )
+ for(const auto& description : mFontDescriptionCache)
{
- mCharacterSetCache.PushBack( FcCharSetCopy( CreateCharacterSetFromDescription( description ) ) );
+ mCharacterSetCache.PushBack(FcCharSetCopy(CreateCharacterSetFromDescription(description)));
}
- for( auto& item : mFallbackCache )
+ for(auto& item : mFallbackCache)
{
- if( nullptr != item.fallbackFonts )
+ if(nullptr != item.fallbackFonts)
{
- if( nullptr == item.characterSets )
+ if(nullptr == item.characterSets)
{
item.characterSets = new CharacterSetList;
}
- for( const auto& description : *( item.fallbackFonts ) )
+ for(const auto& description : *(item.fallbackFonts))
{
- item.characterSets->PushBack( FcCharSetCopy( CreateCharacterSetFromDescription( description ) ) );
+ item.characterSets->PushBack(FcCharSetCopy(CreateCharacterSetFromDescription(description)));
}
}
}
fontDescription.weight = mDefaultFontDescription.weight;
fontDescription.slant = mDefaultFontDescription.slant;
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetDefaultPlatformFontDescription\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetDefaultPlatformFontDescription\n");
}
-void FontClient::Plugin::GetSystemFonts( FontList& systemFonts )
+void FontClient::Plugin::GetSystemFonts(FontList& systemFonts)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetSystemFonts\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetSystemFonts\n");
- if( mSystemFonts.empty() )
+ if(mSystemFonts.empty())
{
InitSystemFonts();
}
systemFonts = mSystemFonts;
- DALI_LOG_INFO( gLogFilter, Debug::General, " number of system fonts : [%d]\n", mSystemFonts.size() );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetSystemFonts\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " number of system fonts : [%d]\n", mSystemFonts.size());
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetSystemFonts\n");
}
-void FontClient::Plugin::GetDescription( FontId id,
- FontDescription& fontDescription ) const
+void FontClient::Plugin::GetDescription(FontId id,
+ FontDescription& fontDescription) const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetDescription\n");
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", id );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetDescription\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", id);
const FontId index = id - 1u;
- if( ( id > 0u ) && ( index < mFontIdCache.Count() ) )
+ if((id > 0u) && (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
- for( const auto& item : mFontDescriptionSizeCache )
+ for(const auto& item : mFontDescriptionSizeCache)
{
- if( item.fontId == fontIdCacheItem.id )
+ if(item.fontId == fontIdCacheItem.id)
{
- fontDescription = *( mFontDescriptionCache.begin() + item.validatedFontId - 1u );
-
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetDescription\n");
+ fontDescription = *(mFontDescriptionCache.begin() + item.validatedFontId - 1u);
+
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetDescription\n");
return;
}
}
}
case FontDescription::BITMAP_FONT:
{
- fontDescription.type = FontDescription::BITMAP_FONT;
+ fontDescription.type = FontDescription::BITMAP_FONT;
fontDescription.family = mBitmapFontCache[fontIdCacheItem.id].font.name;
break;
}
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " No description found for the font ID %d\n", id );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetDescription\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " No description found for the font ID %d\n", id);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetDescription\n");
}
-PointSize26Dot6 FontClient::Plugin::GetPointSize( FontId id )
+PointSize26Dot6 FontClient::Plugin::GetPointSize(FontId id)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetPointSize\n");
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", id );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetPointSize\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", id);
const FontId index = id - 1u;
- if( ( id > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((id > 0u) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " point size : %d\n", ( *( mFontFaceCache.begin() + fontIdCacheItem.id ) ).mRequestedPointSize );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetPointSize\n");
- return ( *( mFontFaceCache.begin() + fontIdCacheItem.id ) ).mRequestedPointSize;
+ DALI_LOG_INFO(gLogFilter, Debug::General, " point size : %d\n", (*(mFontFaceCache.begin() + fontIdCacheItem.id)).mRequestedPointSize);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetPointSize\n");
+ return (*(mFontFaceCache.begin() + fontIdCacheItem.id)).mRequestedPointSize;
}
case FontDescription::BITMAP_FONT:
{
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " Invalid font ID %d\n", id );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " Invalid font ID %d\n", id);
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " default point size : %d\n", TextAbstraction::FontClient::DEFAULT_POINT_SIZE );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetPointSize\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " default point size : %d\n", TextAbstraction::FontClient::DEFAULT_POINT_SIZE);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetPointSize\n");
return TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
}
-bool FontClient::Plugin::IsCharacterSupportedByFont( FontId fontId, Character character )
+bool FontClient::Plugin::IsCharacterSupportedByFont(FontId fontId, Character character)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::IsCharacterSupportedByFont\n");
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, " character : %p\n", character );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::IsCharacterSupportedByFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " character : %p\n", character);
- if( ( fontId < 1u ) || ( fontId > mFontIdCache.Count() ) )
+ if((fontId < 1u) || (fontId > mFontIdCache.Count()))
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " Invalid font id. Number of items in the cache: %d\n",mFontIdCache.Count());
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::IsCharacterSupportedByFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " Invalid font id. Number of items in the cache: %d\n", mFontIdCache.Count());
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::IsCharacterSupportedByFont\n");
return false;
}
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[fontId];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
- if( fontIdCacheItem.id < mFontFaceCache.size() )
+ if(fontIdCacheItem.id < mFontFaceCache.size())
{
FontFaceCacheItem& cacheItem = mFontFaceCache[fontIdCacheItem.id];
- if( nullptr == cacheItem.mCharacterSet )
+ if(nullptr == cacheItem.mCharacterSet)
{
// Create again the character set.
// It can be null if the ResetSystemDefaults() method has been called.
FontDescription description;
- description.path = cacheItem.mPath;
- description.family = std::move( FontFamily( cacheItem.mFreeTypeFace->family_name ) );
+ description.path = cacheItem.mPath;
+ description.family = std::move(FontFamily(cacheItem.mFreeTypeFace->family_name));
description.weight = FontWeight::NONE;
- description.width = FontWidth::NONE;
- description.slant = FontSlant::NONE;
+ description.width = FontWidth::NONE;
+ description.slant = FontSlant::NONE;
// Note FreeType doesn't give too much info to build a proper font style.
- if( cacheItem.mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC )
+ if(cacheItem.mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC)
{
description.slant = FontSlant::ITALIC;
}
- if( cacheItem.mFreeTypeFace->style_flags & FT_STYLE_FLAG_BOLD )
+ if(cacheItem.mFreeTypeFace->style_flags & FT_STYLE_FLAG_BOLD)
{
description.weight = FontWeight::BOLD;
}
- cacheItem.mCharacterSet = FcCharSetCopy( CreateCharacterSetFromDescription( description ) );
+ cacheItem.mCharacterSet = FcCharSetCopy(CreateCharacterSetFromDescription(description));
}
- isSupported = FcCharSetHasChar( cacheItem.mCharacterSet, character );
+ isSupported = FcCharSetHasChar(cacheItem.mCharacterSet, character);
}
break;
}
{
const BitmapFont& bitmapFont = mBitmapFontCache[fontIdCacheItem.id].font;
- for( const auto& glyph : bitmapFont.glyphs )
+ for(const auto& glyph : bitmapFont.glyphs)
{
- if( glyph.utf32 == character )
+ if(glyph.utf32 == character)
{
isSupported = true;
break;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " is supported : %s\n", (isSupported ? "true" : "false") );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::IsCharacterSupportedByFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " is supported : %s\n", (isSupported ? "true" : "false"));
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::IsCharacterSupportedByFont\n");
return isSupported;
}
-FontId FontClient::Plugin::FindFontForCharacter( const FontList& fontList,
- const CharacterSetList& characterSetList,
- Character character,
- PointSize26Dot6 requestedPointSize,
- bool preferColor )
+FontId FontClient::Plugin::FindFontForCharacter(const FontList& fontList,
+ const CharacterSetList& characterSetList,
+ Character character,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor)
{
- DALI_ASSERT_DEBUG( ( fontList.size() == characterSetList.Count() ) && "FontClient::Plugin::FindFontForCharacter. Different number of fonts and character sets." );
+ DALI_ASSERT_DEBUG((fontList.size() == characterSetList.Count()) && "FontClient::Plugin::FindFontForCharacter. Different number of fonts and character sets.");
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindFontForCharacter\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " character : %p\n", character );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
- DALI_LOG_INFO( gLogFilter, Debug::General, " preferColor : %s\n", ( preferColor ? "true" : "false" ) );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindFontForCharacter\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " character : %p\n", character);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " preferColor : %s\n", (preferColor ? "true" : "false"));
- FontId fontId = 0u;
- bool foundColor = false;
+ FontId fontId = 0u;
+ bool foundColor = false;
- DALI_LOG_INFO( gLogFilter, Debug::General, " number of fonts : %d\n", fontList.size() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " number of fonts : %d\n", fontList.size());
// Traverse the list of fonts.
// Check for each font if supports the character.
- for( unsigned int index = 0u, numberOfFonts = fontList.size(); index < numberOfFonts; ++index )
+ for(unsigned int index = 0u, numberOfFonts = fontList.size(); index < numberOfFonts; ++index)
{
- const FontDescription& description = fontList[index];
+ const FontDescription& description = fontList[index];
const FcCharSet* const characterSet = characterSetList[index];
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " description; family : [%s]\n", description.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", description.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[description.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[description.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[description.slant] );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " description; family : [%s]\n", description.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", description.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[description.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[description.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[description.slant]);
bool foundInRanges = false;
- if( nullptr != characterSet )
+ if(nullptr != characterSet)
{
- foundInRanges = FcCharSetHasChar( characterSet, character );
+ foundInRanges = FcCharSetHasChar(characterSet, character);
}
- if( foundInRanges )
+ if(foundInRanges)
{
- fontId = GetFontId( description,
- requestedPointSize,
- 0u );
+ fontId = GetFontId(description,
+ requestedPointSize,
+ 0u);
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " font id : %d\n", fontId );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " font id : %d\n", fontId);
- if( preferColor )
+ if(preferColor)
{
- if( ( fontId > 0 ) &&
- ( fontId - 1u < mFontIdCache.Count() ) )
+ if((fontId > 0) &&
+ (fontId - 1u < mFontIdCache.Count()))
{
const FontFaceCacheItem& item = mFontFaceCache[mFontIdCache[fontId - 1u].id];
foundColor = item.mHasColorTables;
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " foundColor : %s\n", ( foundColor ? "true" : "false" ) );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " foundColor : %s\n", (foundColor ? "true" : "false"));
}
// Keep going unless we prefer a different (color) font.
- if( !preferColor || foundColor )
+ if(!preferColor || foundColor)
{
break;
}
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFontForCharacter\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFontForCharacter\n");
return fontId;
}
-FontId FontClient::Plugin::FindDefaultFont( Character charcode,
- PointSize26Dot6 requestedPointSize,
- bool preferColor )
+FontId FontClient::Plugin::FindDefaultFont(Character charcode,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindDefaultFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " character : %p\n", charcode );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
- DALI_LOG_INFO( gLogFilter, Debug::General, " preferColor : %s\n", ( preferColor ? "true" : "false" ) );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindDefaultFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " character : %p\n", charcode);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " preferColor : %s\n", (preferColor ? "true" : "false"));
FontId fontId(0);
// Create the list of default fonts if it has not been created.
- if( mDefaultFonts.empty() )
+ if(mDefaultFonts.empty())
{
FontDescription fontDescription;
fontDescription.family = DEFAULT_FONT_FAMILY_NAME;
- fontDescription.width = IntToWidthType( DEFAULT_FONT_WIDTH );
- fontDescription.weight = IntToWeightType( DEFAULT_FONT_WEIGHT );
- fontDescription.slant = IntToSlantType( DEFAULT_FONT_SLANT );
+ fontDescription.width = IntToWidthType(DEFAULT_FONT_WIDTH);
+ fontDescription.weight = IntToWeightType(DEFAULT_FONT_WEIGHT);
+ fontDescription.slant = IntToSlantType(DEFAULT_FONT_SLANT);
- SetFontList( fontDescription, mDefaultFonts, mDefaultFontCharacterSets );
+ SetFontList(fontDescription, mDefaultFonts, mDefaultFontCharacterSets);
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " number of default fonts : %d\n", mDefaultFonts.size() );
-
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " number of default fonts : %d\n", mDefaultFonts.size());
// Traverse the list of default fonts.
// Check for each default font if supports the character.
- fontId = FindFontForCharacter( mDefaultFonts, mDefaultFontCharacterSets, charcode, requestedPointSize, preferColor );
+ fontId = FindFontForCharacter(mDefaultFonts, mDefaultFontCharacterSets, charcode, requestedPointSize, preferColor);
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindDefaultFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindDefaultFont\n");
return fontId;
}
-FontId FontClient::Plugin::FindFallbackFont( Character charcode,
- const FontDescription& preferredFontDescription,
- PointSize26Dot6 requestedPointSize,
- bool preferColor )
+FontId FontClient::Plugin::FindFallbackFont(Character charcode,
+ const FontDescription& preferredFontDescription,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindFallbackFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " character : %p\n", charcode );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
- DALI_LOG_INFO( gLogFilter, Debug::General, " preferColor : %s\n", ( preferColor ? "true" : "false" ) );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindFallbackFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " character : %p\n", charcode);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " preferColor : %s\n", (preferColor ? "true" : "false"));
// The font id to be returned.
FontId fontId = 0u;
// Fill the font description with the preferred font description and complete with the defaults.
fontDescription.family = preferredFontDescription.family.empty() ? DEFAULT_FONT_FAMILY_NAME : preferredFontDescription.family;
- fontDescription.weight = ( ( FontWeight::NONE == preferredFontDescription.weight ) ? IntToWeightType( DEFAULT_FONT_WEIGHT ) : preferredFontDescription.weight );
- fontDescription.width = ( ( FontWidth::NONE == preferredFontDescription.width ) ? IntToWidthType( DEFAULT_FONT_WIDTH ) : preferredFontDescription.width );
- fontDescription.slant = ( ( FontSlant::NONE == preferredFontDescription.slant ) ? IntToSlantType( DEFAULT_FONT_SLANT ) : preferredFontDescription.slant );
+ fontDescription.weight = ((FontWeight::NONE == preferredFontDescription.weight) ? IntToWeightType(DEFAULT_FONT_WEIGHT) : preferredFontDescription.weight);
+ fontDescription.width = ((FontWidth::NONE == preferredFontDescription.width) ? IntToWidthType(DEFAULT_FONT_WIDTH) : preferredFontDescription.width);
+ fontDescription.slant = ((FontSlant::NONE == preferredFontDescription.slant) ? IntToSlantType(DEFAULT_FONT_SLANT) : preferredFontDescription.slant);
- DALI_LOG_INFO( gLogFilter, Debug::General, " preferredFontDescription --> fontDescription\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " [%s] --> [%s]\n", preferredFontDescription.family.c_str(), fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWeight::Name[preferredFontDescription.weight], FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWidth::Name[preferredFontDescription.width], FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontSlant::Name[preferredFontDescription.slant], FontSlant::Name[fontDescription.slant] );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " preferredFontDescription --> fontDescription\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " [%s] --> [%s]\n", preferredFontDescription.family.c_str(), fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWeight::Name[preferredFontDescription.weight], FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontWidth::Name[preferredFontDescription.width], FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " [%s] --> [%s]\n", FontSlant::Name[preferredFontDescription.slant], FontSlant::Name[fontDescription.slant]);
// Check first if the font's description has been queried before.
- FontList* fontList = nullptr;
+ FontList* fontList = nullptr;
CharacterSetList* characterSetList = nullptr;
- if( !FindFallbackFontList( fontDescription, fontList, characterSetList ) )
+ if(!FindFallbackFontList(fontDescription, fontList, characterSetList))
{
- fontList = new FontList;
+ fontList = new FontList;
characterSetList = new CharacterSetList;
- SetFontList( fontDescription, *fontList, *characterSetList );
+ SetFontList(fontDescription, *fontList, *characterSetList);
#ifdef __APPLE__
FontDescription appleColorEmoji;
appleColorEmoji.family = "Apple Color Emoji";
- appleColorEmoji.width = fontDescription.width;
+ appleColorEmoji.width = fontDescription.width;
appleColorEmoji.weight = fontDescription.weight;
- appleColorEmoji.slant = fontDescription.slant;
- FontList emojiFontList;
+ appleColorEmoji.slant = fontDescription.slant;
+ FontList emojiFontList;
CharacterSetList emojiCharSetList;
SetFontList(appleColorEmoji, emojiFontList, emojiCharSetList);
std::move(fontList->begin(), fontList->end(), std::back_inserter(emojiFontList));
emojiCharSetList.Insert(emojiCharSetList.End(), characterSetList->Begin(), characterSetList->End());
- *fontList = std::move(emojiFontList);
+ *fontList = std::move(emojiFontList);
*characterSetList = std::move(emojiCharSetList);
#endif
// Add the font-list to the cache.
- mFallbackCache.push_back( std::move( FallbackCacheItem( std::move( fontDescription ), fontList, characterSetList ) ) );
+ mFallbackCache.push_back(std::move(FallbackCacheItem(std::move(fontDescription), fontList, characterSetList)));
}
- if( fontList && characterSetList )
+ if(fontList && characterSetList)
{
- fontId = FindFontForCharacter( *fontList, *characterSetList, charcode, requestedPointSize, preferColor );
+ fontId = FindFontForCharacter(*fontList, *characterSetList, charcode, requestedPointSize, preferColor);
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFallbackFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFallbackFont\n");
return fontId;
}
-FontId FontClient::Plugin::GetFontId( const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex,
- bool cacheDescription )
+FontId FontClient::Plugin::GetFontId(const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex,
+ bool cacheDescription)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetFontId\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " path : [%s]\n", path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetFontId\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " path : [%s]\n", path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
FontId id = 0u;
- if( nullptr != mFreeTypeLibrary )
+ if(nullptr != mFreeTypeLibrary)
{
FontId foundId = 0u;
- if( FindFont( path, requestedPointSize, faceIndex, foundId ) )
+ if(FindFont(path, requestedPointSize, faceIndex, foundId))
{
id = foundId;
}
else
{
- id = CreateFont( path, requestedPointSize, faceIndex, cacheDescription );
+ id = CreateFont(path, requestedPointSize, faceIndex, cacheDescription);
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", id );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetFontId\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", id);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetFontId\n");
return id;
}
-FontId FontClient::Plugin::GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex )
+FontId FontClient::Plugin::GetFontId(const FontDescription& fontDescription,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetFontId\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetFontId\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
// This method uses three vectors which caches:
// * The bitmap font cache
FontId fontId = 0u;
// Check first if the font description matches with a previously loaded bitmap font.
- if( FindBitmapFont( fontDescription.family, fontId ) )
+ if(FindBitmapFont(fontDescription.family, fontId))
{
return fontId;
}
// Check if the font's description have been validated before.
FontDescriptionId validatedFontId = 0u;
- if( !FindValidatedFont( fontDescription,
- validatedFontId ) )
+ if(!FindValidatedFont(fontDescription,
+ validatedFontId))
{
// Use font config to validate the font's description.
- ValidateFont( fontDescription,
- validatedFontId );
+ ValidateFont(fontDescription,
+ validatedFontId);
}
FontId fontFaceId = 0u;
// Check if exists a pair 'validatedFontId, requestedPointSize' in the cache.
- if( !FindFont( validatedFontId, requestedPointSize, fontFaceId ) )
+ if(!FindFont(validatedFontId, requestedPointSize, fontFaceId))
{
// Retrieve the font file name path.
- const FontDescription& description = *( mFontDescriptionCache.begin() + validatedFontId - 1u );
+ const FontDescription& description = *(mFontDescriptionCache.begin() + validatedFontId - 1u);
// Retrieve the font id. Do not cache the description as it has been already cached.
- fontId = GetFontId( description.path,
- requestedPointSize,
- faceIndex,
- false );
+ fontId = GetFontId(description.path,
+ requestedPointSize,
+ faceIndex,
+ false);
- fontFaceId = mFontIdCache[fontId-1u].id;
- mFontFaceCache[fontFaceId].mCharacterSet = FcCharSetCopy( mCharacterSetCache[validatedFontId - 1u] );
+ fontFaceId = mFontIdCache[fontId - 1u].id;
+ mFontFaceCache[fontFaceId].mCharacterSet = FcCharSetCopy(mCharacterSetCache[validatedFontId - 1u]);
// Cache the pair 'validatedFontId, requestedPointSize' to improve the following queries.
- mFontDescriptionSizeCache.push_back( FontDescriptionSizeCacheItem( validatedFontId,
- requestedPointSize,
- fontFaceId ) );
+ mFontDescriptionSizeCache.push_back(FontDescriptionSizeCacheItem(validatedFontId,
+ requestedPointSize,
+ fontFaceId));
}
else
{
fontId = mFontFaceCache[fontFaceId].mFontId + 1u;
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetFontId\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetFontId\n");
return fontId;
}
-FontId FontClient::Plugin::GetFontId( const BitmapFont& bitmapFont )
+FontId FontClient::Plugin::GetFontId(const BitmapFont& bitmapFont)
{
- for( const auto& item : mBitmapFontCache )
+ for(const auto& item : mBitmapFontCache)
{
- if( bitmapFont.name == item.font.name )
+ if(bitmapFont.name == item.font.name)
{
return item.id + 1u;
}
BitmapFontCacheItem bitmapFontCacheItem;
bitmapFontCacheItem.font = bitmapFont;
- bitmapFontCacheItem.id = mFontIdCache.Count();
+ bitmapFontCacheItem.id = mFontIdCache.Count();
// Resize the vector with the pixel buffers.
- bitmapFontCacheItem.pixelBuffers.resize( bitmapFont.glyphs.size() );
+ bitmapFontCacheItem.pixelBuffers.resize(bitmapFont.glyphs.size());
// Traverse all the glyphs and load the pixel buffer of those with ascender and descender equal to zero.
unsigned int index = 0u;
- for( auto& glyph : bitmapFontCacheItem.font.glyphs )
+ for(auto& glyph : bitmapFontCacheItem.font.glyphs)
{
Devel::PixelBuffer& pixelBuffer = bitmapFontCacheItem.pixelBuffers[index];
- if( EqualsZero( glyph.ascender ) && EqualsZero( glyph.descender ) )
+ if(EqualsZero(glyph.ascender) && EqualsZero(glyph.descender))
{
// Load the glyph.
- pixelBuffer = LoadImageFromFile( glyph.url );
+ pixelBuffer = LoadImageFromFile(glyph.url);
- if( pixelBuffer )
+ if(pixelBuffer)
{
glyph.ascender = static_cast<float>(pixelBuffer.GetHeight());
}
}
- bitmapFontCacheItem.font.ascender = std::max( glyph.ascender, bitmapFontCacheItem.font.ascender );
- bitmapFontCacheItem.font.descender = std::min( glyph.descender, bitmapFontCacheItem.font.descender );
+ bitmapFontCacheItem.font.ascender = std::max(glyph.ascender, bitmapFontCacheItem.font.ascender);
+ bitmapFontCacheItem.font.descender = std::min(glyph.descender, bitmapFontCacheItem.font.descender);
++index;
}
FontIdCacheItem fontIdCacheItem;
fontIdCacheItem.type = FontDescription::BITMAP_FONT;
- fontIdCacheItem.id = mBitmapFontCache.size();
+ fontIdCacheItem.id = mBitmapFontCache.size();
- mBitmapFontCache.push_back( std::move( bitmapFontCacheItem ) );
- mFontIdCache.PushBack( fontIdCacheItem );
+ mBitmapFontCache.push_back(std::move(bitmapFontCacheItem));
+ mFontIdCache.PushBack(fontIdCacheItem);
return bitmapFontCacheItem.id + 1u;
}
-void FontClient::Plugin::ValidateFont( const FontDescription& fontDescription,
- FontDescriptionId& validatedFontId )
+void FontClient::Plugin::ValidateFont(const FontDescription& fontDescription,
+ FontDescriptionId& validatedFontId)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::ValidateFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::ValidateFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
// Create a font pattern.
- FcPattern* fontFamilyPattern = CreateFontFamilyPattern( fontDescription );
+ FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription);
FontDescription description;
FcCharSet* characterSet = nullptr;
- bool matched = MatchFontDescriptionToPattern( fontFamilyPattern, description, &characterSet );
- FcPatternDestroy( fontFamilyPattern );
+ bool matched = MatchFontDescriptionToPattern(fontFamilyPattern, description, &characterSet);
+ FcPatternDestroy(fontFamilyPattern);
- if( matched && ( nullptr != characterSet ) )
+ if(matched && (nullptr != characterSet))
{
// Add the path to the cache.
description.type = FontDescription::FACE_FONT;
- mFontDescriptionCache.push_back( description );
+ mFontDescriptionCache.push_back(description);
// Set the index to the vector of paths to font file names.
validatedFontId = mFontDescriptionCache.size();
- DALI_LOG_INFO( gLogFilter, Debug::General, " matched description; family : [%s]\n", description.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", description.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[description.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[description.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[description.slant] );
- DALI_LOG_INFO( gLogFilter, Debug::General, " validatedFontId : %d\n", validatedFontId );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " matched description; family : [%s]\n", description.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", description.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[description.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[description.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[description.slant]);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " validatedFontId : %d\n", validatedFontId);
// The reference counter of the character set has already been increased in MatchFontDescriptionToPattern.
- mCharacterSetCache.PushBack( characterSet );
+ mCharacterSetCache.PushBack(characterSet);
// Cache the index and the matched font's description.
- FontDescriptionCacheItem item( description,
- validatedFontId );
+ FontDescriptionCacheItem item(description,
+ validatedFontId);
- mValidatedFontCache.push_back( std::move( item ) );
+ mValidatedFontCache.push_back(std::move(item));
- if( ( fontDescription.family != description.family ) ||
- ( fontDescription.width != description.width ) ||
- ( fontDescription.weight != description.weight ) ||
- ( fontDescription.slant != description.slant ) )
+ if((fontDescription.family != description.family) ||
+ (fontDescription.width != description.width) ||
+ (fontDescription.weight != description.weight) ||
+ (fontDescription.slant != description.slant))
{
// Cache the given font's description if it's different than the matched.
- FontDescriptionCacheItem item( fontDescription,
- validatedFontId );
+ FontDescriptionCacheItem item(fontDescription,
+ validatedFontId);
- mValidatedFontCache.push_back( std::move( item ) );
+ mValidatedFontCache.push_back(std::move(item));
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " font validation failed for font [%s]\n", fontDescription.family.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font validation failed for font [%s]\n", fontDescription.family.c_str());
}
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::ValidateFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::ValidateFont\n");
}
-void FontClient::Plugin::GetFontMetrics( FontId fontId,
- FontMetrics& metrics )
+void FontClient::Plugin::GetFontMetrics(FontId fontId,
+ FontMetrics& metrics)
{
const FontId index = fontId - 1u;
- if( ( fontId > 0 ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
metrics = font.mMetrics;
// Adjust the metrics if the fixed-size font should be down-scaled
- if( font.mIsFixedSizeBitmap )
+ if(font.mIsFixedSizeBitmap)
{
- const float desiredFixedSize = static_cast<float>( font.mRequestedPointSize ) * FROM_266 / POINTS_PER_INCH * mDpiVertical;
+ const float desiredFixedSize = static_cast<float>(font.mRequestedPointSize) * FROM_266 / POINTS_PER_INCH * mDpiVertical;
- if( desiredFixedSize > 0.f )
+ if(desiredFixedSize > 0.f)
{
const float scaleFactor = desiredFixedSize / font.mFixedHeightPixels;
- metrics.ascender = metrics.ascender * scaleFactor;
- metrics.descender = metrics.descender * scaleFactor;
- metrics.height = metrics.height * scaleFactor;
- metrics.underlinePosition = metrics.underlinePosition * scaleFactor;
+ metrics.ascender = metrics.ascender * scaleFactor;
+ metrics.descender = metrics.descender * scaleFactor;
+ metrics.height = metrics.height * scaleFactor;
+ metrics.underlinePosition = metrics.underlinePosition * scaleFactor;
metrics.underlineThickness = metrics.underlineThickness * scaleFactor;
}
}
{
const BitmapFontCacheItem& bitmapFontCacheItem = mBitmapFontCache[fontIdCacheItem.id];
- metrics.ascender = bitmapFontCacheItem.font.ascender;
- metrics.descender = bitmapFontCacheItem.font.descender;
- metrics.height = metrics.ascender - metrics.descender;
- metrics.underlinePosition = bitmapFontCacheItem.font.underlinePosition;
+ metrics.ascender = bitmapFontCacheItem.font.ascender;
+ metrics.descender = bitmapFontCacheItem.font.descender;
+ metrics.height = metrics.ascender - metrics.descender;
+ metrics.underlinePosition = bitmapFontCacheItem.font.underlinePosition;
metrics.underlineThickness = bitmapFontCacheItem.font.underlineThickness;
break;
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::GetFontMetrics. Invalid font id : %d\n", fontId );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::GetFontMetrics. Invalid font id : %d\n", fontId);
}
}
-GlyphIndex FontClient::Plugin::GetGlyphIndex( FontId fontId,
- Character charcode )
+GlyphIndex FontClient::Plugin::GetGlyphIndex(FontId fontId,
+ Character charcode)
{
- GlyphIndex glyphIndex = 0u;
- const FontId index = fontId - 1u;
+ GlyphIndex glyphIndex = 0u;
+ const FontId index = fontId - 1u;
- if( ( fontId > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0u) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- if( FontDescription::FACE_FONT == fontIdCacheItem.type )
+ if(FontDescription::FACE_FONT == fontIdCacheItem.type)
{
FT_Face ftFace = mFontFaceCache[fontIdCacheItem.id].mFreeTypeFace;
- glyphIndex = FT_Get_Char_Index( ftFace, charcode );
+ glyphIndex = FT_Get_Char_Index(ftFace, charcode);
}
}
return glyphIndex;
}
-bool FontClient::Plugin::GetGlyphMetrics( GlyphInfo* array,
- uint32_t size,
- GlyphType type,
- bool horizontal )
+bool FontClient::Plugin::GetGlyphMetrics(GlyphInfo* array,
+ uint32_t size,
+ GlyphType type,
+ bool horizontal)
{
- if( VECTOR_GLYPH == type )
+ if(VECTOR_GLYPH == type)
{
- return GetVectorMetrics( array, size, horizontal );
+ return GetVectorMetrics(array, size, horizontal);
}
- return GetBitmapMetrics( array, size, horizontal );
+ return GetBitmapMetrics(array, size, horizontal);
}
-bool FontClient::Plugin::GetBitmapMetrics( GlyphInfo* array,
- uint32_t size,
- bool horizontal )
+bool FontClient::Plugin::GetBitmapMetrics(GlyphInfo* array,
+ uint32_t size,
+ bool horizontal)
{
- bool success( true );
+ bool success(true);
- for( unsigned int i=0; i<size; ++i )
+ for(unsigned int i = 0; i < size; ++i)
{
GlyphInfo& glyph = array[i];
FontId index = glyph.fontId - 1u;
- if( ( glyph.fontId > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((glyph.fontId > 0u) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
#ifdef FREETYPE_BITMAP_SUPPORT
// Check to see if we should be loading a Fixed Size bitmap?
- if( font.mIsFixedSizeBitmap )
+ if(font.mIsFixedSizeBitmap)
{
- FT_Select_Size( ftFace, font.mFixedSizeIndex ); ///< @todo: needs to be investigated why it's needed to select the size again.
- int error = FT_Load_Glyph( ftFace, glyph.index, FT_LOAD_COLOR );
- if ( FT_Err_Ok == error )
+ FT_Select_Size(ftFace, font.mFixedSizeIndex); ///< @todo: needs to be investigated why it's needed to select the size again.
+ int error = FT_Load_Glyph(ftFace, glyph.index, FT_LOAD_COLOR);
+ if(FT_Err_Ok == error)
{
- glyph.width = font.mFixedWidthPixels;
- glyph.height = font.mFixedHeightPixels;
- glyph.advance = font.mFixedWidthPixels;
+ glyph.width = font.mFixedWidthPixels;
+ glyph.height = font.mFixedHeightPixels;
+ glyph.advance = font.mFixedWidthPixels;
glyph.xBearing = 0.0f;
glyph.yBearing = font.mFixedHeightPixels;
// Adjust the metrics if the fixed-size font should be down-scaled
- const float desiredFixedSize = static_cast<float>( font.mRequestedPointSize ) * FROM_266 / POINTS_PER_INCH * mDpiVertical;
+ const float desiredFixedSize = static_cast<float>(font.mRequestedPointSize) * FROM_266 / POINTS_PER_INCH * mDpiVertical;
- if( desiredFixedSize > 0.f )
+ if(desiredFixedSize > 0.f)
{
const float scaleFactor = desiredFixedSize / font.mFixedHeightPixels;
- glyph.width = glyph.width * scaleFactor ;
- glyph.height = glyph.height * scaleFactor;
- glyph.advance = glyph.advance * scaleFactor;
+ glyph.width = glyph.width * scaleFactor;
+ glyph.height = glyph.height * scaleFactor;
+ glyph.advance = glyph.advance * scaleFactor;
glyph.xBearing = glyph.xBearing * scaleFactor;
glyph.yBearing = glyph.yBearing * scaleFactor;
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::GetBitmapMetrics. FreeType Bitmap Load_Glyph error %d\n", error );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::GetBitmapMetrics. FreeType Bitmap Load_Glyph error %d\n", error);
success = false;
}
}
// FT_LOAD_DEFAULT causes some issues in the alignment of the glyph inside the bitmap.
// i.e. with the SNum-3R font.
// @todo: add an option to use the FT_LOAD_DEFAULT if required?
- int error = FT_Load_Glyph( ftFace, glyph.index, FT_LOAD_NO_AUTOHINT );
+ int error = FT_Load_Glyph(ftFace, glyph.index, FT_LOAD_NO_AUTOHINT);
// Keep the width of the glyph before doing the software emboldening.
// It will be used to calculate a scale factor to be applied to the
// advance as Harfbuzz doesn't apply any SW emboldening to calculate
// the advance of the glyph.
- const float width = static_cast< float >( ftFace->glyph->metrics.width ) * FROM_266;
+ const float width = static_cast<float>(ftFace->glyph->metrics.width) * FROM_266;
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
- const bool isEmboldeningRequired = glyph.isBoldRequired && !( ftFace->style_flags & FT_STYLE_FLAG_BOLD );
- if( isEmboldeningRequired )
+ const bool isEmboldeningRequired = glyph.isBoldRequired && !(ftFace->style_flags & FT_STYLE_FLAG_BOLD);
+ if(isEmboldeningRequired)
{
// Does the software bold.
- FT_GlyphSlot_Embolden( ftFace->glyph );
+ FT_GlyphSlot_Embolden(ftFace->glyph);
}
- glyph.width = static_cast< float >( ftFace->glyph->metrics.width ) * FROM_266;
- glyph.height = static_cast< float >( ftFace->glyph->metrics.height ) * FROM_266;
- if( horizontal )
+ glyph.width = static_cast<float>(ftFace->glyph->metrics.width) * FROM_266;
+ glyph.height = static_cast<float>(ftFace->glyph->metrics.height) * FROM_266;
+ if(horizontal)
{
- glyph.xBearing += static_cast< float >( ftFace->glyph->metrics.horiBearingX ) * FROM_266;
- glyph.yBearing += static_cast< float >( ftFace->glyph->metrics.horiBearingY ) * FROM_266;
+ glyph.xBearing += static_cast<float>(ftFace->glyph->metrics.horiBearingX) * FROM_266;
+ glyph.yBearing += static_cast<float>(ftFace->glyph->metrics.horiBearingY) * FROM_266;
}
else
{
- glyph.xBearing += static_cast< float >( ftFace->glyph->metrics.vertBearingX ) * FROM_266;
- glyph.yBearing += static_cast< float >( ftFace->glyph->metrics.vertBearingY ) * FROM_266;
+ glyph.xBearing += static_cast<float>(ftFace->glyph->metrics.vertBearingX) * FROM_266;
+ glyph.yBearing += static_cast<float>(ftFace->glyph->metrics.vertBearingY) * FROM_266;
}
- if( isEmboldeningRequired && !Dali::EqualsZero( width ) )
+ if(isEmboldeningRequired && !Dali::EqualsZero(width))
{
// If the glyph is emboldened by software, the advance is multiplied by a
// scale factor to make it slightly bigger.
- glyph.advance *= ( glyph.width / width );
+ glyph.advance *= (glyph.width / width);
}
// Use the bounding box of the bitmap to correct the metrics.
// font's point size.
FT_Glyph ftGlyph;
- error = FT_Get_Glyph( ftFace->glyph, &ftGlyph );
+ error = FT_Get_Glyph(ftFace->glyph, &ftGlyph);
FT_BBox bbox;
- FT_Glyph_Get_CBox( ftGlyph, FT_GLYPH_BBOX_GRIDFIT, &bbox );
+ FT_Glyph_Get_CBox(ftGlyph, FT_GLYPH_BBOX_GRIDFIT, &bbox);
const float descender = glyph.height - glyph.yBearing;
- glyph.height = ( bbox.yMax - bbox.yMin) * FROM_266;
- glyph.yBearing = glyph.height - round( descender );
+ glyph.height = (bbox.yMax - bbox.yMin) * FROM_266;
+ glyph.yBearing = glyph.height - round(descender);
// Created FT_Glyph object must be released with FT_Done_Glyph
- FT_Done_Glyph( ftGlyph );
+ FT_Done_Glyph(ftGlyph);
}
else
{
BitmapFontCacheItem& bitmapFontCacheItem = mBitmapFontCache[fontIdCacheItem.id];
unsigned int index = 0u;
- for( auto& item : bitmapFontCacheItem.font.glyphs )
+ for(auto& item : bitmapFontCacheItem.font.glyphs)
{
- if( item.utf32 == glyph.index )
+ if(item.utf32 == glyph.index)
{
Devel::PixelBuffer& pixelBuffer = bitmapFontCacheItem.pixelBuffers[index];
- if( !pixelBuffer )
+ if(!pixelBuffer)
{
- pixelBuffer = LoadImageFromFile( item.url );
+ pixelBuffer = LoadImageFromFile(item.url);
}
- glyph.width = static_cast< float >( pixelBuffer.GetWidth() );
- glyph.height = static_cast< float >( pixelBuffer.GetHeight() );
- glyph.xBearing = 0.f;
- glyph.yBearing = glyph.height + item.descender;
- glyph.advance = glyph.width;
+ glyph.width = static_cast<float>(pixelBuffer.GetWidth());
+ glyph.height = static_cast<float>(pixelBuffer.GetHeight());
+ glyph.xBearing = 0.f;
+ glyph.yBearing = glyph.height + item.descender;
+ glyph.advance = glyph.width;
glyph.scaleFactor = 1.f;
break;
}
else
{
// Check if it's an embedded image.
- if( ( 0u == glyph.fontId ) && ( 0u != glyph.index ) && ( glyph.index <= mEmbeddedItemCache.Count() ) )
+ if((0u == glyph.fontId) && (0u != glyph.index) && (glyph.index <= mEmbeddedItemCache.Count()))
{
const EmbeddedItem& item = mEmbeddedItemCache[glyph.index - 1u];
- glyph.width = static_cast<float>( item.width );
- glyph.height = static_cast<float>( item.height );
- glyph.xBearing = 0.f;
- glyph.yBearing = glyph.height;
- glyph.advance = glyph.width;
+ glyph.width = static_cast<float>(item.width);
+ glyph.height = static_cast<float>(item.height);
+ glyph.xBearing = 0.f;
+ glyph.yBearing = glyph.height;
+ glyph.advance = glyph.width;
glyph.scaleFactor = 1.f;
}
else
return success;
}
-bool FontClient::Plugin::GetVectorMetrics( GlyphInfo* array,
- uint32_t size,
- bool horizontal )
+bool FontClient::Plugin::GetVectorMetrics(GlyphInfo* array,
+ uint32_t size,
+ bool horizontal)
{
#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
- bool success( true );
+ bool success(true);
- for( unsigned int i = 0u; i < size; ++i )
+ for(unsigned int i = 0u; i < size; ++i)
{
FontId fontId = array[i].fontId;
- if( ( fontId > 0u ) &&
- ( fontId - 1u ) < mFontIdCache.Count() )
+ if((fontId > 0u) &&
+ (fontId - 1u) < mFontIdCache.Count())
{
FontFaceCacheItem& font = mFontFaceCache[mFontIdCache[fontId - 1u].id];
- if( ! font.mVectorFontId )
+ if(!font.mVectorFontId)
{
- font.mVectorFontId = mVectorFontCache->GetFontId( font.mPath );
+ font.mVectorFontId = mVectorFontCache->GetFontId(font.mPath);
}
- mVectorFontCache->GetGlyphMetrics( font.mVectorFontId, array[i] );
+ mVectorFontCache->GetGlyphMetrics(font.mVectorFontId, array[i]);
// Vector metrics are in EMs, convert to pixels
- const float scale = ( static_cast<float>( font.mRequestedPointSize ) * FROM_266 ) * static_cast<float>( mDpiVertical ) / POINTS_PER_INCH;
- array[i].width *= scale;
- array[i].height *= scale;
+ const float scale = (static_cast<float>(font.mRequestedPointSize) * FROM_266) * static_cast<float>(mDpiVertical) / POINTS_PER_INCH;
+ array[i].width *= scale;
+ array[i].height *= scale;
array[i].xBearing *= scale;
array[i].yBearing *= scale;
- array[i].advance *= scale;
+ array[i].advance *= scale;
}
else
{
#endif
}
-void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
+void FontClient::Plugin::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth)
{
const FontId index = fontId - 1u;
- if( ( fontId > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0u) &&
+ (index < mFontIdCache.Count()))
{
data.isColorBitmap = false;
- data.isColorEmoji = false;
+ data.isColorEmoji = false;
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
bool isShearRequired = false;
const FontFaceCacheItem& fontFaceCacheItem = mFontFaceCache[fontIdCacheItem.id];
- FT_Face ftFace = fontFaceCacheItem.mFreeTypeFace;
+ FT_Face ftFace = fontFaceCacheItem.mFreeTypeFace;
FT_Error error;
#ifdef FREETYPE_BITMAP_SUPPORT
// Check to see if this is fixed size bitmap
- if( fontFaceCacheItem.mIsFixedSizeBitmap )
+ if(fontFaceCacheItem.mIsFixedSizeBitmap)
{
- error = FT_Load_Glyph( ftFace, glyphIndex, FT_LOAD_COLOR );
+ error = FT_Load_Glyph(ftFace, glyphIndex, FT_LOAD_COLOR);
}
else
#endif
// FT_LOAD_DEFAULT causes some issues in the alignment of the glyph inside the bitmap.
// i.e. with the SNum-3R font.
// @todo: add an option to use the FT_LOAD_DEFAULT if required?
- error = FT_Load_Glyph( ftFace, glyphIndex, FT_LOAD_NO_AUTOHINT );
+ error = FT_Load_Glyph(ftFace, glyphIndex, FT_LOAD_NO_AUTOHINT);
}
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
- if( isBoldRequired && !( ftFace->style_flags & FT_STYLE_FLAG_BOLD ) )
+ if(isBoldRequired && !(ftFace->style_flags & FT_STYLE_FLAG_BOLD))
{
// Does the software bold.
- FT_GlyphSlot_Embolden( ftFace->glyph );
+ FT_GlyphSlot_Embolden(ftFace->glyph);
}
- if( isItalicRequired && !( ftFace->style_flags & FT_STYLE_FLAG_ITALIC ) )
+ if(isItalicRequired && !(ftFace->style_flags & FT_STYLE_FLAG_ITALIC))
{
// Will do the software italic.
isShearRequired = true;
}
FT_Glyph glyph;
- error = FT_Get_Glyph( ftFace->glyph, &glyph );
+ error = FT_Get_Glyph(ftFace->glyph, &glyph);
// Convert to bitmap if necessary
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
- if( glyph->format != FT_GLYPH_FORMAT_BITMAP )
+ if(glyph->format != FT_GLYPH_FORMAT_BITMAP)
{
- int offsetX = 0, offsetY = 0;
- bool isOutlineGlyph = ( glyph->format == FT_GLYPH_FORMAT_OUTLINE && outlineWidth > 0 );
+ int offsetX = 0, offsetY = 0;
+ bool isOutlineGlyph = (glyph->format == FT_GLYPH_FORMAT_OUTLINE && outlineWidth > 0);
// Create a bitmap for the outline
- if( isOutlineGlyph )
+ if(isOutlineGlyph)
{
// Retrieve the horizontal and vertical distance from the current pen position to the
// left and top border of the glyph bitmap for a normal glyph before applying the outline.
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
FT_Glyph normalGlyph;
- error = FT_Get_Glyph( ftFace->glyph, &normalGlyph );
+ error = FT_Get_Glyph(ftFace->glyph, &normalGlyph);
- error = FT_Glyph_To_Bitmap( &normalGlyph, FT_RENDER_MODE_NORMAL, 0, 1 );
- if( FT_Err_Ok == error )
+ error = FT_Glyph_To_Bitmap(&normalGlyph, FT_RENDER_MODE_NORMAL, 0, 1);
+ if(FT_Err_Ok == error)
{
- FT_BitmapGlyph bitmapGlyph = reinterpret_cast< FT_BitmapGlyph >( normalGlyph );
+ FT_BitmapGlyph bitmapGlyph = reinterpret_cast<FT_BitmapGlyph>(normalGlyph);
offsetX = bitmapGlyph->left;
offsetY = bitmapGlyph->top;
}
// Created FT_Glyph object must be released with FT_Done_Glyph
- FT_Done_Glyph( normalGlyph );
+ FT_Done_Glyph(normalGlyph);
}
// Now apply the outline
// Set up a stroker
FT_Stroker stroker;
- error = FT_Stroker_New( mFreeTypeLibrary, &stroker );
+ error = FT_Stroker_New(mFreeTypeLibrary, &stroker);
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
- FT_Stroker_Set( stroker, outlineWidth * 64, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0 );
- error = FT_Glyph_StrokeBorder( &glyph, stroker, 0, 1 );
+ FT_Stroker_Set(stroker, outlineWidth * 64, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
+ error = FT_Glyph_StrokeBorder(&glyph, stroker, 0, 1);
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
- FT_Stroker_Done( stroker );
+ FT_Stroker_Done(stroker);
}
else
{
- DALI_LOG_ERROR( "FT_Glyph_StrokeBorder Failed with error: %d\n", error );
+ DALI_LOG_ERROR("FT_Glyph_StrokeBorder Failed with error: %d\n", error);
}
}
else
{
- DALI_LOG_ERROR( "FT_Stroker_New Failed with error: %d\n", error );
+ DALI_LOG_ERROR("FT_Stroker_New Failed with error: %d\n", error);
}
}
- error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, 0, 1 );
- if( FT_Err_Ok == error )
+ error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
+ if(FT_Err_Ok == error)
{
- FT_BitmapGlyph bitmapGlyph = reinterpret_cast< FT_BitmapGlyph >( glyph );
+ FT_BitmapGlyph bitmapGlyph = reinterpret_cast<FT_BitmapGlyph>(glyph);
- if( isOutlineGlyph )
+ if(isOutlineGlyph)
{
// Calculate the additional horizontal and vertical offsets needed for the position of the outline glyph
data.outlineOffsetX = offsetX - bitmapGlyph->left - outlineWidth;
data.outlineOffsetY = bitmapGlyph->top - offsetY - outlineWidth;
}
- ConvertBitmap( data, bitmapGlyph->bitmap, isShearRequired );
+ ConvertBitmap(data, bitmapGlyph->bitmap, isShearRequired);
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::CreateBitmap. FT_Get_Glyph Failed with error: %d\n", error );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::CreateBitmap. FT_Get_Glyph Failed with error: %d\n", error);
}
}
else
{
- ConvertBitmap( data, ftFace->glyph->bitmap, isShearRequired );
+ ConvertBitmap(data, ftFace->glyph->bitmap, isShearRequired);
}
data.isColorEmoji = fontFaceCacheItem.mIsFixedSizeBitmap;
// Created FT_Glyph object must be released with FT_Done_Glyph
- FT_Done_Glyph( glyph );
+ FT_Done_Glyph(glyph);
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::CreateBitmap. FT_Load_Glyph Failed with error: %d\n", error );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::CreateBitmap. FT_Load_Glyph Failed with error: %d\n", error);
}
break;
}
BitmapFontCacheItem& bitmapFontCacheItem = mBitmapFontCache[fontIdCacheItem.id];
unsigned int index = 0u;
- for( auto& item : bitmapFontCacheItem.font.glyphs )
+ for(auto& item : bitmapFontCacheItem.font.glyphs)
{
- if( item.utf32 == glyphIndex )
+ if(item.utf32 == glyphIndex)
{
Devel::PixelBuffer& pixelBuffer = bitmapFontCacheItem.pixelBuffers[index];
- if( !pixelBuffer )
+ if(!pixelBuffer)
{
- pixelBuffer = LoadImageFromFile( item.url );
+ pixelBuffer = LoadImageFromFile(item.url);
}
- data.width = pixelBuffer.GetWidth();
+ data.width = pixelBuffer.GetWidth();
data.height = pixelBuffer.GetHeight();
data.isColorBitmap = bitmapFontCacheItem.font.isColorFont;
- ConvertBitmap( data, data.width, data.height, pixelBuffer.GetBuffer() );
+ ConvertBitmap(data, data.width, data.height, pixelBuffer.GetBuffer());
// Sets the pixel format.
data.format = pixelBuffer.GetPixelFormat();
}
else
{
- if( ( 0u != glyphIndex ) && ( glyphIndex <= mEmbeddedItemCache.Count() ) )
+ if((0u != glyphIndex) && (glyphIndex <= mEmbeddedItemCache.Count()))
{
// It's an embedded item.
const EmbeddedItem& item = mEmbeddedItemCache[glyphIndex - 1u];
- data.width = item.width;
+ data.width = item.width;
data.height = item.height;
- if( 0u != item.pixelBufferId )
+ if(0u != item.pixelBufferId)
{
- Devel::PixelBuffer pixelBuffer = mPixelBufferCache[item.pixelBufferId-1u].pixelBuffer;
- if( pixelBuffer )
+ Devel::PixelBuffer pixelBuffer = mPixelBufferCache[item.pixelBufferId - 1u].pixelBuffer;
+ if(pixelBuffer)
{
- ConvertBitmap( data, pixelBuffer.GetWidth(), pixelBuffer.GetHeight(), pixelBuffer.GetBuffer() );
+ ConvertBitmap(data, pixelBuffer.GetWidth(), pixelBuffer.GetHeight(), pixelBuffer.GetBuffer());
// Sets the pixel format.
data.format = pixelBuffer.GetPixelFormat();
{
// Creates the output buffer
const unsigned int bufferSize = data.width * data.height * 4u;
- data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
+ data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
- memset( data.buffer, 0u, bufferSize );
+ memset(data.buffer, 0u, bufferSize);
// Just creates a void buffer. Doesn't matter what pixel format is set as is the application code the responsible of filling it.
}
}
}
-PixelData FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
+PixelData FontClient::Plugin::CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth)
{
TextAbstraction::FontClient::GlyphBufferData data;
- CreateBitmap( fontId, glyphIndex, false, false, data, outlineWidth );
+ CreateBitmap(fontId, glyphIndex, false, false, data, outlineWidth);
- return PixelData::New( data.buffer,
- data.width * data.height * Pixel::GetBytesPerPixel( data.format ),
- data.width,
- data.height,
- data.format,
- PixelData::DELETE_ARRAY );
+ return PixelData::New(data.buffer,
+ data.width * data.height * Pixel::GetBytesPerPixel(data.format),
+ data.width,
+ data.height,
+ data.format,
+ PixelData::DELETE_ARRAY);
}
-void FontClient::Plugin::CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
+void FontClient::Plugin::CreateVectorBlob(FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight)
{
- blob = nullptr;
+ blob = nullptr;
blobLength = 0;
#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
- if( ( fontId > 0u ) &&
- ( fontId - 1u < mFontIdCache.Count() ) )
+ if((fontId > 0u) &&
+ (fontId - 1u < mFontIdCache.Count()))
{
- const FontId fontFaceId = mFontIdCache[fontId - 1u].id;
- FontFaceCacheItem& font = mFontFaceCache[fontFaceId];
+ const FontId fontFaceId = mFontIdCache[fontId - 1u].id;
+ FontFaceCacheItem& font = mFontFaceCache[fontFaceId];
- if( ! font.mVectorFontId )
+ if(!font.mVectorFontId)
{
- font.mVectorFontId = mVectorFontCache->GetFontId( font.mPath );
+ font.mVectorFontId = mVectorFontCache->GetFontId(font.mPath);
}
- mVectorFontCache->GetVectorBlob( font.mVectorFontId, fontFaceId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
+ mVectorFontCache->GetVectorBlob(font.mVectorFontId, fontFaceId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight);
}
#endif
}
-const GlyphInfo& FontClient::Plugin::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
+const GlyphInfo& FontClient::Plugin::GetEllipsisGlyph(PointSize26Dot6 requestedPointSize)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::GetEllipsisGlyph\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize %d.\n", requestedPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::GetEllipsisGlyph\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize %d.\n", requestedPointSize);
// First look into the cache if there is an ellipsis glyph for the requested point size.
- for( const auto& item : mEllipsisCache )
+ for(const auto& item : mEllipsisCache)
{
- if( item.requestedPointSize == requestedPointSize )
+ if(item.requestedPointSize == requestedPointSize)
{
// Use the glyph in the cache.
- DALI_LOG_INFO( gLogFilter, Debug::General, " glyph id %d found in the cache.\n", item.glyph.index );
- DALI_LOG_INFO( gLogFilter, Debug::General, " font %d.\n", item.glyph.fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetEllipsisGlyph\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " glyph id %d found in the cache.\n", item.glyph.index);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font %d.\n", item.glyph.fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetEllipsisGlyph\n");
return item.glyph;
}
}
// No glyph has been found. Create one.
- mEllipsisCache.PushBack( EllipsisItem() );
- EllipsisItem& item = *( mEllipsisCache.End() - 1u );
+ mEllipsisCache.PushBack(EllipsisItem());
+ EllipsisItem& item = *(mEllipsisCache.End() - 1u);
item.requestedPointSize = requestedPointSize;
// Find a font for the ellipsis glyph.
- item.glyph.fontId = FindDefaultFont( ELLIPSIS_CHARACTER,
- requestedPointSize,
- false );
+ item.glyph.fontId = FindDefaultFont(ELLIPSIS_CHARACTER,
+ requestedPointSize,
+ false);
// Set the character index to access the glyph inside the font.
- item.glyph.index = FT_Get_Char_Index( mFontFaceCache[mFontIdCache[item.glyph.fontId-1u].id].mFreeTypeFace,
- ELLIPSIS_CHARACTER );
+ item.glyph.index = FT_Get_Char_Index(mFontFaceCache[mFontIdCache[item.glyph.fontId - 1u].id].mFreeTypeFace,
+ ELLIPSIS_CHARACTER);
- GetBitmapMetrics( &item.glyph, 1u, true );
+ GetBitmapMetrics(&item.glyph, 1u, true);
- DALI_LOG_INFO( gLogFilter, Debug::General, " glyph id %d found in the cache.\n", item.glyph.index );
- DALI_LOG_INFO( gLogFilter, Debug::General, " font %d.\n", item.glyph.fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::GetEllipsisGlyph\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " glyph id %d found in the cache.\n", item.glyph.index);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font %d.\n", item.glyph.fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::GetEllipsisGlyph\n");
return item.glyph;
}
-bool FontClient::Plugin::IsColorGlyph( FontId fontId, GlyphIndex glyphIndex )
+bool FontClient::Plugin::IsColorGlyph(FontId fontId, GlyphIndex glyphIndex)
{
FT_Error error = -1;
const FontId index = fontId - 1u;
- if( ( fontId > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0u) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- switch( fontIdCacheItem.type )
+ switch(fontIdCacheItem.type)
{
case FontDescription::FACE_FONT:
{
#ifdef FREETYPE_BITMAP_SUPPORT
- const FontFaceCacheItem& item = mFontFaceCache[fontIdCacheItem.id];
- FT_Face ftFace = item.mFreeTypeFace;
+ const FontFaceCacheItem& item = mFontFaceCache[fontIdCacheItem.id];
+ FT_Face ftFace = item.mFreeTypeFace;
// Check to see if this is fixed size bitmap
- if( item.mHasColorTables )
+ if(item.mHasColorTables)
{
- error = FT_Load_Glyph( ftFace, glyphIndex, FT_LOAD_COLOR );
+ error = FT_Load_Glyph(ftFace, glyphIndex, FT_LOAD_COLOR);
}
#endif
break;
return FT_Err_Ok == error;
}
-FT_FaceRec_* FontClient::Plugin::GetFreetypeFace( FontId fontId )
+FT_FaceRec_* FontClient::Plugin::GetFreetypeFace(FontId fontId)
{
FT_Face fontFace = nullptr;
const FontId index = fontId - 1u;
- if( ( fontId > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0u) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- if( FontDescription::FACE_FONT == fontIdCacheItem.type )
+ if(FontDescription::FACE_FONT == fontIdCacheItem.type)
{
fontFace = mFontFaceCache[fontIdCacheItem.id].mFreeTypeFace;
}
return fontFace;
}
-FontDescription::Type FontClient::Plugin::GetFontType( FontId fontId )
+FontDescription::Type FontClient::Plugin::GetFontType(FontId fontId)
{
const FontId index = fontId - 1u;
- if( ( fontId > 0u ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0u) &&
+ (index < mFontIdCache.Count()))
{
return mFontIdCache[index].type;
}
return FontDescription::INVALID;
}
-bool FontClient::Plugin::AddCustomFontDirectory( const FontPath& path )
+bool FontClient::Plugin::AddCustomFontDirectory(const FontPath& path)
{
// nullptr as first parameter means the current configuration is used.
- return FcConfigAppFontAddDir( nullptr, reinterpret_cast<const FcChar8 *>( path.c_str() ) );
+ return FcConfigAppFontAddDir(nullptr, reinterpret_cast<const FcChar8*>(path.c_str()));
}
-GlyphIndex FontClient::Plugin::CreateEmbeddedItem( const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat )
+GlyphIndex FontClient::Plugin::CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat)
{
EmbeddedItem embeddedItem;
embeddedItem.pixelBufferId = 0u;
- embeddedItem.width = description.width;
- embeddedItem.height = description.height;
+ embeddedItem.width = description.width;
+ embeddedItem.height = description.height;
pixelFormat = Pixel::A8;
- if( !description.url.empty() )
+ if(!description.url.empty())
{
// Check if the url is in the cache.
PixelBufferId index = 0u;
- for( const auto& cacheItem : mPixelBufferCache )
+ for(const auto& cacheItem : mPixelBufferCache)
{
++index;
- if( cacheItem.url == description.url )
+ if(cacheItem.url == description.url)
{
// The url is in the pixel buffer cache.
// Set the index +1 to the vector.
}
Devel::PixelBuffer pixelBuffer;
- if( 0u == embeddedItem.pixelBufferId )
+ if(0u == embeddedItem.pixelBufferId)
{
// The pixel buffer is not in the cache. Create one and cache it.
// Load the image from the url.
- pixelBuffer = LoadImageFromFile( description.url );
+ pixelBuffer = LoadImageFromFile(description.url);
// Create the cache item.
PixelBufferCacheItem pixelBufferCacheItem;
pixelBufferCacheItem.pixelBuffer = pixelBuffer;
- pixelBufferCacheItem.url = description.url;
+ pixelBufferCacheItem.url = description.url;
// Store the cache item in the cache.
- mPixelBufferCache.push_back( std::move( pixelBufferCacheItem ) );
+ mPixelBufferCache.push_back(std::move(pixelBufferCacheItem));
// Set the pixel buffer id to the embedded item.
embeddedItem.pixelBufferId = mPixelBufferCache.size();
else
{
// Retrieve the pixel buffer from the cache to set the pixel format.
- pixelBuffer = mPixelBufferCache[embeddedItem.pixelBufferId-1u].pixelBuffer;
+ pixelBuffer = mPixelBufferCache[embeddedItem.pixelBufferId - 1u].pixelBuffer;
}
- if( pixelBuffer )
+ if(pixelBuffer)
{
// Set the size of the embedded item if it has not been set.
- if( 0u == embeddedItem.width )
+ if(0u == embeddedItem.width)
{
- embeddedItem.width = static_cast<unsigned int>( pixelBuffer.GetWidth() );
+ embeddedItem.width = static_cast<unsigned int>(pixelBuffer.GetWidth());
}
- if( 0u == embeddedItem.height )
+ if(0u == embeddedItem.height)
{
- embeddedItem.height = static_cast<unsigned int>( pixelBuffer.GetHeight() );
+ embeddedItem.height = static_cast<unsigned int>(pixelBuffer.GetHeight());
}
// Set the pixel format.
// Find if the same embeddedItem has already been created.
unsigned int index = 0u;
- for( const auto& item : mEmbeddedItemCache )
+ for(const auto& item : mEmbeddedItemCache)
{
++index;
- if( ( item.pixelBufferId == embeddedItem.pixelBufferId ) &&
- ( item.width == embeddedItem.width ) &&
- ( item.height == embeddedItem.height ) )
+ if((item.pixelBufferId == embeddedItem.pixelBufferId) &&
+ (item.width == embeddedItem.width) &&
+ (item.height == embeddedItem.height))
{
return index;
}
}
// Cache the embedded item.
- mEmbeddedItemCache.PushBack( embeddedItem );
+ mEmbeddedItemCache.PushBack(embeddedItem);
return mEmbeddedItemCache.Count();
}
void FontClient::Plugin::InitSystemFonts()
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::InitSystemFonts\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::InitSystemFonts\n");
FcFontSet* fontSet = GetFcFontSet(); // Creates a FcFontSet that needs to be destroyed by calling FcFontSetDestroy.
- if( fontSet )
+ if(fontSet)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " number of system fonts : %d\n", fontSet->nfont );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " number of system fonts : %d\n", fontSet->nfont);
// Reserve some space to avoid reallocations.
- mSystemFonts.reserve( fontSet->nfont );
+ mSystemFonts.reserve(fontSet->nfont);
- for( int i = 0u; i < fontSet->nfont; ++i )
+ for(int i = 0u; i < fontSet->nfont; ++i)
{
FcPattern* fontPattern = fontSet->fonts[i];
FontPath path;
// Skip fonts with no path
- if( GetFcString( fontPattern, FC_FILE, path ) )
+ if(GetFcString(fontPattern, FC_FILE, path))
{
- mSystemFonts.push_back( FontDescription() );
+ mSystemFonts.push_back(FontDescription());
FontDescription& fontDescription = mSystemFonts.back();
- fontDescription.path = std::move( path );
+ fontDescription.path = std::move(path);
- int width = 0;
+ int width = 0;
int weight = 0;
- int slant = 0;
- GetFcString( fontPattern, FC_FAMILY, fontDescription.family );
- GetFcInt( fontPattern, FC_WIDTH, width );
- GetFcInt( fontPattern, FC_WEIGHT, weight );
- GetFcInt( fontPattern, FC_SLANT, slant );
- fontDescription.width = IntToWidthType( width );
- fontDescription.weight = IntToWeightType( weight );
- fontDescription.slant = IntToSlantType( slant );
-
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
+ int slant = 0;
+ GetFcString(fontPattern, FC_FAMILY, fontDescription.family);
+ GetFcInt(fontPattern, FC_WIDTH, width);
+ GetFcInt(fontPattern, FC_WEIGHT, weight);
+ GetFcInt(fontPattern, FC_SLANT, slant);
+ fontDescription.width = IntToWidthType(width);
+ fontDescription.weight = IntToWeightType(weight);
+ fontDescription.slant = IntToSlantType(slant);
+
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
}
}
// Destroys the font set created.
- FcFontSetDestroy( fontSet );
+ FcFontSetDestroy(fontSet);
}
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::InitSystemFonts\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::InitSystemFonts\n");
}
-bool FontClient::Plugin::MatchFontDescriptionToPattern( FcPattern* pattern, Dali::TextAbstraction::FontDescription& fontDescription, FcCharSet** characterSet )
+bool FontClient::Plugin::MatchFontDescriptionToPattern(FcPattern* pattern, Dali::TextAbstraction::FontDescription& fontDescription, FcCharSet** characterSet)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::MatchFontDescriptionToPattern\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::MatchFontDescriptionToPattern\n");
- FcResult result = FcResultMatch;
- FcPattern* match = FcFontMatch( nullptr /* use default configure */, pattern, &result ); // Creates a new font pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcResult result = FcResultMatch;
+ FcPattern* match = FcFontMatch(nullptr /* use default configure */, pattern, &result); // Creates a new font pattern that needs to be destroyed by calling FcPatternDestroy.
const bool matched = nullptr != match;
- DALI_LOG_INFO( gLogFilter, Debug::General, " pattern matched : %s\n", ( matched ? "true" : "false" ) );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " pattern matched : %s\n", (matched ? "true" : "false"));
- if( matched )
+ if(matched)
{
- int width = 0;
+ int width = 0;
int weight = 0;
- int slant = 0;
- GetFcString( match, FC_FILE, fontDescription.path );
- GetFcString( match, FC_FAMILY, fontDescription.family );
- GetFcInt( match, FC_WIDTH, width );
- GetFcInt( match, FC_WEIGHT, weight );
- GetFcInt( match, FC_SLANT, slant );
- fontDescription.width = IntToWidthType( width );
- fontDescription.weight = IntToWeightType( weight );
- fontDescription.slant = IntToSlantType( slant );
+ int slant = 0;
+ GetFcString(match, FC_FILE, fontDescription.path);
+ GetFcString(match, FC_FAMILY, fontDescription.family);
+ GetFcInt(match, FC_WIDTH, width);
+ GetFcInt(match, FC_WEIGHT, weight);
+ GetFcInt(match, FC_SLANT, slant);
+ fontDescription.width = IntToWidthType(width);
+ fontDescription.weight = IntToWeightType(weight);
+ fontDescription.slant = IntToSlantType(slant);
// Retrieve the character set and increase the reference counter.
- FcPatternGetCharSet( match, FC_CHARSET, 0u, characterSet );
- *characterSet = FcCharSetCopy( *characterSet );
+ FcPatternGetCharSet(match, FC_CHARSET, 0u, characterSet);
+ *characterSet = FcCharSetCopy(*characterSet);
// destroyed the matched pattern
- FcPatternDestroy( match );
+ FcPatternDestroy(match);
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
}
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::MatchFontDescriptionToPattern\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::MatchFontDescriptionToPattern\n");
return matched;
}
-FcPattern* FontClient::Plugin::CreateFontFamilyPattern( const FontDescription& fontDescription ) const
+FcPattern* FontClient::Plugin::CreateFontFamilyPattern(const FontDescription& fontDescription) const
{
// create the cached font family lookup pattern
// a pattern holds a set of names, each name refers to a property of the font
FcPattern* fontFamilyPattern = FcPatternCreate(); // FcPatternCreate creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
- if( !fontFamilyPattern )
+ if(!fontFamilyPattern)
{
return nullptr;
}
// add a property to the pattern for the font family
- FcPatternAddString( fontFamilyPattern, FC_FAMILY, reinterpret_cast<const FcChar8*>( fontDescription.family.c_str() ) );
+ FcPatternAddString(fontFamilyPattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fontDescription.family.c_str()));
// add a property to the pattern for local setting.
- const char* locale = setlocale( LC_MESSAGES, nullptr );
- if( locale != nullptr)
+ const char* locale = setlocale(LC_MESSAGES, nullptr);
+ if(locale != nullptr)
{
- FcPatternAddString( fontFamilyPattern, FC_LANG, reinterpret_cast<const FcChar8*>( locale ) );
+ FcPatternAddString(fontFamilyPattern, FC_LANG, reinterpret_cast<const FcChar8*>(locale));
}
int width = FONT_WIDTH_TYPE_TO_INT[fontDescription.width];
- if( width < 0 )
+ if(width < 0)
{
// Use default.
width = DEFAULT_FONT_WIDTH;
}
int weight = FONT_WEIGHT_TYPE_TO_INT[fontDescription.weight];
- if( weight < 0 )
+ if(weight < 0)
{
// Use default.
weight = DEFAULT_FONT_WEIGHT;
}
int slant = FONT_SLANT_TYPE_TO_INT[fontDescription.slant];
- if( slant < 0 )
+ if(slant < 0)
{
// Use default.
slant = DEFAULT_FONT_SLANT;
}
- FcPatternAddInteger( fontFamilyPattern, FC_WIDTH, width );
- FcPatternAddInteger( fontFamilyPattern, FC_WEIGHT, weight );
- FcPatternAddInteger( fontFamilyPattern, FC_SLANT, slant );
+ FcPatternAddInteger(fontFamilyPattern, FC_WIDTH, width);
+ FcPatternAddInteger(fontFamilyPattern, FC_WEIGHT, weight);
+ FcPatternAddInteger(fontFamilyPattern, FC_SLANT, slant);
// modify the config, with the mFontFamilyPatterm
- FcConfigSubstitute( nullptr /* use default configure */, fontFamilyPattern, FcMatchPattern );
+ FcConfigSubstitute(nullptr /* use default configure */, fontFamilyPattern, FcMatchPattern);
// provide default values for unspecified properties in the font pattern
// e.g. patterns without a specified style or weight are set to Medium
- FcDefaultSubstitute( fontFamilyPattern );
+ FcDefaultSubstitute(fontFamilyPattern);
return fontFamilyPattern;
}
// a pattern holds a set of names, each name refers to a property of the font
FcPattern* pattern = FcPatternCreate();
- if( nullptr != pattern )
+ if(nullptr != pattern)
{
// create an object set used to define which properties are to be returned in the patterns from FcFontList.
FcObjectSet* objectSet = FcObjectSetCreate();
- if( nullptr != objectSet )
+ if(nullptr != objectSet)
{
// build an object set from a list of property names
- FcObjectSetAdd( objectSet, FC_FILE );
- FcObjectSetAdd( objectSet, FC_FAMILY );
- FcObjectSetAdd( objectSet, FC_WIDTH );
- FcObjectSetAdd( objectSet, FC_WEIGHT );
- FcObjectSetAdd( objectSet, FC_SLANT );
+ FcObjectSetAdd(objectSet, FC_FILE);
+ FcObjectSetAdd(objectSet, FC_FAMILY);
+ FcObjectSetAdd(objectSet, FC_WIDTH);
+ FcObjectSetAdd(objectSet, FC_WEIGHT);
+ FcObjectSetAdd(objectSet, FC_SLANT);
// get a list of fonts
// creates patterns from those fonts containing only the objects in objectSet and returns the set of unique such patterns
- fontset = FcFontList( nullptr /* the default configuration is checked to be up to date, and used */, pattern, objectSet ); // Creates a FcFontSet that needs to be destroyed by calling FcFontSetDestroy.
+ fontset = FcFontList(nullptr /* the default configuration is checked to be up to date, and used */, pattern, objectSet); // Creates a FcFontSet that needs to be destroyed by calling FcFontSetDestroy.
// clear up the object set
- FcObjectSetDestroy( objectSet );
+ FcObjectSetDestroy(objectSet);
}
// clear up the pattern
- FcPatternDestroy( pattern );
+ FcPatternDestroy(pattern);
}
return fontset;
}
-bool FontClient::Plugin::GetFcString( const FcPattern* const pattern,
- const char* const n,
- std::string& string )
+bool FontClient::Plugin::GetFcString(const FcPattern* const pattern,
+ const char* const n,
+ std::string& string)
{
- FcChar8* file = nullptr;
- const FcResult retVal = FcPatternGetString( pattern, n, 0u, &file );
+ FcChar8* file = nullptr;
+ const FcResult retVal = FcPatternGetString(pattern, n, 0u, &file);
- if( FcResultMatch == retVal )
+ if(FcResultMatch == retVal)
{
// Have to use reinterpret_cast because FcChar8 is unsigned char*, not a const char*.
- string.assign( reinterpret_cast<const char*>( file ) );
+ string.assign(reinterpret_cast<const char*>(file));
return true;
}
return false;
}
-bool FontClient::Plugin::GetFcInt( const _FcPattern* const pattern, const char* const n, int& intVal )
+bool FontClient::Plugin::GetFcInt(const _FcPattern* const pattern, const char* const n, int& intVal)
{
- const FcResult retVal = FcPatternGetInteger( pattern, n, 0u, &intVal );
+ const FcResult retVal = FcPatternGetInteger(pattern, n, 0u, &intVal);
- if( FcResultMatch == retVal )
+ if(FcResultMatch == retVal)
{
return true;
}
return false;
}
-FontId FontClient::Plugin::CreateFont( const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex,
- bool cacheDescription )
+FontId FontClient::Plugin::CreateFont(const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex,
+ bool cacheDescription)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::CreateFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " path : [%s]\n", path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::CreateFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " path : [%s]\n", path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
FontId id = 0u;
// Create & cache new font face
FT_Face ftFace;
- int error = FT_New_Face( mFreeTypeLibrary,
- path.c_str(),
- 0,
- &ftFace );
+ int error = FT_New_Face(mFreeTypeLibrary,
+ path.c_str(),
+ 0,
+ &ftFace);
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
// Check if a font is scalable.
- const bool isScalable = ( 0 != ( ftFace->face_flags & FT_FACE_FLAG_SCALABLE ) );
- const bool hasFixedSizedBitmaps = ( 0 != ( ftFace->face_flags & FT_FACE_FLAG_FIXED_SIZES ) ) && ( 0 != ftFace->num_fixed_sizes );
- const bool hasColorTables = ( 0 != ( ftFace->face_flags & FT_FACE_FLAG_COLOR ) );
- FontId fontFaceId = 0u;
+ const bool isScalable = (0 != (ftFace->face_flags & FT_FACE_FLAG_SCALABLE));
+ const bool hasFixedSizedBitmaps = (0 != (ftFace->face_flags & FT_FACE_FLAG_FIXED_SIZES)) && (0 != ftFace->num_fixed_sizes);
+ const bool hasColorTables = (0 != (ftFace->face_flags & FT_FACE_FLAG_COLOR));
+ FontId fontFaceId = 0u;
- DALI_LOG_INFO( gLogFilter, Debug::General, " isScalable : [%s]\n", ( isScalable ? "true" : "false" ) );
- DALI_LOG_INFO( gLogFilter, Debug::General, " hasFixedSizedBitmaps : [%s]\n", ( hasFixedSizedBitmaps ? "true" : "false" ) );
- DALI_LOG_INFO( gLogFilter, Debug::General, " hasColorTables : [%s]\n", ( hasColorTables ? "true" : "false" ) );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " isScalable : [%s]\n", (isScalable ? "true" : "false"));
+ DALI_LOG_INFO(gLogFilter, Debug::General, " hasFixedSizedBitmaps : [%s]\n", (hasFixedSizedBitmaps ? "true" : "false"));
+ DALI_LOG_INFO(gLogFilter, Debug::General, " hasColorTables : [%s]\n", (hasColorTables ? "true" : "false"));
// Check to see if the font contains fixed sizes?
- if( !isScalable && hasFixedSizedBitmaps )
+ if(!isScalable && hasFixedSizedBitmaps)
{
PointSize26Dot6 actualPointSize = 0u;
- int fixedSizeIndex = 0;
- for( ; fixedSizeIndex < ftFace->num_fixed_sizes; ++fixedSizeIndex )
+ int fixedSizeIndex = 0;
+ for(; fixedSizeIndex < ftFace->num_fixed_sizes; ++fixedSizeIndex)
{
const PointSize26Dot6 fixedSize = ftFace->available_sizes[fixedSizeIndex].size;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " size index : %d, size : %d\n", fixedSizeIndex, fixedSize );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " size index : %d, size : %d\n", fixedSizeIndex, fixedSize);
- if( fixedSize >= requestedPointSize )
+ if(fixedSize >= requestedPointSize)
{
actualPointSize = fixedSize;
break;
}
}
- if( 0u == actualPointSize )
+ if(0u == actualPointSize)
{
// The requested point size is bigger than the bigest fixed size.
- fixedSizeIndex = ftFace->num_fixed_sizes - 1;
+ fixedSizeIndex = ftFace->num_fixed_sizes - 1;
actualPointSize = ftFace->available_sizes[fixedSizeIndex].size;
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " size index : %d, actual size : %d\n", fixedSizeIndex, actualPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " size index : %d, actual size : %d\n", fixedSizeIndex, actualPointSize);
// Tell Freetype to use this size
- error = FT_Select_Size( ftFace, fixedSizeIndex );
- if ( FT_Err_Ok != error )
+ error = FT_Select_Size(ftFace, fixedSizeIndex);
+ if(FT_Err_Ok != error)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FreeType Select_Size error: %d\n", error );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FreeType Select_Size error: %d\n", error);
}
else
{
- const float fixedWidth = static_cast<float>( ftFace->available_sizes[ fixedSizeIndex ].width );
- const float fixedHeight = static_cast<float>( ftFace->available_sizes[ fixedSizeIndex ].height );
+ const float fixedWidth = static_cast<float>(ftFace->available_sizes[fixedSizeIndex].width);
+ const float fixedHeight = static_cast<float>(ftFace->available_sizes[fixedSizeIndex].height);
// Indicate that the font is a fixed sized bitmap
- FontMetrics metrics( fixedHeight, // The ascender in pixels.
- 0.0f,
- fixedHeight, // The height in pixels.
- 0.0f,
- 0.0f );
+ FontMetrics metrics(fixedHeight, // The ascender in pixels.
+ 0.0f,
+ fixedHeight, // The height in pixels.
+ 0.0f,
+ 0.0f);
// Create the FreeType font face item to cache.
- FontFaceCacheItem fontFaceCacheItem( ftFace, path, requestedPointSize, faceIndex, metrics, fixedSizeIndex, fixedWidth, fixedHeight, hasColorTables );
+ FontFaceCacheItem fontFaceCacheItem(ftFace, path, requestedPointSize, faceIndex, metrics, fixedSizeIndex, fixedWidth, fixedHeight, hasColorTables);
// Set the index to the font's id cache.
fontFaceCacheItem.mFontId = mFontIdCache.Count();
// Set the index to the FreeType font face cache.
fontIdCacheItem.id = mFontFaceCache.size();
- fontFaceId = fontIdCacheItem.id + 1u;
+ fontFaceId = fontIdCacheItem.id + 1u;
// Cache the items.
- mFontFaceCache.push_back( fontFaceCacheItem );
- mFontIdCache.PushBack( fontIdCacheItem );
+ mFontFaceCache.push_back(fontFaceCacheItem);
+ mFontIdCache.PushBack(fontIdCacheItem);
// Set the font id to be returned.
id = mFontIdCache.Count();
}
else
{
- error = FT_Set_Char_Size( ftFace,
- 0,
- requestedPointSize,
- mDpiHorizontal,
- mDpiVertical );
+ error = FT_Set_Char_Size(ftFace,
+ 0,
+ requestedPointSize,
+ mDpiHorizontal,
+ mDpiVertical);
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
-
FT_Size_Metrics& ftMetrics = ftFace->size->metrics;
- FontMetrics metrics( static_cast< float >( ftMetrics.ascender ) * FROM_266,
- static_cast< float >( ftMetrics.descender ) * FROM_266,
- static_cast< float >( ftMetrics.height ) * FROM_266,
- static_cast< float >( ftFace->underline_position ) * FROM_266,
- static_cast< float >( ftFace->underline_thickness ) * FROM_266 );
+ FontMetrics metrics(static_cast<float>(ftMetrics.ascender) * FROM_266,
+ static_cast<float>(ftMetrics.descender) * FROM_266,
+ static_cast<float>(ftMetrics.height) * FROM_266,
+ static_cast<float>(ftFace->underline_position) * FROM_266,
+ static_cast<float>(ftFace->underline_thickness) * FROM_266);
// Create the FreeType font face item to cache.
- FontFaceCacheItem fontFaceCacheItem( ftFace, path, requestedPointSize, faceIndex, metrics );
+ FontFaceCacheItem fontFaceCacheItem(ftFace, path, requestedPointSize, faceIndex, metrics);
// Set the index to the font's id cache.
fontFaceCacheItem.mFontId = mFontIdCache.Count();
// Set the index to the FreeType font face cache.
fontIdCacheItem.id = mFontFaceCache.size();
- fontFaceId = fontIdCacheItem.id + 1u;
+ fontFaceId = fontIdCacheItem.id + 1u;
// Cache the items.
- mFontFaceCache.push_back( fontFaceCacheItem );
- mFontIdCache.PushBack( fontIdCacheItem );
+ mFontFaceCache.push_back(fontFaceCacheItem);
+ mFontIdCache.PushBack(fontIdCacheItem);
// Set the font id to be returned.
id = mFontIdCache.Count();
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " FreeType Set_Char_Size error: %d for pointSize %d\n", error, requestedPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " FreeType Set_Char_Size error: %d for pointSize %d\n", error, requestedPointSize);
}
}
- if( 0u != fontFaceId )
+ if(0u != fontFaceId)
{
- if( cacheDescription )
+ if(cacheDescription)
{
- CacheFontPath( ftFace, fontFaceId, requestedPointSize, path );
+ CacheFontPath(ftFace, fontFaceId, requestedPointSize, path);
}
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, " FreeType New_Face error: %d for [%s]\n", error, path.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " FreeType New_Face error: %d for [%s]\n", error, path.c_str());
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font id : %d\n", id );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::CreateFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font id : %d\n", id);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::CreateFont\n");
return id;
}
-void FontClient::Plugin::ConvertBitmap( TextAbstraction::FontClient::GlyphBufferData& data, unsigned int srcWidth, unsigned int srcHeight, const unsigned char* const srcBuffer )
+void FontClient::Plugin::ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, unsigned int srcWidth, unsigned int srcHeight, const unsigned char* const srcBuffer)
{
// Set the input dimensions.
- const ImageDimensions inputDimensions( srcWidth, srcHeight );
+ const ImageDimensions inputDimensions(srcWidth, srcHeight);
// Set the output dimensions.
// If the output dimension is not given, the input dimension is set
// and won't be downscaling.
- data.width = ( data.width == 0 ) ? srcWidth : data.width;
- data.height = ( data.height == 0 ) ? srcHeight : data.height;
- const ImageDimensions desiredDimensions( data.width, data.height );
+ data.width = (data.width == 0) ? srcWidth : data.width;
+ data.height = (data.height == 0) ? srcHeight : data.height;
+ const ImageDimensions desiredDimensions(data.width, data.height);
// Creates the output buffer
const unsigned int bufferSize = data.width * data.height * 4u;
- data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
+ data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
- if( inputDimensions == desiredDimensions )
+ if(inputDimensions == desiredDimensions)
{
// There isn't downscaling.
- memcpy( data.buffer, srcBuffer, bufferSize );
+ memcpy(data.buffer, srcBuffer, bufferSize);
}
else
{
- Dali::Internal::Platform::LanczosSample4BPP( srcBuffer,
- inputDimensions,
- data.buffer,
- desiredDimensions );
+ Dali::Internal::Platform::LanczosSample4BPP(srcBuffer,
+ inputDimensions,
+ data.buffer,
+ desiredDimensions);
}
}
-void FontClient::Plugin::ConvertBitmap( TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap srcBitmap, bool isShearRequired )
+void FontClient::Plugin::ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap srcBitmap, bool isShearRequired)
{
- if( srcBitmap.width*srcBitmap.rows > 0 )
+ if(srcBitmap.width * srcBitmap.rows > 0)
{
- switch( srcBitmap.pixel_mode )
+ switch(srcBitmap.pixel_mode)
{
case FT_PIXEL_MODE_GRAY:
{
- if( srcBitmap.pitch == static_cast<int>( srcBitmap.width ) )
+ if(srcBitmap.pitch == static_cast<int>(srcBitmap.width))
{
- uint8_t* pixelsIn = srcBitmap.buffer;
- unsigned int width = srcBitmap.width;
- unsigned height = srcBitmap.rows;
+ uint8_t* pixelsIn = srcBitmap.buffer;
+ unsigned int width = srcBitmap.width;
+ unsigned height = srcBitmap.rows;
- std::unique_ptr<uint8_t, void(*)(void*)> pixelsOutPtr( nullptr, free );
+ std::unique_ptr<uint8_t, void (*)(void*)> pixelsOutPtr(nullptr, free);
- if( isShearRequired )
+ if(isShearRequired)
{
/**
* Glyphs' bitmaps with no slant retrieved from FreeType:
*
* This difference in some bitmaps' width causes an overlap of some glyphs. This is the reason why a shear operation is done here instead of relying on the experimental FT_GlyphSlot_Oblique() implementation.
*/
- unsigned int widthOut = 0u;
+ unsigned int widthOut = 0u;
unsigned int heightOut = 0u;
- uint8_t* pixelsOut = nullptr;
-
- Dali::Internal::Platform::HorizontalShear( pixelsIn,
- width,
- height,
- 1u,
- -TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE,
- pixelsOut,
- widthOut,
- heightOut );
-
- width = widthOut;
- height = heightOut;
+ uint8_t* pixelsOut = nullptr;
+
+ Dali::Internal::Platform::HorizontalShear(pixelsIn,
+ width,
+ height,
+ 1u,
+ -TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE,
+ pixelsOut,
+ widthOut,
+ heightOut);
+
+ width = widthOut;
+ height = heightOut;
pixelsIn = pixelsOut;
- pixelsOutPtr.reset( pixelsOut );
+ pixelsOutPtr.reset(pixelsOut);
}
const unsigned int bufferSize = width * height;
- data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
- data.width = width;
- data.height = height;
- data.format = Pixel::L8; // Sets the pixel format.
- memcpy( data.buffer, pixelsIn, bufferSize );
+ data.buffer = new unsigned char[bufferSize]; // @note The caller is responsible for deallocating the bitmap data using delete[].
+ data.width = width;
+ data.height = height;
+ data.format = Pixel::L8; // Sets the pixel format.
+ memcpy(data.buffer, pixelsIn, bufferSize);
}
break;
}
#ifdef FREETYPE_BITMAP_SUPPORT
case FT_PIXEL_MODE_BGRA:
{
- if( srcBitmap.pitch == static_cast<int>( srcBitmap.width << 2u ) )
+ if(srcBitmap.pitch == static_cast<int>(srcBitmap.width << 2u))
{
- ConvertBitmap( data, srcBitmap.width, srcBitmap.rows, srcBitmap.buffer );
+ ConvertBitmap(data, srcBitmap.width, srcBitmap.rows, srcBitmap.buffer);
// Sets the pixel format.
data.format = Pixel::BGRA8888;
#endif
default:
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::ConvertBitmap. FontClient Unable to create Bitmap of this PixelType\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::ConvertBitmap. FontClient Unable to create Bitmap of this PixelType\n");
break;
}
}
}
}
-bool FontClient::Plugin::FindFont( const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex,
- FontId& fontId ) const
+bool FontClient::Plugin::FindFont(const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex,
+ FontId& fontId) const
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " path : [%s]\n", path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " number of fonts in the cache : %d\n", mFontFaceCache.size() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " path : [%s]\n", path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " number of fonts in the cache : %d\n", mFontFaceCache.size());
fontId = 0u;
- for( const auto& cacheItem : mFontFaceCache )
+ for(const auto& cacheItem : mFontFaceCache)
{
- if( cacheItem.mRequestedPointSize == requestedPointSize &&
- cacheItem.mFaceIndex == faceIndex &&
- cacheItem.mPath == path )
+ if(cacheItem.mRequestedPointSize == requestedPointSize &&
+ cacheItem.mFaceIndex == faceIndex &&
+ cacheItem.mPath == path)
{
fontId = cacheItem.mFontId + 1u;
- DALI_LOG_INFO( gLogFilter, Debug::General, " font found, id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font found, id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n");
return true;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font not found\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font not found\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n");
return false;
}
-bool FontClient::Plugin::FindValidatedFont( const FontDescription& fontDescription,
- FontDescriptionId& validatedFontId )
+bool FontClient::Plugin::FindValidatedFont(const FontDescription& fontDescription,
+ FontDescriptionId& validatedFontId)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindValidatedFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " number of validated fonts in the cache : %d\n", mValidatedFontCache.size() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindValidatedFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " number of validated fonts in the cache : %d\n", mValidatedFontCache.size());
validatedFontId = 0u;
- for( const auto& item : mValidatedFontCache )
+ for(const auto& item : mValidatedFontCache)
{
- if( !fontDescription.family.empty() &&
- ( fontDescription.family == item.fontDescription.family ) &&
- ( fontDescription.width == item.fontDescription.width ) &&
- ( fontDescription.weight == item.fontDescription.weight ) &&
- ( fontDescription.slant == item.fontDescription.slant ) )
+ if(!fontDescription.family.empty() &&
+ (fontDescription.family == item.fontDescription.family) &&
+ (fontDescription.width == item.fontDescription.width) &&
+ (fontDescription.weight == item.fontDescription.weight) &&
+ (fontDescription.slant == item.fontDescription.slant))
{
validatedFontId = item.index;
- DALI_LOG_INFO( gLogFilter, Debug::General, " validated font found, id : %d\n", validatedFontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindValidatedFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " validated font found, id : %d\n", validatedFontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindValidatedFont\n");
return true;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " validated font not found\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindValidatedFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " validated font not found\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindValidatedFont\n");
return false;
}
-bool FontClient::Plugin::FindFallbackFontList( const FontDescription& fontDescription,
- FontList*& fontList,
- CharacterSetList*& characterSetList )
+bool FontClient::Plugin::FindFallbackFontList(const FontDescription& fontDescription,
+ FontList*& fontList,
+ CharacterSetList*& characterSetList)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindFallbackFontList\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str() );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant] );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, " number of fallback font lists in the cache : %d\n", mFallbackCache.size() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindFallbackFontList\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " description; family : [%s]\n", fontDescription.family.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " path : [%s]\n", fontDescription.path.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " width : [%s]\n", FontWidth::Name[fontDescription.width]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " weight : [%s]\n", FontWeight::Name[fontDescription.weight]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " slant : [%s]\n\n", FontSlant::Name[fontDescription.slant]);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, " number of fallback font lists in the cache : %d\n", mFallbackCache.size());
fontList = nullptr;
- for( const auto& item : mFallbackCache )
+ for(const auto& item : mFallbackCache)
{
- if( !fontDescription.family.empty() &&
- ( fontDescription.family == item.fontDescription.family ) &&
- ( fontDescription.width == item.fontDescription.width ) &&
- ( fontDescription.weight == item.fontDescription.weight ) &&
- ( fontDescription.slant == item.fontDescription.slant ) )
+ if(!fontDescription.family.empty() &&
+ (fontDescription.family == item.fontDescription.family) &&
+ (fontDescription.width == item.fontDescription.width) &&
+ (fontDescription.weight == item.fontDescription.weight) &&
+ (fontDescription.slant == item.fontDescription.slant))
{
- fontList = item.fallbackFonts;
+ fontList = item.fallbackFonts;
characterSetList = item.characterSets;
- DALI_LOG_INFO( gLogFilter, Debug::General, " fallback font list found.\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFallbackFontList\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " fallback font list found.\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFallbackFontList\n");
return true;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " fallback font list not found.\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFallbackFontList\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " fallback font list not found.\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFallbackFontList\n");
return false;
}
-bool FontClient::Plugin::FindFont( FontDescriptionId validatedFontId,
- PointSize26Dot6 requestedPointSize,
- FontId& fontId )
+bool FontClient::Plugin::FindFont(FontDescriptionId validatedFontId,
+ PointSize26Dot6 requestedPointSize,
+ FontId& fontId)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "-->FontClient::Plugin::FindFont\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, " validatedFontId : %d\n", validatedFontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "-->FontClient::Plugin::FindFont\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, " validatedFontId : %d\n", validatedFontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, " requestedPointSize : %d\n", requestedPointSize);
fontId = 0u;
- for( const auto& item : mFontDescriptionSizeCache )
+ for(const auto& item : mFontDescriptionSizeCache)
{
- if( ( validatedFontId == item.validatedFontId ) &&
- ( requestedPointSize == item.requestedPointSize ) )
+ if((validatedFontId == item.validatedFontId) &&
+ (requestedPointSize == item.requestedPointSize))
{
fontId = item.fontId;
- DALI_LOG_INFO( gLogFilter, Debug::General, " font found, id : %d\n", fontId );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font found, id : %d\n", fontId);
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n");
return true;
}
}
- DALI_LOG_INFO( gLogFilter, Debug::General, " font not found.\n" );
- DALI_LOG_INFO( gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n" );
+ DALI_LOG_INFO(gLogFilter, Debug::General, " font not found.\n");
+ DALI_LOG_INFO(gLogFilter, Debug::General, "<--FontClient::Plugin::FindFont\n");
return false;
}
-bool FontClient::Plugin::FindBitmapFont( const FontFamily& bitmapFont, FontId& fontId ) const
+bool FontClient::Plugin::FindBitmapFont(const FontFamily& bitmapFont, FontId& fontId) const
{
fontId = 0u;
- for( const auto& item : mBitmapFontCache )
+ for(const auto& item : mBitmapFontCache)
{
- if( bitmapFont == item.font.name )
+ if(bitmapFont == item.font.name)
{
fontId = item.id + 1u;
return true;
return false;
}
-bool FontClient::Plugin::IsScalable( const FontPath& path )
+bool FontClient::Plugin::IsScalable(const FontPath& path)
{
bool isScalable = false;
FT_Face ftFace;
- int error = FT_New_Face( mFreeTypeLibrary,
- path.c_str(),
- 0,
- &ftFace );
- if( FT_Err_Ok != error )
+ int error = FT_New_Face(mFreeTypeLibrary,
+ path.c_str(),
+ 0,
+ &ftFace);
+ if(FT_Err_Ok != error)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::IsScalable. FreeType Cannot check font: %s\n", path.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::IsScalable. FreeType Cannot check font: %s\n", path.c_str());
}
else
{
return isScalable;
}
-bool FontClient::Plugin::IsScalable( const FontDescription& fontDescription )
+bool FontClient::Plugin::IsScalable(const FontDescription& fontDescription)
{
// Create a font pattern.
- FcPattern* fontFamilyPattern = CreateFontFamilyPattern( fontDescription ); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
FcResult result = FcResultMatch;
// match the pattern
- FcPattern* match = FcFontMatch( nullptr /* use default configure */, fontFamilyPattern, &result ); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
- bool isScalable = false;
+ FcPattern* match = FcFontMatch(nullptr /* use default configure */, fontFamilyPattern, &result); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
+ bool isScalable = false;
- if( match )
+ if(match)
{
// Get the path to the font file name.
FontPath path;
- GetFcString( match, FC_FILE, path );
- isScalable = IsScalable( path );
+ GetFcString(match, FC_FILE, path);
+ isScalable = IsScalable(path);
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::IsScalable. FreeType Cannot check font: [%s]\n", fontDescription.family.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::IsScalable. FreeType Cannot check font: [%s]\n", fontDescription.family.c_str());
}
// Destroys the created patterns.
- FcPatternDestroy( match );
- FcPatternDestroy( fontFamilyPattern );
+ FcPatternDestroy(match);
+ FcPatternDestroy(fontFamilyPattern);
return isScalable;
}
-void FontClient::Plugin::GetFixedSizes( const FontPath& path, Vector< PointSize26Dot6 >& sizes )
+void FontClient::Plugin::GetFixedSizes(const FontPath& path, Vector<PointSize26Dot6>& sizes)
{
// Empty the caller container
sizes.Clear();
FT_Face ftFace;
- int error = FT_New_Face( mFreeTypeLibrary,
- path.c_str(),
- 0,
- &ftFace );
- if( FT_Err_Ok != error )
+ int error = FT_New_Face(mFreeTypeLibrary,
+ path.c_str(),
+ 0,
+ &ftFace);
+ if(FT_Err_Ok != error)
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::GetFixedSizes. FreeType Cannot check font path : [%s]\n", path.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::GetFixedSizes. FreeType Cannot check font path : [%s]\n", path.c_str());
}
// Fetch the number of fixed sizes available
- if ( ftFace->num_fixed_sizes && ftFace->available_sizes )
+ if(ftFace->num_fixed_sizes && ftFace->available_sizes)
{
- for ( int i = 0; i < ftFace->num_fixed_sizes; ++i )
+ for(int i = 0; i < ftFace->num_fixed_sizes; ++i)
{
- sizes.PushBack( ftFace->available_sizes[ i ].size );
+ sizes.PushBack(ftFace->available_sizes[i].size);
}
}
}
-void FontClient::Plugin::GetFixedSizes( const FontDescription& fontDescription,
- Vector< PointSize26Dot6 >& sizes )
+void FontClient::Plugin::GetFixedSizes(const FontDescription& fontDescription,
+ Vector<PointSize26Dot6>& sizes)
{
// Create a font pattern.
- FcPattern* fontFamilyPattern = CreateFontFamilyPattern( fontDescription ); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcPattern* fontFamilyPattern = CreateFontFamilyPattern(fontDescription); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
FcResult result = FcResultMatch;
// match the pattern
- FcPattern* match = FcFontMatch( nullptr /* use default configure */, fontFamilyPattern, &result ); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcPattern* match = FcFontMatch(nullptr /* use default configure */, fontFamilyPattern, &result); // Creates a font pattern that needs to be destroyed by calling FcPatternDestroy.
- if( match )
+ if(match)
{
// Get the path to the font file name.
FontPath path;
- GetFcString( match, FC_FILE, path );
- GetFixedSizes( path, sizes );
+ GetFcString(match, FC_FILE, path);
+ GetFixedSizes(path, sizes);
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::GetFixedSizes. FreeType Cannot check font: [%s]\n", fontDescription.family.c_str() );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::GetFixedSizes. FreeType Cannot check font: [%s]\n", fontDescription.family.c_str());
}
// Destroys the created patterns.
- FcPatternDestroy( match );
- FcPatternDestroy( fontFamilyPattern );
+ FcPatternDestroy(match);
+ FcPatternDestroy(fontFamilyPattern);
}
-bool FontClient::Plugin::HasItalicStyle( FontId fontId ) const
+bool FontClient::Plugin::HasItalicStyle(FontId fontId) const
{
bool hasItalicStyle = false;
const FontId index = fontId - 1u;
- if( ( fontId > 0 ) &&
- ( index < mFontIdCache.Count() ) )
+ if((fontId > 0) &&
+ (index < mFontIdCache.Count()))
{
const FontIdCacheItem& fontIdCacheItem = mFontIdCache[index];
- if( FontDescription::FACE_FONT == fontIdCacheItem.type )
+ if(FontDescription::FACE_FONT == fontIdCacheItem.type)
{
const FontFaceCacheItem& font = mFontFaceCache[fontIdCacheItem.id];
- hasItalicStyle = 0u != ( font.mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC );
+ hasItalicStyle = 0u != (font.mFreeTypeFace->style_flags & FT_STYLE_FLAG_ITALIC);
}
}
else
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "FontClient::Plugin::GetFontMetrics. Invalid font id : %d\n", fontId );
+ DALI_LOG_INFO(gLogFilter, Debug::General, "FontClient::Plugin::GetFontMetrics. Invalid font id : %d\n", fontId);
}
return hasItalicStyle;
}
-void FontClient::Plugin::CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path )
+void FontClient::Plugin::CacheFontPath(FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path)
{
FontDescription description;
- description.path = path;
- description.family = std::move( FontFamily( ftFace->family_name ) );
+ description.path = path;
+ description.family = std::move(FontFamily(ftFace->family_name));
description.weight = FontWeight::NONE;
- description.width = FontWidth::NONE;
- description.slant = FontSlant::NONE;
+ description.width = FontWidth::NONE;
+ description.slant = FontSlant::NONE;
// Note FreeType doesn't give too much info to build a proper font style.
- if( ftFace->style_flags & FT_STYLE_FLAG_ITALIC )
+ if(ftFace->style_flags & FT_STYLE_FLAG_ITALIC)
{
description.slant = FontSlant::ITALIC;
}
- if( ftFace->style_flags & FT_STYLE_FLAG_BOLD )
+ if(ftFace->style_flags & FT_STYLE_FLAG_BOLD)
{
description.weight = FontWeight::BOLD;
}
FontDescriptionId validatedFontId = 0u;
- if( !FindValidatedFont( description,
- validatedFontId ) )
+ if(!FindValidatedFont(description,
+ validatedFontId))
{
- FcPattern* pattern = CreateFontFamilyPattern( description ); // Creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcPattern* pattern = CreateFontFamilyPattern(description); // Creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
- FcResult result = FcResultMatch;
- FcPattern* match = FcFontMatch( nullptr, pattern, &result ); // FcFontMatch creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcResult result = FcResultMatch;
+ FcPattern* match = FcFontMatch(nullptr, pattern, &result); // FcFontMatch creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
FcCharSet* characterSet = nullptr;
- FcPatternGetCharSet( match, FC_CHARSET, 0u, &characterSet );
+ FcPatternGetCharSet(match, FC_CHARSET, 0u, &characterSet);
- const FontId fontFaceId = id - 1u;
- mFontFaceCache[fontFaceId].mCharacterSet = FcCharSetCopy( characterSet ); // Increases the reference counter.
+ const FontId fontFaceId = id - 1u;
+ mFontFaceCache[fontFaceId].mCharacterSet = FcCharSetCopy(characterSet); // Increases the reference counter.
// Destroys the created patterns.
- FcPatternDestroy( match );
- FcPatternDestroy( pattern );
+ FcPatternDestroy(match);
+ FcPatternDestroy(pattern);
// Add the path to the cache.
description.type = FontDescription::FACE_FONT;
- mFontDescriptionCache.push_back( description );
+ mFontDescriptionCache.push_back(description);
// Set the index to the vector of paths to font file names.
validatedFontId = mFontDescriptionCache.size();
// Increase the reference counter and add the character set to the cache.
- mCharacterSetCache.PushBack( FcCharSetCopy( characterSet ) );
+ mCharacterSetCache.PushBack(FcCharSetCopy(characterSet));
// Cache the index and the font's description.
- mValidatedFontCache.push_back( std::move( FontDescriptionCacheItem( std::move( description ),
- validatedFontId) ) );
+ mValidatedFontCache.push_back(std::move(FontDescriptionCacheItem(std::move(description),
+ validatedFontId)));
// Cache the pair 'validatedFontId, requestedPointSize' to improve the following queries.
- mFontDescriptionSizeCache.push_back( FontDescriptionSizeCacheItem( validatedFontId,
- requestedPointSize,
- fontFaceId ) );
+ mFontDescriptionSizeCache.push_back(FontDescriptionSizeCacheItem(validatedFontId,
+ requestedPointSize,
+ fontFaceId));
}
}
-FcCharSet* FontClient::Plugin::CreateCharacterSetFromDescription( const FontDescription& description )
+FcCharSet* FontClient::Plugin::CreateCharacterSetFromDescription(const FontDescription& description)
{
FcCharSet* characterSet = nullptr;
- FcPattern* pattern = CreateFontFamilyPattern( description ); // Creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcPattern* pattern = CreateFontFamilyPattern(description); // Creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
- if( nullptr != pattern )
+ if(nullptr != pattern)
{
- FcResult result = FcResultMatch;
- FcPattern* match = FcFontMatch( nullptr, pattern, &result ); // FcFontMatch creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
+ FcResult result = FcResultMatch;
+ FcPattern* match = FcFontMatch(nullptr, pattern, &result); // FcFontMatch creates a new pattern that needs to be destroyed by calling FcPatternDestroy.
- FcPatternGetCharSet( match, FC_CHARSET, 0u, &characterSet );
+ FcPatternGetCharSet(match, FC_CHARSET, 0u, &characterSet);
// Destroys the created patterns.
- FcPatternDestroy( match );
- FcPatternDestroy( pattern );
+ FcPatternDestroy(match);
+ FcPatternDestroy(pattern);
}
return characterSet;
}
-void FontClient::Plugin::ClearFallbackCache( std::vector<FallbackCacheItem>& fallbackCache )
+void FontClient::Plugin::ClearFallbackCache(std::vector<FallbackCacheItem>& fallbackCache)
{
- for( auto& item : fallbackCache )
+ for(auto& item : fallbackCache)
{
- if( nullptr != item.fallbackFonts )
+ if(nullptr != item.fallbackFonts)
{
delete item.fallbackFonts;
}
- if( nullptr != item.characterSets )
+ if(nullptr != item.characterSets)
{
// Free the resources allocated by the FcCharSet objects in the 'characterSets' vector.
- DestroyCharacterSets( *item.characterSets );
+ DestroyCharacterSets(*item.characterSets);
delete item.characterSets;
}
}
void FontClient::Plugin::ClearCharacterSetFromFontFaceCache()
{
- for( auto& item : mFontFaceCache )
+ for(auto& item : mFontFaceCache)
{
- FcCharSetDestroy( item.mCharacterSet );
+ FcCharSetDestroy(item.mCharacterSet);
item.mCharacterSet = nullptr;
}
}
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
struct Segmentation::Plugin
{
- void GetLineBreakPositions( const Character* const text,
- Length numberOfCharacters,
- LineBreakInfo* breakInfo )
+ void GetLineBreakPositions(const Character* const text,
+ Length numberOfCharacters,
+ LineBreakInfo* breakInfo)
{
- set_linebreaks_utf32( text, numberOfCharacters, NULL, breakInfo );
+ set_linebreaks_utf32(text, numberOfCharacters, NULL, breakInfo);
}
- void GetWordBreakPositions( const Character* const text,
- Length numberOfCharacters,
- WordBreakInfo* breakInfo )
+ void GetWordBreakPositions(const Character* const text,
+ Length numberOfCharacters,
+ WordBreakInfo* breakInfo)
{
- set_wordbreaks_utf32( text, numberOfCharacters, NULL, breakInfo );
+ set_wordbreaks_utf32(text, numberOfCharacters, NULL, breakInfo);
}
};
Segmentation::Segmentation()
-: mPlugin( NULL )
-{}
+: mPlugin(NULL)
+{
+}
Segmentation::~Segmentation()
{
{
TextAbstraction::Segmentation segmentationHandle;
- SingletonService service( SingletonService::Get() );
- if( service )
+ SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( TextAbstraction::Segmentation ) );
- if( handle )
+ Dali::BaseHandle handle = service.GetSingleton(typeid(TextAbstraction::Segmentation));
+ if(handle)
{
// If so, downcast the handle
- Segmentation* impl = dynamic_cast< Internal::Segmentation* >( handle.GetObjectPtr() );
- segmentationHandle = TextAbstraction::Segmentation( impl );
+ Segmentation* impl = dynamic_cast<Internal::Segmentation*>(handle.GetObjectPtr());
+ segmentationHandle = TextAbstraction::Segmentation(impl);
}
else // create and register the object
{
- segmentationHandle = TextAbstraction::Segmentation( new Segmentation );
- service.Register( typeid( segmentationHandle ), segmentationHandle );
+ segmentationHandle = TextAbstraction::Segmentation(new Segmentation);
+ service.Register(typeid(segmentationHandle), segmentationHandle);
}
}
return segmentationHandle;
}
-void Segmentation::GetLineBreakPositions( const Character* const text,
- Length numberOfCharacters,
- LineBreakInfo* breakInfo )
+void Segmentation::GetLineBreakPositions(const Character* const text,
+ Length numberOfCharacters,
+ LineBreakInfo* breakInfo)
{
CreatePlugin();
- mPlugin->GetLineBreakPositions( text, numberOfCharacters, breakInfo );
+ mPlugin->GetLineBreakPositions(text, numberOfCharacters, breakInfo);
}
-void Segmentation::GetWordBreakPositions( const Character* const text,
- Length numberOfCharacters,
- WordBreakInfo* breakInfo )
+void Segmentation::GetWordBreakPositions(const Character* const text,
+ Length numberOfCharacters,
+ WordBreakInfo* breakInfo)
{
CreatePlugin();
- mPlugin->GetWordBreakPositions( text, numberOfCharacters, breakInfo );
+ mPlugin->GetWordBreakPositions(text, numberOfCharacters, breakInfo);
}
void Segmentation::CreatePlugin()
{
- if( !mPlugin )
+ if(!mPlugin)
{
mPlugin = new Plugin();
}
/*
- * Copyright (c) 2019 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.
#include "font-client-impl.h"
// EXTERNAL INCLUDES
-#include <harfbuzz/hb.h>
-#include <harfbuzz/hb-ft.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <harfbuzz/hb-ft.h>
+#include <harfbuzz/hb.h>
namespace
{
-
#if defined(DEBUG_ENABLED)
Dali::Integration::Log::Filter* gLogFilter = Dali::Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_FONT_CLIENT");
#endif
-}
+} // namespace
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
-const char* const DEFAULT_LANGUAGE = "en";
+const char* const DEFAULT_LANGUAGE = "en";
const unsigned int DEFAULT_LANGUAGE_LENGTH = 2u;
-const float FROM_266 = 1.0f / 64.0f;
+const float FROM_266 = 1.0f / 64.0f;
const hb_script_t SCRIPT_TO_HARFBUZZ[] =
-{
- HB_SCRIPT_COMMON,
-
- HB_SCRIPT_COMMON, // ASCII_DIGITS
- HB_SCRIPT_COMMON, // ASCII_PS
-
- HB_SCRIPT_COMMON, // C1_CONTROLS
- HB_SCRIPT_COMMON, // C1_PS
- HB_SCRIPT_COMMON, // C1_MATH
- HB_SCRIPT_COMMON, // SML_P
- HB_SCRIPT_COMMON, // PHONETIC_U
- HB_SCRIPT_COMMON, // PHONETIC_SS
- HB_SCRIPT_COMMON, // NUMERIC_SS
- HB_SCRIPT_COMMON, // LETTER_LIKE
- HB_SCRIPT_COMMON, // NUMBER_FORMS
- HB_SCRIPT_COMMON, // FRACTIONS_NF
- HB_SCRIPT_COMMON, // NON_LATIN_LED
- HB_SCRIPT_COMMON, // HWFW_S
-
- HB_SCRIPT_CYRILLIC,
- HB_SCRIPT_GREEK,
- HB_SCRIPT_LATIN,
-
- HB_SCRIPT_ARABIC,
- HB_SCRIPT_HEBREW,
-
- HB_SCRIPT_ARMENIAN,
- HB_SCRIPT_GEORGIAN,
-
- HB_SCRIPT_HAN,
- HB_SCRIPT_HANGUL,
- HB_SCRIPT_HIRAGANA,
- HB_SCRIPT_KATAKANA,
- HB_SCRIPT_BOPOMOFO,
-
- HB_SCRIPT_BENGALI,
- HB_SCRIPT_MYANMAR,
- HB_SCRIPT_DEVANAGARI,
- HB_SCRIPT_GUJARATI,
- HB_SCRIPT_GURMUKHI,
- HB_SCRIPT_KANNADA,
- HB_SCRIPT_MALAYALAM,
- HB_SCRIPT_ORIYA,
- HB_SCRIPT_SINHALA,
- HB_SCRIPT_TAMIL,
- HB_SCRIPT_TELUGU,
-
- HB_SCRIPT_LAO,
- HB_SCRIPT_THAI,
- HB_SCRIPT_KHMER,
- HB_SCRIPT_JAVANESE,
- HB_SCRIPT_SUNDANESE,
-
- HB_SCRIPT_ETHIOPIC,
- HB_SCRIPT_OL_CHIKI,
- HB_SCRIPT_TAGALOG,
- HB_SCRIPT_MEETEI_MAYEK,
-
- HB_SCRIPT_UNKNOWN, // EMOJI
- HB_SCRIPT_UNKNOWN, // SYMBOLS1
- HB_SCRIPT_UNKNOWN, // SYMBOLS2
- HB_SCRIPT_UNKNOWN, // SYMBOLS3
- HB_SCRIPT_UNKNOWN, // SYMBOLS4
- HB_SCRIPT_UNKNOWN, // SYMBOLS5
- HB_SCRIPT_UNKNOWN
-};
+ {
+ HB_SCRIPT_COMMON,
+
+ HB_SCRIPT_COMMON, // ASCII_DIGITS
+ HB_SCRIPT_COMMON, // ASCII_PS
+
+ HB_SCRIPT_COMMON, // C1_CONTROLS
+ HB_SCRIPT_COMMON, // C1_PS
+ HB_SCRIPT_COMMON, // C1_MATH
+ HB_SCRIPT_COMMON, // SML_P
+ HB_SCRIPT_COMMON, // PHONETIC_U
+ HB_SCRIPT_COMMON, // PHONETIC_SS
+ HB_SCRIPT_COMMON, // NUMERIC_SS
+ HB_SCRIPT_COMMON, // LETTER_LIKE
+ HB_SCRIPT_COMMON, // NUMBER_FORMS
+ HB_SCRIPT_COMMON, // FRACTIONS_NF
+ HB_SCRIPT_COMMON, // NON_LATIN_LED
+ HB_SCRIPT_COMMON, // HWFW_S
+
+ HB_SCRIPT_CYRILLIC,
+ HB_SCRIPT_GREEK,
+ HB_SCRIPT_LATIN,
+
+ HB_SCRIPT_ARABIC,
+ HB_SCRIPT_HEBREW,
+
+ HB_SCRIPT_ARMENIAN,
+ HB_SCRIPT_GEORGIAN,
+
+ HB_SCRIPT_HAN,
+ HB_SCRIPT_HANGUL,
+ HB_SCRIPT_HIRAGANA,
+ HB_SCRIPT_KATAKANA,
+ HB_SCRIPT_BOPOMOFO,
+
+ HB_SCRIPT_BENGALI,
+ HB_SCRIPT_MYANMAR,
+ HB_SCRIPT_DEVANAGARI,
+ HB_SCRIPT_GUJARATI,
+ HB_SCRIPT_GURMUKHI,
+ HB_SCRIPT_KANNADA,
+ HB_SCRIPT_MALAYALAM,
+ HB_SCRIPT_ORIYA,
+ HB_SCRIPT_SINHALA,
+ HB_SCRIPT_TAMIL,
+ HB_SCRIPT_TELUGU,
+
+ HB_SCRIPT_LAO,
+ HB_SCRIPT_THAI,
+ HB_SCRIPT_KHMER,
+ HB_SCRIPT_JAVANESE,
+ HB_SCRIPT_SUNDANESE,
+
+ HB_SCRIPT_ETHIOPIC,
+ HB_SCRIPT_OL_CHIKI,
+ HB_SCRIPT_TAGALOG,
+ HB_SCRIPT_MEETEI_MAYEK,
+
+ HB_SCRIPT_UNKNOWN, // EMOJI
+ HB_SCRIPT_UNKNOWN, // SYMBOLS1
+ HB_SCRIPT_UNKNOWN, // SYMBOLS2
+ HB_SCRIPT_UNKNOWN, // SYMBOLS3
+ HB_SCRIPT_UNKNOWN, // SYMBOLS4
+ HB_SCRIPT_UNKNOWN, // SYMBOLS5
+ HB_SCRIPT_UNKNOWN};
struct Shaping::Plugin
{
: mIndices(),
mAdvance(),
mCharacterMap(),
- mFontId( 0u )
+ mFontId(0u)
{
}
{
}
- Length Shape( const Character* const text,
- Length numberOfCharacters,
- FontId fontId,
- Script script )
+ Length Shape(const Character* const text,
+ Length numberOfCharacters,
+ FontId fontId,
+ Script script)
{
// Clear previoursly shaped texts.
mIndices.Clear();
mOffset.Clear();
mFontId = fontId;
- TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
- TextAbstraction::Internal::FontClient& fontClientImpl = TextAbstraction::GetImplementation( fontClient );
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ TextAbstraction::Internal::FontClient& fontClientImpl = TextAbstraction::GetImplementation(fontClient);
- const FontDescription::Type type = fontClientImpl.GetFontType( fontId );
+ const FontDescription::Type type = fontClientImpl.GetFontType(fontId);
- switch( type )
+ switch(type)
{
case FontDescription::FACE_FONT:
{
// Reserve some space to avoid reallocations.
- const Length numberOfGlyphs = static_cast<Length>( 1.3f * static_cast<float>( numberOfCharacters ) );
- mIndices.Reserve( numberOfGlyphs );
- mAdvance.Reserve( numberOfGlyphs );
- mCharacterMap.Reserve( numberOfGlyphs );
- mOffset.Reserve( 2u * numberOfGlyphs );
+ const Length numberOfGlyphs = static_cast<Length>(1.3f * static_cast<float>(numberOfCharacters));
+ mIndices.Reserve(numberOfGlyphs);
+ mAdvance.Reserve(numberOfGlyphs);
+ mCharacterMap.Reserve(numberOfGlyphs);
+ mOffset.Reserve(2u * numberOfGlyphs);
// Retrieve a FreeType font's face.
- FT_Face face = fontClientImpl.GetFreetypeFace( fontId );
- if( nullptr == face )
+ FT_Face face = fontClientImpl.GetFreetypeFace(fontId);
+ if(nullptr == face)
{
// Nothing to do if the face is null.
return 0u;
}
unsigned int horizontalDpi = 0u;
- unsigned int verticalDpi = 0u;
- fontClient.GetDpi( horizontalDpi, verticalDpi );
+ unsigned int verticalDpi = 0u;
+ fontClient.GetDpi(horizontalDpi, verticalDpi);
- FT_Set_Char_Size( face,
- 0u,
- fontClient.GetPointSize( fontId ),
- horizontalDpi,
- verticalDpi );
+ FT_Set_Char_Size(face,
+ 0u,
+ fontClient.GetPointSize(fontId),
+ horizontalDpi,
+ verticalDpi);
/* Get our harfbuzz font struct */
hb_font_t* harfBuzzFont;
- harfBuzzFont = hb_ft_font_create( face, NULL );
+ harfBuzzFont = hb_ft_font_create(face, NULL);
/* Create a buffer for harfbuzz to use */
hb_buffer_t* harfBuzzBuffer = hb_buffer_create();
- const bool rtlDirection = IsRightToLeftScript( script );
- hb_buffer_set_direction( harfBuzzBuffer,
- rtlDirection ? HB_DIRECTION_RTL : HB_DIRECTION_LTR ); /* or LTR */
-
- hb_buffer_set_script( harfBuzzBuffer,
- SCRIPT_TO_HARFBUZZ[ script ] ); /* see hb-unicode.h */
+ const bool rtlDirection = IsRightToLeftScript(script);
+ hb_buffer_set_direction(harfBuzzBuffer,
+ rtlDirection ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); /* or LTR */
+ hb_buffer_set_script(harfBuzzBuffer,
+ SCRIPT_TO_HARFBUZZ[script]); /* see hb-unicode.h */
- char* currentLocale = setlocale(LC_MESSAGES,NULL);
+ char* currentLocale = setlocale(LC_MESSAGES, NULL);
- std::istringstream stringStream( currentLocale );
- std::string localeString;
+ std::istringstream stringStream(currentLocale);
+ std::string localeString;
std::getline(stringStream, localeString, '_');
- hb_buffer_set_language( harfBuzzBuffer, hb_language_from_string( localeString.c_str(), localeString.size() ) );
+ hb_buffer_set_language(harfBuzzBuffer, hb_language_from_string(localeString.c_str(), localeString.size()));
/* Layout the text */
- hb_buffer_add_utf32( harfBuzzBuffer, text, numberOfCharacters, 0u, numberOfCharacters );
+ hb_buffer_add_utf32(harfBuzzBuffer, text, numberOfCharacters, 0u, numberOfCharacters);
- hb_shape( harfBuzzFont, harfBuzzBuffer, NULL, 0u );
+ hb_shape(harfBuzzFont, harfBuzzBuffer, NULL, 0u);
/* Get glyph data */
- unsigned int glyphCount;
- hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( harfBuzzBuffer, &glyphCount );
- hb_glyph_position_t *glyphPositions = hb_buffer_get_glyph_positions( harfBuzzBuffer, &glyphCount );
- const GlyphIndex lastGlyphIndex = glyphCount - 1u;
+ unsigned int glyphCount;
+ hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos(harfBuzzBuffer, &glyphCount);
+ hb_glyph_position_t* glyphPositions = hb_buffer_get_glyph_positions(harfBuzzBuffer, &glyphCount);
+ const GlyphIndex lastGlyphIndex = glyphCount - 1u;
- for( GlyphIndex i = 0u; i < glyphCount; )
+ for(GlyphIndex i = 0u; i < glyphCount;)
{
- if( rtlDirection )
+ if(rtlDirection)
{
// If the direction is right to left, Harfbuzz retrieves the glyphs in the visual order.
// The glyphs are needed in the logical order to layout the text in lines.
// Do not change the order of the glyphs if they belong to the same cluster.
GlyphIndex rtlIndex = lastGlyphIndex - i;
- unsigned int cluster = glyphInfo[rtlIndex].cluster;
- unsigned int previousCluster = cluster;
- Length numberOfGlyphsInCluster = 0u;
+ unsigned int cluster = glyphInfo[rtlIndex].cluster;
+ unsigned int previousCluster = cluster;
+ Length numberOfGlyphsInCluster = 0u;
- while( ( cluster == previousCluster ) )
+ while((cluster == previousCluster))
{
++numberOfGlyphsInCluster;
previousCluster = cluster;
- if( rtlIndex > 0u )
+ if(rtlIndex > 0u)
{
--rtlIndex;
}
}
- rtlIndex = lastGlyphIndex - ( i + ( numberOfGlyphsInCluster - 1u ) );
+ rtlIndex = lastGlyphIndex - (i + (numberOfGlyphsInCluster - 1u));
- for( GlyphIndex j = 0u; j < numberOfGlyphsInCluster; ++j )
+ for(GlyphIndex j = 0u; j < numberOfGlyphsInCluster; ++j)
{
const GlyphIndex index = rtlIndex + j;
- mIndices.PushBack( glyphInfo[index].codepoint );
- mAdvance.PushBack( glyphPositions[index].x_advance * FROM_266 );
- mCharacterMap.PushBack( glyphInfo[index].cluster );
- mOffset.PushBack( glyphPositions[index].x_offset * FROM_266 );
- mOffset.PushBack( glyphPositions[index].y_offset * FROM_266 );
+ mIndices.PushBack(glyphInfo[index].codepoint);
+ mAdvance.PushBack(glyphPositions[index].x_advance * FROM_266);
+ mCharacterMap.PushBack(glyphInfo[index].cluster);
+ mOffset.PushBack(glyphPositions[index].x_offset * FROM_266);
+ mOffset.PushBack(glyphPositions[index].y_offset * FROM_266);
}
i += numberOfGlyphsInCluster;
}
else
{
- mIndices.PushBack( glyphInfo[i].codepoint );
- mAdvance.PushBack( glyphPositions[i].x_advance * FROM_266 );
- mCharacterMap.PushBack( glyphInfo[i].cluster );
- mOffset.PushBack( glyphPositions[i].x_offset * FROM_266 );
- mOffset.PushBack( glyphPositions[i].y_offset * FROM_266 );
+ mIndices.PushBack(glyphInfo[i].codepoint);
+ mAdvance.PushBack(glyphPositions[i].x_advance * FROM_266);
+ mCharacterMap.PushBack(glyphInfo[i].cluster);
+ mOffset.PushBack(glyphPositions[i].x_offset * FROM_266);
+ mOffset.PushBack(glyphPositions[i].y_offset * FROM_266);
++i;
}
}
/* Cleanup */
- hb_buffer_destroy( harfBuzzBuffer );
- hb_font_destroy( harfBuzzFont );
+ hb_buffer_destroy(harfBuzzBuffer);
+ hb_font_destroy(harfBuzzFont);
break;
}
case FontDescription::BITMAP_FONT:
{
// Reserve some space to avoid reallocations.
// The advance and offset tables can be initialized with zeros as it's not needed to get metrics from the bitmaps here.
- mIndices.Resize( numberOfCharacters );
- mAdvance.Resize( numberOfCharacters, 0u );
- mCharacterMap.Reserve( numberOfCharacters );
- mOffset.Resize( 2u * numberOfCharacters, 0.f );
+ mIndices.Resize(numberOfCharacters);
+ mAdvance.Resize(numberOfCharacters, 0u);
+ mCharacterMap.Reserve(numberOfCharacters);
+ mOffset.Resize(2u * numberOfCharacters, 0.f);
// The utf32 character can be used as the glyph's index.
- std::copy( text, text + numberOfCharacters, mIndices.Begin() );
+ std::copy(text, text + numberOfCharacters, mIndices.Begin());
// The glyph to character map is 1 to 1.
- for( unsigned int index = 0u; index < numberOfCharacters; ++index )
+ for(unsigned int index = 0u; index < numberOfCharacters; ++index)
{
- mCharacterMap.PushBack( index );
+ mCharacterMap.PushBack(index);
}
break;
}
return mIndices.Count();
}
- void GetGlyphs( GlyphInfo* glyphInfo,
- CharacterIndex* glyphToCharacterMap )
+ void GetGlyphs(GlyphInfo* glyphInfo,
+ CharacterIndex* glyphToCharacterMap)
{
- Vector<CharacterIndex>::ConstIterator indicesIt = mIndices.Begin();
- Vector<float>::ConstIterator advanceIt = mAdvance.Begin();
- Vector<float>::ConstIterator offsetIt = mOffset.Begin();
+ Vector<CharacterIndex>::ConstIterator indicesIt = mIndices.Begin();
+ Vector<float>::ConstIterator advanceIt = mAdvance.Begin();
+ Vector<float>::ConstIterator offsetIt = mOffset.Begin();
Vector<CharacterIndex>::ConstIterator characterMapIt = mCharacterMap.Begin();
- for( GlyphIndex index = 0u, size = mIndices.Count(); index < size; ++index )
+ for(GlyphIndex index = 0u, size = mIndices.Count(); index < size; ++index)
{
- GlyphInfo& glyph = *( glyphInfo + index );
- CharacterIndex& glyphToCharacter = *( glyphToCharacterMap + index );
+ GlyphInfo& glyph = *(glyphInfo + index);
+ CharacterIndex& glyphToCharacter = *(glyphToCharacterMap + index);
- glyph.fontId = mFontId;
- glyph.index = *( indicesIt + index );
- glyph.advance = *( advanceIt + index );
+ glyph.fontId = mFontId;
+ glyph.index = *(indicesIt + index);
+ glyph.advance = *(advanceIt + index);
const GlyphIndex offsetIndex = 2u * index;
- glyph.xBearing = *( offsetIt + offsetIndex );
- glyph.yBearing = *( offsetIt + offsetIndex + 1u );
+ glyph.xBearing = *(offsetIt + offsetIndex);
+ glyph.yBearing = *(offsetIt + offsetIndex + 1u);
- glyphToCharacter = *( characterMapIt + index );
+ glyphToCharacter = *(characterMapIt + index);
}
}
};
Shaping::Shaping()
-: mPlugin( NULL )
+: mPlugin(NULL)
{
}
{
TextAbstraction::Shaping shapingHandle;
- SingletonService service( SingletonService::Get() );
- if( service )
+ SingletonService service(SingletonService::Get());
+ if(service)
{
// Check whether the singleton is already created
- Dali::BaseHandle handle = service.GetSingleton( typeid( TextAbstraction::Shaping ) );
- if( handle )
+ Dali::BaseHandle handle = service.GetSingleton(typeid(TextAbstraction::Shaping));
+ if(handle)
{
// If so, downcast the handle
- Shaping* impl = dynamic_cast< Internal::Shaping* >( handle.GetObjectPtr() );
- shapingHandle = TextAbstraction::Shaping( impl );
+ Shaping* impl = dynamic_cast<Internal::Shaping*>(handle.GetObjectPtr());
+ shapingHandle = TextAbstraction::Shaping(impl);
}
else // create and register the object
{
- shapingHandle = TextAbstraction::Shaping( new Shaping );
- service.Register( typeid( shapingHandle ), shapingHandle );
+ shapingHandle = TextAbstraction::Shaping(new Shaping);
+ service.Register(typeid(shapingHandle), shapingHandle);
}
}
return shapingHandle;
}
-Length Shaping::Shape( const Character* const text,
- Length numberOfCharacters,
- FontId fontId,
- Script script )
+Length Shaping::Shape(const Character* const text,
+ Length numberOfCharacters,
+ FontId fontId,
+ Script script)
{
CreatePlugin();
- return mPlugin->Shape( text,
- numberOfCharacters,
- fontId,
- script );
+ return mPlugin->Shape(text,
+ numberOfCharacters,
+ fontId,
+ script);
}
-void Shaping::GetGlyphs( GlyphInfo* glyphInfo,
- CharacterIndex* glyphToCharacterMap )
+void Shaping::GetGlyphs(GlyphInfo* glyphInfo,
+ CharacterIndex* glyphToCharacterMap)
{
CreatePlugin();
- mPlugin->GetGlyphs( glyphInfo,
- glyphToCharacterMap );
+ mPlugin->GetGlyphs(glyphInfo,
+ glyphToCharacterMap);
}
void Shaping::CreatePlugin()
{
- if( !mPlugin )
+ if(!mPlugin)
{
mPlugin = new Plugin();
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
TextRenderer::TextRenderer()
{
}
TextAbstraction::TextRenderer shapingHandle;
SingletonService service(SingletonService::Get());
- if (service)
+ if(service)
{
// Check whether the singleton is already created
Dali::BaseHandle handle = service.GetSingleton(typeid(TextAbstraction::TextRenderer));
- if (handle)
+ if(handle)
{
// If so, downcast the handle
- TextRenderer* impl = dynamic_cast< Internal::TextRenderer* >(handle.GetObjectPtr());
- shapingHandle = TextAbstraction::TextRenderer(impl);
+ TextRenderer* impl = dynamic_cast<Internal::TextRenderer*>(handle.GetObjectPtr());
+ shapingHandle = TextAbstraction::TextRenderer(impl);
}
else // create and register the object
{
/*
- * Copyright (c) 2016 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.
#include <third-party/glyphy/vector-font-cache.h>
// EXTERNAL INCLUDES
-#include <vector>
#include <math.h>
+#include <vector>
// INTERNAL INCLUDES
-#include <dali/internal/text/glyphy/glyphy.h>
#include <dali/internal/text/glyphy/glyphy-freetype.h>
+#include <dali/internal/text/glyphy/glyphy.h>
using namespace std;
namespace
{
-
const unsigned int INITIAL_GLYPH_CAPACITY = 50;
-const double MIN_FONT_SIZE = 10;
+const double MIN_FONT_SIZE = 10;
static glyphy_bool_t
-accumulate_endpoint( glyphy_arc_endpoint_t* endpoint,
- vector<glyphy_arc_endpoint_t>* endpoints )
+accumulate_endpoint(glyphy_arc_endpoint_t* endpoint,
+ vector<glyphy_arc_endpoint_t>* endpoints)
{
- endpoints->push_back( *endpoint );
+ endpoints->push_back(*endpoint);
return true;
}
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
typedef vector<VectorBlob> BlobArray;
struct VectorGlyph
/**
* @brief Create a vector-based glyph.
*/
- static VectorGlyph* New( FT_Face face,
- FontId fontId,
- GlyphIndex index,
- glyphy_arc_accumulator_t* accumulator )
+ static VectorGlyph* New(FT_Face face,
+ FontId fontId,
+ GlyphIndex index,
+ glyphy_arc_accumulator_t* accumulator)
{
VectorGlyph* newGlyph = new VectorGlyph();
- newGlyph->blobData.resize( 1024 * 16 );
+ newGlyph->blobData.resize(1024 * 16);
- if( FT_Err_Ok != FT_Load_Glyph( face,
- index,
- FT_LOAD_NO_BITMAP |
+ if(FT_Err_Ok != FT_Load_Glyph(face,
+ index,
+ FT_LOAD_NO_BITMAP |
FT_LOAD_NO_HINTING |
FT_LOAD_NO_AUTOHINT |
FT_LOAD_NO_SCALE |
FT_LOAD_LINEAR_DESIGN |
FT_LOAD_IGNORE_TRANSFORM))
{
- DALI_LOG_ERROR( "FT_Load_Glyph failed\n" );
+ DALI_LOG_ERROR("FT_Load_Glyph failed\n");
delete newGlyph;
return NULL;
}
- const double upem = static_cast<double>( face->units_per_EM );
- const double tolerance = upem * 1.0f/2048.0f;
+ const double upem = static_cast<double>(face->units_per_EM);
+ const double tolerance = upem * 1.0f / 2048.0f;
- glyphy_arc_accumulator_reset( accumulator);
- glyphy_arc_accumulator_set_tolerance( accumulator, tolerance );
+ glyphy_arc_accumulator_reset(accumulator);
+ glyphy_arc_accumulator_set_tolerance(accumulator, tolerance);
vector<glyphy_arc_endpoint_t> endpoints;
- glyphy_arc_accumulator_set_callback( accumulator,
- reinterpret_cast<glyphy_arc_endpoint_accumulator_callback_t>( accumulate_endpoint ),
- &endpoints );
+ glyphy_arc_accumulator_set_callback(accumulator,
+ reinterpret_cast<glyphy_arc_endpoint_accumulator_callback_t>(accumulate_endpoint),
+ &endpoints);
- if( FT_Err_Ok != glyphy_freetype_outline_decompose( &face->glyph->outline, accumulator ) )
+ if(FT_Err_Ok != glyphy_freetype_outline_decompose(&face->glyph->outline, accumulator))
{
- DALI_LOG_ERROR( "glyphy_freetype_outline_decompose failed\n" );
+ DALI_LOG_ERROR("glyphy_freetype_outline_decompose failed\n");
delete newGlyph;
return NULL;
}
- DALI_ASSERT_DEBUG( glyphy_arc_accumulator_get_error(accumulator) <= tolerance && "glyphy_arc_accumulator_get_error > tolerance" );
+ DALI_ASSERT_DEBUG(glyphy_arc_accumulator_get_error(accumulator) <= tolerance && "glyphy_arc_accumulator_get_error > tolerance");
- if( endpoints.size() )
+ if(endpoints.size())
{
- glyphy_outline_winding_from_even_odd( &endpoints[0], endpoints.size (), false );
+ glyphy_outline_winding_from_even_odd(&endpoints[0], endpoints.size(), false);
}
- unsigned int blobLength( 0 );
- double averageFetchAchieved( 0.0 );
- if (!glyphy_arc_list_encode_blob( endpoints.size() ? &endpoints[0] : NULL,
- endpoints.size(),
- &newGlyph->blobData[0],
- newGlyph->blobData.capacity(),
- upem / ( MIN_FONT_SIZE * M_SQRT2 ),
- 4,
- &averageFetchAchieved,
- &blobLength,
- &newGlyph->nominalWidth,
- &newGlyph->nominalHeight,
- &newGlyph->extents ) )
+ unsigned int blobLength(0);
+ double averageFetchAchieved(0.0);
+ if(!glyphy_arc_list_encode_blob(endpoints.size() ? &endpoints[0] : NULL,
+ endpoints.size(),
+ &newGlyph->blobData[0],
+ newGlyph->blobData.capacity(),
+ upem / (MIN_FONT_SIZE * M_SQRT2),
+ 4,
+ &averageFetchAchieved,
+ &blobLength,
+ &newGlyph->nominalWidth,
+ &newGlyph->nominalHeight,
+ &newGlyph->extents))
{
- DALI_LOG_ERROR( "glyphy_arc_list_encode_blob failed\n" );
+ DALI_LOG_ERROR("glyphy_arc_list_encode_blob failed\n");
delete newGlyph;
return NULL;
}
- newGlyph->blobData.resize( blobLength );
+ newGlyph->blobData.resize(blobLength);
- glyphy_extents_scale( &newGlyph->extents, 1.0/upem, 1.0/upem );
+ glyphy_extents_scale(&newGlyph->extents, 1.0 / upem, 1.0 / upem);
newGlyph->glyphInfo.fontId = fontId;
newGlyph->glyphInfo.index = index;
- if( glyphy_extents_is_empty( &newGlyph->extents ) )
+ if(glyphy_extents_is_empty(&newGlyph->extents))
{
newGlyph->glyphInfo.width = 0.0f;
newGlyph->glyphInfo.height = 0.0f;
newGlyph->glyphInfo.yBearing = newGlyph->glyphInfo.height + (newGlyph->extents.min_y);
}
- newGlyph->glyphInfo.advance = face->glyph->metrics.horiAdvance / upem;
+ newGlyph->glyphInfo.advance = face->glyph->metrics.horiAdvance / upem;
newGlyph->glyphInfo.scaleFactor = 0.0f;
return newGlyph;
}
VectorGlyph()
- : advance( 0.0 ),
- nominalWidth( 0 ),
- nominalHeight( 0 ),
+ : advance(0.0),
+ nominalWidth(0),
+ nominalHeight(0),
glyphInfo(),
blobData()
{
- glyphy_extents_clear( &extents );
+ glyphy_extents_clear(&extents);
}
glyphy_extents_t extents;
struct VectorFont
{
- VectorFont( FT_Face face )
- : mFace( face ),
+ VectorFont(FT_Face face)
+ : mFace(face),
mGlyphCache()
{
- mGlyphCache.reserve( INITIAL_GLYPH_CAPACITY );
+ mGlyphCache.reserve(INITIAL_GLYPH_CAPACITY);
}
FT_Face mFace;
struct VectorFontCache::Impl
{
- Impl( FT_Library freeTypeLibrary )
- : mFreeTypeLibrary( freeTypeLibrary ),
+ Impl(FT_Library freeTypeLibrary)
+ : mFreeTypeLibrary(freeTypeLibrary),
mIdLookup(),
mVectorFonts(),
- mAccumulator( NULL )
+ mAccumulator(NULL)
{
mAccumulator = glyphy_arc_accumulator_create();
}
~Impl()
{
- glyphy_arc_accumulator_destroy( mAccumulator );
+ glyphy_arc_accumulator_destroy(mAccumulator);
}
private:
-
// Declared private and left undefined to avoid copies.
- Impl( const Impl& );
+ Impl(const Impl&);
// Declared private and left undefined to avoid copies.
- Impl& operator=( const Impl& );
+ Impl& operator=(const Impl&);
public:
-
FT_Library mFreeTypeLibrary; ///< A handle to a FreeType library instance.
vector<string> mIdLookup;
glyphy_arc_accumulator_t* mAccumulator;
};
-VectorFontCache::VectorFontCache( FT_Library freeTypeLibrary )
-: mImpl( NULL )
+VectorFontCache::VectorFontCache(FT_Library freeTypeLibrary)
+: mImpl(NULL)
{
- mImpl = new Impl( freeTypeLibrary );
+ mImpl = new Impl(freeTypeLibrary);
}
VectorFontCache::~VectorFontCache()
delete mImpl;
}
-FontId VectorFontCache::GetFontId( const std::string& url )
+FontId VectorFontCache::GetFontId(const std::string& url)
{
- FontId id( 0 );
+ FontId id(0);
- if( mImpl )
+ if(mImpl)
{
- if( ! FindFont( url, id ) )
+ if(!FindFont(url, id))
{
- id = CreateFont( url );
+ id = CreateFont(url);
}
}
return id;
}
-void VectorFontCache::GetGlyphMetrics( FontId vectorFontId, GlyphInfo& glyphInfo )
+void VectorFontCache::GetGlyphMetrics(FontId vectorFontId, GlyphInfo& glyphInfo)
{
- if( mImpl )
+ if(mImpl)
{
- if( vectorFontId > 0 &&
- vectorFontId-1 < mImpl->mVectorFonts.size() )
+ if(vectorFontId > 0 &&
+ vectorFontId - 1 < mImpl->mVectorFonts.size())
{
- VectorFont* font = mImpl->mVectorFonts[ vectorFontId-1 ];
+ VectorFont* font = mImpl->mVectorFonts[vectorFontId - 1];
GlyphCache& cache = font->mGlyphCache;
- bool foundGlyph( false );
- unsigned int foundIndex( 0 );
- for( unsigned int i=0; i<cache.size(); ++i )
+ bool foundGlyph(false);
+ unsigned int foundIndex(0);
+ for(unsigned int i = 0; i < cache.size(); ++i)
{
VectorGlyph* glyph = cache[i];
- if( glyph->glyphInfo.index == glyphInfo.index )
+ if(glyph->glyphInfo.index == glyphInfo.index)
{
foundIndex = i;
foundGlyph = true;
}
}
- if( foundGlyph )
+ if(foundGlyph)
{
VectorGlyph* glyph = cache[foundIndex];
// Note - this clobbers the original fontId, but helps avoid duplicating identical blobs
}
else
{
- VectorGlyph* newGlyph = VectorGlyph::New( font->mFace,
- glyphInfo.fontId,
- glyphInfo.index,
- mImpl->mAccumulator );
+ VectorGlyph* newGlyph = VectorGlyph::New(font->mFace,
+ glyphInfo.fontId,
+ glyphInfo.index,
+ mImpl->mAccumulator);
- if( newGlyph )
+ if(newGlyph)
{
glyphInfo = newGlyph->glyphInfo;
- cache.push_back( newGlyph );
+ cache.push_back(newGlyph);
}
}
}
}
}
-void VectorFontCache::GetVectorBlob( FontId vectorFontId,
- FontId fontId,
- GlyphIndex glyphIndex,
- VectorBlob*& blob,
- unsigned int& blobLength,
- unsigned int& nominalWidth,
- unsigned int& nominalHeight )
+void VectorFontCache::GetVectorBlob(FontId vectorFontId,
+ FontId fontId,
+ GlyphIndex glyphIndex,
+ VectorBlob*& blob,
+ unsigned int& blobLength,
+ unsigned int& nominalWidth,
+ unsigned int& nominalHeight)
{
- if( mImpl )
+ if(mImpl)
{
- if( vectorFontId > 0 &&
- vectorFontId-1 < mImpl->mVectorFonts.size() )
+ if(vectorFontId > 0 &&
+ vectorFontId - 1 < mImpl->mVectorFonts.size())
{
- VectorFont* font = mImpl->mVectorFonts[ vectorFontId-1 ];
+ VectorFont* font = mImpl->mVectorFonts[vectorFontId - 1];
GlyphCache& cache = font->mGlyphCache;
- bool foundGlyph( false );
- unsigned int foundIndex( 0 );
- for( unsigned int i=0; i<cache.size(); ++i )
+ bool foundGlyph(false);
+ unsigned int foundIndex(0);
+ for(unsigned int i = 0; i < cache.size(); ++i)
{
VectorGlyph* glyph = cache[i];
- if( glyph->glyphInfo.index == glyphIndex )
+ if(glyph->glyphInfo.index == glyphIndex)
{
foundIndex = i;
foundGlyph = true;
}
}
- if( foundGlyph )
+ if(foundGlyph)
{
VectorGlyph* glyph = cache[foundIndex];
}
else
{
- VectorGlyph* newGlyph = VectorGlyph::New( font->mFace, fontId, glyphIndex, mImpl->mAccumulator );
+ VectorGlyph* newGlyph = VectorGlyph::New(font->mFace, fontId, glyphIndex, mImpl->mAccumulator);
- if( newGlyph )
+ if(newGlyph)
{
blob = &newGlyph->blobData[0];
blobLength = newGlyph->blobData.size();
nominalWidth = newGlyph->nominalWidth;
nominalHeight = newGlyph->nominalHeight;
- cache.push_back( newGlyph );
+ cache.push_back(newGlyph);
}
}
}
}
}
-bool VectorFontCache::FindFont( const string& url, FontId& vectorFontId ) const
+bool VectorFontCache::FindFont(const string& url, FontId& vectorFontId) const
{
vectorFontId = 0u;
const vector<string>& idLookup = mImpl->mIdLookup;
- for( unsigned int i=0; i<idLookup.size(); ++i, ++vectorFontId )
+ for(unsigned int i = 0; i < idLookup.size(); ++i, ++vectorFontId)
{
- if( url == idLookup[i] )
+ if(url == idLookup[i])
{
++vectorFontId;
return true;
return false;
}
-FontId VectorFontCache::CreateFont( const string& url )
+FontId VectorFontCache::CreateFont(const string& url)
{
- FontId id( 0 );
+ FontId id(0);
// Create & cache new font face
FT_Face face;
- int error = FT_New_Face( mImpl->mFreeTypeLibrary,
- url.c_str(),
- 0,
- &face );
+ int error = FT_New_Face(mImpl->mFreeTypeLibrary,
+ url.c_str(),
+ 0,
+ &face);
- if( FT_Err_Ok == error )
+ if(FT_Err_Ok == error)
{
- mImpl->mIdLookup.push_back( url );
+ mImpl->mIdLookup.push_back(url);
id = mImpl->mIdLookup.size();
- VectorFont* newFont = new VectorFont( face );
- mImpl->mVectorFonts.push_back( newFont );
+ VectorFont* newFont = new VectorFont(face);
+ mImpl->mVectorFonts.push_back(newFont);
- DALI_ASSERT_DEBUG( mImpl->mIdLookup.size() == mImpl->mVectorFonts.size() );
+ DALI_ASSERT_DEBUG(mImpl->mIdLookup.size() == mImpl->mVectorFonts.size());
}
return id;
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace ThreadSettings
{
-
void SetThreadName(const std::string& threadName)
{
int err = prctl(PR_SET_NAME, threadName.c_str());
- if ( err )
+ if(err)
{
- DALI_LOG_ERROR( "prctl(PR_SET_NAME, %s) failed\n", threadName.c_str() );
+ DALI_LOG_ERROR("prctl(PR_SET_NAME, %s) failed\n", threadName.c_str());
}
}
/*
- * Copyright (c) 2019 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.
*
*/
-#include <dali/internal/trace/common/trace-factory.h>
#include <dali/internal/trace/android/trace-manager-impl-android.h>
+#include <dali/internal/trace/common/trace-factory.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace TraceManagerFactory
{
-
// TraceManager Factory to be implemented by the platform
-TraceManagerUPtr CreateTraceFactory( PerformanceInterface* performanceInterface )
+TraceManagerUPtr CreateTraceFactory(PerformanceInterface* performanceInterface)
{
- return TraceManagerUPtr( new Dali::Internal::Adaptor::TraceManagerAndroid( performanceInterface ) );
+ return TraceManagerUPtr(new Dali::Internal::Adaptor::TraceManagerAndroid(performanceInterface));
}
} // namespace TraceManagerFactory
} // namespace Internal
-} // namespace Dali // namespace Dali
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
*/
// EXTERNAL INCLUDES
-#include <dali/internal/trace/android/trace-manager-impl-android.h>
#include <dali/internal/system/common/performance-interface.h>
+#include <dali/internal/trace/android/trace-manager-impl-android.h>
// INTERNAL INCLUDES
namespace Dali
{
-
-
namespace Internal
{
-
namespace Adaptor
{
-
TraceManagerAndroid* TraceManagerAndroid::traceManagerAndroid = nullptr;
-TraceManagerAndroid::TraceManagerAndroid( PerformanceInterface* performanceInterface )
-: TraceManager( performanceInterface )
+TraceManagerAndroid::TraceManagerAndroid(PerformanceInterface* performanceInterface)
+: TraceManager(performanceInterface)
{
TraceManagerAndroid::traceManagerAndroid = this;
}
return LogContext;
}
-void TraceManagerAndroid::LogContext( bool start, const char* tag )
+void TraceManagerAndroid::LogContext(bool start, const char* tag)
{
- if( start )
+ if(start)
{
- unsigned short contextId = traceManagerAndroid->mPerformanceInterface->AddContext( tag );
- traceManagerAndroid->mPerformanceInterface->AddMarker( PerformanceInterface::START, contextId );
+ unsigned short contextId = traceManagerAndroid->mPerformanceInterface->AddContext(tag);
+ traceManagerAndroid->mPerformanceInterface->AddMarker(PerformanceInterface::START, contextId);
}
else
{
- unsigned short contextId = traceManagerAndroid->mPerformanceInterface->AddContext( tag );
- traceManagerAndroid->mPerformanceInterface->AddMarker( PerformanceInterface::END, contextId );
+ unsigned short contextId = traceManagerAndroid->mPerformanceInterface->AddContext(tag);
+ traceManagerAndroid->mPerformanceInterface->AddMarker(PerformanceInterface::END, contextId);
}
}
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace TraceManagerFactory
{
-
// Factory function creating new TraceFactory
// Symbol exists but may be overriden during linking
__attribute__((weak))
-TraceManagerUPtr CreateTraceFactory( PerformanceInterface* performanceInterface )
+TraceManagerUPtr
+CreateTraceFactory(PerformanceInterface* performanceInterface)
{
// return empty handle if TraceManager not implemented
return nullptr;
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-TraceManager::TraceManager( PerformanceInterface* performanceInterface )
-: mPerformanceInterface( performanceInterface )
+TraceManager::TraceManager(PerformanceInterface* performanceInterface)
+: mPerformanceInterface(performanceInterface)
{
}
bool TraceManager::Initialise()
{
auto logFunction = GetLogContextFunction();
- if( !logFunction )
+ if(!logFunction)
{
- return false;
+ return false;
}
- Dali::Integration::Trace::InstallLogContextFunction( logFunction );
+ Dali::Integration::Trace::InstallLogContextFunction(logFunction);
return true;
}
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace TraceManagerFactory
{
-
// TraceManager Factory to be implemented by the platform
-TraceManagerUPtr CreateTraceFactory( PerformanceInterface* performanceInterface )
+TraceManagerUPtr CreateTraceFactory(PerformanceInterface* performanceInterface)
{
- return TraceManagerUPtr( new Dali::Internal::Adaptor::TraceManagerGeneric( performanceInterface ) );
+ return TraceManagerUPtr(new Dali::Internal::Adaptor::TraceManagerGeneric(performanceInterface));
}
} // namespace TraceManagerFactory
/*
- * Copyright (c) 2019 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.
*/
// EXTERNAL INCLUDES
-#include <dali/internal/system/common/performance-interface.h>
#include "trace-manager-impl-generic.h"
+#include <dali/internal/system/common/performance-interface.h>
// INTERNAL INCLUDES
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
TraceManagerGeneric* TraceManagerGeneric::traceManagerGeneric = nullptr;
-TraceManagerGeneric::TraceManagerGeneric( PerformanceInterface* performanceInterface )
-: TraceManager( performanceInterface )
+TraceManagerGeneric::TraceManagerGeneric(PerformanceInterface* performanceInterface)
+: TraceManager(performanceInterface)
{
TraceManagerGeneric::traceManagerGeneric = this;
}
return LogContext;
}
-void TraceManagerGeneric::LogContext( bool start, const char* tag )
+void TraceManagerGeneric::LogContext(bool start, const char* tag)
{
- if( start )
+ if(start)
{
- unsigned short contextId = traceManagerGeneric->mPerformanceInterface->AddContext( tag );
- traceManagerGeneric->mPerformanceInterface->AddMarker( PerformanceInterface::START, contextId );
+ unsigned short contextId = traceManagerGeneric->mPerformanceInterface->AddContext(tag);
+ traceManagerGeneric->mPerformanceInterface->AddMarker(PerformanceInterface::START, contextId);
}
else
{
- unsigned short contextId = traceManagerGeneric->mPerformanceInterface->AddContext( tag );
- traceManagerGeneric->mPerformanceInterface->AddMarker( PerformanceInterface::END, contextId );
+ unsigned short contextId = traceManagerGeneric->mPerformanceInterface->AddContext(tag);
+ traceManagerGeneric->mPerformanceInterface->AddMarker(PerformanceInterface::END, contextId);
}
}
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace TraceManagerFactory
{
-
// TraceManager Factory to be implemented by the platform
-TraceManagerUPtr CreateTraceFactory( PerformanceInterface* performanceInterface )
+TraceManagerUPtr CreateTraceFactory(PerformanceInterface* performanceInterface)
{
- return TraceManagerUPtr( new Dali::Internal::Adaptor::TraceManagerTizen( performanceInterface ) );
+ return TraceManagerUPtr(new Dali::Internal::Adaptor::TraceManagerTizen(performanceInterface));
}
} // namespace TraceManagerFactory
/*
- * Copyright (c) 2018 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.
*/
// EXTERNAL INCLUDES
-#include <ttrace.h>
#include <dali/internal/trace/tizen/trace-manager-impl-tizen.h>
+#include <ttrace.h>
// INTERNAL INCLUDES
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-TraceManagerTizen::TraceManagerTizen( PerformanceInterface* performanceInterface )
-: TraceManager( performanceInterface )
+TraceManagerTizen::TraceManagerTizen(PerformanceInterface* performanceInterface)
+: TraceManager(performanceInterface)
{
}
return LogContext;
}
-void TraceManagerTizen::LogContext( bool start, const char* tag )
+void TraceManagerTizen::LogContext(bool start, const char* tag)
{
- if( start )
+ if(start)
{
- traceBegin( TTRACE_TAG_GRAPHICS, tag );
+ traceBegin(TTRACE_TAG_GRAPHICS, tag);
}
else
{
- traceEnd( TTRACE_TAG_GRAPHICS );
+ traceEnd(TTRACE_TAG_GRAPHICS);
}
}
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-
// Type Registration
Dali::BaseHandle Create()
{
return Dali::BaseHandle();
}
-Dali::TypeRegistration type( typeid( Dali::VectorAnimationRenderer ), typeid( Dali::BaseHandle ), Create );
+Dali::TypeRegistration type(typeid(Dali::VectorAnimationRenderer), typeid(Dali::BaseHandle), Create);
} // unnamed namespace
}
VectorAnimationRenderer::VectorAnimationRenderer()
-: mPlugin( std::string() )
+: mPlugin(std::string())
{
}
{
}
-void VectorAnimationRenderer::Initialize( const std::string& url )
+void VectorAnimationRenderer::Initialize(const std::string& url)
{
- mPlugin.Initialize( url );
+ mPlugin.Initialize(url);
}
void VectorAnimationRenderer::Finalize()
mPlugin.Finalize();
}
-void VectorAnimationRenderer::SetRenderer( Dali::Renderer renderer )
+void VectorAnimationRenderer::SetRenderer(Dali::Renderer renderer)
{
- mPlugin.SetRenderer( renderer );
+ mPlugin.SetRenderer(renderer);
}
-void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
+void VectorAnimationRenderer::SetSize(uint32_t width, uint32_t height)
{
- mPlugin.SetSize( width, height );
+ mPlugin.SetSize(width, height);
}
-bool VectorAnimationRenderer::Render( uint32_t frameNumber )
+bool VectorAnimationRenderer::Render(uint32_t frameNumber)
{
- return mPlugin.Render( frameNumber );
+ return mPlugin.Render(frameNumber);
}
uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
return mPlugin.GetFrameRate();
}
-void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+void VectorAnimationRenderer::GetDefaultSize(uint32_t& width, uint32_t& height) const
{
- mPlugin.GetDefaultSize( width, height );
+ mPlugin.GetDefaultSize(width, height);
}
-void VectorAnimationRenderer::GetLayerInfo( Property::Map& map ) const
+void VectorAnimationRenderer::GetLayerInfo(Property::Map& map) const
{
- mPlugin.GetLayerInfo( map );
+ mPlugin.GetLayerInfo(map);
}
-bool VectorAnimationRenderer::GetMarkerInfo( const std::string& marker, uint32_t& startFrame, uint32_t& endFrame ) const
+bool VectorAnimationRenderer::GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const
{
- return mPlugin.GetMarkerInfo( marker, startFrame, endFrame );
+ return mPlugin.GetMarkerInfo(marker, startFrame, endFrame);
}
void VectorAnimationRenderer::IgnoreRenderedFrame()
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2019 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.
#include <dali/internal/vector-animation/common/vector-animation-renderer-plugin-proxy.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
#include <dali/integration-api/debug.h>
+#include <dlfcn.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
// The default plugin name
-const char* DEFAULT_OBJECT_NAME( "libdali2-vector-animation-renderer-plugin.so" );
+const char* DEFAULT_OBJECT_NAME("libdali2-vector-animation-renderer-plugin.so");
-}
+} // namespace
-VectorAnimationRendererPluginProxy::VectorAnimationRendererPluginProxy( const std::string& sharedObjectName )
+VectorAnimationRendererPluginProxy::VectorAnimationRendererPluginProxy(const std::string& sharedObjectName)
: mSharedObjectName(),
- mLibHandle( NULL ),
- mPlugin( NULL ),
- mCreateVectorAnimationRendererPtr( NULL ),
+ mLibHandle(NULL),
+ mPlugin(NULL),
+ mCreateVectorAnimationRendererPtr(NULL),
mDefaultSignal()
{
- if( !sharedObjectName.empty() )
+ if(!sharedObjectName.empty())
{
mSharedObjectName = sharedObjectName;
}
VectorAnimationRendererPluginProxy::~VectorAnimationRendererPluginProxy()
{
- if( mPlugin )
+ if(mPlugin)
{
delete mPlugin;
mPlugin = NULL;
- if( mLibHandle && dlclose( mLibHandle ) )
+ if(mLibHandle && dlclose(mLibHandle))
{
- DALI_LOG_ERROR( "Error closing vector animation renderer plugin library: %s\n", dlerror() );
+ DALI_LOG_ERROR("Error closing vector animation renderer plugin library: %s\n", dlerror());
}
}
}
void VectorAnimationRendererPluginProxy::Initialize()
{
- mLibHandle = dlopen( mSharedObjectName.c_str(), RTLD_LAZY );
+ mLibHandle = dlopen(mSharedObjectName.c_str(), RTLD_LAZY);
char* error = dlerror();
- if( mLibHandle == NULL || error != NULL )
+ if(mLibHandle == NULL || error != NULL)
{
- DALI_LOG_ERROR( "VectorAnimationRendererPluginProxy::Initialize: dlopen error [%s]\n", error );
+ DALI_LOG_ERROR("VectorAnimationRendererPluginProxy::Initialize: dlopen error [%s]\n", error);
return;
}
// load plugin
- mCreateVectorAnimationRendererPtr = reinterpret_cast< CreateVectorAnimationRendererFunction >( dlsym( mLibHandle, "CreateVectorAnimationRendererPlugin" ) );
+ mCreateVectorAnimationRendererPtr = reinterpret_cast<CreateVectorAnimationRendererFunction>(dlsym(mLibHandle, "CreateVectorAnimationRendererPlugin"));
error = dlerror();
- if( mCreateVectorAnimationRendererPtr == NULL || error != NULL )
+ if(mCreateVectorAnimationRendererPtr == NULL || error != NULL)
{
- DALI_LOG_ERROR( "VectorAnimationRendererPluginProxy::Initialize: Cannot load symbol: %s\n", error );
+ DALI_LOG_ERROR("VectorAnimationRendererPluginProxy::Initialize: Cannot load symbol: %s\n", error);
return;
}
mPlugin = mCreateVectorAnimationRendererPtr();
- if( !mPlugin )
+ if(!mPlugin)
{
DALI_LOG_ERROR("VectorAnimationRendererPluginProxy::Initialize: Plugin creation failed\n");
return;
}
}
-bool VectorAnimationRendererPluginProxy::Initialize( const std::string& url )
+bool VectorAnimationRendererPluginProxy::Initialize(const std::string& url)
{
- if( mPlugin )
+ if(mPlugin)
{
- return mPlugin->Initialize( url );
+ return mPlugin->Initialize(url);
}
return false;
}
void VectorAnimationRendererPluginProxy::Finalize()
{
- if( mPlugin )
+ if(mPlugin)
{
mPlugin->Finalize();
}
}
-void VectorAnimationRendererPluginProxy::SetRenderer( Dali::Renderer renderer )
+void VectorAnimationRendererPluginProxy::SetRenderer(Dali::Renderer renderer)
{
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->SetRenderer( renderer );
+ mPlugin->SetRenderer(renderer);
}
}
-void VectorAnimationRendererPluginProxy::SetSize( uint32_t width, uint32_t height )
+void VectorAnimationRendererPluginProxy::SetSize(uint32_t width, uint32_t height)
{
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->SetSize( width, height );
+ mPlugin->SetSize(width, height);
}
}
-bool VectorAnimationRendererPluginProxy::Render( uint32_t frameNumber )
+bool VectorAnimationRendererPluginProxy::Render(uint32_t frameNumber)
{
- if( mPlugin )
+ if(mPlugin)
{
- return mPlugin->Render( frameNumber );
+ return mPlugin->Render(frameNumber);
}
return false;
}
uint32_t VectorAnimationRendererPluginProxy::GetTotalFrameNumber() const
{
- if( mPlugin )
+ if(mPlugin)
{
return mPlugin->GetTotalFrameNumber();
}
float VectorAnimationRendererPluginProxy::GetFrameRate() const
{
- if( mPlugin )
+ if(mPlugin)
{
return mPlugin->GetFrameRate();
}
return 0.0f;
}
-void VectorAnimationRendererPluginProxy::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+void VectorAnimationRendererPluginProxy::GetDefaultSize(uint32_t& width, uint32_t& height) const
{
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->GetDefaultSize( width, height );
+ mPlugin->GetDefaultSize(width, height);
}
}
-void VectorAnimationRendererPluginProxy::GetLayerInfo( Property::Map& map ) const
+void VectorAnimationRendererPluginProxy::GetLayerInfo(Property::Map& map) const
{
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->GetLayerInfo( map );
+ mPlugin->GetLayerInfo(map);
}
}
-bool VectorAnimationRendererPluginProxy::GetMarkerInfo( const std::string& marker, uint32_t& startFrame, uint32_t& endFrame ) const
+bool VectorAnimationRendererPluginProxy::GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const
{
- if( mPlugin )
+ if(mPlugin)
{
- return mPlugin->GetMarkerInfo( marker, startFrame, endFrame );
+ return mPlugin->GetMarkerInfo(marker, startFrame, endFrame);
}
return false;
}
void VectorAnimationRendererPluginProxy::IgnoreRenderedFrame()
{
- if( mPlugin )
+ if(mPlugin)
{
mPlugin->IgnoreRenderedFrame();
}
VectorAnimationRendererPlugin::UploadCompletedSignalType& VectorAnimationRendererPluginProxy::UploadCompletedSignal()
{
- if( mPlugin )
+ if(mPlugin)
{
return mPlugin->UploadCompletedSignal();
}
/*
- * 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
const char* const UNITS("px");
return Dali::BaseHandle();
}
-Dali::TypeRegistration type( typeid( Dali::VectorImageRenderer ), typeid( Dali::BaseHandle ), Create );
+Dali::TypeRegistration type(typeid(Dali::VectorImageRenderer), typeid(Dali::BaseHandle), Create);
} // unnamed namespace
}
}
-void VectorImageRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+void VectorImageRenderer::GetDefaultSize(uint32_t& width, uint32_t& height) const
{
if(mPlugin.IsValid())
{
/*
- * 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.
#include <dali/internal/vector-image/common/vector-image-renderer-plugin-proxy.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
#include <dali/integration-api/debug.h>
+#include <dlfcn.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
// The default plugin name
-const char* DEFAULT_OBJECT_NAME( "libdali2-vector-image-renderer-plugin.so" );
+const char* DEFAULT_OBJECT_NAME("libdali2-vector-image-renderer-plugin.so");
-}
+} // namespace
VectorImageRendererPluginProxy::VectorImageRendererPluginProxy(std::string sharedObjectName)
: mSharedObjectName(std::move(sharedObjectName)),
}
// load plugin
- mCreateVectorImageRendererPtr = reinterpret_cast< CreateVectorImageRendererFunction >( dlsym( mLibHandle, "CreateVectorImageRendererPlugin" ) );
+ mCreateVectorImageRendererPtr = reinterpret_cast<CreateVectorImageRendererFunction>(dlsym(mLibHandle, "CreateVectorImageRendererPlugin"));
error = dlerror();
- if( mCreateVectorImageRendererPtr == nullptr || error != nullptr )
+ if(mCreateVectorImageRendererPtr == nullptr || error != nullptr)
{
- DALI_LOG_ERROR( "VectorImageRendererPluginProxy::Initialize: Cannot load symbol: %s\n", error );
+ DALI_LOG_ERROR("VectorImageRendererPluginProxy::Initialize: Cannot load symbol: %s\n", error);
return;
}
mPlugin = mCreateVectorImageRendererPtr();
- if( !mPlugin )
+ if(!mPlugin)
{
DALI_LOG_ERROR("VectorImageRendererPluginProxy::Initialize: Plugin creation failed\n");
return;
bool VectorImageRendererPluginProxy::Rasterize(Dali::Devel::PixelBuffer& buffer)
{
- if( mPlugin )
+ if(mPlugin)
{
return mPlugin->Rasterize(buffer);
}
return false;
}
-void VectorImageRendererPluginProxy::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+void VectorImageRendererPluginProxy::GetDefaultSize(uint32_t& width, uint32_t& height) const
{
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->GetDefaultSize( width, height );
+ mPlugin->GetDefaultSize(width, height);
}
}
/*
- * Copyright (c) 2016 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.
#include <dali/internal/video/common/video-player-impl.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
#include <dali/integration-api/debug.h>
-#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dlfcn.h>
// INTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/native-image-source.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-
-const char* VIDEO_PLUGIN_SO( "libdali2-video-player-plugin.so" );
+const char* VIDEO_PLUGIN_SO("libdali2-video-player-plugin.so");
Dali::BaseHandle Create()
{
return Dali::VideoPlayer::New();
}
-Dali::TypeRegistration type( typeid( Dali::VideoPlayer ), typeid( Dali::BaseHandle ), Create );
+Dali::TypeRegistration type(typeid(Dali::VideoPlayer), typeid(Dali::BaseHandle), Create);
} // unnamed namespace
}
VideoPlayer::VideoPlayer()
-: mPlugin( NULL ),
- mHandle( NULL ),
- mCreateVideoPlayerPtr( NULL ),
- mDestroyVideoPlayerPtr( NULL )
+: mPlugin(NULL),
+ mHandle(NULL),
+ mCreateVideoPlayerPtr(NULL),
+ mDestroyVideoPlayerPtr(NULL)
{
}
VideoPlayer::~VideoPlayer()
{
- if( mHandle != NULL )
+ if(mHandle != NULL)
{
- if( mDestroyVideoPlayerPtr != NULL )
+ if(mDestroyVideoPlayerPtr != NULL)
{
- mDestroyVideoPlayerPtr( mPlugin );
+ mDestroyVideoPlayerPtr(mPlugin);
}
- dlclose( mHandle );
+ dlclose(mHandle);
}
}
-void VideoPlayer::Initialize( Dali::Actor actor, VideoSyncMode syncMode )
+void VideoPlayer::Initialize(Dali::Actor actor, VideoSyncMode syncMode)
{
char* error = NULL;
- mHandle = dlopen( VIDEO_PLUGIN_SO, RTLD_LAZY );
+ mHandle = dlopen(VIDEO_PLUGIN_SO, RTLD_LAZY);
error = dlerror();
- if( mHandle == NULL || error != NULL )
+ if(mHandle == NULL || error != NULL)
{
- DALI_LOG_ERROR( "VideoPlayer::Initialize(), dlopen error: %s\n", error );
+ DALI_LOG_ERROR("VideoPlayer::Initialize(), dlopen error: %s\n", error);
return;
}
- mCreateVideoPlayerPtr = reinterpret_cast< CreateVideoPlayerFunction >( dlsym( mHandle, "CreateVideoPlayerPlugin" ) );
+ mCreateVideoPlayerPtr = reinterpret_cast<CreateVideoPlayerFunction>(dlsym(mHandle, "CreateVideoPlayerPlugin"));
error = dlerror();
- if( mCreateVideoPlayerPtr == NULL || error != NULL )
+ if(mCreateVideoPlayerPtr == NULL || error != NULL)
{
- DALI_LOG_ERROR( "Can't load symbol CreateVideoPlayerPlugin(), error: %s\n", error );
+ DALI_LOG_ERROR("Can't load symbol CreateVideoPlayerPlugin(), error: %s\n", error);
return;
}
- mPlugin = mCreateVideoPlayerPtr( actor, syncMode );
+ mPlugin = mCreateVideoPlayerPtr(actor, syncMode);
- if( mPlugin == NULL )
+ if(mPlugin == NULL)
{
- DALI_LOG_ERROR( "Can't create the VideoPlayerPlugin object\n" );
+ DALI_LOG_ERROR("Can't create the VideoPlayerPlugin object\n");
return;
}
- mDestroyVideoPlayerPtr = reinterpret_cast< DestroyVideoPlayerFunction >( dlsym( mHandle, "DestroyVideoPlayerPlugin" ) );
+ mDestroyVideoPlayerPtr = reinterpret_cast<DestroyVideoPlayerFunction>(dlsym(mHandle, "DestroyVideoPlayerPlugin"));
error = dlerror();
- if( mDestroyVideoPlayerPtr == NULL || error != NULL )
+ if(mDestroyVideoPlayerPtr == NULL || error != NULL)
{
- DALI_LOG_ERROR( "Can't load symbol DestroyVideoPlayerPlugin(), error: %s\n", error );
+ DALI_LOG_ERROR("Can't load symbol DestroyVideoPlayerPlugin(), error: %s\n", error);
return;
}
}
-void VideoPlayer::SetUrl( const std::string& url )
+void VideoPlayer::SetUrl(const std::string& url)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetUrl( url );
+ mPlugin->SetUrl(url);
}
}
std::string VideoPlayer::GetUrl()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->GetUrl();
}
void VideoPlayer::SetLooping(bool looping)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetLooping( looping );
+ mPlugin->SetLooping(looping);
}
}
bool VideoPlayer::IsLooping()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->IsLooping();
}
void VideoPlayer::Play()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
mPlugin->Play();
}
void VideoPlayer::Pause()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
mPlugin->Pause();
}
void VideoPlayer::Stop()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
mPlugin->Stop();
}
}
-void VideoPlayer::SetMute( bool mute )
+void VideoPlayer::SetMute(bool mute)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetMute( mute );
+ mPlugin->SetMute(mute);
}
}
bool VideoPlayer::IsMuted()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->IsMuted();
}
return false;
}
-void VideoPlayer::SetVolume( float left, float right )
+void VideoPlayer::SetVolume(float left, float right)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetVolume( left, right );
+ mPlugin->SetVolume(left, right);
}
}
-void VideoPlayer::GetVolume( float& left, float& right )
+void VideoPlayer::GetVolume(float& left, float& right)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->GetVolume( left, right );
+ mPlugin->GetVolume(left, right);
}
}
-void VideoPlayer::SetRenderingTarget( Dali::Any target )
+void VideoPlayer::SetRenderingTarget(Dali::Any target)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetRenderingTarget( target );
+ mPlugin->SetRenderingTarget(target);
}
}
-void VideoPlayer::SetPlayPosition( int millisecond )
+void VideoPlayer::SetPlayPosition(int millisecond)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetPlayPosition( millisecond );
+ mPlugin->SetPlayPosition(millisecond);
}
}
int VideoPlayer::GetPlayPosition()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->GetPlayPosition();
}
return 0;
}
-void VideoPlayer::SetDisplayArea( DisplayArea area )
+void VideoPlayer::SetDisplayArea(DisplayArea area)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetDisplayArea( area );
+ mPlugin->SetDisplayArea(area);
}
}
-void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
+void VideoPlayer::SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetDisplayRotation( rotation );
+ mPlugin->SetDisplayRotation(rotation);
}
}
Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->GetDisplayRotation();
}
Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->FinishedSignal();
}
return mFinishedSignal;
}
-void VideoPlayer::Forward( int millisecond )
+void VideoPlayer::Forward(int millisecond)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->Forward( millisecond );
+ mPlugin->Forward(millisecond);
}
}
-void VideoPlayer::Backward( int millisecond )
+void VideoPlayer::Backward(int millisecond)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->Backward( millisecond );
+ mPlugin->Backward(millisecond);
}
}
bool VideoPlayer::IsVideoTextureSupported()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->IsVideoTextureSupported();
}
return false;
}
-void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
+void VideoPlayer::SetCodecType(Dali::VideoPlayerPlugin::CodecType type)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetCodecType( type );
+ mPlugin->SetCodecType(type);
}
}
Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->GetCodecType();
}
return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
}
-void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
+void VideoPlayer::SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode)
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
- mPlugin->SetDisplayMode( mode );
+ mPlugin->SetDisplayMode(mode);
}
}
Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->GetDisplayMode();
}
Any VideoPlayer::GetMediaPlayer()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
return mPlugin->GetMediaPlayer();
}
void VideoPlayer::StartSynchronization()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
mPlugin->StartSynchronization();
}
void VideoPlayer::FinishSynchronization()
{
- if( mPlugin != NULL )
+ if(mPlugin != NULL)
{
mPlugin->FinishSynchronization();
}
}
-} // namespace Adaptor;
-} // namespace Internal;
-} // namespace Dali;
-
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/web-engine/common/web-engine-impl.h>
// EXTERNAL INCLUDES
-#include <dlfcn.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry.h>
+#include <dlfcn.h>
#include <sstream>
// INTERNAL INCLUDES
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace // unnamed namespace
{
-
-constexpr char const * const kPluginFullNamePrefix = "libdali2-web-engine-";
-constexpr char const * const kPluginFullNamePostfix = "-plugin.so";
-constexpr char const * const kPluginFullNameDefault = "libdali2-web-engine-plugin.so";
+constexpr char const* const kPluginFullNamePrefix = "libdali2-web-engine-";
+constexpr char const* const kPluginFullNamePostfix = "-plugin.so";
+constexpr char const* const kPluginFullNameDefault = "libdali2-web-engine-plugin.so";
// Note: Dali WebView policy does not allow to use multiple web engines in an application.
// So once pluginName is set to non-empty string, it will not change.
std::string pluginName;
-std::string MakePluginName( const char* environmentName )
+std::string MakePluginName(const char* environmentName)
{
std::stringstream fullName;
fullName << kPluginFullNamePrefix << environmentName << kPluginFullNamePostfix;
- return std::move( fullName.str() );
+ return std::move(fullName.str());
}
Dali::BaseHandle Create()
return Dali::WebEngine::New();
}
-Dali::TypeRegistration type( typeid( Dali::WebEngine ), typeid( Dali::BaseHandle ), Create );
+Dali::TypeRegistration type(typeid(Dali::WebEngine), typeid(Dali::BaseHandle), Create);
} // unnamed namespace
{
WebEngine* instance = new WebEngine();
- if( !instance->Initialize() )
+ if(!instance->Initialize())
{
delete instance;
return nullptr;
}
WebEngine::WebEngine()
-: mPlugin( NULL ),
- mHandle( NULL ),
- mCreateWebEnginePtr( NULL ),
- mDestroyWebEnginePtr( NULL )
+: mPlugin(NULL),
+ mHandle(NULL),
+ mCreateWebEnginePtr(NULL),
+ mDestroyWebEnginePtr(NULL)
{
}
WebEngine::~WebEngine()
{
- if( mHandle != NULL )
+ if(mHandle != NULL)
{
- if( mDestroyWebEnginePtr != NULL )
+ if(mDestroyWebEnginePtr != NULL)
{
mPlugin->Destroy();
- mDestroyWebEnginePtr( mPlugin );
+ mDestroyWebEnginePtr(mPlugin);
}
- dlclose( mHandle );
+ dlclose(mHandle);
}
}
bool WebEngine::InitializePluginHandle()
{
- if( pluginName.length() == 0 )
+ if(pluginName.length() == 0)
{
// pluginName is not initialized yet.
- const char* name = EnvironmentVariable::GetEnvironmentVariable( DALI_ENV_WEB_ENGINE_NAME );
- if( name )
+ const char* name = EnvironmentVariable::GetEnvironmentVariable(DALI_ENV_WEB_ENGINE_NAME);
+ if(name)
{
- pluginName = MakePluginName( name );
- mHandle = dlopen( pluginName.c_str(), RTLD_LAZY );
- if( mHandle )
+ pluginName = MakePluginName(name);
+ mHandle = dlopen(pluginName.c_str(), RTLD_LAZY);
+ if(mHandle)
{
return true;
}
}
- pluginName = std::string( kPluginFullNameDefault );
+ pluginName = std::string(kPluginFullNameDefault);
}
- mHandle = dlopen( pluginName.c_str(), RTLD_LAZY );
- if( !mHandle )
+ mHandle = dlopen(pluginName.c_str(), RTLD_LAZY);
+ if(!mHandle)
{
- DALI_LOG_ERROR( "Can't load %s : %s\n", pluginName.c_str(), dlerror() );
+ DALI_LOG_ERROR("Can't load %s : %s\n", pluginName.c_str(), dlerror());
return false;
}
{
char* error = NULL;
- if( !InitializePluginHandle() )
+ if(!InitializePluginHandle())
{
return false;
}
- mCreateWebEnginePtr = reinterpret_cast< CreateWebEngineFunction >( dlsym( mHandle, "CreateWebEnginePlugin" ) );
- if( mCreateWebEnginePtr == NULL )
+ mCreateWebEnginePtr = reinterpret_cast<CreateWebEngineFunction>(dlsym(mHandle, "CreateWebEnginePlugin"));
+ if(mCreateWebEnginePtr == NULL)
{
- DALI_LOG_ERROR( "Can't load symbol CreateWebEnginePlugin(), error: %s\n", error );
+ DALI_LOG_ERROR("Can't load symbol CreateWebEnginePlugin(), error: %s\n", error);
return false;
}
- mDestroyWebEnginePtr = reinterpret_cast< DestroyWebEngineFunction >( dlsym( mHandle, "DestroyWebEnginePlugin" ) );
+ mDestroyWebEnginePtr = reinterpret_cast<DestroyWebEngineFunction>(dlsym(mHandle, "DestroyWebEnginePlugin"));
- if( mDestroyWebEnginePtr == NULL )
+ if(mDestroyWebEnginePtr == NULL)
{
- DALI_LOG_ERROR( "Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error );
+ DALI_LOG_ERROR("Can't load symbol DestroyWebEnginePlugin(), error: %s\n", error);
return false;
}
mPlugin = mCreateWebEnginePtr();
- if( mPlugin == NULL )
+ if(mPlugin == NULL)
{
- DALI_LOG_ERROR( "Can't create the WebEnginePlugin object\n" );
+ DALI_LOG_ERROR("Can't create the WebEnginePlugin object\n");
return false;
}
return true;
}
-void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId )
+void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
{
- mPlugin->Create( width, height, locale, timezoneId );
+ mPlugin->Create(width, height, locale, timezoneId);
}
-void WebEngine::Create( int width, int height, int argc, char** argv )
+void WebEngine::Create(int width, int height, int argc, char** argv)
{
- mPlugin->Create( width, height, argc, argv );
+ mPlugin->Create(width, height, argc, argv);
}
void WebEngine::Destroy()
return mPlugin->GetBackForwardList();
}
-void WebEngine::LoadUrl( const std::string& url )
+void WebEngine::LoadUrl(const std::string& url)
{
- mPlugin->LoadUrl( url );
+ mPlugin->LoadUrl(url);
}
std::string WebEngine::GetTitle() const
return mPlugin->GetUserAgent();
}
-void WebEngine::SetUserAgent( const std::string& userAgent )
+void WebEngine::SetUserAgent(const std::string& userAgent)
{
- mPlugin->SetUserAgent( userAgent );
+ mPlugin->SetUserAgent(userAgent);
}
-void WebEngine::LoadHtmlString( const std::string& htmlString )
+void WebEngine::LoadHtmlString(const std::string& htmlString)
{
- mPlugin->LoadHtmlString( htmlString );
+ mPlugin->LoadHtmlString(htmlString);
}
void WebEngine::Reload()
mPlugin->Resume();
}
-void WebEngine::ScrollBy( int deltaX, int deltaY )
+void WebEngine::ScrollBy(int deltaX, int deltaY)
{
- mPlugin->ScrollBy( deltaX, deltaY );
+ mPlugin->ScrollBy(deltaX, deltaY);
}
-void WebEngine::SetScrollPosition( int x, int y )
+void WebEngine::SetScrollPosition(int x, int y)
{
- mPlugin->SetScrollPosition( x, y );
+ mPlugin->SetScrollPosition(x, y);
}
Dali::Vector2 WebEngine::GetScrollPosition() const
mPlugin->GoBack();
}
-void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler )
+void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
{
- mPlugin->EvaluateJavaScript( script, resultHandler );
+ mPlugin->EvaluateJavaScript(script, resultHandler);
}
-void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler )
+void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
{
- mPlugin->AddJavaScriptMessageHandler( exposedObjectName, handler );
+ mPlugin->AddJavaScriptMessageHandler(exposedObjectName, handler);
}
void WebEngine::ClearAllTilesResources()
mPlugin->ClearHistory();
}
-void WebEngine::SetSize( int width, int height )
+void WebEngine::SetSize(int width, int height)
{
- mPlugin->SetSize( width, height );
+ mPlugin->SetSize(width, height);
}
-bool WebEngine::SendTouchEvent( const Dali::TouchEvent& touch )
+bool WebEngine::SendTouchEvent(const Dali::TouchEvent& touch)
{
- return mPlugin->SendTouchEvent( touch );
+ return mPlugin->SendTouchEvent(touch);
}
-bool WebEngine::SendKeyEvent( const Dali::KeyEvent& event )
+bool WebEngine::SendKeyEvent(const Dali::KeyEvent& event)
{
- return mPlugin->SendKeyEvent( event );
+ return mPlugin->SendKeyEvent(event);
}
-void WebEngine::SetFocus( bool focused )
+void WebEngine::SetFocus(bool focused)
{
- mPlugin->SetFocus( focused );
+ mPlugin->SetFocus(focused);
}
-void WebEngine::UpdateDisplayArea( Dali::Rect< int > displayArea )
+void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
{
- mPlugin->UpdateDisplayArea( displayArea );
+ mPlugin->UpdateDisplayArea(displayArea);
}
-void WebEngine::EnableVideoHole( bool enabled )
+void WebEngine::EnableVideoHole(bool enabled)
{
- mPlugin->EnableVideoHole( enabled );
+ mPlugin->EnableVideoHole(enabled);
}
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
return mPlugin->ScrollEdgeReachedSignal();
}
-} // namespace Adaptor;
-} // namespace Internal;
-} // namespace Dali;
-
-
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * Copyright (c) 2019 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> DisplayConnectionFactoryAndroid::CreateDisplayConnection()
{
return Utils::MakeUnique<DisplayConnectionAndroid>();
return Utils::MakeUnique<DisplayConnectionFactoryAndroid>();
}
-}
+} // namespace Adaptor
-}
+} // namespace Internal
-}
+} // namespace Dali
/*
- * 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.
*/
// CLASS HEADER
-#include <dali/internal/window-system/android/display-connection-impl-android.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/window-system/android/display-connection-impl-android.h>
// EXTERNAL_HEADERS
#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
DisplayConnection* DisplayConnectionAndroid::New()
{
DisplayConnection* pDisplayConnection(new DisplayConnectionAndroid());
}
DisplayConnectionAndroid::DisplayConnectionAndroid()
-: mDisplay( NULL ),
- mSurfaceType( RenderSurfaceInterface::WINDOW_RENDER_SURFACE ),
- mGraphics( nullptr )
+: mDisplay(NULL),
+ mSurfaceType(RenderSurfaceInterface::WINDOW_RENDER_SURFACE),
+ mGraphics(nullptr)
{
}
Any DisplayConnectionAndroid::GetDisplay()
{
- return Any( mDisplay );
+ return Any(mDisplay);
}
void DisplayConnectionAndroid::ConsumeEvents()
bool DisplayConnectionAndroid::InitializeGraphics()
{
- auto eglGraphics = static_cast<EglGraphics*>( mGraphics );
- EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- if( !eglImpl.InitializeGles( mDisplay ) )
+ if(!eglImpl.InitializeGles(mDisplay))
{
- DALI_LOG_ERROR( "Failed to initialize GLES.\n" );
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");
return false;
}
return true;
}
-void DisplayConnectionAndroid::SetSurfaceType( Dali::RenderSurfaceInterface::Type type )
+void DisplayConnectionAndroid::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)
{
mSurfaceType = type;
- mDisplay = EGL_DEFAULT_DISPLAY;
+ mDisplay = EGL_DEFAULT_DISPLAY;
}
-void DisplayConnectionAndroid::SetGraphicsInterface( GraphicsInterface& graphics )
+void DisplayConnectionAndroid::SetGraphicsInterface(GraphicsInterface& graphics)
{
mGraphics = &graphics;
}
/*
- * 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.
#include <dali/internal/window-system/android/render-surface-factory-android.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/common/window-render-surface.h>
-#include <dali/internal/window-system/common/pixmap-render-surface.h>
-#include <dali/internal/window-system/common/display-utils.h>
#include <dali/integration-api/adaptor-framework/native-render-surface.h>
+#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/common/pixmap-render-surface.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
// EXTERNAL INCLUDES
#include <memory>
{
namespace Adaptor
{
-
-std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryAndroid::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowRenderSurface> RenderSurfaceFactoryAndroid::CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowRenderSurface>(positionSize, surface, isTransparent);
}
-std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryAndroid::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<PixmapRenderSurface> RenderSurfaceFactoryAndroid::CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return std::unique_ptr< PixmapRenderSurface >( nullptr );
+ return std::unique_ptr<PixmapRenderSurface>(nullptr);
}
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryAndroid::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+std::unique_ptr<NativeRenderSurface> RenderSurfaceFactoryAndroid::CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent)
{
- return std::unique_ptr< NativeRenderSurface >( nullptr );
+ return std::unique_ptr<NativeRenderSurface>(nullptr);
}
// this should be created from somewhere
-std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
{
// returns Window factory
- return Utils::MakeUnique< RenderSurfaceFactoryAndroid >();
+ return Utils::MakeUnique<RenderSurfaceFactoryAndroid>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2019 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.
#include <dali/internal/window-system/common/window-render-surface.h>
// EXTERNAL_HEADERS
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/events/mouse-button.h>
-#include <dali/integration-api/debug.h>
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/events/mouse-button.h>
+#include <dali/public-api/object/any.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
#endif
-WindowBaseAndroid::WindowBaseAndroid( Dali::PositionSize positionSize, Any surface, bool isTransparent )
-: mWindow( nullptr ),
- mOwnSurface( false ),
- mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
- mRotationAppSet( false )
+WindowBaseAndroid::WindowBaseAndroid(Dali::PositionSize positionSize, Any surface, bool isTransparent)
+: mWindow(nullptr),
+ mOwnSurface(false),
+ mIsTransparent(false), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
+ mRotationAppSet(false)
{
- Initialize( positionSize, surface, isTransparent );
+ Initialize(positionSize, surface, isTransparent);
}
WindowBaseAndroid::~WindowBaseAndroid() = default;
-void WindowBaseAndroid::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+void WindowBaseAndroid::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
{
- if( !surface.Empty() )
+ if(!surface.Empty())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Initialising using supplied Android native window\n" );
- mWindow = static_cast< ANativeWindow* >( AnyCast< void* >( surface ) );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Initialising using supplied Android native window\n");
+ mWindow = static_cast<ANativeWindow*>(AnyCast<void*>(surface));
}
else
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Initialising using default Android native window\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Initialising using default Android native window\n");
mWindow = Dali::Integration::AndroidFramework::Get().GetApplicationWindow();
}
- DALI_ASSERT_ALWAYS( mWindow && "Failed to get Android window" );
+ DALI_ASSERT_ALWAYS(mWindow && "Failed to get Android window");
mIsTransparent = true;
}
mDeleteRequestSignal.Emit();
}
-void WindowBaseAndroid::OnFocusIn( void* data, int type, void* event )
+void WindowBaseAndroid::OnFocusIn(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnFocusOut( void* data, int type, void* event )
+void WindowBaseAndroid::OnFocusOut(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnWindowDamaged( void* data, int type, void* event )
+void WindowBaseAndroid::OnWindowDamaged(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnMouseButtonDown( void* data, int type, void* event )
+void WindowBaseAndroid::OnMouseButtonDown(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnMouseButtonUp( void* data, int type, void* event )
+void WindowBaseAndroid::OnMouseButtonUp(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnMouseButtonMove( void* data, int type, void* event )
+void WindowBaseAndroid::OnMouseButtonMove(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnMouseWheel( void* data, int type, void* event )
+void WindowBaseAndroid::OnMouseWheel(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnKeyDown( void* data, int type, void* event )
+void WindowBaseAndroid::OnKeyDown(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnKeyUp( void* data, int type, void* event )
+void WindowBaseAndroid::OnKeyUp(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnSelectionClear( void* data, int type, void* event )
+void WindowBaseAndroid::OnSelectionClear(void* data, int type, void* event)
{
}
-void WindowBaseAndroid::OnSelectionNotify( void* data, int type, void* event )
+void WindowBaseAndroid::OnSelectionNotify(void* data, int type, void* event)
{
}
Any WindowBaseAndroid::GetNativeWindow()
{
- return static_cast< void* >( mWindow );
+ return static_cast<void*>(mWindow);
}
int WindowBaseAndroid::GetNativeWindowId()
return 0;
}
-EGLNativeWindowType WindowBaseAndroid::CreateEglWindow( int width, int height )
+EGLNativeWindowType WindowBaseAndroid::CreateEglWindow(int width, int height)
{
// from eglplatform.h header
// typedef struct ANativeWindow* EGLNativeWindowType;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Returns the window created for us.\n");
return mWindow;
}
void WindowBaseAndroid::DestroyEglWindow()
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Does nothing, the window is not owned by us.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Does nothing, the window is not owned by us.\n");
}
-void WindowBaseAndroid::SetEglWindowRotation( int angle )
+void WindowBaseAndroid::SetEglWindowRotation(int angle)
{
}
-void WindowBaseAndroid::SetEglWindowBufferTransform( int angle )
+void WindowBaseAndroid::SetEglWindowBufferTransform(int angle)
{
}
-void WindowBaseAndroid::SetEglWindowTransform( int angle )
+void WindowBaseAndroid::SetEglWindowTransform(int angle)
{
}
-void WindowBaseAndroid::ResizeEglWindow( PositionSize positionSize )
+void WindowBaseAndroid::ResizeEglWindow(PositionSize positionSize)
{
}
return false;
}
-void WindowBaseAndroid::Move( PositionSize positionSize )
+void WindowBaseAndroid::Move(PositionSize positionSize)
{
}
-void WindowBaseAndroid::Resize( PositionSize positionSize )
+void WindowBaseAndroid::Resize(PositionSize positionSize)
{
}
-void WindowBaseAndroid::MoveResize( PositionSize positionSize )
+void WindowBaseAndroid::MoveResize(PositionSize positionSize)
{
}
-void WindowBaseAndroid::SetClass( const std::string& name, const std::string& className )
+void WindowBaseAndroid::SetClass(const std::string& name, const std::string& className)
{
}
{
}
-void WindowBaseAndroid::SetAvailableAnlges( const std::vector< int >& angles )
+void WindowBaseAndroid::SetAvailableAnlges(const std::vector<int>& angles)
{
}
-void WindowBaseAndroid::SetPreferredAngle( int angle )
+void WindowBaseAndroid::SetPreferredAngle(int angle)
{
}
-void WindowBaseAndroid::SetAcceptFocus( bool accept )
+void WindowBaseAndroid::SetAcceptFocus(bool accept)
{
}
return 0;
}
-std::string WindowBaseAndroid::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string WindowBaseAndroid::GetSupportedAuxiliaryHint(unsigned int index) const
{
return std::string();
}
-unsigned int WindowBaseAndroid::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int WindowBaseAndroid::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
return 0;
}
-bool WindowBaseAndroid::RemoveAuxiliaryHint( unsigned int id )
+bool WindowBaseAndroid::RemoveAuxiliaryHint(unsigned int id)
{
return false;
}
-bool WindowBaseAndroid::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool WindowBaseAndroid::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
return false;
}
-std::string WindowBaseAndroid::GetAuxiliaryHintValue( unsigned int id ) const
+std::string WindowBaseAndroid::GetAuxiliaryHintValue(unsigned int id) const
{
return std::string();
}
-unsigned int WindowBaseAndroid::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int WindowBaseAndroid::GetAuxiliaryHintId(const std::string& hint) const
{
return 0;
}
-void WindowBaseAndroid::SetInputRegion( const Rect< int >& inputRegion )
+void WindowBaseAndroid::SetInputRegion(const Rect<int>& inputRegion)
{
}
-void WindowBaseAndroid::SetType( Dali::WindowType type )
+void WindowBaseAndroid::SetType(Dali::WindowType type)
{
}
-bool WindowBaseAndroid::SetNotificationLevel( Dali::WindowNotificationLevel level )
+bool WindowBaseAndroid::SetNotificationLevel(Dali::WindowNotificationLevel level)
{
return false;
}
return Dali::WindowNotificationLevel::NONE;
}
-void WindowBaseAndroid::SetOpaqueState( bool opaque )
+void WindowBaseAndroid::SetOpaqueState(bool opaque)
{
}
return WindowScreenOffMode::TIMEOUT;
}
-bool WindowBaseAndroid::SetBrightness( int brightness )
+bool WindowBaseAndroid::SetBrightness(int brightness)
{
return false;
}
return 0;
}
-bool WindowBaseAndroid::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+bool WindowBaseAndroid::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
{
return false;
}
-bool WindowBaseAndroid::UngrabKey( Dali::KEY key )
+bool WindowBaseAndroid::UngrabKey(Dali::KEY key)
{
return false;
}
-bool WindowBaseAndroid::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+bool WindowBaseAndroid::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
{
return false;
}
-bool WindowBaseAndroid::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+bool WindowBaseAndroid::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
{
return false;
}
-void WindowBaseAndroid::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void WindowBaseAndroid::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
AConfiguration* config = Dali::Integration::AndroidFramework::Get().GetApplicationConfiguration();
- int32_t density = AConfiguration_getDensity( config );
- if( density == ACONFIGURATION_DENSITY_ANY )
+ int32_t density = AConfiguration_getDensity(config);
+ if(density == ACONFIGURATION_DENSITY_ANY)
{
- DALI_LOG_ERROR( "Failed to get Android DPI, use 0 instead." );
+ DALI_LOG_ERROR("Failed to get Android DPI, use 0 instead.");
density = 0;
}
return 0;
}
-void WindowBaseAndroid::SetWindowRotationAngle( int degree )
+void WindowBaseAndroid::SetWindowRotationAngle(int degree)
{
}
-void WindowBaseAndroid::WindowRotationCompleted( int degree, int width, int height )
+void WindowBaseAndroid::WindowRotationCompleted(int degree, int width, int height)
{
}
-void WindowBaseAndroid::SetTransparency( bool transparent )
+void WindowBaseAndroid::SetTransparency(bool transparent)
{
}
-void WindowBaseAndroid::SetParent( WindowBase* parentWinBase )
+void WindowBaseAndroid::SetParent(WindowBase* parentWinBase)
{
}
} // namespace Internal
} // namespace Dali
-
/*
- * Copyright (c) 2018 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.
{
namespace Adaptor
{
-
-std::unique_ptr< WindowBase > WindowFactoryAndroid::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowBase> WindowFactoryAndroid::CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowBaseAndroid >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowBaseAndroid>(positionSize, surface, isTransparent);
}
// this should be created from Window impl
-std::unique_ptr< WindowFactory > GetWindowFactory()
+std::unique_ptr<WindowFactory> GetWindowFactory()
{
// returns Window factory
- return Utils::MakeUnique< WindowFactoryAndroid >();
+ return Utils::MakeUnique<WindowFactoryAndroid>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
#include <dali/internal/window-system/common/window-system.h>
// EXTERNAL_HEADERS
-#include <dali/integration-api/debug.h>
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace WindowSystem
{
-
void Initialize()
{
}
{
}
-void GetScreenSize( int& width, int& height )
+void GetScreenSize(int& width, int& height)
{
ANativeWindow* window = Dali::Integration::AndroidFramework::Get().GetApplicationWindow();
- width = ANativeWindow_getWidth( window );
- height = ANativeWindow_getHeight( window );
- DALI_LOG_WARNING( "Native window width %d, height %d", width, height );
+ width = ANativeWindow_getWidth(window);
+ height = ANativeWindow_getHeight(window);
+ DALI_LOG_WARNING("Native window width %d, height %d", width, height);
}
-bool SetKeyboardRepeatInfo( float rate, float delay )
+bool SetKeyboardRepeatInfo(float rate, float delay)
{
return false;
}
-bool GetKeyboardRepeatInfo( float& rate, float& delay )
+bool GetKeyboardRepeatInfo(float& rate, float& delay)
{
return false;
}
} // namespace Internal
} // namespace Dali
-
/*
- * 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.
*/
// CLASS HEADER
-#include <dali/internal/window-system/common/display-connection.h>
#include <dali/internal/window-system/common/display-connection-factory.h>
+#include <dali/internal/window-system/common/display-connection.h>
// INTERNAL INCLUDES
-#include <dali/internal/window-system/common/display-connection-impl.h>
#include <dali/internal/window-system/common/display-connection-factory.h>
-
+#include <dali/internal/window-system/common/display-connection-impl.h>
namespace Dali
{
-
-DisplayConnection* DisplayConnection::New( Dali::Internal::Adaptor::GraphicsInterface& graphics )
+DisplayConnection* DisplayConnection::New(Dali::Internal::Adaptor::GraphicsInterface& graphics)
{
- auto factory = Dali::Internal::Adaptor::GetDisplayConnectionFactory();
+ auto factory = Dali::Internal::Adaptor::GetDisplayConnectionFactory();
auto displayConnection = factory->CreateDisplayConnection();
- Internal::Adaptor::DisplayConnection* internal( displayConnection.release() );
- internal->SetGraphicsInterface( graphics );
+ Internal::Adaptor::DisplayConnection* internal(displayConnection.release());
+ internal->SetGraphicsInterface(graphics);
return new DisplayConnection(internal);
}
-DisplayConnection* DisplayConnection::New( Dali::Internal::Adaptor::GraphicsInterface& graphics, Dali::RenderSurfaceInterface::Type type )
+DisplayConnection* DisplayConnection::New(Dali::Internal::Adaptor::GraphicsInterface& graphics, Dali::RenderSurfaceInterface::Type type)
{
- auto factory = Dali::Internal::Adaptor::GetDisplayConnectionFactory();
+ auto factory = Dali::Internal::Adaptor::GetDisplayConnectionFactory();
auto displayConnection = factory->CreateDisplayConnection();
- Internal::Adaptor::DisplayConnection* internal( displayConnection.release() );
+ Internal::Adaptor::DisplayConnection* internal(displayConnection.release());
- internal->SetGraphicsInterface( graphics );
- internal->SetSurfaceType( type );
+ internal->SetGraphicsInterface(graphics);
+ internal->SetSurfaceType(type);
return new DisplayConnection(internal);
}
DisplayConnection::DisplayConnection(Internal::Adaptor::DisplayConnection* impl)
{
- mImpl.reset( impl );
+ mImpl.reset(impl);
}
Any DisplayConnection::GetDisplay()
return mImpl->InitializeGraphics();
}
-}
+} // namespace Dali
/*
- * 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.
#include <dali/internal/window-system/common/event-handler.h>
// EXTERNAL INCLUDES
-#include <cstring>
#include <sys/time.h>
+#include <cstring>
#include <dali/devel-api/events/touch-point.h>
-#include <dali/public-api/events/key-event.h>
-#include <dali/public-api/events/wheel-event.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/hover-event-integ.h>
#include <dali/integration-api/events/wheel-event-integ.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/wheel-event.h>
// INTERNAL INCLUDES
#include <dali/internal/clipboard/common/clipboard-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
#if defined(DEBUG_ENABLED)
namespace
{
} // unnamed namespace
#endif
-EventHandler::EventHandler( WindowBase* windowBase, DamageObserver& damageObserver )
-: mStyleMonitor( StyleMonitor::Get() ),
- mDamageObserver( damageObserver ),
- mClipboardEventNotifier( ClipboardEventNotifier::Get() ),
- mClipboard( Clipboard::Get() ),
- mPaused( false )
+EventHandler::EventHandler(WindowBase* windowBase, DamageObserver& damageObserver)
+: mStyleMonitor(StyleMonitor::Get()),
+ mDamageObserver(damageObserver),
+ mClipboardEventNotifier(ClipboardEventNotifier::Get()),
+ mClipboard(Clipboard::Get()),
+ mPaused(false)
{
// Connect signals
- if( windowBase )
+ if(windowBase)
{
- windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
- windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
- windowBase->RotationSignal().Connect( this, &EventHandler::OnRotation );
- windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent );
- windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent );
- windowBase->KeyEventSignal().Connect( this, &EventHandler::OnKeyEvent );
- windowBase->SelectionDataSendSignal().Connect( this, &EventHandler::OnSelectionDataSend );
- windowBase->SelectionDataReceivedSignal().Connect( this, &EventHandler::OnSelectionDataReceived );
- windowBase->StyleChangedSignal().Connect( this, &EventHandler::OnStyleChanged );
+ windowBase->WindowDamagedSignal().Connect(this, &EventHandler::OnWindowDamaged);
+ windowBase->FocusChangedSignal().Connect(this, &EventHandler::OnFocusChanged);
+ windowBase->RotationSignal().Connect(this, &EventHandler::OnRotation);
+ windowBase->TouchEventSignal().Connect(this, &EventHandler::OnTouchEvent);
+ windowBase->WheelEventSignal().Connect(this, &EventHandler::OnWheelEvent);
+ windowBase->KeyEventSignal().Connect(this, &EventHandler::OnKeyEvent);
+ windowBase->SelectionDataSendSignal().Connect(this, &EventHandler::OnSelectionDataSend);
+ windowBase->SelectionDataReceivedSignal().Connect(this, &EventHandler::OnSelectionDataReceived);
+ windowBase->StyleChangedSignal().Connect(this, &EventHandler::OnStyleChanged);
}
else
{
{
}
-void EventHandler::SendEvent( StyleChange::Type styleChange )
+void EventHandler::SendEvent(StyleChange::Type styleChange)
{
- DALI_ASSERT_DEBUG( mStyleMonitor && "StyleMonitor Not Available" );
- GetImplementation( mStyleMonitor ).StyleChanged(styleChange);
+ DALI_ASSERT_DEBUG(mStyleMonitor && "StyleMonitor Not Available");
+ GetImplementation(mStyleMonitor).StyleChanged(styleChange);
}
-void EventHandler::SendEvent( const DamageArea& area )
+void EventHandler::SendEvent(const DamageArea& area)
{
- mDamageObserver.OnDamaged( area );
+ mDamageObserver.OnDamaged(area);
}
void EventHandler::Pause()
mPaused = false;
}
-void EventHandler::OnTouchEvent( Integration::Point& point, uint32_t timeStamp )
+void EventHandler::OnTouchEvent(Integration::Point& point, uint32_t timeStamp)
{
- for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ for(ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter)
{
- (*iter)->OnTouchPoint( point, timeStamp );
+ (*iter)->OnTouchPoint(point, timeStamp);
}
}
-void EventHandler::OnWheelEvent( Integration::WheelEvent& wheelEvent )
+void EventHandler::OnWheelEvent(Integration::WheelEvent& wheelEvent)
{
- for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ for(ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter)
{
- (*iter)->OnWheelEvent( wheelEvent );
+ (*iter)->OnWheelEvent(wheelEvent);
}
}
-void EventHandler::OnKeyEvent( Integration::KeyEvent& keyEvent )
+void EventHandler::OnKeyEvent(Integration::KeyEvent& keyEvent)
{
- for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ for(ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter)
{
- (*iter)->OnKeyEvent( keyEvent );
+ (*iter)->OnKeyEvent(keyEvent);
}
}
-void EventHandler::OnFocusChanged( bool focusIn )
+void EventHandler::OnFocusChanged(bool focusIn)
{
// If the window gains focus and we hid the keyboard then show it again.
- if( focusIn )
+ if(focusIn)
{
Dali::Clipboard clipboard = Clipboard::Get();
- if ( clipboard )
+ if(clipboard)
{
clipboard.HideClipboard();
}
{
// Hiding clipboard event will be ignored once because window focus out event is always received on showing clipboard
Dali::Clipboard clipboard = Clipboard::Get();
- if ( clipboard )
+ if(clipboard)
{
- Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
+ Clipboard& clipBoardImpl(GetImplementation(clipboard));
clipBoardImpl.HideClipboard(true);
}
}
}
-void EventHandler::OnRotation( const RotationEvent& event )
+void EventHandler::OnRotation(const RotationEvent& event)
{
- for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
+ for(ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter)
{
- (*iter)->OnRotation( event );
+ (*iter)->OnRotation(event);
}
}
-void EventHandler::OnWindowDamaged( const DamageArea& area )
+void EventHandler::OnWindowDamaged(const DamageArea& area)
{
- SendEvent( area );
+ SendEvent(area);
}
-void EventHandler::OnSelectionDataSend( void* event )
+void EventHandler::OnSelectionDataSend(void* event)
{
Dali::Clipboard clipboard = Clipboard::Get();
- if( clipboard )
+ if(clipboard)
{
- Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
- clipBoardImpl.ExcuteBuffered( true, event );
+ Clipboard& clipBoardImpl(GetImplementation(clipboard));
+ clipBoardImpl.ExcuteBuffered(true, event);
}
}
-void EventHandler::OnSelectionDataReceived( void* event )
+void EventHandler::OnSelectionDataReceived(void* event)
{
// We have got the selected content, inform the clipboard event listener (if we have one).
- Dali::Clipboard clipboard = Clipboard::Get();
- char* selectionData = NULL;
- if( clipboard )
+ Dali::Clipboard clipboard = Clipboard::Get();
+ char* selectionData = NULL;
+ if(clipboard)
{
- Clipboard& clipBoardImpl( GetImplementation( clipboard ) );
- selectionData = clipBoardImpl.ExcuteBuffered( false, event );
+ Clipboard& clipBoardImpl(GetImplementation(clipboard));
+ selectionData = clipBoardImpl.ExcuteBuffered(false, event);
}
- if( selectionData && mClipboardEventNotifier )
+ if(selectionData && mClipboardEventNotifier)
{
- ClipboardEventNotifier& clipboardEventNotifier( ClipboardEventNotifier::GetImplementation( mClipboardEventNotifier ) );
- std::string content( selectionData, strlen( selectionData ) );
+ ClipboardEventNotifier& clipboardEventNotifier(ClipboardEventNotifier::GetImplementation(mClipboardEventNotifier));
+ std::string content(selectionData, strlen(selectionData));
- clipboardEventNotifier.SetContent( content );
+ clipboardEventNotifier.SetContent(content);
clipboardEventNotifier.EmitContentSelectedSignal();
- DALI_LOG_INFO( gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d): %s\n" , strlen(selectionData), selectionData );
+ DALI_LOG_INFO(gSelectionEventLogFilter, Debug::General, "EcoreEventSelectionNotify: Content(%d): %s\n", strlen(selectionData), selectionData);
}
}
-void EventHandler::OnStyleChanged( StyleChange::Type styleChange )
+void EventHandler::OnStyleChanged(StyleChange::Type styleChange)
{
- SendEvent( styleChange );
+ SendEvent(styleChange);
}
-void EventHandler::AddObserver( Observer& observer )
+void EventHandler::AddObserver(Observer& observer)
{
- ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
+ ObserverContainer::iterator match(find(mObservers.begin(), mObservers.end(), &observer));
- if ( match == mObservers.end() )
+ if(match == mObservers.end())
{
- mObservers.push_back( &observer );
+ mObservers.push_back(&observer);
}
}
-void EventHandler::RemoveObserver( Observer& observer )
+void EventHandler::RemoveObserver(Observer& observer)
{
- ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
+ ObserverContainer::iterator match(find(mObservers.begin(), mObservers.end(), &observer));
- if ( match != mObservers.end() )
+ if(match != mObservers.end())
{
- mObservers.erase( match );
+ mObservers.erase(match);
}
}
/*
- * 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.
namespace Dali
{
-
-DALI_ADAPTOR_API NativeRenderSurface* CreateNativeSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+DALI_ADAPTOR_API NativeRenderSurface* CreateNativeSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent)
{
auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
- auto nativeRenderSurface = renderSurfaceFactory->CreateNativeRenderSurface( surfaceSize, surface, isTransparent );
+ auto nativeRenderSurface = renderSurfaceFactory->CreateNativeRenderSurface(surfaceSize, surface, isTransparent);
return nativeRenderSurface.release();
}
/*
- * Copyright (c) 2019 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.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/window-system/common/window-impl.h>
namespace Dali
{
{
namespace Adaptor
{
-
Orientation* Orientation::New(Window* window)
{
Orientation* orientation = new Orientation(window);
return mChangedSignal;
}
-void Orientation::OnOrientationChange( const RotationEvent& rotation )
+void Orientation::OnOrientationChange(const RotationEvent& rotation)
{
mOrientation = rotation.angle;
mWindowWidth = rotation.width;
mWindowHeight = rotation.height;
// Emit signal
- if( !mChangedSignal.Empty() )
+ if(!mChangedSignal.Empty())
{
- Dali::Orientation handle( this );
- mChangedSignal.Emit( handle );
+ Dali::Orientation handle(this);
+ mChangedSignal.Emit(handle);
}
}
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
WindowBase::WindowBase()
: mIconifyChangedSignal(),
mFocusChangedSignal(),
/*
- * 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.
#include <dali/internal/window-system/common/window-impl.h>
// EXTERNAL HEADERS
-#include <thread>
+#include <dali/devel-api/adaptor-framework/orientation.h>
#include <dali/integration-api/core.h>
+#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/actors/layer.h>
#include <dali/public-api/actors/camera-actor.h>
-#include <dali/public-api/render-tasks/render-task.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/rendering/frame-buffer.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
-#include <dali/devel-api/adaptor-framework/orientation.h>
-#include <dali/integration-api/events/touch-event-integ.h>
+#include <thread>
// INTERNAL HEADERS
+#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/window-system/common/event-handler.h>
#include <dali/internal/window-system/common/orientation-impl.h>
#include <dali/internal/window-system/common/render-surface-factory.h>
-#include <dali/internal/window-system/common/window-factory.h>
#include <dali/internal/window-system/common/window-base.h>
-#include <dali/internal/window-system/common/window-system.h>
+#include <dali/internal/window-system/common/window-factory.h>
#include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/common/window-visibility-observer.h>
-#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
namespace Dali
{
{
namespace Adaptor
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW" );
+Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW");
#endif
} // unnamed namespace
Window* Window::New(Any surface, const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
{
- Window* window = new Window();
+ Window* window = new Window();
window->mIsTransparent = isTransparent;
window->Initialize(surface, positionSize, name, className);
return window;
Window::Window()
: mWindowSurface(nullptr),
mWindowBase(),
- mIsTransparent( false ),
- mIsFocusAcceptable( true ),
- mIconified( false ),
- mOpaqueState( false ),
- mResizeEnabled( false ),
- mType( WindowType::NORMAL ),
- mParentWindow( NULL ),
- mPreferredAngle( static_cast< int >( WindowOrientation::NO_ORIENTATION_PREFERENCE ) ),
- mRotationAngle( 0 ),
- mWindowWidth( 0 ),
- mWindowHeight( 0 ),
- mOrientationMode( Internal::Adaptor::Window::OrientationMode::PORTRAIT ),
- mNativeWindowId( -1 ),
+ mIsTransparent(false),
+ mIsFocusAcceptable(true),
+ mIconified(false),
+ mOpaqueState(false),
+ mResizeEnabled(false),
+ mType(WindowType::NORMAL),
+ mParentWindow(NULL),
+ mPreferredAngle(static_cast<int>(WindowOrientation::NO_ORIENTATION_PREFERENCE)),
+ mRotationAngle(0),
+ mWindowWidth(0),
+ mWindowHeight(0),
+ mOrientationMode(Internal::Adaptor::Window::OrientationMode::PORTRAIT),
+ mNativeWindowId(-1),
mDeleteRequestSignal(),
mFocusChangeSignal(),
mResizeSignal(),
Window::~Window()
{
- if ( mAdaptor )
+ if(mAdaptor)
{
- auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
auto accessible2 = mScene.GetRootLayer();
- auto accessible = Accessibility::Accessible::Get( accessible2 );
- bridge->RemoveTopLevelWindow( accessible );
+ auto accessible = Accessibility::Accessible::Get(accessible2);
+ bridge->RemoveTopLevelWindow(accessible);
- mAdaptor->RemoveWindow( this );
+ mAdaptor->RemoveWindow(this);
}
- if ( mEventHandler )
+ if(mEventHandler)
{
- mEventHandler->RemoveObserver( *this );
+ mEventHandler->RemoveObserver(*this);
}
}
{
// Create a window render surface
auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
- mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
- mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
+ mSurface = renderSurfaceFactory->CreateWindowRenderSurface(positionSize, surface, mIsTransparent);
+ mWindowSurface = static_cast<WindowRenderSurface*>(mSurface.get());
// Get a window base
mWindowBase = mWindowSurface->GetWindowBase();
// Connect signals
- mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
- mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
- mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
- mWindowBase->TransitionEffectEventSignal().Connect( this, &Window::OnTransitionEffectEvent );
- mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect( this, &Window::OnKeyboardRepeatSettingsChanged );
- mWindowBase->WindowRedrawRequestSignal().Connect( this, &Window::OnWindowRedrawRequest );
+ mWindowBase->IconifyChangedSignal().Connect(this, &Window::OnIconifyChanged);
+ mWindowBase->FocusChangedSignal().Connect(this, &Window::OnFocusChanged);
+ mWindowBase->DeleteRequestSignal().Connect(this, &Window::OnDeleteRequest);
+ mWindowBase->TransitionEffectEventSignal().Connect(this, &Window::OnTransitionEffectEvent);
+ mWindowBase->KeyboardRepeatSettingsChangedSignal().Connect(this, &Window::OnKeyboardRepeatSettingsChanged);
+ mWindowBase->WindowRedrawRequestSignal().Connect(this, &Window::OnWindowRedrawRequest);
- mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
+ mWindowSurface->OutputTransformedSignal().Connect(this, &Window::OnOutputTransformed);
- if( !positionSize.IsEmpty() )
+ if(!positionSize.IsEmpty())
{
- AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
mResizeEnabled = true;
}
- SetClass( name, className );
+ SetClass(name, className);
mWindowSurface->Map();
- mOrientation = Orientation::New( this );
+ mOrientation = Orientation::New(this);
// Get OrientationMode
int screenWidth, screenHeight;
- WindowSystem::GetScreenSize( screenWidth, screenHeight );
- if( screenWidth > screenHeight )
+ WindowSystem::GetScreenSize(screenWidth, screenHeight);
+ if(screenWidth > screenHeight)
{
mOrientationMode = Internal::Adaptor::Window::OrientationMode::LANDSCAPE;
}
void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
{
- mEventHandler = EventHandlerPtr(new EventHandler( mWindowSurface->GetWindowBase(), *mAdaptor ) );
- mEventHandler->AddObserver( *this );
+ mEventHandler = EventHandlerPtr(new EventHandler(mWindowSurface->GetWindowBase(), *mAdaptor));
+ mEventHandler->AddObserver(*this);
- auto bridge = Accessibility::Bridge::GetCurrentBridge();
- auto v = mScene.GetRootLayer();
- auto accessible = Accessibility::Accessible::Get( v, true );
- bridge->AddTopLevelWindow( accessible );
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ auto v = mScene.GetRootLayer();
+ auto accessible = Accessibility::Accessible::Get(v, true);
+ bridge->AddTopLevelWindow(accessible);
//FIXME: line below is temporary solution for missing "activate" signal and should be removed
Show();
}
-void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
+void Window::OnSurfaceSet(Dali::RenderSurfaceInterface* surface)
{
- mWindowSurface = static_cast<WindowRenderSurface*>( surface );
+ mWindowSurface = static_cast<WindowRenderSurface*>(surface);
}
-void Window::SetClass( std::string name, std::string className )
+void Window::SetClass(std::string name, std::string className)
{
- mName = name;
+ mName = name;
mClassName = className;
- mWindowBase->SetClass( name, className );
+ mWindowBase->SetClass(name, className);
}
std::string Window::GetClassName() const
mSurface->SetFullSwapNextFrame();
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Raise() \n", this, mNativeWindowId);
}
void Window::Lower()
mSurface->SetFullSwapNextFrame();
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Lower() \n", this, mNativeWindowId);
}
void Window::Activate()
mSurface->SetFullSwapNextFrame();
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
}
uint32_t Window::GetLayerCount() const
return mScene.GetLayerCount();
}
-Dali::Layer Window::GetLayer( uint32_t depth ) const
+Dali::Layer Window::GetLayer(uint32_t depth) const
{
- return mScene.GetLayer( depth );
+ return mScene.GetLayer(depth);
}
Dali::RenderTaskList Window::GetRenderTaskList() const
return mScene.GetRenderTaskList();
}
-void Window::AddAvailableOrientation( WindowOrientation orientation )
+void Window::AddAvailableOrientation(WindowOrientation orientation)
{
- if( IsOrientationAvailable( orientation ) == false )
+ if(IsOrientationAvailable(orientation) == false)
{
return;
}
- bool found = false;
- int convertedAngle = ConvertToAngle( orientation );
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
- for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
+ bool found = false;
+ int convertedAngle = ConvertToAngle(orientation);
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), AddAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
+ for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
{
- if( mAvailableAngles[i] == convertedAngle )
+ if(mAvailableAngles[i] == convertedAngle)
{
found = true;
break;
}
}
- if( !found )
+ if(!found)
{
- mAvailableAngles.push_back( convertedAngle );
- SetAvailableAnlges( mAvailableAngles );
+ mAvailableAngles.push_back(convertedAngle);
+ SetAvailableAnlges(mAvailableAngles);
}
}
-void Window::RemoveAvailableOrientation( WindowOrientation orientation )
+void Window::RemoveAvailableOrientation(WindowOrientation orientation)
{
- if( IsOrientationAvailable( orientation ) == false )
+ if(IsOrientationAvailable(orientation) == false)
{
return;
}
- int convertedAngle = ConvertToAngle( orientation );
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle );
- for( std::vector< int >::iterator iter = mAvailableAngles.begin();
- iter != mAvailableAngles.end(); ++iter )
+ int convertedAngle = ConvertToAngle(orientation);
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), RemoveAvailableOrientation: %d\n", this, mNativeWindowId, convertedAngle);
+ for(std::vector<int>::iterator iter = mAvailableAngles.begin();
+ iter != mAvailableAngles.end();
+ ++iter)
{
- if( *iter == convertedAngle )
+ if(*iter == convertedAngle)
{
- mAvailableAngles.erase( iter );
+ mAvailableAngles.erase(iter);
break;
}
}
- SetAvailableAnlges( mAvailableAngles );
+ SetAvailableAnlges(mAvailableAngles);
}
-void Window::SetPreferredOrientation( WindowOrientation orientation )
+void Window::SetPreferredOrientation(WindowOrientation orientation)
{
- if( orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE )
+ if(orientation < WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
{
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::CheckOrientation: Invalid input orientation [%d]\n", orientation);
return;
}
- mPreferredAngle = ConvertToAngle( orientation );
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
- mWindowBase->SetPreferredAngle( mPreferredAngle );
+ mPreferredAngle = ConvertToAngle(orientation);
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
+ mWindowBase->SetPreferredAngle(mPreferredAngle);
}
WindowOrientation Window::GetPreferredOrientation()
{
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle );
- WindowOrientation preferredOrientation = ConvertToOrientation( mPreferredAngle );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetPreferredOrientation: %d\n", this, mNativeWindowId, mPreferredAngle);
+ WindowOrientation preferredOrientation = ConvertToOrientation(mPreferredAngle);
return preferredOrientation;
}
-void Window::SetAvailableAnlges( const std::vector< int >& angles )
+void Window::SetAvailableAnlges(const std::vector<int>& angles)
{
- if( angles.size() > 4 )
+ if(angles.size() > 4)
{
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size() );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetAvailableAnlges: Invalid vector size! [%d]\n", angles.size());
return;
}
- mWindowBase->SetAvailableAnlges( angles );
+ mWindowBase->SetAvailableAnlges(angles);
}
-int Window::ConvertToAngle( WindowOrientation orientation )
+int Window::ConvertToAngle(WindowOrientation orientation)
{
- int convertAngle = static_cast< int >( orientation );
- if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
+ int convertAngle = static_cast<int>(orientation);
+ if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
{
- switch( orientation )
+ switch(orientation)
{
case WindowOrientation::LANDSCAPE:
{
return convertAngle;
}
-WindowOrientation Window::ConvertToOrientation( int angle ) const
+WindowOrientation Window::ConvertToOrientation(int angle) const
{
- WindowOrientation orientation = static_cast< WindowOrientation >( angle );
- if( mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE )
+ WindowOrientation orientation = static_cast<WindowOrientation>(angle);
+ if(mOrientationMode == Internal::Adaptor::Window::OrientationMode::LANDSCAPE)
{
- switch( angle )
+ switch(angle)
{
case 0:
{
return orientation;
}
-bool Window::IsOrientationAvailable( WindowOrientation orientation ) const
+bool Window::IsOrientationAvailable(WindowOrientation orientation) const
{
- if( orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE )
+ if(orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE || orientation > WindowOrientation::LANDSCAPE_INVERSE)
{
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation);
return false;
}
return true;
return mWindowSurface->GetNativeWindow();
}
-void Window::SetAcceptFocus( bool accept )
+void Window::SetAcceptFocus(bool accept)
{
mIsFocusAcceptable = accept;
- mWindowBase->SetAcceptFocus( accept );
+ mWindowBase->SetAcceptFocus(accept);
}
bool Window::IsFocusAcceptable() const
mWindowBase->Show();
- if( !mIconified )
+ if(!mIconified)
{
- WindowVisibilityObserver* observer( mAdaptor );
+ WindowVisibilityObserver* observer(mAdaptor);
observer->OnWindowShown();
- Dali::Window handle( this );
- mVisibilityChangedSignal.Emit( handle, true );
+ Dali::Window handle(this);
+ mVisibilityChangedSignal.Emit(handle, true);
}
mSurface->SetFullSwapNextFrame();
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
}
void Window::Hide()
mWindowBase->Hide();
- if( !mIconified )
+ if(!mIconified)
{
- WindowVisibilityObserver* observer( mAdaptor );
+ WindowVisibilityObserver* observer(mAdaptor);
observer->OnWindowHidden();
- Dali::Window handle( this );
- mVisibilityChangedSignal.Emit( handle, false );
+ Dali::Window handle(this);
+ mVisibilityChangedSignal.Emit(handle, false);
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
}
bool Window::IsVisible() const
{
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), IsVisible(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
return mVisible && !mIconified;
}
return mWindowBase->GetSupportedAuxiliaryHintCount();
}
-std::string Window::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string Window::GetSupportedAuxiliaryHint(unsigned int index) const
{
- return mWindowBase->GetSupportedAuxiliaryHint( index );
+ return mWindowBase->GetSupportedAuxiliaryHint(index);
}
-unsigned int Window::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int Window::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
- return mWindowBase->AddAuxiliaryHint( hint, value );
+ return mWindowBase->AddAuxiliaryHint(hint, value);
}
-bool Window::RemoveAuxiliaryHint( unsigned int id )
+bool Window::RemoveAuxiliaryHint(unsigned int id)
{
- return mWindowBase->RemoveAuxiliaryHint( id );
+ return mWindowBase->RemoveAuxiliaryHint(id);
}
-bool Window::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool Window::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
- return mWindowBase->SetAuxiliaryHintValue( id, value );
+ return mWindowBase->SetAuxiliaryHintValue(id, value);
}
-std::string Window::GetAuxiliaryHintValue( unsigned int id ) const
+std::string Window::GetAuxiliaryHintValue(unsigned int id) const
{
- return mWindowBase->GetAuxiliaryHintValue( id );
+ return mWindowBase->GetAuxiliaryHintValue(id);
}
-unsigned int Window::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int Window::GetAuxiliaryHintId(const std::string& hint) const
{
- return mWindowBase->GetAuxiliaryHintId( hint );
+ return mWindowBase->GetAuxiliaryHintId(hint);
}
-void Window::SetInputRegion( const Rect< int >& inputRegion )
+void Window::SetInputRegion(const Rect<int>& inputRegion)
{
- mWindowBase->SetInputRegion( inputRegion );
+ mWindowBase->SetInputRegion(inputRegion);
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
}
-void Window::SetType( WindowType type )
+void Window::SetType(WindowType type)
{
- if( type != mType )
+ if(type != mType)
{
- mWindowBase->SetType( type );
+ mWindowBase->SetType(type);
mType = type;
}
return mType;
}
-bool Window::SetNotificationLevel( WindowNotificationLevel level )
+bool Window::SetNotificationLevel(WindowNotificationLevel level)
{
- if( mType != WindowType::NOTIFICATION )
+ if(mType != WindowType::NOTIFICATION)
{
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetNotificationLevel: Not supported window type [%d]\n", mType);
return false;
}
- return mWindowBase->SetNotificationLevel( level );
+ return mWindowBase->SetNotificationLevel(level);
}
WindowNotificationLevel Window::GetNotificationLevel() const
{
- if( mType != WindowType::NOTIFICATION )
+ if(mType != WindowType::NOTIFICATION)
{
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::GetNotificationLevel: Not supported window type [%d]\n", mType);
return WindowNotificationLevel::NONE;
}
return mWindowBase->GetNotificationLevel();
}
-void Window::SetOpaqueState( bool opaque )
+void Window::SetOpaqueState(bool opaque)
{
mOpaqueState = opaque;
- mWindowBase->SetOpaqueState( opaque );
+ mWindowBase->SetOpaqueState(opaque);
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetOpaqueState: opaque = %d\n", opaque);
}
bool Window::IsOpaqueState() const
bool Window::SetScreenOffMode(WindowScreenOffMode screenOffMode)
{
- return mWindowBase->SetScreenOffMode( screenOffMode );
+ return mWindowBase->SetScreenOffMode(screenOffMode);
}
WindowScreenOffMode Window::GetScreenOffMode() const
return mWindowBase->GetScreenOffMode();
}
-bool Window::SetBrightness( int brightness )
+bool Window::SetBrightness(int brightness)
{
- if( brightness < 0 || brightness > 100 )
+ if(brightness < 0 || brightness > 100)
{
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "Window::SetBrightness: Invalid brightness value [%d]\n", brightness);
return false;
}
- return mWindowBase->SetBrightness( brightness );
+ return mWindowBase->SetBrightness(brightness);
}
int Window::GetBrightness() const
return mWindowBase->GetBrightness();
}
-void Window::SetSize( Dali::Window::WindowSize size )
+void Window::SetSize(Dali::Window::WindowSize size)
{
- if( !mResizeEnabled )
+ if(!mResizeEnabled)
{
- AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
mResizeEnabled = true;
}
PositionSize oldRect = mSurface->GetPositionSize();
- mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
+ mWindowSurface->MoveResize(PositionSize(oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight()));
PositionSize newRect = mSurface->GetPositionSize();
// When surface size is updated, inform adaptor of resizing and emit ResizeSignal
- if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
+ if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
{
- Uint16Pair newSize( newRect.width, newRect.height );
+ Uint16Pair newSize(newRect.width, newRect.height);
SurfaceResized();
- mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
+ mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetSize(): resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
- Dali::Window handle( this );
- mResizeSignal.Emit( handle, newSize );
+ Dali::Window handle(this);
+ mResizeSignal.Emit(handle, newSize);
- mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
+ mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
}
mSurface->SetFullSwapNextFrame();
{
PositionSize positionSize = mSurface->GetPositionSize();
- return Dali::Window::WindowSize( positionSize.width, positionSize.height );
+ return Dali::Window::WindowSize(positionSize.width, positionSize.height);
}
-void Window::SetPosition( Dali::Window::WindowPosition position )
+void Window::SetPosition(Dali::Window::WindowPosition position)
{
- if( !mResizeEnabled )
+ if(!mResizeEnabled)
{
- AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
mResizeEnabled = true;
}
PositionSize oldRect = mSurface->GetPositionSize();
- mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
+ mWindowSurface->MoveResize(PositionSize(position.GetX(), position.GetY(), oldRect.width, oldRect.height));
mSurface->SetFullSwapNextFrame();
}
{
PositionSize positionSize = mSurface->GetPositionSize();
- return Dali::Window::WindowPosition( positionSize.x, positionSize.y );
+ return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
}
-void Window::SetPositionSize( PositionSize positionSize )
+void Window::SetPositionSize(PositionSize positionSize)
{
- if( !mResizeEnabled )
+ if(!mResizeEnabled)
{
- AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
mResizeEnabled = true;
}
PositionSize oldRect = mSurface->GetPositionSize();
- mWindowSurface->MoveResize( positionSize );
+ mWindowSurface->MoveResize(positionSize);
PositionSize newRect = mSurface->GetPositionSize();
// When surface size is updated, inform adaptor of resizing and emit ResizeSignal
- if( ( oldRect.width != newRect.width ) || ( oldRect.height != newRect.height ) )
+ if((oldRect.width != newRect.width) || (oldRect.height != newRect.height))
{
- Uint16Pair newSize( newRect.width, newRect.height );
+ Uint16Pair newSize(newRect.width, newRect.height);
SurfaceResized();
- mAdaptor->SurfaceResizePrepare( mSurface.get(), newSize );
+ mAdaptor->SurfaceResizePrepare(mSurface.get(), newSize);
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height );
- Dali::Window handle( this );
- mResizeSignal.Emit( handle, newSize );
- mAdaptor->SurfaceResizeComplete( mSurface.get(), newSize );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetPositionSize():resize signal [%d x %d]\n", this, mNativeWindowId, newRect.width, newRect.height);
+ Dali::Window handle(this);
+ mResizeSignal.Emit(handle, newSize);
+ mAdaptor->SurfaceResizeComplete(mSurface.get(), newSize);
}
mSurface->SetFullSwapNextFrame();
return mScene.GetRootLayer();
}
-void Window::SetTransparency( bool transparent )
+void Window::SetTransparency(bool transparent)
{
- mWindowSurface->SetTransparency( transparent );
+ mWindowSurface->SetTransparency(transparent);
}
-bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+bool Window::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
{
- return mWindowBase->GrabKey( key, grabMode );
+ return mWindowBase->GrabKey(key, grabMode);
}
-bool Window::UngrabKey( Dali::KEY key )
+bool Window::UngrabKey(Dali::KEY key)
{
- return mWindowBase->UngrabKey( key );
+ return mWindowBase->UngrabKey(key);
}
-bool Window::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+bool Window::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
{
- return mWindowBase->GrabKeyList( key, grabMode, result );
+ return mWindowBase->GrabKeyList(key, grabMode, result);
}
-bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+bool Window::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
{
- return mWindowBase->UngrabKeyList( key, result );
+ return mWindowBase->UngrabKeyList(key, result);
}
-void Window::OnIconifyChanged( bool iconified )
+void Window::OnIconifyChanged(bool iconified)
{
- if( iconified )
+ if(iconified)
{
mIconified = true;
- if( mVisible )
+ if(mVisible)
{
- WindowVisibilityObserver* observer( mAdaptor );
+ WindowVisibilityObserver* observer(mAdaptor);
observer->OnWindowHidden();
- Dali::Window handle( this );
- mVisibilityChangedSignal.Emit( handle, false );
+ Dali::Window handle(this);
+ mVisibilityChangedSignal.Emit(handle, false);
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
}
else
{
mIconified = false;
- if( mVisible )
+ if(mVisible)
{
- WindowVisibilityObserver* observer( mAdaptor );
+ WindowVisibilityObserver* observer(mAdaptor);
observer->OnWindowShown();
- Dali::Window handle( this );
- mVisibilityChangedSignal.Emit( handle, true );
+ Dali::Window handle(this);
+ mVisibilityChangedSignal.Emit(handle, true);
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
}
mSurface->SetFullSwapNextFrame();
}
-void Window::OnFocusChanged( bool focusIn )
+void Window::OnFocusChanged(bool focusIn)
{
- Dali::Window handle( this );
- mFocusChangeSignal.Emit( handle, focusIn );
+ Dali::Window handle(this);
+ mFocusChangeSignal.Emit(handle, focusIn);
mSurface->SetFullSwapNextFrame();
- if (auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
+ if(auto b = Dali::Accessibility::Bridge::GetCurrentBridge())
{
- if (focusIn)
+ if(focusIn)
{
b->ApplicationShown();
}
mDeleteRequestSignal.Emit();
}
-void Window::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
+void Window::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
{
- Dali::Window handle( this );
- mTransitionEffectEventSignal.Emit( handle, state, type );
+ Dali::Window handle(this);
+ mTransitionEffectEventSignal.Emit(handle, state, type);
}
void Window::OnKeyboardRepeatSettingsChanged()
{
- Dali::Window handle( this );
+ Dali::Window handle(this);
mKeyboardRepeatSettingsChangedSignal.Emit();
}
mAdaptor->RenderOnce();
}
-void Window::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
+void Window::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
{
- FeedTouchPoint( point, timeStamp );
+ FeedTouchPoint(point, timeStamp);
}
-void Window::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
+void Window::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
{
- FeedWheelEvent( wheelEvent );
+ FeedWheelEvent(wheelEvent);
}
-void Window::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
+void Window::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
{
- FeedKeyEvent( keyEvent );
+ FeedKeyEvent(keyEvent);
}
void Window::OnRotation(const RotationEvent& rotation)
void Window::OnPause()
{
- if( mEventHandler )
+ if(mEventHandler)
{
mEventHandler->Pause();
}
void Window::OnResume()
{
- if( mEventHandler )
+ if(mEventHandler)
{
mEventHandler->Resume();
}
mSurface->SetFullSwapNextFrame();
}
-void Window::RecalculateTouchPosition( Integration::Point& point )
+void Window::RecalculateTouchPosition(Integration::Point& point)
{
Vector2 position = point.GetScreenPosition();
Vector2 convertedPosition;
- switch( mRotationAngle )
+ switch(mRotationAngle)
{
case 90:
{
- convertedPosition.x = static_cast<float>( mWindowWidth ) - position.y;
+ convertedPosition.x = static_cast<float>(mWindowWidth) - position.y;
convertedPosition.y = position.x;
break;
}
case 180:
{
- convertedPosition.x = static_cast<float>( mWindowWidth ) - position.x;
- convertedPosition.y = static_cast<float>( mWindowHeight ) - position.y;
+ convertedPosition.x = static_cast<float>(mWindowWidth) - position.x;
+ convertedPosition.y = static_cast<float>(mWindowHeight) - position.y;
break;
}
case 270:
{
convertedPosition.x = position.y;
- convertedPosition.y = static_cast<float>( mWindowHeight ) - position.x;
+ convertedPosition.y = static_cast<float>(mWindowHeight) - position.x;
break;
}
default:
}
}
- point.SetScreenPosition( convertedPosition );
+ point.SetScreenPosition(convertedPosition);
}
-Dali::Window Window::Get( Dali::Actor actor )
+Dali::Window Window::Get(Dali::Actor actor)
{
Internal::Adaptor::Window* windowImpl = nullptr;
- if ( Internal::Adaptor::Adaptor::IsAvailable() )
+ if(Internal::Adaptor::Adaptor::IsAvailable())
{
- Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
- windowImpl = dynamic_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
- if( windowImpl )
+ Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation(Internal::Adaptor::Adaptor::Get());
+ windowImpl = dynamic_cast<Internal::Adaptor::Window*>(adaptor.GetWindow(actor));
+ if(windowImpl)
{
- return Dali::Window( windowImpl );
+ return Dali::Window(windowImpl);
}
}
return Dali::Window();
}
-void Window::SetParent( Dali::Window& parent )
+void Window::SetParent(Dali::Window& parent)
{
- if ( DALI_UNLIKELY( parent ) )
+ if(DALI_UNLIKELY(parent))
{
- mParentWindow = parent;
- Dali::Window self = Dali::Window( this );
+ mParentWindow = parent;
+ Dali::Window self = Dali::Window(this);
// check circular parent window setting
- if ( Dali::DevelWindow::GetParent( parent ) == self )
+ if(Dali::DevelWindow::GetParent(parent) == self)
{
- Dali::DevelWindow::Unparent( parent );
+ Dali::DevelWindow::Unparent(parent);
}
- mWindowBase->SetParent( GetImplementation( mParentWindow ).mWindowBase );
+ mWindowBase->SetParent(GetImplementation(mParentWindow).mWindowBase);
}
}
void Window::Unparent()
{
- mWindowBase->SetParent( nullptr );
+ mWindowBase->SetParent(nullptr);
mParentWindow.Reset();
}
WindowOrientation Window::GetCurrentOrientation() const
{
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle );
- return ConvertToOrientation( mRotationAngle );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mRotationAngle);
+ return ConvertToOrientation(mRotationAngle);
}
-void Window::SetAvailableOrientations( const Dali::Vector<WindowOrientation>& orientations )
+void Window::SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations)
{
Dali::Vector<float>::SizeType count = orientations.Count();
- for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
+ for(Dali::Vector<float>::SizeType index = 0; index < count; ++index)
{
- if( IsOrientationAvailable( orientations[index] ) == false )
+ if(IsOrientationAvailable(orientations[index]) == false)
{
DALI_LOG_ERROR("Window::SetAvailableOrientations, invalid orientation: %d\n", orientations[index]);
continue;
}
- bool found = false;
- int convertedAngle = ConvertToAngle( orientations[index] );
+ bool found = false;
+ int convertedAngle = ConvertToAngle(orientations[index]);
- for( std::size_t i = 0; i < mAvailableAngles.size(); i++ )
+ for(std::size_t i = 0; i < mAvailableAngles.size(); i++)
{
- if( mAvailableAngles[i] == convertedAngle )
+ if(mAvailableAngles[i] == convertedAngle)
{
found = true;
break;
}
}
- if( !found )
+ if(!found)
{
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle );
- mAvailableAngles.push_back( convertedAngle );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, convertedAngle);
+ mAvailableAngles.push_back(convertedAngle);
}
}
- SetAvailableAnlges( mAvailableAngles );
+ SetAvailableAnlges(mAvailableAngles);
}
int32_t Window::GetNativeId() const
return mWindowBase->GetNativeWindowId();
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
/*
- * 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.
#include <dali/internal/window-system/common/window-render-surface.h>
// EXTERNAL INCLUDES
-#include <dali/integration-api/gl-abstraction.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/gl-abstraction.h>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
#include <dali/internal/adaptor/common/adaptor-internal-services.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/internal/system/common/environment-variables.h>
#include <dali/internal/window-system/common/window-base.h>
#include <dali/internal/window-system/common/window-factory.h>
#include <dali/internal/window-system/common/window-system.h>
-#include <dali/internal/system/common/environment-variables.h>
namespace Dali
{
{
namespace Adaptor
{
-
namespace
{
-
-const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved
-const float FULL_UPDATE_RATIO( 0.8f ); ///< Force full update when the dirty area is larget than this ratio
+const int MINIMUM_DIMENSION_CHANGE(1); ///< Minimum change for window to be considered to have moved
+const float FULL_UPDATE_RATIO(0.8f); ///< Force full update when the dirty area is larget than this ratio
#if defined(DEBUG_ENABLED)
Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_WINDOW_RENDER_SURFACE");
#endif
-void MergeRects( Rect< int >& mergingRect, const std::vector< Rect< int > >& rects )
+void MergeRects(Rect<int>& mergingRect, const std::vector<Rect<int>>& rects)
{
uint32_t i = 0;
- if( mergingRect.IsEmpty() )
+ if(mergingRect.IsEmpty())
{
- for( ; i < rects.size(); i++ )
+ for(; i < rects.size(); i++)
{
- if( !rects[i].IsEmpty() )
+ if(!rects[i].IsEmpty())
{
mergingRect = rects[i];
break;
}
}
- for( ; i < rects.size(); i++ )
+ for(; i < rects.size(); i++)
{
- mergingRect.Merge( rects[i] );
+ mergingRect.Merge(rects[i]);
}
}
-void InsertRects( WindowRenderSurface::DamagedRectsContainer& damagedRectsList, const std::vector< Rect< int > >& damagedRects )
+void InsertRects(WindowRenderSurface::DamagedRectsContainer& damagedRectsList, const std::vector<Rect<int>>& damagedRects)
{
- damagedRectsList.push_front( damagedRects );
- if( damagedRectsList.size() > 4 ) // past triple buffers + current
+ damagedRectsList.push_front(damagedRects);
+ if(damagedRectsList.size() > 4) // past triple buffers + current
{
damagedRectsList.pop_back();
}
mResizeFinished(true),
mDefaultScreenRotationAvailable(false)
{
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
- Initialize( surface );
+ DALI_LOG_INFO(gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n");
+ Initialize(surface);
}
WindowRenderSurface::~WindowRenderSurface()
{
- if( mRotationTrigger )
+ if(mRotationTrigger)
{
delete mRotationTrigger;
}
}
-void WindowRenderSurface::Initialize( Any surface )
+void WindowRenderSurface::Initialize(Any surface)
{
// If width or height are zero, go full screen.
- if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) )
+ if((mPositionSize.width == 0) || (mPositionSize.height == 0))
{
// Default window size == screen size
mPositionSize.x = 0;
mPositionSize.y = 0;
- WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height );
+ WindowSystem::GetScreenSize(mPositionSize.width, mPositionSize.height);
}
// Create a window base
auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory();
- mWindowBase = windowFactory->CreateWindowBase( mPositionSize, surface, ( mColorDepth == COLOR_DEPTH_32 ? true : false ) );
+ mWindowBase = windowFactory->CreateWindowBase(mPositionSize, surface, (mColorDepth == COLOR_DEPTH_32 ? true : false));
// Connect signals
- mWindowBase->OutputTransformedSignal().Connect( this, &WindowRenderSurface::OutputTransformed );
+ mWindowBase->OutputTransformedSignal().Connect(this, &WindowRenderSurface::OutputTransformed);
// Check screen rotation
mScreenRotationAngle = mWindowBase->GetScreenRotationAngle();
- if( mScreenRotationAngle != 0 )
+ if(mScreenRotationAngle != 0)
{
- mScreenRotationFinished = false;
- mResizeFinished = false;
+ mScreenRotationFinished = false;
+ mResizeFinished = false;
mDefaultScreenRotationAvailable = true;
- DALI_LOG_RELEASE_INFO("WindowRenderSurface::Initialize, screen rotation is enabled, screen rotation angle:[%d]\n", mScreenRotationAngle );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::Initialize, screen rotation is enabled, screen rotation angle:[%d]\n", mScreenRotationAngle);
}
}
mWindowBase->Show();
}
-void WindowRenderSurface::SetRenderNotification( TriggerEventInterface* renderNotification )
+void WindowRenderSurface::SetRenderNotification(TriggerEventInterface* renderNotification)
{
mRenderNotification = renderNotification;
}
-void WindowRenderSurface::SetTransparency( bool transparent )
+void WindowRenderSurface::SetTransparency(bool transparent)
{
- mWindowBase->SetTransparency( transparent );
+ mWindowBase->SetTransparency(transparent);
}
void WindowRenderSurface::RequestRotation(int angle, int width, int height)
return mPositionSize;
}
-void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void WindowRenderSurface::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
- if( mDpiHorizontal == 0 || mDpiVertical == 0 )
+ if(mDpiHorizontal == 0 || mDpiVertical == 0)
{
- const char* environmentDpiHorizontal = std::getenv( DALI_ENV_DPI_HORIZONTAL );
- mDpiHorizontal = environmentDpiHorizontal ? std::atoi( environmentDpiHorizontal ) : 0;
+ const char* environmentDpiHorizontal = std::getenv(DALI_ENV_DPI_HORIZONTAL);
+ mDpiHorizontal = environmentDpiHorizontal ? std::atoi(environmentDpiHorizontal) : 0;
- const char* environmentDpiVertical = std::getenv( DALI_ENV_DPI_VERTICAL );
- mDpiVertical = environmentDpiVertical ? std::atoi( environmentDpiVertical ) : 0;
+ const char* environmentDpiVertical = std::getenv(DALI_ENV_DPI_VERTICAL);
+ mDpiVertical = environmentDpiVertical ? std::atoi(environmentDpiVertical) : 0;
- if( mDpiHorizontal == 0 || mDpiVertical == 0 )
+ if(mDpiHorizontal == 0 || mDpiVertical == 0)
{
- mWindowBase->GetDpi( mDpiHorizontal, mDpiVertical );
+ mWindowBase->GetDpi(mDpiHorizontal, mDpiVertical);
}
}
dpiHorizontal = mDpiHorizontal;
- dpiVertical = mDpiVertical;
+ dpiVertical = mDpiVertical;
}
int WindowRenderSurface::GetOrientation() const
{
mGraphics = &mAdaptor->GetGraphicsInterface();
- DALI_ASSERT_ALWAYS( mGraphics && "Graphics interface is not created" );
+ DALI_ASSERT_ALWAYS(mGraphics && "Graphics interface is not created");
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- mEGL = &eglGraphics->GetEglInterface();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ mEGL = &eglGraphics->GetEglInterface();
- if ( mEGLContext == NULL )
+ if(mEGLContext == NULL)
{
// Create the OpenGL context for this window
Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
eglImpl.ChooseConfig(true, mColorDepth);
- eglImpl.CreateWindowContext( mEGLContext );
+ eglImpl.CreateWindowContext(mEGLContext);
// Create the OpenGL surface
CreateSurface();
void WindowRenderSurface::DestroySurface()
{
- DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gWindowRenderSurfaceLogFilter);
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- if( eglGraphics )
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ if(eglGraphics)
{
- DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: WinId (%d)\n", mWindowBase->GetNativeWindowId() );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: WinId (%d)\n", mWindowBase->GetNativeWindowId());
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.DestroySurface( mEGLSurface );
+ eglImpl.DestroySurface(mEGLSurface);
mEGLSurface = nullptr;
// Destroy context also
- eglImpl.DestroyContext( mEGLContext );
+ eglImpl.DestroyContext(mEGLContext);
mEGLContext = nullptr;
mWindowBase->DestroyEglWindow();
bool WindowRenderSurface::ReplaceGraphicsSurface()
{
- DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gWindowRenderSurfaceLogFilter);
// Destroy the old one
mWindowBase->DestroyEglWindow();
int width, height;
- if( mScreenRotationAngle == 0 || mScreenRotationAngle == 180 )
+ if(mScreenRotationAngle == 0 || mScreenRotationAngle == 180)
{
- width = mPositionSize.width;
+ width = mPositionSize.width;
height = mPositionSize.height;
}
else
{
- width = mPositionSize.height;
+ width = mPositionSize.height;
height = mPositionSize.width;
}
// Create the EGL window
- EGLNativeWindowType window = mWindowBase->CreateEglWindow( width, height );
+ EGLNativeWindowType window = mWindowBase->CreateEglWindow(width, height);
// Set screen rotation
mScreenRotationFinished = false;
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- return eglImpl.ReplaceSurfaceWindow( window, mEGLSurface, mEGLContext );
+ return eglImpl.ReplaceSurfaceWindow(window, mEGLSurface, mEGLContext);
}
-void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
+void WindowRenderSurface::MoveResize(Dali::PositionSize positionSize)
{
- bool needToMove = false;
+ bool needToMove = false;
bool needToResize = false;
// Check moving
- if( (fabs(positionSize.x - mPositionSize.x) > MINIMUM_DIMENSION_CHANGE) ||
- (fabs(positionSize.y - mPositionSize.y) > MINIMUM_DIMENSION_CHANGE) )
+ if((fabs(positionSize.x - mPositionSize.x) > MINIMUM_DIMENSION_CHANGE) ||
+ (fabs(positionSize.y - mPositionSize.y) > MINIMUM_DIMENSION_CHANGE))
{
needToMove = true;
}
// Check resizing
- if( (fabs(positionSize.width - mPositionSize.width) > MINIMUM_DIMENSION_CHANGE) ||
- (fabs(positionSize.height - mPositionSize.height) > MINIMUM_DIMENSION_CHANGE) )
+ if((fabs(positionSize.width - mPositionSize.width) > MINIMUM_DIMENSION_CHANGE) ||
+ (fabs(positionSize.height - mPositionSize.height) > MINIMUM_DIMENSION_CHANGE))
{
needToResize = true;
}
- if( needToResize )
+ if(needToResize)
{
- if( needToMove )
+ if(needToMove)
{
- mWindowBase->MoveResize( positionSize );
+ mWindowBase->MoveResize(positionSize);
}
else
{
- mWindowBase->Resize( positionSize );
+ mWindowBase->Resize(positionSize);
}
mResizeFinished = false;
- mPositionSize = positionSize;
+ mPositionSize = positionSize;
}
else
{
- if( needToMove )
+ if(needToMove)
{
- mWindowBase->Move( positionSize );
+ mWindowBase->Move(positionSize);
mPositionSize = positionSize;
}
}
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height );
+ DALI_LOG_INFO(gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height);
}
void WindowRenderSurface::StartRender()
{
Dali::Mutex::ScopedLock lock(mMutex);
- DALI_LOG_RELEASE_INFO( "WindowRenderSurface::PreRender: CreateFrameRenderedSyncFence [%d]\n", frameRenderedSync );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::PreRender: CreateFrameRenderedSyncFence [%d]\n", frameRenderedSync);
mFrameCallbackInfoContainer.push_back(std::unique_ptr<FrameCallbackInfo>(new FrameCallbackInfo(callbacks, frameRenderedSync)));
{
Dali::Mutex::ScopedLock lock(mMutex);
- DALI_LOG_RELEASE_INFO( "WindowRenderSurface::PreRender: CreateFramePresentedSyncFence [%d]\n", framePresentedSync );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::PreRender: CreateFramePresentedSyncFence [%d]\n", framePresentedSync);
mFrameCallbackInfoContainer.push_back(std::unique_ptr<FrameCallbackInfo>(new FrameCallbackInfo(callbacks, framePresentedSync)));
{
}
-void WindowRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
+void WindowRenderSurface::SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization)
{
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::SetThreadSynchronization: called\n" );
+ DALI_LOG_INFO(gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::SetThreadSynchronization: called\n");
mThreadSynchronization = &threadSynchronization;
}
void WindowRenderSurface::MakeContextCurrent()
{
- if ( mEGL != nullptr )
+ if(mEGL != nullptr)
{
- mEGL->MakeContextCurrent( mEGLSurface, mEGLContext );
+ mEGL->MakeContextCurrent(mEGLSurface, mEGLContext);
}
}
void WindowRenderSurface::ProcessFrameCallback()
{
- Dali::Mutex::ScopedLock lock( mMutex );
+ Dali::Mutex::ScopedLock lock(mMutex);
- for( auto&& iter : mFrameCallbackInfoContainer )
+ for(auto&& iter : mFrameCallbackInfoContainer)
{
- if( !iter->fileDescriptorMonitor )
+ if(!iter->fileDescriptorMonitor)
{
- iter->fileDescriptorMonitor = std::unique_ptr< FileDescriptorMonitor >( new FileDescriptorMonitor( iter->fileDescriptor,
- MakeCallback( this, &WindowRenderSurface::OnFileDescriptorEventDispatched ), FileDescriptorMonitor::FD_READABLE ) );
+ iter->fileDescriptorMonitor = std::unique_ptr<FileDescriptorMonitor>(new FileDescriptorMonitor(iter->fileDescriptor,
+ MakeCallback(this, &WindowRenderSurface::OnFileDescriptorEventDispatched),
+ FileDescriptorMonitor::FD_READABLE));
- DALI_LOG_RELEASE_INFO( "WindowRenderSurface::ProcessFrameCallback: Add handler [%d]\n", iter->fileDescriptor );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::ProcessFrameCallback: Add handler [%d]\n", iter->fileDescriptor);
}
}
}
-void WindowRenderSurface::OnFileDescriptorEventDispatched( FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor )
+void WindowRenderSurface::OnFileDescriptorEventDispatched(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor)
{
- if( !( eventBitMask & FileDescriptorMonitor::FD_READABLE ) )
+ if(!(eventBitMask & FileDescriptorMonitor::FD_READABLE))
{
- DALI_LOG_ERROR( "WindowRenderSurface::OnFileDescriptorEventDispatched: file descriptor error [%d]\n", eventBitMask );
- close( fileDescriptor );
+ DALI_LOG_ERROR("WindowRenderSurface::OnFileDescriptorEventDispatched: file descriptor error [%d]\n", eventBitMask);
+ close(fileDescriptor);
return;
}
- DALI_LOG_RELEASE_INFO( "WindowRenderSurface::OnFileDescriptorEventDispatched: Frame rendered [%d]\n", fileDescriptor );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::OnFileDescriptorEventDispatched: Frame rendered [%d]\n", fileDescriptor);
- std::unique_ptr< FrameCallbackInfo > callbackInfo;
+ std::unique_ptr<FrameCallbackInfo> callbackInfo;
{
- Dali::Mutex::ScopedLock lock( mMutex );
- auto frameCallbackInfo = std::find_if( mFrameCallbackInfoContainer.begin(), mFrameCallbackInfoContainer.end(),
- [fileDescriptor]( std::unique_ptr< FrameCallbackInfo >& callbackInfo )
- {
- return callbackInfo->fileDescriptor == fileDescriptor;
- } );
- if( frameCallbackInfo != mFrameCallbackInfoContainer.end() )
+ Dali::Mutex::ScopedLock lock(mMutex);
+ auto frameCallbackInfo = std::find_if(mFrameCallbackInfoContainer.begin(), mFrameCallbackInfoContainer.end(), [fileDescriptor](std::unique_ptr<FrameCallbackInfo>& callbackInfo) {
+ return callbackInfo->fileDescriptor == fileDescriptor;
+ });
+ if(frameCallbackInfo != mFrameCallbackInfoContainer.end())
{
- callbackInfo = std::move( *frameCallbackInfo );
+ callbackInfo = std::move(*frameCallbackInfo);
- mFrameCallbackInfoContainer.erase( frameCallbackInfo );
+ mFrameCallbackInfoContainer.erase(frameCallbackInfo);
}
}
// Call the connected callback
- if( callbackInfo )
+ if(callbackInfo)
{
- for( auto&& iter : ( callbackInfo )->callbacks )
+ for(auto&& iter : (callbackInfo)->callbacks)
{
- CallbackBase::Execute( *( iter.first ), iter.second );
+ CallbackBase::Execute(*(iter.first), iter.second);
}
}
}
-void WindowRenderSurface::SetBufferDamagedRects( const std::vector< Rect< int > >& damagedRects, Rect< int >& clippingRect )
+void WindowRenderSurface::SetBufferDamagedRects(const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
{
- auto eglGraphics = static_cast< EglGraphics* >( mGraphics );
- if ( eglGraphics )
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ if(eglGraphics)
{
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- if( !eglImpl.IsPartialUpdateRequired() )
+ if(!eglImpl.IsPartialUpdateRequired())
{
return;
}
- Rect< int > surfaceRect( 0, 0, mPositionSize.width, mPositionSize.height );
+ Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
- if( mFullSwapNextFrame )
+ if(mFullSwapNextFrame)
{
- InsertRects( mBufferDamagedRects, std::vector< Rect< int > >( 1, surfaceRect ) );
- clippingRect = Rect< int >();
+ InsertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
+ clippingRect = Rect<int>();
return;
}
- EGLint bufferAge = eglImpl.GetBufferAge( mEGLSurface );
+ EGLint bufferAge = eglImpl.GetBufferAge(mEGLSurface);
// Buffer age 0 means the back buffer in invalid and requires full swap
- if( !damagedRects.size() || bufferAge == 0 )
+ if(!damagedRects.size() || bufferAge == 0)
{
- InsertRects( mBufferDamagedRects, std::vector< Rect< int > >( 1, surfaceRect ) );
- clippingRect = Rect< int >();
+ InsertRects(mBufferDamagedRects, std::vector<Rect<int>>(1, surfaceRect));
+ clippingRect = Rect<int>();
return;
}
// We push current frame damaged rects here, zero index for current frame
- InsertRects( mBufferDamagedRects, damagedRects );
+ InsertRects(mBufferDamagedRects, damagedRects);
// Merge damaged rects into clipping rect
auto bufferDamagedRects = mBufferDamagedRects.begin();
- while( bufferAge-- >= 0 && bufferDamagedRects != mBufferDamagedRects.end() )
+ while(bufferAge-- >= 0 && bufferDamagedRects != mBufferDamagedRects.end())
{
- const std::vector< Rect< int > >& rects = *bufferDamagedRects++;
- MergeRects( clippingRect, rects );
+ const std::vector<Rect<int>>& rects = *bufferDamagedRects++;
+ MergeRects(clippingRect, rects);
}
- if( !clippingRect.Intersect( surfaceRect ) || clippingRect.Area() > surfaceRect.Area() * FULL_UPDATE_RATIO )
+ if(!clippingRect.Intersect(surfaceRect) || clippingRect.Area() > surfaceRect.Area() * FULL_UPDATE_RATIO)
{
// clipping area too big or doesn't intersect surface rect
- clippingRect = Rect< int >();
+ clippingRect = Rect<int>();
return;
}
- std::vector< Rect< int > > damagedRegion;
- damagedRegion.push_back( clippingRect );
+ std::vector<Rect<int>> damagedRegion;
+ damagedRegion.push_back(clippingRect);
- eglImpl.SetDamageRegion( mEGLSurface, damagedRegion );
+ eglImpl.SetDamageRegion(mEGLSurface, damagedRegion);
}
}
-void WindowRenderSurface::SwapBuffers( const std::vector<Rect<int>>& damagedRects )
+void WindowRenderSurface::SwapBuffers(const std::vector<Rect<int>>& damagedRects)
{
- auto eglGraphics = static_cast< EglGraphics* >( mGraphics );
- if( eglGraphics )
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ if(eglGraphics)
{
- Rect< int > surfaceRect( 0, 0, mPositionSize.width, mPositionSize.height );
+ Rect<int> surfaceRect(0, 0, mPositionSize.width, mPositionSize.height);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- if( !eglImpl.IsPartialUpdateRequired() || mFullSwapNextFrame || !damagedRects.size() || (damagedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO) )
+ if(!eglImpl.IsPartialUpdateRequired() || mFullSwapNextFrame || !damagedRects.size() || (damagedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO))
{
mFullSwapNextFrame = false;
- eglImpl.SwapBuffers( mEGLSurface );
+ eglImpl.SwapBuffers(mEGLSurface);
return;
}
mFullSwapNextFrame = false;
- std::vector< Rect< int > > mergedRects = damagedRects;
+ std::vector<Rect<int>> mergedRects = damagedRects;
// Merge intersecting rects, form an array of non intersecting rects to help driver a bit
// Could be optional and can be removed, needs to be checked with and without on platform
const int n = mergedRects.size();
- for( int i = 0; i < n - 1; i++ )
+ for(int i = 0; i < n - 1; i++)
{
- if( mergedRects[i].IsEmpty() )
+ if(mergedRects[i].IsEmpty())
{
continue;
}
- for( int j = i + 1; j < n; j++ )
+ for(int j = i + 1; j < n; j++)
{
- if( mergedRects[j].IsEmpty() )
+ if(mergedRects[j].IsEmpty())
{
continue;
}
- if( mergedRects[i].Intersects( mergedRects[j] ) )
+ if(mergedRects[i].Intersects(mergedRects[j]))
{
- mergedRects[i].Merge( mergedRects[j] );
- mergedRects[j].width = 0;
+ mergedRects[i].Merge(mergedRects[j]);
+ mergedRects[j].width = 0;
mergedRects[j].height = 0;
}
}
}
int j = 0;
- for( int i = 0; i < n; i++ )
+ for(int i = 0; i < n; i++)
{
- if( !mergedRects[i].IsEmpty() )
+ if(!mergedRects[i].IsEmpty())
{
mergedRects[j++] = mergedRects[i];
}
}
- if( j != 0 )
+ if(j != 0)
{
- mergedRects.resize( j );
+ mergedRects.resize(j);
}
- if( !mergedRects.size() || ( mergedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO ) )
+ if(!mergedRects.size() || (mergedRects[0].Area() > surfaceRect.Area() * FULL_UPDATE_RATIO))
{
- eglImpl.SwapBuffers( mEGLSurface );
+ eglImpl.SwapBuffers(mEGLSurface);
}
else
{
- eglImpl.SwapBuffers( mEGLSurface, mergedRects );
+ eglImpl.SwapBuffers(mEGLSurface, mergedRects);
}
}
}
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * Copyright (c) 2018 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.
namespace Dali::Internal::Adaptor
{
-
std::unique_ptr<DisplayConnection>
DisplayConnectionFactoryCocoa::CreateDisplayConnection()
{
return Utils::MakeUnique<DisplayConnectionFactoryCocoa>();
}
-}
+} // namespace Dali::Internal::Adaptor
/*
- * 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.
*
*/
- // CLASS HEADER
+// CLASS HEADER
#include <EGL/egl.h>
#include <dali/internal/window-system/macos/display-connection-impl-mac.h>
namespace Dali::Internal::Adaptor
{
-
DisplayConnection* DisplayConnectionCocoa::New()
{
return new DisplayConnectionCocoa();
bool DisplayConnectionCocoa::InitializeEgl(EglInterface& egl)
{
- EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
+ EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
if(!eglImpl.InitializeGles(EGL_DEFAULT_DISPLAY))
{
- DALI_LOG_ERROR( "Failed to initialize GLES.\n" );
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");
return false;
}
bool DisplayConnectionCocoa::InitializeGraphics()
{
- auto eglGraphics = static_cast<EglGraphics *>( mGraphics );
- EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
if(!eglImpl.InitializeGles(EGL_DEFAULT_DISPLAY))
{
- DALI_LOG_ERROR( "Failed to initialize GLES.\n" );
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");
return false;
}
return true;
}
-void DisplayConnectionCocoa::SetSurfaceType( Dali::RenderSurfaceInterface::Type type )
+void DisplayConnectionCocoa::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)
{
}
-void DisplayConnectionCocoa::SetGraphicsInterface( GraphicsInterface& graphics )
+void DisplayConnectionCocoa::SetGraphicsInterface(GraphicsInterface& graphics)
{
mGraphics = &graphics;
}
/*
- * 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.
namespace Dali::Internal::Adaptor
{
-
-std::unique_ptr< WindowRenderSurface >
+std::unique_ptr<WindowRenderSurface>
RenderSurfaceFactoryCocoa::CreateWindowRenderSurface(
Dali::PositionSize positionSize,
- Any surface,
- bool isTransparent
-)
+ Any surface,
+ bool isTransparent)
{
- return Utils::MakeUnique< WindowRenderSurfaceCocoa >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowRenderSurfaceCocoa>(positionSize, surface, isTransparent);
}
-std::unique_ptr< PixmapRenderSurface >
+std::unique_ptr<PixmapRenderSurface>
RenderSurfaceFactoryCocoa::CreatePixmapRenderSurface(
Dali::PositionSize positionSize,
- Any surface,
- bool isTransparent
-)
+ Any surface,
+ bool isTransparent)
{
DALI_LOG_ERROR("Pixmap isn't been supported in Windows");
return nullptr;
}
-std::unique_ptr< NativeRenderSurface >
+std::unique_ptr<NativeRenderSurface>
RenderSurfaceFactoryCocoa::CreateNativeRenderSurface(
SurfaceSize surfaceSize,
- Any surface,
- bool isTransparent
-)
+ Any surface,
+ bool isTransparent)
{
- return std::unique_ptr< NativeRenderSurface >( nullptr );
+ return std::unique_ptr<NativeRenderSurface>(nullptr);
}
// this should be created from somewhere
-std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
{
// returns Window factory
- return Utils::MakeUnique< RenderSurfaceFactoryCocoa >();
+ return Utils::MakeUnique<RenderSurfaceFactoryCocoa>();
}
-} // namespace Dali::Adaptor::Internal
+} // namespace Dali::Internal::Adaptor
/*
- * 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.
#include <dali/internal/window-system/macos/window-factory-mac.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/macos/window-base-mac.h>
#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/macos/window-base-mac.h>
namespace Dali::Internal::Adaptor
{
-
std::unique_ptr<WindowBase> WindowFactoryCocoa::CreateWindowBase(
Dali::PositionSize positionSize,
- Any surface,
- bool isTransparent
-)
+ Any surface,
+ bool isTransparent)
{
- return Utils::MakeUnique< WindowBaseCocoa >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowBaseCocoa>(positionSize, surface, isTransparent);
}
// this should be created from Window impl
-std::unique_ptr< WindowFactory > GetWindowFactory()
+std::unique_ptr<WindowFactory> GetWindowFactory()
{
// returns Window factory
- return Utils::MakeUnique< WindowFactoryCocoa >();
+ return Utils::MakeUnique<WindowFactoryCocoa>();
}
} // namespace Dali::Internal::Adaptor
/*
- * 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.
namespace Dali::Internal::Adaptor
{
WindowRenderSurfaceCocoa::WindowRenderSurfaceCocoa(Dali::PositionSize positionSize, Any surface, bool isTransparent)
- : WindowRenderSurface(positionSize, surface, isTransparent)
- , mReady(false)
+: WindowRenderSurface(positionSize, surface, isTransparent),
+ mReady(false)
{
}
{
std::unique_lock<std::mutex> lock(mCondMutex);
WindowRenderSurface::StartRender();
- while (!mReady)
+ while(!mReady)
{
mRenderWait.wait(lock);
}
mReady = true;
mRenderWait.notify_all();
}
-} // Dali::Internal::Adaptor
+} // namespace Dali::Internal::Adaptor
/*
- * Copyright (c) 2017 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.
{
namespace Adaptor
{
-
std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> DisplayConnectionFactoryEcoreWl::CreateDisplayConnection()
{
return Utils::MakeUnique<DisplayConnectionEcoreWl>();
return Utils::MakeUnique<DisplayConnectionFactoryEcoreWl>();
}
-}
-}
-}
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
*/
// CLASS HEADER
-#include <dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.h>
// EXTERNAL_HEADERS
-#include <tbm_dummy_display.h>
#include <dali/integration-api/debug.h>
+#include <tbm_dummy_display.h>
#ifdef ECORE_WAYLAND2
#include <Ecore_Wl2.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
DisplayConnection* DisplayConnectionEcoreWl::New()
{
DisplayConnection* pDisplayConnection(new DisplayConnectionEcoreWl());
}
DisplayConnectionEcoreWl::DisplayConnectionEcoreWl()
-: mDisplay( NULL ),
- mSurfaceType( RenderSurfaceInterface::WINDOW_RENDER_SURFACE ),
- mGraphics( nullptr )
+: mDisplay(NULL),
+ mSurfaceType(RenderSurfaceInterface::WINDOW_RENDER_SURFACE),
+ mGraphics(nullptr)
{
}
DisplayConnectionEcoreWl::~DisplayConnectionEcoreWl()
{
- if( mSurfaceType == RenderSurfaceInterface::NATIVE_RENDER_SURFACE )
+ if(mSurfaceType == RenderSurfaceInterface::NATIVE_RENDER_SURFACE)
{
ReleaseNativeDisplay();
}
Any DisplayConnectionEcoreWl::GetDisplay()
{
- return Any( mDisplay );
+ return Any(mDisplay);
}
void DisplayConnectionEcoreWl::ConsumeEvents()
bool DisplayConnectionEcoreWl::InitializeGraphics()
{
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- if( !eglImpl.InitializeGles( mDisplay ) )
+ if(!eglImpl.InitializeGles(mDisplay))
{
DALI_LOG_ERROR("Failed to initialize GLES.\n");
return false;
return true;
}
-void DisplayConnectionEcoreWl::SetSurfaceType( Dali::RenderSurfaceInterface::Type type )
+void DisplayConnectionEcoreWl::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)
{
mSurfaceType = type;
- if( mSurfaceType == Dali::RenderSurfaceInterface::NATIVE_RENDER_SURFACE )
+ if(mSurfaceType == Dali::RenderSurfaceInterface::NATIVE_RENDER_SURFACE)
{
mDisplay = GetNativeDisplay();
}
else
{
#ifdef ECORE_WAYLAND2
- Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
- mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl2_display_get( display ) );
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+ mDisplay = reinterpret_cast<EGLNativeDisplayType>(ecore_wl2_display_get(display));
#else
- mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() );
+ mDisplay = reinterpret_cast<EGLNativeDisplayType>(ecore_wl_display_get());
#endif
}
}
-void DisplayConnectionEcoreWl::SetGraphicsInterface( GraphicsInterface& graphics )
+void DisplayConnectionEcoreWl::SetGraphicsInterface(GraphicsInterface& graphics)
{
mGraphics = &graphics;
}
EGLNativeDisplayType DisplayConnectionEcoreWl::GetNativeDisplay()
{
- return reinterpret_cast< EGLNativeDisplayType >( tbm_dummy_display_create() );
+ return reinterpret_cast<EGLNativeDisplayType>(tbm_dummy_display_create());
}
void DisplayConnectionEcoreWl::ReleaseNativeDisplay()
{
- if( mDisplay )
+ if(mDisplay)
{
- tbm_dummy_display_destroy( reinterpret_cast< tbm_dummy_display* >( mDisplay ) );
+ tbm_dummy_display_destroy(reinterpret_cast<tbm_dummy_display*>(mDisplay));
}
}
/*
- * 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.
#include <dali/internal/window-system/tizen-wayland/ecore-wl/render-surface-factory-ecore-wl.h>
// INTERNAL HEADERS
+#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/common/pixmap-render-surface.h>
#include <dali/internal/window-system/common/window-render-surface.h>
#include <dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h>
-#include <dali/internal/window-system/common/pixmap-render-surface.h>
-#include <dali/internal/window-system/common/display-utils.h>
// EXTERNAL INCLUDES
#include <memory>
{
namespace Adaptor
{
-
-std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryEcoreWl::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowRenderSurface> RenderSurfaceFactoryEcoreWl::CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowRenderSurface>(positionSize, surface, isTransparent);
}
-std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreWl::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<PixmapRenderSurface> RenderSurfaceFactoryEcoreWl::CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return std::unique_ptr< PixmapRenderSurface >( nullptr );
+ return std::unique_ptr<PixmapRenderSurface>(nullptr);
}
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+std::unique_ptr<NativeRenderSurface> RenderSurfaceFactoryEcoreWl::CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( surfaceSize, surface, isTransparent );
+ return Utils::MakeUnique<NativeRenderSurfaceEcoreWl>(surfaceSize, surface, isTransparent);
}
// this should be created from somewhere
-std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
{
// returns Window factory
- return Utils::MakeUnique< RenderSurfaceFactoryEcoreWl >();
+ return Utils::MakeUnique<RenderSurfaceFactoryEcoreWl>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2019 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.
#include <dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h>
// INTERNAL HEADERS
+#include <dali/internal/input/common/key-impl.h>
#include <dali/internal/window-system/common/window-impl.h>
-#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/common/window-render-surface.h>
-#include <dali/internal/input/common/key-impl.h>
+#include <dali/internal/window-system/common/window-system.h>
// EXTERNAL_HEADERS
-#include <dali/public-api/object/any.h>
-#include <dali/integration-api/debug.h>
#include <Ecore_Input.h>
-#include <vconf.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/any.h>
#include <vconf-keys.h>
+#include <vconf.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
#endif
-const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
-const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
+const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
+const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
-const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
+const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
// DBUS accessibility
-const char* BUS = "org.enlightenment.wm-screen-reader";
+const char* BUS = "org.enlightenment.wm-screen-reader";
const char* INTERFACE = "org.tizen.GestureNavigation";
-const char* PATH = "/org/tizen/GestureNavigation";
+const char* PATH = "/org/tizen/GestureNavigation";
/**
* Get the device name from the provided ecore key event
*/
-void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
+void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
{
- const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
+ const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
- if( ecoreDeviceName )
+ if(ecoreDeviceName)
{
result = ecoreDeviceName;
}
/**
* Get the device class from the provided ecore event
*/
-void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
+void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
{
- switch( ecoreDeviceClass )
+ switch(ecoreDeviceClass)
{
case ECORE_DEVICE_CLASS_SEAT:
{
}
}
-void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
+void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
{
- switch( ecoreDeviceSubclass )
+ switch(ecoreDeviceSubclass)
{
case ECORE_DEVICE_SUBCLASS_FINGER:
{
/////////////////////////////////////////////////////////////////////////////////////////////////
/// Called when the window iconify state is changed.
-static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- return windowBase->OnIconifyStateChanged( data, type, event );
+ return windowBase->OnIconifyStateChanged(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the window gains focus
-static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- return windowBase->OnFocusIn( data, type, event );
+ return windowBase->OnFocusIn(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the window loses focus
-static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- return windowBase->OnFocusOut( data, type, event );
+ return windowBase->OnFocusOut(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the output is transformed
-static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
+static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- return windowBase->OnOutputTransform( data, type, event );
+ return windowBase->OnOutputTransform(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the output transform should be ignored
-static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
+static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- return windowBase->OnIgnoreOutputTransform( data, type, event );
+ return windowBase->OnIgnoreOutputTransform(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
/**
* Called when rotate event is recevied.
*/
-static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
+static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::EcoreEventRotate\n" );
- windowBase->OnRotation( data, type, event );
+ DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::EcoreEventRotate\n");
+ windowBase->OnRotation(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch down is received.
*/
-static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonDown( data, type, event );
+ windowBase->OnMouseButtonDown(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch up is received.
*/
-static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonUp( data, type, event );
+ windowBase->OnMouseButtonUp(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch motion is received.
*/
-static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonMove( data, type, event );
+ windowBase->OnMouseButtonMove(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch is canceled.
*/
-static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonCancel( data, type, event );
+ windowBase->OnMouseButtonCancel(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a mouse wheel is received.
*/
-static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnMouseWheel( data, type, event );
+ windowBase->OnMouseWheel(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a detent rotation event is recevied.
*/
-static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
+static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnDetentRotation( data, type, event );
+ windowBase->OnDetentRotation(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a key down is received.
*/
-static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
+static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnKeyDown( data, type, event );
+ windowBase->OnKeyDown(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a key up is received.
*/
-static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
+static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnKeyUp( data, type, event );
+ windowBase->OnKeyUp(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when the source window notifies us the content in clipboard is selected.
*/
-static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
+static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnDataSend( data, type, event );
+ windowBase->OnDataSend(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
* Called when the source window sends us about the selected content.
* For example, when item is selected in the clipboard.
*/
-static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
+static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->OnDataReceive( data, type, event );
+ windowBase->OnDataReceive(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a font name is changed.
*/
-static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
+static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
windowBase->OnFontNameChanged();
}
/**
* Called when a font size is changed.
*/
-static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
+static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
windowBase->OnFontSizeChanged();
}
#ifdef DALI_ELDBUS_AVAILABLE
// Callback for Ecore ElDBus accessibility events.
-static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
+static void EcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( context );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(context);
+ if(windowBase)
{
- windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
+ windowBase->OnEcoreElDBusAccessibilityNotification(context, message);
}
}
#endif // DALI_ELDBUS_AVAILABLE
-static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
+static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
+ windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
}
}
-static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
+static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->RegistryGlobalCallbackRemove( data, registry, id );
+ windowBase->RegistryGlobalCallbackRemove(data, registry, id);
}
}
-static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
+static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
{
}
-static void TizenPolicyConformantArea( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h )
+static void TizenPolicyConformantArea(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
{
}
-static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
+static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
+ windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
}
}
-static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
+static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
{
}
-static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
+static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
+ windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
}
}
-static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
+static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
{
}
-static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
+static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
{
}
-static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
+static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
{
}
-static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
+static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
{
}
-static void TizenPolicyConformantRegion( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial )
+static void TizenPolicyConformantRegion(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial)
{
}
-static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
+static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
{
- WindowBaseEcoreWl* windowBase = static_cast< WindowBaseEcoreWl* >( data );
- if( windowBase )
+ WindowBaseEcoreWl* windowBase = static_cast<WindowBaseEcoreWl*>(data);
+ if(windowBase)
{
- windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
+ windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
}
}
const struct wl_registry_listener registryListener =
-{
- RegistryGlobalCallback,
- RegistryGlobalCallbackRemove
-};
+ {
+ RegistryGlobalCallback,
+ RegistryGlobalCallbackRemove};
const struct tizen_policy_listener tizenPolicyListener =
-{
- TizenPolicyConformant,
- TizenPolicyConformantArea,
- TizenPolicyNotificationChangeDone,
- TizenPolicyTransientForDone,
- TizenPolicyScreenModeChangeDone,
- TizenPolicyIconifyStateChanged,
- TizenPolicySupportedAuxiliaryHints,
- TizenPolicyAllowedAuxiliaryHint,
- TizenPolicyAuxiliaryMessage,
- TizenPolicyConformantRegion
-};
+ {
+ TizenPolicyConformant,
+ TizenPolicyConformantArea,
+ TizenPolicyNotificationChangeDone,
+ TizenPolicyTransientForDone,
+ TizenPolicyScreenModeChangeDone,
+ TizenPolicyIconifyStateChanged,
+ TizenPolicySupportedAuxiliaryHints,
+ TizenPolicyAllowedAuxiliaryHint,
+ TizenPolicyAuxiliaryMessage,
+ TizenPolicyConformantRegion};
const struct tizen_display_policy_listener tizenDisplayPolicyListener =
-{
- DisplayPolicyBrightnessChangeDone
-};
+ {
+ DisplayPolicyBrightnessChangeDone};
} // unnamed namespace
WindowBaseEcoreWl::~WindowBaseEcoreWl()
{
#ifdef DALI_ELDBUS_AVAILABLE
- // Close down ElDBus connections.
- if( mSystemConnection )
- {
- eldbus_connection_unref( mSystemConnection );
- }
+ // Close down ElDBus connections.
+ if(mSystemConnection)
+ {
+ eldbus_connection_unref(mSystemConnection);
+ }
#endif // DALI_ELDBUS_AVAILABLE
- vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
- vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
+ vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
- for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
+ for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
{
- ecore_event_handler_del( *iter );
+ ecore_event_handler_del(*iter);
}
mEcoreEventHandler.Clear();
- if( mEventQueue )
+ if(mEventQueue)
{
- wl_event_queue_destroy( mEventQueue );
+ wl_event_queue_destroy(mEventQueue);
}
mSupportedAuxiliaryHints.clear();
mAuxiliaryHints.clear();
- if( mEglWindow != NULL )
+ if(mEglWindow != NULL)
{
- wl_egl_window_destroy( mEglWindow );
+ wl_egl_window_destroy(mEglWindow);
mEglWindow = NULL;
}
- if( mOwnSurface )
+ if(mOwnSurface)
{
- ecore_wl_window_free( mEcoreWindow );
+ ecore_wl_window_free(mEcoreWindow);
WindowSystem::Shutdown();
}
}
-void WindowBaseEcoreWl::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+void WindowBaseEcoreWl::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
{
- if( surface.Empty() == false )
+ if(surface.Empty() == false)
{
// check we have a valid type
- DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl_Window *) ) && "Surface type is invalid" );
+ DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl_Window*)) && "Surface type is invalid");
- mEcoreWindow = AnyCast< Ecore_Wl_Window* >( surface );
+ mEcoreWindow = AnyCast<Ecore_Wl_Window*>(surface);
}
else
{
WindowSystem::Initialize();
mOwnSurface = true;
- CreateWindow( positionSize );
+ CreateWindow(positionSize);
}
- mWlSurface = ecore_wl_window_surface_create( mEcoreWindow );
+ mWlSurface = ecore_wl_window_surface_create(mEcoreWindow);
- SetTransparency( isTransparent );
+ SetTransparency(isTransparent);
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
// Register Rotate event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
// Register Touch events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
// Register Mouse wheel events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
// Register Detent event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
// Register Key events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
// Register Selection event - clipboard selection
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
// Register Vconf notify - font name and size
- vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
- vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
+ vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
InitializeEcoreElDBus();
mDisplay = ecore_wl_display_get();
- if( mDisplay )
+ if(mDisplay)
{
- wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
- if( displayWrapper )
+ wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
+ if(displayWrapper)
{
- mEventQueue = wl_display_create_queue( mDisplay );
- if( mEventQueue )
+ mEventQueue = wl_display_create_queue(mDisplay);
+ if(mEventQueue)
{
- wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
+ wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
- wl_registry* registry = wl_display_get_registry( displayWrapper );
- wl_registry_add_listener( registry, ®istryListener, this );
+ wl_registry* registry = wl_display_get_registry(displayWrapper);
+ wl_registry_add_listener(registry, ®istryListener, this);
}
- wl_proxy_wrapper_destroy( displayWrapper );
+ wl_proxy_wrapper_destroy(displayWrapper);
}
}
// get auxiliary hint
- Eina_List* hints = ecore_wl_window_aux_hints_supported_get( mEcoreWindow );
- if( hints )
+ Eina_List* hints = ecore_wl_window_aux_hints_supported_get(mEcoreWindow);
+ if(hints)
{
- Eina_List* l = NULL;
- char* hint = NULL;
+ Eina_List* l = NULL;
+ char* hint = NULL;
- for( l = hints, ( hint = static_cast< char* >( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( hint = static_cast< char* >( eina_list_data_get(l) ) ) )
+ for(l = hints, (hint = static_cast<char*>(eina_list_data_get(l))); l; l = eina_list_next(l), (hint = static_cast<char*>(eina_list_data_get(l))))
{
- mSupportedAuxiliaryHints.push_back( hint );
+ mSupportedAuxiliaryHints.push_back(hint);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::Initialize: %s\n", hint);
}
}
}
-Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl::OnIconifyStateChanged(void* data, int type, void* event)
{
- Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
- Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+ Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl_Event_Window_Iconify_State_Change*>(event));
+ Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
- if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- if( iconifyChangedEvent->iconified == EINA_TRUE )
+ if(iconifyChangedEvent->iconified == EINA_TRUE)
{
- mIconifyChangedSignal.Emit( true );
+ mIconifyChangedSignal.Emit(true);
}
else
{
- mIconifyChangedSignal.Emit( false );
+ mIconifyChangedSignal.Emit(false);
}
handled = ECORE_CALLBACK_DONE;
}
return handled;
}
-Eina_Bool WindowBaseEcoreWl::OnFocusIn( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl::OnFocusIn(void* data, int type, void* event)
{
- Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
+ Ecore_Wl_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl_Event_Focus_In*>(event));
- if( focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(focusInEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
- mFocusChangedSignal.Emit( true );
+ mFocusChangedSignal.Emit(true);
}
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool WindowBaseEcoreWl::OnFocusOut( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl::OnFocusOut(void* data, int type, void* event)
{
- Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
+ Ecore_Wl_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl_Event_Focus_Out*>(event));
- if( focusOutEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(focusOutEvent->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
- mFocusChangedSignal.Emit( false );
+ mFocusChangedSignal.Emit(false);
}
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool WindowBaseEcoreWl::OnOutputTransform( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl::OnOutputTransform(void* data, int type, void* event)
{
- Ecore_Wl_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl_Event_Output_Transform* >( event ) );
+ Ecore_Wl_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl_Event_Output_Transform*>(event));
- if( transformEvent->output == ecore_wl_window_output_find( mEcoreWindow ) )
+ if(transformEvent->output == ecore_wl_window_output_find(mEcoreWindow))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
mOutputTransformedSignal.Emit();
}
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl::OnIgnoreOutputTransform(void* data, int type, void* event)
{
- Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl_Event_Ignore_Output_Transform* >( event ) );
+ Ecore_Wl_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl_Event_Ignore_Output_Transform*>(event));
- if( ignoreTransformEvent->win == mEcoreWindow )
+ if(ignoreTransformEvent->win == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
mOutputTransformedSignal.Emit();
}
return ECORE_CALLBACK_PASS_ON;
}
-void WindowBaseEcoreWl::OnRotation( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnRotation(void* data, int type, void* event)
{
- Ecore_Wl_Event_Window_Rotate* ev( static_cast< Ecore_Wl_Event_Window_Rotate* >( event ) );
+ Ecore_Wl_Event_Window_Rotate* ev(static_cast<Ecore_Wl_Event_Window_Rotate*>(event));
- if( ev->win == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(ev->win == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h );
+ DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::OnRotation, angle: %d, width: %d, height: %d\n", ev->angle, ev->w, ev->h);
RotationEvent rotationEvent;
- rotationEvent.angle = ev->angle;
+ rotationEvent.angle = ev->angle;
rotationEvent.winResize = 0;
- if( ev->angle == 0 || ev->angle == 180 )
+ if(ev->angle == 0 || ev->angle == 180)
{
- rotationEvent.width = ev->w;
+ rotationEvent.width = ev->w;
rotationEvent.height = ev->h;
}
else
{
- rotationEvent.width = ev->h;
+ rotationEvent.width = ev->h;
rotationEvent.height = ev->w;
}
- mRotationSignal.Emit( rotationEvent );
+ mRotationSignal.Emit(rotationEvent);
}
}
-void WindowBaseEcoreWl::OnMouseButtonDown( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnMouseButtonDown(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- PointState::Type state ( PointState::DOWN );
+ PointState::Type state(PointState::DOWN);
// Check if the buttons field is set and ensure it's the primary touch button.
// If this event was triggered by buttons other than the primary button (used for touch), then
// just send an interrupted event to Core.
- if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
+ if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
{
state = PointState::INTERRUPTED;
}
- Device::Class::Type deviceClass;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+ GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( state );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- point.SetDeviceClass( deviceClass );
- point.SetDeviceSubclass( deviceSubclass );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(state);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ point.SetDeviceClass(deviceClass);
+ point.SetDeviceSubclass(deviceSubclass);
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreWl::OnMouseButtonUp( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnMouseButtonUp(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- Device::Class::Type deviceClass;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+ GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::UP );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- point.SetDeviceClass( deviceClass );
- point.SetDeviceSubclass( deviceSubclass );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::UP);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ point.SetDeviceClass(deviceClass);
+ point.SetDeviceSubclass(deviceSubclass);
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreWl::OnMouseButtonMove( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnMouseButtonMove(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
+ Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- Device::Class::Type deviceClass;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+ GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::MOTION );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- point.SetDeviceClass( deviceClass );
- point.SetDeviceSubclass( deviceSubclass );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::MOTION);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ point.SetDeviceClass(deviceClass);
+ point.SetDeviceSubclass(deviceSubclass);
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreWl::OnMouseButtonCancel( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnMouseButtonCancel(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::INTERRUPTED );
- point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::INTERRUPTED);
+ point.SetScreenPosition(Vector2(0.0f, 0.0f));
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseButtonCancel\n");
}
}
-void WindowBaseEcoreWl::OnMouseWheel( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnMouseWheel(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
+ Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
- if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
- Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
+ Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
- mWheelEventSignal.Emit( wheelEvent );
+ mWheelEventSignal.Emit(wheelEvent);
}
}
-void WindowBaseEcoreWl::OnDetentRotation( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnDetentRotation(void* data, int type, void* event)
{
- Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
+ Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::OnDetentRotation\n");
- int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
+ int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
int timeStamp = detentEvent->timestamp;
- Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2( 0.0f, 0.0f ), direction, timeStamp );
+ Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0, Vector2(0.0f, 0.0f), direction, timeStamp);
- mWheelEventSignal.Emit( wheelEvent );
+ mWheelEventSignal.Emit(wheelEvent);
}
-void WindowBaseEcoreWl::OnKeyDown( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnKeyDown(void* data, int type, void* event)
{
- Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
+ Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
- if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyDown\n");
- std::string keyName( keyEvent->keyname );
- std::string logicalKey( "" );
- std::string keyString( "" );
- std::string compose( "" );
+ std::string keyName(keyEvent->keyname);
+ std::string logicalKey("");
+ std::string keyString("");
+ std::string compose("");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
- if( keyEvent->compose )
+ if(keyEvent->compose)
{
compose = keyEvent->compose;
}
// Ensure key symbol is not NULL as keys like SHIFT have a null string.
- if( keyEvent->key )
+ if(keyEvent->key)
{
logicalKey = keyEvent->key;
}
- int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
- keyCode = ( keyCode == -1 ) ? 0 : keyCode;
- int modifier( keyEvent->modifiers );
+ int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
+ keyCode = (keyCode == -1) ? 0 : keyCode;
+ int modifier(keyEvent->modifiers);
unsigned long time = keyEvent->timestamp;
- if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
+ if(!strncmp(keyEvent->keyname, "Keycode-", 8))
{
- keyCode = atoi( keyEvent->keyname + 8 );
+ keyCode = atoi(keyEvent->keyname + 8);
}
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- if( keyEvent->string )
+ if(keyEvent->string)
{
keyString = keyEvent->string;
}
- std::string deviceName;
- Device::Class::Type deviceClass;
+ std::string deviceName;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceName( keyEvent, deviceName );
- GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
+ GetDeviceName(keyEvent, deviceName);
+ GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
- Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
+ Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseEcoreWl::OnKeyUp( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnKeyUp(void* data, int type, void* event)
{
- Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
+ Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
- if( keyEvent->window == static_cast< unsigned int >( ecore_wl_window_id_get( mEcoreWindow ) ) )
+ if(keyEvent->window == static_cast<unsigned int>(ecore_wl_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp\n");
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
// Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
- if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
+ if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::OnKeyUp: This event flag indicates the event is canceled. \n");
return;
}
#endif // Since ecore 1.23 version
- std::string keyName( keyEvent->keyname );
- std::string logicalKey( "" );
- std::string keyString( "" );
- std::string compose( "" );
+ std::string keyName(keyEvent->keyname);
+ std::string logicalKey("");
+ std::string keyString("");
+ std::string compose("");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
- if( keyEvent->compose )
+ if(keyEvent->compose)
{
compose = keyEvent->compose;
}
// Ensure key symbol is not NULL as keys like SHIFT have a null string.
- if( keyEvent->key )
+ if(keyEvent->key)
{
logicalKey = keyEvent->key;
}
- int keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
- keyCode = ( keyCode == -1 ) ? 0 : keyCode;
- int modifier( keyEvent->modifiers );
+ int keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
+ keyCode = (keyCode == -1) ? 0 : keyCode;
+ int modifier(keyEvent->modifiers);
unsigned long time = keyEvent->timestamp;
- if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
+ if(!strncmp(keyEvent->keyname, "Keycode-", 8))
{
- keyCode = atoi( keyEvent->keyname + 8 );
+ keyCode = atoi(keyEvent->keyname + 8);
}
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- if( keyEvent->string )
+ if(keyEvent->string)
{
keyString = keyEvent->string;
}
- std::string deviceName;
- Device::Class::Type deviceClass;
+ std::string deviceName;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceName( keyEvent, deviceName );
- GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
+ GetDeviceName(keyEvent, deviceName);
+ GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
- Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
+ Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseEcoreWl::OnDataSend( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnDataSend(void* data, int type, void* event)
{
- mSelectionDataSendSignal.Emit( event );
+ mSelectionDataSendSignal.Emit(event);
}
-void WindowBaseEcoreWl::OnDataReceive( void* data, int type, void* event )
+void WindowBaseEcoreWl::OnDataReceive(void* data, int type, void* event)
{
- mSelectionDataReceivedSignal.Emit( event );
+ mSelectionDataReceivedSignal.Emit(event);
}
void WindowBaseEcoreWl::OnFontNameChanged()
{
- mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
+ mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
}
void WindowBaseEcoreWl::OnFontSizeChanged()
{
- mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
+ mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
}
-void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
+void WindowBaseEcoreWl::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
{
#ifdef DALI_ELDBUS_AVAILABLE
AccessibilityInfo info;
// The string defines the arg-list's respective types.
- if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
+ if(!eldbus_message_arguments_get(message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime))
{
- DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
+ DALI_LOG_ERROR("OnEcoreElDBusAccessibilityNotification: Error getting arguments\n");
}
- mAccessibilitySignal.Emit( info );
+ mAccessibilitySignal.Emit(info);
#endif
}
-void WindowBaseEcoreWl::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
+void WindowBaseEcoreWl::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
- if( strcmp( interface, tizen_policy_interface.name ) == 0 )
+ if(strcmp(interface, tizen_policy_interface.name) == 0)
{
- uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
+ uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
- mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
- if( !mTizenPolicy )
+ mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
+ if(!mTizenPolicy)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
return;
}
- tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
+ tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
}
- else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
+ else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
{
- mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
- if( !mTizenDisplayPolicy )
+ mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
+ if(!mTizenDisplayPolicy)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
return;
}
- tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
+ tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
}
}
-void WindowBaseEcoreWl::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
+void WindowBaseEcoreWl::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
{
- mTizenPolicy = NULL;
+ mTizenPolicy = NULL;
mTizenDisplayPolicy = NULL;
}
-void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
+void WindowBaseEcoreWl::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
{
- mNotificationLevel = level;
- mNotificationChangeState = state;
+ mNotificationLevel = level;
+ mNotificationChangeState = state;
mNotificationLevelChangeDone = true;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
}
-void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
+void WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
{
- mScreenOffMode = mode;
+ mScreenOffMode = mode;
mScreenOffModeChangeState = state;
- mScreenOffModeChangeDone = true;
+ mScreenOffModeChangeDone = true;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
}
-void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
+void WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
{
- mBrightness = brightness;
+ mBrightness = brightness;
mBrightnessChangeState = state;
- mBrightnessChangeDone = true;
+ mBrightnessChangeDone = true;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
}
Any WindowBaseEcoreWl::GetNativeWindow()
int WindowBaseEcoreWl::GetNativeWindowId()
{
- return ecore_wl_window_id_get( mEcoreWindow );
+ return ecore_wl_window_id_get(mEcoreWindow);
}
-EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow( int width, int height )
+EGLNativeWindowType WindowBaseEcoreWl::CreateEglWindow(int width, int height)
{
- mEglWindow = wl_egl_window_create( mWlSurface, width, height );
+ mEglWindow = wl_egl_window_create(mWlSurface, width, height);
- return static_cast< EGLNativeWindowType >( mEglWindow );
+ return static_cast<EGLNativeWindowType>(mEglWindow);
}
void WindowBaseEcoreWl::DestroyEglWindow()
{
- if( mEglWindow != NULL )
+ if(mEglWindow != NULL)
{
- wl_egl_window_destroy( mEglWindow );
+ wl_egl_window_destroy(mEglWindow);
mEglWindow = NULL;
}
}
-void WindowBaseEcoreWl::SetEglWindowRotation( int angle )
+void WindowBaseEcoreWl::SetEglWindowRotation(int angle)
{
wl_egl_window_rotation rotation;
- switch( angle )
+ switch(angle)
{
case 0:
{
}
}
- wl_egl_window_set_rotation( mEglWindow, rotation );
+ wl_egl_window_set_rotation(mEglWindow, rotation);
}
-void WindowBaseEcoreWl::SetEglWindowBufferTransform( int angle )
+void WindowBaseEcoreWl::SetEglWindowBufferTransform(int angle)
{
wl_output_transform bufferTransform;
- switch( angle )
+ switch(angle)
{
case 0:
{
}
}
- wl_egl_window_set_buffer_transform( mEglWindow, bufferTransform );
+ wl_egl_window_set_buffer_transform(mEglWindow, bufferTransform);
}
-void WindowBaseEcoreWl::SetEglWindowTransform( int angle )
+void WindowBaseEcoreWl::SetEglWindowTransform(int angle)
{
wl_output_transform windowTransform;
- switch( angle )
+ switch(angle)
{
case 0:
{
}
}
- wl_egl_window_set_window_transform( mEglWindow, windowTransform );
+ wl_egl_window_set_window_transform(mEglWindow, windowTransform);
}
-void WindowBaseEcoreWl::ResizeEglWindow( PositionSize positionSize )
+void WindowBaseEcoreWl::ResizeEglWindow(PositionSize positionSize)
{
- wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
+ wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
}
bool WindowBaseEcoreWl::IsEglWindowRotationSupported()
{
// Check capability
- wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) );
- if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED )
+ wl_egl_window_capability capability = static_cast<wl_egl_window_capability>(wl_egl_window_get_capabilities(mEglWindow));
+ if(capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED)
{
mSupportedPreProtation = true;
return true;
return false;
}
-void WindowBaseEcoreWl::Move( PositionSize positionSize )
+void WindowBaseEcoreWl::Move(PositionSize positionSize)
{
- ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
+ ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
}
-void WindowBaseEcoreWl::Resize( PositionSize positionSize )
+void WindowBaseEcoreWl::Resize(PositionSize positionSize)
{
- ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
+ ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
}
-void WindowBaseEcoreWl::MoveResize( PositionSize positionSize )
+void WindowBaseEcoreWl::MoveResize(PositionSize positionSize)
{
- ecore_wl_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
- ecore_wl_window_update_size( mEcoreWindow, positionSize.width, positionSize.height );
+ ecore_wl_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
+ ecore_wl_window_update_size(mEcoreWindow, positionSize.width, positionSize.height);
}
-void WindowBaseEcoreWl::SetClass( const std::string& name, const std::string& className )
+void WindowBaseEcoreWl::SetClass(const std::string& name, const std::string& className)
{
- ecore_wl_window_title_set( mEcoreWindow, name.c_str() );
- ecore_wl_window_class_name_set( mEcoreWindow, className.c_str() );
+ ecore_wl_window_title_set(mEcoreWindow, name.c_str());
+ ecore_wl_window_class_name_set(mEcoreWindow, className.c_str());
}
void WindowBaseEcoreWl::Raise()
{
// Use ecore_wl_window_activate to prevent the window shown without rendering
- ecore_wl_window_activate( mEcoreWindow );
+ ecore_wl_window_activate(mEcoreWindow);
}
void WindowBaseEcoreWl::Lower()
{
- ecore_wl_window_lower( mEcoreWindow );
+ ecore_wl_window_lower(mEcoreWindow);
}
void WindowBaseEcoreWl::Activate()
{
- ecore_wl_window_activate( mEcoreWindow );
+ ecore_wl_window_activate(mEcoreWindow);
}
-void WindowBaseEcoreWl::SetAvailableAnlges( const std::vector< int >& angles )
+void WindowBaseEcoreWl::SetAvailableAnlges(const std::vector<int>& angles)
{
- int rotations[4] = { 0 };
- DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size() );
- for( std::size_t i = 0; i < angles.size(); ++i )
+ int rotations[4] = {0};
+ DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl::SetAvailableAnlges, angle's count: %d\n", angles.size());
+ for(std::size_t i = 0; i < angles.size(); ++i)
{
- rotations[i] = static_cast< int >( angles[i] );
- DALI_LOG_RELEASE_INFO( "%d ", rotations[i] );
+ rotations[i] = static_cast<int>(angles[i]);
+ DALI_LOG_RELEASE_INFO("%d ", rotations[i]);
}
- ecore_wl_window_rotation_available_rotations_set( mEcoreWindow, rotations, angles.size() );
+ ecore_wl_window_rotation_available_rotations_set(mEcoreWindow, rotations, angles.size());
}
-void WindowBaseEcoreWl::SetPreferredAngle( int angle )
+void WindowBaseEcoreWl::SetPreferredAngle(int angle)
{
- ecore_wl_window_rotation_preferred_rotation_set( mEcoreWindow, angle );
+ ecore_wl_window_rotation_preferred_rotation_set(mEcoreWindow, angle);
}
-void WindowBaseEcoreWl::SetAcceptFocus( bool accept )
+void WindowBaseEcoreWl::SetAcceptFocus(bool accept)
{
- ecore_wl_window_focus_skip_set( mEcoreWindow, !accept );
+ ecore_wl_window_focus_skip_set(mEcoreWindow, !accept);
}
void WindowBaseEcoreWl::Show()
{
- ecore_wl_window_show( mEcoreWindow );
+ ecore_wl_window_show(mEcoreWindow);
}
void WindowBaseEcoreWl::Hide()
{
- ecore_wl_window_hide( mEcoreWindow );
+ ecore_wl_window_hide(mEcoreWindow);
}
unsigned int WindowBaseEcoreWl::GetSupportedAuxiliaryHintCount() const
return mSupportedAuxiliaryHints.size();
}
-std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string WindowBaseEcoreWl::GetSupportedAuxiliaryHint(unsigned int index) const
{
- if( index >= GetSupportedAuxiliaryHintCount() )
+ if(index >= GetSupportedAuxiliaryHintCount())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
}
return mSupportedAuxiliaryHints[index];
}
-unsigned int WindowBaseEcoreWl::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int WindowBaseEcoreWl::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
bool supported = false;
// Check if the hint is suppported
- for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
+ for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
{
- if( *iter == hint )
+ if(*iter == hint)
{
supported = true;
break;
}
}
- if( !supported )
+ if(!supported)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
return 0;
}
// Check if the hint is already added
- for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
+ for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
{
- if( mAuxiliaryHints[i].first == hint )
+ if(mAuxiliaryHints[i].first == hint)
{
// Just change the value
mAuxiliaryHints[i].second = value;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
- return i + 1; // id is index + 1
+ return i + 1; // id is index + 1
}
}
// Add the hint
- mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
+ mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
unsigned int id = mAuxiliaryHints.size();
- ecore_wl_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
+ ecore_wl_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
return id;
}
-bool WindowBaseEcoreWl::RemoveAuxiliaryHint( unsigned int id )
+bool WindowBaseEcoreWl::RemoveAuxiliaryHint(unsigned int id)
{
- if( id == 0 || id > mAuxiliaryHints.size() )
+ if(id == 0 || id > mAuxiliaryHints.size())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
return false;
}
mAuxiliaryHints[id - 1].second = std::string();
- ecore_wl_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
+ ecore_wl_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
return true;
}
-bool WindowBaseEcoreWl::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool WindowBaseEcoreWl::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
- if( id == 0 || id > mAuxiliaryHints.size() )
+ if(id == 0 || id > mAuxiliaryHints.size())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
return false;
}
mAuxiliaryHints[id - 1].second = value;
- ecore_wl_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
+ ecore_wl_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
return true;
}
-std::string WindowBaseEcoreWl::GetAuxiliaryHintValue( unsigned int id ) const
+std::string WindowBaseEcoreWl::GetAuxiliaryHintValue(unsigned int id) const
{
- if( id == 0 || id > mAuxiliaryHints.size() )
+ if(id == 0 || id > mAuxiliaryHints.size())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
return std::string();
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
return mAuxiliaryHints[id - 1].second;
}
-unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int WindowBaseEcoreWl::GetAuxiliaryHintId(const std::string& hint) const
{
- for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
+ for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
{
- if( mAuxiliaryHints[i].first == hint )
+ if(mAuxiliaryHints[i].first == hint)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
return i + 1;
}
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
return 0;
}
-void WindowBaseEcoreWl::SetInputRegion( const Rect< int >& inputRegion )
+void WindowBaseEcoreWl::SetInputRegion(const Rect<int>& inputRegion)
{
- ecore_wl_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
+ ecore_wl_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
}
-void WindowBaseEcoreWl::SetType( Dali::WindowType type )
+void WindowBaseEcoreWl::SetType(Dali::WindowType type)
{
Ecore_Wl_Window_Type windowType;
- switch( type )
+ switch(type)
{
case Dali::WindowType::NORMAL:
{
}
}
- ecore_wl_window_type_set( mEcoreWindow, windowType );
+ ecore_wl_window_type_set(mEcoreWindow, windowType);
}
-bool WindowBaseEcoreWl::SetNotificationLevel( Dali::WindowNotificationLevel level )
+bool WindowBaseEcoreWl::SetNotificationLevel(Dali::WindowNotificationLevel level)
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int notificationLevel;
- switch( level )
+ switch(level)
{
case Dali::WindowNotificationLevel::NONE:
{
}
default:
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: invalid level [%d]\n", level);
notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
break;
}
}
mNotificationLevelChangeDone = false;
- mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
+ mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
- tizen_policy_set_notification_level( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), notificationLevel );
+ tizen_policy_set_notification_level(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), notificationLevel);
int count = 0;
- while( !mNotificationLevelChangeDone && count < 3 )
+ while(!mNotificationLevelChangeDone && count < 3)
{
ecore_wl_flush();
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mNotificationLevelChangeDone )
+ if(!mNotificationLevelChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
return false;
}
- else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Permission denied! [%d]\n", level);
return false;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
return true;
}
Dali::WindowNotificationLevel WindowBaseEcoreWl::GetNotificationLevel() const
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int count = 0;
- while( !mNotificationLevelChangeDone && count < 3 )
+ while(!mNotificationLevelChangeDone && count < 3)
{
ecore_wl_flush();
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mNotificationLevelChangeDone )
+ if(!mNotificationLevelChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
return Dali::Window::NotificationLevel::NONE;
}
Dali::WindowNotificationLevel level;
- switch( mNotificationLevel )
+ switch(mNotificationLevel)
{
case TIZEN_POLICY_LEVEL_NONE:
{
}
default:
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
level = Dali::WindowNotificationLevel::NONE;
break;
}
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetNotificationLevel: level [%d]\n", mNotificationLevel);
return level;
}
-void WindowBaseEcoreWl::SetOpaqueState( bool opaque )
+void WindowBaseEcoreWl::SetOpaqueState(bool opaque)
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
- tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
+ tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
}
bool WindowBaseEcoreWl::SetScreenOffMode(WindowScreenOffMode screenOffMode)
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
- mScreenOffModeChangeDone = false;
+ mScreenOffModeChangeDone = false;
mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
unsigned int mode = 0;
- switch( screenOffMode )
+ switch(screenOffMode)
{
case WindowScreenOffMode::TIMEOUT:
{
}
}
- tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl_window_surface_get( mEcoreWindow ), mode );
+ tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl_window_surface_get(mEcoreWindow), mode);
int count = 0;
- while( !mScreenOffModeChangeDone && count < 3 )
+ while(!mScreenOffModeChangeDone && count < 3)
{
ecore_wl_flush();
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mScreenOffModeChangeDone )
+ if(!mScreenOffModeChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
return false;
}
- else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
return false;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
return true;
}
WindowScreenOffMode WindowBaseEcoreWl::GetScreenOffMode() const
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int count = 0;
- while( !mScreenOffModeChangeDone && count < 3 )
+ while(!mScreenOffModeChangeDone && count < 3)
{
ecore_wl_flush();
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mScreenOffModeChangeDone )
+ if(!mScreenOffModeChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
return WindowScreenOffMode::TIMEOUT;
}
WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
- switch( mScreenOffMode )
+ switch(mScreenOffMode)
{
case 0:
{
}
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
return screenMode;
}
-bool WindowBaseEcoreWl::SetBrightness( int brightness )
+bool WindowBaseEcoreWl::SetBrightness(int brightness)
{
- while( !mTizenDisplayPolicy )
+ while(!mTizenDisplayPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
- mBrightnessChangeDone = false;
+ mBrightnessChangeDone = false;
mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
- tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl_window_surface_get( mEcoreWindow ), brightness );
+ tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl_window_surface_get(mEcoreWindow), brightness);
int count = 0;
- while( !mBrightnessChangeDone && count < 3 )
+ while(!mBrightnessChangeDone && count < 3)
{
ecore_wl_flush();
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mBrightnessChangeDone )
+ if(!mBrightnessChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
return false;
}
- else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Permission denied! [%d]\n", brightness);
return false;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::SetBrightness: Brightness is changed [%d]\n", mBrightness);
return true;
}
int WindowBaseEcoreWl::GetBrightness() const
{
- while( !mTizenDisplayPolicy )
+ while(!mTizenDisplayPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int count = 0;
- while( !mBrightnessChangeDone && count < 3 )
+ while(!mBrightnessChangeDone && count < 3)
{
ecore_wl_flush();
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mBrightnessChangeDone )
+ if(!mBrightnessChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
return 0;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl::GetBrightness: Brightness [%d]\n", mBrightness);
return mBrightness;
}
-bool WindowBaseEcoreWl::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+bool WindowBaseEcoreWl::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
{
Ecore_Wl_Window_Keygrab_Mode mode;
- switch( grabMode )
+ switch(grabMode)
{
case KeyGrab::TOPMOST:
{
}
}
- return ecore_wl_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
+ return ecore_wl_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
}
-bool WindowBaseEcoreWl::UngrabKey( Dali::KEY key )
+bool WindowBaseEcoreWl::UngrabKey(Dali::KEY key)
{
- return ecore_wl_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
+ return ecore_wl_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
}
-bool WindowBaseEcoreWl::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+bool WindowBaseEcoreWl::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
{
- int keyCount = key.Count();
+ int keyCount = key.Count();
int keyGrabModeCount = grabMode.Count();
- if( keyCount != keyGrabModeCount || keyCount == 0 )
+ if(keyCount != keyGrabModeCount || keyCount == 0)
{
return false;
}
eina_init();
- Eina_List* keyList = NULL;
- Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
+ Eina_List* keyList = NULL;
+ Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
- for( int index = 0; index < keyCount; ++index )
+ for(int index = 0; index < keyCount; ++index)
{
- info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
+ info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
- switch( grabMode[index] )
+ switch(grabMode[index])
{
case KeyGrab::TOPMOST:
{
}
}
- keyList = eina_list_append( keyList, &info );
+ keyList = eina_list_append(keyList, &info);
}
- Eina_List* grabList = ecore_wl_window_keygrab_list_set( mEcoreWindow, keyList );
+ Eina_List* grabList = ecore_wl_window_keygrab_list_set(mEcoreWindow, keyList);
- result.Resize( keyCount, true );
+ result.Resize(keyCount, true);
- Eina_List* l = NULL;
- Eina_List* m = NULL;
- void* listData = NULL;
- void* data = NULL;
- if( grabList != NULL )
+ Eina_List* l = NULL;
+ Eina_List* m = NULL;
+ void* listData = NULL;
+ void* data = NULL;
+ if(grabList != NULL)
{
- EINA_LIST_FOREACH( grabList, m, data )
+ EINA_LIST_FOREACH(grabList, m, data)
{
int index = 0;
- EINA_LIST_FOREACH( keyList, l, listData )
+ EINA_LIST_FOREACH(keyList, l, listData)
{
- if( static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key == NULL )
+ if(static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key == NULL)
{
- DALI_LOG_ERROR( "input key list has null data!" );
+ DALI_LOG_ERROR("input key list has null data!");
break;
}
- if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
+ if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
{
result[index] = false;
}
}
}
- delete [] info;
+ delete[] info;
- eina_list_free( keyList );
- eina_list_free( grabList );
+ eina_list_free(keyList);
+ eina_list_free(grabList);
eina_shutdown();
return true;
}
-bool WindowBaseEcoreWl::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+bool WindowBaseEcoreWl::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
{
int keyCount = key.Count();
- if( keyCount == 0 )
+ if(keyCount == 0)
{
return false;
}
eina_init();
- Eina_List* keyList = NULL;
- Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
+ Eina_List* keyList = NULL;
+ Ecore_Wl_Window_Keygrab_Info* info = new Ecore_Wl_Window_Keygrab_Info[keyCount];
- for( int index = 0; index < keyCount; ++index )
+ for(int index = 0; index < keyCount; ++index)
{
- info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
- keyList = eina_list_append( keyList, &info );
+ info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
+ keyList = eina_list_append(keyList, &info);
}
- Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset( mEcoreWindow, keyList );
+ Eina_List* ungrabList = ecore_wl_window_keygrab_list_unset(mEcoreWindow, keyList);
- result.Resize( keyCount, true );
+ result.Resize(keyCount, true);
- Eina_List* l = NULL;
- Eina_List* m = NULL;
- void *listData = NULL;
- void *data = NULL;
+ Eina_List* l = NULL;
+ Eina_List* m = NULL;
+ void* listData = NULL;
+ void* data = NULL;
- if( ungrabList != NULL )
+ if(ungrabList != NULL)
{
- EINA_LIST_FOREACH( ungrabList, m, data )
+ EINA_LIST_FOREACH(ungrabList, m, data)
{
int index = 0;
- EINA_LIST_FOREACH( keyList, l, listData )
+ EINA_LIST_FOREACH(keyList, l, listData)
{
- if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl_Window_Keygrab_Info* >( listData )->key ) == 0 )
+ if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl_Window_Keygrab_Info*>(listData)->key) == 0)
{
result[index] = false;
}
}
}
- delete [] info;
+ delete[] info;
- eina_list_free( keyList );
- eina_list_free( ungrabList );
+ eina_list_free(keyList);
+ eina_list_free(ungrabList);
eina_shutdown();
return true;
}
-void WindowBaseEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void WindowBaseEcoreWl::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
// calculate DPI
float xres, yres;
xres = ecore_wl_dpi_get();
yres = ecore_wl_dpi_get();
- dpiHorizontal = int( xres + 0.5f ); // rounding
- dpiVertical = int( yres + 0.5f );
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
}
int WindowBaseEcoreWl::GetOrientation() const
{
int transform = 0;
- if( ecore_wl_window_ignore_output_transform_get( mEcoreWindow ) )
+ if(ecore_wl_window_ignore_output_transform_get(mEcoreWindow))
{
transform = 0;
}
else
{
- transform = ecore_wl_output_transform_get( ecore_wl_window_output_find( mEcoreWindow ) );
+ transform = ecore_wl_output_transform_get(ecore_wl_window_output_find(mEcoreWindow));
}
mScreenRotationAngle = transform * 90;
return mScreenRotationAngle;
}
-void WindowBaseEcoreWl::SetWindowRotationAngle( int degree )
+void WindowBaseEcoreWl::SetWindowRotationAngle(int degree)
{
mWindowRotationAngle = degree;
- ecore_wl_window_rotation_set( mEcoreWindow, degree );
+ ecore_wl_window_rotation_set(mEcoreWindow, degree);
}
-void WindowBaseEcoreWl::WindowRotationCompleted( int degree, int width, int height )
+void WindowBaseEcoreWl::WindowRotationCompleted(int degree, int width, int height)
{
- ecore_wl_window_rotation_change_done_send( mEcoreWindow );
+ ecore_wl_window_rotation_change_done_send(mEcoreWindow);
}
-void WindowBaseEcoreWl::SetTransparency( bool transparent )
+void WindowBaseEcoreWl::SetTransparency(bool transparent)
{
- ecore_wl_window_alpha_set( mEcoreWindow, transparent );
+ ecore_wl_window_alpha_set(mEcoreWindow, transparent);
}
void WindowBaseEcoreWl::InitializeEcoreElDBus()
{
#ifdef DALI_ELDBUS_AVAILABLE
Eldbus_Object* object;
- Eldbus_Proxy* manager;
+ Eldbus_Proxy* manager;
- if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
+ if(!(mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
{
- DALI_LOG_ERROR( "Unable to get system bus\n" );
+ DALI_LOG_ERROR("Unable to get system bus\n");
}
- object = eldbus_object_get( mSystemConnection, BUS, PATH );
- if( !object )
+ object = eldbus_object_get(mSystemConnection, BUS, PATH);
+ if(!object)
{
- DALI_LOG_ERROR( "Getting object failed\n" );
+ DALI_LOG_ERROR("Getting object failed\n");
return;
}
- manager = eldbus_proxy_get( object, INTERFACE );
- if( !manager )
+ manager = eldbus_proxy_get(object, INTERFACE);
+ if(!manager)
{
- DALI_LOG_ERROR( "Getting proxy failed\n" );
+ DALI_LOG_ERROR("Getting proxy failed\n");
return;
}
- if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
+ if(!eldbus_proxy_signal_handler_add(manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this))
{
- DALI_LOG_ERROR( "No signal handler returned\n" );
+ DALI_LOG_ERROR("No signal handler returned\n");
}
#endif
}
-void WindowBaseEcoreWl::CreateWindow( PositionSize positionSize )
+void WindowBaseEcoreWl::CreateWindow(PositionSize positionSize)
{
- mEcoreWindow = ecore_wl_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW );
+ mEcoreWindow = ecore_wl_window_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
- if ( mEcoreWindow == 0 )
+ if(mEcoreWindow == 0)
{
- DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
+ DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
}
}
-void WindowBaseEcoreWl::SetParent( WindowBase* parentWinBase )
+void WindowBaseEcoreWl::SetParent(WindowBase* parentWinBase)
{
Ecore_Wl_Window* ecoreParent = NULL;
- if( parentWinBase )
+ if(parentWinBase)
{
- WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>( parentWinBase );
- ecoreParent = winBaseEcore->mEcoreWindow;
+ WindowBaseEcoreWl* winBaseEcore = static_cast<WindowBaseEcoreWl*>(parentWinBase);
+ ecoreParent = winBaseEcore->mEcoreWindow;
}
- ecore_wl_window_parent_set( mEcoreWindow, ecoreParent );
+ ecore_wl_window_parent_set(mEcoreWindow, ecoreParent);
}
int WindowBaseEcoreWl::CreateFrameRenderedSyncFence()
/*
- * Copyright (c) 2018 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.
#include <dali/internal/window-system/tizen-wayland/ecore-wl/window-factory-ecore-wl.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h>
#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/tizen-wayland/ecore-wl/window-base-ecore-wl.h>
namespace Dali
{
{
namespace Adaptor
{
-
-std::unique_ptr< WindowBase > WindowFactoryEcoreWl::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowBase> WindowFactoryEcoreWl::CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowBaseEcoreWl >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowBaseEcoreWl>(positionSize, surface, isTransparent);
}
// this should be created from Window impl
-std::unique_ptr< WindowFactory > GetWindowFactory()
+std::unique_ptr<WindowFactory> GetWindowFactory()
{
// returns Window factory
- return Utils::MakeUnique< WindowFactoryEcoreWl >();
+ return Utils::MakeUnique<WindowFactoryEcoreWl>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace WindowSystem
{
-
void Initialize()
{
- ecore_wl_init( NULL );
+ ecore_wl_init(NULL);
}
void Shutdown()
ecore_wl_shutdown();
}
-void GetScreenSize( int& width, int& height )
+void GetScreenSize(int& width, int& height)
{
- ecore_wl_screen_size_get( &width, &height );
+ ecore_wl_screen_size_get(&width, &height);
}
-bool SetKeyboardRepeatInfo( float rate, float delay )
+bool SetKeyboardRepeatInfo(float rate, float delay)
{
- return ecore_wl_keyboard_repeat_info_set( static_cast<double>( rate ), static_cast<double>( delay ) );
+ return ecore_wl_keyboard_repeat_info_set(static_cast<double>(rate), static_cast<double>(delay));
}
-bool GetKeyboardRepeatInfo( float& rate, float& delay )
+bool GetKeyboardRepeatInfo(float& rate, float& delay)
{
double rateVal, delayVal;
- bool ret = ecore_wl_keyboard_repeat_info_get( &rateVal, &delayVal );
- rate = static_cast<float>( rateVal );
- delay = static_cast<float>( delayVal );
+ bool ret = ecore_wl_keyboard_repeat_info_get(&rateVal, &delayVal);
+ rate = static_cast<float>(rateVal);
+ delay = static_cast<float>(delayVal);
return ret;
}
/*
- * 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.
#include <dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.h>
// INTERNAL HEADERS
+#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/common/pixmap-render-surface.h>
#include <dali/internal/window-system/common/window-render-surface.h>
#include <dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h>
-#include <dali/internal/window-system/common/pixmap-render-surface.h>
-#include <dali/internal/window-system/common/display-utils.h>
// EXTERNAL INCLUDES
#include <memory>
{
namespace Adaptor
{
-
-std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryEcoreWl2::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowRenderSurface> RenderSurfaceFactoryEcoreWl2::CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowRenderSurface>(positionSize, surface, isTransparent);
}
-std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreWl2::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<PixmapRenderSurface> RenderSurfaceFactoryEcoreWl2::CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return std::unique_ptr< PixmapRenderSurface >( nullptr );
+ return std::unique_ptr<PixmapRenderSurface>(nullptr);
}
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl2::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+std::unique_ptr<NativeRenderSurface> RenderSurfaceFactoryEcoreWl2::CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( surfaceSize, surface, isTransparent );
+ return Utils::MakeUnique<NativeRenderSurfaceEcoreWl>(surfaceSize, surface, isTransparent);
}
// this should be created from somewhere
-std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
{
// returns Window factory
- return Utils::MakeUnique< RenderSurfaceFactoryEcoreWl2 >();
+ return Utils::MakeUnique<RenderSurfaceFactoryEcoreWl2>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2019 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.
#include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
// INTERNAL HEADERS
+#include <dali/internal/input/common/key-impl.h>
#include <dali/internal/window-system/common/window-impl.h>
-#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/common/window-render-surface.h>
-#include <dali/internal/input/common/key-impl.h>
+#include <dali/internal/window-system/common/window-system.h>
// EXTERNAL_HEADERS
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/events/mouse-button.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
-#include <dali/integration-api/debug.h>
#include <Ecore_Input.h>
-#include <vconf.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
+#include <dali/public-api/events/mouse-button.h>
+#include <dali/public-api/object/any.h>
#include <vconf-keys.h>
+#include <vconf.h>
#include <wayland-egl-tizen.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
#endif
-const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
-const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
+const uint32_t MAX_TIZEN_CLIENT_VERSION = 7;
+const unsigned int PRIMARY_TOUCH_BUTTON_ID = 1;
-const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
+const char* DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME = "db/setting/accessibility/font_name"; // It will be update at vconf-key.h and replaced.
// DBUS accessibility
-const char* BUS = "org.enlightenment.wm-screen-reader";
+const char* BUS = "org.enlightenment.wm-screen-reader";
const char* INTERFACE = "org.tizen.GestureNavigation";
-const char* PATH = "/org/tizen/GestureNavigation";
+const char* PATH = "/org/tizen/GestureNavigation";
struct KeyCodeMap
{
- xkb_keysym_t keySym;
+ xkb_keysym_t keySym;
xkb_keycode_t keyCode;
- bool isKeyCode;
+ bool isKeyCode;
};
/**
* Get the device name from the provided ecore key event
*/
-void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
+void GetDeviceName(Ecore_Event_Key* keyEvent, std::string& result)
{
- const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
+ const char* ecoreDeviceName = ecore_device_name_get(keyEvent->dev);
- if( ecoreDeviceName )
+ if(ecoreDeviceName)
{
result = ecoreDeviceName;
}
/**
* Get the device class from the provided ecore event
*/
-void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
+void GetDeviceClass(Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass)
{
- switch( ecoreDeviceClass )
+ switch(ecoreDeviceClass)
{
case ECORE_DEVICE_CLASS_SEAT:
{
}
}
-void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
+void GetDeviceSubclass(Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass)
{
- switch( ecoreDeviceSubclass )
+ switch(ecoreDeviceSubclass)
{
case ECORE_DEVICE_SUBCLASS_FINGER:
{
}
}
-
-void FindKeyCode( struct xkb_keymap* keyMap, xkb_keycode_t key, void* data )
+void FindKeyCode(struct xkb_keymap* keyMap, xkb_keycode_t key, void* data)
{
- KeyCodeMap* foundKeyCode = static_cast< KeyCodeMap* >( data );
- if( foundKeyCode->isKeyCode )
+ KeyCodeMap* foundKeyCode = static_cast<KeyCodeMap*>(data);
+ if(foundKeyCode->isKeyCode)
{
return;
}
- xkb_keysym_t keySym = foundKeyCode->keySym;
- int nsyms = 0;
+ xkb_keysym_t keySym = foundKeyCode->keySym;
+ int nsyms = 0;
const xkb_keysym_t* symsOut = NULL;
- nsyms = xkb_keymap_key_get_syms_by_level( keyMap, key, 0, 0, &symsOut );
+ nsyms = xkb_keymap_key_get_syms_by_level(keyMap, key, 0, 0, &symsOut);
- if( nsyms && symsOut )
+ if(nsyms && symsOut)
{
- if( *symsOut == keySym )
+ if(*symsOut == keySym)
{
- foundKeyCode->keyCode = key;
+ foundKeyCode->keyCode = key;
foundKeyCode->isKeyCode = true;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/// Called when the window iconify state is changed.
-static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowIconifyStateChanged(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- return windowBase->OnIconifyStateChanged( data, type, event );
+ return windowBase->OnIconifyStateChanged(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the window gains focus
-static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- return windowBase->OnFocusIn( data, type, event );
+ return windowBase->OnFocusIn(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the window loses focus
-static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- return windowBase->OnFocusOut( data, type, event );
+ return windowBase->OnFocusOut(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the output is transformed
-static Eina_Bool EcoreEventOutputTransform( void* data, int type, void* event )
+static Eina_Bool EcoreEventOutputTransform(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- return windowBase->OnOutputTransform( data, type, event );
+ return windowBase->OnOutputTransform(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/// Called when the output transform should be ignored
-static Eina_Bool EcoreEventIgnoreOutputTransform( void* data, int type, void* event )
+static Eina_Bool EcoreEventIgnoreOutputTransform(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- return windowBase->OnIgnoreOutputTransform( data, type, event );
+ return windowBase->OnIgnoreOutputTransform(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
/**
* Called when rotate event is recevied.
*/
-static Eina_Bool EcoreEventRotate( void* data, int type, void* event )
+static Eina_Bool EcoreEventRotate(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::EcoreEventRotate\n" );
- windowBase->OnRotation( data, type, event );
+ DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::EcoreEventRotate\n");
+ windowBase->OnRotation(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when configure event is recevied.
*/
-static Eina_Bool EcoreEventConfigure( void* data, int type, void* event )
+static Eina_Bool EcoreEventConfigure(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnConfiguration( data, type, event );
+ windowBase->OnConfiguration(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch down is received.
*/
-static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonDown( data, type, event );
+ windowBase->OnMouseButtonDown(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch up is received.
*/
-static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonUp( data, type, event );
+ windowBase->OnMouseButtonUp(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch motion is received.
*/
-static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonMove( data, type, event );
+ windowBase->OnMouseButtonMove(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch is canceled.
*/
-static Eina_Bool EcoreEventMouseButtonCancel( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonCancel(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonCancel( data, type, event );
+ windowBase->OnMouseButtonCancel(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a mouse wheel is received.
*/
-static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnMouseWheel( data, type, event );
+ windowBase->OnMouseWheel(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a detent rotation event is recevied.
*/
-static Eina_Bool EcoreEventDetentRotation( void* data, int type, void* event )
+static Eina_Bool EcoreEventDetentRotation(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnDetentRotation( data, type, event );
+ windowBase->OnDetentRotation(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a key down is received.
*/
-static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
+static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnKeyDown( data, type, event );
+ windowBase->OnKeyDown(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a key up is received.
*/
-static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
+static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnKeyUp( data, type, event );
+ windowBase->OnKeyUp(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when the source window notifies us the content in clipboard is selected.
*/
-static Eina_Bool EcoreEventDataSend( void* data, int type, void* event )
+static Eina_Bool EcoreEventDataSend(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnDataSend( data, type, event );
+ windowBase->OnDataSend(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
* Called when the source window sends us about the selected content.
* For example, when item is selected in the clipboard.
*/
-static Eina_Bool EcoreEventDataReceive( void* data, int type, void* event )
+static Eina_Bool EcoreEventDataReceive(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->OnDataReceive( data, type, event );
+ windowBase->OnDataReceive(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when transition animation of the window's shown/hidden is started by window manager.
*/
-static Eina_Bool EcoreEventEffectStart(void *data, int type, void *event)
+static Eina_Bool EcoreEventEffectStart(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- Ecore_Wl2_Event_Effect_Start *effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ Ecore_Wl2_Event_Effect_Start* effectStart = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectStart, effect type[ %d ]\n", effectStart->type);
+ if(windowBase)
{
- if( effectStart->type < 3 ) // only under restack
+ if(effectStart->type < 3) // only under restack
{
- windowBase->OnTransitionEffectEvent( WindowEffectState::START, static_cast<WindowEffectType>( effectStart->type ) );
+ windowBase->OnTransitionEffectEvent(WindowEffectState::START, static_cast<WindowEffectType>(effectStart->type));
}
}
return ECORE_CALLBACK_PASS_ON;
/**
* Called when transition animation of the window's shown/hidden is ended by window manager.
*/
-static Eina_Bool EcoreEventEffectEnd(void *data, int type, void *event)
+static Eina_Bool EcoreEventEffectEnd(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Effect_Start *effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>( event );
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type );
- if( windowBase )
+ Ecore_Wl2_Event_Effect_Start* effectEnd = static_cast<Ecore_Wl2_Event_Effect_Start*>(event);
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventEffectEnd, effect type[ %d ]\n", effectEnd->type);
+ if(windowBase)
{
- if( effectEnd->type < 3 ) // only under restack
+ if(effectEnd->type < 3) // only under restack
{
- windowBase->OnTransitionEffectEvent( WindowEffectState::END, static_cast<WindowEffectType>( effectEnd->type ) );
+ windowBase->OnTransitionEffectEvent(WindowEffectState::END, static_cast<WindowEffectType>(effectEnd->type));
}
}
return ECORE_CALLBACK_PASS_ON;
// Keyboard Repeat Settings Changed Callbacks
/////////////////////////////////////////////////////////////////////////////////////////////////
-static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void *data, int type, void *event)
+static Eina_Bool EcoreEventSeatKeyboardRepeatChanged(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed *keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>( event );
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id );
- if( windowBase )
- {
- windowBase->OnKeyboardRepeatSettingsChanged();
- }
+ Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed* keyboardRepeat = static_cast<Ecore_Wl2_Event_Seat_Keyboard_Repeat_Changed*>(event);
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventSeatKeyboardRepeatChanged, id[ %d ]\n", keyboardRepeat->id);
+ if(windowBase)
+ {
+ windowBase->OnKeyboardRepeatSettingsChanged();
+ }
return ECORE_CALLBACK_RENEW;
}
// Keymap Changed Callbacks
/////////////////////////////////////////////////////////////////////////////////////////////////
-static Eina_Bool EcoreEventSeatKeymapChanged(void *data, int type, void *event)
+static Eina_Bool EcoreEventSeatKeymapChanged(void* data, int type, void* event)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->KeymapChanged( data, type, event );
+ windowBase->KeymapChanged(data, type, event);
}
return ECORE_CALLBACK_RENEW;
/**
* Called when a font name is changed.
*/
-static void VconfNotifyFontNameChanged( keynode_t* node, void* data )
+static void VconfNotifyFontNameChanged(keynode_t* node, void* data)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
windowBase->OnFontNameChanged();
}
/**
* Called when a font size is changed.
*/
-static void VconfNotifyFontSizeChanged( keynode_t* node, void* data )
+static void VconfNotifyFontSizeChanged(keynode_t* node, void* data)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
windowBase->OnFontSizeChanged();
}
// Window Redraw Request Event Callbacks
/////////////////////////////////////////////////////////////////////////////////////////////////
-static Eina_Bool EcoreEventWindowRedrawRequest(void *data, int type, void *event)
+static Eina_Bool EcoreEventWindowRedrawRequest(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Window_Redraw_Request *windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request *>(event);
- WindowBaseEcoreWl2 *windowBase = static_cast<WindowBaseEcoreWl2 *>(data);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win );
- if ( windowBase )
+ Ecore_Wl2_Event_Window_Redraw_Request* windowRedrawRequest = static_cast<Ecore_Wl2_Event_Window_Redraw_Request*>(event);
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::EcoreEventWindowRedrawRequest, window[ %d ]\n", windowRedrawRequest->win);
+ if(windowBase)
{
windowBase->OnEcoreEventWindowRedrawRequest();
}
#ifdef DALI_ELDBUS_AVAILABLE
// Callback for Ecore ElDBus accessibility events.
-static void EcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
+static void EcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( context );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(context);
+ if(windowBase)
{
- windowBase->OnEcoreElDBusAccessibilityNotification( context, message );
+ windowBase->OnEcoreElDBusAccessibilityNotification(context, message);
}
}
#endif // DALI_ELDBUS_AVAILABLE
-static void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
+static void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->RegistryGlobalCallback( data, registry, name, interface, version );
+ windowBase->RegistryGlobalCallback(data, registry, name, interface, version);
}
}
-static void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
+static void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->RegistryGlobalCallbackRemove( data, registry, id );
+ windowBase->RegistryGlobalCallbackRemove(data, registry, id);
}
}
-static void TizenPolicyConformant( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant )
+static void TizenPolicyConformant(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t isConformant)
{
}
-static void TizenPolicyConformantArea( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h )
+static void TizenPolicyConformantArea(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
{
}
-static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
+static void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->TizenPolicyNotificationChangeDone( data, tizenPolicy, surface, level, state );
+ windowBase->TizenPolicyNotificationChangeDone(data, tizenPolicy, surface, level, state);
}
}
-static void TizenPolicyTransientForDone( void* data, struct tizen_policy* tizenPolicy, uint32_t childId )
+static void TizenPolicyTransientForDone(void* data, struct tizen_policy* tizenPolicy, uint32_t childId)
{
}
-static void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
+static void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->TizenPolicyScreenModeChangeDone( data, tizenPolicy, surface, mode, state );
+ windowBase->TizenPolicyScreenModeChangeDone(data, tizenPolicy, surface, mode, state);
}
}
-static void TizenPolicyIconifyStateChanged( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force )
+static void TizenPolicyIconifyStateChanged(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t iconified, uint32_t force)
{
}
-static void TizenPolicySupportedAuxiliaryHints( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints )
+static void TizenPolicySupportedAuxiliaryHints(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, struct wl_array* hints, uint32_t numNints)
{
}
-static void TizenPolicyAllowedAuxiliaryHint( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id )
+static void TizenPolicyAllowedAuxiliaryHint(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int id)
{
}
-static void TizenPolicyAuxiliaryMessage( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options )
+static void TizenPolicyAuxiliaryMessage(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, const char* key, const char* val, struct wl_array* options)
{
}
-static void TizenPolicyConformantRegion( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial )
+static void TizenPolicyConformantRegion(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial)
{
}
-static void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
+static void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
{
- WindowBaseEcoreWl2* windowBase = static_cast< WindowBaseEcoreWl2* >( data );
- if( windowBase )
+ WindowBaseEcoreWl2* windowBase = static_cast<WindowBaseEcoreWl2*>(data);
+ if(windowBase)
{
- windowBase->DisplayPolicyBrightnessChangeDone( data, displayPolicy, surface, brightness, state );
+ windowBase->DisplayPolicyBrightnessChangeDone(data, displayPolicy, surface, brightness, state);
}
}
const struct wl_registry_listener registryListener =
-{
- RegistryGlobalCallback,
- RegistryGlobalCallbackRemove
-};
+ {
+ RegistryGlobalCallback,
+ RegistryGlobalCallbackRemove};
const struct tizen_policy_listener tizenPolicyListener =
-{
- TizenPolicyConformant,
- TizenPolicyConformantArea,
- TizenPolicyNotificationChangeDone,
- TizenPolicyTransientForDone,
- TizenPolicyScreenModeChangeDone,
- TizenPolicyIconifyStateChanged,
- TizenPolicySupportedAuxiliaryHints,
- TizenPolicyAllowedAuxiliaryHint,
- TizenPolicyAuxiliaryMessage,
- TizenPolicyConformantRegion
-};
+ {
+ TizenPolicyConformant,
+ TizenPolicyConformantArea,
+ TizenPolicyNotificationChangeDone,
+ TizenPolicyTransientForDone,
+ TizenPolicyScreenModeChangeDone,
+ TizenPolicyIconifyStateChanged,
+ TizenPolicySupportedAuxiliaryHints,
+ TizenPolicyAllowedAuxiliaryHint,
+ TizenPolicyAuxiliaryMessage,
+ TizenPolicyConformantRegion};
const struct tizen_display_policy_listener tizenDisplayPolicyListener =
-{
- DisplayPolicyBrightnessChangeDone
-};
+ {
+ DisplayPolicyBrightnessChangeDone};
} // unnamed namespace
WindowBaseEcoreWl2::~WindowBaseEcoreWl2()
{
#ifdef DALI_ELDBUS_AVAILABLE
- // Close down ElDBus connections.
- if( mSystemConnection )
- {
- eldbus_connection_unref( mSystemConnection );
- }
+ // Close down ElDBus connections.
+ if(mSystemConnection)
+ {
+ eldbus_connection_unref(mSystemConnection);
+ }
#endif // DALI_ELDBUS_AVAILABLE
- vconf_ignore_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged );
- vconf_ignore_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged );
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged);
+ vconf_ignore_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged);
- for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
+ for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
{
- ecore_event_handler_del( *iter );
+ ecore_event_handler_del(*iter);
}
mEcoreEventHandler.Clear();
- if( mEventQueue )
+ if(mEventQueue)
{
- wl_event_queue_destroy( mEventQueue );
+ wl_event_queue_destroy(mEventQueue);
}
mSupportedAuxiliaryHints.clear();
mAuxiliaryHints.clear();
- if( mEglWindow != NULL )
+ if(mEglWindow != NULL)
{
- wl_egl_window_destroy( mEglWindow );
+ wl_egl_window_destroy(mEglWindow);
mEglWindow = NULL;
}
- if( mOwnSurface )
+ if(mOwnSurface)
{
- ecore_wl2_window_free( mEcoreWindow );
+ ecore_wl2_window_free(mEcoreWindow);
WindowSystem::Shutdown();
}
}
-void WindowBaseEcoreWl2::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
{
- if( surface.Empty() == false )
+ if(surface.Empty() == false)
{
// check we have a valid type
- DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (Ecore_Wl2_Window *) ) && "Surface type is invalid" );
+ DALI_ASSERT_ALWAYS((surface.GetType() == typeid(Ecore_Wl2_Window*)) && "Surface type is invalid");
- mEcoreWindow = AnyCast< Ecore_Wl2_Window* >( surface );
+ mEcoreWindow = AnyCast<Ecore_Wl2_Window*>(surface);
}
else
{
WindowSystem::Initialize();
mOwnSurface = true;
- CreateWindow( positionSize );
+ CreateWindow(positionSize);
}
- mWlSurface = ecore_wl2_window_surface_get( mEcoreWindow );
+ mWlSurface = ecore_wl2_window_surface_get(mEcoreWindow);
- SetTransparency( isTransparent );
+ SetTransparency(isTransparent);
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM, EcoreEventOutputTransform, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM, EcoreEventIgnoreOutputTransform, this));
// Register Rotate event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE, EcoreEventRotate, this));
// Register Configure event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, EcoreEventConfigure, this));
// Register Touch events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, this));
// Register Mouse wheel events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
// Register Detent event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_DETENT_ROTATE, EcoreEventDetentRotation, this));
// Register Key events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
// Register Selection event - clipboard selection
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY, EcoreEventDataReceive, this));
// Register Effect Start/End event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_START, EcoreEventEffectStart, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_EFFECT_END, EcoreEventEffectEnd, this));
// Register Keyboard repeat event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYBOARD_REPEAT_CHANGED, EcoreEventSeatKeyboardRepeatChanged, this));
// Register Window redraw request event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_REDRAW_REQUEST, EcoreEventWindowRedrawRequest, this));
// Register Vconf notify - font name and size
- vconf_notify_key_changed( DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this );
- vconf_notify_key_changed( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this );
+ vconf_notify_key_changed(DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, VconfNotifyFontNameChanged, this);
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, VconfNotifyFontSizeChanged, this);
InitializeEcoreElDBus();
- Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
- mDisplay = ecore_wl2_display_get( display );
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+ mDisplay = ecore_wl2_display_get(display);
- if( mDisplay )
+ if(mDisplay)
{
- wl_display* displayWrapper = static_cast< wl_display* >( wl_proxy_create_wrapper( mDisplay ) );
- if( displayWrapper )
+ wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
+ if(displayWrapper)
{
- mEventQueue = wl_display_create_queue( mDisplay );
- if( mEventQueue )
+ mEventQueue = wl_display_create_queue(mDisplay);
+ if(mEventQueue)
{
- wl_proxy_set_queue( reinterpret_cast< wl_proxy* >( displayWrapper ), mEventQueue );
+ wl_proxy_set_queue(reinterpret_cast<wl_proxy*>(displayWrapper), mEventQueue);
- wl_registry* registry = wl_display_get_registry( displayWrapper );
- wl_registry_add_listener( registry, ®istryListener, this );
+ wl_registry* registry = wl_display_get_registry(displayWrapper);
+ wl_registry_add_listener(registry, ®istryListener, this);
}
- wl_proxy_wrapper_destroy( displayWrapper );
+ wl_proxy_wrapper_destroy(displayWrapper);
}
}
- Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( display );
+ Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
- if( ecoreWlInput )
+ if(ecoreWlInput)
{
- mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
+ mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
}
// get auxiliary hint
- Eina_List* hints = ecore_wl2_window_aux_hints_supported_get( mEcoreWindow );
- if( hints )
+ Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
+ if(hints)
{
- Eina_List* l = NULL;
- char* hint = NULL;
+ Eina_List* l = NULL;
+ char* hint = NULL;
- for( l = hints, ( hint = static_cast< char* >( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( hint = static_cast< char* >( eina_list_data_get(l) ) ) )
+ for(l = hints, (hint = static_cast<char*>(eina_list_data_get(l))); l; l = eina_list_next(l), (hint = static_cast<char*>(eina_list_data_get(l))))
{
- mSupportedAuxiliaryHints.push_back( hint );
+ mSupportedAuxiliaryHints.push_back(hint);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::Initialize: %s\n", hint);
}
}
}
-Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl2::OnIconifyStateChanged(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl2_Event_Window_Iconify_State_Change* >( event ) );
- Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+ Ecore_Wl2_Event_Window_Iconify_State_Change* iconifyChangedEvent(static_cast<Ecore_Wl2_Event_Window_Iconify_State_Change*>(event));
+ Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
- if( iconifyChangedEvent->win == static_cast< unsigned int>( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(iconifyChangedEvent->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- if( iconifyChangedEvent->iconified == EINA_TRUE )
+ if(iconifyChangedEvent->iconified == EINA_TRUE)
{
- mIconifyChangedSignal.Emit( true );
+ mIconifyChangedSignal.Emit(true);
}
else
{
- mIconifyChangedSignal.Emit( false );
+ mIconifyChangedSignal.Emit(false);
}
handled = ECORE_CALLBACK_DONE;
}
return handled;
}
-Eina_Bool WindowBaseEcoreWl2::OnFocusIn( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl2::OnFocusIn(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl2_Event_Focus_In* >( event ) );
+ Ecore_Wl2_Event_Focus_In* focusInEvent(static_cast<Ecore_Wl2_Event_Focus_In*>(event));
- if( focusInEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(focusInEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
- mFocusChangedSignal.Emit( true );
+ mFocusChangedSignal.Emit(true);
}
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool WindowBaseEcoreWl2::OnFocusOut( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl2::OnFocusOut(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl2_Event_Focus_Out* >( event ) );
+ Ecore_Wl2_Event_Focus_Out* focusOutEvent(static_cast<Ecore_Wl2_Event_Focus_Out*>(event));
- if( focusOutEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(focusOutEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
- mFocusChangedSignal.Emit( false );
+ mFocusChangedSignal.Emit(false);
}
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool WindowBaseEcoreWl2::OnOutputTransform( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl2::OnOutputTransform(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Output_Transform* transformEvent( static_cast< Ecore_Wl2_Event_Output_Transform* >( event ) );
+ Ecore_Wl2_Event_Output_Transform* transformEvent(static_cast<Ecore_Wl2_Event_Output_Transform*>(event));
- if( transformEvent->output == ecore_wl2_window_output_find( mEcoreWindow ) )
+ if(transformEvent->output == ecore_wl2_window_output_find(mEcoreWindow))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventOutputTransform\n", mEcoreWindow);
mScreenRotationAngle = GetScreenRotationAngle();
return ECORE_CALLBACK_PASS_ON;
}
-Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreWl2::OnIgnoreOutputTransform(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent( static_cast< Ecore_Wl2_Event_Ignore_Output_Transform* >( event ) );
+ Ecore_Wl2_Event_Ignore_Output_Transform* ignoreTransformEvent(static_cast<Ecore_Wl2_Event_Ignore_Output_Transform*>(event));
- if( ignoreTransformEvent->win == mEcoreWindow )
+ if(ignoreTransformEvent->win == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window (%p) EcoreEventIgnoreOutputTransform\n", mEcoreWindow);
mScreenRotationAngle = GetScreenRotationAngle();
}
}
-void WindowBaseEcoreWl2::OnConfiguration( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnConfiguration(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Window_Configure* ev( static_cast< Ecore_Wl2_Event_Window_Configure* >( event ) );
+ Ecore_Wl2_Event_Window_Configure* ev(static_cast<Ecore_Wl2_Event_Window_Configure*>(event));
- if( ev->win == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(ev->win == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
// Note: To comply with the wayland protocol, Dali should make an ack_configure
// by calling ecore_wl2_window_commit
}
}
-void WindowBaseEcoreWl2::OnMouseButtonDown( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnMouseButtonDown(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- Device::Class::Type deviceClass;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+ GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
- PointState::Type state ( PointState::DOWN );
+ PointState::Type state(PointState::DOWN);
- if( deviceClass != Device::Class::Type::MOUSE )
+ if(deviceClass != Device::Class::Type::MOUSE)
{
// Check if the buttons field is set and ensure it's the primary touch button.
// If this event was triggered by buttons other than the primary button (used for touch), then
// just send an interrupted event to Core.
- if( touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
+ if(touchEvent->buttons && (touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID))
{
state = PointState::INTERRUPTED;
}
}
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( state );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- point.SetDeviceClass( deviceClass );
- point.SetDeviceSubclass( deviceSubclass );
- point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(state);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ point.SetDeviceClass(deviceClass);
+ point.SetDeviceSubclass(deviceSubclass);
+ point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreWl2::OnMouseButtonUp( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnMouseButtonUp(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- Device::Class::Type deviceClass;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+ GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::UP );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- point.SetDeviceClass( deviceClass );
- point.SetDeviceSubclass( deviceSubclass );
- point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::UP);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ point.SetDeviceClass(deviceClass);
+ point.SetDeviceSubclass(deviceSubclass);
+ point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreWl2::OnMouseButtonMove( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnMouseButtonMove(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
+ Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- Device::Class::Type deviceClass;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+ GetDeviceClass(ecore_device_class_get(touchEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(touchEvent->dev), deviceSubclass);
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::MOTION );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- point.SetDeviceClass( deviceClass );
- point.SetDeviceSubclass( deviceSubclass );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::MOTION);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ point.SetDeviceClass(deviceClass);
+ point.SetDeviceSubclass(deviceSubclass);
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreWl2::OnMouseButtonCancel( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnMouseButtonCancel(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(touchEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::INTERRUPTED );
- point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::INTERRUPTED);
+ point.SetScreenPosition(Vector2(0.0f, 0.0f));
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseButtonCancel\n");
}
}
-void WindowBaseEcoreWl2::OnMouseWheel( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnMouseWheel(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
+ Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
- if( mouseWheelEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(mouseWheelEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
- Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( mouseWheelEvent->x, mouseWheelEvent->y ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
+ Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(mouseWheelEvent->x, mouseWheelEvent->y), mouseWheelEvent->z, mouseWheelEvent->timestamp);
- mWheelEventSignal.Emit( wheelEvent );
+ mWheelEventSignal.Emit(wheelEvent);
}
}
-void WindowBaseEcoreWl2::OnDetentRotation( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnDetentRotation(void* data, int type, void* event)
{
- Ecore_Event_Detent_Rotate* detentEvent = static_cast< Ecore_Event_Detent_Rotate* >( event );
+ Ecore_Event_Detent_Rotate* detentEvent = static_cast<Ecore_Event_Detent_Rotate*>(event);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::OnDetentRotation\n");
- int direction = ( detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE ) ? 1 : -1;
+ int direction = (detentEvent->direction == ECORE_DETENT_DIRECTION_CLOCKWISE) ? 1 : -1;
int timeStamp = detentEvent->timestamp;
- Integration::WheelEvent wheelEvent( Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2( 0.0f, 0.0f ), 0, timeStamp );
+ Integration::WheelEvent wheelEvent(Integration::WheelEvent::CUSTOM_WHEEL, direction, 0, Vector2(0.0f, 0.0f), 0, timeStamp);
- mWheelEventSignal.Emit( wheelEvent );
+ mWheelEventSignal.Emit(wheelEvent);
}
-void WindowBaseEcoreWl2::OnKeyDown( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnKeyDown(void* data, int type, void* event)
{
- Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
+ Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
- if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyDown\n");
- std::string keyName( keyEvent->keyname );
- std::string logicalKey( "" );
- std::string keyString( "" );
- std::string compose( "" );
+ std::string keyName(keyEvent->keyname);
+ std::string logicalKey("");
+ std::string keyString("");
+ std::string compose("");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
- if( keyEvent->compose )
+ if(keyEvent->compose)
{
compose = keyEvent->compose;
}
// Ensure key symbol is not NULL as keys like SHIFT have a null string.
- if( keyEvent->key )
+ if(keyEvent->key)
{
logicalKey = keyEvent->key;
}
int keyCode = 0;
- GetKeyCode( keyName, keyCode ); // Get key code dynamically.
+ GetKeyCode(keyName, keyCode); // Get key code dynamically.
- if( keyCode == 0 )
+ if(keyCode == 0)
{
// Get a specific key code from dali key look up table.
- keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
+ keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
}
- keyCode = ( keyCode == -1 ) ? 0 : keyCode;
- int modifier( keyEvent->modifiers );
+ keyCode = (keyCode == -1) ? 0 : keyCode;
+ int modifier(keyEvent->modifiers);
unsigned long time = keyEvent->timestamp;
- if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
+ if(!strncmp(keyEvent->keyname, "Keycode-", 8))
{
- keyCode = atoi( keyEvent->keyname + 8 );
+ keyCode = atoi(keyEvent->keyname + 8);
}
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- if( keyEvent->string )
+ if(keyEvent->string)
{
keyString = keyEvent->string;
}
- std::string deviceName;
- Device::Class::Type deviceClass;
+ std::string deviceName;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceName( keyEvent, deviceName );
- GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
+ GetDeviceName(keyEvent, deviceName);
+ GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
- Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass );
+ Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, deviceName, deviceClass, deviceSubclass);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseEcoreWl2::OnKeyUp( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnKeyUp(void* data, int type, void* event)
{
- Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
+ Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
- if( keyEvent->window == static_cast< unsigned int >( ecore_wl2_window_id_get( mEcoreWindow ) ) )
+ if(keyEvent->window == static_cast<unsigned int>(ecore_wl2_window_id_get(mEcoreWindow)))
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp\n");
#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) && (ECORE_VERSION_MINOR >= 23)
// Cancel processing flag is sent because this key event will combine with the previous key. So, the event should not actually perform anything.
- if( keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL )
+ if(keyEvent->event_flags & ECORE_EVENT_FLAG_CANCEL)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::OnKeyUp: This event flag indicates the event is canceled. \n");
return;
}
#endif // Since ecore 1.23 version
- std::string keyName( keyEvent->keyname );
- std::string logicalKey( "" );
- std::string keyString( "" );
- std::string compose( "" );
+ std::string keyName(keyEvent->keyname);
+ std::string logicalKey("");
+ std::string keyString("");
+ std::string compose("");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
- if( keyEvent->compose )
+ if(keyEvent->compose)
{
compose = keyEvent->compose;
}
// Ensure key symbol is not NULL as keys like SHIFT have a null string.
- if( keyEvent->key )
+ if(keyEvent->key)
{
logicalKey = keyEvent->key;
}
int keyCode = 0;
- GetKeyCode( keyName, keyCode ); // Get key code dynamically.
+ GetKeyCode(keyName, keyCode); // Get key code dynamically.
- if( keyCode == 0 )
+ if(keyCode == 0)
{
// Get a specific key code from dali key look up table.
- keyCode = KeyLookup::GetDaliKeyCode( keyEvent->keyname );
+ keyCode = KeyLookup::GetDaliKeyCode(keyEvent->keyname);
}
- keyCode = ( keyCode == -1 ) ? 0 : keyCode;
- int modifier( keyEvent->modifiers );
+ keyCode = (keyCode == -1) ? 0 : keyCode;
+ int modifier(keyEvent->modifiers);
unsigned long time = keyEvent->timestamp;
- if( !strncmp( keyEvent->keyname, "Keycode-", 8 ) )
+ if(!strncmp(keyEvent->keyname, "Keycode-", 8))
{
- keyCode = atoi( keyEvent->keyname + 8 );
+ keyCode = atoi(keyEvent->keyname + 8);
}
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- if( keyEvent->string )
+ if(keyEvent->string)
{
keyString = keyEvent->string;
}
- std::string deviceName;
- Device::Class::Type deviceClass;
+ std::string deviceName;
+ Device::Class::Type deviceClass;
Device::Subclass::Type deviceSubclass;
- GetDeviceName( keyEvent, deviceName );
- GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
- GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
+ GetDeviceName(keyEvent, deviceName);
+ GetDeviceClass(ecore_device_class_get(keyEvent->dev), deviceClass);
+ GetDeviceSubclass(ecore_device_subclass_get(keyEvent->dev), deviceSubclass);
- Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass );
+ Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, deviceName, deviceClass, deviceSubclass);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseEcoreWl2::OnDataSend( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnDataSend(void* data, int type, void* event)
{
- mSelectionDataSendSignal.Emit( event );
+ mSelectionDataSendSignal.Emit(event);
}
-void WindowBaseEcoreWl2::OnDataReceive( void* data, int type, void* event )
+void WindowBaseEcoreWl2::OnDataReceive(void* data, int type, void* event)
{
- mSelectionDataReceivedSignal.Emit( event );
+ mSelectionDataReceivedSignal.Emit(event);
}
void WindowBaseEcoreWl2::OnFontNameChanged()
{
- mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_CHANGE );
+ mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_CHANGE);
}
void WindowBaseEcoreWl2::OnFontSizeChanged()
{
- mStyleChangedSignal.Emit( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
+ mStyleChangedSignal.Emit(StyleChange::DEFAULT_FONT_SIZE_CHANGE);
}
-void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message )
+void WindowBaseEcoreWl2::OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message)
{
#ifdef DALI_ELDBUS_AVAILABLE
AccessibilityInfo info;
// The string defines the arg-list's respective types.
- if( !eldbus_message_arguments_get( message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime ) )
+ if(!eldbus_message_arguments_get(message, "iiiiiiu", &info.gestureValue, &info.startX, &info.startY, &info.endX, &info.endY, &info.state, &info.eventTime))
{
- DALI_LOG_ERROR( "OnEcoreElDBusAccessibilityNotification: Error getting arguments\n" );
+ DALI_LOG_ERROR("OnEcoreElDBusAccessibilityNotification: Error getting arguments\n");
}
- mAccessibilitySignal.Emit( info );
+ mAccessibilitySignal.Emit(info);
#endif
}
-void WindowBaseEcoreWl2::OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type )
+void WindowBaseEcoreWl2::OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type)
{
- mTransitionEffectEventSignal.Emit( state, type );
+ mTransitionEffectEventSignal.Emit(state, type);
}
void WindowBaseEcoreWl2::OnKeyboardRepeatSettingsChanged()
mWindowRedrawRequestSignal.Emit();
}
-void WindowBaseEcoreWl2::KeymapChanged(void *data, int type, void *event)
+void WindowBaseEcoreWl2::KeymapChanged(void* data, int type, void* event)
{
- Ecore_Wl2_Event_Seat_Keymap_Changed *changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>( event );
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id );
- Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get( changed->display );
- if( ecoreWlInput )
+ Ecore_Wl2_Event_Seat_Keymap_Changed* changed = static_cast<Ecore_Wl2_Event_Seat_Keymap_Changed*>(event);
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::KeymapChanged, keymap id[ %d ]\n", changed->id);
+ Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(changed->display);
+ if(ecoreWlInput)
{
- mKeyMap = ecore_wl2_input_keymap_get( ecoreWlInput );
+ mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
}
}
-void WindowBaseEcoreWl2::RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version )
+void WindowBaseEcoreWl2::RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version)
{
- if( strcmp( interface, tizen_policy_interface.name ) == 0 )
+ if(strcmp(interface, tizen_policy_interface.name) == 0)
{
- uint32_t clientVersion = std::min( version, MAX_TIZEN_CLIENT_VERSION );
+ uint32_t clientVersion = std::min(version, MAX_TIZEN_CLIENT_VERSION);
- mTizenPolicy = static_cast< tizen_policy* >( wl_registry_bind( registry, name, &tizen_policy_interface, clientVersion ) );
- if( !mTizenPolicy )
+ mTizenPolicy = static_cast<tizen_policy*>(wl_registry_bind(registry, name, &tizen_policy_interface, clientVersion));
+ if(!mTizenPolicy)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_policy_interface) is failed.\n");
return;
}
- tizen_policy_add_listener( mTizenPolicy, &tizenPolicyListener, data );
+ tizen_policy_add_listener(mTizenPolicy, &tizenPolicyListener, data);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_policy_add_listener is called.\n");
}
- else if( strcmp( interface, tizen_display_policy_interface.name ) == 0 )
+ else if(strcmp(interface, tizen_display_policy_interface.name) == 0)
{
- mTizenDisplayPolicy = static_cast< tizen_display_policy* >( wl_registry_bind( registry, name, &tizen_display_policy_interface, version ) );
- if( !mTizenDisplayPolicy )
+ mTizenDisplayPolicy = static_cast<tizen_display_policy*>(wl_registry_bind(registry, name, &tizen_display_policy_interface, version));
+ if(!mTizenDisplayPolicy)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: wl_registry_bind(tizen_display_policy_interface) is failed.\n");
return;
}
- tizen_display_policy_add_listener( mTizenDisplayPolicy, &tizenDisplayPolicyListener, data );
+ tizen_display_policy_add_listener(mTizenDisplayPolicy, &tizenDisplayPolicyListener, data);
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::RegistryGlobalCallback: tizen_display_policy_add_listener is called.\n");
}
}
-void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id )
+void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id)
{
- mTizenPolicy = NULL;
+ mTizenPolicy = NULL;
mTizenDisplayPolicy = NULL;
}
-void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state )
+void WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state)
{
- mNotificationLevel = level;
- mNotificationChangeState = state;
+ mNotificationLevel = level;
+ mNotificationChangeState = state;
mNotificationLevelChangeDone = true;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyNotificationChangeDone: level = %d, state = %d\n", level, state);
}
-void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state )
+void WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state)
{
- mScreenOffMode = mode;
+ mScreenOffMode = mode;
mScreenOffModeChangeState = state;
- mScreenOffModeChangeDone = true;
+ mScreenOffModeChangeDone = true;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::TizenPolicyScreenModeChangeDone: mode = %d, state = %d\n", mode, state);
}
-void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state )
+void WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state)
{
- mBrightness = brightness;
+ mBrightness = brightness;
mBrightnessChangeState = state;
- mBrightnessChangeDone = true;
+ mBrightnessChangeDone = true;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreWl2::DisplayPolicyBrightnessChangeDone: brightness = %d, state = %d\n", brightness, state);
}
-void WindowBaseEcoreWl2::GetKeyCode( std::string keyName, int32_t& keyCode )
+void WindowBaseEcoreWl2::GetKeyCode(std::string keyName, int32_t& keyCode)
{
xkb_keysym_t sym = XKB_KEY_NoSymbol;
- KeyCodeMap foundKeyCode;
+ KeyCodeMap foundKeyCode;
- sym = xkb_keysym_from_name( keyName.c_str(), XKB_KEYSYM_NO_FLAGS );
- if( sym == XKB_KEY_NoSymbol )
+ sym = xkb_keysym_from_name(keyName.c_str(), XKB_KEYSYM_NO_FLAGS);
+ if(sym == XKB_KEY_NoSymbol)
{
- DALI_LOG_ERROR( "Failed to get keysym in WindowBaseEcoreWl2\n" );
+ DALI_LOG_ERROR("Failed to get keysym in WindowBaseEcoreWl2\n");
return;
}
- foundKeyCode.keySym = sym;
+ foundKeyCode.keySym = sym;
foundKeyCode.isKeyCode = false;
- xkb_keymap_key_for_each( mKeyMap, FindKeyCode, &foundKeyCode );
- keyCode = static_cast< int32_t >( foundKeyCode.keyCode );
+ xkb_keymap_key_for_each(mKeyMap, FindKeyCode, &foundKeyCode);
+ keyCode = static_cast<int32_t>(foundKeyCode.keyCode);
}
Any WindowBaseEcoreWl2::GetNativeWindow()
int WindowBaseEcoreWl2::GetNativeWindowId()
{
- return ecore_wl2_window_id_get( mEcoreWindow );
+ return ecore_wl2_window_id_get(mEcoreWindow);
}
EGLNativeWindowType WindowBaseEcoreWl2::CreateEglWindow(int width, int height)
void WindowBaseEcoreWl2::DestroyEglWindow()
{
- if( mEglWindow != NULL )
+ if(mEglWindow != NULL)
{
- wl_egl_window_destroy( mEglWindow );
+ wl_egl_window_destroy(mEglWindow);
mEglWindow = NULL;
}
}
-void WindowBaseEcoreWl2::SetEglWindowRotation( int angle )
+void WindowBaseEcoreWl2::SetEglWindowRotation(int angle)
{
wl_egl_window_tizen_rotation rotation;
- switch( angle )
+ switch(angle)
{
case 0:
{
- rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
+ rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
break;
}
case 90:
}
default:
{
- rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0 ;
+ rotation = WL_EGL_WINDOW_TIZEN_ROTATION_0;
break;
}
}
- wl_egl_window_tizen_set_rotation( mEglWindow, rotation );
+ wl_egl_window_tizen_set_rotation(mEglWindow, rotation);
}
-void WindowBaseEcoreWl2::SetEglWindowBufferTransform( int angle )
+void WindowBaseEcoreWl2::SetEglWindowBufferTransform(int angle)
{
wl_output_transform bufferTransform;
- switch( angle )
+ switch(angle)
{
case 0:
{
}
}
- wl_egl_window_tizen_set_buffer_transform( mEglWindow, bufferTransform );
+ wl_egl_window_tizen_set_buffer_transform(mEglWindow, bufferTransform);
}
-void WindowBaseEcoreWl2::SetEglWindowTransform( int angle )
+void WindowBaseEcoreWl2::SetEglWindowTransform(int angle)
{
wl_output_transform windowTransform;
- switch( angle )
+ switch(angle)
{
case 0:
{
}
}
- wl_egl_window_tizen_set_window_transform( mEglWindow, windowTransform );
+ wl_egl_window_tizen_set_window_transform(mEglWindow, windowTransform);
}
-void WindowBaseEcoreWl2::ResizeEglWindow( PositionSize positionSize )
+void WindowBaseEcoreWl2::ResizeEglWindow(PositionSize positionSize)
{
- wl_egl_window_resize( mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y );
+ wl_egl_window_resize(mEglWindow, positionSize.width, positionSize.height, positionSize.x, positionSize.y);
// Note: Both "Resize" and "MoveResize" cases can reach here, but only "MoveResize" needs to submit serial number
- if( mMoveResizeSerial != mLastSubmittedMoveResizeSerial )
+ if(mMoveResizeSerial != mLastSubmittedMoveResizeSerial)
{
- wl_egl_window_tizen_set_window_serial( mEglWindow, mMoveResizeSerial );
+ wl_egl_window_tizen_set_window_serial(mEglWindow, mMoveResizeSerial);
mLastSubmittedMoveResizeSerial = mMoveResizeSerial;
}
}
return false;
}
-void WindowBaseEcoreWl2::Move( PositionSize positionSize )
+void WindowBaseEcoreWl2::Move(PositionSize positionSize)
{
mWindowPositionSize = positionSize;
- ecore_wl2_window_position_set( mEcoreWindow, positionSize.x, positionSize.y );
+ ecore_wl2_window_position_set(mEcoreWindow, positionSize.x, positionSize.y);
}
-void WindowBaseEcoreWl2::Resize( PositionSize positionSize )
+void WindowBaseEcoreWl2::Resize(PositionSize positionSize)
{
mWindowPositionSize = positionSize;
- ecore_wl2_window_geometry_set( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
+ ecore_wl2_window_geometry_set(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
}
-void WindowBaseEcoreWl2::MoveResize( PositionSize positionSize )
+void WindowBaseEcoreWl2::MoveResize(PositionSize positionSize)
{
mWindowPositionSize = positionSize;
- ecore_wl2_window_sync_geometry_set( mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
+ ecore_wl2_window_sync_geometry_set(mEcoreWindow, ++mMoveResizeSerial, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
}
-void WindowBaseEcoreWl2::SetClass( const std::string& name, const std::string& className )
+void WindowBaseEcoreWl2::SetClass(const std::string& name, const std::string& className)
{
- ecore_wl2_window_title_set( mEcoreWindow, name.c_str() );
- ecore_wl2_window_class_set( mEcoreWindow, className.c_str() );
+ ecore_wl2_window_title_set(mEcoreWindow, name.c_str());
+ ecore_wl2_window_class_set(mEcoreWindow, className.c_str());
}
void WindowBaseEcoreWl2::Raise()
{
// Use ecore_wl2_window_activate to prevent the window shown without rendering
- ecore_wl2_window_activate( mEcoreWindow );
+ ecore_wl2_window_activate(mEcoreWindow);
}
void WindowBaseEcoreWl2::Lower()
{
- ecore_wl2_window_lower( mEcoreWindow );
+ ecore_wl2_window_lower(mEcoreWindow);
}
void WindowBaseEcoreWl2::Activate()
{
- ecore_wl2_window_activate( mEcoreWindow );
+ ecore_wl2_window_activate(mEcoreWindow);
}
void WindowBaseEcoreWl2::SetAvailableAnlges(const std::vector<int>& angles)
ecore_wl2_window_available_rotations_set(mEcoreWindow, rotations, angles.size());
}
-void WindowBaseEcoreWl2::SetPreferredAngle( int angle )
+void WindowBaseEcoreWl2::SetPreferredAngle(int angle)
{
- DALI_LOG_RELEASE_INFO( "WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle );
- ecore_wl2_window_preferred_rotation_set( mEcoreWindow, angle );
+ DALI_LOG_RELEASE_INFO("WindowBaseEcoreWl2::SetPreferredAngle, angle: %d\n", angle);
+ ecore_wl2_window_preferred_rotation_set(mEcoreWindow, angle);
}
-void WindowBaseEcoreWl2::SetAcceptFocus( bool accept )
+void WindowBaseEcoreWl2::SetAcceptFocus(bool accept)
{
- ecore_wl2_window_focus_skip_set( mEcoreWindow, !accept );
+ ecore_wl2_window_focus_skip_set(mEcoreWindow, !accept);
}
void WindowBaseEcoreWl2::Show()
{
- if( !mVisible )
+ if(!mVisible)
{
- ecore_wl2_window_geometry_set( mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height );
+ ecore_wl2_window_geometry_set(mEcoreWindow, mWindowPositionSize.x, mWindowPositionSize.y, mWindowPositionSize.width, mWindowPositionSize.height);
}
mVisible = true;
- ecore_wl2_window_show( mEcoreWindow );
+ ecore_wl2_window_show(mEcoreWindow);
}
void WindowBaseEcoreWl2::Hide()
{
mVisible = false;
- ecore_wl2_window_hide( mEcoreWindow );
+ ecore_wl2_window_hide(mEcoreWindow);
}
unsigned int WindowBaseEcoreWl2::GetSupportedAuxiliaryHintCount() const
return mSupportedAuxiliaryHints.size();
}
-std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string WindowBaseEcoreWl2::GetSupportedAuxiliaryHint(unsigned int index) const
{
- if( index >= GetSupportedAuxiliaryHintCount() )
+ if(index >= GetSupportedAuxiliaryHintCount())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetSupportedAuxiliaryHint: Invalid index! [%d]\n", index);
}
return mSupportedAuxiliaryHints[index];
}
-unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int WindowBaseEcoreWl2::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
bool supported = false;
// Check if the hint is suppported
- for( std::vector< std::string >::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter )
+ for(std::vector<std::string>::iterator iter = mSupportedAuxiliaryHints.begin(); iter != mSupportedAuxiliaryHints.end(); ++iter)
{
- if( *iter == hint )
+ if(*iter == hint)
{
supported = true;
break;
}
}
- if( !supported )
+ if(!supported)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint.c_str());
return 0;
}
// Check if the hint is already added
- for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
+ for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
{
- if( mAuxiliaryHints[i].first == hint )
+ if(mAuxiliaryHints[i].first == hint)
{
// Just change the value
mAuxiliaryHints[i].second = value;
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1 );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), i + 1);
- return i + 1; // id is index + 1
+ return i + 1; // id is index + 1
}
}
// Add the hint
- mAuxiliaryHints.push_back( std::pair< std::string, std::string >( hint, value ) );
+ mAuxiliaryHints.push_back(std::pair<std::string, std::string>(hint, value));
unsigned int id = mAuxiliaryHints.size();
- ecore_wl2_window_aux_hint_add( mEcoreWindow, static_cast< int >( id ), hint.c_str(), value.c_str() );
+ ecore_wl2_window_aux_hint_add(mEcoreWindow, static_cast<int>(id), hint.c_str(), value.c_str());
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint.c_str(), value.c_str(), id);
return id;
}
-bool WindowBaseEcoreWl2::RemoveAuxiliaryHint( unsigned int id )
+bool WindowBaseEcoreWl2::RemoveAuxiliaryHint(unsigned int id)
{
- if( id == 0 || id > mAuxiliaryHints.size() )
+ if(id == 0 || id > mAuxiliaryHints.size())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: Invalid id [%d]\n", id);
return false;
}
mAuxiliaryHints[id - 1].second = std::string();
- ecore_wl2_window_aux_hint_del( mEcoreWindow, static_cast< int >( id ) );
+ ecore_wl2_window_aux_hint_del(mEcoreWindow, static_cast<int>(id));
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::RemoveAuxiliaryHint: id = %d, hint = %s\n", id, mAuxiliaryHints[id - 1].first.c_str());
return true;
}
-bool WindowBaseEcoreWl2::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool WindowBaseEcoreWl2::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
- if( id == 0 || id > mAuxiliaryHints.size() )
+ if(id == 0 || id > mAuxiliaryHints.size())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: Invalid id [%d]\n", id);
return false;
}
mAuxiliaryHints[id - 1].second = value;
- ecore_wl2_window_aux_hint_change( mEcoreWindow, static_cast< int >( id ), value.c_str() );
+ ecore_wl2_window_aux_hint_change(mEcoreWindow, static_cast<int>(id), value.c_str());
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
return true;
}
-std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue( unsigned int id ) const
+std::string WindowBaseEcoreWl2::GetAuxiliaryHintValue(unsigned int id) const
{
- if( id == 0 || id > mAuxiliaryHints.size() )
+ if(id == 0 || id > mAuxiliaryHints.size())
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: Invalid id [%d]\n", id);
return std::string();
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, mAuxiliaryHints[id - 1].first.c_str(), mAuxiliaryHints[id - 1].second.c_str());
return mAuxiliaryHints[id - 1].second;
}
-unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int WindowBaseEcoreWl2::GetAuxiliaryHintId(const std::string& hint) const
{
- for( unsigned int i = 0; i < mAuxiliaryHints.size(); i++ )
+ for(unsigned int i = 0; i < mAuxiliaryHints.size(); i++)
{
- if( mAuxiliaryHints[i].first == hint )
+ if(mAuxiliaryHints[i].first == hint)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1 );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: hint = %s, id = %d\n", hint.c_str(), i + 1);
return i + 1;
}
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str() );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetAuxiliaryHintId: Invalid hint! [%s]\n", hint.c_str());
return 0;
}
-void WindowBaseEcoreWl2::SetInputRegion( const Rect< int >& inputRegion )
+void WindowBaseEcoreWl2::SetInputRegion(const Rect<int>& inputRegion)
{
- ecore_wl2_window_input_region_set( mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
+ ecore_wl2_window_input_region_set(mEcoreWindow, inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
}
-void WindowBaseEcoreWl2::SetType( Dali::WindowType type )
+void WindowBaseEcoreWl2::SetType(Dali::WindowType type)
{
Ecore_Wl2_Window_Type windowType;
- switch( type )
+ switch(type)
{
case Dali::WindowType::NORMAL:
{
}
}
- ecore_wl2_window_type_set( mEcoreWindow, windowType );
+ ecore_wl2_window_type_set(mEcoreWindow, windowType);
}
-bool WindowBaseEcoreWl2::SetNotificationLevel( Dali::WindowNotificationLevel level )
+bool WindowBaseEcoreWl2::SetNotificationLevel(Dali::WindowNotificationLevel level)
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int notificationLevel;
- switch( level )
+ switch(level)
{
case Dali::WindowNotificationLevel::NONE:
{
}
default:
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: invalid level [%d]\n", level);
notificationLevel = TIZEN_POLICY_LEVEL_DEFAULT;
break;
}
}
mNotificationLevelChangeDone = false;
- mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
+ mNotificationChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
- tizen_policy_set_notification_level( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), notificationLevel );
+ tizen_policy_set_notification_level(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), notificationLevel);
int count = 0;
- while( !mNotificationLevelChangeDone && count < 3 )
+ while(!mNotificationLevelChangeDone && count < 3)
{
- ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mNotificationLevelChangeDone )
+ if(!mNotificationLevelChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level change is failed [%d, %d]\n", level, mNotificationChangeState);
return false;
}
- else if( mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ else if(mNotificationChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Permission denied! [%d]\n", level);
return false;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetNotificationLevel: Level is changed [%d]\n", mNotificationLevel);
return true;
}
Dali::WindowNotificationLevel WindowBaseEcoreWl2::GetNotificationLevel() const
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int count = 0;
- while( !mNotificationLevelChangeDone && count < 3 )
+ while(!mNotificationLevelChangeDone && count < 3)
{
- ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mNotificationLevelChangeDone )
+ if(!mNotificationLevelChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: Error! [%d]\n", mNotificationChangeState);
return Dali::WindowNotificationLevel::NONE;
}
Dali::WindowNotificationLevel level;
- switch( mNotificationLevel )
+ switch(mNotificationLevel)
{
case TIZEN_POLICY_LEVEL_NONE:
{
}
default:
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: invalid level [%d]\n", mNotificationLevel);
level = Dali::WindowNotificationLevel::NONE;
break;
}
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetNotificationLevel: level [%d]\n", mNotificationLevel);
return level;
}
-void WindowBaseEcoreWl2::SetOpaqueState( bool opaque )
+void WindowBaseEcoreWl2::SetOpaqueState(bool opaque)
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
- tizen_policy_set_opaque_state( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), ( opaque ? 1 : 0 ) );
+ tizen_policy_set_opaque_state(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), (opaque ? 1 : 0));
}
bool WindowBaseEcoreWl2::SetScreenOffMode(WindowScreenOffMode screenOffMode)
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
- mScreenOffModeChangeDone = false;
+ mScreenOffModeChangeDone = false;
mScreenOffModeChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
unsigned int mode = 0;
- switch( screenOffMode )
+ switch(screenOffMode)
{
case WindowScreenOffMode::TIMEOUT:
{
}
}
- tizen_policy_set_window_screen_mode( mTizenPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), mode );
+ tizen_policy_set_window_screen_mode(mTizenPolicy, ecore_wl2_window_surface_get(mEcoreWindow), mode);
int count = 0;
- while( !mScreenOffModeChangeDone && count < 3 )
+ while(!mScreenOffModeChangeDone && count < 3)
{
- ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mScreenOffModeChangeDone )
+ if(!mScreenOffModeChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode change is failed [%d, %d]\n", screenOffMode, mScreenOffModeChangeState);
return false;
}
- else if( mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ else if(mScreenOffModeChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Permission denied! [%d]\n", screenOffMode);
return false;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetScreenOffMode: Screen mode is changed [%d]\n", mScreenOffMode);
return true;
}
WindowScreenOffMode WindowBaseEcoreWl2::GetScreenOffMode() const
{
- while( !mTizenPolicy )
+ while(!mTizenPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int count = 0;
- while( !mScreenOffModeChangeDone && count < 3 )
+ while(!mScreenOffModeChangeDone && count < 3)
{
- ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mScreenOffModeChangeDone )
+ if(!mScreenOffModeChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: Error! [%d]\n", mScreenOffModeChangeState);
return WindowScreenOffMode::TIMEOUT;
}
WindowScreenOffMode screenMode = WindowScreenOffMode::TIMEOUT;
- switch( mScreenOffMode )
+ switch(mScreenOffMode)
{
case 0:
{
}
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetScreenOffMode: screen mode [%d]\n", mScreenOffMode);
return screenMode;
}
-bool WindowBaseEcoreWl2::SetBrightness( int brightness )
+bool WindowBaseEcoreWl2::SetBrightness(int brightness)
{
- while( !mTizenDisplayPolicy )
+ while(!mTizenDisplayPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
- mBrightnessChangeDone = false;
+ mBrightnessChangeDone = false;
mBrightnessChangeState = TIZEN_POLICY_ERROR_STATE_NONE;
- tizen_display_policy_set_window_brightness( mTizenDisplayPolicy, ecore_wl2_window_surface_get( mEcoreWindow ), brightness );
+ tizen_display_policy_set_window_brightness(mTizenDisplayPolicy, ecore_wl2_window_surface_get(mEcoreWindow), brightness);
int count = 0;
- while( !mBrightnessChangeDone && count < 3 )
+ while(!mBrightnessChangeDone && count < 3)
{
- ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mBrightnessChangeDone )
+ if(!mBrightnessChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness change is failed [%d, %d]\n", brightness, mBrightnessChangeState);
return false;
}
- else if( mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED )
+ else if(mBrightnessChangeState == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Permission denied! [%d]\n", brightness);
return false;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::SetBrightness: Brightness is changed [%d]\n", mBrightness);
return true;
}
int WindowBaseEcoreWl2::GetBrightness() const
{
- while( !mTizenDisplayPolicy )
+ while(!mTizenDisplayPolicy)
{
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
}
int count = 0;
- while( !mBrightnessChangeDone && count < 3 )
+ while(!mBrightnessChangeDone && count < 3)
{
- ecore_wl2_display_flush( ecore_wl2_connected_display_get( NULL ) );
- wl_display_dispatch_queue( mDisplay, mEventQueue );
+ ecore_wl2_display_flush(ecore_wl2_connected_display_get(NULL));
+ wl_display_dispatch_queue(mDisplay, mEventQueue);
count++;
}
- if( !mBrightnessChangeDone )
+ if(!mBrightnessChangeDone)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Error! [%d]\n", mBrightnessChangeState);
return 0;
}
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Verbose, "WindowBaseEcoreWl2::GetBrightness: Brightness [%d]\n", mBrightness);
return mBrightness;
}
-bool WindowBaseEcoreWl2::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+bool WindowBaseEcoreWl2::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
{
Ecore_Wl2_Window_Keygrab_Mode mode;
- switch( grabMode )
+ switch(grabMode)
{
case KeyGrab::TOPMOST:
{
}
}
- return ecore_wl2_window_keygrab_set( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0, 0, mode );
+ return ecore_wl2_window_keygrab_set(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0, 0, mode);
}
-bool WindowBaseEcoreWl2::UngrabKey( Dali::KEY key )
+bool WindowBaseEcoreWl2::UngrabKey(Dali::KEY key)
{
- return ecore_wl2_window_keygrab_unset( mEcoreWindow, KeyLookup::GetKeyName( key ), 0, 0 );
+ return ecore_wl2_window_keygrab_unset(mEcoreWindow, KeyLookup::GetKeyName(key), 0, 0);
}
-bool WindowBaseEcoreWl2::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+bool WindowBaseEcoreWl2::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
{
- int keyCount = key.Count();
+ int keyCount = key.Count();
int keyGrabModeCount = grabMode.Count();
- if( keyCount != keyGrabModeCount || keyCount == 0 )
+ if(keyCount != keyGrabModeCount || keyCount == 0)
{
return false;
}
eina_init();
- Eina_List* keyList = NULL;
- Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
+ Eina_List* keyList = NULL;
+ Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
- for( int index = 0; index < keyCount; ++index )
+ for(int index = 0; index < keyCount; ++index)
{
- info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
+ info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
- switch( grabMode[index] )
+ switch(grabMode[index])
{
case KeyGrab::TOPMOST:
{
}
}
- keyList = eina_list_append( keyList, &info );
+ keyList = eina_list_append(keyList, &info);
}
- Eina_List* grabList = ecore_wl2_window_keygrab_list_set( mEcoreWindow, keyList );
+ Eina_List* grabList = ecore_wl2_window_keygrab_list_set(mEcoreWindow, keyList);
- result.Resize( keyCount, true );
+ result.Resize(keyCount, true);
- Eina_List* l = NULL;
- Eina_List* m = NULL;
- void* listData = NULL;
- void* data = NULL;
- if( grabList != NULL )
+ Eina_List* l = NULL;
+ Eina_List* m = NULL;
+ void* listData = NULL;
+ void* data = NULL;
+ if(grabList != NULL)
{
- EINA_LIST_FOREACH( grabList, m, data )
+ EINA_LIST_FOREACH(grabList, m, data)
{
int index = 0;
- EINA_LIST_FOREACH( keyList, l, listData )
+ EINA_LIST_FOREACH(keyList, l, listData)
{
- if( static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key == NULL )
+ if(static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key == NULL)
{
- DALI_LOG_ERROR( "input key list has null data!" );
+ DALI_LOG_ERROR("input key list has null data!");
break;
}
- if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
+ if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
{
result[index] = false;
}
}
}
- delete [] info;
+ delete[] info;
- eina_list_free( keyList );
- eina_list_free( grabList );
+ eina_list_free(keyList);
+ eina_list_free(grabList);
eina_shutdown();
return true;
}
-bool WindowBaseEcoreWl2::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+bool WindowBaseEcoreWl2::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
{
int keyCount = key.Count();
- if( keyCount == 0 )
+ if(keyCount == 0)
{
return false;
}
eina_init();
- Eina_List* keyList = NULL;
- Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
+ Eina_List* keyList = NULL;
+ Ecore_Wl2_Window_Keygrab_Info* info = new Ecore_Wl2_Window_Keygrab_Info[keyCount];
- for( int index = 0; index < keyCount; ++index )
+ for(int index = 0; index < keyCount; ++index)
{
- info[index].key = const_cast< char* >( KeyLookup::GetKeyName( key[index] ) );
- keyList = eina_list_append( keyList, &info );
+ info[index].key = const_cast<char*>(KeyLookup::GetKeyName(key[index]));
+ keyList = eina_list_append(keyList, &info);
}
- Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset( mEcoreWindow, keyList );
+ Eina_List* ungrabList = ecore_wl2_window_keygrab_list_unset(mEcoreWindow, keyList);
- result.Resize( keyCount, true );
+ result.Resize(keyCount, true);
- Eina_List* l = NULL;
- Eina_List* m = NULL;
- void *listData = NULL;
- void *data = NULL;
+ Eina_List* l = NULL;
+ Eina_List* m = NULL;
+ void* listData = NULL;
+ void* data = NULL;
- if( ungrabList != NULL )
+ if(ungrabList != NULL)
{
- EINA_LIST_FOREACH( ungrabList, m, data )
+ EINA_LIST_FOREACH(ungrabList, m, data)
{
int index = 0;
- EINA_LIST_FOREACH( keyList, l, listData )
+ EINA_LIST_FOREACH(keyList, l, listData)
{
- if( strcmp( static_cast< char* >( data ), static_cast< Ecore_Wl2_Window_Keygrab_Info* >( listData )->key ) == 0 )
+ if(strcmp(static_cast<char*>(data), static_cast<Ecore_Wl2_Window_Keygrab_Info*>(listData)->key) == 0)
{
result[index] = false;
}
}
}
- delete [] info;
+ delete[] info;
- eina_list_free( keyList );
- eina_list_free( ungrabList );
+ eina_list_free(keyList);
+ eina_list_free(ungrabList);
eina_shutdown();
return true;
}
-void WindowBaseEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void WindowBaseEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
// calculate DPI
float xres, yres;
- Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mEcoreWindow );
+ Ecore_Wl2_Output* output = ecore_wl2_window_output_find(mEcoreWindow);
// 1 inch = 25.4 millimeters
- xres = ecore_wl2_output_dpi_get( output );
- yres = ecore_wl2_output_dpi_get( output );
+ xres = ecore_wl2_output_dpi_get(output);
+ yres = ecore_wl2_output_dpi_get(output);
- dpiHorizontal = int( xres + 0.5f ); // rounding
- dpiVertical = int( yres + 0.5f );
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
}
int WindowBaseEcoreWl2::GetOrientation() const
ecore_wl2_window_rotation_change_done_send(mEcoreWindow, degree, width, height);
}
-void WindowBaseEcoreWl2::SetTransparency( bool transparent )
+void WindowBaseEcoreWl2::SetTransparency(bool transparent)
{
- ecore_wl2_window_alpha_set( mEcoreWindow, transparent );
+ ecore_wl2_window_alpha_set(mEcoreWindow, transparent);
}
void WindowBaseEcoreWl2::InitializeEcoreElDBus()
{
#ifdef DALI_ELDBUS_AVAILABLE
Eldbus_Object* object;
- Eldbus_Proxy* manager;
+ Eldbus_Proxy* manager;
- if( !( mSystemConnection = eldbus_connection_get( ELDBUS_CONNECTION_TYPE_SYSTEM ) ) )
+ if(!(mSystemConnection = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM)))
{
- DALI_LOG_ERROR( "Unable to get system bus\n" );
+ DALI_LOG_ERROR("Unable to get system bus\n");
}
- object = eldbus_object_get( mSystemConnection, BUS, PATH );
- if( !object )
+ object = eldbus_object_get(mSystemConnection, BUS, PATH);
+ if(!object)
{
- DALI_LOG_ERROR( "Getting object failed\n" );
+ DALI_LOG_ERROR("Getting object failed\n");
return;
}
- manager = eldbus_proxy_get( object, INTERFACE );
- if( !manager )
+ manager = eldbus_proxy_get(object, INTERFACE);
+ if(!manager)
{
- DALI_LOG_ERROR( "Getting proxy failed\n" );
+ DALI_LOG_ERROR("Getting proxy failed\n");
return;
}
- if( !eldbus_proxy_signal_handler_add( manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this ) )
+ if(!eldbus_proxy_signal_handler_add(manager, "GestureDetected", EcoreElDBusAccessibilityNotification, this))
{
- DALI_LOG_ERROR( "No signal handler returned\n" );
+ DALI_LOG_ERROR("No signal handler returned\n");
}
#endif
}
-void WindowBaseEcoreWl2::CreateWindow( PositionSize positionSize )
+void WindowBaseEcoreWl2::CreateWindow(PositionSize positionSize)
{
- Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
- if( !display )
+ Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
+ if(!display)
{
- DALI_ASSERT_ALWAYS( 0 && "Failed to get display" );
+ DALI_ASSERT_ALWAYS(0 && "Failed to get display");
}
- ecore_wl2_display_sync( display );
+ ecore_wl2_display_sync(display);
- mEcoreWindow = ecore_wl2_window_new( display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
+ mEcoreWindow = ecore_wl2_window_new(display, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
- if ( mEcoreWindow == 0 )
+ if(mEcoreWindow == 0)
{
- DALI_ASSERT_ALWAYS( 0 && "Failed to create Wayland window" );
+ DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window");
}
// Set default type
- ecore_wl2_window_type_set( mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL );
+ ecore_wl2_window_type_set(mEcoreWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
}
-void WindowBaseEcoreWl2::SetParent( WindowBase* parentWinBase )
+void WindowBaseEcoreWl2::SetParent(WindowBase* parentWinBase)
{
Ecore_Wl2_Window* ecoreParent = NULL;
- if( parentWinBase )
+ if(parentWinBase)
{
- WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>( parentWinBase );
- ecoreParent = winBaseEcore2->mEcoreWindow;
+ WindowBaseEcoreWl2* winBaseEcore2 = static_cast<WindowBaseEcoreWl2*>(parentWinBase);
+ ecoreParent = winBaseEcore2->mEcoreWindow;
}
- ecore_wl2_window_parent_set( mEcoreWindow, ecoreParent );
+ ecore_wl2_window_parent_set(mEcoreWindow, ecoreParent);
}
int WindowBaseEcoreWl2::CreateFrameRenderedSyncFence()
{
- return wl_egl_window_tizen_create_commit_sync_fd( mEglWindow );
+ return wl_egl_window_tizen_create_commit_sync_fd(mEglWindow);
}
int WindowBaseEcoreWl2::CreateFramePresentedSyncFence()
{
- return wl_egl_window_tizen_create_presentation_sync_fd( mEglWindow );
+ return wl_egl_window_tizen_create_presentation_sync_fd(mEglWindow);
}
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
#include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-factory-ecore-wl2.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.h>
namespace Dali
{
{
namespace Adaptor
{
-
-std::unique_ptr< WindowBase > WindowFactoryEcoreWl2::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowBase> WindowFactoryEcoreWl2::CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowBaseEcoreWl2 >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowBaseEcoreWl2>(positionSize, surface, isTransparent);
}
// this should be created from Window impl
-std::unique_ptr< WindowFactory > GetWindowFactory()
+std::unique_ptr<WindowFactory> GetWindowFactory()
{
// returns Window factory
- return Utils::MakeUnique< WindowFactoryEcoreWl2 >();
+ return Utils::MakeUnique<WindowFactoryEcoreWl2>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
*/
// INTERNAL HEADERS
-#include <dali/internal/window-system/common/window-system.h>
#include <dali/devel-api/adaptor-framework/keyboard.h>
+#include <dali/internal/window-system/common/window-system.h>
// EXTERNAL_HEADERS
#include <Ecore_Wl2.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace WindowSystem
{
-
void Initialize()
{
ecore_wl2_init();
ecore_wl2_shutdown();
}
-void GetScreenSize( int& width, int& height )
+void GetScreenSize(int& width, int& height)
{
- Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL );
- if( display )
+ Ecore_Wl2_Display* display = ecore_wl2_display_connect(NULL);
+ if(display)
{
- ecore_wl2_display_screen_size_get( display, &width, &height );
- DALI_ASSERT_ALWAYS((width>0) && "screen width is 0");
- DALI_ASSERT_ALWAYS((height>0) && "screen height is 0");
+ ecore_wl2_display_screen_size_get(display, &width, &height);
+ DALI_ASSERT_ALWAYS((width > 0) && "screen width is 0");
+ DALI_ASSERT_ALWAYS((height > 0) && "screen height is 0");
}
}
-bool SetKeyboardRepeatInfo( float rate, float delay )
+bool SetKeyboardRepeatInfo(float rate, float delay)
{
- Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) );
- return ecore_wl2_input_keyboard_repeat_set( input, static_cast<double>( rate ), static_cast<double>( delay ) );
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
+ return ecore_wl2_input_keyboard_repeat_set(input, static_cast<double>(rate), static_cast<double>(delay));
}
-bool GetKeyboardRepeatInfo( float& rate, float& delay )
+bool GetKeyboardRepeatInfo(float& rate, float& delay)
{
- Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) );
- double rateVal, delayVal;
- bool ret = ecore_wl2_input_keyboard_repeat_get( input, &rateVal, &delayVal );
- rate = static_cast<float>( rateVal );
- delay = static_cast<float>( delayVal );
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
+ double rateVal, delayVal;
+ bool ret = ecore_wl2_input_keyboard_repeat_get(input, &rateVal, &delayVal);
+ rate = static_cast<float>(rateVal);
+ delay = static_cast<float>(delayVal);
return ret;
}
/*
- * 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.
#include <dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h>
// EXTERNAL INCLUDES
-#include <dali/integration-api/gl-abstraction.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/gl-abstraction.h>
#ifdef ECORE_WAYLAND2
#include <Ecore_Wl2.h>
namespace Dali
{
-
namespace
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gNativeSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_NATIVE_RENDER_SURFACE");
#endif
} // unnamed namespace
-NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent )
-: mRenderNotification( NULL ),
- mGraphics( NULL ),
- mEGL( nullptr ),
- mEGLSurface( nullptr ),
- mEGLContext( nullptr ),
- mOwnSurface( false ),
- mDrawableCompleted( false ),
- mTbmQueue( NULL ),
- mConsumeSurface( NULL ),
- mThreadSynchronization( NULL )
+NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, Any surface, bool isTransparent)
+: mRenderNotification(NULL),
+ mGraphics(NULL),
+ mEGL(nullptr),
+ mEGLSurface(nullptr),
+ mEGLContext(nullptr),
+ mOwnSurface(false),
+ mDrawableCompleted(false),
+ mTbmQueue(NULL),
+ mConsumeSurface(NULL),
+ mThreadSynchronization(NULL)
{
Dali::Internal::Adaptor::WindowSystem::Initialize();
- if( surface.Empty() )
+ if(surface.Empty())
{
mSurfaceSize = surfaceSize;
- mColorDepth = isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
- mTbmFormat = isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888;
+ mColorDepth = isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
+ mTbmFormat = isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888;
CreateNativeRenderable();
}
else
{
- mTbmQueue = AnyCast< tbm_surface_queue_h >( surface );
+ mTbmQueue = AnyCast<tbm_surface_queue_h>(surface);
- uint16_t width = static_cast<uint16_t>( tbm_surface_queue_get_width( mTbmQueue ) );
- uint16_t height = static_cast<uint16_t>( tbm_surface_queue_get_height( mTbmQueue ) );
- mSurfaceSize = SurfaceSize( width, height );
+ uint16_t width = static_cast<uint16_t>(tbm_surface_queue_get_width(mTbmQueue));
+ uint16_t height = static_cast<uint16_t>(tbm_surface_queue_get_height(mTbmQueue));
+ mSurfaceSize = SurfaceSize(width, height);
- mTbmFormat = tbm_surface_queue_get_format( mTbmQueue );
+ mTbmFormat = tbm_surface_queue_get_format(mTbmQueue);
- mColorDepth = ( mTbmFormat == TBM_FORMAT_ARGB8888 ) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
+ mColorDepth = (mTbmFormat == TBM_FORMAT_ARGB8888) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
}
}
NativeRenderSurfaceEcoreWl::~NativeRenderSurfaceEcoreWl()
{
- if ( mEGLSurface )
+ if(mEGLSurface)
{
DestroySurface();
}
// release the surface if we own one
- if( mOwnSurface )
+ if(mOwnSurface)
{
ReleaseDrawable();
- if( mTbmQueue )
+ if(mTbmQueue)
{
- tbm_surface_queue_destroy( mTbmQueue );
+ tbm_surface_queue_destroy(mTbmQueue);
}
- DALI_LOG_INFO( gNativeSurfaceLogFilter, Debug::General, "Own tbm surface queue destroy\n" );
+ DALI_LOG_INFO(gNativeSurfaceLogFilter, Debug::General, "Own tbm surface queue destroy\n");
}
Dali::Internal::Adaptor::WindowSystem::Shutdown();
return mConsumeSurface;
}
-void NativeRenderSurfaceEcoreWl::SetRenderNotification( TriggerEventInterface* renderNotification )
+void NativeRenderSurfaceEcoreWl::SetRenderNotification(TriggerEventInterface* renderNotification)
{
mRenderNotification = renderNotification;
}
void NativeRenderSurfaceEcoreWl::WaitUntilSurfaceReplaced()
{
- ConditionalWait::ScopedLock lock( mTbmSurfaceCondition );
- while( !mDrawableCompleted )
+ ConditionalWait::ScopedLock lock(mTbmSurfaceCondition);
+ while(!mDrawableCompleted)
{
- mTbmSurfaceCondition.Wait( lock );
+ mTbmSurfaceCondition.Wait(lock);
}
mDrawableCompleted = false;
PositionSize NativeRenderSurfaceEcoreWl::GetPositionSize() const
{
- return PositionSize( 0, 0, static_cast<int>( mSurfaceSize.GetWidth() ), static_cast<int>( mSurfaceSize.GetHeight() ) );
+ return PositionSize(0, 0, static_cast<int>(mSurfaceSize.GetWidth()), static_cast<int>(mSurfaceSize.GetHeight()));
}
-void NativeRenderSurfaceEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void NativeRenderSurfaceEcoreWl::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
// calculate DPI
float xres, yres;
yres = ecore_wl_dpi_get();
#endif
- dpiHorizontal = int( xres + 0.5f ); // rounding
- dpiVertical = int( yres + 0.5f );
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
}
int NativeRenderSurfaceEcoreWl::GetOrientation() const
void NativeRenderSurfaceEcoreWl::InitializeGraphics()
{
- DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gNativeSurfaceLogFilter);
- mGraphics = &mAdaptor->GetGraphicsInterface();
- auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
+ mGraphics = &mAdaptor->GetGraphicsInterface();
+ auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics*>(mGraphics);
mEGL = &eglGraphics->GetEglInterface();
- if ( mEGLContext == NULL )
+ if(mEGLContext == NULL)
{
// Create the OpenGL context for this window
Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
- eglImpl.CreateWindowContext( mEGLContext );
+ eglImpl.CreateWindowContext(mEGLContext);
// Create the OpenGL surface
CreateSurface();
void NativeRenderSurfaceEcoreWl::CreateSurface()
{
- DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gNativeSurfaceLogFilter);
- auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics*>(mGraphics);
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- mEGLSurface = eglImpl.CreateSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ), mColorDepth );
+ mEGLSurface = eglImpl.CreateSurfaceWindow(reinterpret_cast<EGLNativeWindowType>(mTbmQueue), mColorDepth);
}
void NativeRenderSurfaceEcoreWl::DestroySurface()
{
- DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gNativeSurfaceLogFilter);
- auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics*>(mGraphics);
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.DestroySurface( mEGLSurface );
+ eglImpl.DestroySurface(mEGLSurface);
}
bool NativeRenderSurfaceEcoreWl::ReplaceGraphicsSurface()
{
- DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gNativeSurfaceLogFilter);
- if( !mTbmQueue )
+ if(!mTbmQueue)
{
return false;
}
- auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics*>(mGraphics);
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- return eglImpl.ReplaceSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ), mEGLSurface, mEGLContext );
+ return eglImpl.ReplaceSurfaceWindow(reinterpret_cast<EGLNativeWindowType>(mTbmQueue), mEGLSurface, mEGLContext);
}
-void NativeRenderSurfaceEcoreWl::MoveResize( Dali::PositionSize positionSize )
+void NativeRenderSurfaceEcoreWl::MoveResize(Dali::PositionSize positionSize)
{
tbm_surface_queue_error_e error = TBM_SURFACE_QUEUE_ERROR_NONE;
- error = tbm_surface_queue_reset( mTbmQueue, positionSize.width, positionSize.height, mTbmFormat );
+ error = tbm_surface_queue_reset(mTbmQueue, positionSize.width, positionSize.height, mTbmFormat);
- if( error != TBM_SURFACE_QUEUE_ERROR_NONE )
+ if(error != TBM_SURFACE_QUEUE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Failed to resize tbm_surface_queue" );
+ DALI_LOG_ERROR("Failed to resize tbm_surface_queue");
}
- mSurfaceSize.SetWidth( static_cast<uint16_t>( positionSize.width ) );
- mSurfaceSize.SetHeight( static_cast<uint16_t>( positionSize.height ) );
+ mSurfaceSize.SetWidth(static_cast<uint16_t>(positionSize.width));
+ mSurfaceSize.SetHeight(static_cast<uint16_t>(positionSize.height));
}
void NativeRenderSurfaceEcoreWl::StartRender()
{
}
-bool NativeRenderSurfaceEcoreWl::PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect )
+bool NativeRenderSurfaceEcoreWl::PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
{
//TODO: Need to support partial update
return true;
}
-void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects )
+void NativeRenderSurfaceEcoreWl::PostRender(bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects)
{
- auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- if (eglGraphics)
+ auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics*>(mGraphics);
+ if(eglGraphics)
{
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.SwapBuffers( mEGLSurface, damagedRects );
+ eglImpl.SwapBuffers(mEGLSurface, damagedRects);
}
//TODO: Move calling tbm_surface_queue_acruie to OffscreenWindow and Scene in EvasPlugin
- if ( mOwnSurface )
+ if(mOwnSurface)
{
- if( mThreadSynchronization )
+ if(mThreadSynchronization)
{
mThreadSynchronization->PostRenderStarted();
}
- if( tbm_surface_queue_can_acquire( mTbmQueue, 1 ) )
+ if(tbm_surface_queue_can_acquire(mTbmQueue, 1))
{
- if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
+ if(tbm_surface_queue_acquire(mTbmQueue, &mConsumeSurface) != TBM_SURFACE_QUEUE_ERROR_NONE)
{
- DALI_LOG_ERROR( "Failed to acquire a tbm_surface\n" );
+ DALI_LOG_ERROR("Failed to acquire a tbm_surface\n");
return;
}
}
- if ( mConsumeSurface )
+ if(mConsumeSurface)
{
- tbm_surface_internal_ref( mConsumeSurface );
+ tbm_surface_internal_ref(mConsumeSurface);
}
- if( replacingSurface )
+ if(replacingSurface)
{
- ConditionalWait::ScopedLock lock( mTbmSurfaceCondition );
+ ConditionalWait::ScopedLock lock(mTbmSurfaceCondition);
mDrawableCompleted = true;
- mTbmSurfaceCondition.Notify( lock );
+ mTbmSurfaceCondition.Notify(lock);
}
- // create damage for client applications which wish to know the update timing
- if( !replacingSurface && mRenderNotification )
+ // create damage for client applications which wish to know the update timing
+ if(!replacingSurface && mRenderNotification)
{
// use notification trigger
// Tell the event-thread to render the tbm_surface
mRenderNotification->Trigger();
}
- if( mThreadSynchronization )
+ if(mThreadSynchronization)
{
// wait until the event-thread completed to use the tbm_surface
mThreadSynchronization->PostRenderWaitForCompletion();
else
{
// create damage for client applications which wish to know the update timing
- if( !replacingSurface && mRenderNotification )
+ if(!replacingSurface && mRenderNotification)
{
// use notification trigger
// Tell the event-thread to render the tbm_surface
ReleaseLock();
}
-void NativeRenderSurfaceEcoreWl::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
+void NativeRenderSurfaceEcoreWl::SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization)
{
mThreadSynchronization = &threadSynchronization;
}
void NativeRenderSurfaceEcoreWl::MakeContextCurrent()
{
- if ( mEGL != nullptr )
+ if(mEGL != nullptr)
{
- mEGL->MakeContextCurrent( mEGLSurface, mEGLContext );
+ mEGL->MakeContextCurrent(mEGLSurface, mEGLContext);
}
}
void NativeRenderSurfaceEcoreWl::ReleaseLock()
{
- if( mThreadSynchronization )
+ if(mThreadSynchronization)
{
mThreadSynchronization->PostRenderComplete();
}
void NativeRenderSurfaceEcoreWl::CreateNativeRenderable()
{
- int width = static_cast<int>( mSurfaceSize.GetWidth() );
- int height = static_cast<int>( mSurfaceSize.GetHeight() );
+ int width = static_cast<int>(mSurfaceSize.GetWidth());
+ int height = static_cast<int>(mSurfaceSize.GetHeight());
// check we're creating one with a valid size
- DALI_ASSERT_ALWAYS( width > 0 && height > 0 && "tbm_surface size is invalid" );
+ DALI_ASSERT_ALWAYS(width > 0 && height > 0 && "tbm_surface size is invalid");
- mTbmQueue = tbm_surface_queue_create( 3, width, height, mTbmFormat, TBM_BO_DEFAULT );
+ mTbmQueue = tbm_surface_queue_create(3, width, height, mTbmFormat, TBM_BO_DEFAULT);
- if( mTbmQueue )
+ if(mTbmQueue)
{
mOwnSurface = true;
}
void NativeRenderSurfaceEcoreWl::ReleaseDrawable()
{
- if( mConsumeSurface )
+ if(mConsumeSurface)
{
- tbm_surface_internal_unref( mConsumeSurface );
+ tbm_surface_internal_unref(mConsumeSurface);
- if( tbm_surface_internal_is_valid( mConsumeSurface ) )
+ if(tbm_surface_internal_is_valid(mConsumeSurface))
{
- tbm_surface_queue_release( mTbmQueue, mConsumeSurface );
+ tbm_surface_queue_release(mTbmQueue, mConsumeSurface);
}
mConsumeSurface = NULL;
}
/*
- * Copyright (c) 2017 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.
{
namespace Adaptor
{
-
std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> DisplayConnectionFactoryX::CreateDisplayConnection()
{
return Utils::MakeUnique<DisplayConnectionX11>();
return Utils::MakeUnique<DisplayConnectionFactoryX>();
}
-}
-}
-}
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
/*
- * 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.
#include <dali/internal/window-system/ubuntu-x11/display-connection-impl-x.h>
// EXTERNAL_HEADERS
-#include <dali/internal/system/linux/dali-ecore-x.h>
#include <dali/integration-api/debug.h>
+#include <dali/internal/system/linux/dali-ecore-x.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
DisplayConnection* DisplayConnectionX11::New()
{
//DisplayConnection* pDisplayConnection(new DisplayConnection());
}
DisplayConnectionX11::DisplayConnectionX11()
-: mGraphics( nullptr ),
- mDisplay( nullptr )
+: mGraphics(nullptr),
+ mDisplay(nullptr)
{
}
// Check if there are any events in the queue
events = XEventsQueued(mDisplay, QueuedAfterFlush);
- if (events > 0)
+ if(events > 0)
{
// Just flush event to prevent memory leak from event queue as the events get built up in
// memory but are only deleted when we retrieve them
XEvent ev;
XNextEvent(mDisplay, &ev);
}
- }
- while (events > 0);
+ } while(events > 0);
}
bool DisplayConnectionX11::InitializeGraphics()
{
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- if (!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))
+ if(!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))
{
DALI_LOG_ERROR("Failed to initialize GLES.\n");
return false;
return true;
}
-void DisplayConnectionX11::SetSurfaceType( Dali::RenderSurfaceInterface::Type type )
+void DisplayConnectionX11::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)
{
- if( type == Dali::RenderSurfaceInterface::WINDOW_RENDER_SURFACE )
+ if(type == Dali::RenderSurfaceInterface::WINDOW_RENDER_SURFACE)
{
// Because of DDK issue, we need to use separated x display instead of ecore default display
mDisplay = XOpenDisplay(0);
}
}
-void DisplayConnectionX11::SetGraphicsInterface( GraphicsInterface& graphics )
+void DisplayConnectionX11::SetGraphicsInterface(GraphicsInterface& graphics)
{
mGraphics = &graphics;
}
/*
- * 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.
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include <X11/extensions/Xfixes.h> // for damage notify
#include <X11/extensions/Xdamage.h> // for damage notify
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/integration-api/debug.h>
+#include <X11/extensions/Xfixes.h> // for damage notify
#include <dali/devel-api/threading/mutex.h>
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/gl-abstraction.h>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
{
namespace Adaptor
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gPixmapRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_PIXMAP_RENDER_SURFACE_ECORE_X");
#endif
{
static const int INITIAL_PRODUCE_BUFFER_INDEX = 0;
static const int INITIAL_CONSUME_BUFFER_INDEX = 1;
-}
-
-PixmapRenderSurfaceEcoreX::PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent )
-: mGraphics( nullptr ),
- mDisplayConnection( nullptr ),
- mPosition( positionSize ),
- mRenderNotification( NULL ),
- mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
- mOwnSurface( false ),
- mProduceBufferIndex( INITIAL_PRODUCE_BUFFER_INDEX ),
- mConsumeBufferIndex( INITIAL_CONSUME_BUFFER_INDEX ),
+} // namespace
+
+PixmapRenderSurfaceEcoreX::PixmapRenderSurfaceEcoreX(Dali::PositionSize positionSize, Any surface, bool isTransparent)
+: mGraphics(nullptr),
+ mDisplayConnection(nullptr),
+ mPosition(positionSize),
+ mRenderNotification(NULL),
+ mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24),
+ mOwnSurface(false),
+ mProduceBufferIndex(INITIAL_PRODUCE_BUFFER_INDEX),
+ mConsumeBufferIndex(INITIAL_CONSUME_BUFFER_INDEX),
mX11Pixmaps(),
mEglSurfaces(),
- mThreadSynchronization( nullptr ),
+ mThreadSynchronization(nullptr),
mPixmapCondition()
{
- for( int i = 0; i != BUFFER_COUNT; ++i )
+ for(int i = 0; i != BUFFER_COUNT; ++i)
{
- mX11Pixmaps[i] = 0;
+ mX11Pixmaps[i] = 0;
mEglSurfaces[i] = 0;
}
- Initialize( surface );
+ Initialize(surface);
}
PixmapRenderSurfaceEcoreX::~PixmapRenderSurfaceEcoreX()
DestroySurface();
// release the surface if we own one
- if( mOwnSurface )
+ if(mOwnSurface)
{
- for (int i = 0; i < BUFFER_COUNT; ++i)
+ for(int i = 0; i < BUFFER_COUNT; ++i)
{
Ecore_X_Pixmap pixmap = mX11Pixmaps[i];
// if we did create the pixmap, delete the pixmap
- DALI_LOG_INFO( gPixmapRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", pixmap );
- ecore_x_pixmap_free( pixmap );
+ DALI_LOG_INFO(gPixmapRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", pixmap);
+ ecore_x_pixmap_free(pixmap);
}
}
}
-void PixmapRenderSurfaceEcoreX::Initialize( Any surface )
+void PixmapRenderSurfaceEcoreX::Initialize(Any surface)
{
// see if there is a surface in Any surface
- unsigned int surfaceId = GetSurfaceId( surface );
+ unsigned int surfaceId = GetSurfaceId(surface);
// if the surface is empty, create a new one.
- if ( surfaceId == 0 )
+ if(surfaceId == 0)
{
// we own the surface about to created
mOwnSurface = true;
else
{
// XLib should already be initialized so no point in calling XInitThreads
- UseExistingRenderable( surfaceId );
+ UseExistingRenderable(surfaceId);
}
}
{
Ecore_X_Pixmap pixmap = 0;
{
- ConditionalWait::ScopedLock lock( mPixmapCondition );
+ ConditionalWait::ScopedLock lock(mPixmapCondition);
pixmap = mX11Pixmaps[mProduceBufferIndex];
}
- return Any( pixmap );
+ return Any(pixmap);
}
void PixmapRenderSurfaceEcoreX::SetRenderNotification(TriggerEventInterface* renderNotification)
return mPosition;
}
-void PixmapRenderSurfaceEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void PixmapRenderSurfaceEcoreX::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
// calculate DPI
float xres, yres;
xres = ecore_x_dpi_get();
yres = ecore_x_dpi_get();
- dpiHorizontal = int( xres + 0.5f ); // rounding
- dpiVertical = int( yres + 0.5f );
+ dpiHorizontal = int(xres + 0.5f); // rounding
+ dpiVertical = int(yres + 0.5f);
}
int PixmapRenderSurfaceEcoreX::GetOrientation() const
void PixmapRenderSurfaceEcoreX::InitializeGraphics()
{
- mGraphics = &mAdaptor->GetGraphicsInterface();
+ mGraphics = &mAdaptor->GetGraphicsInterface();
mDisplayConnection = &mAdaptor->GetDisplayConnectionInterface();
-
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
eglImpl.ChooseConfig(false, mColorDepth);
}
void PixmapRenderSurfaceEcoreX::CreateSurface()
{
- DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gPixmapRenderSurfaceLogFilter);
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- for (int i = 0; i < BUFFER_COUNT; ++i)
+ for(int i = 0; i < BUFFER_COUNT; ++i)
{
// create the EGL surface
// need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast<XPixmap>( mX11Pixmaps[i] );
- mEglSurfaces[i] = eglImpl.CreateSurfacePixmap( EGLNativePixmapType( pixmap ), mColorDepth ); // reinterpret_cast does not compile
+ XPixmap pixmap = static_cast<XPixmap>(mX11Pixmaps[i]);
+ mEglSurfaces[i] = eglImpl.CreateSurfacePixmap(EGLNativePixmapType(pixmap), mColorDepth); // reinterpret_cast does not compile
}
}
void PixmapRenderSurfaceEcoreX::DestroySurface()
{
- DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gPixmapRenderSurfaceLogFilter);
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- for (int i = 0; i < BUFFER_COUNT; ++i)
+ for(int i = 0; i < BUFFER_COUNT; ++i)
{
// need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast<XPixmap>( mX11Pixmaps[i] );
- eglImpl.MakeCurrent( EGLNativePixmapType( pixmap ), mEglSurfaces[i] );
- eglImpl.DestroySurface( mEglSurfaces[i] );
+ XPixmap pixmap = static_cast<XPixmap>(mX11Pixmaps[i]);
+ eglImpl.MakeCurrent(EGLNativePixmapType(pixmap), mEglSurfaces[i]);
+ eglImpl.DestroySurface(mEglSurfaces[i]);
}
}
bool PixmapRenderSurfaceEcoreX::ReplaceGraphicsSurface()
{
- DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
+ DALI_LOG_TRACE_METHOD(gPixmapRenderSurfaceLogFilter);
bool contextLost = false;
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- for (int i = 0; i < BUFFER_COUNT; ++i)
+ for(int i = 0; i < BUFFER_COUNT; ++i)
{
// a new surface for the new pixmap
// need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast<XPixmap>( mX11Pixmaps[i] );
- contextLost = eglImpl.ReplaceSurfacePixmap( EGLNativePixmapType( pixmap ), mEglSurfaces[i] ); // reinterpret_cast does not compile
+ XPixmap pixmap = static_cast<XPixmap>(mX11Pixmaps[i]);
+ contextLost = eglImpl.ReplaceSurfacePixmap(EGLNativePixmapType(pixmap), mEglSurfaces[i]); // reinterpret_cast does not compile
}
// need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast<XPixmap>( mX11Pixmaps[mProduceBufferIndex] );
- eglImpl.MakeCurrent( EGLNativePixmapType( pixmap ), mEglSurfaces[mProduceBufferIndex] );
+ XPixmap pixmap = static_cast<XPixmap>(mX11Pixmaps[mProduceBufferIndex]);
+ eglImpl.MakeCurrent(EGLNativePixmapType(pixmap), mEglSurfaces[mProduceBufferIndex]);
return contextLost;
}
{
}
-bool PixmapRenderSurfaceEcoreX::PreRender( bool, const std::vector<Rect<int>>&, Rect<int>& )
+bool PixmapRenderSurfaceEcoreX::PreRender(bool, const std::vector<Rect<int>>&, Rect<int>&)
{
// Nothing to do for pixmaps
return true;
}
-void PixmapRenderSurfaceEcoreX::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects )
+void PixmapRenderSurfaceEcoreX::PostRender(bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects)
{
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
// flush gl instruction queue
Integration::GlAbstraction& glAbstraction = eglGraphics->GetGlAbstraction();
glAbstraction.Flush();
- if( mThreadSynchronization )
+ if(mThreadSynchronization)
{
mThreadSynchronization->PostRenderStarted();
}
{
- ConditionalWait::ScopedLock lock( mPixmapCondition );
- mConsumeBufferIndex = __sync_fetch_and_xor( &mProduceBufferIndex, 1 ); // Swap buffer indexes.
+ ConditionalWait::ScopedLock lock(mPixmapCondition);
+ mConsumeBufferIndex = __sync_fetch_and_xor(&mProduceBufferIndex, 1); // Swap buffer indexes.
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
// need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XPixmap pixmap = static_cast<XPixmap>( mX11Pixmaps[mProduceBufferIndex] );
- eglImpl.MakeCurrent( EGLNativePixmapType( pixmap ), mEglSurfaces[mProduceBufferIndex] );
+ XPixmap pixmap = static_cast<XPixmap>(mX11Pixmaps[mProduceBufferIndex]);
+ eglImpl.MakeCurrent(EGLNativePixmapType(pixmap), mEglSurfaces[mProduceBufferIndex]);
}
// create damage for client applications which wish to know the update timing
- if( mRenderNotification )
+ if(mRenderNotification)
{
// use notification trigger
// Tell the event-thread to render the pixmap
else
{
// as a fallback, send damage event.
- Ecore_X_Drawable drawable = Ecore_X_Drawable( mX11Pixmaps[mProduceBufferIndex] );
+ Ecore_X_Drawable drawable = Ecore_X_Drawable(mX11Pixmaps[mProduceBufferIndex]);
- if( drawable )
+ if(drawable)
{
- XRectangle rect;
+ XRectangle rect;
XserverRegion region;
- rect.x = 0;
- rect.y = 0;
- rect.width = mPosition.width;
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = mPosition.width;
rect.height = mPosition.height;
XDisplay* display = AnyCast<XDisplay*>(mDisplayConnection->GetDisplay());
// make a fixes region as updated area
- region = XFixesCreateRegion( display, &rect, 1 );
+ region = XFixesCreateRegion(display, &rect, 1);
// add damage event to updated drawable
- Drawable xdrawable( drawable ); // ecore type is unsigned int whereas in 64bit linux Drawable is long unsigned int
- XDamageAdd( display, xdrawable, region );
- XFixesDestroyRegion( display, region );
+ Drawable xdrawable(drawable); // ecore type is unsigned int whereas in 64bit linux Drawable is long unsigned int
+ XDamageAdd(display, xdrawable, region);
+ XFixesDestroyRegion(display, region);
- XFlush( display );
+ XFlush(display);
}
}
- if( mThreadSynchronization )
+ if(mThreadSynchronization)
{
mThreadSynchronization->PostRenderWaitForCompletion();
}
ReleaseLock();
}
-void PixmapRenderSurfaceEcoreX::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
+void PixmapRenderSurfaceEcoreX::SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization)
{
mThreadSynchronization = &threadSynchronization;
}
void PixmapRenderSurfaceEcoreX::ReleaseLock()
{
- if( mThreadSynchronization )
+ if(mThreadSynchronization)
{
mThreadSynchronization->PostRenderComplete();
}
void PixmapRenderSurfaceEcoreX::CreateRenderable()
{
// check we're creating one with a valid size
- DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid" );
+ DALI_ASSERT_ALWAYS(mPosition.width > 0 && mPosition.height > 0 && "Pixmap size is invalid");
- for (int i = 0; i < BUFFER_COUNT; ++i)
+ for(int i = 0; i < BUFFER_COUNT; ++i)
{
// create the pixmap
mX11Pixmaps[i] = ecore_x_pixmap_new(0, mPosition.width, mPosition.height, mColorDepth);
// clear the pixmap
unsigned int foreground;
- Ecore_X_GC gc;
+ Ecore_X_GC gc;
foreground = 0;
- gc = ecore_x_gc_new( mX11Pixmaps[i],
- ECORE_X_GC_VALUE_MASK_FOREGROUND,
- &foreground );
+ gc = ecore_x_gc_new(mX11Pixmaps[i],
+ ECORE_X_GC_VALUE_MASK_FOREGROUND,
+ &foreground);
- DALI_ASSERT_ALWAYS( gc && "CreateRenderable(): failed to get gc" );
+ DALI_ASSERT_ALWAYS(gc && "CreateRenderable(): failed to get gc");
- ecore_x_drawable_rectangle_fill( mX11Pixmaps[i], gc, 0, 0, mPosition.width, mPosition.height );
+ ecore_x_drawable_rectangle_fill(mX11Pixmaps[i], gc, 0, 0, mPosition.width, mPosition.height);
- DALI_ASSERT_ALWAYS( mX11Pixmaps[i] && "Failed to create X pixmap" );
+ DALI_ASSERT_ALWAYS(mX11Pixmaps[i] && "Failed to create X pixmap");
// we SHOULD guarantee the xpixmap/x11 window was created in x server.
ecore_x_sync();
}
}
-void PixmapRenderSurfaceEcoreX::UseExistingRenderable( unsigned int surfaceId )
+void PixmapRenderSurfaceEcoreX::UseExistingRenderable(unsigned int surfaceId)
{
}
-unsigned int PixmapRenderSurfaceEcoreX::GetSurfaceId( Any surface ) const
+unsigned int PixmapRenderSurfaceEcoreX::GetSurfaceId(Any surface) const
{
unsigned int surfaceId = 0;
- if ( surface.Empty() == false )
+ if(surface.Empty() == false)
{
// check we have a valid type
- DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
- (surface.GetType() == typeid (Ecore_X_Window) ) )
- && "Surface type is invalid" );
+ DALI_ASSERT_ALWAYS(((surface.GetType() == typeid(XWindow)) ||
+ (surface.GetType() == typeid(Ecore_X_Window))) &&
+ "Surface type is invalid");
- if ( surface.GetType() == typeid (Ecore_X_Window) )
+ if(surface.GetType() == typeid(Ecore_X_Window))
{
- surfaceId = AnyCast<Ecore_X_Window>( surface );
+ surfaceId = AnyCast<Ecore_X_Window>(surface);
}
else
{
- surfaceId = AnyCast<XWindow>( surface );
+ surfaceId = AnyCast<XWindow>(surface);
}
}
return surfaceId;
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * 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.
{
namespace Adaptor
{
-
-std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryEcoreX::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowRenderSurface> RenderSurfaceFactoryEcoreX::CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowRenderSurface>(positionSize, surface, isTransparent);
}
-std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreX::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<PixmapRenderSurface> RenderSurfaceFactoryEcoreX::CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< PixmapRenderSurfaceEcoreX >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<PixmapRenderSurfaceEcoreX>(positionSize, surface, isTransparent);
}
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreX::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+std::unique_ptr<NativeRenderSurface> RenderSurfaceFactoryEcoreX::CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent)
{
- return std::unique_ptr< NativeRenderSurface >( nullptr );
+ return std::unique_ptr<NativeRenderSurface>(nullptr);
}
// this should be created from somewhere
-std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
{
// returns Window factory
- return Utils::MakeUnique< RenderSurfaceFactoryEcoreX >();
+ return Utils::MakeUnique<RenderSurfaceFactoryEcoreX>();
}
} // namespace Adaptor
/*
- * 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.
// INTERNAL HEADERS
#include <dali/internal/window-system/common/window-impl.h>
-#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
#include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
// EXTERNAL_HEADERS
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/events/mouse-button.h>
#include <dali/integration-api/debug.h>
#include <dali/internal/input/ubuntu-x11/dali-ecore-input.h>
+#include <dali/public-api/events/mouse-button.h>
+#include <dali/public-api/object/any.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
-const std::string DEFAULT_DEVICE_NAME = "";
-const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
+const std::string DEFAULT_DEVICE_NAME = "";
+const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
-const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
+const unsigned int PRIMARY_TOUCH_BUTTON_ID(1);
#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////
// Window Callbacks
/////////////////////////////////////////////////////////////////////////////////////////////////
-static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowPropertyChanged(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- return windowBase->OnWindowPropertyChanged( data, type, event );
+ return windowBase->OnWindowPropertyChanged(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
/**
* Called when the window receives a delete request
*/
-static Eina_Bool EcoreEventWindowDeleteRequest( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowDeleteRequest(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
windowBase->OnDeleteRequest();
}
/**
* Called when the window gains focus.
*/
-static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowFocusIn(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnFocusIn( data, type, event );
+ windowBase->OnFocusIn(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when the window loses focus.
*/
-static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowFocusOut(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnFocusOut( data, type, event );
+ windowBase->OnFocusOut(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when the window is damaged.
*/
-static Eina_Bool EcoreEventWindowDamaged( void* data, int type, void* event )
+static Eina_Bool EcoreEventWindowDamaged(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnWindowDamaged( data, type, event );
+ windowBase->OnWindowDamaged(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
/**
* Called when the source window notifies us the content in clipboard is selected.
*/
-static Eina_Bool EcoreEventSelectionClear( void* data, int type, void* event )
+static Eina_Bool EcoreEventSelectionClear(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnSelectionClear( data, type, event );
+ windowBase->OnSelectionClear(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
* Called when the source window sends us about the selected content.
* For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
*/
-static Eina_Bool EcoreEventSelectionNotify( void* data, int type, void* event )
+static Eina_Bool EcoreEventSelectionNotify(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnSelectionNotify( data, type, event );
+ windowBase->OnSelectionNotify(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch down is received.
*/
-static Eina_Bool EcoreEventMouseButtonDown( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonDown(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonDown( data, type, event );
+ windowBase->OnMouseButtonDown(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch up is received.
*/
-static Eina_Bool EcoreEventMouseButtonUp( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonUp(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonUp( data, type, event );
+ windowBase->OnMouseButtonUp(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a touch motion is received.
*/
-static Eina_Bool EcoreEventMouseButtonMove( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseButtonMove(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnMouseButtonMove( data, type, event );
+ windowBase->OnMouseButtonMove(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a mouse wheel is received.
*/
-static Eina_Bool EcoreEventMouseWheel( void* data, int type, void* event )
+static Eina_Bool EcoreEventMouseWheel(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnMouseWheel( data, type, event );
+ windowBase->OnMouseWheel(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a key down is received.
*/
-static Eina_Bool EcoreEventKeyDown( void* data, int type, void* event )
+static Eina_Bool EcoreEventKeyDown(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnKeyDown( data, type, event );
+ windowBase->OnKeyDown(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
/**
* Called when a key up is received.
*/
-static Eina_Bool EcoreEventKeyUp( void* data, int type, void* event )
+static Eina_Bool EcoreEventKeyUp(void* data, int type, void* event)
{
- WindowBaseEcoreX* windowBase = static_cast< WindowBaseEcoreX* >( data );
- if( windowBase )
+ WindowBaseEcoreX* windowBase = static_cast<WindowBaseEcoreX*>(data);
+ if(windowBase)
{
- windowBase->OnKeyUp( data, type, event );
+ windowBase->OnKeyUp(data, type, event);
}
return ECORE_CALLBACK_PASS_ON;
}
WindowBaseEcoreX::~WindowBaseEcoreX()
{
- for( Dali::Vector< Ecore_Event_Handler* >::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter )
+ for(Dali::Vector<Ecore_Event_Handler*>::Iterator iter = mEcoreEventHandler.Begin(), endIter = mEcoreEventHandler.End(); iter != endIter; ++iter)
{
- ecore_event_handler_del( *iter );
+ ecore_event_handler_del(*iter);
}
mEcoreEventHandler.Clear();
- if( mOwnSurface )
+ if(mOwnSurface)
{
- ecore_x_window_free( mEcoreWindow );
+ ecore_x_window_free(mEcoreWindow);
WindowSystem::Shutdown();
}
}
-void WindowBaseEcoreX::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+void WindowBaseEcoreX::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
{
// see if there is a surface in Any surface
- unsigned int surfaceId = GetSurfaceId( surface );
+ unsigned int surfaceId = GetSurfaceId(surface);
// if the surface is empty, create a new one.
- if( surfaceId == 0 )
+ if(surfaceId == 0)
{
WindowSystem::Initialize();
// we own the surface about to created
mOwnSurface = true;
- CreateWindow( positionSize, isTransparent );
+ CreateWindow(positionSize, isTransparent);
}
else
{
// XLib should already be initialized so no point in calling XInitThreads
- mEcoreWindow = static_cast< Ecore_X_Window >( surfaceId );
+ mEcoreWindow = static_cast<Ecore_X_Window>(surfaceId);
}
// set up etc properties to match with ecore-evas
- char *id = NULL;
- if( ( id = getenv("DESKTOP_STARTUP_ID") ) )
+ char* id = NULL;
+ if((id = getenv("DESKTOP_STARTUP_ID")))
{
- ecore_x_netwm_startup_id_set( mEcoreWindow, id );
+ ecore_x_netwm_startup_id_set(mEcoreWindow, id);
}
- ecore_x_icccm_hints_set( mEcoreWindow,
- 1, // accepts_focus
- ECORE_X_WINDOW_STATE_HINT_NORMAL, // initial_state
- 0, // icon_pixmap
- 0, // icon_mask
- 0, // icon_window
- 0, // window_group
- 0 ); // is_urgent
+ ecore_x_icccm_hints_set(mEcoreWindow,
+ 1, // accepts_focus
+ ECORE_X_WINDOW_STATE_HINT_NORMAL, // initial_state
+ 0, // icon_pixmap
+ 0, // icon_mask
+ 0, // icon_window
+ 0, // window_group
+ 0); // is_urgent
// we SHOULD guarantee the x11 window was created in x server.
ecore_x_sync();
- ecore_x_input_multi_select( mEcoreWindow );
+ ecore_x_input_multi_select(mEcoreWindow);
// This ensures that we catch the window close (or delete) request
- ecore_x_icccm_protocol_set( mEcoreWindow, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, EINA_TRUE );
+ ecore_x_icccm_protocol_set(mEcoreWindow, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, EINA_TRUE);
// Enable Drag & Drop
- ecore_x_dnd_aware_set( mEcoreWindow, EINA_TRUE );
+ ecore_x_dnd_aware_set(mEcoreWindow, EINA_TRUE);
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DELETE_REQUEST, EcoreEventWindowDeleteRequest, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, EcoreEventWindowPropertyChanged, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, EcoreEventWindowDeleteRequest, this));
// Register window focus events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, this));
// Register Window damage events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, this));
// Register Touch events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, this ) ); // process mouse out event like up event
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, this)); // process mouse out event like up event
// Register Mouse wheel events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this));
// Register Key events
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, EcoreEventKeyDown, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_EVENT_KEY_UP, EcoreEventKeyUp, this));
// Register Selection event
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, this ) );
- mEcoreEventHandler.PushBack( ecore_event_handler_add( ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, this ) );
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, this));
+ mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, this));
}
-Eina_Bool WindowBaseEcoreX::OnWindowPropertyChanged( void* data, int type, void* event )
+Eina_Bool WindowBaseEcoreX::OnWindowPropertyChanged(void* data, int type, void* event)
{
- Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast< Ecore_X_Event_Window_Property* >( event );
- Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
+ Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast<Ecore_X_Event_Window_Property*>(event);
+ Eina_Bool handled(ECORE_CALLBACK_PASS_ON);
- if( propertyChangedEvent->win == mEcoreWindow )
+ if(propertyChangedEvent->win == mEcoreWindow)
{
- Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
+ Ecore_X_Window_State_Hint state(ecore_x_icccm_state_get(propertyChangedEvent->win));
- switch( state )
+ switch(state)
{
case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
{
// Window was hidden.
- mIconifyChangedSignal.Emit( true );
+ mIconifyChangedSignal.Emit(true);
handled = ECORE_CALLBACK_DONE;
break;
}
case ECORE_X_WINDOW_STATE_HINT_ICONIC:
{
// Window was iconified (minimised).
- mIconifyChangedSignal.Emit( true );
+ mIconifyChangedSignal.Emit(true);
handled = ECORE_CALLBACK_DONE;
break;
}
case ECORE_X_WINDOW_STATE_HINT_NORMAL:
{
// Window was shown.
- mIconifyChangedSignal.Emit( false );
+ mIconifyChangedSignal.Emit(false);
handled = ECORE_CALLBACK_DONE;
break;
}
mDeleteRequestSignal.Emit();
}
-void WindowBaseEcoreX::OnFocusIn( void* data, int type, void* event )
+void WindowBaseEcoreX::OnFocusIn(void* data, int type, void* event)
{
- Ecore_X_Event_Window_Focus_In* focusInEvent = static_cast< Ecore_X_Event_Window_Focus_In* >( event );
+ Ecore_X_Event_Window_Focus_In* focusInEvent = static_cast<Ecore_X_Event_Window_Focus_In*>(event);
- if( focusInEvent->win == mEcoreWindow )
+ if(focusInEvent->win == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n");
- mFocusChangedSignal.Emit( true );
+ mFocusChangedSignal.Emit(true);
}
}
-void WindowBaseEcoreX::OnFocusOut( void* data, int type, void* event )
+void WindowBaseEcoreX::OnFocusOut(void* data, int type, void* event)
{
- Ecore_X_Event_Window_Focus_Out* focusOutEvent = static_cast< Ecore_X_Event_Window_Focus_Out* >( event );
+ Ecore_X_Event_Window_Focus_Out* focusOutEvent = static_cast<Ecore_X_Event_Window_Focus_Out*>(event);
// If the window loses focus then hide the keyboard.
- if( focusOutEvent->win == mEcoreWindow )
+ if(focusOutEvent->win == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n");
- mFocusChangedSignal.Emit( false );
+ mFocusChangedSignal.Emit(false);
}
}
-void WindowBaseEcoreX::OnWindowDamaged( void* data, int type, void* event )
+void WindowBaseEcoreX::OnWindowDamaged(void* data, int type, void* event)
{
- Ecore_X_Event_Window_Damage* windowDamagedEvent = static_cast< Ecore_X_Event_Window_Damage* >( event );
+ Ecore_X_Event_Window_Damage* windowDamagedEvent = static_cast<Ecore_X_Event_Window_Damage*>(event);
- if( windowDamagedEvent->win == mEcoreWindow )
+ if(windowDamagedEvent->win == mEcoreWindow)
{
DamageArea area;
- area.x = windowDamagedEvent->x;
- area.y = windowDamagedEvent->y;
- area.width = windowDamagedEvent->w;
+ area.x = windowDamagedEvent->x;
+ area.y = windowDamagedEvent->y;
+ area.width = windowDamagedEvent->w;
area.height = windowDamagedEvent->h;
- mWindowDamagedSignal.Emit( area );
+ mWindowDamagedSignal.Emit(area);
}
}
-void WindowBaseEcoreX::OnMouseButtonDown( void* data, int type, void* event )
+void WindowBaseEcoreX::OnMouseButtonDown(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == mEcoreWindow )
+ if(touchEvent->window == mEcoreWindow)
{
- PointState::Type state ( PointState::DOWN );
+ PointState::Type state(PointState::DOWN);
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( state );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( touchEvent->multi.angle ) );
- if( touchEvent->buttons)
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(state);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(touchEvent->multi.angle));
+ if(touchEvent->buttons)
{
- point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+ point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
}
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreX::OnMouseButtonUp( void* data, int type, void* event )
+void WindowBaseEcoreX::OnMouseButtonUp(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Button* touchEvent = static_cast< Ecore_Event_Mouse_Button* >( event );
+ Ecore_Event_Mouse_Button* touchEvent = static_cast<Ecore_Event_Mouse_Button*>(event);
- if( touchEvent->window == mEcoreWindow )
+ if(touchEvent->window == mEcoreWindow)
{
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::UP );
- point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
- point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
- point.SetPressure( touchEvent->multi.pressure );
- point.SetAngle( Degree( static_cast<float>( touchEvent->multi.angle ) ) );
- if( touchEvent->buttons)
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::UP);
+ point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
+ point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radius_x, touchEvent->multi.radius_y));
+ point.SetPressure(touchEvent->multi.pressure);
+ point.SetAngle(Degree(static_cast<float>(touchEvent->multi.angle)));
+ if(touchEvent->buttons)
{
- point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+ point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
}
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreX::OnMouseButtonMove( void* data, int type, void* event )
+void WindowBaseEcoreX::OnMouseButtonMove(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Move* touchEvent = static_cast< Ecore_Event_Mouse_Move* >( event );
+ Ecore_Event_Mouse_Move* touchEvent = static_cast<Ecore_Event_Mouse_Move*>(event);
- if( touchEvent->window == mEcoreWindow )
+ if(touchEvent->window == mEcoreWindow)
{
Integration::Point point;
- point.SetDeviceId( touchEvent->multi.device );
- point.SetState( PointState::MOTION );
- point.SetScreenPosition( Vector2( static_cast<float>( touchEvent->x ), static_cast<float>( touchEvent->y ) ) );
- point.SetRadius( static_cast<float>( touchEvent->multi.radius ), Vector2( static_cast<float>( touchEvent->multi.radius_x ), static_cast<float>( touchEvent->multi.radius_y ) ) );
- point.SetPressure( static_cast<float>( touchEvent->multi.pressure ) );
- point.SetAngle( Degree( static_cast<float>( touchEvent->multi.angle ) ) );
+ point.SetDeviceId(touchEvent->multi.device);
+ point.SetState(PointState::MOTION);
+ point.SetScreenPosition(Vector2(static_cast<float>(touchEvent->x), static_cast<float>(touchEvent->y)));
+ point.SetRadius(static_cast<float>(touchEvent->multi.radius), Vector2(static_cast<float>(touchEvent->multi.radius_x), static_cast<float>(touchEvent->multi.radius_y)));
+ point.SetPressure(static_cast<float>(touchEvent->multi.pressure));
+ point.SetAngle(Degree(static_cast<float>(touchEvent->multi.angle)));
- mTouchEventSignal.Emit( point, touchEvent->timestamp );
+ mTouchEventSignal.Emit(point, touchEvent->timestamp);
}
}
-void WindowBaseEcoreX::OnMouseWheel( void* data, int type, void* event )
+void WindowBaseEcoreX::OnMouseWheel(void* data, int type, void* event)
{
- Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast< Ecore_Event_Mouse_Wheel* >( event );
+ Ecore_Event_Mouse_Wheel* mouseWheelEvent = static_cast<Ecore_Event_Mouse_Wheel*>(event);
- if( mouseWheelEvent->window == mEcoreWindow )
+ if(mouseWheelEvent->window == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
- Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2( static_cast<float>( mouseWheelEvent->x ), static_cast<float>( mouseWheelEvent->y ) ), mouseWheelEvent->z, mouseWheelEvent->timestamp );
+ Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(static_cast<float>(mouseWheelEvent->x), static_cast<float>(mouseWheelEvent->y)), mouseWheelEvent->z, mouseWheelEvent->timestamp);
- mWheelEventSignal.Emit( wheelEvent );
+ mWheelEventSignal.Emit(wheelEvent);
}
}
-void WindowBaseEcoreX::OnKeyDown( void* data, int type, void* event )
+void WindowBaseEcoreX::OnKeyDown(void* data, int type, void* event)
{
- Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
+ Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
- if( keyEvent->window == mEcoreWindow )
+ if(keyEvent->window == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnKeyDown\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnKeyDown\n");
- std::string keyName( keyEvent->keyname );
- std::string logicalKey( "" );
- std::string keyString( "" );
- std::string compose( "" );
+ std::string keyName(keyEvent->keyname);
+ std::string logicalKey("");
+ std::string keyString("");
+ std::string compose("");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
- if( keyEvent->compose )
+ if(keyEvent->compose)
{
compose = keyEvent->compose;
}
// Ensure key symbol is not NULL as keys like SHIFT have a null string.
- if( keyEvent->key )
+ if(keyEvent->key)
{
logicalKey = keyEvent->key;
}
- int keyCode = ecore_x_keysym_keycode_get( keyEvent->keyname );
- int modifier( keyEvent->modifiers );
+ int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
+ int modifier(keyEvent->modifiers);
unsigned long time = keyEvent->timestamp;
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- if( keyEvent->string )
+ if(keyEvent->string)
{
keyString = keyEvent->string;
}
- Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+ Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseEcoreX::OnKeyUp( void* data, int type, void* event )
+void WindowBaseEcoreX::OnKeyUp(void* data, int type, void* event)
{
- Ecore_Event_Key* keyEvent = static_cast< Ecore_Event_Key* >( event );
+ Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
- if ( keyEvent->window == mEcoreWindow )
+ if(keyEvent->window == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, " WindowBaseEcoreX::OnKeyUp\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, " WindowBaseEcoreX::OnKeyUp\n");
- std::string keyName( keyEvent->keyname );
- std::string logicalKey( "" );
- std::string keyString( "" );
- std::string compose( "" );
+ std::string keyName(keyEvent->keyname);
+ std::string logicalKey("");
+ std::string keyString("");
+ std::string compose("");
// Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
- if( keyEvent->compose )
+ if(keyEvent->compose)
{
compose = keyEvent->compose;
}
// Ensure key symbol is not NULL as keys like SHIFT have a null string.
- if( keyEvent->key )
+ if(keyEvent->key)
{
logicalKey = keyEvent->key;
}
- int keyCode = ecore_x_keysym_keycode_get( keyEvent->keyname );
- int modifier( keyEvent->modifiers );
- unsigned long time( keyEvent->timestamp );
+ int keyCode = ecore_x_keysym_keycode_get(keyEvent->keyname);
+ int modifier(keyEvent->modifiers);
+ unsigned long time(keyEvent->timestamp);
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- if( keyEvent->string )
+ if(keyEvent->string)
{
keyString = keyEvent->string;
}
- Integration::KeyEvent keyEvent( keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+ Integration::KeyEvent keyEvent(keyName, logicalKey, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseEcoreX::OnSelectionClear( void* data, int type, void* event )
+void WindowBaseEcoreX::OnSelectionClear(void* data, int type, void* event)
{
- Ecore_X_Event_Selection_Clear* selectionClearEvent = static_cast< Ecore_X_Event_Selection_Clear* >( event );
+ Ecore_X_Event_Selection_Clear* selectionClearEvent = static_cast<Ecore_X_Event_Selection_Clear*>(event);
- if( selectionClearEvent->win == mEcoreWindow )
+ if(selectionClearEvent->win == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, " WindowBaseEcoreX::OnSelectionClear\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, " WindowBaseEcoreX::OnSelectionClear\n");
- if( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ if(selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY)
{
// Request to get the content from Ecore.
- ecore_x_selection_secondary_request( selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT );
+ ecore_x_selection_secondary_request(selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT);
}
}
}
-void WindowBaseEcoreX::OnSelectionNotify( void* data, int type, void* event )
+void WindowBaseEcoreX::OnSelectionNotify(void* data, int type, void* event)
{
- Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast< Ecore_X_Event_Selection_Notify* >( event );
+ Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast<Ecore_X_Event_Selection_Notify*>(event);
- if( selectionNotifyEvent->win == mEcoreWindow )
+ if(selectionNotifyEvent->win == mEcoreWindow)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, " WindowBaseEcoreX::OnSelectionNotify\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::Concise, " WindowBaseEcoreX::OnSelectionNotify\n");
- Ecore_X_Selection_Data* selectionData = static_cast< Ecore_X_Selection_Data* >( selectionNotifyEvent->data );
- if( selectionData->data )
+ Ecore_X_Selection_Data* selectionData = static_cast<Ecore_X_Selection_Data*>(selectionNotifyEvent->data);
+ if(selectionData->data)
{
- if( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY )
+ if(selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY)
{
- mSelectionDataReceivedSignal.Emit( event );
+ mSelectionDataReceivedSignal.Emit(event);
}
}
}
return mEcoreWindow;
}
-EGLNativeWindowType WindowBaseEcoreX::CreateEglWindow( int width, int height )
+EGLNativeWindowType WindowBaseEcoreX::CreateEglWindow(int width, int height)
{
// need to create X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
- XWindow window( mEcoreWindow );
- return reinterpret_cast< EGLNativeWindowType >( window );
+ XWindow window(mEcoreWindow);
+ return reinterpret_cast<EGLNativeWindowType>(window);
}
void WindowBaseEcoreX::DestroyEglWindow()
{
}
-void WindowBaseEcoreX::SetEglWindowRotation( int angle )
+void WindowBaseEcoreX::SetEglWindowRotation(int angle)
{
}
-void WindowBaseEcoreX::SetEglWindowBufferTransform( int angle )
+void WindowBaseEcoreX::SetEglWindowBufferTransform(int angle)
{
}
-void WindowBaseEcoreX::SetEglWindowTransform( int angle )
+void WindowBaseEcoreX::SetEglWindowTransform(int angle)
{
}
-void WindowBaseEcoreX::ResizeEglWindow( PositionSize positionSize )
+void WindowBaseEcoreX::ResizeEglWindow(PositionSize positionSize)
{
}
return false;
}
-void WindowBaseEcoreX::Move( PositionSize positionSize )
+void WindowBaseEcoreX::Move(PositionSize positionSize)
{
- ecore_x_window_move( mEcoreWindow, positionSize.x, positionSize.y );
+ ecore_x_window_move(mEcoreWindow, positionSize.x, positionSize.y);
}
-void WindowBaseEcoreX::Resize( PositionSize positionSize )
+void WindowBaseEcoreX::Resize(PositionSize positionSize)
{
- ecore_x_window_resize( mEcoreWindow, positionSize.width, positionSize.height );
+ ecore_x_window_resize(mEcoreWindow, positionSize.width, positionSize.height);
}
-void WindowBaseEcoreX::MoveResize( PositionSize positionSize )
+void WindowBaseEcoreX::MoveResize(PositionSize positionSize)
{
- ecore_x_window_move_resize( mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
+ ecore_x_window_move_resize(mEcoreWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
}
-void WindowBaseEcoreX::SetClass( const std::string& name, const std::string& className )
+void WindowBaseEcoreX::SetClass(const std::string& name, const std::string& className)
{
- ecore_x_icccm_title_set( mEcoreWindow, name.c_str() );
- ecore_x_netwm_name_set( mEcoreWindow, name.c_str() );
- ecore_x_icccm_name_class_set( mEcoreWindow, name.c_str(), className.c_str() );
+ ecore_x_icccm_title_set(mEcoreWindow, name.c_str());
+ ecore_x_netwm_name_set(mEcoreWindow, name.c_str());
+ ecore_x_icccm_name_class_set(mEcoreWindow, name.c_str(), className.c_str());
}
void WindowBaseEcoreX::Raise()
{
- ecore_x_window_raise( mEcoreWindow );
+ ecore_x_window_raise(mEcoreWindow);
}
void WindowBaseEcoreX::Lower()
{
- ecore_x_window_lower( mEcoreWindow );
+ ecore_x_window_lower(mEcoreWindow);
}
void WindowBaseEcoreX::Activate()
{
- ecore_x_netwm_client_active_request( ecore_x_window_root_get( mEcoreWindow ), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0 );
+ ecore_x_netwm_client_active_request(ecore_x_window_root_get(mEcoreWindow), mEcoreWindow, 1 /* request type, 1:application, 2:pager */, 0);
}
-void WindowBaseEcoreX::SetAvailableAnlges( const std::vector< int >& angles )
+void WindowBaseEcoreX::SetAvailableAnlges(const std::vector<int>& angles)
{
}
-void WindowBaseEcoreX::SetPreferredAngle( int angle )
+void WindowBaseEcoreX::SetPreferredAngle(int angle)
{
}
-void WindowBaseEcoreX::SetAcceptFocus( bool accept )
+void WindowBaseEcoreX::SetAcceptFocus(bool accept)
{
}
void WindowBaseEcoreX::Show()
{
- ecore_x_window_show( mEcoreWindow );
+ ecore_x_window_show(mEcoreWindow);
}
void WindowBaseEcoreX::Hide()
{
- ecore_x_window_hide( mEcoreWindow );
+ ecore_x_window_hide(mEcoreWindow);
}
unsigned int WindowBaseEcoreX::GetSupportedAuxiliaryHintCount() const
return 0;
}
-std::string WindowBaseEcoreX::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string WindowBaseEcoreX::GetSupportedAuxiliaryHint(unsigned int index) const
{
return std::string();
}
-unsigned int WindowBaseEcoreX::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int WindowBaseEcoreX::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
return 0;
}
-bool WindowBaseEcoreX::RemoveAuxiliaryHint( unsigned int id )
+bool WindowBaseEcoreX::RemoveAuxiliaryHint(unsigned int id)
{
return false;
}
-bool WindowBaseEcoreX::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool WindowBaseEcoreX::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
return false;
}
-std::string WindowBaseEcoreX::GetAuxiliaryHintValue( unsigned int id ) const
+std::string WindowBaseEcoreX::GetAuxiliaryHintValue(unsigned int id) const
{
return std::string();
}
-unsigned int WindowBaseEcoreX::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int WindowBaseEcoreX::GetAuxiliaryHintId(const std::string& hint) const
{
return 0;
}
-void WindowBaseEcoreX::SetInputRegion( const Rect< int >& inputRegion )
+void WindowBaseEcoreX::SetInputRegion(const Rect<int>& inputRegion)
{
}
-void WindowBaseEcoreX::SetType( Dali::WindowType type )
+void WindowBaseEcoreX::SetType(Dali::WindowType type)
{
}
-bool WindowBaseEcoreX::SetNotificationLevel( Dali::WindowNotificationLevel level )
+bool WindowBaseEcoreX::SetNotificationLevel(Dali::WindowNotificationLevel level)
{
return false;
}
-Dali::WindowNotificationLevel WindowBaseEcoreX::GetNotificationLevel() const
+Dali::WindowNotificationLevel WindowBaseEcoreX::GetNotificationLevel() const
{
return Dali::WindowNotificationLevel::NONE;
}
-void WindowBaseEcoreX::SetOpaqueState( bool opaque )
+void WindowBaseEcoreX::SetOpaqueState(bool opaque)
{
}
return WindowScreenOffMode::TIMEOUT;
}
-bool WindowBaseEcoreX::SetBrightness( int brightness )
+bool WindowBaseEcoreX::SetBrightness(int brightness)
{
return false;
}
return 0;
}
-bool WindowBaseEcoreX::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+bool WindowBaseEcoreX::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
{
return false;
}
-bool WindowBaseEcoreX::UngrabKey( Dali::KEY key )
+bool WindowBaseEcoreX::UngrabKey(Dali::KEY key)
{
return false;
}
-bool WindowBaseEcoreX::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+bool WindowBaseEcoreX::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
{
return false;
}
-bool WindowBaseEcoreX::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+bool WindowBaseEcoreX::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
{
return false;
}
-void WindowBaseEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void WindowBaseEcoreX::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
// 1 inch = 25.4 millimeters
// ecore does not account for differing DPI in the x and y axes, so only get for x is available
return 0;
}
-void WindowBaseEcoreX::SetWindowRotationAngle( int degree )
+void WindowBaseEcoreX::SetWindowRotationAngle(int degree)
{
mWindowRotationAngle = degree;
}
-void WindowBaseEcoreX::WindowRotationCompleted( int degree, int width, int height )
+void WindowBaseEcoreX::WindowRotationCompleted(int degree, int width, int height)
{
}
-void WindowBaseEcoreX::SetTransparency( bool transparent )
+void WindowBaseEcoreX::SetTransparency(bool transparent)
{
}
-unsigned int WindowBaseEcoreX::GetSurfaceId( Any surface ) const
+unsigned int WindowBaseEcoreX::GetSurfaceId(Any surface) const
{
unsigned int surfaceId = 0;
- if ( surface.Empty() == false )
+ if(surface.Empty() == false)
{
// check we have a valid type
- DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) || (surface.GetType() == typeid (Ecore_X_Window) ) )
- && "Surface type is invalid" );
+ DALI_ASSERT_ALWAYS(((surface.GetType() == typeid(XWindow)) || (surface.GetType() == typeid(Ecore_X_Window))) && "Surface type is invalid");
- if ( surface.GetType() == typeid (Ecore_X_Window) )
+ if(surface.GetType() == typeid(Ecore_X_Window))
{
- surfaceId = AnyCast< Ecore_X_Window >( surface );
+ surfaceId = AnyCast<Ecore_X_Window>(surface);
}
else
{
- surfaceId = static_cast<unsigned int>( AnyCast< XWindow >( surface ) );
+ surfaceId = static_cast<unsigned int>(AnyCast<XWindow>(surface));
}
}
return surfaceId;
}
-void WindowBaseEcoreX::CreateWindow( PositionSize positionSize, bool isTransparent )
+void WindowBaseEcoreX::CreateWindow(PositionSize positionSize, bool isTransparent)
{
- if( isTransparent )
- {
- // create 32 bit window
- mEcoreWindow = ecore_x_window_argb_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
- mIsTransparent = true;
- }
- else
- {
- // create 24 bit window
- mEcoreWindow = ecore_x_window_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
- }
+ if(isTransparent)
+ {
+ // create 32 bit window
+ mEcoreWindow = ecore_x_window_argb_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
+ mIsTransparent = true;
+ }
+ else
+ {
+ // create 24 bit window
+ mEcoreWindow = ecore_x_window_new(0, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
+ }
- if ( mEcoreWindow == 0 )
- {
- DALI_ASSERT_ALWAYS( 0 && "Failed to create X window" );
- }
+ if(mEcoreWindow == 0)
+ {
+ DALI_ASSERT_ALWAYS(0 && "Failed to create X window");
+ }
}
-void WindowBaseEcoreX::SetParent( WindowBase* parentWinBase )
+void WindowBaseEcoreX::SetParent(WindowBase* parentWinBase)
{
Ecore_X_Window ecoreParent = 0;
- if( parentWinBase )
+ if(parentWinBase)
{
- WindowBaseEcoreX* winBaseEcoreX = static_cast<WindowBaseEcoreX*>( parentWinBase );
- ecoreParent = winBaseEcoreX->mEcoreWindow;
- ecore_x_icccm_transient_for_set( mEcoreWindow, ecoreParent );
+ WindowBaseEcoreX* winBaseEcoreX = static_cast<WindowBaseEcoreX*>(parentWinBase);
+ ecoreParent = winBaseEcoreX->mEcoreWindow;
+ ecore_x_icccm_transient_for_set(mEcoreWindow, ecoreParent);
}
else
{
ecoreParent = 0;
- ecore_x_icccm_transient_for_unset( mEcoreWindow );
+ ecore_x_icccm_transient_for_unset(mEcoreWindow);
}
}
/*
- * Copyright (c) 2018 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.
#include <dali/internal/window-system/ubuntu-x11/window-factory-ecore-x.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h>
#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/ubuntu-x11/window-base-ecore-x.h>
namespace Dali
{
{
namespace Adaptor
{
-
-std::unique_ptr< WindowBase > WindowFactoryEcoreX::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowBase> WindowFactoryEcoreX::CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowBaseEcoreX >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowBaseEcoreX>(positionSize, surface, isTransparent);
}
// this should be created from Window impl
-std::unique_ptr< WindowFactory > GetWindowFactory()
+std::unique_ptr<WindowFactory> GetWindowFactory()
{
// returns Window factory
- return Utils::MakeUnique< WindowFactoryEcoreX >();
+ return Utils::MakeUnique<WindowFactoryEcoreX>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2017 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace ECore
{
-
namespace WindowInterface
{
// CONSTANTS
Ecore_X_Window GetWindow()
{
- Ecore_X_Atom xAtomCbhm = ecore_x_atom_get( CBHM_WINDOW );
+ Ecore_X_Atom xAtomCbhm = ecore_x_atom_get(CBHM_WINDOW);
Ecore_X_Window xCbhmWin = 0;
- unsigned char *buf = NULL;
- int num = 0;
+ unsigned char* buf = NULL;
+ int num = 0;
// XA_WINDOW is a macro with C cast
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
- int ret = ecore_x_window_prop_property_get( 0, xAtomCbhm, XA_WINDOW, 0, &buf, &num );
+ int ret = ecore_x_window_prop_property_get(0, xAtomCbhm, XA_WINDOW, 0, &buf, &num);
#pragma GCC diagnostic pop
- if ( ret && num )
+ if(ret && num)
{
- memcpy( &xCbhmWin, buf, sizeof( Ecore_X_Window ) );
+ memcpy(&xCbhmWin, buf, sizeof(Ecore_X_Window));
}
- if ( buf )
+ if(buf)
{
- free( buf );
+ free(buf);
}
return xCbhmWin;
}
-std::string GetWindowProperty( Ecore_X_Atom property, Ecore_X_Atom *xDataType, unsigned int num )
+std::string GetWindowProperty(Ecore_X_Atom property, Ecore_X_Atom* xDataType, unsigned int num)
{
- std::string data("");
-
- if ( !property )
- {
- return data;
- }
-
- ecore_x_sync();
-
- long unsigned int numRet = 0, bytes = 0;
- int ret = 0, sizeRet;
- unsigned int i;
- unsigned char *propRet;
- Ecore_X_Atom typeRet;
-
- // X11 Function to get window property
- ret = XGetWindowProperty( static_cast<Display*>(ecore_x_display_get()), // Display* X Server Connection
- GetWindow(), // Window window in question
- property, // Atom name of property
- num, // long offset where required data is stored
- LONG_MAX, // long length of data to retrieve
- False, // Bool flag to delete data
- ecore_x_window_prop_any_type(), // Atom atom id associated to property type
- reinterpret_cast< Atom * >( &typeRet ), // Atom actual_type_return, atom id property type
- &sizeRet, // int* format of property
- &numRet, // unsigned long* number of items being returned in prop_return
- &bytes, // unsigned long* remaining bytes if partial retrieval
- &propRet ); // unsigned char** return data
- if ( ret != Success )
- {
- return data;
- }
-
- if ( !numRet )
- {
- XFree( propRet );
- return data;
- }
-
- numRet--; // As propRet in XGetWindowProperty gets an extra 0 added for compatibility reasons.
-
- switch ( sizeRet ) // Format returned by XGetWindowProperty int, short, long
- {
- case 8:
- {
- for ( i = 0; i < numRet; i++ )
- {
- data += propRet[i];
- }
- }
- break;
-
- case 16:
- {
- for ( i = 0; i < numRet; i++ )
- {
- data += ( propRet )[i];
- }
- }
- break;
-
- case 32:
- {
- for ( i = 0; i < numRet; i++ )
- {
- data += ( propRet )[i];
- }
- }
- break;
- }
-
- XFree( propRet );
-
- if ( xDataType )
- {
- *xDataType = typeRet;
- }
-
- return data;
+ std::string data("");
+
+ if(!property)
+ {
+ return data;
+ }
+
+ ecore_x_sync();
+
+ long unsigned int numRet = 0, bytes = 0;
+ int ret = 0, sizeRet;
+ unsigned int i;
+ unsigned char* propRet;
+ Ecore_X_Atom typeRet;
+
+ // X11 Function to get window property
+ ret = XGetWindowProperty(static_cast<Display*>(ecore_x_display_get()), // Display* X Server Connection
+ GetWindow(), // Window window in question
+ property, // Atom name of property
+ num, // long offset where required data is stored
+ LONG_MAX, // long length of data to retrieve
+ False, // Bool flag to delete data
+ ecore_x_window_prop_any_type(), // Atom atom id associated to property type
+ reinterpret_cast<Atom*>(&typeRet), // Atom actual_type_return, atom id property type
+ &sizeRet, // int* format of property
+ &numRet, // unsigned long* number of items being returned in prop_return
+ &bytes, // unsigned long* remaining bytes if partial retrieval
+ &propRet); // unsigned char** return data
+ if(ret != Success)
+ {
+ return data;
+ }
+
+ if(!numRet)
+ {
+ XFree(propRet);
+ return data;
}
-void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate,
- long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char *msg )
+ numRet--; // As propRet in XGetWindowProperty gets an extra 0 added for compatibility reasons.
+
+ switch(sizeRet) // Format returned by XGetWindowProperty int, short, long
+ {
+ case 8:
+ {
+ for(i = 0; i < numRet; i++)
+ {
+ data += propRet[i];
+ }
+ }
+ break;
+
+ case 16:
+ {
+ for(i = 0; i < numRet; i++)
+ {
+ data += (propRet)[i];
+ }
+ }
+ break;
+
+ case 32:
+ {
+ for(i = 0; i < numRet; i++)
+ {
+ data += (propRet)[i];
+ }
+ }
+ break;
+ }
+
+ XFree(propRet);
+
+ if(xDataType)
+ {
+ *xDataType = typeRet;
+ }
+
+ return data;
+}
+
+void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate, long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char* msg)
{
XClientMessageEvent message;
- memset(&message, 0, sizeof( message ) );
- message.type = ClientMessage;
- message.display = static_cast<Display*>( display );
+ memset(&message, 0, sizeof(message));
+ message.type = ClientMessage;
+ message.display = static_cast<Display*>(display);
message.message_type = messageType;
- message.format = messageFormat;
- message.window = window;
+ message.format = messageFormat;
+ message.window = window;
snprintf(message.data.b, 20, "%s", msg);
- XSendEvent( static_cast<Display*>( display ), window, propagate, eventMask, reinterpret_cast< XEvent* >( &message ) );
+ XSendEvent(static_cast<Display*>(display), window, propagate, eventMask, reinterpret_cast<XEvent*>(&message));
}
-
} // namespace WindowInterface
-
} // namespace ECore
} // namespace Adaptor
/*
- * Copyright (c) 2019 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.
*/
// INTERNAL HEADERS
-#include <dali/internal/window-system/common/window-system.h>
#include <dali/devel-api/adaptor-framework/keyboard.h>
+#include <dali/internal/window-system/common/window-system.h>
// EXTERNAL_HEADERS
#include <dali/internal/system/linux/dali-ecore-x.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace WindowSystem
{
-
void Initialize()
{
- ecore_x_init( NULL );
+ ecore_x_init(NULL);
}
void Shutdown()
ecore_x_shutdown();
}
-void GetScreenSize( int& width, int& height )
+void GetScreenSize(int& width, int& height)
{
- ecore_x_screen_size_get( ecore_x_default_screen_get(), &width, &height );
+ ecore_x_screen_size_get(ecore_x_default_screen_get(), &width, &height);
}
-bool SetKeyboardRepeatInfo( float rate, float delay )
+bool SetKeyboardRepeatInfo(float rate, float delay)
{
return false;
}
-bool GetKeyboardRepeatInfo( float& rate, float& delay )
+bool GetKeyboardRepeatInfo(float& rate, float& delay)
{
return false;
}
/*
- * Copyright (c) 2018 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.
{
namespace Adaptor
{
-
-
-
std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> DisplayConnectionFactoryWin::CreateDisplayConnection()
{
return Utils::MakeUnique<DisplayConnectionWin>();
return Utils::MakeUnique<DisplayConnectionFactoryWin>();
}
-}
-}
-}
\ No newline at end of file
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
\ No newline at end of file
/*\r
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
*\r
*/\r
\r
- // CLASS HEADER\r
+// CLASS HEADER\r
#include <dali/internal/window-system/windows/display-connection-impl-win.h>\r
\r
// EXTERNAL INCLUDES\r
\r
namespace Dali\r
{\r
-\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
DisplayConnection* DisplayConnectionWin::New()\r
{\r
DisplayConnection* pDisplayConnection(new DisplayConnectionWin());\r
\r
bool DisplayConnectionWin::InitializeEgl(EglInterface& egl)\r
{\r
- EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );\r
+ EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);\r
\r
- if( !eglImpl.InitializeGles( reinterpret_cast<EGLNativeDisplayType>( mDisplay ) ) )\r
+ if(!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))\r
{\r
- DALI_LOG_ERROR( "Failed to initialize GLES.\n" );\r
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");\r
return false;\r
}\r
\r
\r
bool DisplayConnectionWin::InitializeGraphics()\r
{\r
- auto eglGraphics = static_cast<EglGraphics *>( mGraphics );\r
- EglImplementation& eglImpl = eglGraphics->GetEglImplementation();\r
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);\r
+ EglImplementation& eglImpl = eglGraphics->GetEglImplementation();\r
\r
- if( !eglImpl.InitializeGles( reinterpret_cast<EGLNativeDisplayType>( mDisplay ) ) )\r
+ if(!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))\r
{\r
- DALI_LOG_ERROR( "Failed to initialize GLES.\n" );\r
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");\r
return false;\r
}\r
\r
return true;\r
}\r
\r
-void DisplayConnectionWin::SetSurfaceType( Dali::RenderSurfaceInterface::Type type )\r
+void DisplayConnectionWin::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)\r
{\r
- if( type == Dali::RenderSurfaceInterface::WINDOW_RENDER_SURFACE )\r
+ if(type == Dali::RenderSurfaceInterface::WINDOW_RENDER_SURFACE)\r
{\r
- mDisplay = GetDC( GetForegroundWindow() );\r
+ mDisplay = GetDC(GetForegroundWindow());\r
}\r
}\r
\r
-void DisplayConnectionWin::SetGraphicsInterface( GraphicsInterface& graphics )\r
+void DisplayConnectionWin::SetGraphicsInterface(GraphicsInterface& graphics)\r
{\r
mGraphics = &graphics;\r
}\r
/*
-* Copyright (c) 2018 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.
#include <dali/internal/window-system/windows/platform-implement-win.h>
// EXTERNAL INCLUDES
-#include <map>
#include <windows.h>
+#include <map>
// INTERNAL INCLUDES
#include <dali/internal/window-system/windows/event-system-win.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace WindowsPlatform
{
-
-LRESULT CALLBACK WinProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+LRESULT CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- WindowImpl::ProcWinMessage( reinterpret_cast<uint64_t>( hWnd ), uMsg, wParam, lParam );
+ WindowImpl::ProcWinMessage(reinterpret_cast<uint64_t>(hWnd), uMsg, wParam, lParam);
- LRESULT ret = DefWindowProc( hWnd, uMsg, wParam, lParam );
+ LRESULT ret = DefWindowProc(hWnd, uMsg, wParam, lParam);
return ret;
}
namespace
{
-
const std::string DALI_WINDOW_CLASS_NAME = "DaliWindow";
uint32_t sNumWindows = 0;
void EnsureWindowClassRegistered()
{
- if (sNumWindows == 0)
+ if(sNumWindows == 0)
{
- WNDCLASS cs = { 0 };
- cs.cbClsExtra = 0;
- cs.cbWndExtra = 0;
+ WNDCLASS cs = {0};
+ cs.cbClsExtra = 0;
+ cs.cbWndExtra = 0;
cs.hbrBackground = (HBRUSH)(COLOR_WINDOW + 2);
- cs.hCursor = NULL;
- cs.hIcon = NULL;
- cs.hInstance = GetModuleHandle(NULL);
- cs.lpfnWndProc = (WNDPROC)WinProc;
+ cs.hCursor = NULL;
+ cs.hIcon = NULL;
+ cs.hInstance = GetModuleHandle(NULL);
+ cs.lpfnWndProc = (WNDPROC)WinProc;
cs.lpszClassName = DALI_WINDOW_CLASS_NAME.c_str();
- cs.lpszMenuName = NULL;
- cs.style = CS_VREDRAW | CS_HREDRAW;
+ cs.lpszMenuName = NULL;
+ cs.style = CS_VREDRAW | CS_HREDRAW;
RegisterClass(&cs);
}
}
void EnsureWindowClassUnregistered()
{
- if (sNumWindows == 0)
+ if(sNumWindows == 0)
{
UnregisterClass(DALI_WINDOW_CLASS_NAME.c_str(), GetModuleHandle(NULL));
}
void RemoveListener(uint64_t hWnd)
{
std::map<uint64_t, WindowImpl*>::iterator x = sHWndToListener.find(hWnd);
- if (sHWndToListener.end() != x)
+ if(sHWndToListener.end() != x)
{
sHWndToListener.erase(x);
}
}
-}
+} // namespace
-const uint32_t WindowImpl::STYLE = WS_OVERLAPPED;
-const int32_t WindowImpl::EDGE_WIDTH = 8;
-const int32_t WindowImpl::EDGE_HEIGHT = 18;
+const uint32_t WindowImpl::STYLE = WS_OVERLAPPED;
+const int32_t WindowImpl::EDGE_WIDTH = 8;
+const int32_t WindowImpl::EDGE_HEIGHT = 18;
WindowImpl::WindowImpl()
{
colorDepth = -1;
- mHWnd = 0;
- mHdc = 0;
- listener = NULL;
+ mHWnd = 0;
+ mHdc = 0;
+ listener = NULL;
}
WindowImpl::~WindowImpl()
RemoveListener(mHWnd);
}
-void WindowImpl::ProcWinMessage( uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam )
+void WindowImpl::ProcWinMessage(uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam)
{
- std::map<uint64_t, WindowImpl*>::iterator x = sHWndToListener.find( hWnd );
+ std::map<uint64_t, WindowImpl*>::iterator x = sHWndToListener.find(hWnd);
- if( sHWndToListener.end() != x )
+ if(sHWndToListener.end() != x)
{
CallbackBase* listener = x->second->listener;
- if( NULL != listener )
+ if(NULL != listener)
{
- TWinEventInfo eventInfo( hWnd, uMsg, wParam, lParam );
- CallbackBase::Execute( *listener, &eventInfo );
+ TWinEventInfo eventInfo(hWnd, uMsg, wParam, lParam);
+ CallbackBase::Execute(*listener, &eventInfo);
}
}
}
-void WindowImpl::GetDPI( float &xDpi, float &yDpi )
+void WindowImpl::GetDPI(float& xDpi, float& yDpi)
{
- HDC hdcScreen = GetDC( reinterpret_cast<HWND>( mHWnd ) );
+ HDC hdcScreen = GetDC(reinterpret_cast<HWND>(mHWnd));
- int32_t iX = GetDeviceCaps( hdcScreen, HORZRES ); // pixel
- int32_t iY = GetDeviceCaps( hdcScreen, VERTRES ); // pixel
- int32_t iPhsX = GetDeviceCaps( hdcScreen, HORZSIZE ); // mm
- int32_t iPhsY = GetDeviceCaps( hdcScreen, VERTSIZE ); // mm
+ int32_t iX = GetDeviceCaps(hdcScreen, HORZRES); // pixel
+ int32_t iY = GetDeviceCaps(hdcScreen, VERTRES); // pixel
+ int32_t iPhsX = GetDeviceCaps(hdcScreen, HORZSIZE); // mm
+ int32_t iPhsY = GetDeviceCaps(hdcScreen, VERTSIZE); // mm
- xDpi = static_cast<float>( iX ) / static_cast<float>( iPhsX ) * INCH;
- yDpi = static_cast<float>( iY ) / static_cast<float>( iPhsY ) * INCH;
+ xDpi = static_cast<float>(iX) / static_cast<float>(iPhsX) * INCH;
+ yDpi = static_cast<float>(iY) / static_cast<float>(iPhsY) * INCH;
}
int WindowImpl::GetColorDepth()
{
- DALI_ASSERT_DEBUG( colorDepth >= 0 && "HWND hasn't been created, no color depth" );
+ DALI_ASSERT_DEBUG(colorDepth >= 0 && "HWND hasn't been created, no color depth");
return colorDepth;
}
uint64_t WindowImpl::CreateHwnd(
- _In_opt_ const char *lpWindowName,
- _In_ int X,
- _In_ int Y,
- _In_ int nWidth,
- _In_ int nHeight,
- _In_opt_ uint64_t parent )
+ _In_opt_ const char* lpWindowName,
+ _In_ int X,
+ _In_ int Y,
+ _In_ int nWidth,
+ _In_ int nHeight,
+ _In_opt_ uint64_t parent)
{
EnsureWindowClassRegistered();
++sNumWindows;
- HWND hWnd = CreateWindow( DALI_WINDOW_CLASS_NAME.c_str(), lpWindowName, STYLE, X, Y,
- nWidth + 2 * EDGE_WIDTH, nHeight + 2 * EDGE_HEIGHT, NULL, NULL, GetModuleHandle(NULL), NULL );
- ::ShowWindow( hWnd, SW_SHOW );
+ HWND hWnd = CreateWindow(DALI_WINDOW_CLASS_NAME.c_str(), lpWindowName, STYLE, X, Y, nWidth + 2 * EDGE_WIDTH, nHeight + 2 * EDGE_HEIGHT, NULL, NULL, GetModuleHandle(NULL), NULL);
+ ::ShowWindow(hWnd, SW_SHOW);
return reinterpret_cast<uint64_t>(hWnd);
}
void WindowImpl::DestroyHWnd(uint64_t hWnd)
{
- if (hWnd != 0)
+ if(hWnd != 0)
{
::DestroyWindow(reinterpret_cast<HWND>(hWnd));
}
}
-void WindowImpl::SetListener( CallbackBase *callback )
+void WindowImpl::SetListener(CallbackBase* callback)
{
listener = callback;
}
bool WindowImpl::PostWinMessage(
_In_ uint32_t Msg,
_In_ uint64_t wParam,
- _In_ uint64_t lParam )
+ _In_ uint64_t lParam)
{
- return (bool)PostMessage( reinterpret_cast<HWND>( mHWnd ), Msg, wParam, lParam );
+ return (bool)PostMessage(reinterpret_cast<HWND>(mHWnd), Msg, wParam, lParam);
}
-void WindowImpl::SetHWND( uint64_t inHWnd )
+void WindowImpl::SetHWND(uint64_t inHWnd)
{
- if (mHWnd != inHWnd)
+ if(mHWnd != inHWnd)
{
RemoveListener(mHWnd);
- mHWnd = inHWnd;
- mHdc = reinterpret_cast<uint64_t>(GetDC(reinterpret_cast<HWND>(mHWnd)));
+ mHWnd = inHWnd;
+ mHdc = reinterpret_cast<uint64_t>(GetDC(reinterpret_cast<HWND>(mHWnd)));
colorDepth = GetDeviceCaps(reinterpret_cast<HDC>(mHdc), BITSPIXEL) * GetDeviceCaps(reinterpret_cast<HDC>(mHdc), PLANES);
std::map<uint64_t, WindowImpl*>::iterator x = sHWndToListener.find(mHWnd);
- if (sHWndToListener.end() == x)
+ if(sHWndToListener.end() == x)
{
sHWndToListener.insert(std::make_pair(mHWnd, this));
}
GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(&WinProc));
- if (0 == ret)
+ if(0 == ret)
{
DWORD error = GetLastError();
return;
}
HMODULE module = GetModuleHandle(nullptr);
- ret = SetWindowLongPtr((HWND)mHWnd,
+ ret = SetWindowLongPtr((HWND)mHWnd,
GWLP_HINSTANCE,
reinterpret_cast<LONG_PTR>(&module));
}
_In_ uint32_t Msg,
_In_ uint64_t wParam,
_In_ uint64_t lParam,
- _In_ uint64_t threadID/* = -1*/ )
+ _In_ uint64_t threadID /* = -1*/)
{
- if( -1 == threadID )
+ if(-1 == threadID)
{
threadID = GetCurrentThreadId();
}
- return (bool)PostThreadMessage( threadID, Msg, wParam, lParam );
+ return (bool)PostThreadMessage(threadID, Msg, wParam, lParam);
}
struct TTimerCallbackInfo
{
- void *data;
+ void* data;
timerCallback callback;
- HWND hWnd;
+ HWND hWnd;
};
void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nTimerid, DWORD dwTime)
{
- TTimerCallbackInfo *info = (TTimerCallbackInfo*)nTimerid;
- info->callback( info->data );
+ TTimerCallbackInfo* info = (TTimerCallbackInfo*)nTimerid;
+ info->callback(info->data);
}
-intptr_t SetTimer(int interval, timerCallback callback, void *data)
+intptr_t SetTimer(int interval, timerCallback callback, void* data)
{
HWND hwnd = GetActiveWindow();
- if (!hwnd)
+ if(!hwnd)
{
hwnd = FindWindow(DALI_WINDOW_CLASS_NAME.c_str(), nullptr);
}
- if (!hwnd)
+ if(!hwnd)
{
return -1;
}
- TTimerCallbackInfo *callbackInfo = new TTimerCallbackInfo;
- callbackInfo->data = data;
- callbackInfo->callback = callback;
- callbackInfo->hWnd = hwnd;
+ TTimerCallbackInfo* callbackInfo = new TTimerCallbackInfo;
+ callbackInfo->data = data;
+ callbackInfo->callback = callback;
+ callbackInfo->hWnd = hwnd;
INT_PTR timerID = (INT_PTR)callbackInfo;
- ::SetTimer( hwnd, timerID, interval, TimerProc );
+ ::SetTimer(hwnd, timerID, interval, TimerProc);
return timerID;
}
void KillTimer(intptr_t id)
{
- TTimerCallbackInfo *info = (TTimerCallbackInfo*)id;
- ::KillTimer( info->hWnd, id );
+ TTimerCallbackInfo* info = (TTimerCallbackInfo*)id;
+ ::KillTimer(info->hWnd, id);
delete info;
}
-std::string GetKeyName( int keyCode )
+std::string GetKeyName(int keyCode)
{
- switch( keyCode )
+ switch(keyCode)
{
case VK_BACK:
{
}
default:
{
- if (keyCode > 0 && keyCode < 128)
+ if(keyCode > 0 && keyCode < 128)
{
return std::string(1u, static_cast<char>(keyCode));
}
return "";
}
-static LARGE_INTEGER cpuFrequency;
-static LARGE_INTEGER *pCpuFrequency = NULL;
+static LARGE_INTEGER cpuFrequency;
+static LARGE_INTEGER* pCpuFrequency = NULL;
uint64_t GetCurrentThreadId()
{
return ::GetCurrentThreadId();
}
-void GetNanoseconds( uint64_t& timeInNanoseconds )
+void GetNanoseconds(uint64_t& timeInNanoseconds)
{
- if( NULL == pCpuFrequency )
+ if(NULL == pCpuFrequency)
{
pCpuFrequency = &cpuFrequency;
- QueryPerformanceFrequency( pCpuFrequency );
+ QueryPerformanceFrequency(pCpuFrequency);
}
LARGE_INTEGER curTime;
- QueryPerformanceCounter( &curTime );
+ QueryPerformanceCounter(&curTime);
timeInNanoseconds = static_cast<double>(curTime.QuadPart) / static_cast<double>(pCpuFrequency->QuadPart) * 1000000000;
}
-unsigned int GetCurrentMilliSeconds( void )
+unsigned int GetCurrentMilliSeconds(void)
{
- if( NULL == pCpuFrequency )
+ if(NULL == pCpuFrequency)
{
pCpuFrequency = &cpuFrequency;
- QueryPerformanceFrequency( pCpuFrequency );
+ QueryPerformanceFrequency(pCpuFrequency);
}
LARGE_INTEGER curTime;
- QueryPerformanceCounter( &curTime );
+ QueryPerformanceCounter(&curTime);
return curTime.QuadPart * 1000 / pCpuFrequency->QuadPart;
}
-} // namespace WindowsPlatformImplement
+} // namespace WindowsPlatform
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
/*
- * 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.
{
namespace Adaptor
{
-
-std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryWin::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowRenderSurface> RenderSurfaceFactoryWin::CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowRenderSurface>(positionSize, surface, isTransparent);
}
-std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryWin::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<PixmapRenderSurface> RenderSurfaceFactoryWin::CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
DALI_LOG_ERROR("Pixmap isn't been supported in Windows");
return nullptr;
}
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryWin::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+std::unique_ptr<NativeRenderSurface> RenderSurfaceFactoryWin::CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent)
{
- return std::unique_ptr< NativeRenderSurface >( nullptr );
+ return std::unique_ptr<NativeRenderSurface>(nullptr);
}
// this should be created from somewhere
-std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
{
// returns Window factory
- return Utils::MakeUnique< RenderSurfaceFactoryWin >();
+ return Utils::MakeUnique<RenderSurfaceFactoryWin>();
}
} // namespace Adaptor
/*
- * 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.
#include <dali/internal/window-system/windows/window-base-win.h>
// EXTERNAL_HEADERS
-#include <dali/public-api/object/any.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/any.h>
// INTERNAL HEADERS
#include <dali/internal/window-system/common/window-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
-const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
+const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
-const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
+const unsigned int PRIMARY_TOUCH_BUTTON_ID(1);
#if defined(DEBUG_ENABLED)
-Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
#endif
} // unnamed namespace
-WindowBaseWin::WindowBaseWin( Dali::PositionSize positionSize, Any surface, bool isTransparent )
-: mWin32Window( 0 ),
- mOwnSurface( false ),
- mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
- mRotationAppSet( false )
+WindowBaseWin::WindowBaseWin(Dali::PositionSize positionSize, Any surface, bool isTransparent)
+: mWin32Window(0),
+ mOwnSurface(false),
+ mIsTransparent(false), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
+ mRotationAppSet(false)
{
- Initialize( positionSize, surface, isTransparent );
+ Initialize(positionSize, surface, isTransparent);
}
WindowBaseWin::~WindowBaseWin()
{
- mWindowImpl.PostWinMessage( WM_CLOSE, 0, 0 );
+ mWindowImpl.PostWinMessage(WM_CLOSE, 0, 0);
}
-void WindowBaseWin::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+void WindowBaseWin::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
{
// see if there is a surface in Any surface
- uintptr_t surfaceId = GetSurfaceId( surface );
+ uintptr_t surfaceId = GetSurfaceId(surface);
// if the surface is empty, create a new one.
- if( surfaceId == 0 )
+ if(surfaceId == 0)
{
// we own the surface about to created
mOwnSurface = true;
- CreateWinWindow( positionSize, isTransparent );
+ CreateWinWindow(positionSize, isTransparent);
}
else
{
- SetWinWindow( surfaceId );
+ SetWinWindow(surfaceId);
}
- mWindowImpl.SetListener( MakeCallback( this, &WindowBaseWin::EventEntry ) );
+ mWindowImpl.SetListener(MakeCallback(this, &WindowBaseWin::EventEntry));
}
void WindowBaseWin::OnDeleteRequest()
mDeleteRequestSignal.Emit();
}
-void WindowBaseWin::OnFocusIn( int type, TWinEventInfo *event )
+void WindowBaseWin::OnFocusIn(int type, TWinEventInfo* event)
{
}
-void WindowBaseWin::OnFocusOut( int type, TWinEventInfo *event )
+void WindowBaseWin::OnFocusOut(int type, TWinEventInfo* event)
{
}
-void WindowBaseWin::OnWindowDamaged( int type, TWinEventInfo *event )
+void WindowBaseWin::OnWindowDamaged(int type, TWinEventInfo* event)
{
- Event_Mouse_Button* windowDamagedEvent( (Event_Mouse_Button*)event );
+ Event_Mouse_Button* windowDamagedEvent((Event_Mouse_Button*)event);
- if( windowDamagedEvent->window == mWin32Window )
+ if(windowDamagedEvent->window == mWin32Window)
{
DamageArea area;
area.x = 0;
area.y = 0;
- WindowSystem::GetScreenSize( area.width, area.height );
+ WindowSystem::GetScreenSize(area.width, area.height);
- mWindowDamagedSignal.Emit( area );
+ mWindowDamagedSignal.Emit(area);
}
}
-void WindowBaseWin::OnMouseButtonDown( int type, TWinEventInfo *event )
+void WindowBaseWin::OnMouseButtonDown(int type, TWinEventInfo* event)
{
Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event);
- touchEvent.timestamp = GetTickCount();
- touchEvent.x = LOWORD( event->lParam );
- touchEvent.y = HIWORD( event->lParam );
- touchEvent.multi.device = DEVICE_MOUSE;
+ touchEvent.timestamp = GetTickCount();
+ touchEvent.x = LOWORD(event->lParam);
+ touchEvent.y = HIWORD(event->lParam);
+ touchEvent.multi.device = DEVICE_MOUSE;
- if( touchEvent.window == mWin32Window )
+ if(touchEvent.window == mWin32Window)
{
- PointState::Type state ( PointState::DOWN );
+ PointState::Type state(PointState::DOWN);
Integration::Point point;
- point.SetDeviceId( touchEvent.multi.device );
- point.SetState( state );
- point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatform::WindowImpl::EDGE_HEIGHT ) );
- point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
- point.SetPressure( touchEvent.multi.pressure );
- point.SetAngle( Degree( touchEvent.multi.angle ) );
-
- mTouchEventSignal.Emit( point, touchEvent.timestamp );
+ point.SetDeviceId(touchEvent.multi.device);
+ point.SetState(state);
+ point.SetScreenPosition(Vector2(touchEvent.x, touchEvent.y + WindowsPlatform::WindowImpl::EDGE_HEIGHT));
+ point.SetRadius(touchEvent.multi.radius, Vector2(touchEvent.multi.radius_x, touchEvent.multi.radius_y));
+ point.SetPressure(touchEvent.multi.pressure);
+ point.SetAngle(Degree(touchEvent.multi.angle));
+
+ mTouchEventSignal.Emit(point, touchEvent.timestamp);
}
}
-void WindowBaseWin::OnMouseButtonUp( int type, TWinEventInfo *event )
+void WindowBaseWin::OnMouseButtonUp(int type, TWinEventInfo* event)
{
- Event_Mouse_Button touchEvent = *( (Event_Mouse_Button*)event );
- touchEvent.timestamp = GetTickCount();
- touchEvent.x = LOWORD( event->lParam );
- touchEvent.y = HIWORD( event->lParam );
- touchEvent.multi.device = DEVICE_MOUSE;
+ Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event);
+ touchEvent.timestamp = GetTickCount();
+ touchEvent.x = LOWORD(event->lParam);
+ touchEvent.y = HIWORD(event->lParam);
+ touchEvent.multi.device = DEVICE_MOUSE;
- if( touchEvent.window == mWin32Window )
+ if(touchEvent.window == mWin32Window)
{
- PointState::Type state( PointState::UP );
+ PointState::Type state(PointState::UP);
Integration::Point point;
- point.SetDeviceId( touchEvent.multi.device );
- point.SetState( state );
- point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatform::WindowImpl::EDGE_HEIGHT ) );
- point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
- point.SetPressure( touchEvent.multi.pressure );
- point.SetAngle( Degree( touchEvent.multi.angle ) );
-
- mTouchEventSignal.Emit( point, touchEvent.timestamp );
+ point.SetDeviceId(touchEvent.multi.device);
+ point.SetState(state);
+ point.SetScreenPosition(Vector2(touchEvent.x, touchEvent.y + WindowsPlatform::WindowImpl::EDGE_HEIGHT));
+ point.SetRadius(touchEvent.multi.radius, Vector2(touchEvent.multi.radius_x, touchEvent.multi.radius_y));
+ point.SetPressure(touchEvent.multi.pressure);
+ point.SetAngle(Degree(touchEvent.multi.angle));
+
+ mTouchEventSignal.Emit(point, touchEvent.timestamp);
}
}
-void WindowBaseWin::OnMouseButtonMove( int type, TWinEventInfo *event )
+void WindowBaseWin::OnMouseButtonMove(int type, TWinEventInfo* event)
{
Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event);
- touchEvent.timestamp = GetTickCount();
- touchEvent.x = LOWORD( event->lParam );
- touchEvent.y = HIWORD( event->lParam );
- touchEvent.multi.device = DEVICE_MOUSE;
+ touchEvent.timestamp = GetTickCount();
+ touchEvent.x = LOWORD(event->lParam);
+ touchEvent.y = HIWORD(event->lParam);
+ touchEvent.multi.device = DEVICE_MOUSE;
- if( touchEvent.window == mWin32Window )
+ if(touchEvent.window == mWin32Window)
{
- PointState::Type state( PointState::MOTION );
+ PointState::Type state(PointState::MOTION);
Integration::Point point;
- point.SetDeviceId( touchEvent.multi.device );
- point.SetState( state );
- point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatform::WindowImpl::EDGE_HEIGHT) );
- point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
- point.SetPressure( touchEvent.multi.pressure );
- point.SetAngle( Degree( touchEvent.multi.angle ) );
-
- mTouchEventSignal.Emit( point, touchEvent.timestamp );
+ point.SetDeviceId(touchEvent.multi.device);
+ point.SetState(state);
+ point.SetScreenPosition(Vector2(touchEvent.x, touchEvent.y + WindowsPlatform::WindowImpl::EDGE_HEIGHT));
+ point.SetRadius(touchEvent.multi.radius, Vector2(touchEvent.multi.radius_x, touchEvent.multi.radius_y));
+ point.SetPressure(touchEvent.multi.pressure);
+ point.SetAngle(Degree(touchEvent.multi.angle));
+
+ mTouchEventSignal.Emit(point, touchEvent.timestamp);
}
}
-void WindowBaseWin::OnMouseWheel( int type, TWinEventInfo *event )
+void WindowBaseWin::OnMouseWheel(int type, TWinEventInfo* event)
{
- Event_Mouse_Wheel mouseWheelEvent = *((Event_Mouse_Wheel*)( event ));
+ Event_Mouse_Wheel mouseWheelEvent = *((Event_Mouse_Wheel*)(event));
- if( mouseWheelEvent.window == mWin32Window )
+ if(mouseWheelEvent.window == mWin32Window)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent.direction, mouseWheelEvent.modifiers, mouseWheelEvent.x, mouseWheelEvent.y, mouseWheelEvent.z );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent.direction, mouseWheelEvent.modifiers, mouseWheelEvent.x, mouseWheelEvent.y, mouseWheelEvent.z);
- Integration::WheelEvent wheelEvent( Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2( mouseWheelEvent.x, mouseWheelEvent.y ), mouseWheelEvent.z, mouseWheelEvent.timestamp );
+ Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2(mouseWheelEvent.x, mouseWheelEvent.y), mouseWheelEvent.z, mouseWheelEvent.timestamp);
- mWheelEventSignal.Emit( wheelEvent );
+ mWheelEventSignal.Emit(wheelEvent);
}
}
-void WindowBaseWin::OnKeyDown( int type, TWinEventInfo *event )
+void WindowBaseWin::OnKeyDown(int type, TWinEventInfo* event)
{
- if( event->mWindow == mWin32Window )
+ if(event->mWindow == mWin32Window)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n");
- int keyCode = event->wParam;
- std::string keyName( WindowsPlatform::GetKeyName( keyCode ) );
+ int keyCode = event->wParam;
+ std::string keyName(WindowsPlatform::GetKeyName(keyCode));
std::string keyString;
std::string emptyString;
- int modifier( 0 );
- unsigned long time( 0 );
+ int modifier(0);
+ unsigned long time(0);
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- keyString.push_back( event->wParam );
+ keyString.push_back(event->wParam);
- Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+ Integration::KeyEvent keyEvent(keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::DOWN, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
-void WindowBaseWin::OnKeyUp( int type, TWinEventInfo *event )
+void WindowBaseWin::OnKeyUp(int type, TWinEventInfo* event)
{
- if( event->mWindow == mWin32Window )
+ if(event->mWindow == mWin32Window)
{
- DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" );
+ DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n");
- int keyCode = event->wParam;
- std::string keyName( WindowsPlatform::GetKeyName( keyCode ) );
+ int keyCode = event->wParam;
+ std::string keyName(WindowsPlatform::GetKeyName(keyCode));
std::string keyString;
std::string emptyString;
- int modifier( 0 );
- unsigned long time( 0 );
+ int modifier(0);
+ unsigned long time(0);
// Ensure key event string is not NULL as keys like SHIFT have a null string.
- keyString.push_back( event->wParam );
+ keyString.push_back(event->wParam);
- Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+ Integration::KeyEvent keyEvent(keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::UP, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS);
- mKeyEventSignal.Emit( keyEvent );
+ mKeyEventSignal.Emit(keyEvent);
}
}
return mWin32Window;
}
-EGLNativeWindowType WindowBaseWin::CreateEglWindow( int width, int height )
+EGLNativeWindowType WindowBaseWin::CreateEglWindow(int width, int height)
{
- return reinterpret_cast< EGLNativeWindowType >( mWin32Window );
+ return reinterpret_cast<EGLNativeWindowType>(mWin32Window);
}
void WindowBaseWin::DestroyEglWindow()
{
}
-void WindowBaseWin::SetEglWindowRotation( int angle )
+void WindowBaseWin::SetEglWindowRotation(int angle)
{
}
-void WindowBaseWin::SetEglWindowBufferTransform( int angle )
+void WindowBaseWin::SetEglWindowBufferTransform(int angle)
{
}
-void WindowBaseWin::SetEglWindowTransform( int angle )
+void WindowBaseWin::SetEglWindowTransform(int angle)
{
}
-void WindowBaseWin::ResizeEglWindow( PositionSize positionSize )
+void WindowBaseWin::ResizeEglWindow(PositionSize positionSize)
{
}
return false;
}
-void WindowBaseWin::Move( PositionSize positionSize )
+void WindowBaseWin::Move(PositionSize positionSize)
{
}
-void WindowBaseWin::Resize( PositionSize positionSize )
+void WindowBaseWin::Resize(PositionSize positionSize)
{
- ::SetWindowPos( (HWND)mWin32Window, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height, SWP_SHOWWINDOW );
+ ::SetWindowPos((HWND)mWin32Window, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height, SWP_SHOWWINDOW);
}
-void WindowBaseWin::MoveResize( PositionSize positionSize )
+void WindowBaseWin::MoveResize(PositionSize positionSize)
{
}
-void WindowBaseWin::SetClass( const std::string& name, const std::string& className )
+void WindowBaseWin::SetClass(const std::string& name, const std::string& className)
{
}
{
}
-void WindowBaseWin::SetAvailableAnlges( const std::vector< int >& angles )
+void WindowBaseWin::SetAvailableAnlges(const std::vector<int>& angles)
{
}
-void WindowBaseWin::SetPreferredAngle( int angle )
+void WindowBaseWin::SetPreferredAngle(int angle)
{
}
-void WindowBaseWin::SetAcceptFocus( bool accept )
+void WindowBaseWin::SetAcceptFocus(bool accept)
{
}
return 0;
}
-std::string WindowBaseWin::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string WindowBaseWin::GetSupportedAuxiliaryHint(unsigned int index) const
{
return std::string();
}
-unsigned int WindowBaseWin::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+unsigned int WindowBaseWin::AddAuxiliaryHint(const std::string& hint, const std::string& value)
{
return 0;
}
-bool WindowBaseWin::RemoveAuxiliaryHint( unsigned int id )
+bool WindowBaseWin::RemoveAuxiliaryHint(unsigned int id)
{
return false;
}
-bool WindowBaseWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool WindowBaseWin::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
return false;
}
-std::string WindowBaseWin::GetAuxiliaryHintValue( unsigned int id ) const
+std::string WindowBaseWin::GetAuxiliaryHintValue(unsigned int id) const
{
return std::string();
}
-unsigned int WindowBaseWin::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int WindowBaseWin::GetAuxiliaryHintId(const std::string& hint) const
{
return 0;
}
-void WindowBaseWin::SetInputRegion( const Rect< int >& inputRegion )
+void WindowBaseWin::SetInputRegion(const Rect<int>& inputRegion)
{
}
-void WindowBaseWin::SetType( Dali::WindowType type )
+void WindowBaseWin::SetType(Dali::WindowType type)
{
}
-bool WindowBaseWin::SetNotificationLevel( Dali::WindowNotificationLevel level )
+bool WindowBaseWin::SetNotificationLevel(Dali::WindowNotificationLevel level)
{
return false;
}
return Dali::WindowNotificationLevel::NONE;
}
-void WindowBaseWin::SetOpaqueState( bool opaque )
+void WindowBaseWin::SetOpaqueState(bool opaque)
{
}
return WindowScreenOffMode::TIMEOUT;
}
-bool WindowBaseWin::SetBrightness( int brightness )
+bool WindowBaseWin::SetBrightness(int brightness)
{
return false;
}
return 0;
}
-bool WindowBaseWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+bool WindowBaseWin::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
{
return false;
}
-bool WindowBaseWin::UngrabKey( Dali::KEY key )
+bool WindowBaseWin::UngrabKey(Dali::KEY key)
{
return false;
}
-bool WindowBaseWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+bool WindowBaseWin::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
{
return false;
}
-bool WindowBaseWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+bool WindowBaseWin::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
{
return false;
}
-void WindowBaseWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+void WindowBaseWin::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
{
// calculate DPI
float xres, yres;
//// 1 inch = 25.4 millimeters
- mWindowImpl.GetDPI( xres, yres );
+ mWindowImpl.GetDPI(xres, yres);
xres *= 1.5f;
yres *= 1.5f;
- dpiHorizontal = static_cast<int>( xres + 0.5f ); // rounding
- dpiVertical = static_cast<int>( yres + 0.5f );
+ dpiHorizontal = static_cast<int>(xres + 0.5f); // rounding
+ dpiVertical = static_cast<int>(yres + 0.5f);
}
int WindowBaseWin::GetScreenRotationAngle()
return 0;
}
-void WindowBaseWin::SetWindowRotationAngle( int degree )
+void WindowBaseWin::SetWindowRotationAngle(int degree)
{
}
-void WindowBaseWin::WindowRotationCompleted( int degree, int width, int height )
+void WindowBaseWin::WindowRotationCompleted(int degree, int width, int height)
{
}
-void WindowBaseWin::SetTransparency( bool transparent )
+void WindowBaseWin::SetTransparency(bool transparent)
{
}
return 0;
}
-uintptr_t WindowBaseWin::GetSurfaceId( Any surface ) const
+uintptr_t WindowBaseWin::GetSurfaceId(Any surface) const
{
uintptr_t surfaceId = 0;
- if ( surface.Empty() == false )
+ if(surface.Empty() == false)
{
// check we have a valid type
- DALI_ASSERT_ALWAYS( (surface.GetType() == typeid ( WinWindowHandle ) )
- && "Surface type is invalid" );
+ DALI_ASSERT_ALWAYS((surface.GetType() == typeid(WinWindowHandle)) && "Surface type is invalid");
- surfaceId = AnyCast< WinWindowHandle >( surface );
+ surfaceId = AnyCast<WinWindowHandle>(surface);
}
return surfaceId;
}
-void WindowBaseWin::CreateWinWindow( PositionSize positionSize, bool isTransparent )
+void WindowBaseWin::CreateWinWindow(PositionSize positionSize, bool isTransparent)
{
- long hWnd = WindowsPlatform::WindowImpl::CreateHwnd( "Demo", positionSize.x, positionSize.y, positionSize.width, positionSize.height, NULL );
+ long hWnd = WindowsPlatform::WindowImpl::CreateHwnd("Demo", positionSize.x, positionSize.y, positionSize.width, positionSize.height, NULL);
mWindowImpl.SetHWND(hWnd);
mWin32Window = static_cast<WinWindowHandle>(hWnd);
- DALI_ASSERT_ALWAYS( mWin32Window != 0 && "There is no Windows window" );
+ DALI_ASSERT_ALWAYS(mWin32Window != 0 && "There is no Windows window");
}
-void WindowBaseWin::SetWinWindow( uintptr_t surfaceId )
+void WindowBaseWin::SetWinWindow(uintptr_t surfaceId)
{
HWND hWnd = (HWND)surfaceId;
mWindowImpl.SetWinProc();
}
-void WindowBaseWin::EventEntry( TWinEventInfo *event )
+void WindowBaseWin::EventEntry(TWinEventInfo* event)
{
unsigned int uMsg = event->uMsg;
- switch( uMsg )
- {
- case WM_SETFOCUS:
- {
- OnFocusIn( uMsg, event );
- break;
- }
-
- case WM_KILLFOCUS:
- {
- OnFocusOut( uMsg, event );
- break;
- }
-
- case WM_PAINT:
- {
- OnWindowDamaged( uMsg, event );
- break;
- }
-
- case WM_LBUTTONDOWN:
- {
- OnMouseButtonDown( uMsg, event );
- break;
- }
-
- case WM_LBUTTONUP:
- {
- OnMouseButtonUp( uMsg, event );
- break;
- }
-
- case WM_MOUSEMOVE:
- {
- OnMouseButtonMove( uMsg, event );
- break;
- }
-
- case WM_MOUSEWHEEL:
- {
- OnMouseWheel( uMsg, event );
- break;
- }
-
- case WM_KEYDOWN:
- {
- OnKeyDown( uMsg, event );
- break;
- }
-
- case WM_KEYUP:
+ switch(uMsg)
{
- OnKeyUp( uMsg, event );
- break;
- }
-
- default:
- break;
+ case WM_SETFOCUS:
+ {
+ OnFocusIn(uMsg, event);
+ break;
+ }
+
+ case WM_KILLFOCUS:
+ {
+ OnFocusOut(uMsg, event);
+ break;
+ }
+
+ case WM_PAINT:
+ {
+ OnWindowDamaged(uMsg, event);
+ break;
+ }
+
+ case WM_LBUTTONDOWN:
+ {
+ OnMouseButtonDown(uMsg, event);
+ break;
+ }
+
+ case WM_LBUTTONUP:
+ {
+ OnMouseButtonUp(uMsg, event);
+ break;
+ }
+
+ case WM_MOUSEMOVE:
+ {
+ OnMouseButtonMove(uMsg, event);
+ break;
+ }
+
+ case WM_MOUSEWHEEL:
+ {
+ OnMouseWheel(uMsg, event);
+ break;
+ }
+
+ case WM_KEYDOWN:
+ {
+ OnKeyDown(uMsg, event);
+ break;
+ }
+
+ case WM_KEYUP:
+ {
+ OnKeyUp(uMsg, event);
+ break;
+ }
+
+ default:
+ break;
}
}
-void WindowBaseWin::SetParent( WindowBase* parentWinBase )
+void WindowBaseWin::SetParent(WindowBase* parentWinBase)
{
-
}
int WindowBaseWin::CreateFrameRenderedSyncFence()
} // namespace Internal
} // namespace Dali
-
/*
- * Copyright (c) 2018 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.
#include <dali/internal/window-system/windows/window-factory-win.h>
// INTERNAL HEADERS
-#include <dali/internal/window-system/windows/window-base-win.h>
#include <dali/internal/window-system/common/display-utils.h>
+#include <dali/internal/window-system/windows/window-base-win.h>
namespace Dali
{
{
namespace Adaptor
{
-
-std::unique_ptr< WindowBase > WindowFactoryWin::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+std::unique_ptr<WindowBase> WindowFactoryWin::CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent)
{
- return Utils::MakeUnique< WindowBaseWin >( positionSize, surface, isTransparent );
+ return Utils::MakeUnique<WindowBaseWin>(positionSize, surface, isTransparent);
}
// this should be created from Window impl
-std::unique_ptr< WindowFactory > GetWindowFactory()
+std::unique_ptr<WindowFactory> GetWindowFactory()
{
// returns Window factory
- return Utils::MakeUnique< WindowFactoryWin >();
+ return Utils::MakeUnique<WindowFactoryWin>();
}
} // namespace Adaptor
/*
- * Copyright (c) 2018 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.
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace WindowSystem
{
-
void Initialize()
{
}
-void GetScreenSize( int& width, int& height )
+void GetScreenSize(int& width, int& height)
{
- width = GetSystemMetrics( SM_CXSCREEN );
- height = GetSystemMetrics( SM_CYSCREEN );
+ width = GetSystemMetrics(SM_CXSCREEN);
+ height = GetSystemMetrics(SM_CYSCREEN);
}
-bool SetKeyboardRepeatInfo( float rate, float delay )
+bool SetKeyboardRepeatInfo(float rate, float delay)
{
return false;
}
-bool GetKeyboardRepeatInfo( float& rate, float& delay )
+bool GetKeyboardRepeatInfo(float& rate, float& delay)
{
return false;
}
} // namespace Internal
} // namespace Dali
-
/*
- * Copyright (c) 2018 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.
#include "dali-feedback.h"
// EXTERNAL INCLUDES
-#include <iostream>
-#include <fstream>
#include <feedback.h>
#include <mm_sound.h>
#include <mm_sound_private.h>
+#include <fstream>
+#include <iostream>
#include <dlog.h>
-#define DEBUG_PRINTF(fmt, arg...) LOGD(" " fmt, ##arg)
+#define DEBUG_PRINTF(fmt, arg...) LOGD(" " fmt, ##arg)
using std::string;
using namespace Dali;
namespace Dali
{
-
namespace Plugin
{
-
DaliFeedback::DaliFeedback()
{
feedback_initialize();
feedback_deinitialize();
}
-void DaliFeedback::PlayHaptic( const std::string& filePath )
+void DaliFeedback::PlayHaptic(const std::string& filePath)
{
}
-void DaliFeedback::PlayHapticMonotone( unsigned int duration )
+void DaliFeedback::PlayHapticMonotone(unsigned int duration)
{
}
{
}
-int DaliFeedback::PlaySound( const std::string& fileName )
+int DaliFeedback::PlaySound(const std::string& fileName)
{
- int handle = -1;
- int errorCode = mm_sound_play_keysound( fileName.c_str(), VOLUME_TYPE_SYSTEM & VOLUME_GAIN_TOUCH );
- if( errorCode < 0 )
+ int handle = -1;
+ int errorCode = mm_sound_play_keysound(fileName.c_str(), VOLUME_TYPE_SYSTEM & VOLUME_GAIN_TOUCH);
+ if(errorCode < 0)
{
- DEBUG_PRINTF( "PlaySound() %s failed with error code = %d\n", fileName.c_str(), errorCode );
+ DEBUG_PRINTF("PlaySound() %s failed with error code = %d\n", fileName.c_str(), errorCode);
}
return handle;
}
-void DaliFeedback::StopSound( int handle )
+void DaliFeedback::StopSound(int handle)
{
- int errorCode = mm_sound_stop_keysound( NULL );
- if( errorCode < 0 )
+ int errorCode = mm_sound_stop_keysound(NULL);
+ if(errorCode < 0)
{
- DEBUG_PRINTF( "StopSound() handle = %d failed with error code = %d\n", handle, errorCode);
+ DEBUG_PRINTF("StopSound() handle = %d failed with error code = %d\n", handle, errorCode);
}
else
{
- DEBUG_PRINTF( "stop handle %d success\n", handle );
+ DEBUG_PRINTF("stop handle %d success\n", handle);
}
}
-void DaliFeedback::PlayFeedbackPattern( int type, int pattern )
+void DaliFeedback::PlayFeedbackPattern(int type, int pattern)
{
- int errorCode = feedback_play_type( static_cast<feedback_type_e>(type), static_cast<feedback_pattern_e>(pattern) );
- if( errorCode != 0 )
+ int errorCode = feedback_play_type(static_cast<feedback_type_e>(type), static_cast<feedback_pattern_e>(pattern));
+ if(errorCode != 0)
{
- DEBUG_PRINTF( "DaliFeedback::PlayFeedbackPattern() with type = %d, pattern = %d returned with error = %d\n", (int)type, (int)pattern, errorCode );
+ DEBUG_PRINTF("DaliFeedback::PlayFeedbackPattern() with type = %d, pattern = %d returned with error = %d\n", (int)type, (int)pattern, errorCode);
}
}
} // namespace Plugin
} // namespace Dali
-