/debuglinks.list
/debugsources.list
/dali/internal/adaptor/common/system-cache-path.cpp
+.clangd
+compile_commands.json
* [3. Building for MS Windows](#3-building-for-ms-windows)
* Build with the Visual Studio project.
* Build with CMake.
+ * [4. Building for MacOS](#4-building-for-macos)
# Build Instructions
- INSTALL_CMAKE_MODULES ---> Whether to install the CMake modules (Used by the CMake command find_package() to find previously installed libraries).
- PROFILE_LCASE ---> The platform (must be windows).
- ENABLE_DEBUG ---> Whether to build with debug enabled.
+
+## 4. Building for MacOS
+
+It is assumed that the DALi environment has been set up & that DALi Core has been built accordingly.
+
+To build the repository enter the 'build/tizen' folder:
+```zsh
+% cd dali-adaptor/build/tizen
+```
+Then run the following command to set up the build:
+```zsh
+% cmake -DCMAKE_INSTALL_PREFIX=$DESKTOP_PREFIX -DCMAKE_TOOLCHAIN_FILE=$VCPKG_FOLDER/scripts/buildsystems/vcpkg.cmake -DINSTALL_CMAKE_MODULES=ON -DENABLE_PROFILE=MACOS -DPROFILE_LCASE=macos
+```
+If a Debug build is required, then add `-DCMAKE_BUILD_TYPE=Debug -DENABLE_DEBUG=ON`
+
+To build, run:
+```zsh
+% make install -j8
+```
#!/bin/bash
-TEMP=`getopt -o dhsSmf --long debug,help,failnorerun,serial,tct,modules -n 'execute.sh' -- "$@"`
+TEMP=`getopt -o dhsSmfq --long debug,help,failnorerun,quiet,serial,tct,modules -n 'execute.sh' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
function usage
{
- echo -e "Usage: execute.sh [-d][-s|-S|-r] [module|testcase]"
+ echo -e "Usage: execute.sh [-d][-s|-S|-r][-q] [module|testcase]"
echo -e " execute.sh\t\tExecute test cases from all modules in parallel"
echo -e " execute.sh -f \tExecute test cases from all modules in parallel without rerunning failed test cases"
echo -e " execute.sh -d <testcase>\tDebug testcase"
echo -e " execute.sh [module]\tExecute test cases from the given module in parallel"
echo -e " execute.sh -s [module]\t\tExecute test cases in serial using Testkit-Lite"
echo -e " execute.sh -S [module]\t\tExecute test cases in serial"
+ echo -e " execute.sh -q|--quiet ...\tExecute test cases, but don't write output"
echo -e " execute.sh <testcase>\tFind and execute the given test case"
exit 2
}
opt_modules=0
opt_debug=0
opt_noFailedRerun="";
+opt_quiet="";
while true ; do
case "$1" in
-h|--help) usage ;;
-s|--tct) opt_tct=1 ; shift ;;
-f|--nofailedrerun) opt_noFailedRerun="-f" ; shift ;;
-S|--serial) opt_serial="-s" ; shift ;;
+ -q|--quiet) opt_quiet="-q" ; shift ;;
-m|--modules) opt_modules=1 ; shift ;;
--) shift; break;;
*) echo "Internal error $1!" ; exit 1 ;;
EOF
}
+function output_start
+{
+ start=`date +"%Y-%m-%d_%H_%M_%S"`
+ cat > tct-${1}-core-tests.xml <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="./style/testresult.xsl"?>
+<test_definition>
+<environment build_id="" device_id="localhost" device_model="" device_name="N/A" host="Ubuntu" manufacturer="" resolution="N/A" screen_size="N/A"><other /></environment>
+<summary test_plan_name="Empty test_plan_name"><start_at>$start</start_at><end_at>$start</end_at></summary>
+ <suite category="Core APIs" name="tct-$1-core-tests">
+ <set name="default" set_debug_msg="automated-tests.auto.suite_1_set_1.dlog">
+EOF
+}
+
+
+function output_end
+{
+ cat >> tct-${1}-core-tests.xml <<EOF
+ </set>
+ </suite>
+</test_definition>
+EOF
+}
+
+
if [ $opt_modules == 1 ] ; then
modules= get_modules
echo $modules
rm -f tct*core-tests.xml
# Clean up old coverage data
-if [ -d ../build/tizen ] ; then
- rm -f ../build/tizen/dali/.libs/*.gcda
-fi
+[ -d ../build/tizen ] && rm -f ../build/tizen/dali/.libs/*.gcda
+[ -d ../build/tizen-cmake ] && find ../build/tizen-cmake/ -name \*.gcda -exec rm {} \;
find build \( -name "*.gcda" \) -exec rm '{}' \;
do
echo -e "$ASCII_BOLD"
echo -e "Executing $mod$ASCII_RESET"
- build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun
+ output_start $mod
+ dbus-launch build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun $opt_quiet
+ output_end $mod
done
summary_end
summary_start
module=$1
shift;
- build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $*
+ output_start ${module}
+ dbus-launch build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $opt_quiet $*
+ output_end ${module}
summary_end
else
if [ $ret -ne 6 ] ; then
if [ $opt_debug -ne 0 ] ; then
echo DEBUGGING:
- gdb --args build/src/$mod/tct-$mod-core $1
+ dbus-launch gdb --args build/src/$mod/tct-$mod-core $1
else
echo $output
"output:s" => { "optvar"=>\$opt_output, "desc"=>"Generate html output"},
"help" => { "optvar"=>\$opt_help, "desc"=>""},
"quiet" => { "optvar"=>\$opt_quiet, "desc"=>""},
- "verbose" => { "optvar"=>\$opt_verbose, "desc"=>"" });
+ "verbose" => { "optvar"=>\$opt_verbose, "desc"=>"Also output coverage" });
my %longOptions = map { $_ => $options{$_}->{"optvar"} } keys(%options);
GetOptions( %longOptions ) or pod2usage(2);
}
}
-# NEW STUFF
-## Format per file, repeated, no linebreak
+# Format per file, repeated, no linebreak
# <diffcmd>
# index c1..c2 c3
# --- a/<left-hand-side-file>
# +++ b/<right-hand-side-file>
# <diff hunks>
-
+#
# Format of each diff hunk, repeated, no linebreak
# @@ <ranges> @@ line
# 3 lines of context
$files{$file}->{"patch"} = [@checklines];
$files{$file}->{"b_lines"} = {%b_lines};
- my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit)?/!} (keys(%files));;
+ my %filter = map { $_ => $files{$_} } grep {m!^dali(-toolkit|-scene-loader)?/!} (keys(%files));
if($pd_debug)
{
my $abs_filename = File::Spec->rel2abs($file, $root);
my $sumcountref = $info_data{$abs_filename}->{"sum"};
+ if($debug>1)
+ {
+ print("File: $abs_filename\n");
+ print Dumper($info_data{$abs_filename});
+ print "\n";
+ }
+
if( $sumcountref )
{
for my $patch (@$patchref)
## MAIN ##
################################################################################
-my $cwd = getcwd(); # expect this to be automated-tests folder
-
-# execute coverage.sh, generating build/tizen/dali.info from lib, and
-# *.dir/dali.info. Don't generate html
-print `./coverage.sh -n`;
-chdir "..";
-$root = getcwd();
-
-our %info_data; # Hash of all data from .info files
-my @info_files = split(/\n/, `find . -name dali.info`);
-my %new_info;
-
-# Read in all specified .info files
-foreach (@info_files)
-{
- %new_info = %{read_info_file($_)};
-
- # Combine %new_info with %info_data
- %info_data = %{combine_info_files(\%info_data, \%new_info)};
-}
-
# Generate git diff command
my @cmd=('--no-pager','diff','--no-ext-diff','-U0','--no-color');
}
else
{
- die "Both cached & working files - cannot get correct patch from git\n";
+ die "Error: Both cached & working files - cannot get correct patch from git\nRun git add first.";
# Would have to diff from separate clone.
}
}
push @cmd, @ARGV;
+# Before executing the diff, run the coverage.sh script. This is done here so that the
+# error condition above happens straight away, rather than after spewing out lots of information.
+
+my $cwd = getcwd(); # expect this to be automated-tests folder
+# execute coverage.sh, generating build/tizen/dali.info from lib, and
+# *.dir/dali.info. Don't generate html
+printf("Running coverage.sh\n");
+my $coverage_output=`./coverage.sh -n`;
+chdir "..";
+$root = getcwd();
+
+our %info_data; # Hash of all data from .info files
+my @info_files = split(/\n/, `find . -name dali.info`);
+my %new_info;
+
+# Read in all specified .info files
+foreach (@info_files)
+{
+ %new_info = %{read_info_file($_)};
+
+ # Combine %new_info with %info_data
+ %info_data = %{combine_info_files(\%info_data, \%new_info)};
+}
+
+
# Execute diff & coverage from root directory
my $filesref = run_diff(@cmd);
}
if( $filecount == 0 )
{
- print "No source files found\n";
+ print "Warning: No source files found\n";
exit 0; # Exit with no error.
}
#print_simplified_info() if $debug;
#exit 0;
+if($debug > 1)
+{
+ print "Info keys:\n";
+ for my $key (keys(%info_data))
+ {
+ print "$key\n";
+ }
+ print "\n\n";
+}
my $percentref = calc_patch_coverage_percentage($filesref);
if($percentref->[0] == 0)
{
- print "No coverable lines found\n";
+ print "Warning: No coverable lines found\n";
exit 0;
}
my $percent = $percentref->[1];
+printf(join("\n", grep { $_ !~ /^Remov/ } split(/\n/,$coverage_output))) if $opt_verbose;
+#printf($coverage_output) if $opt_verbose;
+
my $color=BOLD RED;
if($opt_output)
{
print RESET;
}
+printf("\n\n=========================\nPatch coverage output:\n=========================\n");
printf("Line Coverage: %d/%d\n", $percentref->[2], $percentref->[0]);
printf("Percentage of change covered: %5.2f%\n", $percent);
-#include <getopt.h>
-#include <stdlib.h>
-#include <string.h>
#include <test-harness.h>
#include "tct-dali-adaptor-internal-core.h"
int main(int argc, char* const argv[])
{
- int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
- const char* optString = "sf";
- bool optRerunFailed(true);
- bool optRunSerially(false);
-
- int nextOpt = 0;
- do
- {
- nextOpt = getopt(argc, argv, optString);
- switch(nextOpt)
- {
- case 'f':
- optRerunFailed = false;
- break;
- case 's':
- optRunSerially = true;
- break;
- case '?':
- TestHarness::Usage(argv[0]);
- exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
- break;
- }
- } while(nextOpt != -1);
-
- if(optind == argc) // no testcase name in argument list
- {
- if(optRunSerially)
- {
- result = TestHarness::RunAll(argv[0], tc_array);
- }
- else
- {
- result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed);
- }
- }
- else
- {
- // optind is index of next argument - interpret as testcase name
- result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
- }
- return result;
+ return TestHarness::RunTests(argc, argv, tc_array);
}
// 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);
#define DALI_TEST_SUITE_UTILS_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.
* @param expressions code to execute
* @param except the exception expected in the assert
*/
-#define DALI_TEST_THROWS(expressions, except) \
- try \
- { \
- TestApplication::EnableLogging(false); \
- expressions; \
- TestApplication::EnableLogging(true); \
- fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \
- tet_result(TET_FAIL); \
- throw("TET_FAIL"); \
- } \
- catch(except &) \
- { \
- tet_result(TET_PASS); \
- } \
- catch(...) \
- { \
- fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \
- tet_result(TET_FAIL); \
- throw; \
+#define DALI_TEST_THROWS(expressions, except) \
+ try \
+ { \
+ TestApplication::EnableLogging(false); \
+ expressions; \
+ TestApplication::EnableLogging(true); \
+ fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \
+ tet_result(TET_FAIL); \
+ throw("TET_FAIL"); \
+ } \
+ catch(except&) \
+ { \
+ tet_result(TET_PASS); \
+ } \
+ catch(...) \
+ { \
+ fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \
+ tet_result(TET_FAIL); \
+ throw; \
}
// Functor to test whether an Applied signal is emitted
/*
- * 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.
mCore = Dali::Integration::Core::New(mRenderController,
mPlatformAbstraction,
- mGlAbstraction,
- mGlSyncAbstraction,
- mGlContextHelperAbstraction,
+ mGraphicsController,
Integration::RenderToFrameBuffer::FALSE,
Integration::DepthBufferAvailable::TRUE,
Integration::StencilBufferAvailable::TRUE,
return mRenderController;
}
+TestGraphicsController& TestApplication::GetGraphicsController()
+{
+ return mGraphicsController;
+}
+
TestGlAbstraction& TestApplication::GetGlAbstraction()
{
- return mGlAbstraction;
+ return static_cast<TestGlAbstraction&>(mGraphicsController.GetGlAbstraction());
}
TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction()
{
- return mGlSyncAbstraction;
+ return static_cast<TestGlSyncAbstraction&>(mGraphicsController.GetGlSyncAbstraction());
}
TestGlContextHelperAbstraction& TestApplication::GetGlContextHelperAbstraction()
{
- return mGlContextHelperAbstraction;
+ return static_cast<TestGlContextHelperAbstraction&>(mGraphicsController.GetGlContextHelperAbstraction());
}
void TestApplication::ProcessEvent(const Integration::Event& event)
void TestApplication::ResetContext()
{
mCore->ContextDestroyed();
- mGlAbstraction.Initialize();
+ mGraphicsController.Initialize();
mCore->ContextCreated();
}
#define DALI_TEST_APPLICATION_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.
#include <dali/integration-api/resource-policies.h>
#include <dali/integration-api/scene.h>
#include <dali/integration-api/trace.h>
+
#include <dali/public-api/common/dali-common.h>
#include <test-platform-abstraction.h>
-#include "test-gl-abstraction.h"
-#include "test-gl-context-helper-abstraction.h"
-#include "test-gl-sync-abstraction.h"
+#include "test-graphics-controller.h"
#include "test-render-controller.h"
namespace Dali
void CreateScene();
void InitializeCore();
~TestApplication() override;
- static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
- static void LogContext(bool start, const char* tag);
- Dali::Integration::Core& GetCore();
- TestPlatformAbstraction& GetPlatform();
- TestRenderController& GetRenderController();
+ static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
+ static void LogContext(bool start, const char* tag);
+ Dali::Integration::Core& GetCore();
+ TestPlatformAbstraction& GetPlatform();
+ TestRenderController& GetRenderController();
+ TestGraphicsController& GetGraphicsController();
+
TestGlAbstraction& GetGlAbstraction();
TestGlSyncAbstraction& GetGlSyncAbstraction();
TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
- void ProcessEvent(const Integration::Event& event);
- void SendNotification();
- bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
- bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
- bool RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
- uint32_t GetUpdateStatus();
- bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
- bool RenderOnly();
- void ResetContext();
- bool GetRenderNeedsUpdate();
- bool GetRenderNeedsPostRender();
- uint32_t Wait(uint32_t durationToWait);
- static void EnableLogging(bool enabled)
+
+ void ProcessEvent(const Integration::Event& event);
+ void SendNotification();
+ bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
+ bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
+ bool RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
+ uint32_t GetUpdateStatus();
+ bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
+ bool RenderOnly();
+ void ResetContext();
+ bool GetRenderNeedsUpdate();
+ bool GetRenderNeedsPostRender();
+ uint32_t Wait(uint32_t durationToWait);
+ static void EnableLogging(bool enabled)
{
mLoggingEnabled = enabled;
}
void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
protected:
- TestPlatformAbstraction mPlatformAbstraction;
- TestRenderController mRenderController;
- TestGlAbstraction mGlAbstraction;
- TestGlSyncAbstraction mGlSyncAbstraction;
- TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+ TestPlatformAbstraction mPlatformAbstraction;
+ TestRenderController mRenderController;
+ TestGraphicsController mGraphicsController;
Integration::UpdateStatus mStatus;
Integration::RenderStatus mRenderStatus;
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "test-graphics-application.h"
+
+namespace Dali
+{
+bool TestGraphicsApplication::mLoggingEnabled = true;
+
+TestGraphicsApplication::TestGraphicsApplication(uint32_t surfaceWidth,
+ uint32_t surfaceHeight,
+ uint32_t horizontalDpi,
+ uint32_t verticalDpi,
+ bool initialize,
+ bool enablePartialUpdate)
+: mCore(NULL),
+ mSurfaceWidth(surfaceWidth),
+ mSurfaceHeight(surfaceHeight),
+ mFrame(0u),
+ mDpi{horizontalDpi, verticalDpi},
+ mLastVSyncTime(0u),
+ mPartialUpdateEnabled(enablePartialUpdate)
+{
+ if(initialize)
+ {
+ Initialize();
+ }
+}
+
+void TestGraphicsApplication::Initialize()
+{
+ CreateCore();
+ CreateScene();
+ InitializeCore();
+}
+
+void TestGraphicsApplication::CreateCore()
+{
+ // We always need the first update!
+ mStatus.keepUpdating = Integration::KeepUpdating::STAGE_KEEP_RENDERING;
+
+ mGraphicsController.InitializeGLES(mGlAbstraction);
+ mGraphicsController.Initialize(mGlSyncAbstraction, mGlContextHelperAbstraction);
+
+ mCore = Dali::Integration::Core::New(mRenderController,
+ mPlatformAbstraction,
+ mGraphicsController,
+ Integration::RenderToFrameBuffer::FALSE,
+ Integration::DepthBufferAvailable::TRUE,
+ Integration::StencilBufferAvailable::TRUE,
+ mPartialUpdateEnabled ? Integration::PartialUpdateAvailable::TRUE : Integration::PartialUpdateAvailable::FALSE);
+
+ mCore->ContextCreated();
+
+ Dali::Integration::Log::LogFunction logFunction(&TestGraphicsApplication::LogMessage);
+ Dali::Integration::Log::InstallLogFunction(logFunction);
+
+ Dali::Integration::Trace::LogContextFunction logContextFunction(&TestGraphicsApplication::LogContext);
+ Dali::Integration::Trace::InstallLogContextFunction(logContextFunction);
+
+ Dali::Integration::Trace::LogContext(true, "Test");
+}
+
+void TestGraphicsApplication::CreateScene()
+{
+ mScene = Dali::Integration::Scene::New(Size(static_cast<float>(mSurfaceWidth), static_cast<float>(mSurfaceHeight)));
+ mScene.SetDpi(Vector2(static_cast<float>(mDpi.x), static_cast<float>(mDpi.y)));
+}
+
+void TestGraphicsApplication::InitializeCore()
+{
+ mCore->SceneCreated();
+ mCore->Initialize();
+}
+
+TestGraphicsApplication::~TestGraphicsApplication()
+{
+ Dali::Integration::Log::UninstallLogFunction();
+ delete mCore;
+}
+
+void TestGraphicsApplication::LogContext(bool start, const char* tag)
+{
+ if(start)
+ {
+ fprintf(stderr, "INFO: Trace Start: %s\n", tag);
+ }
+ else
+ {
+ fprintf(stderr, "INFO: Trace End: %s\n", tag);
+ }
+}
+
+void TestGraphicsApplication::LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message)
+{
+ if(mLoggingEnabled)
+ {
+ switch(level)
+ {
+ case Dali::Integration::Log::DebugInfo:
+ fprintf(stderr, "INFO: %s", message.c_str());
+ break;
+ case Dali::Integration::Log::DebugWarning:
+ fprintf(stderr, "WARN: %s", message.c_str());
+ break;
+ case Dali::Integration::Log::DebugError:
+ fprintf(stderr, "ERROR: %s", message.c_str());
+ break;
+ default:
+ fprintf(stderr, "DEFAULT: %s", message.c_str());
+ break;
+ }
+ }
+}
+
+Dali::Integration::Core& TestGraphicsApplication::GetCore()
+{
+ return *mCore;
+}
+
+TestPlatformAbstraction& TestGraphicsApplication::GetPlatform()
+{
+ return mPlatformAbstraction;
+}
+
+TestRenderController& TestGraphicsApplication::GetRenderController()
+{
+ return mRenderController;
+}
+
+Graphics::Controller& TestGraphicsApplication::GetGraphicsController()
+{
+ return mGraphicsController;
+}
+
+TestGlAbstraction& TestGraphicsApplication::GetGlAbstraction()
+{
+ return static_cast<TestGlAbstraction&>(mGraphicsController.GetGlAbstraction());
+}
+
+TestGlSyncAbstraction& TestGraphicsApplication::GetGlSyncAbstraction()
+{
+ return static_cast<TestGlSyncAbstraction&>(mGraphicsController.GetGlSyncAbstraction());
+}
+
+TestGlContextHelperAbstraction& TestGraphicsApplication::GetGlContextHelperAbstraction()
+{
+ return static_cast<TestGlContextHelperAbstraction&>(mGraphicsController.GetGlContextHelperAbstraction());
+}
+
+void TestGraphicsApplication::ProcessEvent(const Integration::Event& event)
+{
+ mCore->QueueEvent(event);
+ mCore->ProcessEvents();
+}
+
+void TestGraphicsApplication::SendNotification()
+{
+ mCore->ProcessEvents();
+}
+
+void TestGraphicsApplication::DoUpdate(uint32_t intervalMilliseconds, const char* location)
+{
+ if(GetUpdateStatus() == 0 &&
+ mRenderStatus.NeedsUpdate() == false &&
+ !GetRenderController().WasCalled(TestRenderController::RequestUpdateFunc))
+ {
+ fprintf(stderr, "WARNING - Update not required :%s\n", location == NULL ? "NULL" : location);
+ }
+
+ uint32_t nextVSyncTime = mLastVSyncTime + intervalMilliseconds;
+ float elapsedSeconds = static_cast<float>(intervalMilliseconds) * 0.001f;
+
+ mCore->Update(elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus, false, false);
+
+ GetRenderController().Initialize();
+
+ mLastVSyncTime = nextVSyncTime;
+}
+
+bool TestGraphicsApplication::Render(uint32_t intervalMilliseconds, const char* location)
+{
+ DoUpdate(intervalMilliseconds, location);
+
+ // Reset the status
+ mRenderStatus.SetNeedsUpdate(false);
+ mRenderStatus.SetNeedsPostRender(false);
+
+ mCore->PreRender(mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/);
+ mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/);
+ mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/);
+ mCore->PostRender(false /*do not skip rendering*/);
+
+ mFrame++;
+
+ return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+bool TestGraphicsApplication::PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects)
+{
+ DoUpdate(intervalMilliseconds, location);
+
+ mCore->PreRender(mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/);
+ mCore->PreRender(mScene, damagedRects);
+
+ return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+bool TestGraphicsApplication::RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect)
+{
+ mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/, clippingRect);
+ mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/, clippingRect);
+ mCore->PostRender(false /*do not skip rendering*/);
+
+ mFrame++;
+
+ return mStatus.KeepUpdating() || mRenderStatus.NeedsUpdate();
+}
+
+uint32_t TestGraphicsApplication::GetUpdateStatus()
+{
+ return mStatus.KeepUpdating();
+}
+
+bool TestGraphicsApplication::UpdateOnly(uint32_t intervalMilliseconds)
+{
+ DoUpdate(intervalMilliseconds);
+ return mStatus.KeepUpdating();
+}
+
+bool TestGraphicsApplication::GetRenderNeedsUpdate()
+{
+ return mRenderStatus.NeedsUpdate();
+}
+
+bool TestGraphicsApplication::GetRenderNeedsPostRender()
+{
+ return mRenderStatus.NeedsPostRender();
+}
+
+bool TestGraphicsApplication::RenderOnly()
+{
+ // Update Time values
+ mCore->PreRender(mRenderStatus, false /*do not force clear*/, false /*do not skip rendering*/);
+ mCore->RenderScene(mRenderStatus, mScene, true /*render the off-screen buffers*/);
+ mCore->RenderScene(mRenderStatus, mScene, false /*render the surface*/);
+ mCore->PostRender(false /*do not skip rendering*/);
+
+ mFrame++;
+
+ return mRenderStatus.NeedsUpdate();
+}
+
+void TestGraphicsApplication::ResetContext()
+{
+ mCore->ContextDestroyed();
+ mGraphicsController.InitializeGLES(mGlAbstraction);
+ mGraphicsController.Initialize(mGlSyncAbstraction, mGlContextHelperAbstraction);
+ mCore->ContextCreated();
+}
+
+uint32_t TestGraphicsApplication::Wait(uint32_t durationToWait)
+{
+ int time = 0;
+
+ for(uint32_t i = 0; i <= (durationToWait / RENDER_FRAME_INTERVAL); i++)
+ {
+ SendNotification();
+ Render(RENDER_FRAME_INTERVAL);
+ time += RENDER_FRAME_INTERVAL;
+ }
+ return time;
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TEST_GRAPHICS_APPLICATION_H
+#define DALI_TEST_GRAPHICS_APPLICATION_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/resource-policies.h>
+#include <dali/integration-api/scene.h>
+#include <dali/integration-api/trace.h>
+
+#include <dali/internal/graphics/gles/egl-graphics-controller.h>
+#include <dali/public-api/common/dali-common.h>
+
+#include <test-gl-abstraction.h>
+#include <test-gl-context-helper-abstraction.h>
+#include <test-gl-sync-abstraction.h>
+#include <test-platform-abstraction.h>
+#include <test-render-controller.h>
+
+namespace Dali
+{
+class DALI_CORE_API TestGraphicsApplication : public ConnectionTracker
+{
+public:
+ // Default values derived from H2 device.
+ static const uint32_t DEFAULT_SURFACE_WIDTH = 480;
+ static const uint32_t DEFAULT_SURFACE_HEIGHT = 800;
+
+ static constexpr uint32_t DEFAULT_HORIZONTAL_DPI = 220;
+ static constexpr uint32_t DEFAULT_VERTICAL_DPI = 217;
+
+ static const uint32_t DEFAULT_RENDER_INTERVAL = 1;
+
+ static const uint32_t RENDER_FRAME_INTERVAL = 16;
+
+ TestGraphicsApplication(uint32_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
+ uint32_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
+ uint32_t horizontalDpi = DEFAULT_HORIZONTAL_DPI,
+ uint32_t verticalDpi = DEFAULT_VERTICAL_DPI,
+ bool initialize = true,
+ bool enablePartialUpdate = false);
+
+ void Initialize();
+ void CreateCore();
+ void CreateScene();
+ void InitializeCore();
+ ~TestGraphicsApplication() override;
+ static void LogMessage(Dali::Integration::Log::DebugPriority level, std::string& message);
+ static void LogContext(bool start, const char* tag);
+ Dali::Integration::Core& GetCore();
+ TestPlatformAbstraction& GetPlatform();
+ TestRenderController& GetRenderController();
+ Graphics::Controller& GetGraphicsController();
+
+ TestGlAbstraction& GetGlAbstraction();
+ TestGlSyncAbstraction& GetGlSyncAbstraction();
+ TestGlContextHelperAbstraction& GetGlContextHelperAbstraction();
+
+ void ProcessEvent(const Integration::Event& event);
+ void SendNotification();
+ bool Render(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location = NULL);
+ bool PreRenderWithPartialUpdate(uint32_t intervalMilliseconds, const char* location, std::vector<Rect<int>>& damagedRects);
+ bool RenderWithPartialUpdate(std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
+ uint32_t GetUpdateStatus();
+ bool UpdateOnly(uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL);
+ bool RenderOnly();
+ void ResetContext();
+ bool GetRenderNeedsUpdate();
+ bool GetRenderNeedsPostRender();
+ uint32_t Wait(uint32_t durationToWait);
+ static void EnableLogging(bool enabled)
+ {
+ mLoggingEnabled = enabled;
+ }
+
+ Integration::Scene GetScene() const
+ {
+ return mScene;
+ }
+
+private:
+ void DoUpdate(uint32_t intervalMilliseconds, const char* location = NULL);
+
+protected:
+ TestPlatformAbstraction mPlatformAbstraction;
+ TestRenderController mRenderController;
+ Graphics::EglGraphicsController mGraphicsController; // Use real controller in Adaptor
+ TestGlAbstraction mGlAbstraction;
+ TestGlSyncAbstraction mGlSyncAbstraction;
+ TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+
+ Integration::UpdateStatus mStatus;
+ Integration::RenderStatus mRenderStatus;
+
+ Integration::Core* mCore;
+ Dali::Integration::Scene mScene;
+
+ uint32_t mSurfaceWidth;
+ uint32_t mSurfaceHeight;
+ uint32_t mFrame;
+
+ struct
+ {
+ uint32_t x;
+ uint32_t y;
+ } mDpi;
+ uint32_t mLastVSyncTime;
+ bool mPartialUpdateEnabled;
+ static bool mLoggingEnabled;
+};
+
+} // namespace Dali
+
+#endif // DALI_TEST_GRAPHICS_APPLICATION_H
--- /dev/null
+#ifndef TEST_GRAPHICS_CONTROLLER_H
+#define TEST_GRAPHICS_CONTROLLER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/graphics-api/graphics-controller.h>
+#include "test-gl-abstraction.h"
+#include "test-gl-context-helper-abstraction.h"
+#include "test-gl-sync-abstraction.h"
+
+namespace Dali
+{
+class TestGraphicsController : public Dali::Graphics::Controller
+{
+public:
+ TestGraphicsController() = default;
+ virtual ~TestGraphicsController() = default;
+
+ void Initialize()
+ {
+ mGlAbstraction.Initialize();
+ }
+
+ Integration::GlAbstraction& GetGlAbstraction() override
+ {
+ return mGlAbstraction;
+ }
+
+ Integration::GlSyncAbstraction& GetGlSyncAbstraction() override
+ {
+ return mGlSyncAbstraction;
+ }
+
+ Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override
+ {
+ return mGlContextHelperAbstraction;
+ }
+
+private:
+ TestGlAbstraction mGlAbstraction;
+ TestGlSyncAbstraction mGlSyncAbstraction;
+ TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+};
+
+} // namespace Dali
+
+#endif //TEST_GRAPHICS_CONTROLLER_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.
#include <sys/wait.h>
#include <testcase.h>
-#include <time.h>
+#include <getopt.h>
#include <unistd.h>
-
+#include <algorithm>
#include <chrono>
+#include <cstdlib>
#include <cstring>
+#include <ctime>
+#include <fstream>
#include <map>
+#include <sstream>
#include <vector>
+using std::chrono::steady_clock;
+using std::chrono::system_clock;
+
namespace TestHarness
{
typedef std::map<int32_t, TestCase> RunningTestCases;
return slash;
}
-void SuppressLogOutput()
+std::vector<std::string> Split(const std::string& aString, char delimiter)
{
- // Close stdout and stderr to suppress the log output
- close(STDOUT_FILENO); // File descriptor number for stdout is 1
- close(STDERR_FILENO); // File descriptor number for stderr is 2
+ std::vector<std::string> tokens;
+ std::string token;
+ std::istringstream tokenStream(aString);
+ while(std::getline(tokenStream, token, delimiter))
+ {
+ tokens.push_back(token);
+ }
+ return tokens;
+}
- // The POSIX specification requires that /dev/null must be provided,
- // The open function always chooses the lowest unused file descriptor
- // It is sufficient for stdout to be writable.
- open("/dev/null", O_WRONLY); // Redirect file descriptor number 1 (i.e. stdout) to /dev/null
- // When stderr is opened it must be both readable and writable.
- open("/dev/null", O_RDWR); // Redirect file descriptor number 2 (i.e. stderr) to /dev/null
+std::string Join(const std::vector<std::string>& tokens, char delimiter)
+{
+ std::ostringstream oss;
+
+ unsigned int delimiterCount = 0;
+ for(auto& token : tokens)
+ {
+ oss << token;
+ if(delimiterCount < tokens.size() - 1)
+ {
+ oss << delimiter;
+ }
+ ++delimiterCount;
+ }
+ return oss.str();
+}
+
+std::string ChildOutputFilename(int pid)
+{
+ std::ostringstream os;
+ os << "/tmp/tct-child." << pid;
+ return os.str();
+}
+
+std::string TestModuleFilename(const char* processName)
+{
+ auto pathComponents = Split(processName, '/');
+ auto aModule = pathComponents.back();
+ aModule += "-tests.xml";
+ return aModule;
+}
+
+std::string TestModuleName(const char* processName)
+{
+ auto pathComponents = Split(processName, '/');
+ auto aModule = pathComponents.back();
+ auto moduleComponents = Split(aModule, '-');
+
+ moduleComponents[1][0] = std::toupper(moduleComponents[1][0]);
+ moduleComponents[2][0] = std::toupper(moduleComponents[2][0]);
+
+ std::ostringstream oss;
+ for(unsigned int i = 1; i < moduleComponents.size() - 1; ++i) // [0]=tct, [n-1]=core
+ {
+ oss << moduleComponents[i];
+
+ if(i > 1 && i < moduleComponents.size() - 2) // skip first and last delimiter
+ {
+ oss << '-';
+ }
+ }
+
+ return oss.str();
+}
+
+std::string ReadAndEscape(std::string filename)
+{
+ std::ostringstream os;
+ std::ifstream ifs;
+ ifs.open(filename, std::ifstream::in);
+ while(ifs.good())
+ {
+ std::string line;
+ std::getline(ifs, line);
+ for(auto c : line)
+ {
+ switch(c)
+ {
+ case '<':
+ os << "<";
+ break;
+ case '>':
+ os << ">";
+ break;
+ case '&':
+ os << "&";
+ break;
+ default:
+ os << c;
+ break;
+ }
+ }
+ os << "\\"
+ << "n";
+ }
+ ifs.close();
+ return os.str();
+}
+
+void OutputTestResult(
+ std::ofstream& ofs,
+ const char* pathToExecutable,
+ std::string testSuiteName,
+ TestCase& testCase,
+ std::string startTime,
+ std::string endTime)
+{
+ std::string outputFilename = ChildOutputFilename(testCase.childPid);
+ std::string testOutput = ReadAndEscape(outputFilename);
+
+ ofs << "<testcase component=\"CoreAPI/" << testSuiteName << "/default\" execution_type=\"auto\" id=\""
+ << testCase.name << "\" purpose=\"\" result=\"" << (testCase.result == 0 ? "PASS" : "FAIL") << "\">" << std::endl
+ << "<description><test_script_entry test_script_expected_result=\"0\">"
+ << pathToExecutable << testCase.name << "</test_script_entry>" << std::endl
+ << "</description>"
+ << "<result_info><actual_result>" << (testCase.result == 0 ? "PASS" : "FAIL") << "</actual_result>" << std::endl
+ << "<start>" << startTime << "</start>"
+ << "<end>" << endTime << "</end>"
+ << "<stdout><![CDATA[]]></stdout>"
+ << "<stderr><![CDATA[" << testOutput << "]]></stderr></result_info></testcase>" << std::endl;
+
+ unlink(outputFilename.c_str());
+}
+
+void OutputTestResults(const char* processName, RunningTestCases& children)
+{
+ std::ofstream ofs;
+ std::string filename = TestModuleFilename(processName);
+ std::string moduleName = TestModuleName(processName);
+ ofs.open(filename, std::ofstream::out | std::ofstream::app);
+
+ // Sort completed cases by original test case id
+ std::vector<TestCase> childTestCases;
+ childTestCases.reserve(children.size());
+ for(auto& element : children) childTestCases.push_back(element.second);
+ std::sort(childTestCases.begin(), childTestCases.end(), [](const TestCase& a, const TestCase& b) {
+ return a.testCase < b.testCase;
+ });
+
+ const int BUFSIZE = 256;
+ char buffer[BUFSIZE];
+ for(auto& testCase : childTestCases)
+ {
+ auto tt = system_clock::to_time_t(testCase.startSystemTime);
+ strftime(buffer, BUFSIZE, "%c", localtime(&tt));
+ std::string startTime(buffer);
+ OutputTestResult(ofs, processName, moduleName, testCase, startTime, startTime);
+ }
+
+ ofs.close();
+}
+
+void OutputStatistics(const char* processName, int32_t numPasses, int32_t numFailures)
+{
+ FILE* fp = fopen("summary.xml", "a");
+ if(fp != NULL)
+ {
+ fprintf(fp,
+ " <suite name=\"%s-tests\">\n"
+ " <total_case>%d</total_case>\n"
+ " <pass_case>%d</pass_case>\n"
+ " <pass_rate>%5.2f</pass_rate>\n"
+ " <fail_case>%d</fail_case>\n"
+ " <fail_rate>%5.2f</fail_rate>\n"
+ " <block_case>0</block_case>\n"
+ " <block_rate>0.00</block_rate>\n"
+ " <na_case>0</na_case>\n"
+ " <na_rate>0.00</na_rate>\n"
+ " </suite>\n",
+ basename(processName),
+ numPasses + numFailures,
+ numPasses,
+ (float)numPasses * 100.0f / (numPasses + numFailures),
+ numFailures,
+ (float)numFailures * 100.0f / (numPasses + numFailures));
+ fclose(fp);
+ }
}
int32_t RunTestCase(struct ::testcase_s& testCase)
return result;
}
-int32_t RunTestCaseInChildProcess(struct ::testcase_s& testCase, bool suppressOutput)
+int32_t RunTestCaseRedirectOutput(TestCase& testCase, bool suppressOutput)
+{
+ // Executing in child process
+ // Close stdout and stderr to suppress the log output
+ close(STDOUT_FILENO); // File descriptor number for stdout is 1
+
+ // The POSIX specification requires that /dev/null must be provided,
+ // The open function always chooses the lowest unused file descriptor
+ // It is sufficient for stdout to be writable.
+ open("/dev/null", O_WRONLY); // Redirect file descriptor number 1 (i.e. stdout) to /dev/null
+
+ fflush(stderr);
+ close(STDERR_FILENO);
+ if(suppressOutput)
+ {
+ stderr = fopen("/dev/null", "w+"); // Redirect fd 2 to /dev/null
+ }
+ else
+ {
+ // When stderr is opened it must be both readable and writable.
+ std::string childOutputFilename = ChildOutputFilename(getpid());
+ stderr = fopen(childOutputFilename.c_str(), "w+");
+ }
+
+ int32_t status = RunTestCase(*testCase.tctPtr);
+
+ fflush(stderr);
+ fclose(stderr);
+
+ return status;
+}
+
+int32_t RunTestCaseInChildProcess(TestCase& testCase, bool redirect)
{
int32_t testResult = EXIT_STATUS_TESTCASE_FAILED;
int32_t pid = fork();
if(pid == 0) // Child process
{
- if(suppressOutput)
+ if(redirect)
{
- SuppressLogOutput();
+ int status = RunTestCaseRedirectOutput(testCase, false);
+ exit(status);
}
else
{
- printf("\n");
- for(int32_t i = 0; i < 80; ++i) printf("#");
- printf("\nTC: %s\n", testCase.name);
- fflush(stdout);
+ int status = RunTestCase(*testCase.tctPtr);
+ exit(status);
}
-
- int32_t status = RunTestCase(testCase);
-
- if(!suppressOutput)
- {
- fflush(stdout);
- fflush(stderr);
- fclose(stdout);
- fclose(stderr);
- }
- exit(status);
}
else if(pid == -1)
{
}
else // Parent process
{
- int32_t status = 0;
- int32_t childPid = waitpid(pid, &status, 0);
+ int32_t status = 0;
+ int32_t childPid = waitpid(pid, &status, 0);
+ testCase.childPid = childPid;
if(childPid == -1)
{
perror("waitpid");
return testResult;
}
-void OutputStatistics(const char* processName, int32_t numPasses, int32_t numFailures)
+int32_t RunAll(const char* processName, ::testcase tc_array[], bool quiet)
{
- FILE* fp = fopen("summary.xml", "a");
- if(fp != NULL)
+ int32_t numFailures = 0;
+ int32_t numPasses = 0;
+ std::ofstream ofs;
+ std::string filename = TestModuleFilename(processName);
+ std::string moduleName = TestModuleName(processName);
+ ofs.open(filename, std::ofstream::out | std::ofstream::app);
+ const int BUFSIZE = 256;
+ char buffer[BUFSIZE];
+
+ // Run test cases in child process( to handle signals ), but run serially.
+ for(uint32_t i = 0; tc_array[i].name; i++)
{
- fprintf(fp,
- " <suite name=\"%s\">\n"
- " <total_case>%d</total_case>\n"
- " <pass_case>%d</pass_case>\n"
- " <pass_rate>%5.2f</pass_rate>\n"
- " <fail_case>%d</fail_case>\n"
- " <fail_rate>%5.2f</fail_rate>\n"
- " <block_case>0</block_case>\n"
- " <block_rate>0.00</block_rate>\n"
- " <na_case>0</na_case>\n"
- " <na_rate>0.00</na_rate>\n"
- " </suite>\n",
- basename(processName),
- numPasses + numFailures,
- numPasses,
- (float)numPasses / (numPasses + numFailures),
- numFailures,
- (float)numFailures / (numPasses + numFailures));
- fclose(fp);
- }
-}
+ auto tt = system_clock::to_time_t(system_clock::now());
+ strftime(buffer, BUFSIZE, "%c", localtime(&tt));
+ std::string startTime(buffer);
-int32_t RunAll(const char* processName, ::testcase tc_array[])
-{
- int32_t numFailures = 0;
- int32_t numPasses = 0;
+ TestCase testCase(i, &tc_array[i]);
+ testCase.result = RunTestCaseInChildProcess(testCase, quiet);
- // Run test cases in child process( to kill output/handle signals ), but run serially.
- for(uint32_t i = 0; tc_array[i].name; i++)
- {
- int32_t result = RunTestCaseInChildProcess(tc_array[i], false);
- if(result == 0)
+ tt = system_clock::to_time_t(system_clock::now());
+ strftime(buffer, BUFSIZE, "%c", localtime(&tt));
+ std::string endTime(buffer);
+
+ if(testCase.result == 0)
{
numPasses++;
}
{
numFailures++;
}
+ if(!quiet)
+ {
+ OutputTestResult(ofs, processName, moduleName, testCase, startTime, endTime);
+ }
}
+ ofs.close();
OutputStatistics(processName, numPasses, numFailures);
}
// Constantly runs up to MAX_NUM_CHILDREN processes
-int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool reRunFailed)
+int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool reRunFailed, bool quiet)
{
int32_t numFailures = 0;
int32_t numPasses = 0;
int32_t pid = fork();
if(pid == 0) // Child process
{
- SuppressLogOutput();
- exit(RunTestCase(tc_array[nextTestCase]));
+ TestCase testCase(nextTestCase, &tc_array[nextTestCase]);
+ int status = RunTestCaseRedirectOutput(testCase, quiet);
+ exit(status);
}
else if(pid == -1)
{
else // Parent process
{
TestCase tc(nextTestCase, tc_array[nextTestCase].name);
- tc.startTime = std::chrono::steady_clock::now();
+ tc.startTime = steady_clock::now();
+ tc.startSystemTime = system_clock::now();
+ tc.childPid = pid;
children[pid] = tc;
nextTestCase++;
{
if(WIFEXITED(status))
{
- int32_t testResult = WEXITSTATUS(status);
- if(testResult)
+ auto& testCase = children[childPid];
+ testCase.result = WEXITSTATUS(status);
+ if(testCase.result)
{
- printf("Test case %s failed: %d\n", children[childPid].testCaseName, testResult);
- failedTestCases.push_back(children[childPid].testCase);
+ printf("Test case %s failed: %d\n", testCase.name, testCase.result);
+ failedTestCases.push_back(testCase.testCase);
numFailures++;
}
else
RunningTestCases::iterator iter = children.find(childPid);
if(iter != children.end())
{
- printf("Test case %s exited with signal %s\n", iter->second.testCaseName, strsignal(status));
+ printf("Test case %s exited with signal %s\n", iter->second.name, strsignal(status));
+ iter->second.result = 1;
failedTestCases.push_back(iter->second.testCase);
}
else
}
}
+ if(!quiet)
+ {
+ OutputTestResults(processName, children);
+ }
+
OutputStatistics(processName, numPasses, numFailures);
if(reRunFailed)
printf("=");
}
printf("\n");
- RunTestCaseInChildProcess(tc_array[failedTestCases[i]], false);
+ int index = failedTestCases[i];
+ TestCase testCase(index, &tc_array[index]);
+ RunTestCaseInChildProcess(testCase, false);
}
}
" %s <testcase name>\t\t Execute a test case\n"
" %s \t\t Execute all test cases in parallel\n"
" %s -r\t\t Execute all test cases in parallel, rerunning failed test cases\n"
- " %s -s\t\t Execute all test cases serially\n",
+ " %s -s\t\t Execute all test cases serially\n"
+ " %s -q\t\t Run without output\n",
+ program,
program,
program,
program,
program);
}
+int RunTests(int argc, char* const argv[], ::testcase tc_array[])
+{
+ int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
+ const char* optString = "sfq";
+ bool optRerunFailed(true);
+ bool optRunSerially(false);
+ bool optQuiet(false);
+
+ int nextOpt = 0;
+ do
+ {
+ nextOpt = getopt(argc, argv, optString);
+ switch(nextOpt)
+ {
+ case 'f':
+ optRerunFailed = false;
+ break;
+ case 's':
+ optRunSerially = true;
+ break;
+ case 'q':
+ optQuiet = true;
+ break;
+ case '?':
+ TestHarness::Usage(argv[0]);
+ exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
+ break;
+ }
+ } while(nextOpt != -1);
+
+ if(optind == argc) // no testcase name in argument list
+ {
+ if(optRunSerially)
+ {
+ result = TestHarness::RunAll(argv[0], tc_array, optQuiet);
+ }
+ else
+ {
+ result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed, optQuiet);
+ }
+ }
+ else
+ {
+ // optind is index of next argument - interpret as testcase name
+ result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
+ }
+ return result;
+}
+
} // namespace TestHarness
struct TestCase
{
int32_t testCase;
- const char* testCaseName;
+ const char* name;
std::chrono::steady_clock::time_point startTime;
+ std::chrono::system_clock::time_point startSystemTime;
+ int32_t result;
+ pid_t childPid{0};
+ testcase* tctPtr;
+ TestCase(int32_t index, testcase* testCase)
+ : testCase(index),
+ name(testCase->name),
+ startTime(),
+ startSystemTime(),
+ result(0),
+ childPid(0),
+ tctPtr(testCase)
+ {
+ }
TestCase()
: testCase(0),
- testCaseName(NULL),
- startTime()
+ name(NULL),
+ startTime(),
+ startSystemTime(),
+ result(0),
+ childPid(0),
+ tctPtr(nullptr)
{
}
TestCase(int32_t tc, const char* name)
: testCase(tc),
- testCaseName(name),
- startTime()
+ name(name),
+ startTime(),
+ startSystemTime(),
+ result(0),
+ childPid(0),
+ tctPtr(nullptr)
{
}
TestCase(const TestCase& rhs)
: testCase(rhs.testCase),
- testCaseName(rhs.testCaseName),
- startTime(rhs.startTime)
+ name(rhs.name),
+ startTime(rhs.startTime),
+ startSystemTime(rhs.startSystemTime),
+ result(rhs.result),
+ childPid(rhs.childPid),
+ tctPtr(rhs.tctPtr)
{
}
TestCase& operator=(const TestCase& rhs)
{
- testCase = rhs.testCase;
- testCaseName = rhs.testCaseName;
- startTime = rhs.startTime;
+ testCase = rhs.testCase;
+ name = rhs.name;
+ startTime = rhs.startTime;
+ startSystemTime = rhs.startSystemTime;
+ result = rhs.result;
+ childPid = rhs.childPid;
+ tctPtr = rhs.tctPtr;
return *this;
}
};
*/
void Usage(const char* program);
+/**
+ * Main function.
+ * @param[in] argc Argument count
+ * @param[in] argv Argument vector
+ * @param[in] tc_array Array of test cases
+ */
+int RunTests(int argc, char* const argv[], ::testcase tc_array[]);
+
} // namespace TestHarness
#endif
-#include <getopt.h>
-#include <stdlib.h>
-#include <string.h>
#include <test-harness.h>
#include "tct-dali-adaptor-core.h"
int main(int argc, char* const argv[])
{
- int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
- const char* optString = "sf";
- bool optRerunFailed(true);
- bool optRunSerially(false);
-
- int nextOpt = 0;
- do
- {
- nextOpt = getopt(argc, argv, optString);
- switch(nextOpt)
- {
- case 'f':
- optRerunFailed = false;
- break;
- case 's':
- optRunSerially = true;
- break;
- case '?':
- TestHarness::Usage(argv[0]);
- exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
- break;
- }
- } while(nextOpt != -1);
-
- if(optind == argc) // no testcase name in argument list
- {
- if(optRunSerially)
- {
- result = TestHarness::RunAll(argv[0], tc_array);
- }
- else
- {
- result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed);
- }
- }
- else
- {
- // optind is index of next argument - interpret as testcase name
- result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
- }
- return result;
+ return TestHarness::RunTests(argc, argv, tc_array);
}
/*
- * 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) 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.
END_TEST;
}
-
-int UtcDaliDownloadRemoteChunkedImage(void)
-{
- std::string url("http://d2k43l0oslhof9.cloudfront.net/platform/image/contents/vc/20/01/58/20170629100630071189_0bf6b911-a847-cba4-e518-be40fe2f579420170629192203240.jpg");
-
- Devel::PixelBuffer pixelBuffer = Dali::DownloadImageSynchronously(url);
- DALI_TEST_CHECK(pixelBuffer);
- DALI_TEST_EQUALS(pixelBuffer.GetWidth(), 279u, TEST_LOCATION);
- DALI_TEST_EQUALS(pixelBuffer.GetHeight(), 156u, TEST_LOCATION);
- DALI_TEST_EQUALS(pixelBuffer.GetPixelFormat(), Pixel::RGBA8888, 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.
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;
}
-
--- /dev/null
+SET(PKG_NAME "dali-graphics")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+
+SET(CAPI_LIB "dali-graphics")
+SET(TC_SOURCES
+ utc-Dali-GraphicsGeometry.cpp
+)
+
+LIST(APPEND TC_SOURCES
+ ../dali-adaptor/dali-test-suite-utils/dali-test-suite-utils.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-harness.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-graphics-application.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-gl-abstraction.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-gl-sync-abstraction.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-native-image.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-render-controller.cpp
+ ../dali-adaptor/dali-test-suite-utils/test-trace-call-stack.cpp
+ ../dali-adaptor/dali-test-suite-utils/adaptor-test-adaptor-impl.cpp
+ tct-dali-graphics-core.cpp
+)
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+ dali2-core
+ dali2-adaptor
+ ecore
+ ecore-x
+)
+
+ADD_COMPILE_OPTIONS( -O0 -ggdb --coverage -Wall -Werror )
+ADD_COMPILE_OPTIONS( ${${CAPI_LIB}_CFLAGS_OTHER} )
+
+ADD_DEFINITIONS(-DTEST_RESOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../resources\" )
+
+FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
+ SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
+ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(
+ ../../../
+ ${${CAPI_LIB}_INCLUDE_DIRS}
+ ../dali-adaptor/dali-test-suite-utils
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+ ${${CAPI_LIB}_LIBRARIES}
+ --coverage
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+ DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
--- /dev/null
+#include <test-harness.h>
+
+#include "tct-dali-graphics-core.h"
+
+int main(int argc, char* const argv[])
+{
+ return TestHarness::RunTests(argc, argv, tc_array);
+}
--- /dev/null
+#include <dali-test-suite-utils.h>
+
+#include <dali/graphics-api/graphics-controller.h>
+#include <dali/internal/graphics/gles/egl-graphics-controller.h>
+#include <test-graphics-application.h>
+//#include <dali/graphics-api/graphics-api-buffer.h>
+
+int UtcDaliGraphicsCreateGeometry(void)
+{
+ // Initialize actual egl graphics controller (without initializing egl!)
+ TestGraphicsApplication app;
+
+ struct Vertex
+ {
+ float x;
+ float y;
+ };
+
+ std::vector<Vertex> someData(100);
+ //Graphics::Controller& graphicsController = app.GetGraphicsController();
+
+ //Graphics::BufferCreateInfo createInfo;
+ //createInfo
+ // .SetBufferUsageFlags(BufferUsage::VERTEX_BUFFER)
+ // .SetSize(someData.size();
+
+ //auto buffer = graphicsController->CreateBuffer(createInfo);
+ //std::unique_ptr<Graphics::Memory> memory = graphicsController.MapBufferRange(buffer, 0, someData.size());
+ //uint32_t* memory = memory->Lock();
+ //std::memcpy(memory, &someData[0], someData.size()*sizeof(Vertex));
+ //memory->Unlock();
+
+ //graphicsController.SubmitCommands(emptyCommand);
+
+ // Test that data has been uploaded to GL, e.g. test that GPU buffer has been created
+ //auto& gl = app.GetGlAbstraction();
+ //auto& bufferDataCalls = gl.GetBufferDataCalls();
+ //DALI_TEST_EQUALS(bufferDataCalls.size(), 1u, TEST_LOCATION);
+ //DALI_TEST_EQUALS(bufferDataCalls[0], someData.size(), TEST_LOCATION);
+ DALI_TEST_CHECK(1);
+ END_TEST;
+}
-#include <getopt.h>
-#include <stdlib.h>
-#include <string.h>
#include <test-harness.h>
#include "tct-dali-platform-abstraction-core.h"
int main(int argc, char* const argv[])
{
- int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
-
- const char* optString = "sf";
- bool optRerunFailed(true);
- bool optRunSerially(false);
-
- int nextOpt = 0;
- do
- {
- nextOpt = getopt(argc, argv, optString);
- switch(nextOpt)
- {
- case 'f':
- optRerunFailed = false;
- break;
- case 's':
- optRunSerially = true;
- break;
- case '?':
- TestHarness::Usage(argv[0]);
- exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
- break;
- }
- } while(nextOpt != -1);
-
- if(optind == argc) // no testcase name in argument list
- {
- if(optRunSerially)
- {
- result = TestHarness::RunAll(argv[0], tc_array);
- }
- else
- {
- result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed);
- }
- }
- else
- {
- // optind is index of next argument - interpret as testcase name
- result = TestHarness::FindAndRunTestCase(tc_array, argv[optind]);
- }
- return result;
+ return TestHarness::RunTests(argc, argv, tc_array);
}
install_manifest.txt
libdali2-adaptor.so.*
linker-test
+*config.cmake
+*.dylib
SET( THIRD_PARTY_WINDOWS_PLATFORM ${ROOT_SRC_DIR}/third-party/windows-platform )
ENDIF()
+SET( THIRD_PARTY_MACOS_PLATFORM "" )
+IF( APPLE )
+ SET( THIRD_PARTY_MACOS_PLATFORM ${ROOT_SRC_DIR}/third-party/macos-platform )
+ENDIF()
+
INCLUDE_DIRECTORIES(
${ROOT_SRC_DIR}
${PROFILE_INCLUDE_DIRECTORIES}
${THIRD_PARTY_WINDOWS_PLATFORM}
+ ${THIRD_PARTY_MACOS_PLATFORM}
${VCPKG_INCLUDE_DIR}
${INCLUDE_DIR}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake DESTINATION share/${name})
# Install the pdb file.
- IF( ENABLE_DEBUG )
+ IF( ENABLE_DEBUG AND WIN32 )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/${name}.pdb DESTINATION ${BIN_DIR} )
ENDIF()
ELSE()
INCLUDE( ${ADAPTOR_ROOT}/doc/file.list )
INSTALL( FILES ${package_doxy_files} DESTINATION ${packagedoxydir} )
-IF( NOT UBUNTU_PROFILE AND NOT ANDROID_PROFILE AND NOT WINDOWS_PROFILE )
+IF( NOT UBUNTU_PROFILE AND NOT ANDROID_PROFILE AND NOT WINDOWS_PROFILE AND NOT MACOS_PROFILE )
INSTALL( FILES ${public_api_adaptor_tizen_header_files} DESTINATION ${tizenadaptorframeworkpublicapidir} )
IF( NOT WAYLAND )
INSTALL( FILES ${devel_api_adaptor_tizen_x11_header_files} DESTINATION ${tizenadaptorframeworkdevelapidir} )
ENDIF()
# Test for profile and exit if something wrong
-SET( VALID_PROFILES COMMON MOBILE WEARABLE TV IVI UBUNTU ANDROID WINDOWS )
+SET( VALID_PROFILES COMMON MOBILE WEARABLE TV IVI UBUNTU ANDROID WINDOWS MACOS )
LIST( FIND VALID_PROFILES ${enable_profile} RESULT )
IF( RESULT EQUAL -1 )
MESSAGE( FATAL_ERROR "Invalid profile!" )
SET( fontConfigurationFile $ENV{FONT_CONFIGURATION_FILE} )
ENDIF()
-IF( UBUNTU_PROFILE )
+IF( UBUNTU_PROFILE OR MACOS_PROFILE )
SET( cachePath $ENV{HOME} )
ELSE()
SET( cachePath /home/owner )
-Wall
)
-# Default set of linked librarires
-SET( DALI_LDFLAGS
- ${DALICORE_LDFLAGS}
- ${OPENGLES20_LDFLAGS}
- ${FREETYPE_LDFLAGS}
- ${FONTCONFIG_LDFLAGS}
- ${CAIRO_LDFLAGS}
- ${PNG_LDFLAGS}
- ${WEBP_LDFLAGS}
- ${WEBP_DEMUX_LDFLAGS}
- ${DLOG_LDFLAGS}
- ${VCONF_LDFLAGS}
- ${EXIF_LDFLAGS}
- ${TTS_LDFLAGS}
- ${CAPI_SYSTEM_SENSOR_LDFLAGS}
- ${LIBDRM_LDFLAGS}
- ${LIBEXIF_LDFLAGS}
- ${LIBCURL_LDFLAGS}
- ${LIBCRYPTO_LDFLAGS}
- ${HARFBUZZ_LDFLAGS}
- ${UTILX_LDFLAGS}
- -lgif
- -lturbojpeg
- -ljpeg
-)
+IF (NOT APPLE)
+ # Default set of linked librarires
+ SET( DALI_LDFLAGS
+ ${DALICORE_LDFLAGS}
+ ${OPENGLES20_LDFLAGS}
+ ${FREETYPE_LDFLAGS}
+ ${FONTCONFIG_LDFLAGS}
+ ${CAIRO_LDFLAGS}
+ ${PNG_LDFLAGS}
+ ${WEBP_LDFLAGS}
+ ${WEBP_DEMUX_LDFLAGS}
+ ${DLOG_LDFLAGS}
+ ${VCONF_LDFLAGS}
+ ${EXIF_LDFLAGS}
+ ${TTS_LDFLAGS}
+ ${CAPI_SYSTEM_SENSOR_LDFLAGS}
+ ${LIBDRM_LDFLAGS}
+ ${LIBEXIF_LDFLAGS}
+ ${LIBCURL_LDFLAGS}
+ ${LIBCRYPTO_LDFLAGS}
+ ${HARFBUZZ_LDFLAGS}
+ ${UTILX_LDFLAGS}
+ -lgif
+ -lturbojpeg
+ -ljpeg
+ )
+ENDIF()
# Android includes pthread with android lib
if( NOT ANDROID_PROFILE )
/*
- * 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(...)
--- /dev/null
+# PROFILE: MACOS
+
+# Set the sources
+SET( SOURCES
+ ${adaptor_accessibility_common_src_files}
+ ${adaptor_accessibility_macos_src_files}
+ ${adaptor_adaptor_common_src_files}
+ ${adaptor_adaptor_macos_src_files}
+ ${adaptor_clipboard_common_src_files}
+ ${adaptor_clipboard_macos_src_files}
+ ${adaptor_framework_generic_src_files}
+ ${devel_api_src_files}
+ ${adaptor_devel_api_text_abstraction_src_files}
+ ${adaptor_graphics_common_src_files}
+ ${adaptor_graphics_gles_src_files}
+ ${adaptor_graphics_macos_src_files}
+ ${adaptor_haptics_common_src_files}
+ ${adaptor_imaging_common_src_files}
+ ${adaptor_imaging_macos_src_files}
+ ${adaptor_input_common_src_files}
+ ${adaptor_input_macos_src_files}
+ ${adaptor_integration_api_src_files}
+ ${adaptor_legacy_common_src_files}
+ ${adaptor_network_common_src_files}
+ ${adaptor_offscreen_common_src_files}
+ ${adaptor_public_api_src_files}
+ ${adaptor_sensor_common_src_files}
+ ${adaptor_sensor_macos_src_files}
+ ${adaptor_styling_common_src_files}
+ ${adaptor_system_common_src_files}
+ ${adaptor_system_macos_src_files}
+ ${adaptor_system_macos_src_files}
+ ${adaptor_text_common_src_files}
+ ${adaptor_text_macos_src_files}
+ ${adaptor_resampler_src_files}
+ ${adaptor_vector_animation_common_src_files}
+ ${adaptor_vector_image_common_src_files}
+ ${adaptor_video_common_src_files}
+ ${adaptor_web_engine_common_src_files}
+ ${adaptor_window_system_common_src_files}
+ ${adaptor_macos_platform_src_files}
+ ${adaptor_trace_common_src_files}
+ ${adaptor_thread_common_src_files}
+ ${adaptor_window_system_macos_src_files}
+ ${devel_api_text_abstraction_src_files}
+ ${adaptor_addons_common_src_files}
+ ${adaptor_addons_macos_src_files}
+ ${static_libraries_glyphy_src_files}
+ ${static_libraries_libunibreak_src_files}
+ ${static_libraries_nanosvg_src_files}
+)
+
+IF( ENABLE_NETWORK_LOGGING )
+ SET( SOURCES ${SOURCES}
+ ${adaptor_performance_logging_src_files}
+ )
+ENDIF()
+
+IF( ENABLE_TRACE )
+ SET( SOURCES ${SOURCES}
+ ${adaptor_trace_generic_src_files}
+ )
+ENDIF()
+
+FIND_PACKAGE( curl REQUIRED )
+FIND_LIBRARY( EXIF_LIBRARY NAMES libexif REQUIRED )
+
+FIND_PACKAGE( png REQUIRED )
+FIND_PACKAGE( gif REQUIRED )
+FIND_PACKAGE( jpeg REQUIRED )
+FIND_LIBRARY( TURBO_JPEG_LIBRARY NAMES turbojpeg REQUIRED )
+
+FIND_PACKAGE( freetype REQUIRED )
+FIND_PACKAGE( harfbuzz REQUIRED )
+FIND_LIBRARY( FRIBIDI_LIBRARY NAMES fribidi REQUIRED )
+
+FIND_PACKAGE( unofficial-angle REQUIRED )
+FIND_PACKAGE( unofficial-cairo REQUIRED )
+FIND_PACKAGE( dali2-core REQUIRED)
+
+FIND_PACKAGE( WebP REQUIRED )
+SET(DALI_WEBP_AVAILABLE 1)
+ADD_DEFINITIONS( -DDALI_WEBP_AVAILABLE )
+
+FIND_LIBRARY(OpenGL OpenGL)
+FIND_LIBRARY(IOSurface IOSurface)
+FIND_LIBRARY(QuartzCore QuartzCore)
+FIND_LIBRARY(Foundation Foundation)
+FIND_LIBRARY(Cocoa Cocoa)
+
+# Set the linker flags
+SET(REQUIRED_LIBS
+ CURL::libcurl
+ ${GETOPT_LIBRARY}
+ ${EXIF_LIBRARY}
+ ${PNG_LIBRARIES}
+ ${GIF_LIBRARIES}
+ ${FONTCONFIG_LDFLAGS}
+ ${CAIRO_LDFLAGS}
+ JPEG::JPEG
+ ${TURBO_JPEG_LIBRARY}
+ Freetype::Freetype
+ harfbuzz::harfbuzz
+ ${FRIBIDI_LIBRARY}
+ unofficial::angle::libEGL
+ unofficial::angle::libGLESv2
+ unofficial::cairo::cairo
+ WebP::webp
+ WebP::webpdemux
+ dali2-core::dali2-core
+ ${OpenGL}
+ ${IOSurface}
+ ${Foundation}
+ ${QuartzCore}
+ ${Cocoa}
+ -pthread
+)
+
+# Set compile options
+ADD_COMPILE_OPTIONS(
+ ${FONTCONFIG_CFLAGS}
+ ${CAIRO_CFLAGS}
+)
#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();
}
#define DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H
/*
- * 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 <exception>
#include <functional>
#include <memory>
+#include <stdexcept>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
-#include <stdexcept>
//INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/accessibility.h>
* object as direct ancestor of application and therefore make it visible for
* accessibility clients.
*/
- virtual void AddTopLevelWindow( Accessible* ) = 0;
+ virtual void AddTopLevelWindow(Accessible*) = 0;
/**
* @brief Removes top level window
* structure created from Actors objects. This method removes previously added
* window from visible accessibility objects.
*/
- virtual void RemoveTopLevelWindow( Accessible* ) = 0;
+ virtual void RemoveTopLevelWindow(Accessible*) = 0;
/**
* @brief Adds popup window
* Hierarchy of objects visible for accessibility clients is based on tree-like
* structure created from Actors objects. This method adds new popup to the tree.
*/
- virtual void AddPopup( Accessible* ) = 0;
+ virtual void AddPopup(Accessible*) = 0;
/**
* @brief Removes popup window
* structure created from Actors objects. This method removes previously added
* popup window.
*/
- virtual void RemovePopup( Accessible* ) = 0;
+ virtual void RemovePopup(Accessible*) = 0;
/**
* @brief Set name of current application which will be visible on accessibility bus
*/
- virtual void SetApplicationName( std::string ) = 0;
+ virtual void SetApplicationName(std::string) = 0;
/**
* @brief Get object being root of accessibility tree
*
* @return handler to accessibility object
*/
- virtual Accessible* FindByPath( const std::string& s) const = 0;
+ virtual Accessible* FindByPath(const std::string& s) const = 0;
/**
* @brief Show application on accessibility bus
*/
virtual ForceUpResult ForceUp()
{
- if( data )
+ if(data)
{
return ForceUpResult::ALREADY_UP;
}
- data = std::make_shared< Data >();
+ data = std::make_shared<Data>();
data->bridge = this;
return ForceUpResult::JUST_STARTED;
}
/**
* @brief Emits caret-moved event on at-spi bus.
**/
- virtual void EmitCaretMoved( Accessible* obj, unsigned int cursorPosition ) = 0;
+ virtual void EmitCaretMoved(Accessible* obj, unsigned int cursorPosition) = 0;
/**
* @brief Emits active-descendant-changed event on at-spi bus.
**/
- virtual void EmitActiveDescendantChanged( Accessible* obj, Accessible *child ) = 0;
+ virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0;
/**
* @brief Emits text-changed event on at-spi bus.
**/
- virtual void EmitTextChanged( Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string &content ) = 0;
+ virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0;
/**
* @brief Emits state-changed event on at-spi bus.
**/
- virtual void EmitStateChanged( Accessible* obj, State state, int val1, int val2 = 0 ) = 0;
+ virtual void EmitStateChanged(Accessible* obj, State state, int val1, int val2 = 0) = 0;
/**
* @brief Emits window event on at-spi bus.
**/
- virtual void Emit( Accessible* obj, WindowEvent we, unsigned int detail1 = 0 ) = 0;
+ virtual void Emit(Accessible* obj, WindowEvent we, unsigned int detail1 = 0) = 0;
/**
* @brief Emits property-changed event on at-spi bus.
**/
- virtual void Emit( Accessible* obj, ObjectPropertyChangeEvent event ) = 0;
+ virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0;
/**
* @brief Emits bounds-changed event on at-spi bus.
**/
- virtual void EmitBoundsChanged( Accessible* obj, Rect<> rect ) = 0;
+ virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0;
/**
* @brief Emits key event on at-spi bus.
* Screen-reader might receive this event and reply, that given keycode is consumed. In that case
* further processing of the keycode should be ignored.
**/
- virtual Consumed Emit( KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText ) = 0;
+ virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0;
/**
* @brief Reads given text by screen reader
* Callback can be one of the following signals:
* ReadingCancelled, ReadingStopped, ReadingSkipped
*/
- virtual void Say( const std::string& text, bool discardable, std::function<void(std::string)> callback ) = 0;
+ virtual void Say(const std::string& text, bool discardable, std::function<void(std::string)> callback) = 0;
/**
* @brief Force accessibility client to pause.
protected:
struct Data
{
- std::unordered_set< Accessible* > knownObjects;
- std::string busName;
- Bridge* bridge = nullptr;
- Actor highlightActor, currentlyHighlightedActor;
+ std::unordered_set<Accessible*> knownObjects;
+ std::string busName;
+ Bridge* bridge = nullptr;
+ Actor highlightActor, currentlyHighlightedActor;
};
- std::shared_ptr< Data > data;
+ std::shared_ptr<Data> data;
friend class Accessible;
/**
* might come and object will be identified by number id (it's memory address).
* To avoid memory corruption number id is checked against set of known objects.
**/
- void RegisterOnBridge( Accessible* );
+ void RegisterOnBridge(Accessible*);
/**
* @brief Tells bridge, that given object is considered root (doesn't have any parents).
* All root objects will have the same parent - application object. Application object
* is controlled by bridge and private.
**/
- void SetIsOnRootLevel( Accessible* );
+ void SetIsOnRootLevel(Accessible*);
};
/**
*/
inline bool IsUp()
{
- if( Bridge::GetCurrentBridge() == nullptr )
+ if(Bridge::GetCurrentBridge() == nullptr)
{
return false;
}
- if( Bridge::GetCurrentBridge()->GetIsEnabled() == false )
+ if(Bridge::GetCurrentBridge()->GetIsEnabled() == false)
{
return false;
}
* language to use. Word boundaries are returned as non-zero values in table breaks, which
* must be of size at least length.
**/
- void FindWordSeparationsUtf8( const utf8_t *s, size_t length, const char *language, char *breaks );
+ void FindWordSeparationsUtf8(const utf8_t* s, size_t length, const char* language, char* breaks);
/**
* @brief Calculaties line boundaries in given utf8 text.
* language to use. Line boundaries are returned as non-zero values in table breaks, which
* must be of size at least length.
**/
- void FindLineSeparationsUtf8( const utf8_t *s, size_t length, const char *language, char *breaks );
+ void FindLineSeparationsUtf8(const utf8_t* s, size_t length, const char* language, char* breaks);
/**
* @brief Helper function for emiting active-descendant-changed event
**/
- void EmitActiveDescendantChanged( Accessible* obj, Accessible *child );
+ void EmitActiveDescendantChanged(Accessible* obj, Accessible* child);
/**
* @brief Helper function for emiting state-changed event
**/
- void EmitStateChanged( State state, int newValue1, int newValue2 = 0 );
+ void EmitStateChanged(State state, int newValue1, int newValue2 = 0);
/**
* @brief Helper function for emiting bounds-changed event
**/
- void EmitBoundsChanged( Rect<> rect );
+ void EmitBoundsChanged(Rect<> rect);
/**
* @brief Emit "showing" event.
*
* @param[in] showing flag pointing if object is showing
*/
- void EmitShowing( bool showing );
+ void EmitShowing(bool showing);
/**
* @brief Emit "visible" event.
*
* @param[in] visible flag pointing if object is visible
*/
- void EmitVisible( bool visible );
+ void EmitVisible(bool visible);
/**
* @brief Emit "highlighted" event.
*
* @param[in] set flag pointing if object is highlighted
*/
- void EmitHighlighted( bool set );
+ void EmitHighlighted(bool set);
/**
* @brief Emit "focused" event.
*
* @param[in] set flag pointing if object is focused
*/
- void EmitFocused( bool set );
+ void EmitFocused(bool set);
/**
* @brief Emit "text inserted" event
* @param[in] length text length
* @param[in] content inserted text
*/
- void EmitTextInserted( unsigned int position, unsigned int length, const std::string &content );
+ void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content);
/**
* @brief Emit "text deleted" event
* @param[in] length text length
* @param[in] content deleted text
*/
- void EmitTextDeleted( unsigned int position, unsigned int length, const std::string &content );
+ void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content);
/**
* @brief Emit "caret moved" event
*
* @param[in] cursorPosition new caret position
*/
- void EmitTextCaretMoved( unsigned int cursorPosition );
+ void EmitTextCaretMoved(unsigned int cursorPosition);
/**
* @brief Emit "highlighted" event
* @param[in] we enumerated window event
* @param[in] detail1 additional parameter which interpretation depends on chosen event
*/
- void Emit( WindowEvent we, unsigned int detail1 = 0 );
+ void Emit(WindowEvent we, unsigned int detail1 = 0);
/**
* @brief Emits property-changed event
* @param[in] event Property changed event
**/
- void Emit( ObjectPropertyChangeEvent event );
+ void Emit(ObjectPropertyChangeEvent event);
/**
* @brief Get accessibility name
*
* @return collection of accessibility objects
*/
- virtual std::vector< Accessible* > GetChildren();
+ virtual std::vector<Accessible*> GetChildren();
/**
* @brief Get nth child
*
* @return accessibility object
*/
- virtual Accessible* GetChildAtIndex( size_t index ) = 0;
+ virtual Accessible* GetChildAtIndex(size_t index) = 0;
/**
* @brief Get index that current object has in its parent's children collection
*
* @see Dali::Accessibility::GestureInfo
*/
- virtual bool DoGesture(const GestureInfo &gestureInfo) = 0;
+ virtual bool DoGesture(const GestureInfo& gestureInfo) = 0;
/**
* @brief Re-emits selected states of an Accessibility Object
* @param[in] states chosen states to re-emit
* @param[in] doRecursive if true all children of the Accessibility Object will also re-emit the states
*/
- void NotifyAccessibilityStateChange( Dali::Accessibility::States states, bool doRecursive );
+ void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool doRecursive);
/**
* @brief Get information about current object and all relations that connects
*
* @return collection of strings with implemented interfaces
*/
- std::vector< std::string > GetInterfaces();
+ std::vector<std::string> GetInterfaces();
/**
* @brief Check if object is on root level
*/
- bool GetIsOnRootLevel() const { return isOnRootLevel; }
+ bool GetIsOnRootLevel() const
+ {
+ return isOnRootLevel;
+ }
/**
* @brief The method registers functor resposible for converting Actor into Accessible
* @param functor returning Accessible handle from Actor object
*/
- static void RegisterControlAccessibilityGetter( std::function< Accessible*( Dali::Actor ) > functor);
+ static void RegisterControlAccessibilityGetter(std::function<Accessible*(Dali::Actor)> functor);
/**
* @brief Acquire Accessible object from Actor object
*
* @return handle to Accessible object
*/
- static Accessible* Get( Dali::Actor actor, bool root = false );
+ static Accessible* Get(Dali::Actor actor, bool root = false);
protected:
Accessible();
- Accessible( const Accessible& ) = delete;
- Accessible( Accessible&& ) = delete;
- Accessible& operator=( const Accessible& ) = delete;
- Accessible& operator=( Accessible&& ) = delete;
- std::shared_ptr< Bridge::Data > GetBridgeData();
+ Accessible(const Accessible&) = delete;
+ Accessible(Accessible&&) = delete;
+ Accessible& operator=(const Accessible&) = delete;
+ Accessible& operator=(Accessible&&) = delete;
+ std::shared_ptr<Bridge::Data> GetBridgeData();
public:
static Dali::Actor GetHighlightActor();
- static void SetHighlightActor(Dali::Actor actor);
+ static void SetHighlightActor(Dali::Actor actor);
static Dali::Actor GetCurrentlyHighlightedActor();
- static void SetCurrentlyHighlightedActor(Dali::Actor);
- static void SetObjectRegistry(ObjectRegistry registry);
+ static void SetCurrentlyHighlightedActor(Dali::Actor);
+ static void SetObjectRegistry(ObjectRegistry registry);
private:
friend class Bridge;
- std::weak_ptr< Bridge::Data > bridgeData;
- bool isOnRootLevel = false;
+ std::weak_ptr<Bridge::Data> bridgeData;
+ bool isOnRootLevel = false;
};
/**
*
* @return string with name of action
*/
- virtual std::string GetActionName( size_t index ) = 0;
+ virtual std::string GetActionName(size_t index) = 0;
/**
* @brief Get translated name of action with given index
*
* @note translation is not supported in this version
*/
- virtual std::string GetLocalizedActionName( size_t index ) = 0;
+ virtual std::string GetLocalizedActionName(size_t index) = 0;
/**
* @brief Get description of action with given index
*
* @return string with description of action
*/
- virtual std::string GetActionDescription( size_t index ) = 0;
+ virtual std::string GetActionDescription(size_t index) = 0;
/**
* @brief Get key code binded to action with given index
*
* @return string with key name
*/
- virtual std::string GetActionKeyBinding( size_t index ) = 0;
+ virtual std::string GetActionKeyBinding(size_t index) = 0;
/**
* @brief Get number of provided actions
*
* @return true on success, false otherwise
*/
- virtual bool DoAction( size_t index ) = 0;
+ virtual bool DoAction(size_t index) = 0;
/**
* @brief Perform an action with given name
*
* @return true on success, false otherwise
*/
- virtual bool DoAction( const std::string& name ) = 0;
-
+ virtual bool DoAction(const std::string& name) = 0;
};
/**
*
* @see Dali::Rect
*/
- virtual Rect<> GetExtents( CoordType ctype ) = 0;
+ virtual Rect<> GetExtents(CoordType ctype) = 0;
/**
* @brief Get layer current object is localized on
*
* @see Dali::Accessibility::Point
*/
- virtual Accessible* GetAccessibleAtPoint( Point p, CoordType ctype );
+ virtual Accessible* GetAccessibleAtPoint(Point p, CoordType ctype);
/**
* @brief Check if current object contains given point
*
* @see Dali::Accessibility::Point
*/
- virtual bool Contains( Point p, CoordType ctype );
+ virtual bool Contains(Point p, CoordType ctype);
};
/**
*
* @return true if value could have been assigned, false otherwise
*/
- virtual bool SetCurrent( double val) = 0;
+ virtual bool SetCurrent(double val) = 0;
/**
* @brief Get the lowest increment that can be distinguished
*
* @return substring of stored text
*/
- virtual std::string GetText( size_t startOffset, size_t endOffset ) = 0;
+ virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
/**
* @brief Get number of all stored characters
*
* @see Dali::Accessibility::Range
*/
- virtual Range GetTextAtOffset( size_t offset, TextBoundary boundary ) = 0;
+ virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
/**
* @brief Get selected text
*
* @see Dali::Accessibility::Range
*/
- virtual Range GetSelection( size_t selectionNum ) = 0;
+ virtual Range GetSelection(size_t selectionNum) = 0;
/**
* @brief Remove selection
*
* @return bool on success, false otherwise
*/
- virtual bool RemoveSelection( size_t selectionNum ) = 0;
+ virtual bool RemoveSelection(size_t selectionNum) = 0;
/**
* @brief Get selected text
*
* @return true on success, false otherwise
*/
- virtual bool SetSelection( size_t selectionNum, size_t startOffset, size_t endOffset ) = 0;
+ virtual bool SetSelection(size_t selectionNum, size_t startOffset, size_t endOffset) = 0;
};
/**
*
* @return true on success, false otherwise
*/
- virtual bool CopyText( size_t startPosition, size_t endPosition ) = 0;
+ virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
/**
* @brief Cut text in range to system clipboard
*
* @return true on success, false otherwise
*/
- virtual bool CutText( size_t startPosition, size_t endPosition ) = 0;
+ virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
};
/**
{
public:
EmptyAccessibleWithAddress() = default;
- EmptyAccessibleWithAddress( Address address ) : address( std::move( address ) ) {}
+ EmptyAccessibleWithAddress(Address address)
+ : address(std::move(address))
+ {
+ }
- void SetAddress( Address address ) { this->address = std::move( address ); }
+ void SetAddress(Address address)
+ {
+ this->address = std::move(address);
+ }
- std::string GetName() override { return ""; }
- std::string GetDescription() override { return ""; }
- Accessible* GetParent() override { return nullptr; }
- size_t GetChildCount() override { return 0; }
- std::vector< Accessible* > GetChildren() override { return {}; }
- Accessible* GetChildAtIndex( size_t index ) override
+ std::string GetName() override
{
- throw std::domain_error{"out of bounds index (" + std::to_string( index ) + ") - no children"};
+ return "";
+ }
+ std::string GetDescription() override
+ {
+ return "";
+ }
+ Accessible* GetParent() override
+ {
+ return nullptr;
+ }
+ size_t GetChildCount() override
+ {
+ return 0;
+ }
+ std::vector<Accessible*> GetChildren() override
+ {
+ return {};
+ }
+ Accessible* GetChildAtIndex(size_t index) override
+ {
+ throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"};
+ }
+ size_t GetIndexInParent() override
+ {
+ return static_cast<size_t>(-1);
+ }
+ Role GetRole() override
+ {
+ return {};
}
- size_t GetIndexInParent() override { return static_cast< size_t >( -1 ); }
- Role GetRole() override { return {}; }
std::string GetRoleName() override;
- States GetStates() override { return {}; }
- Attributes GetAttributes() override { return {}; }
+ States GetStates() override
+ {
+ return {};
+ }
+ Attributes GetAttributes() override
+ {
+ return {};
+ }
Address GetAddress() override
{
return address;
}
- bool DoGesture(const GestureInfo &gestureInfo) override
+ bool DoGesture(const GestureInfo& gestureInfo) override
{
return false;
}
Address address;
};
-}
-}
+} // namespace Accessibility
+} // namespace Dali
#endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H
#ifndef DALI_ATSPI_ACCESSIBILITY_H\r
#define DALI_ATSPI_ACCESSIBILITY_H\r
/*\r
- * Copyright (c) 2019 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
// EXTERNAL INCLUDES\r
\r
+#include <string.h>\r
#include <array>\r
#include <atomic>\r
#include <bitset>\r
+#include <cassert>\r
#include <exception>\r
#include <functional>\r
+#include <list>\r
+#include <map>\r
#include <memory>\r
+#include <sstream>\r
#include <string>\r
-#include <map>\r
#include <unordered_map>\r
#include <vector>\r
-#include <list>\r
-#include <cassert>\r
-#include <sstream>\r
-#include <string.h>\r
\r
// INTERNAL INCLUDES\r
#include <dali/public-api/dali-adaptor-common.h>\r
{\r
namespace Accessibility\r
{\r
-\r
/**\r
* @brief Enumeration describing a relation between accessible objects\r
* 1 to 0..N relation model is supported. By default relation is not symmetrical.\r
*/\r
enum class RelationType : uint32_t\r
{\r
- NULL_OF, ///< Null Relation.\r
- LABEL_FOR, ///< Label For.\r
- LABELLED_BY, ///< Labelled By.\r
- CONTROLLER_FOR, ///< Controller For.\r
- CONTROLLED_BY, ///< Controlled By.\r
- MEMBER_OF, ///< Member Of.\r
- TOOLTIP_FOR, ///< ToolTip For.\r
- NODE_CHILD_OF, ///< Node Child Of.\r
- NODE_PARENT_OF, ///< Node Parent Of.\r
- EXTENDED, ///< Extended.\r
- FLOWS_TO, ///< Flows To.\r
- FLOWS_FROM, ///< Flows From.\r
- SUBWINDOW_OF, ///< Sub Window Of.\r
- EMBEDS, ///< Embeds.\r
- EMBEDDED_BY, ///< Embedded By.\r
- POPUP_FOR, ///< Popup For\r
+ NULL_OF, ///< Null Relation.\r
+ LABEL_FOR, ///< Label For.\r
+ LABELLED_BY, ///< Labelled By.\r
+ CONTROLLER_FOR, ///< Controller For.\r
+ CONTROLLED_BY, ///< Controlled By.\r
+ MEMBER_OF, ///< Member Of.\r
+ TOOLTIP_FOR, ///< ToolTip For.\r
+ NODE_CHILD_OF, ///< Node Child Of.\r
+ NODE_PARENT_OF, ///< Node Parent Of.\r
+ EXTENDED, ///< Extended.\r
+ FLOWS_TO, ///< Flows To.\r
+ FLOWS_FROM, ///< Flows From.\r
+ SUBWINDOW_OF, ///< Sub Window Of.\r
+ EMBEDS, ///< Embeds.\r
+ EMBEDDED_BY, ///< Embedded By.\r
+ POPUP_FOR, ///< Popup For\r
PARENT_WINDOW_OF, ///< Parent Window Of.\r
- DESCRIPTION_FOR, ///< Description For.\r
- DESCRIBED_BY, ///< Described By.\r
- DETAILS, ///< Details.\r
- DETAILS_FOR, ///< Details For.\r
- ERROR_MESSAGE, ///< Error Message.\r
- ERROR_FOR, ///< Error For.\r
+ DESCRIPTION_FOR, ///< Description For.\r
+ DESCRIBED_BY, ///< Described By.\r
+ DETAILS, ///< Details.\r
+ DETAILS_FOR, ///< Details For.\r
+ ERROR_MESSAGE, ///< Error Message.\r
+ ERROR_FOR, ///< Error For.\r
MAX_COUNT\r
};\r
\r
enum class CoordType\r
{\r
SCREEN, ///< Screen.\r
- WINDOW ///< Window.\r
+ WINDOW ///< Window.\r
};\r
\r
/**\r
*/\r
enum class ComponentLayer\r
{\r
- INVALID, ///< Invalid.\r
+ INVALID, ///< Invalid.\r
BACKGROUND, ///< Background.\r
- CANVAS, ///< Canvas.\r
- WIDGET, ///< Widget.\r
- MDI, ///< MDI.\r
- POPUP, ///< Popup.\r
- OVERLAY, ///< Overlay.\r
- WINDOW, ///< Window.\r
+ CANVAS, ///< Canvas.\r
+ WIDGET, ///< Widget.\r
+ MDI, ///< MDI.\r
+ POPUP, ///< Popup.\r
+ OVERLAY, ///< Overlay.\r
+ WINDOW, ///< Window.\r
MAX_COUNT\r
};\r
\r
enum class TextBoundary : uint32_t\r
{\r
CHARACTER, ///> Only one character is acquired.\r
- WORD, ///> Not supported.\r
- SENTENCE, ///> Not supported.\r
- LINE, ///> Not supported.\r
+ WORD, ///> Not supported.\r
+ SENTENCE, ///> Not supported.\r
+ LINE, ///> Not supported.\r
PARAGRAPH, ///> Not supported.\r
MAX_COUNT\r
};\r
* @see Dali::Accessibility::Accessible::GetStates\r
* @see Dali::Accessibility::Accessible::GetRoles\r
*/\r
-template < size_t I, typename S >\r
+template<size_t I, typename S>\r
class BitSets\r
{\r
- std::array< uint32_t, I > data;\r
+ std::array<uint32_t, I> data;\r
\r
void _set()\r
{\r
return true;\r
}\r
\r
- template < typename T > static constexpr bool _accepts()\r
+ template<typename T>\r
+ static constexpr bool _accepts()\r
{\r
- return std::is_enum< T >::value;\r
+ return std::is_enum<T>::value;\r
}\r
\r
- template < typename T, typename T2, typename ... ARGS > static constexpr bool _accepts()\r
+ template<typename T, typename T2, typename... ARGS>\r
+ static constexpr bool _accepts()\r
{\r
- return std::is_enum< T >::value && _accepts< T2, ARGS... >();\r
+ return std::is_enum<T>::value && _accepts<T2, ARGS...>();\r
}\r
\r
- template < typename T, typename ... ARGS > void _set(T t, ARGS ... args)\r
+ template<typename T, typename... ARGS>\r
+ void _set(T t, ARGS... args)\r
{\r
(*this)[t] = true;\r
_set(args...);\r
}\r
+\r
public:\r
BitSets()\r
{\r
- for( auto& u : data )\r
+ for(auto& u : data)\r
{\r
u = 0;\r
}\r
}\r
BitSets(const BitSets&) = default;\r
- BitSets(BitSets&&) = default;\r
+ BitSets(BitSets&&) = default;\r
\r
- template < typename T, typename ... ARGS, typename std::enable_if< _accepts< T, ARGS... >() >::type * = nullptr >BitSets( T t, ARGS ... args )\r
+ template<typename T, typename... ARGS, typename std::enable_if<_accepts<T, ARGS...>()>::type* = nullptr>\r
+ BitSets(T t, ARGS... args)\r
{\r
- for( auto& u : data )\r
- u = 0;\r
- _set( t, args... );\r
+ for(auto& u : data)\r
+ u = 0;\r
+ _set(t, args...);\r
}\r
\r
- explicit BitSets( std::array< uint32_t, I > d )\r
+ explicit BitSets(std::array<uint32_t, I> d)\r
{\r
- for( auto i = 0u; i < I; ++i )\r
+ for(auto i = 0u; i < I; ++i)\r
{\r
data[i] = d[i];\r
}\r
}\r
\r
- explicit BitSets( std::array< int32_t, I > d )\r
+ explicit BitSets(std::array<int32_t, I> d)\r
{\r
- for( auto i = 0u; i < I; ++i )\r
+ for(auto i = 0u; i < I; ++i)\r
{\r
- data[i] = static_cast<uint32_t>( d[i] );\r
+ data[i] = static_cast<uint32_t>(d[i]);\r
}\r
}\r
\r
- BitSets& operator = (const BitSets&) = default;\r
- BitSets& operator = (BitSets&&) = default;\r
+ BitSets& operator=(const BitSets&) = default;\r
+ BitSets& operator=(BitSets&&) = default;\r
\r
struct reference\r
{\r
- std::array< uint32_t, I >& data;\r
- size_t pos;\r
+ std::array<uint32_t, I>& data;\r
+ size_t pos;\r
\r
- reference& operator=( reference r )\r
+ reference& operator=(reference r)\r
{\r
- (*this) = static_cast<bool>( r );\r
+ (*this) = static_cast<bool>(r);\r
return *this;\r
}\r
\r
- reference& operator=( bool v )\r
+ reference& operator=(bool v)\r
{\r
- if( v )\r
+ if(v)\r
{\r
data[pos / 32] |= 1 << (pos & 31);\r
}\r
\r
operator bool() const\r
{\r
- auto i = static_cast<size_t>( pos );\r
+ auto i = static_cast<size_t>(pos);\r
return (data[i / 32] & (1 << (i & 31))) != 0;\r
}\r
};\r
\r
- reference operator[]( S index )\r
+ reference operator[](S index)\r
{\r
- return { data, static_cast<size_t>( index ) };\r
+ return {data, static_cast<size_t>(index)};\r
}\r
\r
- bool operator[]( S index ) const\r
+ bool operator[](S index) const\r
{\r
- auto i = static_cast<size_t>( index );\r
- return ( data[i / 32] & ( 1 << (i & 31) ) ) != 0;\r
+ auto i = static_cast<size_t>(index);\r
+ return (data[i / 32] & (1 << (i & 31))) != 0;\r
}\r
\r
- std::array< uint32_t, I > GetRawData() const\r
+ std::array<uint32_t, I> GetRawData() const\r
{\r
return data;\r
}\r
\r
- BitSets operator|( BitSets b ) const\r
+ BitSets operator|(BitSets b) const\r
{\r
BitSets r;\r
- for( auto i = 0u; i < I; ++i )\r
+ for(auto i = 0u; i < I; ++i)\r
{\r
r.data[i] = data[i] | b.data[i];\r
}\r
return r;\r
}\r
\r
- BitSets operator^( BitSets b ) const\r
+ BitSets operator^(BitSets b) const\r
{\r
BitSets r;\r
- for( auto i = 0u; i < I; ++i )\r
+ for(auto i = 0u; i < I; ++i)\r
{\r
r.data[i] = data[i] ^ b.data[i];\r
}\r
return r;\r
}\r
\r
- BitSets operator&( BitSets b ) const\r
+ BitSets operator&(BitSets b) const\r
{\r
BitSets r;\r
- for( auto i = 0u; i < I; ++i )\r
+ for(auto i = 0u; i < I; ++i)\r
{\r
r.data[i] = data[i] & b.data[i];\r
}\r
return r;\r
}\r
\r
- bool operator==( BitSets b ) const\r
+ bool operator==(BitSets b) const\r
{\r
- for( auto i = 0u; i < I; ++i )\r
+ for(auto i = 0u; i < I; ++i)\r
{\r
- if( data[i] != b.data[i] )\r
+ if(data[i] != b.data[i])\r
{\r
return false;\r
}\r
\r
explicit operator bool() const\r
{\r
- for( auto& u : data )\r
+ for(auto& u : data)\r
{\r
- if( u )\r
+ if(u)\r
{\r
return true;\r
}\r
};\r
\r
using ReadingInfoTypes = BitSets<1, ReadingInfoType>;\r
-using States = BitSets< 2, State >;\r
-using Attributes = std::unordered_map< std::string, std::string >;\r
+using States = BitSets<2, State>;\r
+using Attributes = std::unordered_map<std::string, std::string>;\r
\r
/**\r
* @brief Class representing unique object address on accessibility bus\r
public:\r
Address() = default;\r
\r
- Address( std::string bus, std::string path )\r
+ Address(std::string bus, std::string path)\r
: mBus(std::move(bus)),\r
mPath(std::move(path))\r
{\r
return mPath;\r
}\r
\r
- bool operator == ( const Address& a ) const\r
+ bool operator==(const Address& a) const\r
{\r
return mBus == a.mBus && mPath == a.mPath;\r
}\r
\r
- bool operator != ( const Address& a ) const\r
+ bool operator!=(const Address& a) const\r
{\r
return !(*this == a);\r
}\r
\r
Point() = default;\r
\r
- Point( int x, int y )\r
+ Point(int x, int y)\r
: x(x),\r
y(y)\r
{\r
*/\r
struct DALI_ADAPTOR_API Size\r
{\r
- int width = 0;\r
+ int width = 0;\r
int height = 0;\r
\r
Size() = default;\r
{\r
}\r
\r
- bool operator==( Size p ) const\r
+ bool operator==(Size p) const\r
{\r
return width == p.width && height == p.height;\r
}\r
\r
- bool operator!=( Size p ) const\r
+ bool operator!=(Size p) const\r
{\r
return !(*this == p);\r
}\r
*/\r
struct DALI_ADAPTOR_API Range\r
{\r
- int32_t startOffset = 0;\r
- int32_t endOffset = 0;\r
+ int32_t startOffset = 0;\r
+ int32_t endOffset = 0;\r
std::string content;\r
\r
Range() = default;\r
{\r
}\r
\r
- Gesture type{};\r
- int32_t xBeg{};\r
- int32_t xEnd{};\r
- int32_t yBeg{};\r
- int32_t yEnd{};\r
+ Gesture type{};\r
+ int32_t xBeg{};\r
+ int32_t xEnd{};\r
+ int32_t yBeg{};\r
+ int32_t yEnd{};\r
GestureState state{};\r
- uint32_t eventTime{};\r
+ uint32_t eventTime{};\r
};\r
\r
/**\r
*/\r
struct DALI_ADAPTOR_API Relation\r
{\r
-Relation(RelationType relationType, std::vector<Address> targets)\r
-: relationType(relationType),\r
- targets(targets)\r
-{\r
-}\r
+ Relation(RelationType relationType, std::vector<Address> targets)\r
+ : relationType(relationType),\r
+ targets(targets)\r
+ {\r
+ }\r
\r
-RelationType relationType;\r
-std::vector<Address> targets;\r
+ RelationType relationType;\r
+ std::vector<Address> targets;\r
};\r
\r
} // namespace Accessibility\r
/*
- * 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)
+{
+ GetImplementation(*this).SetRenderingMode(mode);
+}
+
+GlWindow::RenderingMode GlWindow::GetRenderingMode() const
+{
+ return GetImplementation(*this).GetRenderingMode();
+}
+
GlWindow::FocusChangeSignalType& GlWindow::FocusChangeSignal()
{
return GetImplementation(*this).FocusChangeSignal();
return GetImplementation(*this).VisibilityChangedSignal();
}
-GlWindow::GlWindow( Internal::Adaptor::GlWindow* window )
-: BaseHandle( window )
+GlWindow::GlWindow(Internal::Adaptor::GlWindow* window)
+: BaseHandle(window)
{
}
-}// Dali
+} // namespace Dali
#define DALI_GL_WINDOW_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.
*/
// EXTERNAL INCLUDES
-#include <string>
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/uint-16-pair.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/signals/dali-signal.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
+#include <string>
// INTERNAL INCLUDES
#include <dali/public-api/dali-adaptor-common.h>
{
class GlWindow;
}
-}
+} // namespace DALI_INTERNAL
class TouchEvent;
class KeyEvent;
class DALI_ADAPTOR_API GlWindow : public BaseHandle
{
public:
+ using WindowSize = Uint16Pair;
- using WindowSize = Uint16Pair ;
-
- typedef Signal< void ( const KeyEvent& ) > KeyEventSignalType; ///< GlWindow Key Event signal type
- typedef Signal< void ( const TouchEvent& ) > TouchEventSignalType; ///< GlWindow Touch Event signal type
- typedef Signal< void ( GlWindow, bool ) > FocusChangeSignalType; ///< GlWindow Focus signal type
- typedef Signal< void ( WindowSize ) > ResizeSignalType; ///< GlWindow resize signal type
- typedef Signal< void ( GlWindow, bool ) > VisibilityChangedSignalType; ///< GlWindow visibility change signal type
+ typedef Signal<void(const KeyEvent&)> KeyEventSignalType; ///< GlWindow Key Event signal type
+ typedef Signal<void(const TouchEvent&)> TouchEventSignalType; ///< GlWindow Touch Event signal type
+ typedef Signal<void(GlWindow, bool)> FocusChangeSignalType; ///< GlWindow Focus signal type
+ typedef Signal<void(WindowSize)> ResizeSignalType; ///< GlWindow resize signal type
+ typedef Signal<void(GlWindow, bool)> VisibilityChangedSignalType; ///< GlWindow visibility change signal type
public:
-
// Enumerations
/**
*/
enum class GlesVersion
{
- VERSION_2_0 = 0, ///< GLES version 2.0
- VERSION_3_0, ///< GLES version 3.0
+ VERSION_2_0 = 0, ///< GLES version 2.0
+ VERSION_3_0, ///< GLES version 3.0
+ };
+
+ /**
+ * @brief Enumeration for rendering mode
+ *
+ * This Enumeration is used to choose the rendering mode.
+ * It has two options.
+ * One of them is continuous mode. It is rendered continuously.
+ * The other is on demand mode. It is rendered by application.
+ */
+ enum class RenderingMode
+ {
+ CONTINUOUS, ///< continuous mode
+ ON_DEMAND ///< on demand by application
};
/**
* @note This creates an extra GlWindow in addition to the default main GlWindow
* @return A new GlWindow
*/
- static GlWindow New( PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent = false );
+ static GlWindow New(PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
/**
* @brief Creates an uninitialized handle.
*/
GlWindow& operator=(const GlWindow& rhs);
- /**
+ /**
* @brief Move constructor.
*
* @param[in] rhs A reference to the moved handle
* @param[in] version the GLES version
*
*/
- void SetEglConfig( bool depth, bool stencil, int msaa, GlesVersion version );
+ void SetEglConfig(bool depth, bool stencil, int msaa, GlesVersion version);
/**
* @brief Raises GlWindow to the top of GlWindow stack.
*
* @param[in] positionSize The new GlWindow position
*/
- void SetPositionSize( PositionSize positionSize );
+ void SetPositionSize(PositionSize positionSize);
/**
* @brief Gets a position of the GlWindow.
* @note The window auxiliary hint is the value which is used to decide which actions should be made available to the user by the window manager.
* If you want to set specific hint to your window, then you should check whether it exists in the supported auxiliary hints.
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const;
/**
* @brief Creates an auxiliary hint of the window.
* @param[in] value The value string.
* @return The ID of created auxiliary hint, or @c 0 on failure.
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value);
/**
* @brief Removes an auxiliary hint of the window.
* @param[in] id The ID of the auxiliary hint.
* @return True if no error occurred, false otherwise.
*/
- bool RemoveAuxiliaryHint( unsigned int id );
+ bool RemoveAuxiliaryHint(unsigned int id);
/**
* @brief Changes a value of the auxiliary hint.
* @param[in] value The value string to be set.
* @return True if no error occurred, false otherwise.
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value);
/**
* @brief Gets a value of the auxiliary hint.
* @param[in] id The auxiliary hint ID.
* @return The string value of the auxiliary hint ID, or an empty string if none exists.
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const;
+ std::string GetAuxiliaryHintValue(unsigned int id) const;
/**
* @brief Gets a ID of the auxiliary hint string.
* @param[in] hint The auxiliary hint string.
* @return The ID of the auxiliary hint string, or @c 0 if none exists.
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const;
/**
* @brief Sets a region to accept input events.
*
* @param[in] inputRegion The region to accept input events.
*/
- void SetInputRegion( const Rect< int >& inputRegion );
+ void SetInputRegion(const Rect<int>& inputRegion);
/**
* @brief Sets a transparent window's visual state to opaque.
* @remarks This will have no effect on an opaque window.
* It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
*/
- void SetOpaqueState( bool opaque );
+ void SetOpaqueState(bool opaque);
/**
* @brief Returns whether a transparent window's visual state is opaque or not.
*
* @return The current GlWindow rotation angle if previously set, or none
*/
- WindowOrientation GetCurrentOrientation() const;
+ WindowOrientation GetCurrentOrientation() const;
- /**
+ /**
* @brief Sets available orientations of the window.
*
* This API is for setting several orientations one time.
*
* @param[in] orientations The available orientations list to add
*/
- void SetAvailableOrientations( const Dali::Vector<WindowOrientation>& orientations );
+ void SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations);
/**
* @brief Sets a preferred orientation.
*
* @note To unset the preferred orientation, angle should be set NO_ORIENTATION_PREFERENCE.
*/
- void SetPreferredOrientation( WindowOrientation orientation );
+ void SetPreferredOrientation(WindowOrientation orientation);
/**
* @brief Registers a GL callback function for application.
* @endcode
* This callback is called when GlWindow is deleted.
*/
- void RegisterGlCallback( CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback );
+ void RegisterGlCallback(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback);
/**
* @brief Renders once more even if GL render functions are not added to idler.
*/
void RenderOnce();
-public: // Signals
+ /**
+ * @brief Sets rendering mode.
+ *
+ * @param[in] mode the rendering mode for GlWindow
+ *
+ * @note The default Rendering mode is continuous.
+ * If OnDemand mode is set, it is rendered by RenderOnce()
+ */
+ void SetRenderingMode(RenderingMode mode);
/**
+ * @brief Gets rendering mode.
+ *
+ * @return current rendering mode in this GlWindow
+ *
+ * @note The default Rendering mode is continuous.
+ * If OnDemand mode is set, it is rendered by RenderOnce()
+ */
+ RenderingMode GetRenderingMode() const;
+
+public: // Signals
+ /**
* @brief The user should connect to this signal to get a timing when GlWindow gains focus or loses focus.
*
* A callback of the following type may be connected:
* @brief This constructor is used by Dali::Application::GetGlWindow().
* @param[in] GlWindow A pointer to the GlWindow
*/
- explicit DALI_INTERNAL GlWindow( Internal::Adaptor::GlWindow* GlWindow );
+ explicit DALI_INTERNAL GlWindow(Internal::Adaptor::GlWindow* GlWindow);
/// @endcond
};
/*
- * 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 dimension;
}
-ImageDimensions GetOriginalImageSize(const std::string& filename)
+ImageDimensions GetOriginalImageSize(const std::string& filename, bool orientationCorrection)
{
- return TizenPlatform::ImageLoader::GetClosestImageSize(filename, ImageDimensions(0, 0), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true);
+ return TizenPlatform::ImageLoader::GetClosestImageSize(filename, ImageDimensions(0, 0), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, orientationCorrection);
}
Devel::PixelBuffer DownloadImageSynchronously(const std::string& url, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection)
#define DALI_IMAGE_LOADING_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.
bool orientationCorrection = true);
/**
- * @brief Get the size of an original image
+ * @brief Get the size of an original image. this method will respect any rotation of image.
* @param[in] filename name of the image.
+ * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
*
* @return dimensions to original image
*/
DALI_ADAPTOR_API ImageDimensions GetOriginalImageSize(
- const std::string& filename);
+ const std::string& filename, bool orientationCorrection = true);
/**
* @brief Load an image synchronously from a remote resource.
#define DALI_VECTOR_ANIMATION_RENDERER_PLUGIN_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.
}
/**
- * @brief Second-phase constructor.
- *
- * @param[in] url The url of the animation file
+ * @brief Finalizes the renderer. It will be called in the main thread.
*/
- virtual bool Initialize(const std::string& url) = 0;
+ virtual void Finalize() = 0;
/**
- * @brief Finalizes the renderer. It will be called in the main thread.
+ * @brief Loads the animation file.
+ *
+ * @param[in] url The url of the vector animation file
+ * @return True if loading success, false otherwise.
*/
- virtual void Finalize() = 0;
+ virtual bool Load(const std::string& url) = 0;
/**
* @brief Sets the renderer used to display the result image.
/*
- * 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
{
-VectorAnimationRenderer VectorAnimationRenderer::New(const std::string& url)
+VectorAnimationRenderer VectorAnimationRenderer::New()
{
Internal::Adaptor::VectorAnimationRendererPtr animationRenderer = Internal::Adaptor::VectorAnimationRenderer::New();
- if(animationRenderer)
- {
- animationRenderer->Initialize(url);
- }
-
return VectorAnimationRenderer(animationRenderer.Get());
}
GetImplementation(*this).Finalize();
}
+bool VectorAnimationRenderer::Load(const std::string& url)
+{
+ return GetImplementation(*this).Load(url);
+}
+
void VectorAnimationRenderer::SetRenderer(Renderer renderer)
{
GetImplementation(*this).SetRenderer(renderer);
#define DALI_VECTOR_ANIMATION_RENDERER_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.
/**
* @brief Creates an initialized handle to a new VectorAnimationRenderer.
*
- * @param[in] url The url of the vector animation file
* @return A handle to a newly allocated VectorAnimationRenderer
*/
- static VectorAnimationRenderer New(const std::string& url);
+ static VectorAnimationRenderer New();
/**
* @brief Creates an empty handle.
void Finalize();
/**
+ * @brief Loads the animation file.
+ *
+ * @param[in] url The url of the vector animation file
+ * @return True if loading success, false otherwise.
+ */
+ bool Load(const std::string& url);
+
+ /**
* @brief Sets the renderer used to display the result image.
*
* @param[in] renderer The renderer used to display the result image
#define DALI_VECTOR_IMAGE_RENDERER_PLUGIN_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
{
-
/**
* VectorImageRendererPlugin is an abstract interface, used by dali-adaptor to render a vector image(SVG).
* A concrete implementation must be created for each platform and provided as a dynamic library which
/**
* @brief Constructor
*/
- VectorImageRendererPlugin() {}
+ VectorImageRendererPlugin()
+ {
+ }
/**
* @brief Destructor
*/
- virtual ~VectorImageRendererPlugin() {}
+ virtual ~VectorImageRendererPlugin()
+ {
+ }
/**
* @brief Load vector image data directly.
* @param[in] buffer The target buffer
* @return True if the rendering succeeds, false otherwise.
*/
- virtual bool Rasterize(Dali::Devel::PixelBuffer &buffer) = 0;
+ virtual bool Rasterize(Dali::Devel::PixelBuffer& buffer) = 0;
/**
* @brief Gets the default size of the file.
* @param[out] width The default width of the file
* @param[out] height The default height of the file
*/
- virtual void GetDefaultSize( uint32_t& width, uint32_t& height ) const = 0;
+ virtual void GetDefaultSize(uint32_t& width, uint32_t& height) const = 0;
/**
* @brief Function pointer called in adaptor to create a plugin instance.
/*
- * 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
#define DALI_VECTOR_IMAGE_RENDERER_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.
#include <dali/public-api/object/base-handle.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
* @{
*/
-namespace Internal DALI_INTERNAL
-{
-namespace Adaptor
+namespace Internal::Adaptor
{
class VectorImageRenderer;
-}
-}
+} // namespace Internal::Adaptor
/**
* @brief Used for rendering a vector image file (SVG)
class DALI_ADAPTOR_API VectorImageRenderer : public BaseHandle
{
public:
-
/**
* @brief Creates an initialized handle to a new VectorImageRenderer.
*
*
* @param[in] handle A reference to the copied handle
*/
- VectorImageRenderer( const VectorImageRenderer& handle ) = default;
+ VectorImageRenderer(const VectorImageRenderer& handle) = default;
/**
* @brief This assignment operator is required for (smart) pointer semantics.
* @param[in] rhs A reference to the copied handle
* @return A reference to this
*/
- VectorImageRenderer& operator=( const VectorImageRenderer& rhs ) = default;
+ VectorImageRenderer& operator=(const VectorImageRenderer& rhs) = default;
/**
* @brief Load vector image data directly.
void GetDefaultSize(uint32_t& width, uint32_t& height) const;
public: // Not intended for application developers
-
/// @cond internal
/**
* @brief The constructor.
*
* @param[in] pointer A pointer to a newly allocated VectorImageRenderer
*/
- explicit DALI_INTERNAL VectorImageRenderer( Internal::Adaptor::VectorImageRenderer* internal );
+ explicit DALI_INTERNAL VectorImageRenderer(Internal::Adaptor::VectorImageRenderer* internal);
/// @endcond
-
};
/**
--- /dev/null
+#ifndef DALI_WEB_ENGINE_BACK_FORWARD_LIST_ITEM_H
+#define DALI_WEB_ENGINE_BACK_FORWARD_LIST_ITEM_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+/**
+ * @brief A class WebBackForwardListItem for back forward list item of web engine.
+ */
+class WebEngineBackForwardListItem
+{
+public:
+ /**
+ * @brief Constructor.
+ */
+ WebEngineBackForwardListItem() = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebEngineBackForwardListItem() = default;
+
+ /**
+ * @brief Returns the URL of the item.
+ * @details The returned URL may differ from the original URL (For example,
+ * if the page is redirected).
+ * @return The URL of the item, otherwise "" in case of an error
+ */
+ virtual std::string GetUrl() const = 0;
+
+ /**
+ * @brief Returns the title of the item.
+ * @return The title of the item, otherwise "" in case of an error
+ */
+ virtual std::string GetTitle() const = 0;
+
+ /**
+ * @brief Returns the original URL of the item.
+ * @return The original URL of the item, otherwise "" in case of an error
+ */
+ virtual std::string GetOriginalUrl() const = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_BACK_FORWARD_LIST_ITEM_H
--- /dev/null
+#ifndef DALI_WEB_ENGINE_BACK_FORWARD_LIST_H
+#define DALI_WEB_ENGINE_BACK_FORWARD_LIST_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <string>
+
+namespace Dali
+{
+class WebEngineBackForwardListItem;
+
+/**
+ * @brief A class WebBackForwardList for back forward list of web engine.
+ */
+class WebEngineBackForwardList
+{
+public:
+ /**
+ * @brief Constructor.
+ */
+ WebEngineBackForwardList() = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebEngineBackForwardList() = default;
+
+ /**
+ * @brief Returns the current item in the @a list.
+ * @return The item of back-forward list.
+ */
+ virtual WebEngineBackForwardListItem& GetCurrentItem() const = 0;
+
+ /**
+ * @brief Returns the item at a given @a index relative to the current item.
+ * @param[in] index The index of the item
+ * @return The item of back-forward list.
+ */
+ virtual WebEngineBackForwardListItem& GetItemAtIndex(uint32_t index) const = 0;
+
+ /**
+ * @brief Returns the length of the back-forward list including the current
+ * item.
+ * @return The length of the back-forward list including the current item,
+ * otherwise @c 0 in case of an error
+ */
+ virtual uint32_t GetItemCount() const = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_BACK_FORWARD_LIST_H
--- /dev/null
+#ifndef DALI_WEB_ENGINE_CONTEXT_H
+#define DALI_WEB_ENGINE_CONTEXT_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+/**
+ * @brief A class WebEngineContext for context of web engine.
+ */
+class WebEngineContext
+{
+public:
+ /**
+ * @brief Enumeration for cache model options.
+ */
+ enum class CacheModel
+ {
+ DOCUMENT_VIEWER, ///< Use the smallest cache capacity.
+ DOCUMENT_BROWSER, ///< Use the bigger cache capacity than DocumentBrowser.
+ PRIMARY_WEB_BROWSER, ///< Use the biggest cache capacity.
+ };
+
+ /**
+ * @brief Constructor.
+ */
+ WebEngineContext() = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebEngineContext() = default;
+
+ /**
+ * @brief Returns the cache model type.
+ * @return #CacheModel
+ */
+ virtual CacheModel GetCacheModel() const = 0;
+
+ /**
+ * @brief Requests to set the cache model.
+ * @param[in] cacheModel The cache model
+ */
+ virtual void SetCacheModel(CacheModel cacheModel) = 0;
+
+ /**
+ * @brief Sets the given proxy URI to network backend of specific context.
+ * @param[in] uri The proxy URI to set
+ */
+ virtual void SetProxyUri(const std::string& uri) = 0;
+
+ /**
+ * @brief Sets a proxy auth credential to network backend of specific context.
+ * @details Normally, proxy auth credential should be got from the callback
+ * set by ewk_view_authentication_callback_set, once the username in
+ * this API has been set with a non-null value, the authentication
+ * callback will never been invoked. Try to avoid using this API.
+ * @param[in] username username to set
+ * @param[in] password password to set
+ */
+ virtual void SetDefaultProxyAuth(const std::string& username, const std::string& password) = 0;
+
+ /**
+ * Adds CA certificates to persistent NSS certificate database
+ * Function accepts a path to a CA certificate file, a path to a directory
+ * containing CA certificate files, or a colon-seprarated list of those.
+ * Certificate files should have *.crt extension.
+ * Directories are traversed recursively.
+ * @param[in] certificatePath path to a CA certificate file(s), see above for details
+ */
+ virtual void SetCertificateFilePath(const std::string& certificatePath) = 0;
+
+ /**
+ * Requests for deleting all web databases.
+ */
+ virtual void DeleteWebDatabase() = 0;
+
+ /**
+ * @brief Deletes web storage.
+ * @details This function does not ensure that all data will be removed.
+ * Should be used to extend free physical memory.
+ */
+ virtual void DeleteWebStorage() = 0;
+
+ /**
+ * @brief Requests for deleting all local file systems.
+ */
+ virtual void DeleteLocalFileSystem() = 0;
+
+ /**
+ * Toggles the cache to be enabled or disabled
+ * Function works asynchronously.
+ * By default the cache is disabled resulting in not storing network data on disk.
+ * @param[in] cacheDisabled enable or disable cache
+ */
+ virtual void DisableCache(bool cacheDisabled) = 0;
+
+ /**
+ * @brief Requests to clear cache
+ */
+ virtual void ClearCache() = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_CONTEXT_H
--- /dev/null
+#ifndef DALI_WEB_ENGINE_COOKIE_MANAGER_H
+#define DALI_WEB_ENGINE_COOKIE_MANAGER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+
+namespace Dali
+{
+/**
+ * @brief A class WebEngineCookieManager to wrap ewk cookie manager.
+ */
+class WebEngineCookieManager
+{
+public:
+ /**
+ * @brief Enumeration for the cookies accept policies.
+ */
+ enum class CookieAcceptPolicy
+ {
+ ALWAYS, ///< Accepts every cookie sent from any page.
+ NEVER, ///< Rejects all the cookies.
+ NO_THIRD_PARTY, ///< Accepts only cookies set by the main document that is loaded.
+ };
+
+ /**
+ * @brief Enumeration for the cookie persistent storage type.
+ */
+ enum class CookiePersistentStorage
+ {
+ TEXT, ///< Cookies are stored in a text file in the Mozilla "cookies.txt" format.
+ SQLITE, ///< Cookies are stored in a SQLite file in the current Mozilla format.
+ };
+
+ /**
+ * @brief Constructor.
+ */
+ WebEngineCookieManager() = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebEngineCookieManager() = default;
+
+ /**
+ * @brief Sets @a policy as the cookie acceptance policy for @a manager.
+ * @details By default, only cookies set by the main document loaded are
+ * accepted.
+ *
+ * @param[in] policy A #Dali::WebEngineCookieManager::CookieAcceptPolicy
+ */
+ virtual void SetCookieAcceptPolicy(CookieAcceptPolicy policy) = 0;
+
+ /**
+ * @brief Gets the cookie acceptance policy.
+ * The default is Toolkit::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY.
+ * @see Toolkit::WebEngineCookieManager::CookieAcceptPolicy::Type
+ */
+ virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0;
+
+ /**
+ * @brief Deletes all the cookies of @a manager.
+ */
+ virtual void ClearCookies() = 0;
+
+ /**
+ * @brief Sets the @a path where non-session cookies are stored persistently using
+ * @a storage as the format to read/write the cookies.
+ * @details Cookies are initially read from @a path/Cookies to create an initial
+ * set of cookies. Then, non-session cookies will be written to @a path/Cookies.
+ * By default, @a manager doesn't store the cookies persistently, so you need to
+ * call this method to keep cookies saved across sessions.
+ * If @a path does not exist it will be created.
+ * @param[in] path The path where to read/write Cookies
+ * @param[in] storage The type of storage
+ */
+ virtual void SetPersistentStorage(const std::string& path, CookiePersistentStorage storage) = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_COOKIE_MANAGER_H
#define DALI_WEB_ENGINE_PLUGIN_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.
// EXTERNAL INCLUDES
#include <dali/public-api/images/native-image-interface.h>
+#include <dali/public-api/math/rect.h>
#include <dali/public-api/signals/dali-signal.h>
#include <functional>
namespace Dali
{
class KeyEvent;
+class PixelData;
class TouchEvent;
+class WebEngineBackForwardList;
+class WebEngineContext;
+class WebEngineCookieManager;
+class WebEngineSettings;
/**
* @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
/**
* @brief WebEngine signal type related with page loading.
*/
- typedef Signal<void(const std::string&)> WebEnginePageLoadSignalType;
+ using WebEnginePageLoadSignalType = Signal<void(const std::string&)>;
/**
* @brief WebView signal type related with page loading error.
*/
- typedef Signal<void(const std::string&, int)> WebEnginePageLoadErrorSignalType;
+ using WebEnginePageLoadErrorSignalType = Signal<void(const std::string&, int)>;
+
+ // forward declaration.
+ enum class ScrollEdge;
/**
- * @brief Enumeration for cache model options.
+ * @brief WebView signal type related with scroll edge reached.
*/
- enum class CacheModel
- {
- /**
- * @brief Use the smallest cache capacity.
- */
- DOCUMENT_VIEWER,
-
- /**
- * @brief Use the bigger cache capacity than DocumentBrowser.
- */
- DOCUMENT_BROWSER,
-
- /**
- * @brief Use the biggest cache capacity.
- */
- PRIMARY_WEB_BROWSER
- };
+ using WebEngineScrollEdgeReachedSignalType = Signal<void(const ScrollEdge)>;
+
+ /**
+ * @brief WebView signal type related with page url changed.
+ */
+ using WebEngineUrlChangedSignalType = Signal<void(const std::string&)>;
+
+ /**
+ * @brief Alert callback when JavaScript alert is called with a message.
+ * It returns true if a pop-up is created successfully, false otherwise.
+ */
+ using JavaScriptAlertCallback = std::function<bool(const std::string&)>;
+
+ /**
+ * @brief Confirm callback when JavaScript confirm is called with a message.
+ * It returns true if a pop-up is created successfully, false otherwise.
+ */
+ using JavaScriptConfirmCallback = std::function<bool(const std::string&)>;
+
+ /**
+ * @brief Prompt callback when JavaScript prompt is called with a message
+ * and an optional value that is the default value for the input field.
+ * It returns true if a pop-up is created successfully, false otherwise.
+ */
+ using JavaScriptPromptCallback = std::function<bool(const std::string&, const std::string&)>;
/**
- * @brief Enumeration for the cookies accept policies.
+ * @brief Enumeration for the scroll edge.
*/
- enum class CookieAcceptPolicy
+ enum class ScrollEdge
{
- /**
- * @brief Accepts every cookie sent from any page.
- */
- ALWAYS,
-
- /**
- * @brief Rejects all the cookies.
- */
- NEVER,
-
- /**
- * @brief Accepts only cookies set by the main document that is loaded.
- */
- NO_THIRD_PARTY
+ LEFT, ///< Left edge reached.
+ RIGHT, ///< Right edge reached.
+ TOP, ///< Top edge reached.
+ BOTTOM, ///< Bottom edge reached.
};
/**
* @brief Constructor.
*/
- WebEnginePlugin()
- {
- }
+ WebEnginePlugin() = default;
/**
* @brief Destructor.
*/
- virtual ~WebEnginePlugin()
- {
- }
+ virtual ~WebEnginePlugin() = default;
/**
* @brief Creates WebEngine instance.
virtual void Create(int width, int height, const std::string& locale, const std::string& timezoneId) = 0;
/**
+ * @brief Creates WebEngine instance.
+ *
+ * @param [in] width The width of Web
+ * @param [in] height The height of Web
+ * @param [in] argc The count of application arguments
+ * @param [in] argv The string array of application arguments
+ */
+ virtual void Create(int width, int height, int argc, char** argv) = 0;
+
+ /**
* @brief Destroys WebEngine instance.
*/
virtual void Destroy() = 0;
/**
+ * @brief Get settings of WebEngine.
+ */
+ virtual WebEngineSettings& GetSettings() const = 0;
+
+ /**
+ * @brief Get context of WebEngine.
+ */
+ virtual WebEngineContext& GetContext() const = 0;
+
+ /**
+ * @brief Get cookie manager of WebEngine.
+ */
+ virtual WebEngineCookieManager& GetCookieManager() const = 0;
+
+ /**
+ * @brief Get back-forward list of WebEngine.
+ */
+ virtual WebEngineBackForwardList& GetBackForwardList() const = 0;
+
+ /**
* @brief Loads a web page based on a given URL.
*
* @param [in] url The URL of the resource to load
virtual void LoadUrl(const std::string& url) = 0;
/**
+ * @brief Returns the title of the Web.
+ *
+ * @return The title of web page
+ */
+ virtual std::string GetTitle() const = 0;
+
+ /**
+ * @brief Returns the Favicon of the Web.
+ *
+ * @return Favicon of Dali::PixelData& type
+ */
+ virtual Dali::PixelData GetFavicon() const = 0;
+
+ /**
* @brief Gets image to render.
*/
virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
*
* @param [in] htmlString The string to use as the contents of the web page
*/
- virtual void LoadHTMLString(const std::string& htmlString) = 0;
+ virtual void LoadHtmlString(const std::string& htmlString) = 0;
/**
* @brief Reloads the Web.
virtual void Resume() = 0;
/**
+ * @brief Scrolls the webpage of view by deltaX and deltaY.
+ */
+ virtual void ScrollBy(int deltaX, int deltaY) = 0;
+
+ /**
+ * @brief Scroll to the specified position of the given view.
+ */
+ virtual void SetScrollPosition(int x, int y) = 0;
+
+ /**
+ * @brief Gets the current scroll position of the given view.
+ */
+ virtual Dali::Vector2 GetScrollPosition() const = 0;
+
+ /**
+ * @brief Gets the possible scroll size of the given view.
+ */
+ virtual Dali::Vector2 GetScrollSize() const = 0;
+
+ /**
+ * @brief Gets the last known content's size.
+ */
+ virtual Dali::Vector2 GetContentSize() const = 0;
+
+ /**
* @brief Returns whether forward is possible.
*
* @return True if forward is possible, false otherwise
virtual void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler) = 0;
/**
- * @brief Clears the history of Web.
+ * @brief Register a callback for JavaScript alert.
+ *
+ * @param[in] callback The callback function
*/
- virtual void ClearHistory() = 0;
+ virtual void RegisterJavaScriptAlertCallback(JavaScriptAlertCallback callback) = 0;
/**
- * @brief Clears the cache of Web.
+ * @brief Reply for JavaScript alert.
*/
- virtual void ClearCache() = 0;
+ virtual void JavaScriptAlertReply() = 0;
/**
- * @brief Clears all the cookies of Web.
+ * @brief Register a callback for JavaScript confirm.
+ *
+ * @param[in] callback The callback function
*/
- virtual void ClearCookies() = 0;
+ virtual void RegisterJavaScriptConfirmCallback(JavaScriptConfirmCallback callback) = 0;
/**
- * @brief Get cache model option. The default is DOCUMENT_VIEWER.
- *
- * @return The cache model option
+ * @brief Reply for JavaScript confirm.
*/
- virtual CacheModel GetCacheModel() const = 0;
+ virtual void JavaScriptConfirmReply( bool confirmed ) = 0;
/**
- * @brief Set cache model option. The default is DOCUMENT_VIEWER.
+ * @brief Register a callback for JavaScript prompt.
*
- * @param[in] cacheModel The cache model option
+ * @param[in] callback The callback function
*/
- virtual void SetCacheModel(CacheModel cacheModel) = 0;
+ virtual void RegisterJavaScriptPromptCallback( JavaScriptPromptCallback callback ) = 0;
/**
- * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
- *
- * @return The cookie acceptance policy
+ * @brief Reply for JavaScript prompt.
*/
- virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0;
+ virtual void JavaScriptPromptReply( const std::string& result ) = 0;
/**
- * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY.
- *
- * @param[in] policy The cookie acceptance policy
+ * @brief Clears the history of Web.
+ */
+ virtual void ClearHistory() = 0;
+
+ /**
+ * @brief Clears all tiles resources of Web.
*/
- virtual void SetCookieAcceptPolicy(CookieAcceptPolicy policy) = 0;
+ virtual void ClearAllTilesResources() = 0;
/**
* @brief Get user agent string.
virtual void SetUserAgent(const std::string& userAgent) = 0;
/**
- * @brief Returns whether JavaScript can be executable. The default is true.
- *
- * @return true if JavaScript executing is enabled, false otherwise
+ * @brief Sets size of Web Page.
*/
- virtual bool IsJavaScriptEnabled() const = 0;
+ virtual void SetSize(int width, int height) = 0;
/**
- * @brief Enables/disables JavaScript executing. The default is enabled.
- *
- * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+ * @brief Sends Touch Events.
*/
- virtual void EnableJavaScript(bool enabled) = 0;
+ virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
/**
- * @brief Returns whether images can be loaded automatically. The default is true.
- *
- * @return true if images are loaded automatically, false otherwise
+ * @brief Sends Key Events.
*/
- virtual bool AreImagesAutomaticallyLoaded() const = 0;
+ virtual bool SendKeyEvent(const KeyEvent& event) = 0;
/**
- * @brief Enables/disables auto loading of images. The default is enabled.
- *
- * @param[in] automatic True if images are loaded automatically, false otherwise
+ * @brief Sets focus.
*/
- virtual void LoadImagesAutomatically(bool automatic) = 0;
+ virtual void SetFocus(bool focused) = 0;
/**
- * @brief Gets the default text encoding name (e.g. UTF-8).
- *
- * @return The default text encoding name
+ * @brief Update display area.
+ * @param[in] displayArea The display area need be updated.
*/
- virtual const std::string& GetDefaultTextEncodingName() const = 0;
+ virtual void UpdateDisplayArea(Dali::Rect<int> displayArea) = 0;
/**
- * @brief Sets the default text encoding name (e.g. UTF-8).
- *
- * @param[in] defaultTextEncodingName The default text encoding name
+ * @brief Enable video hole.
+ * @param[in] enabled True if enabled, false othewise.
*/
- virtual void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName) = 0;
+ virtual void EnableVideoHole(bool enabled) = 0;
/**
- * @brief Returns the default font size in pixel. The default value is 16.
+ * @brief Connects to this signal to be notified when page loading is started.
*
- * @return The default font size
+ * @return A signal object to connect with.
*/
- virtual int GetDefaultFontSize() const = 0;
+ virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
/**
- * @brief Sets the default font size in pixel. The default value is 16.
+ * @brief Connects to this signal to be notified when page loading is in progress.
*
- * @param[in] defaultFontSize A new default font size to set
- */
- virtual void SetDefaultFontSize(int defaultFontSize) = 0;
-
- /**
- * @brief Sets size of Web Page.
- */
- virtual void SetSize(int width, int height) = 0;
-
- /**
- * @brief Sends Touch Events.
+ * @return A signal object to connect with.
*/
- virtual bool SendTouchEvent(const TouchEvent& touch) = 0;
+ virtual WebEnginePageLoadSignalType& PageLoadInProgressSignal() = 0;
/**
- * @brief Sends Key Events.
+ * @brief Connects to this signal to be notified when page loading is finished.
+ *
+ * @return A signal object to connect with.
*/
- virtual bool SendKeyEvent(const KeyEvent& event) = 0;
+ virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
/**
- * @brief Connects to this signal to be notified when page loading is started.
+ * @brief Connects to this signal to be notified when an error occurs in page loading.
*
* @return A signal object to connect with.
*/
- virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
+ virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
/**
- * @brief Connects to this signal to be notified when page loading is finished.
+ * @brief Connects to this signal to be notified when scroll edge is reached.
*
* @return A signal object to connect with.
*/
- virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
+ virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0;
/**
- * @brief Connects to this signal to be notified when an error occurs in page loading.
+ * @brief Connects to this signal to be notified when url is changed.
*
* @return A signal object to connect with.
*/
- virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
+ virtual WebEngineUrlChangedSignalType& UrlChangedSignal() = 0;
+
};
} // namespace Dali
--- /dev/null
+#ifndef DALI_WEB_ENGINE_SETTINGS_H
+#define DALI_WEB_ENGINE_SETTINGS_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+namespace Dali
+{
+/**
+ * @brief A class WebEngineSettings for settings of web engine.
+ */
+class WebEngineSettings
+{
+public:
+ /**
+ * @brief Constructor.
+ */
+ WebEngineSettings() = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebEngineSettings() = default;
+
+ /**
+ *@brief Allow running mixed contents or not.
+ *
+ * @param[in] allowed if true, allow to run mixed contents,
+ * otherwise not allow
+ */
+ virtual void AllowMixedContents(bool allowed) = 0;
+
+ /**
+ * @brief Enable the spatial navigation or not.
+ *
+ * @param[in] enabled if true, use spatial navigation,
+ * otherwise to disable
+ */
+ virtual void EnableSpatialNavigation(bool enabled) = 0;
+
+ /**
+ * @brief Get the default font size.
+ *
+ * @return defaut font size.
+ */
+ virtual uint32_t GetDefaultFontSize() const = 0;
+
+ /**
+ * @brief Set the default font size.
+ *
+ * @param[in] size a new default font size to set
+ */
+ virtual void SetDefaultFontSize(uint32_t size) = 0;
+
+ /**
+ * @brief Enables/disables web security.
+ *
+ * @param[in] enabled if true, to enable the web security
+ * otherwise to disable
+ */
+ virtual void EnableWebSecurity(bool enabled) = 0;
+
+ /**
+ * @brief Allow/Disallow file access from external url
+ *
+ * @param[in] allowed if true, to allow file access from external url
+ * otherwise to disallow
+ */
+ virtual void AllowFileAccessFromExternalUrl(bool allowed) = 0;
+
+ /**
+ * @brief Check if javascript is enabled or not.
+ *
+ * @return true if enabled, false if disabled.
+ */
+ virtual bool IsJavaScriptEnabled() const = 0;
+
+ /**
+ * @brief Enable/Disable javascript
+ *
+ * @param[in] enabled if true, to enable javascript
+ * otherwise to disable
+ */
+ virtual void EnableJavaScript(bool enabled) = 0;
+
+ /**
+ * @brief Allow if the scripts can open new windows.
+ *
+ * @param[in] allowed if true, the scripts can open new windows,
+ * otherwise not
+ */
+ virtual void AllowScriptsOpenWindows(bool allowed) = 0;
+
+ /**
+ * @brief Check if images are loaded automatically or not.
+ *
+ * @return true if enabled, false if disabled.
+ */
+ virtual bool AreImagesLoadedAutomatically() const = 0;
+
+ /**
+ * @brief Allow to load images automatically
+ *
+ * @param[in] automatic if true, to load images automatically,
+ * otherwise not
+ */
+ virtual void AllowImagesLoadAutomatically(bool automatic) = 0;
+
+ /**
+ * @brief Get the default encoding name.
+ *
+ * @return defaut encoding name.
+ */
+ virtual std::string GetDefaultTextEncodingName() const = 0;
+
+ /**
+ * @brief Set the default encoding name.
+ *
+ * @param[in] defaultTextEncodingName a default encoding name to set
+ */
+ virtual void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName) = 0;
+};
+
+} // namespace Dali
+
+#endif // DALI_WEB_ENGINE_SETTINGS_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.
#include <dali/devel-api/adaptor-framework/web-engine.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/internal/web-engine/common/web-engine-impl.h>
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/pixel-data.h>
+
namespace Dali
{
WebEngine::WebEngine()
GetImplementation(*this).Create(width, height, locale, timezoneId);
}
+void WebEngine::Create(int width, int height, int argc, char** argv)
+{
+ GetImplementation(*this).Create(width, height, argc, argv);
+}
+
void WebEngine::Destroy()
{
GetImplementation(*this).Destroy();
return GetImplementation(*this).GetNativeImageSource();
}
+Dali::WebEngineSettings& WebEngine::GetSettings() const
+{
+ return GetImplementation(*this).GetSettings();
+}
+
+Dali::WebEngineContext& WebEngine::GetContext() const
+{
+ return GetImplementation(*this).GetContext();
+}
+
+Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
+{
+ return GetImplementation(*this).GetCookieManager();
+}
+
+Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
+{
+ return GetImplementation(*this).GetBackForwardList();
+}
+
void WebEngine::LoadUrl(const std::string& url)
{
return GetImplementation(*this).LoadUrl(url);
}
+std::string WebEngine::GetTitle() const
+{
+ return GetImplementation(*this).GetTitle();
+}
+
+Dali::PixelData WebEngine::GetFavicon() const
+{
+ return GetImplementation(*this).GetFavicon();
+}
+
const std::string& WebEngine::GetUrl()
{
return GetImplementation(*this).GetUrl();
}
-void WebEngine::LoadHTMLString(const std::string& htmlString)
+void WebEngine::LoadHtmlString(const std::string& htmlString)
{
- GetImplementation(*this).LoadHTMLString(htmlString);
+ GetImplementation(*this).LoadHtmlString(htmlString);
}
void WebEngine::Reload()
GetImplementation(*this).Resume();
}
+void WebEngine::ScrollBy(int deltaX, int deltaY)
+{
+ GetImplementation(*this).ScrollBy(deltaX, deltaY);
+}
+
+void WebEngine::SetScrollPosition(int x, int y)
+{
+ GetImplementation(*this).SetScrollPosition(x, y);
+}
+
+Dali::Vector2 WebEngine::GetScrollPosition() const
+{
+ return GetImplementation(*this).GetScrollPosition();
+}
+
+Dali::Vector2 WebEngine::GetScrollSize() const
+{
+ return GetImplementation(*this).GetScrollSize();
+}
+
+Dali::Vector2 WebEngine::GetContentSize() const
+{
+ return GetImplementation(*this).GetContentSize();
+}
+
bool WebEngine::CanGoForward()
{
return GetImplementation(*this).CanGoForward();
GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
}
-void WebEngine::ClearHistory()
+void WebEngine::RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback )
{
- return GetImplementation(*this).ClearHistory();
+ GetImplementation( *this ).RegisterJavaScriptAlertCallback( callback );
+}
+
+void WebEngine::JavaScriptAlertReply()
+{
+ GetImplementation( *this ).JavaScriptAlertReply();
}
-void WebEngine::ClearCache()
+void WebEngine::RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback )
{
- return GetImplementation(*this).ClearCache();
+ GetImplementation( *this ).RegisterJavaScriptConfirmCallback( callback );
}
-void WebEngine::ClearCookies()
+void WebEngine::JavaScriptConfirmReply( bool confirmed )
{
- return GetImplementation(*this).ClearCookies();
+ GetImplementation( *this ).JavaScriptConfirmReply( confirmed );
}
-Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const
+void WebEngine::RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback )
{
- return GetImplementation(*this).GetCacheModel();
+ GetImplementation( *this ).RegisterJavaScriptPromptCallback( callback );
}
-void WebEngine::SetCacheModel(Dali::WebEnginePlugin::CacheModel cacheModel)
+void WebEngine::JavaScriptPromptReply( const std::string& result )
{
- GetImplementation(*this).SetCacheModel(cacheModel);
+ GetImplementation( *this ).JavaScriptPromptReply( result );
}
-Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const
+void WebEngine::ClearHistory()
{
- return GetImplementation(*this).GetCookieAcceptPolicy();
+ return GetImplementation(*this).ClearHistory();
}
-void WebEngine::SetCookieAcceptPolicy(Dali::WebEnginePlugin::CookieAcceptPolicy policy)
+void WebEngine::ClearAllTilesResources()
{
- GetImplementation(*this).SetCookieAcceptPolicy(policy);
+ GetImplementation( *this ).ClearAllTilesResources();
}
const std::string& WebEngine::GetUserAgent() const
GetImplementation(*this).SetUserAgent(userAgent);
}
-bool WebEngine::IsJavaScriptEnabled() const
-{
- return GetImplementation(*this).IsJavaScriptEnabled();
-}
-
-void WebEngine::EnableJavaScript(bool enabled)
-{
- GetImplementation(*this).EnableJavaScript(enabled);
-}
-
-bool WebEngine::AreImagesAutomaticallyLoaded() const
+void WebEngine::SetSize(int width, int height)
{
- return GetImplementation(*this).AreImagesAutomaticallyLoaded();
+ return GetImplementation(*this).SetSize(width, height);
}
-void WebEngine::LoadImagesAutomatically(bool automatic)
+bool WebEngine::SendTouchEvent(const TouchEvent& touch)
{
- GetImplementation(*this).LoadImagesAutomatically(automatic);
+ return GetImplementation(*this).SendTouchEvent(touch);
}
-const std::string& WebEngine::GetDefaultTextEncodingName() const
+bool WebEngine::SendKeyEvent(const KeyEvent& event)
{
- return GetImplementation(*this).GetDefaultTextEncodingName();
+ return GetImplementation(*this).SendKeyEvent(event);
}
-void WebEngine::SetDefaultTextEncodingName(const std::string& defaultTextEncodingName)
+void WebEngine::SetFocus(bool focused)
{
- GetImplementation(*this).SetDefaultTextEncodingName(defaultTextEncodingName);
+ GetImplementation(*this).SetFocus(focused);
}
-int WebEngine::GetDefaultFontSize() const
+void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
{
- return GetImplementation(*this).GetDefaultFontSize();
+ GetImplementation(*this).UpdateDisplayArea(displayArea);
}
-void WebEngine::SetDefaultFontSize(int defaultFontSize)
+void WebEngine::EnableVideoHole(bool enabled)
{
- GetImplementation(*this).SetDefaultFontSize(defaultFontSize);
+ GetImplementation(*this).EnableVideoHole(enabled);
}
-void WebEngine::SetSize(int width, int height)
+Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
{
- return GetImplementation(*this).SetSize(width, height);
+ return GetImplementation(*this).PageLoadStartedSignal();
}
-bool WebEngine::SendTouchEvent(const TouchEvent& touch)
+Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
{
- return GetImplementation(*this).SendTouchEvent(touch);
+ return GetImplementation(*this).PageLoadInProgressSignal();
}
-bool WebEngine::SendKeyEvent(const KeyEvent& event)
+Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
{
- return GetImplementation(*this).SendKeyEvent(event);
+ return GetImplementation(*this).PageLoadFinishedSignal();
}
-Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
+Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
{
- return GetImplementation(*this).PageLoadStartedSignal();
+ return GetImplementation(*this).PageLoadErrorSignal();
}
-Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
{
- return GetImplementation(*this).PageLoadFinishedSignal();
+ return GetImplementation(*this).ScrollEdgeReachedSignal();
}
-Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
+Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
{
- return GetImplementation(*this).PageLoadErrorSignal();
+ return GetImplementation(*this).UrlChangedSignal();
}
} // namespace Dali
#define DALI_WEB_ENGINE_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void Create(int width, int height, const std::string& locale, const std::string& timezoneId);
/**
+ * @brief Creates WebEngine instance.
+ *
+ * @param [in] width The width of Web
+ * @param [in] height The height of Web
+ * @param [in] argc The count of application arguments
+ * @param [in] argv The string array of application arguments
+ */
+ void Create(int width, int height, int argc, char** argv);
+
+ /**
* @brief Destroys WebEngine instance.
*/
void Destroy();
NativeImageInterfacePtr GetNativeImageSource();
/**
+ * @brief Get settings of WebEngine.
+ */
+ Dali::WebEngineSettings& GetSettings() const;
+
+ /**
+ * @brief Get context of WebEngine.
+ */
+ Dali::WebEngineContext& GetContext() const;
+
+ /**
+ * @brief Get cookie manager of WebEngine.
+ */
+ Dali::WebEngineCookieManager& GetCookieManager() const;
+
+ /**
+ * @brief Get back-forward list of WebEngine.
+ */
+ Dali::WebEngineBackForwardList& GetBackForwardList() const;
+
+ /**
* @brief Loads a web page based on a given URL.
*
* @param [in] url The URL of the resource to load
void LoadUrl(const std::string& url);
/**
+ * @brief Returns the title of the Web.
+ *
+ * @return The title of web page
+ */
+ std::string GetTitle() const;
+
+ /**
+ * @brief Returns the Favicon of the Web.
+ *
+ * @return FavIcon of Dali::PixelData& type
+ */
+ Dali::PixelData GetFavicon() const;
+
+ /**
* @brief Gets the url.
*/
const std::string& GetUrl();
*
* @param [in] htmlString The string to use as the contents of the web page
*/
- void LoadHTMLString(const std::string& htmlString);
+ void LoadHtmlString(const std::string& htmlString);
/**
* @brief Reloads the Web.
void Resume();
/**
+ * @brief Scrolls the webpage of view by deltaX and deltaY.
+ */
+ void ScrollBy(int deltaX, int deltaY);
+
+ /**
+ * @brief Sets an absolute scroll of the given view.
+ */
+ void SetScrollPosition(int x, int y);
+
+ /**
+ * @brief Gets the current scroll position of the given view.
+ */
+ Dali::Vector2 GetScrollPosition() const;
+
+ /**
+ * @brief Gets the possible scroll size of the given view.
+ */
+ Dali::Vector2 GetScrollSize() const;
+
+ /**
+ * @brief Gets the last known content's size.
+ */
+ Dali::Vector2 GetContentSize() const;
+
+ /**
* @brief Returns whether forward is possible.
*
* @return True if forward is possible, false otherwise
void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
/**
- * @brief Clears the history of Web.
+ * @brief Register a callback for JavaScript alert.
+ *
+ * @param[in] callback The callback function
*/
- void ClearHistory();
+ void RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback);
/**
- * @brief Clears the cache of Web.
+ * @brief Reply for JavaScript alert.
*/
- void ClearCache();
+ void JavaScriptAlertReply();
/**
- * @brief Clears all the cookies of Web.
+ * @brief Register a callback for JavaScript confirm.
+ *
+ * @param[in] callback The callback function
*/
- void ClearCookies();
+ void RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback);
/**
- * @brief Get cache model option. The default is DOCUMENT_VIEWER.
- *
- * @return The cache model option
+ * @brief Reply for JavaScript confirm.
*/
- Dali::WebEnginePlugin::CacheModel GetCacheModel() const;
+ void JavaScriptConfirmReply( bool confirmed );
/**
- * @brief Set cache model option. The default is DOCUMENT_VIEWER.
+ * @brief Register a callback for JavaScript prompt.
*
- * @param[in] cacheModel The cache model option
+ * @param[in] callback The callback function
*/
- void SetCacheModel(Dali::WebEnginePlugin::CacheModel cacheModel);
+ void RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback );
/**
- * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
- *
- * @return The cookie acceptance policy
+ * @brief Reply for JavaScript prompt.
*/
- Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const;
+ void JavaScriptPromptReply( const std::string& result );
/**
- * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY.
- *
- * @param[in] policy The cookie acceptance policy
+ * @brief Clears the history of Web.
+ */
+ void ClearHistory();
+
+ /**
+ * @brief Clears all tiles resources of Web.
*/
- void SetCookieAcceptPolicy(Dali::WebEnginePlugin::CookieAcceptPolicy policy);
+ void ClearAllTilesResources();
/**
* @brief Get user agent string.
void SetUserAgent(const std::string& userAgent);
/**
- * @brief Returns whether JavaScript can be executable. The default is true.
- *
- * @return true if JavaScript executing is enabled, false otherwise
+ * @brief Sets the size of Web Pages.
*/
- bool IsJavaScriptEnabled() const;
+ void SetSize(int width, int height);
/**
- * @brief Enables/disables JavaScript executing. The default is enabled.
- *
- * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+ * @brief Sends Touch Events.
*/
- void EnableJavaScript(bool enabled);
+ bool SendTouchEvent(const TouchEvent& touch);
/**
- * @brief Returns whether JavaScript can be executable. The default is true.
- *
- * @return true if images are loaded automatically, false otherwise
+ * @brief Sends key Events.
*/
- bool AreImagesAutomaticallyLoaded() const;
+ bool SendKeyEvent(const KeyEvent& event);
/**
- * @brief Enables/disables auto loading of images. The default is enabled.
- *
- * @param[in] automatic True if images are loaded automatically, false otherwise
+ * @brief Set focus.
+ * @param[in] focused True if web view is focused, false otherwise
*/
- void LoadImagesAutomatically(bool automatic);
+ void SetFocus(bool focused);
/**
- * @brief Gets the default text encoding name.
- *
- * @return The default text encoding name
+ * @brief Update display area.
+ * @param[in] displayArea The area to display web page.
*/
- const std::string& GetDefaultTextEncodingName() const;
+ void UpdateDisplayArea(Dali::Rect<int> displayArea);
/**
- * @brief Sets the default text encoding name.
- *
- * @param[in] defaultTextEncodingName The default text encoding name
+ * @brief Enable video hole.
+ * @param[in] enabled True if video hole is enabled, false otherwise
*/
- void SetDefaultTextEncodingName(const std::string& defaultTextEncodingName);
+ void EnableVideoHole(bool enabled);
/**
- * @brief Returns the default font size in pixel. The default value is 16.
+ * @brief Connects to this signal to be notified when page loading is started.
*
- * @return The default font size
+ * @return A signal object to connect with.
*/
- int GetDefaultFontSize() const;
+ Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
/**
- * @brief Sets the default font size in pixel. The default value is 16.
+ * @brief Connects to this signal to be notified when page loading is in progress.
*
- * @param[in] defaultFontSize A new default font size to set
- */
- void SetDefaultFontSize(int defaultFontSize);
-
- /**
- * @brief Sets the size of Web Pages.
- */
- void SetSize(int width, int height);
-
- /**
- * @brief Sends Touch Events.
+ * @return A signal object to connect with.
*/
- bool SendTouchEvent(const TouchEvent& touch);
+ Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadInProgressSignal();
/**
- * @brief Sends key Events.
+ * @brief Connects to this signal to be notified when page loading is finished.
+ *
+ * @return A signal object to connect with.
*/
- bool SendKeyEvent(const KeyEvent& event);
+ Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal();
/**
- * @brief Connects to this signal to be notified when page loading is started.
+ * @brief Connects to this signal to be notified when an error occurs in page loading.
*
* @return A signal object to connect with.
*/
- Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
+ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal();
/**
- * @brief Connects to this signal to be notified when page loading is finished.
+ * @brief Connects to this signal to be notified when scroll edge is reached.
*
* @return A signal object to connect with.
*/
- Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal();
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
/**
- * @brief Connects to this signal to be notified when an error occurs in page loading.
+ * @brief Connects to this signal to be notified when url is changed.
*
* @return A signal object to connect with.
*/
- Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal();
+ Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& UrlChangedSignal();
private: // Not intended for application developers
/**
/*
- * 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>
#define DALI_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.
#include <memory>
// INTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/public-api/adaptor-framework/window.h>
#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
namespace Dali
{
namespace DevelWindow
{
-
typedef Signal<void()> EventProcessingFinishedSignalType; ///< Event Processing finished signal type
typedef Signal<void(const KeyEvent&)> KeyEventSignalType; ///< Key event signal type
${adaptor_devel_api_dir}/adaptor-framework/video-player.h
${adaptor_devel_api_dir}/adaptor-framework/video-player-plugin.h
${adaptor_devel_api_dir}/adaptor-framework/web-engine.h
+ ${adaptor_devel_api_dir}/adaptor-framework/web-engine-back-forward-list-item.h
+ ${adaptor_devel_api_dir}/adaptor-framework/web-engine-back-forward-list.h
+ ${adaptor_devel_api_dir}/adaptor-framework/web-engine-context.h
+ ${adaptor_devel_api_dir}/adaptor-framework/web-engine-cookie-manager.h
${adaptor_devel_api_dir}/adaptor-framework/web-engine-plugin.h
+ ${adaptor_devel_api_dir}/adaptor-framework/web-engine-settings.h
${adaptor_devel_api_dir}/adaptor-framework/key-extension-plugin.h
${adaptor_devel_api_dir}/adaptor-framework/virtual-keyboard.h
${adaptor_devel_api_dir}/adaptor-framework/physical-keyboard.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);
#define DALI_INTERNAL_ATSPI_ACCESSIBILITY_COMMON_H
/*
- * 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 <string>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
-#include <dali/internal/accessibility/bridge/dbus.h>
#include <dali/internal/accessibility/bridge/dbus-locators.h>
+#include <dali/internal/accessibility/bridge/dbus.h>
+#include <dali/public-api/dali-adaptor-common.h>
#define A11yDbusName "org.a11y.Bus"
#define A11yDbusPath "/org/a11y/bus"
namespace DBus
{
-
class CurrentBridgePtr
{
static Dali::Accessibility::Bridge*& get()
return b;
}
Dali::Accessibility::Bridge* prev;
- CurrentBridgePtr( const CurrentBridgePtr& ) = delete;
- CurrentBridgePtr( CurrentBridgePtr&& ) = delete;
- CurrentBridgePtr& operator=( const CurrentBridgePtr& ) = delete;
- CurrentBridgePtr& operator=( CurrentBridgePtr&& ) = delete;
+ CurrentBridgePtr(const CurrentBridgePtr&) = delete;
+ CurrentBridgePtr(CurrentBridgePtr&&) = delete;
+ CurrentBridgePtr& operator=(const CurrentBridgePtr&) = delete;
+ CurrentBridgePtr& operator=(CurrentBridgePtr&&) = delete;
public:
- CurrentBridgePtr( Dali::Accessibility::Bridge* b )
- : prev( get() )
+ CurrentBridgePtr(Dali::Accessibility::Bridge* b)
+ : prev(get())
{
get() = b;
}
namespace detail
{
-
-template < typename T >
+template<typename T>
struct signature_accessible_impl : signature_helper<signature_accessible_impl<T>>
{
- using subtype = std::pair< std::string, ObjectPath >;
+ using subtype = std::pair<std::string, ObjectPath>;
static constexpr auto name_v = concat("AtspiAccessiblePtr");
- static constexpr auto sig_v = concat("(so)");
+ static constexpr auto sig_v = concat("(so)");
/**
* @brief Marshals value v as marshalled type into message
*/
- static void set( const DBusWrapper::MessageIterPtr& iter, T* t )
+ static void set(const DBusWrapper::MessageIterPtr& iter, T* t)
{
- if( t )
+ if(t)
{
auto v = t->GetAddress();
- signature< subtype >::set( iter, { v.GetBus(), ObjectPath{std::string{ ATSPI_PREFIX_PATH } +v.GetPath()} } );
+ signature<subtype>::set(iter, {v.GetBus(), ObjectPath{std::string{ATSPI_PREFIX_PATH} + v.GetPath()}});
}
else
{
- signature< subtype >::set( iter, { "", ObjectPath{ ATSPI_NULL_PATH } } );
+ signature<subtype>::set(iter, {"", ObjectPath{ATSPI_NULL_PATH}});
}
}
/**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get( const DBusWrapper::MessageIterPtr& iter, T*& v )
+ static bool get(const DBusWrapper::MessageIterPtr& iter, T*& v)
{
subtype tmp;
- if( !signature< subtype >::get( iter, tmp ) )
+ if(!signature<subtype>::get(iter, tmp))
{
return false;
}
- if( tmp.second.value == ATSPI_NULL_PATH )
+ if(tmp.second.value == ATSPI_NULL_PATH)
{
v = nullptr;
return true;
}
- if( tmp.second.value.substr( 0, strlen( ATSPI_PREFIX_PATH ) ) != ATSPI_PREFIX_PATH )
+ if(tmp.second.value.substr(0, strlen(ATSPI_PREFIX_PATH)) != ATSPI_PREFIX_PATH)
{
return false;
}
auto b = CurrentBridgePtr::current();
- if( b->GetBusName() != tmp.first )
+ if(b->GetBusName() != tmp.first)
{
return false;
}
- v = b->FindByPath( tmp.second.value.substr( strlen( ATSPI_PREFIX_PATH ) ) );
+ v = b->FindByPath(tmp.second.value.substr(strlen(ATSPI_PREFIX_PATH)));
return v != nullptr;
}
};
-template <>
-struct signature< Dali::Accessibility::Accessible* > : public signature_accessible_impl< Dali::Accessibility::Accessible >
+template<>
+struct signature<Dali::Accessibility::Accessible*> : public signature_accessible_impl<Dali::Accessibility::Accessible>
{
};
-template <>
-struct signature< Dali::Accessibility::Address > : signature_helper<signature<Dali::Accessibility::Address>>
+template<>
+struct signature<Dali::Accessibility::Address> : signature_helper<signature<Dali::Accessibility::Address>>
{
- using subtype = std::pair< std::string, ObjectPath >;
+ using subtype = std::pair<std::string, ObjectPath>;
static constexpr auto name_v = concat("AtspiAccessiblePtr");
- static constexpr auto sig_v = concat("(so)");
+ static constexpr auto sig_v = concat("(so)");
/**
* @brief Marshals value v as marshalled type into message
*/
- static void set( const DBusWrapper::MessageIterPtr& iter, const Dali::Accessibility::Address& v )
+ static void set(const DBusWrapper::MessageIterPtr& iter, const Dali::Accessibility::Address& v)
{
- if( v )
+ if(v)
{
- signature< subtype >::set( iter, { v.GetBus(), ObjectPath{ std::string{ ATSPI_PREFIX_PATH } + v.GetPath() } } );
+ signature<subtype>::set(iter, {v.GetBus(), ObjectPath{std::string{ATSPI_PREFIX_PATH} + v.GetPath()}});
}
else
{
- signature< subtype >::set( iter, { v.GetBus(), ObjectPath{ ATSPI_NULL_PATH } } );
+ signature<subtype>::set(iter, {v.GetBus(), ObjectPath{ATSPI_NULL_PATH}});
}
}
/**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get( const DBusWrapper::MessageIterPtr& iter, Dali::Accessibility::Address& v )
+ static bool get(const DBusWrapper::MessageIterPtr& iter, Dali::Accessibility::Address& v)
{
subtype tmp;
- if( !signature< subtype >::get( iter, tmp ) )
+ if(!signature<subtype>::get(iter, tmp))
{
return false;
}
- if( tmp.second.value == ATSPI_NULL_PATH )
+ if(tmp.second.value == ATSPI_NULL_PATH)
{
v = {};
return true;
}
- if( tmp.second.value.substr( 0, strlen( ATSPI_PREFIX_PATH ) ) != ATSPI_PREFIX_PATH )
+ if(tmp.second.value.substr(0, strlen(ATSPI_PREFIX_PATH)) != ATSPI_PREFIX_PATH)
{
return false;
}
- v = { std::move( tmp.first ), tmp.second.value.substr( strlen( ATSPI_PREFIX_PATH ) ) };
- return true;
+ v = {std::move(tmp.first), tmp.second.value.substr(strlen(ATSPI_PREFIX_PATH))};
+ return true;
}
};
-template <>
-struct signature< Dali::Accessibility::States > : signature_helper<signature<Dali::Accessibility::States>>
+template<>
+struct signature<Dali::Accessibility::States> : signature_helper<signature<Dali::Accessibility::States>>
{
using subtype = std::array<uint32_t, 2>;
static constexpr auto name_v = signature<subtype>::name_v;
- static constexpr auto sig_v = signature<subtype>::sig_v;
+ static constexpr auto sig_v = signature<subtype>::sig_v;
/**
* @brief Marshals value v as marshalled type into message
*/
- static void set( const DBusWrapper::MessageIterPtr& iter, const Dali::Accessibility::States& v )
+ static void set(const DBusWrapper::MessageIterPtr& iter, const Dali::Accessibility::States& v)
{
- signature< subtype >::set( iter, v.GetRawData() );
+ signature<subtype>::set(iter, v.GetRawData());
}
/**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get( const DBusWrapper::MessageIterPtr& iter, Dali::Accessibility::States& v )
+ static bool get(const DBusWrapper::MessageIterPtr& iter, Dali::Accessibility::States& v)
{
subtype tmp;
- if( !signature< subtype >::get( iter, tmp ) )
+ if(!signature<subtype>::get(iter, tmp))
{
return false;
}
- v = Dali::Accessibility::States{ tmp };
+ v = Dali::Accessibility::States{tmp};
return true;
}
};
-}
-}
+} // namespace detail
+} // namespace DBus
struct _Logger
{
- const char* file;
- int line;
+ const char* file;
+ int line;
std::ostringstream tmp;
- _Logger( const char* f, int l )
- : file( f ),
- line( l ){}
+ _Logger(const char* f, int l)
+ : file(f),
+ line(l)
+ {
+ }
~_Logger()
{
- Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s:%d: %s", file, line, tmp.str().c_str() );
+ Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d: %s", file, line, tmp.str().c_str());
}
- template < typename T >
- _Logger& operator<<( T&& t )
+ template<typename T>
+ _Logger& operator<<(T&& t)
{
- tmp << std::forward< T >( t );
+ tmp << std::forward<T>(t);
return *this;
}
};
struct _LoggerEmpty
{
- template < typename T >
- _LoggerEmpty& operator<<( T&& t )
+ template<typename T>
+ _LoggerEmpty& operator<<(T&& t)
{
return *this;
}
struct _LoggerScope
{
const char* file;
- int line;
+ int line;
- _LoggerScope( const char* f, int l )
- : file( f ),
- line( l )
+ _LoggerScope(const char* f, int l)
+ : file(f),
+ line(l)
{
- Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s:%d: +", file, line );
+ Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d: +", file, line);
}
~_LoggerScope()
{
- Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s:%d: -", file, line );
+ Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d: -", file, line);
}
};
-#define LOG() _Logger( __FILE__, __LINE__ )
-#define SCOPE() _LoggerScope _l##__LINE__( __FILE__, __LINE__ )
+#define LOG() _Logger(__FILE__, __LINE__)
+#define SCOPE() _LoggerScope _l##__LINE__(__FILE__, __LINE__)
#endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_COMMON_H
/*
- * 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;
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H
/*
- * 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.
public:
enum class GetNeighborSearchMode
{
- normal = 0,
- recurseFromRoot = 1,
+ normal = 0,
+ recurseFromRoot = 1,
continueAfterFailedRecursion = 2,
- recurseToOutside = 3,
+ recurseToOutside = 3,
};
- int GetChildCount();
- DBus::ValueOrError< Dali::Accessibility::Accessible* > GetChildAtIndex( int index );
- Dali::Accessibility::Accessible* GetParent();
- DBus::ValueOrError< std::vector< Dali::Accessibility::Accessible* > > GetChildren();
- std::string GetName();
- std::string GetDescription();
- DBus::ValueOrError< uint32_t > GetRole();
- DBus::ValueOrError< std::string > GetRoleName();
- DBus::ValueOrError< std::string > GetLocalizedRoleName();
- DBus::ValueOrError< int32_t > GetIndexInParent();
- DBus::ValueOrError< std::array< uint32_t, 2 > > GetStates();
- DBus::ValueOrError< std::unordered_map< std::string, std::string > > GetAttributes();
- DBus::ValueOrError< std::vector< std::string > > GetInterfaces();
- DBus::ValueOrError< Dali::Accessibility::Accessible*, uint8_t, Dali::Accessibility::Accessible* > GetNavigableAtPoint( int32_t x, int32_t y, uint32_t coordType );
- DBus::ValueOrError< Dali::Accessibility::Accessible*, uint8_t > GetNeighbor( std::string root_path, int32_t direction, int32_t search_mode );
- DBus::ValueOrError< Dali::Accessibility::Accessible*, uint32_t , std::unordered_map< std::string, std::string > > GetDefaultLabelInfo();
+ int GetChildCount();
+ DBus::ValueOrError<Dali::Accessibility::Accessible*> GetChildAtIndex(int index);
+ Dali::Accessibility::Accessible* GetParent();
+ DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*>> GetChildren();
+ std::string GetName();
+ std::string GetDescription();
+ DBus::ValueOrError<uint32_t> GetRole();
+ DBus::ValueOrError<std::string> GetRoleName();
+ DBus::ValueOrError<std::string> GetLocalizedRoleName();
+ DBus::ValueOrError<int32_t> GetIndexInParent();
+ DBus::ValueOrError<std::array<uint32_t, 2>> GetStates();
+ DBus::ValueOrError<std::unordered_map<std::string, std::string>> GetAttributes();
+ DBus::ValueOrError<std::vector<std::string>> GetInterfaces();
+ DBus::ValueOrError<Dali::Accessibility::Accessible*, uint8_t, Dali::Accessibility::Accessible*> GetNavigableAtPoint(int32_t x, int32_t y, uint32_t coordType);
+ DBus::ValueOrError<Dali::Accessibility::Accessible*, uint8_t> GetNeighbor(std::string root_path, int32_t direction, int32_t search_mode);
+ DBus::ValueOrError<Dali::Accessibility::Accessible*, uint32_t, std::unordered_map<std::string, std::string>> GetDefaultLabelInfo();
using ReadingMaterialType = DBus::ValueOrError<
- std::unordered_map< std::string, std::string >, // attributes
- std::string, // name
- std::string, // labeledByName
- std::string, // textIfceName
- uint32_t,
- Dali::Accessibility::States,
- std::string, // localized name
- int32_t, // child count
- double, // current value
- double, // minimum increment
- double, // maximum value
- double, // minimum value
- std::string, // description
- int32_t, // index in parent
- bool, // isSelectedInParent
- bool, // hasCheckBoxChild
- int32_t, // listChildrenCount
- int32_t, // firstSelectedChildIndex
- Dali::Accessibility::Accessible*, // parent
- Dali::Accessibility::States, // parentStateSet
- int32_t, // parentChildCount
- uint32_t, // parentRole
- int32_t, // selectedChildCount,
- Dali::Accessibility::Accessible* // describedByObject
- >;
+ std::unordered_map<std::string, std::string>, // attributes
+ std::string, // name
+ std::string, // labeledByName
+ std::string, // textIfceName
+ uint32_t,
+ Dali::Accessibility::States,
+ std::string, // localized name
+ int32_t, // child count
+ double, // current value
+ double, // minimum increment
+ double, // maximum value
+ double, // minimum value
+ std::string, // description
+ int32_t, // index in parent
+ bool, // isSelectedInParent
+ bool, // hasCheckBoxChild
+ int32_t, // listChildrenCount
+ int32_t, // firstSelectedChildIndex
+ Dali::Accessibility::Accessible*, // parent
+ Dali::Accessibility::States, // parentStateSet
+ int32_t, // parentChildCount
+ uint32_t, // parentRole
+ int32_t, // selectedChildCount,
+ Dali::Accessibility::Accessible* // describedByObject
+ >;
ReadingMaterialType GetReadingMaterial();
- DBus::ValueOrError< bool > DoGesture( Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime );
+ DBus::ValueOrError<bool> DoGesture(Dali::Accessibility::Gesture type, int32_t xBeg, int32_t xEnd, int32_t yBeg, int32_t yEnd, Dali::Accessibility::GestureState state, uint32_t eventTime);
- using Relation = std::tuple< uint32_t, std::vector< Dali::Accessibility::Address > >;
- DBus::ValueOrError<std::vector< Relation >> GetRelationSet();
+ using Relation = std::tuple<uint32_t, std::vector<Dali::Accessibility::Address>>;
+ DBus::ValueOrError<std::vector<Relation>> GetRelationSet();
private:
- Dali::Accessibility::Accessible* CalculateNeighbor( Dali::Accessibility::Accessible* root, Dali::Accessibility::Accessible* start, unsigned char forward, GetNeighborSearchMode search_mode );
- std::vector< Dali::Accessibility::Accessible* > ValidChildrenGet( const std::vector< Dali::Accessibility::Accessible* >& children, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root );
- Dali::Accessibility::Accessible* GetCurrentlyHighlighted();
- Dali::Accessibility::Accessible* DirectionalDepthFirstSearchTryNonDefunctSibling( bool& all_children_visited, Dali::Accessibility::Accessible* node, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward );
- Dali::Accessibility::Accessible* GetNextNonDefunctSibling( Dali::Accessibility::Accessible* obj, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward );
- Dali::Accessibility::Component* CalculateNavigableAccessibleAtPoint( Dali::Accessibility::Accessible* root, Dali::Accessibility::Point p, Dali::Accessibility::CoordType cType, unsigned int maxRecursionDepth );
- Dali::Accessibility::Component * GetObjectInRelation(Dali::Accessibility::Accessible * obj, Dali::Accessibility::RelationType ralationType);
+ Dali::Accessibility::Accessible* CalculateNeighbor(Dali::Accessibility::Accessible* root, Dali::Accessibility::Accessible* start, unsigned char forward, GetNeighborSearchMode search_mode);
+ std::vector<Dali::Accessibility::Accessible*> ValidChildrenGet(const std::vector<Dali::Accessibility::Accessible*>& children, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root);
+ Dali::Accessibility::Accessible* GetCurrentlyHighlighted();
+ Dali::Accessibility::Accessible* DirectionalDepthFirstSearchTryNonDefunctSibling(bool& all_children_visited, Dali::Accessibility::Accessible* node, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward);
+ Dali::Accessibility::Accessible* GetNextNonDefunctSibling(Dali::Accessibility::Accessible* obj, Dali::Accessibility::Accessible* start, Dali::Accessibility::Accessible* root, unsigned char forward);
+ Dali::Accessibility::Component* CalculateNavigableAccessibleAtPoint(Dali::Accessibility::Accessible* root, Dali::Accessibility::Point p, Dali::Accessibility::CoordType cType, unsigned int maxRecursionDepth);
+ Dali::Accessibility::Component* GetObjectInRelation(Dali::Accessibility::Accessible* obj, Dali::Accessibility::RelationType ralationType);
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACCESSIBLE_H
/*
- * 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 + "'"};
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACTION_H
/*
- * 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.
Dali::Accessibility::Action* FindSelf() const;
public:
- DBus::ValueOrError< std::string > GetActionName( int32_t index );
- DBus::ValueOrError< std::string > GetLocalizedActionName( int32_t index );
- DBus::ValueOrError< std::string > GetActionDescription( int32_t index );
- DBus::ValueOrError< std::string > GetActionKeyBinding( int32_t index );
- DBus::ValueOrError< int32_t > GetActionCount();
- DBus::ValueOrError< bool > DoAction( int32_t index );
- DBus::ValueOrError< bool > DoActionName( std::string name );
+ DBus::ValueOrError<std::string> GetActionName(int32_t index);
+ DBus::ValueOrError<std::string> GetLocalizedActionName(int32_t index);
+ DBus::ValueOrError<std::string> GetActionDescription(int32_t index);
+ DBus::ValueOrError<std::string> GetActionKeyBinding(int32_t index);
+ DBus::ValueOrError<int32_t> GetActionCount();
+ DBus::ValueOrError<bool> DoAction(int32_t index);
+ DBus::ValueOrError<bool> DoActionName(std::string name);
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_ACTION_H
/*
- * 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());
}
-
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_BASE_H
/*
- * 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.
{
public:
Dali::Accessibility::EmptyAccessibleWithAddress parent;
- std::vector< Dali::Accessibility::Accessible* > children;
- std::string name;
+ std::vector<Dali::Accessibility::Accessible*> children;
+ std::string name;
std::string GetName() override
{
return children.size();
}
- Dali::Accessibility::Accessible* GetChildAtIndex( size_t index ) override
+ Dali::Accessibility::Accessible* GetChildAtIndex(size_t index) override
{
auto s = children.size();
- if( index >= s )
- throw std::domain_error{"invalid index " + std::to_string( index ) + " for object with " + std::to_string( s ) + " children"};
+ if(index >= s)
+ throw std::domain_error{"invalid index " + std::to_string(index) + " for object with " + std::to_string(s) + " children"};
return children[index];
}
return children.empty() ? nullptr : children[0];
}
- bool DoGesture(const Dali::Accessibility::GestureInfo &gestureInfo) override
+ bool DoGesture(const Dali::Accessibility::GestureInfo& gestureInfo) override
{
- return false;
+ return false;
}
std::vector<Dali::Accessibility::Relation> GetRelationSet() override
{
- return {};
+ return {};
}
- Dali::Accessibility::Address GetAddress() override {
- return { "", "root" };
+ Dali::Accessibility::Address GetAddress() override
+ {
+ return {"", "root"};
}
-
};
-
-enum class FilteredEvents {
+enum class FilteredEvents
+{
boundsChanged
};
-
-namespace std {
- template <> struct hash<std::pair<FilteredEvents, Dali::Accessibility::Accessible*>> {
- size_t operator () (std::pair<FilteredEvents, Dali::Accessibility::Accessible*> v) const {
- return (static_cast<size_t>(v.first) * 131) ^ reinterpret_cast<size_t>(v.second);
- }
- };
-}
-
+namespace std
+{
+template<>
+struct hash<std::pair<FilteredEvents, Dali::Accessibility::Accessible*>>
+{
+ size_t operator()(std::pair<FilteredEvents, Dali::Accessibility::Accessible*> v) const
+ {
+ return (static_cast<size_t>(v.first) * 131) ^ reinterpret_cast<size_t>(v.second);
+ }
+};
+} // namespace std
class BridgeBase : public Dali::Accessibility::Bridge, public Dali::ConnectionTracker
{
bool tickFilteredEvents();
public:
-
void addFilteredEvent(FilteredEvents kind, Dali::Accessibility::Accessible* obj, float delay, std::function<void()> functor);
const std::string& GetBusName() const override;
- void AddTopLevelWindow( Dali::Accessibility::Accessible* window ) override;
- void RemoveTopLevelWindow( Dali::Accessibility::Accessible* window ) override;
- void AddPopup( Dali::Accessibility::Accessible* ) override;
- void RemovePopup( Dali::Accessibility::Accessible* ) override;
+ void AddTopLevelWindow(Dali::Accessibility::Accessible* window) override;
+ void RemoveTopLevelWindow(Dali::Accessibility::Accessible* window) override;
+ void AddPopup(Dali::Accessibility::Accessible*) override;
+ void RemovePopup(Dali::Accessibility::Accessible*) override;
Dali::Accessibility::Accessible* GetApplication() const override
{
return &application;
}
- template < typename SELF, typename... RET, typename... ARGS >
+ template<typename SELF, typename... RET, typename... ARGS>
void AddFunctionToInterface(
- DBus::DBusInterfaceDescription& desc, const std::string& funcName,
- DBus::ValueOrError< RET... > ( SELF::*funcPtr )( ARGS... ) )
+ DBus::DBusInterfaceDescription& desc, const std::string& funcName, DBus::ValueOrError<RET...> (SELF::*funcPtr)(ARGS...))
{
- if ( auto self = dynamic_cast< SELF* >( this ) )
- desc.addMethod< DBus::ValueOrError< RET... >( ARGS... ) >( funcName,
- [=]( ARGS... args ) -> DBus::ValueOrError< RET... > {
- try
- {
- return ( self->*funcPtr )( std::move( args )... );
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- } );
+ if(auto self = dynamic_cast<SELF*>(this))
+ desc.addMethod<DBus::ValueOrError<RET...>(ARGS...)>(funcName,
+ [=](ARGS... args) -> DBus::ValueOrError<RET...> {
+ try
+ {
+ return (self->*funcPtr)(std::move(args)...);
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ });
}
- template < typename T, typename SELF >
- void AddGetPropertyToInterface( DBus::DBusInterfaceDescription& desc,
- const std::string& funcName, T ( SELF::*funcPtr )() )
+ template<typename T, typename SELF>
+ void AddGetPropertyToInterface(DBus::DBusInterfaceDescription& desc,
+ const std::string& funcName,
+ T (SELF::*funcPtr)())
{
- if ( auto self = dynamic_cast< SELF* >( this ) )
- desc.addProperty< T >( funcName,
- [=]() -> DBus::ValueOrError< T > {
- try
- {
- return ( self->*funcPtr )();
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- },
- {} );
+ if(auto self = dynamic_cast<SELF*>(this))
+ desc.addProperty<T>(funcName,
+ [=]() -> DBus::ValueOrError<T> {
+ try
+ {
+ return (self->*funcPtr)();
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ },
+ {});
}
- template < typename T, typename SELF >
- void AddSetPropertyToInterface( DBus::DBusInterfaceDescription& desc,
- const std::string& funcName, void ( SELF::*funcPtr )( T ) )
+ template<typename T, typename SELF>
+ void AddSetPropertyToInterface(DBus::DBusInterfaceDescription& desc,
+ const std::string& funcName,
+ void (SELF::*funcPtr)(T))
{
- if ( auto self = dynamic_cast< SELF* >( this ) )
- desc.addProperty< T >( funcName, {},
- [=]( T t ) -> DBus::ValueOrError< void > {
- try
- {
- ( self->*funcPtr )( std::move( t ) );
- return {};
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- } );
+ if(auto self = dynamic_cast<SELF*>(this))
+ desc.addProperty<T>(funcName, {}, [=](T t) -> DBus::ValueOrError<void> {
+ try
+ {
+ (self->*funcPtr)(std::move(t));
+ return {};
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ });
}
- template < typename T, typename T1, typename SELF >
- void AddGetSetPropertyToInterface( DBus::DBusInterfaceDescription& desc,
- const std::string& funcName, T1 ( SELF::*funcPtrGet )(), DBus::ValueOrError< void > ( SELF::*funcPtrSet )( T ) )
+ template<typename T, typename T1, typename SELF>
+ void AddGetSetPropertyToInterface(DBus::DBusInterfaceDescription& desc,
+ const std::string& funcName,
+ T1 (SELF::*funcPtrGet)(),
+ DBus::ValueOrError<void> (SELF::*funcPtrSet)(T))
{
- if ( auto self = dynamic_cast< SELF* >( this ) )
- desc.addProperty< T >( funcName,
- [=]() -> DBus::ValueOrError< T > {
- try
- {
- return ( self->*funcPtrGet )();
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- },
- [=]( T t ) -> DBus::ValueOrError< void > {
- try
- {
- ( self->*funcPtrSet )( std::move( t ) );
- return {};
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- } );
+ if(auto self = dynamic_cast<SELF*>(this))
+ desc.addProperty<T>(
+ funcName,
+ [=]() -> DBus::ValueOrError<T> {
+ try
+ {
+ return (self->*funcPtrGet)();
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ },
+ [=](T t) -> DBus::ValueOrError<void> {
+ try
+ {
+ (self->*funcPtrSet)(std::move(t));
+ return {};
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ });
}
- template < typename T, typename T1, typename SELF >
- void AddGetSetPropertyToInterface( DBus::DBusInterfaceDescription& desc,
- const std::string& funcName, T1 ( SELF::*funcPtrGet )(), void ( SELF::*funcPtrSet )( T ) )
+ template<typename T, typename T1, typename SELF>
+ void AddGetSetPropertyToInterface(DBus::DBusInterfaceDescription& desc,
+ const std::string& funcName,
+ T1 (SELF::*funcPtrGet)(),
+ void (SELF::*funcPtrSet)(T))
{
- if ( auto self = dynamic_cast< SELF* >( this ) )
- desc.addProperty< T >( funcName,
- [=]() -> DBus::ValueOrError< T > {
- try
- {
- return ( self->*funcPtrGet )();
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- },
- [=]( T t ) -> DBus::ValueOrError< void > {
- try
- {
- ( self->*funcPtrSet )( std::move( t ) );
- return {};
- }
- catch( std::domain_error& e )
- {
- return DBus::Error{e.what()};
- }
- } );
+ if(auto self = dynamic_cast<SELF*>(this))
+ desc.addProperty<T>(
+ funcName,
+ [=]() -> DBus::ValueOrError<T> {
+ try
+ {
+ return (self->*funcPtrGet)();
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ },
+ [=](T t) -> DBus::ValueOrError<void> {
+ try
+ {
+ (self->*funcPtrSet)(std::move(t));
+ return {};
+ }
+ catch(std::domain_error& e)
+ {
+ return DBus::Error{e.what()};
+ }
+ });
}
- static std::string StripPrefix( const std::string& path );
+ static std::string StripPrefix(const std::string& path);
- Dali::Accessibility::Accessible* Find( const std::string& path ) const;
- Dali::Accessibility::Accessible* Find( const Dali::Accessibility::Address& ptr ) const;
+ Dali::Accessibility::Accessible* Find(const std::string& path) const;
+ Dali::Accessibility::Accessible* Find(const Dali::Accessibility::Address& ptr) const;
Dali::Accessibility::Accessible* FindSelf() const;
- Dali::Accessibility::Accessible* FindByPath( const std::string& name ) const override;
- void SetApplicationName( std::string name ) override
+ Dali::Accessibility::Accessible* FindByPath(const std::string& name) const override;
+ void SetApplicationName(std::string name) override
{
- application.name = std::move( name );
+ application.name = std::move(name);
}
protected:
- mutable AppAccessible application;
+ mutable AppAccessible application;
std::vector<Dali::Accessibility::Accessible*> popups;
+
private:
- void IdSet( int id );
- int IdGet();
+ void IdSet(int id);
+ int IdGet();
using CacheElementType = std::tuple<
- Dali::Accessibility::Address, Dali::Accessibility::Address, Dali::Accessibility::Address,
- std::vector< Dali::Accessibility::Address >,
- std::vector< std::string >,
- std::string,
- Dali::Accessibility::Role,
- std::string,
- std::array< uint32_t, 2 > >;
- DBus::ValueOrError< std::vector< CacheElementType > > GetItems();
- CacheElementType CreateCacheElement( Dali::Accessibility::Accessible* item );
+ Dali::Accessibility::Address,
+ Dali::Accessibility::Address,
+ Dali::Accessibility::Address,
+ std::vector<Dali::Accessibility::Address>,
+ std::vector<std::string>,
+ std::string,
+ Dali::Accessibility::Role,
+ std::string,
+ std::array<uint32_t, 2>>;
+ DBus::ValueOrError<std::vector<CacheElementType>> GetItems();
+ CacheElementType CreateCacheElement(Dali::Accessibility::Accessible* item);
protected:
BridgeBase();
virtual ~BridgeBase();
ForceUpResult ForceUp() override;
- void ForceDown() override;
+ void ForceDown() override;
- DBus::DBusServer dbusServer;
+ DBus::DBusServer dbusServer;
DBusWrapper::ConnectionPtr con;
- int id = 0;
+ int id = 0;
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_BASE_H
/*
- * 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;
}
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H
/*
- * 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.
{
private:
struct Comparer;
- static void VisitNodes( Dali::Accessibility::Accessible* obj, std::vector< Dali::Accessibility::Accessible* >& result, Comparer& cmp, size_t maxCount );
+ static void VisitNodes(Dali::Accessibility::Accessible* obj, std::vector<Dali::Accessibility::Accessible*>& result, Comparer& cmp, size_t maxCount);
protected:
BridgeCollection() = default;
public:
using MatchRule = std::tuple<
- std::array< int32_t, 2 >, int32_t,
- std::unordered_map< std::string, std::string >, int32_t,
- std::array< int32_t, 4 >, int32_t,
- std::vector< std::string >, int32_t,
- bool >;
+ std::array<int32_t, 2>,
+ int32_t,
+ std::unordered_map<std::string, std::string>,
+ int32_t,
+ std::array<int32_t, 4>,
+ int32_t,
+ std::vector<std::string>,
+ int32_t,
+ bool>;
struct Index
{
enum
};
};
- DBus::ValueOrError< std::vector< Dali::Accessibility::Accessible* > > GetMatches( MatchRule rule, uint32_t sortBy, int32_t count, bool traverse );
+ DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetMatches(MatchRule rule, uint32_t sortBy, int32_t count, bool traverse);
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COLLECTION_H
/*
- * 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();
}
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COMPONENT_H
/*
- * 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.
Dali::Accessibility::Component* FindSelf() const;
public:
- DBus::ValueOrError< bool > Contains( int32_t x, int32_t y, uint32_t coordType );
- DBus::ValueOrError< Dali::Accessibility::Accessible* > GetAccessibleAtPoint( int32_t x, int32_t y, uint32_t coordType );
- DBus::ValueOrError< std::tuple< int32_t, int32_t, int32_t, int32_t > > GetExtents( uint32_t coordType );
- DBus::ValueOrError< int32_t, int32_t > GetPosition( uint32_t coordType );
- DBus::ValueOrError< int32_t, int32_t > GetSize( uint32_t coordType );
- DBus::ValueOrError< Dali::Accessibility::ComponentLayer > GetLayer();
- DBus::ValueOrError< double > GetAlpha();
- DBus::ValueOrError< bool > GrabFocus();
- DBus::ValueOrError< bool > GrabHighlight();
- DBus::ValueOrError< bool > ClearHighlight();
- DBus::ValueOrError< int16_t > GetMdiZOrder();
+ DBus::ValueOrError<bool> Contains(int32_t x, int32_t y, uint32_t coordType);
+ DBus::ValueOrError<Dali::Accessibility::Accessible*> GetAccessibleAtPoint(int32_t x, int32_t y, uint32_t coordType);
+ DBus::ValueOrError<std::tuple<int32_t, int32_t, int32_t, int32_t> > GetExtents(uint32_t coordType);
+ DBus::ValueOrError<int32_t, int32_t> GetPosition(uint32_t coordType);
+ DBus::ValueOrError<int32_t, int32_t> GetSize(uint32_t coordType);
+ DBus::ValueOrError<Dali::Accessibility::ComponentLayer> GetLayer();
+ DBus::ValueOrError<double> GetAlpha();
+ DBus::ValueOrError<bool> GrabFocus();
+ DBus::ValueOrError<bool> GrabHighlight();
+ DBus::ValueOrError<bool> ClearHighlight();
+ DBus::ValueOrError<int16_t> GetMdiZOrder();
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_COMPONENT_H
/*
- * 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 );
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_EDITABLE_TEXT_H
/*
- * 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.
Dali::Accessibility::EditableText* FindSelf() const;
public:
- DBus::ValueOrError< bool > CopyText( int32_t startPos, int32_t endPos );
- DBus::ValueOrError< bool > CutText( int32_t startPos, int32_t endPos );
- DBus::ValueOrError< bool > PasteText( int32_t pos );
+ DBus::ValueOrError<bool> CopyText(int32_t startPos, int32_t endPos);
+ DBus::ValueOrError<bool> CutText(int32_t startPos, int32_t endPos);
+ DBus::ValueOrError<bool> PasteText(int32_t pos);
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_EDITABLE_TEXT_H
/*
- * 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"});
}
}
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_OBJECT_H
/*
- * 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::SignalId stateChanged;
- void EmitActiveDescendantChanged( Dali::Accessibility::Accessible* obj, Dali::Accessibility::Accessible *child ) override;
- void EmitCaretMoved( Dali::Accessibility::Accessible* obj, unsigned int cursorPosition ) override;
- void EmitTextChanged( Dali::Accessibility::Accessible* obj, Dali::Accessibility::TextChangedState state, unsigned int position, unsigned int length, const std::string &content ) override;
- void EmitStateChanged( Dali::Accessibility::Accessible* obj, Dali::Accessibility::State state, int val1, int val2 ) override;
- void Emit( Dali::Accessibility::Accessible* obj, Dali::Accessibility::WindowEvent we, unsigned int detail1 ) override;
- void Emit( Dali::Accessibility::Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent we ) override;
- void EmitBoundsChanged( Dali::Accessibility::Accessible* obj, Dali::Rect<> rect ) override;
+ void EmitActiveDescendantChanged(Dali::Accessibility::Accessible* obj, Dali::Accessibility::Accessible* child) override;
+ void EmitCaretMoved(Dali::Accessibility::Accessible* obj, unsigned int cursorPosition) override;
+ void EmitTextChanged(Dali::Accessibility::Accessible* obj, Dali::Accessibility::TextChangedState state, unsigned int position, unsigned int length, const std::string& content) override;
+ void EmitStateChanged(Dali::Accessibility::Accessible* obj, Dali::Accessibility::State state, int val1, int val2) override;
+ void Emit(Dali::Accessibility::Accessible* obj, Dali::Accessibility::WindowEvent we, unsigned int detail1) override;
+ void Emit(Dali::Accessibility::Accessible* obj, Dali::Accessibility::ObjectPropertyChangeEvent we) override;
+ void EmitBoundsChanged(Dali::Accessibility::Accessible* obj, Dali::Rect<> rect) override;
public:
- int GetChildCount();
- DBus::ValueOrError< Dali::Accessibility::Accessible* > GetChildAtIndex( int index );
- Dali::Accessibility::Accessible* GetParent();
- DBus::ValueOrError< std::vector< Dali::Accessibility::Accessible* > > GetChildren();
- std::string GetName();
- std::string GetDescription();
- DBus::ValueOrError< uint32_t > GetRole();
- DBus::ValueOrError< std::string > GetRoleName();
- DBus::ValueOrError< std::string > GetLocalizedRoleName();
- DBus::ValueOrError< int32_t > GetIndexInParent();
- DBus::ValueOrError< std::array< uint32_t, 2 > > GetStates();
- DBus::ValueOrError< std::unordered_map< std::string, std::string > > GetAttributes();
- DBus::ValueOrError< std::vector< std::string > > GetInterfaces();
+ int GetChildCount();
+ DBus::ValueOrError<Dali::Accessibility::Accessible*> GetChildAtIndex(int index);
+ Dali::Accessibility::Accessible* GetParent();
+ DBus::ValueOrError<std::vector<Dali::Accessibility::Accessible*> > GetChildren();
+ std::string GetName();
+ std::string GetDescription();
+ DBus::ValueOrError<uint32_t> GetRole();
+ DBus::ValueOrError<std::string> GetRoleName();
+ DBus::ValueOrError<std::string> GetLocalizedRoleName();
+ DBus::ValueOrError<int32_t> GetIndexInParent();
+ DBus::ValueOrError<std::array<uint32_t, 2> > GetStates();
+ DBus::ValueOrError<std::unordered_map<std::string, std::string> > GetAttributes();
+ DBus::ValueOrError<std::vector<std::string> > GetInterfaces();
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_OBJECT_H
/*
- * 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);
}
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_TEXT_H
/*
- * 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.
Dali::Accessibility::Text* FindSelf() const;
public:
- DBus::ValueOrError< std::string > GetText( int startOffset, int endOffset );
- DBus::ValueOrError< int32_t > GetCharacterCount();
- DBus::ValueOrError< int32_t > GetCaretOffset();
- DBus::ValueOrError< bool > SetCaretOffset( int32_t offset );
- DBus::ValueOrError< std::string, int, int > GetTextAtOffset( int32_t offset, uint32_t boundary );
- DBus::ValueOrError< int, int > GetSelection( int32_t selectionNum );
- DBus::ValueOrError< bool > RemoveSelection( int32_t selectionNum );
- DBus::ValueOrError< bool > SetSelection( int32_t selectionNum, int32_t startOffset, int32_t endOffset );
+ DBus::ValueOrError<std::string> GetText(int startOffset, int endOffset);
+ DBus::ValueOrError<int32_t> GetCharacterCount();
+ DBus::ValueOrError<int32_t> GetCaretOffset();
+ DBus::ValueOrError<bool> SetCaretOffset(int32_t offset);
+ DBus::ValueOrError<std::string, int, int> GetTextAtOffset(int32_t offset, uint32_t boundary);
+ DBus::ValueOrError<int, int> GetSelection(int32_t selectionNum);
+ DBus::ValueOrError<bool> RemoveSelection(int32_t selectionNum);
+ DBus::ValueOrError<bool> SetSelection(int32_t selectionNum, int32_t startOffset, int32_t endOffset);
};
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_TEXT_H
/*
- * 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()
{
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_VALUE_H
/*
- * 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.
public:
double GetCurrentValue();
- void SetCurrentValue( double new_value );
+ void SetCurrentValue(double new_value);
double GetMaximumValue();
double GetMinimumIncrement();
double GetMinimumValue();
/*
- * 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;
}
{
namespace callmgr
{
-static constexpr const char* BUS = "org.tizen.callmgr";
-static constexpr const char* OBJ_PATH = "/org/tizen/callmgr";
+static constexpr const char* BUS = "org.tizen.callmgr";
+static constexpr const char* OBJ_PATH = "/org/tizen/callmgr";
static constexpr const char* INTERFACE = "org.tizen.callmgr";
-}
+} // namespace callmgr
namespace accessibilityEMod
{
-static constexpr const char* BUS = "org.enlightenment.wm-screen-reader";
-static constexpr const char* OBJ_PATH = "/org/tizen/GestureNavigation";
+static constexpr const char* BUS = "org.enlightenment.wm-screen-reader";
+static constexpr const char* OBJ_PATH = "/org/tizen/GestureNavigation";
static constexpr const char* INTERFACE = "org.tizen.GestureNavigation";
static constexpr const char* ACCESSORIES_SP_ENABLED = "AccessoriesSwitchProviderEnabled";
-static constexpr const char* KEY_DOWN_SIGNAL = "KeyDown";
-static constexpr const char* KEY_UP_SIGNAL = "KeyUp";
+static constexpr const char* KEY_DOWN_SIGNAL = "KeyDown";
+static constexpr const char* KEY_UP_SIGNAL = "KeyUp";
static constexpr const char* SCREEN_SP_ENABLED = "ScreenSwitchProviderEnabled";
static constexpr const char* MOUSE_DOWN_SIGNAL = "MouseDown";
-static constexpr const char* MOUSE_UP_SIGNAL = "MouseUp";
+static constexpr const char* MOUSE_UP_SIGNAL = "MouseUp";
static constexpr const char* BACK_BUTTON_INTERCEPTION_ENABLED = "BackButtonInterceptionEnabled";
-static constexpr const char* BACK_BUTTON_DOWN_SIGNAL = "BackButtonDown";
-static constexpr const char* BACK_BUTTON_UP_SIGNAL = "BackButtonUp";
-}
+static constexpr const char* BACK_BUTTON_DOWN_SIGNAL = "BackButtonDown";
+static constexpr const char* BACK_BUTTON_UP_SIGNAL = "BackButtonUp";
+} // namespace accessibilityEMod
namespace freeDesktop
{
-static constexpr const char* BUS = "org.freedesktop.DBus";
-static constexpr const char* OBJ_PATH = "/org/freedesktop/DBus";
-static constexpr const char* INTERFACE = "org.freedesktop.DBus";
-static constexpr const char* PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties";
+static constexpr const char* BUS = "org.freedesktop.DBus";
+static constexpr const char* OBJ_PATH = "/org/freedesktop/DBus";
+static constexpr const char* INTERFACE = "org.freedesktop.DBus";
+static constexpr const char* PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties";
static constexpr const char* GET_CONNECTION_UNIX_PROCESS_ID = "GetConnectionUnixProcessID";
-static constexpr const char* SET = "Set";
-static constexpr const char* GET = "Get";
-}
+static constexpr const char* SET = "Set";
+static constexpr const char* GET = "Get";
+} // namespace freeDesktop
namespace windowManager
{
-static constexpr const char* BUS = "org.enlightenment.wm";
-static constexpr const char* OBJ_PATH = "/org/enlightenment/wm";
-static constexpr const char* INTERFACE = "org.enlightenment.wm.proc";
+static constexpr const char* BUS = "org.enlightenment.wm";
+static constexpr const char* OBJ_PATH = "/org/enlightenment/wm";
+static constexpr const char* INTERFACE = "org.enlightenment.wm.proc";
static constexpr const char* GET_VISIBLE_WIN_INFO = "GetVisibleWinInfo";
-static constexpr const char* GET_FOCUS_PROC = "GetFocusProc";
-}
+static constexpr const char* GET_FOCUS_PROC = "GetFocusProc";
+} // namespace windowManager
namespace atspi
{
-static constexpr const char* BUS = "org.a11y.Bus";
-static constexpr const char* OBJ_PATH = "/org/a11y/bus";
-static constexpr const char* BUS_INTERFACE = "org.a11y.Bus";
+static constexpr const char* BUS = "org.a11y.Bus";
+static constexpr const char* OBJ_PATH = "/org/a11y/bus";
+static constexpr const char* BUS_INTERFACE = "org.a11y.Bus";
static constexpr const char* STATUS_INTERFACE = "org.a11y.Status";
-static constexpr const char* GET_ADDRESS = "GetAddress";
-static constexpr const char* IS_ENABLED = "IsEnabled";
-static constexpr const char* GET_ATTRIBUTES = "GetAttributes";
-static constexpr const char* DO_ACTION_NAME = "DoActionName";
-static constexpr const char* PARENT = "Parent";
-static constexpr const char* GET_MATCHES = "GetMatches";
-static constexpr const char* GET_INDEX_IN_PARENT = "GetIndexInParent";
-static constexpr const char* SELECT_CHILD = "SelectChild";
-static constexpr const char* NAME = "Name";
-static constexpr const char* GET_ROLE = "GetRole";
-static constexpr const char* CHILD_COUNT = "ChildCount";
-static constexpr const char* GET_CHILD_AT_INDEX = "GetChildAtIndex";
-static constexpr const char* GET_STATE = "GetState";
-static constexpr const char* GET_RELATION_SET = "GetRelationSet";
-static constexpr const char* GET_EXTENTS = "GetExtents";
-static constexpr const char* CURRENT_VALUE = "CurrentValue";
-static constexpr const char* MAXIMUM_VALUE = "MaximumValue";
-static constexpr const char* MINIMUM_VALUE = "MinimumValue";
-static constexpr const char* GET_INTERFACES = "GetInterfaces";
+static constexpr const char* GET_ADDRESS = "GetAddress";
+static constexpr const char* IS_ENABLED = "IsEnabled";
+static constexpr const char* GET_ATTRIBUTES = "GetAttributes";
+static constexpr const char* DO_ACTION_NAME = "DoActionName";
+static constexpr const char* PARENT = "Parent";
+static constexpr const char* GET_MATCHES = "GetMatches";
+static constexpr const char* GET_INDEX_IN_PARENT = "GetIndexInParent";
+static constexpr const char* SELECT_CHILD = "SelectChild";
+static constexpr const char* NAME = "Name";
+static constexpr const char* GET_ROLE = "GetRole";
+static constexpr const char* CHILD_COUNT = "ChildCount";
+static constexpr const char* GET_CHILD_AT_INDEX = "GetChildAtIndex";
+static constexpr const char* GET_STATE = "GetState";
+static constexpr const char* GET_RELATION_SET = "GetRelationSet";
+static constexpr const char* GET_EXTENTS = "GetExtents";
+static constexpr const char* CURRENT_VALUE = "CurrentValue";
+static constexpr const char* MAXIMUM_VALUE = "MaximumValue";
+static constexpr const char* MINIMUM_VALUE = "MinimumValue";
+static constexpr const char* GET_INTERFACES = "GetInterfaces";
static constexpr const char* GET_NAVIGABLE_AT_POINT = "GetNavigableAtPoint";
-}
-}
+} // namespace atspi
+} // namespace dbusLocators
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_DBUS_LOCATORS_H
*/
// 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);
}
#include <vector>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
#include <dali/devel-api/adaptor-framework/accessibility.h>
+#include <dali/public-api/common/dali-common.h>
#define ATSPI_PREFIX_PATH "/org/a11y/atspi/accessible/"
#define ATSPI_NULL_PATH "/org/a11y/atspi/null"
};
#define DEFINE_TYPE(name, eldbus_name, unref_call) \
- struct name { virtual ~name() = default; }; \
- using name ## Ptr = std::shared_ptr<name>; \
- using name ## WeakPtr = std::weak_ptr<name>; \
+ struct name \
+ { \
+ virtual ~name() = default; \
+ }; \
+ using name##Ptr = std::shared_ptr<name>; \
+ using name##WeakPtr = std::weak_ptr<name>;
DEFINE_TYPE(Connection, Eldbus_Connection, )
- DEFINE_TYPE(MessageIter, Eldbus_Message_Iter, eldbus_message_iter_container_close(Value))
- DEFINE_TYPE(Message, Eldbus_Message, eldbus_message_unref(Value))
- DEFINE_TYPE(Proxy, Eldbus_Proxy, eldbus_proxy_unref(Value))
- DEFINE_TYPE(Object, Eldbus_Object, eldbus_object_unref(Value))
- DEFINE_TYPE(Pending, Eldbus_Pending, )
- DEFINE_TYPE(EventPropertyChanged, Eldbus_Proxy_Event_Property_Changed, )
+ DEFINE_TYPE(MessageIter, Eldbus_Message_Iter, eldbus_message_iter_container_close(Value))
+ DEFINE_TYPE(Message, Eldbus_Message, eldbus_message_unref(Value))
+ DEFINE_TYPE(Proxy, Eldbus_Proxy, eldbus_proxy_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
- virtual ConnectionPtr eldbus_address_connection_get_impl(const std::string& addr) = 0;
+ virtual ConnectionPtr eldbus_address_connection_get_impl(const std::string& addr) = 0;
-#define eldbus_message_iter_arguments_append_impl_basic_impl(type_set, type_get, sig) \
- virtual void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, type_set src) = 0; \
- virtual bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, type_get &dst) = 0;
+#define eldbus_message_iter_arguments_append_impl_basic_impl(type_set, type_get, sig) \
+ virtual void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, type_set src) = 0; \
+ virtual bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, type_get& dst) = 0;
#define eldbus_message_iter_arguments_append_impl_basic(type, sig) \
eldbus_message_iter_arguments_append_impl_basic_impl(type, type, sig)
+ // 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(uint64_t, t)
- eldbus_message_iter_arguments_append_impl_basic(int16_t, n)
- 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)
- eldbus_message_iter_arguments_append_impl_basic(bool, b)
- eldbus_message_iter_arguments_append_impl_basic_impl(const std::string&, std::string, s)
- eldbus_message_iter_arguments_append_impl_basic_impl(const ObjectPath&, ObjectPath, o)
+ 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(uint64_t, t)
+ eldbus_message_iter_arguments_append_impl_basic(int16_t, n)
+ 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)
+ eldbus_message_iter_arguments_append_impl_basic(bool, b)
+ eldbus_message_iter_arguments_append_impl_basic_impl(const std::string&, std::string, s)
+ eldbus_message_iter_arguments_append_impl_basic_impl(const ObjectPath&, ObjectPath, o)
#undef eldbus_message_iter_arguments_append_impl_basic
#undef eldbus_message_iter_arguments_append_impl_basic_impl
- virtual MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr& it, int type, const std::string& sig) = 0;
- virtual MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr& it, int type) = 0;
- virtual MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr& it, bool write) = 0;
- virtual MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr& proxy, const std::string& funcName) = 0;
- virtual MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr& proxy, const MessagePtr& msg) = 0;
- virtual bool eldbus_message_error_get_impl(const MessagePtr& msg, std::string& name, std::string& text) = 0;
- virtual std::string eldbus_message_signature_get_impl(const MessagePtr& msg) = 0;
-
- using SendCallback = std::function<void(const MessagePtr & msg)>;
- virtual PendingPtr eldbus_proxy_send_impl(const ProxyPtr& proxy, const MessagePtr& msg, const SendCallback& callback) = 0;
- virtual std::string eldbus_proxy_interface_get_impl(const ProxyPtr&) = 0;
- virtual void eldbus_proxy_signal_handler_add_impl(const ProxyPtr& proxy, const std::string& member, const std::function<void(const MessagePtr&)>& cb) = 0;
- virtual std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr& iter) = 0;
- virtual MessagePtr eldbus_message_method_return_new_impl(const MessagePtr& msg) = 0;
- virtual MessagePtr eldbus_message_error_new_impl(const MessagePtr& msg, const std::string& err, const std::string& txt) = 0;
- virtual PendingPtr eldbus_connection_send_impl(const ConnectionPtr& conn, const MessagePtr& msg) = 0;
- virtual MessagePtr eldbus_message_signal_new_impl(const std::string& path, const std::string& iface, const std::string& name) = 0;
- virtual MessagePtr eldbus_message_ref_impl(const MessagePtr& msg) = 0;
- virtual ConnectionPtr eldbus_connection_get_impl(ConnectionType type) = 0;
- virtual std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr& conn) = 0;
- virtual ObjectPtr eldbus_object_get_impl(const ConnectionPtr& conn, const std::string& bus, const std::string& path) = 0;
- virtual ProxyPtr eldbus_proxy_get_impl(const ObjectPtr& obj, const std::string& interface) = 0;
- virtual ProxyPtr eldbus_proxy_copy_impl(const ProxyPtr& ptr) = 0;
+ virtual MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr& it, int type, const std::string& sig) = 0;
+ virtual MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr& it, int type) = 0;
+ virtual MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr& it, bool write) = 0;
+ virtual MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr& proxy, const std::string& funcName) = 0;
+ virtual MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr& proxy, const MessagePtr& msg) = 0;
+ virtual bool eldbus_message_error_get_impl(const MessagePtr& msg, std::string& name, std::string& text) = 0;
+ virtual std::string eldbus_message_signature_get_impl(const MessagePtr& msg) = 0;
+ // clang-format on
+
+ using SendCallback = std::function<void(const MessagePtr& msg)>;
+
+ virtual PendingPtr eldbus_proxy_send_impl(const ProxyPtr& proxy, const MessagePtr& msg, const SendCallback& callback) = 0;
+ virtual std::string eldbus_proxy_interface_get_impl(const ProxyPtr&) = 0;
+ virtual void eldbus_proxy_signal_handler_add_impl(const ProxyPtr& proxy, const std::string& member, const std::function<void(const MessagePtr&)>& cb) = 0;
+ virtual std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr& iter) = 0;
+ virtual MessagePtr eldbus_message_method_return_new_impl(const MessagePtr& msg) = 0;
+ virtual MessagePtr eldbus_message_error_new_impl(const MessagePtr& msg, const std::string& err, const std::string& txt) = 0;
+ virtual PendingPtr eldbus_connection_send_impl(const ConnectionPtr& conn, const MessagePtr& msg) = 0;
+ virtual MessagePtr eldbus_message_signal_new_impl(const std::string& path, const std::string& iface, const std::string& name) = 0;
+ virtual MessagePtr eldbus_message_ref_impl(const MessagePtr& msg) = 0;
+ virtual ConnectionPtr eldbus_connection_get_impl(ConnectionType type) = 0;
+ virtual std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr& conn) = 0;
+ virtual ObjectPtr eldbus_object_get_impl(const ConnectionPtr& conn, const std::string& bus, const std::string& path) = 0;
+ virtual ProxyPtr eldbus_proxy_get_impl(const ObjectPtr& obj, const std::string& interface) = 0;
+ virtual ProxyPtr eldbus_proxy_copy_impl(const ProxyPtr& ptr) = 0;
class StringStorage
{
free(p);
}
};
- std::vector< std::unique_ptr< char, char_ptr_deleter > > storage;
+ std::vector<std::unique_ptr<char, char_ptr_deleter>> storage;
const char* add(const char* txt)
{
auto ptr = strdup(txt);
- storage.push_back(std::unique_ptr< char, char_ptr_deleter >(ptr));
+ storage.push_back(std::unique_ptr<char, char_ptr_deleter>(ptr));
return storage.back().get();
}
const char* add(const std::string& txt)
struct CallId
{
- static std::atomic< unsigned int > LastId;
- unsigned int id = ++LastId;
+ static std::atomic<unsigned int> LastId;
+ unsigned int id = ++LastId;
};
struct MethodInfo
{
- CallId id;
- std::string memberName;
- std::vector< std::pair<std::string, std::string> > in, out; // _Eldbus_Arg_Info
- std::function< DBusWrapper::MessagePtr(const DBusWrapper::MessagePtr & msg) > callback;
+ CallId id;
+ std::string memberName;
+ std::vector<std::pair<std::string, std::string>> in, out; // _Eldbus_Arg_Info
+ std::function<DBusWrapper::MessagePtr(const DBusWrapper::MessagePtr& msg)> callback;
};
struct SignalInfo
{
- CallId id;
- std::string memberName;
- std::vector< std::pair<std::string, std::string> > args;
- unsigned int uniqueId;
+ CallId id;
+ std::string memberName;
+ std::vector<std::pair<std::string, std::string>> args;
+ unsigned int uniqueId;
};
struct PropertyInfo
{
- CallId setterId, getterId;
- std::string memberName, typeSignature;
- std::function< std::string(const DBusWrapper::MessagePtr & src, const DBusWrapper::MessageIterPtr & dst) > getCallback, setCallback;
+ CallId setterId, getterId;
+ std::string memberName, typeSignature;
+ std::function<std::string(const DBusWrapper::MessagePtr&src, const DBusWrapper::MessageIterPtr&dst)> getCallback, setCallback;
};
struct SignalId
{
CallId id;
SignalId() = default;
- SignalId(CallId id) : id(id) {}
+ SignalId(CallId id)
+ : id(id)
+ {
+ }
};
- virtual 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) = 0;
- virtual 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) = 0;
+ virtual 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) = 0;
+ virtual 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) = 0;
static DBusWrapper* Installed();
- static void Install(std::unique_ptr<DBusWrapper>);
+ static void Install(std::unique_ptr<DBusWrapper>);
StringStorage Strings;
};
-namespace detail {
- enum class MethodType {
- Method, Getter, Setter
- };
+namespace detail
+{
+enum class MethodType
+{
+ Method,
+ Getter,
+ Setter
+};
}
-namespace std {
- template <> struct hash<std::tuple<std::string, std::string, std::string>> {
- size_t operator () (const std::tuple<std::string, std::string, std::string>& a) const {
- auto a1 = std::hash<std::string>()(std::get<0>(a));
- auto a2 = std::hash<std::string>()(std::get<1>(a));
- auto a3 = std::hash<std::string>()(std::get<2>(a));
- size_t v = a1;
- v = (v * 11400714819323198485llu) + a2;
- v = (v * 11400714819323198485llu) + a3;
- return v;
- }
+namespace std
+{
+template<>
+struct hash<std::tuple<std::string, std::string, std::string>>
+{
+ size_t operator()(const std::tuple<std::string, std::string, std::string>& a) const
+ {
+ auto a1 = std::hash<std::string>()(std::get<0>(a));
+ auto a2 = std::hash<std::string>()(std::get<1>(a));
+ auto a3 = std::hash<std::string>()(std::get<2>(a));
+ size_t v = a1;
+ v = (v * 11400714819323198485llu) + a2;
+ v = (v * 11400714819323198485llu) + a3;
+ return v;
+ }
+};
+template<>
+struct hash<std::tuple<std::string, std::string, std::string, detail::MethodType>>
+{
+ size_t operator()(const std::tuple<std::string, std::string, std::string, detail::MethodType>& a) const
+ {
+ auto a1 = std::hash<std::string>()(std::get<0>(a));
+ auto a2 = std::hash<std::string>()(std::get<1>(a));
+ auto a3 = std::hash<std::string>()(std::get<2>(a));
+ auto a4 = static_cast<size_t>(std::get<3>(a));
+ size_t v = a1;
+ v = (v * 11400714819323198485llu) + a2;
+ v = (v * 11400714819323198485llu) + a3;
+ v = (v * 11400714819323198485llu) + a4;
+ return v;
+ }
+};
+template<>
+struct hash<std::tuple<std::string, std::string, unsigned int>>
+{
+ size_t operator()(const std::tuple<std::string, std::string, unsigned int>& a) const
+ {
+ auto a1 = std::hash<std::string>()(std::get<0>(a));
+ auto a2 = std::hash<std::string>()(std::get<1>(a));
+ auto a3 = std::get<2>(a);
+ size_t v = a1;
+ v = (v * 11400714819323198485llu) + a2;
+ v = (v * 11400714819323198485llu) + a3;
+ return v;
+ }
+};
+} // namespace std
+
+namespace detail
+{
+template<typename T>
+struct DBusSigImpl
+{
+ enum
+ {
+ value = 0,
+ end = 0
};
- template <> struct hash<std::tuple<std::string, std::string, std::string, detail::MethodType>> {
- size_t operator () (const std::tuple<std::string, std::string, std::string, detail::MethodType>& a) const {
- auto a1 = std::hash<std::string>()(std::get<0>(a));
- auto a2 = std::hash<std::string>()(std::get<1>(a));
- auto a3 = std::hash<std::string>()(std::get<2>(a));
- auto a4 = static_cast<size_t>(std::get<3>(a));
- size_t v = a1;
- v = (v * 11400714819323198485llu) + a2;
- v = (v * 11400714819323198485llu) + a3;
- v = (v * 11400714819323198485llu) + a4;
- return v;
- }
+};
+template<typename T>
+struct DBusSig
+{
+ enum
+ {
+ value = DBusSigImpl<typename std::decay<T>::type>::value,
+ end = DBusSigImpl<typename std::decay<T>::type>::end
};
- template <> struct hash<std::tuple<std::string, std::string, unsigned int>> {
- size_t operator () (const std::tuple<std::string, std::string, unsigned int>& a) const {
- auto a1 = std::hash<std::string>()(std::get<0>(a));
- auto a2 = std::hash<std::string>()(std::get<1>(a));
- auto a3 = std::get<2>(a);
- size_t v = a1;
- v = (v * 11400714819323198485llu) + a2;
- v = (v * 11400714819323198485llu) + a3;
- return v;
- }
+};
+template<typename T, typename Q, size_t I, size_t S>
+struct IndexFromTypeTupleImpl
+{
+ enum
+ {
+ value = std::is_same<typename std::decay<typename std::tuple_element<I, T>::type>::type, Q>::value ? I : IndexFromTypeTupleImpl<T, Q, I + 1, S>::value
};
-}
-
-namespace detail {
- template <typename T> struct DBusSigImpl { enum { value = 0, end = 0 }; };
- template <typename T> struct DBusSig { enum { value = DBusSigImpl<typename std::decay<T>::type>::value, end = DBusSigImpl<typename std::decay<T>::type>::end }; };
- template <typename T, typename Q, size_t I, size_t S> struct IndexFromTypeTupleImpl {
- enum { value = std::is_same<typename std::decay<typename std::tuple_element<I, T>::type>::type, Q>::value ? I : IndexFromTypeTupleImpl<T, Q, I + 1, S>::value };
+};
+template<typename T, typename Q, size_t S>
+struct IndexFromTypeTupleImpl<T, Q, S, S>
+{
+ enum
+ {
+ value = S
};
- template <typename T, typename Q, size_t S> struct IndexFromTypeTupleImpl<T, Q, S, S> { enum { value = S }; };
- template <typename T, typename Q> struct IndexFromTypeTuple {
- enum { value = IndexFromTypeTupleImpl<T, typename std::decay<Q>::type, 0, std::tuple_size<T>::value>::value };
+};
+template<typename T, typename Q>
+struct IndexFromTypeTuple
+{
+ enum
+ {
+ value = IndexFromTypeTupleImpl<T, typename std::decay<Q>::type, 0, std::tuple_size<T>::value>::value
};
- template <typename T, typename = void> struct Encoder;
- template <size_t I, size_t S, typename ... ARGS> struct EncoderTuple;
-}
-
-namespace detail {
- template <> struct DBusSigImpl<uint8_t> { enum { value = 'y', end = 0 }; };
- template <> struct DBusSigImpl<uint16_t> { enum { value = 'q', end = 0 }; };
- template <> struct DBusSigImpl<uint32_t> { enum { value = 'u', end = 0 }; };
- template <> struct DBusSigImpl<uint64_t> { enum { value = 't', end = 0 }; };
- template <> struct DBusSigImpl<int16_t> { enum { value = 'n', end = 0 }; };
- template <> struct DBusSigImpl<int32_t> { enum { value = 'i', end = 0 }; };
- template <> struct DBusSigImpl<int64_t> { enum { value = 'x', end = 0 }; };
- template <> struct DBusSigImpl<double> { enum { value = 'd', end = 0 }; };
- template <> struct DBusSigImpl<bool> { enum { value = 'b', end = 0 }; };
- template <> struct DBusSigImpl<std::string> { enum { value = 's', end = 0 }; };
- template <> struct DBusSigImpl<ObjectPath> { enum { value = 'o', end = 0 }; };
-}
+};
+template<typename T, typename = void>
+struct Encoder;
+template<size_t I, size_t S, typename... ARGS>
+struct EncoderTuple;
+} // namespace detail
+namespace detail
+{
+template<>
+struct DBusSigImpl<uint8_t>
+{
+ enum
+ {
+ value = 'y',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<uint16_t>
+{
+ enum
+ {
+ value = 'q',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<uint32_t>
+{
+ enum
+ {
+ value = 'u',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<uint64_t>
+{
+ enum
+ {
+ value = 't',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<int16_t>
+{
+ enum
+ {
+ value = 'n',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<int32_t>
+{
+ enum
+ {
+ value = 'i',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<int64_t>
+{
+ enum
+ {
+ value = 'x',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<double>
+{
+ enum
+ {
+ value = 'd',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<bool>
+{
+ enum
+ {
+ value = 'b',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<std::string>
+{
+ enum
+ {
+ value = 's',
+ end = 0
+ };
+};
+template<>
+struct DBusSigImpl<ObjectPath>
+{
+ enum
+ {
+ value = 'o',
+ end = 0
+ };
+};
+} // namespace detail
-#define DBUS_DEBUG( ... ) \
- do \
- { \
- DBus::debugPrint( __FILE__, __LINE__, __VA_ARGS__ ); \
- } while( 0 )
+#define DBUS_DEBUG(...) \
+ do \
+ { \
+ DBus::debugPrint(__FILE__, __LINE__, __VA_ARGS__); \
+ } while(0)
#define DBUS_W DBusWrapper::Installed()
*/
namespace DBus
{
+class DBusServer;
+class DBusClient;
+class DBusInterfaceDescription;
- class DBusServer;
- class DBusClient;
- class DBusInterfaceDescription;
-
- /**
+/**
* @brief Formats debug message and calls debug printer (if any) with it
*/
- void debugPrint(const char* file, size_t line, const char* format, ...);
+void debugPrint(const char* file, size_t line, const char* format, ...);
- /**
+/**
* @brief Sets debug printer callback, which will be called with debug messages
*
* Callback will be called in various moments of DBus activity. First value passed to callback
* is pointer to text, second it's length. Text is ended with 0 (not counted towards it's size),
* user can safely printf it.
*/
- void setDebugPrinter(std::function< void(const char*, size_t) >);
-
- struct Error
- {
- std::string message;
+void setDebugPrinter(std::function<void(const char*, size_t)>);
- Error() = default;
- Error(std::string msg) : message(std::move(msg))
- {
- assert(!message.empty());
- }
- };
+struct Error
+{
+ std::string message;
- struct Success
+ Error() = default;
+ Error(std::string msg)
+ : message(std::move(msg))
{
- };
+ assert(!message.empty());
+ }
+};
+struct Success
+{
+};
- /**
+/**
* @brief Value representing data, that came from DBUS or error message
*
* Object of this class either helds series of values (of types ARGS...)
* Both mean the same - ValueOrError containing no real data and being a marker,
* wherever operation successed or failed and containing possible error message.
*/
- template < typename... ARGS >
- class ValueOrError
- {
- public:
- /**
+template<typename... ARGS>
+class ValueOrError
+{
+public:
+ /**
* @brief Empty constructor. Valid only, if all ARGS types are default constructible.
*/
- ValueOrError() = default;
+ ValueOrError() = default;
- /**
+ /**
* @brief Value constructor.
*
* This will be initialized as success with passed in values.
*/
- ValueOrError(ARGS... t) : value(std::move(t)...) {}
+ ValueOrError(ARGS... t)
+ : value(std::move(t)...)
+ {
+ }
- /**
+ /**
* @brief Alternative Value constructor.
*
* This will be initialized as success with passed in values.
*/
- ValueOrError(std::tuple< ARGS... > t) : value(std::move(t)) {}
+ ValueOrError(std::tuple<ARGS...> t)
+ : value(std::move(t))
+ {
+ }
- /**
+ /**
* @brief Error constructor. This will be initialized as failure with given error message.
*/
- ValueOrError(Error e) : error(std::move(e))
- {
- assert(!error.message.empty());
- }
+ ValueOrError(Error e)
+ : error(std::move(e))
+ {
+ assert(!error.message.empty());
+ }
- /**
+ /**
* @brief bool operator.
*
* Returns true, if operation was successful (getValues member is callable), or false
* when operation failed (getError is callable).
*/
- explicit operator bool() const
- {
- return error.message.empty();
- }
+ explicit operator bool() const
+ {
+ return error.message.empty();
+ }
- /**
+ /**
* @brief Returns error message object.
*
* Returns object containing error message associated with the failed operation.
* Only callable, if operation actually failed, otherwise will assert.
*/
- const Error& getError() const
- {
- return error;
- }
+ const Error& getError() const
+ {
+ return error;
+ }
- /**
+ /**
* @brief Returns modifiable tuple of held data.
*
* Returns reference to the internal tuple containing held data.
* User can modify (or move) data safely.
* Only callable, if operation actually successed, otherwise will assert.
*/
- std::tuple< ARGS... >& getValues()
- {
- assert(*this);
- return value;
- }
+ std::tuple<ARGS...>& getValues()
+ {
+ assert(*this);
+ return value;
+ }
- /**
+ /**
* @brief Returns const tuple of held data.
*
* Returns const reference to the internal tuple containing held data.
* Only callable, if operation actually successed, otherwise will assert.
*/
- const std::tuple< ARGS... >& getValues() const
- {
- assert(*this);
- return value;
- }
-
- protected:
- std::tuple< ARGS... > value;
- Error error;
-
- };
+ const std::tuple<ARGS...>& getValues() const
+ {
+ assert(*this);
+ return value;
+ }
+protected:
+ std::tuple<ARGS...> value;
+ Error error;
+};
- template <>
- class ValueOrError<>
+template<>
+class ValueOrError<>
+{
+public:
+ ValueOrError() = default;
+ ValueOrError(std::tuple<> t)
{
- public:
- ValueOrError() = default;
- ValueOrError(std::tuple<> t) {}
- ValueOrError(Error e) : error(std::move(e))
- {
- assert(!error.message.empty());
- }
+ }
+ ValueOrError(Error e)
+ : error(std::move(e))
+ {
+ assert(!error.message.empty());
+ }
- explicit operator bool() const
- {
- return error.message.empty();
- }
- const Error& getError() const
- {
- return error;
- }
- std::tuple<>& getValues()
- {
- assert(*this);
- static std::tuple<> t;
- return t;
- }
- std::tuple<> getValues() const
- {
- assert(*this);
- return {};
- }
+ explicit operator bool() const
+ {
+ return error.message.empty();
+ }
+ const Error& getError() const
+ {
+ return error;
+ }
+ std::tuple<>& getValues()
+ {
+ assert(*this);
+ static std::tuple<> t;
+ return t;
+ }
+ std::tuple<> getValues() const
+ {
+ assert(*this);
+ return {};
+ }
- protected:
- Error error;
- };
+protected:
+ Error error;
+};
- template <>
- class ValueOrError< void >
+template<>
+class ValueOrError<void>
+{
+public:
+ ValueOrError() = default;
+ ValueOrError(Success)
{
- public:
- ValueOrError() = default;
- ValueOrError(Success) {}
- ValueOrError(Error e) : error(std::move(e))
- {
- assert(!error.message.empty());
- }
-
- explicit operator bool() const
- {
- return error.message.empty();
- }
- const Error& getError() const
- {
- return error;
- }
- std::tuple<>& getValues()
- {
- assert(*this);
- static std::tuple<> t;
- return t;
- }
- std::tuple<> getValues() const
- {
- assert(*this);
- return {};
- }
+ }
+ ValueOrError(Error e)
+ : error(std::move(e))
+ {
+ assert(!error.message.empty());
+ }
- protected:
- Error error;
- };
+ explicit operator bool() const
+ {
+ return error.message.empty();
+ }
+ const Error& getError() const
+ {
+ return error;
+ }
+ std::tuple<>& getValues()
+ {
+ assert(*this);
+ static std::tuple<> t;
+ return t;
+ }
+ std::tuple<> getValues() const
+ {
+ assert(*this);
+ return {};
+ }
- using ObjectPath = ObjectPath;
+protected:
+ Error error;
+};
+using ObjectPath = ObjectPath;
- /**
+/**
* @brief Class used to marshall DBUS's variant type
*
* Minimalistic class, that allows user to specify DBUS variant type
* as return data in variant. So for example user can't specify method call, which on return
* expects DBUS variant holding either string or int.
*/
- template < typename A >
- struct EldbusVariant
- {
- A value;
- };
+template<typename A>
+struct EldbusVariant
+{
+ A value;
+};
- /**
+/**
* @brief Namespace for private, internal functions and classes
*/
- namespace detail
- {
- inline namespace strings {
- template <std::size_t N>
- using char_array = std::array<char, N>;
-
- constexpr char *xcopy_n(const char *src, size_t n, char *dst)
- {
- for (std::size_t i = 0; i < n; ++i)
- dst[i] = src[i];
+namespace detail
+{
+inline namespace strings
+{
+template<std::size_t N>
+using char_array = std::array<char, N>;
- return dst + n;
- }
+constexpr char* xcopy_n(const char* src, size_t n, char* dst)
+{
+ for(std::size_t i = 0; i < n; ++i)
+ dst[i] = src[i];
- template <std::size_t N>
- constexpr std::size_t xlen(const char (&)[N])
- {
- return N - 1;
- }
+ return dst + n;
+}
- template <std::size_t N>
- constexpr std::size_t xlen(const char_array<N> &)
- {
- return N - 1;
- }
+template<std::size_t N>
+constexpr std::size_t xlen(const char (&)[N])
+{
+ return N - 1;
+}
- template <typename... Args>
- constexpr auto concat(const Args &... args)
- {
- char_array<(1U + ... + xlen(args))> arr{};
- char *ptr = arr.data();
+template<std::size_t N>
+constexpr std::size_t xlen(const char_array<N>&)
+{
+ return N - 1;
+}
- if constexpr (!arr.empty())
- ((ptr = xcopy_n(std::data(args), xlen(args), ptr)), ...);
+template<typename... Args>
+constexpr auto concat(const Args&... args)
+{
+ char_array<(1U + ... + xlen(args))> arr{};
+ char* ptr = arr.data();
- return arr;
- }
+ if constexpr(!arr.empty())
+ ((ptr = xcopy_n(std::data(args), xlen(args), ptr)), ...);
- template<std::size_t... Digits>
- struct to_chars {
- static constexpr const char value[] = {('0' + static_cast<char>(Digits))..., '\0'};
+ return arr;
+}
- static_assert((true && ... && (Digits < 10)));
- };
+template<std::size_t... Digits>
+struct to_chars
+{
+ static constexpr const char value[] = {('0' + static_cast<char>(Digits))..., '\0'};
- template<std::size_t Remainder, std::size_t... Digits>
- struct to_chars_helper : to_chars_helper<Remainder / 10, Remainder % 10, Digits...> {};
+ static_assert((true && ... && (Digits < 10)));
+};
- template<std::size_t... Digits>
- struct to_chars_helper<0, Digits...> : to_chars<Digits...> {};
+template<std::size_t Remainder, std::size_t... Digits>
+struct to_chars_helper : to_chars_helper<Remainder / 10, Remainder % 10, Digits...>
+{
+};
- template<std::size_t N>
- using to_string = to_chars_helper<N / 10, N % 10>;
- }
+template<std::size_t... Digits>
+struct to_chars_helper<0, Digits...> : to_chars<Digits...>
+{
+};
- template < typename T, typename = void >
- struct signature;
- template < typename... ARGS >
- struct signature< std::tuple< ARGS... > >;
- template < typename A, typename B >
- struct signature< std::pair< A, B > >;
- template < typename A >
- struct signature< std::vector< A > >;
- template < typename A, size_t N >
- struct signature< std::array< A, N > >;
- template < typename A, typename B >
- struct signature< std::unordered_map< A, B > >;
- template < typename A, typename B >
- struct signature< std::map< A, B > >;
-
- template <typename T>
- struct signature_helper
- {
- /**
+template<std::size_t N>
+using to_string = to_chars_helper<N / 10, N % 10>;
+} // namespace strings
+
+template<typename T, typename = void>
+struct signature;
+template<typename... ARGS>
+struct signature<std::tuple<ARGS...>>;
+template<typename A, typename B>
+struct signature<std::pair<A, B>>;
+template<typename A>
+struct signature<std::vector<A>>;
+template<typename A, size_t N>
+struct signature<std::array<A, N>>;
+template<typename A, typename B>
+struct signature<std::unordered_map<A, B>>;
+template<typename A, typename B>
+struct signature<std::map<A, B>>;
+
+template<typename T>
+struct signature_helper
+{
+ /**
* @brief Returns name of type marshalled, for informative purposes
*/
- static constexpr std::string_view name()
- {
- return {T::name_v.data()};
- }
+ static constexpr std::string_view name()
+ {
+ return {T::name_v.data()};
+ }
- /**
+ /**
* @brief Returns DBUS' signature of type marshalled
*/
- static constexpr std::string_view sig()
- {
- return {T::sig_v.data()};
- }
- };
+ static constexpr std::string_view sig()
+ {
+ return {T::sig_v.data()};
+ }
+};
- /**
+/**
* @brief Signature class for marshalling uint8 type.
*/
- template <>
- struct signature< uint8_t > : signature_helper<signature<uint8_t>>
- {
- static constexpr auto name_v = concat("uint8_t");
- static constexpr auto sig_v = concat("y");
+template<>
+struct signature<uint8_t> : signature_helper<signature<uint8_t>>
+{
+ static constexpr auto name_v = concat("uint8_t");
+ static constexpr auto sig_v = concat("y");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, uint8_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, uint8_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, uint8_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, uint8_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling uint16 type.
*/
- template <>
- struct signature< uint16_t > : signature_helper<signature<uint16_t>>
- {
- static constexpr auto name_v = concat("uint16_t");
- static constexpr auto sig_v = concat("q");
+template<>
+struct signature<uint16_t> : signature_helper<signature<uint16_t>>
+{
+ static constexpr auto name_v = concat("uint16_t");
+ static constexpr auto sig_v = concat("q");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, uint16_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, uint16_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, uint16_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, uint16_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling uint32 type.
*/
- template <>
- struct signature< uint32_t > : signature_helper<signature<uint32_t>>
- {
- static constexpr auto name_v = concat("uint32_t");
- static constexpr auto sig_v = concat("u");
+template<>
+struct signature<uint32_t> : signature_helper<signature<uint32_t>>
+{
+ static constexpr auto name_v = concat("uint32_t");
+ static constexpr auto sig_v = concat("u");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, uint32_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, uint32_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, uint32_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, uint32_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling uint64 type.
*/
- template <>
- struct signature< uint64_t > : signature_helper<signature<uint64_t>>
- {
- static constexpr auto name_v = concat("uint64_t");
- static constexpr auto sig_v = concat("t");
+template<>
+struct signature<uint64_t> : signature_helper<signature<uint64_t>>
+{
+ static constexpr auto name_v = concat("uint64_t");
+ static constexpr auto sig_v = concat("t");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, uint64_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, uint64_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, uint64_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, uint64_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling int16 type.
*/
- template <>
- struct signature< int16_t > : signature_helper<signature<int16_t>>
- {
- static constexpr auto name_v = concat("int16_t");
- static constexpr auto sig_v = concat("n");
+template<>
+struct signature<int16_t> : signature_helper<signature<int16_t>>
+{
+ static constexpr auto name_v = concat("int16_t");
+ static constexpr auto sig_v = concat("n");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, int16_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, int16_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, int16_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, int16_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling int32 type.
*/
- template <>
- struct signature< int32_t > : signature_helper<signature<int32_t>>
- {
- static constexpr auto name_v = concat("int32_t");
- static constexpr auto sig_v = concat("i");
+template<>
+struct signature<int32_t> : signature_helper<signature<int32_t>>
+{
+ static constexpr auto name_v = concat("int32_t");
+ static constexpr auto sig_v = concat("i");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, int32_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, int32_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, int32_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, int32_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling int64 type.
*/
- template <>
- struct signature< int64_t > : signature_helper<signature<int64_t>>
- {
- static constexpr auto name_v = concat("int64_t");
- static constexpr auto sig_v = concat("x");
+template<>
+struct signature<int64_t> : signature_helper<signature<int64_t>>
+{
+ static constexpr auto name_v = concat("int64_t");
+ static constexpr auto sig_v = concat("x");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, int64_t v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, int64_t v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, int64_t& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, int64_t& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling double type.
*/
- template <>
- struct signature< double > : signature_helper<signature<double>>
- {
- static constexpr auto name_v = concat("double");
- static constexpr auto sig_v = concat("d");
+template<>
+struct signature<double> : signature_helper<signature<double>>
+{
+ static constexpr auto name_v = concat("double");
+ static constexpr auto sig_v = concat("d");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, double v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, double v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, double& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
+ static bool get(const DBusWrapper::MessageIterPtr& iter, double& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, float& v2)
- {
- double v = 0;
- auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- v2 = static_cast<float>(v);
- return r;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, float& v2)
+ {
+ double v = 0;
+ auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ v2 = static_cast<float>(v);
+ return r;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling float type.
*/
- template <>
- struct signature< float > : signature_helper<signature<float>>
- {
- static constexpr auto name_v = concat("float");
- static constexpr auto sig_v = concat("d");
+template<>
+struct signature<float> : signature_helper<signature<float>>
+{
+ static constexpr auto name_v = concat("float");
+ static constexpr auto sig_v = concat("d");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, float v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, float v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, double& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
+ static bool get(const DBusWrapper::MessageIterPtr& iter, double& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, float& v2)
- {
- double v = 0;
- auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- v2 = static_cast<float>(v);
- return r;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, float& v2)
+ {
+ double v = 0;
+ auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ v2 = static_cast<float>(v);
+ return r;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling boolean type.
*/
- template <>
- struct signature< bool > : signature_helper<signature<bool>>
- {
- static constexpr auto name_v = concat("bool");
- static constexpr auto sig_v = concat("b");
+template<>
+struct signature<bool> : signature_helper<signature<bool>>
+{
+ static constexpr auto name_v = concat("bool");
+ static constexpr auto sig_v = concat("b");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, bool v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, bool v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, bool& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, bool& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- template < typename T >
- struct signature<T, typename std::enable_if_t<std::is_enum_v<T>, void>> : signature_helper<signature<T>>
- {
- static constexpr auto name_v = concat("enum");
- static constexpr auto sig_v = signature<typename std::underlying_type<T>::type>::sig_v;
+template<typename T>
+struct signature<T, typename std::enable_if_t<std::is_enum_v<T>, void>> : signature_helper<signature<T>>
+{
+ static constexpr auto name_v = concat("enum");
+ static constexpr auto sig_v = signature<typename std::underlying_type<T>::type>::sig_v;
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, T v)
- {
- signature<typename std::underlying_type<T>::type>::set(iter, static_cast<int64_t>(v));
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, T v)
+ {
+ signature<typename std::underlying_type<T>::type>::set(iter, static_cast<int64_t>(v));
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, T& v)
- {
- typename std::underlying_type<T>::type q = 0;
- if (!signature<typename std::underlying_type<T>::type>::get(iter, q))
- return false;
+ static bool get(const DBusWrapper::MessageIterPtr& iter, T& v)
+ {
+ typename std::underlying_type<T>::type q = 0;
+ if(!signature<typename std::underlying_type<T>::type>::get(iter, q))
+ return false;
- v = static_cast<T>(q);
- return true;
- }
- };
+ v = static_cast<T>(q);
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling string type.
*
* Both (const) char * and std::string types are accepted as value to send.
* Only std::string is accepted as value to receive.
*/
- template <>
- struct signature< std::string > : signature_helper<signature<std::string>>
- {
- static constexpr auto name_v = concat("string");
- static constexpr auto sig_v = concat("s");
+template<>
+struct signature<std::string> : signature_helper<signature<std::string>>
+{
+ static constexpr auto name_v = concat("string");
+ static constexpr auto sig_v = concat("s");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::string& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::string& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
+};
- template <>
- struct signature< ObjectPath > : signature_helper<signature<ObjectPath>>
- {
- static constexpr auto name_v = concat("path");
- static constexpr auto sig_v = concat("o");
+template<>
+struct signature<ObjectPath> : signature_helper<signature<ObjectPath>>
+{
+ static constexpr auto name_v = concat("path");
+ static constexpr auto sig_v = concat("o");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{ v });
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{v});
+ }
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const ObjectPath& v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const ObjectPath& v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const char* v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{ v });
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const char* v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{v});
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, ObjectPath& v)
- {
- return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
- }
+ static bool get(const DBusWrapper::MessageIterPtr& iter, ObjectPath& v)
+ {
+ return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::string& v)
- {
- ObjectPath q;
- if (!DBUS_W->eldbus_message_iter_get_and_next_impl(iter, q)) return false;
- v = std::move(q.value);
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::string& v)
+ {
+ ObjectPath q;
+ if(!DBUS_W->eldbus_message_iter_get_and_next_impl(iter, q)) return false;
+ v = std::move(q.value);
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling (const) char * type.
*
* Both (const) char * and std::string types are accepted as value to send.
* You can't use (const) char * variable type to receive value.
*/
- template <>
- struct signature< char* > : signature_helper<signature<char *>>
- {
- static constexpr auto name_v = concat("string");
- static constexpr auto sig_v = concat("s");
+template<>
+struct signature<char*> : signature_helper<signature<char*>>
+{
+ static constexpr auto name_v = concat("string");
+ static constexpr auto sig_v = concat("s");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v);
+ }
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const char* v)
- {
- DBUS_W->eldbus_message_iter_arguments_append_impl(iter, std::string{ v });
- }
- };
-
- template < size_t INDEX, typename A, typename... ARGS >
- struct signature_tuple_element_type_helper
- {
- using type = typename signature_tuple_element_type_helper< INDEX - 1, ARGS... >::type;
- };
+ static void set(const DBusWrapper::MessageIterPtr& iter, const char* v)
+ {
+ DBUS_W->eldbus_message_iter_arguments_append_impl(iter, std::string{v});
+ }
+};
- template < typename A, typename... ARGS >
- struct signature_tuple_element_type_helper< 0, A, ARGS... >
- {
- using type = A;
- };
+template<size_t INDEX, typename A, typename... ARGS>
+struct signature_tuple_element_type_helper
+{
+ using type = typename signature_tuple_element_type_helper<INDEX - 1, ARGS...>::type;
+};
- /**
+template<typename A, typename... ARGS>
+struct signature_tuple_element_type_helper<0, A, ARGS...>
+{
+ using type = A;
+};
+
+/**
* @brief Helper class to marshall tuples
*
* This class marshals all elements of the tuple value starting at the index INDEX
* and incrementing. This class recursively calls itself with increasing INDEX value
* until INDEX is equal to SIZE, where recursive calling ends.
*/
- template < size_t INDEX, size_t SIZE, typename... ARGS >
- struct signature_tuple_helper : signature_helper<signature_tuple_helper<INDEX, SIZE, ARGS...>>
- {
- using current_type = typename signature_tuple_element_type_helper< INDEX, ARGS... >::type;
+template<size_t INDEX, size_t SIZE, typename... ARGS>
+struct signature_tuple_helper : signature_helper<signature_tuple_helper<INDEX, SIZE, ARGS...>>
+{
+ using current_type = typename signature_tuple_element_type_helper<INDEX, ARGS...>::type;
- static constexpr auto name_v = concat(signature<current_type>::name_v, ", ", signature_tuple_helper<INDEX + 1, SIZE, ARGS...>::name_v);
- static constexpr auto sig_v = concat(signature<current_type>::sig_v, signature_tuple_helper<INDEX + 1, SIZE, ARGS...>::sig_v);
+ static constexpr auto name_v = concat(signature<current_type>::name_v, ", ", signature_tuple_helper<INDEX + 1, SIZE, ARGS...>::name_v);
+ static constexpr auto sig_v = concat(signature<current_type>::sig_v, signature_tuple_helper<INDEX + 1, SIZE, ARGS...>::sig_v);
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple< ARGS... >& args)
- {
- signature< current_type >::set(iter, std::get< INDEX >(args));
- signature_tuple_helper< INDEX + 1, SIZE, ARGS... >::set(iter, args);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple<ARGS...>& args)
+ {
+ signature<current_type>::set(iter, std::get<INDEX>(args));
+ signature_tuple_helper<INDEX + 1, SIZE, ARGS...>::set(iter, args);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple< ARGS... >& args)
- {
- return signature< current_type >::get(iter, std::get< INDEX >(args)) &&
- signature_tuple_helper< INDEX + 1, SIZE, ARGS... >::get(iter, args);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple<ARGS...>& args)
+ {
+ return signature<current_type>::get(iter, std::get<INDEX>(args)) &&
+ signature_tuple_helper<INDEX + 1, SIZE, ARGS...>::get(iter, args);
+ }
+};
- /**
+/**
* @brief Helper class to marshall tuples
*
* This class marks end of the tuple marshalling. Members of this class are called
* when INDEX value is equal to SIZE.
*/
- template < size_t SIZE, typename... ARGS >
- struct signature_tuple_helper< SIZE, SIZE, ARGS... > : signature_helper<signature_tuple_helper<SIZE, SIZE, ARGS...>>
- {
- static constexpr auto name_v = concat("");
- static constexpr auto sig_v = concat("");
+template<size_t SIZE, typename... ARGS>
+struct signature_tuple_helper<SIZE, SIZE, ARGS...> : signature_helper<signature_tuple_helper<SIZE, SIZE, ARGS...>>
+{
+ static constexpr auto name_v = concat("");
+ static constexpr auto sig_v = concat("");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple< ARGS... >& args)
- {
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple<ARGS...>& args)
+ {
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple< ARGS... >& args)
- {
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple<ARGS...>& args)
+ {
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling tuple of values
*
* This class marshalls tuple of values. This represents
* DBUS struct typle, encoded with character 'r'
*/
- template < typename... ARGS >
- struct signature< std::tuple< ARGS... > > : signature_helper<signature<std::tuple<ARGS...>>>
- {
- static constexpr auto name_v = concat("tuple<", signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name_v, ">");
- static constexpr auto sig_v = concat("(", signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::sig_v, ")");
+template<typename... ARGS>
+struct signature<std::tuple<ARGS...>> : signature_helper<signature<std::tuple<ARGS...>>>
+{
+ static constexpr auto name_v = concat("tuple<", signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name_v, ">");
+ static constexpr auto sig_v = concat("(", signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::sig_v, ")");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple< ARGS... >& args)
- {
- auto entry = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'r', "");
- signature_tuple_helper< 0, sizeof...(ARGS), ARGS... >::set(entry, args);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple<ARGS...>& args)
+ {
+ auto entry = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'r', "");
+ signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::set(entry, args);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple< ARGS... >& args)
- {
- auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'r');
- if (!entry) return false;
- return signature_tuple_helper< 0, sizeof...(ARGS), ARGS... >::get(entry, args);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple<ARGS...>& args)
+ {
+ auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'r');
+ if(!entry) return false;
+ return signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::get(entry, args);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling ValueOrError template type
*
* ValueOrError template type is used to marshall list of values passed to
* or
* \code{.cpp} ValueOrError<std::tuple<std::string, std::string, std::tuple<std::string>>> \endcode
*/
- template < typename... ARGS >
- struct signature< ValueOrError< ARGS... > > : signature_helper<signature<ValueOrError<ARGS...>>>
- {
- static constexpr auto name_v = concat("ValueOrError<", signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name_v, ">");
- static constexpr auto sig_v = signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::sig_v;
+template<typename... ARGS>
+struct signature<ValueOrError<ARGS...>> : signature_helper<signature<ValueOrError<ARGS...>>>
+{
+ static constexpr auto name_v = concat("ValueOrError<", signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name_v, ">");
+ static constexpr auto sig_v = signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::sig_v;
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError< ARGS... >& args)
- {
- signature_tuple_helper< 0, sizeof...(ARGS), ARGS... >::set(iter, args.getValues());
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError<ARGS...>& args)
+ {
+ signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::set(iter, args.getValues());
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError< ARGS... >& args)
- {
- return signature_tuple_helper< 0, sizeof...(ARGS), ARGS... >::get(iter, args.getValues());
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError<ARGS...>& args)
+ {
+ return signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::get(iter, args.getValues());
+ }
+};
- /**
+/**
* @brief Signature class for marshalling ValueOrError<void> type
*/
- template <>
- struct signature< ValueOrError< void > > : signature_helper<signature<ValueOrError<void>>>
- {
- static constexpr auto name_v = concat("ValueOrError<void>");
- static constexpr auto sig_v = concat("");
+template<>
+struct signature<ValueOrError<void>> : signature_helper<signature<ValueOrError<void>>>
+{
+ static constexpr auto name_v = concat("ValueOrError<void>");
+ static constexpr auto sig_v = concat("");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError< void >& args)
- {
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError<void>& args)
+ {
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError< void >& args)
- {
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError<void>& args)
+ {
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling ValueOrError<> type
*/
- template <>
- struct signature< ValueOrError<> > : signature_helper<signature<ValueOrError<>>>
- {
- static constexpr auto name_v = concat("ValueOrError<>");
- static constexpr auto sig_v = concat("");
+template<>
+struct signature<ValueOrError<>> : signature_helper<signature<ValueOrError<>>>
+{
+ static constexpr auto name_v = concat("ValueOrError<>");
+ static constexpr auto sig_v = concat("");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError<>& args)
- {
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError<>& args)
+ {
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError<>& args)
- {
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError<>& args)
+ {
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling pair of types
*/
- template < typename A, typename B >
- struct signature< std::pair< A, B > > : signature_helper<signature<std::pair<A, B>>>
- {
- static constexpr auto name_v = concat("pair<", signature_tuple_helper<0, 2, A, B>::name_v, ">");
- static constexpr auto sig_v = concat("(", signature_tuple_helper<0, 2, A, B>::sig_v, ")");
+template<typename A, typename B>
+struct signature<std::pair<A, B>> : signature_helper<signature<std::pair<A, B>>>
+{
+ static constexpr auto name_v = concat("pair<", signature_tuple_helper<0, 2, A, B>::name_v, ">");
+ static constexpr auto sig_v = concat("(", signature_tuple_helper<0, 2, A, B>::sig_v, ")");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::pair< A, B >& ab, bool dictionary = false)
- {
- auto entry = DBUS_W->eldbus_message_iter_container_new_impl(iter, dictionary ? 'e' : 'r', "");
- signature_tuple_helper< 0, 2, A, B >::set(entry, ab);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::pair<A, B>& ab, bool dictionary = false)
+ {
+ auto entry = DBUS_W->eldbus_message_iter_container_new_impl(iter, dictionary ? 'e' : 'r', "");
+ signature_tuple_helper<0, 2, A, B>::set(entry, ab);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::pair< A, B >& ab)
- {
- auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'r');
- if (!entry) {
- entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, '{');
- if (!entry) return false;
- }
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::pair<A, B>& ab)
+ {
+ auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'r');
+ if(!entry)
+ {
+ entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, '{');
+ if(!entry) return false;
+ }
- std::tuple< A, B > ab_tmp;
- auto z = signature_tuple_helper< 0, 2, A, B >::get(entry, ab_tmp);
- if (z)
- {
- ab.first = std::move(std::get< 0 >(ab_tmp));
- ab.second = std::move(std::get< 1 >(ab_tmp));
- }
- return z;
- }
- };
+ std::tuple<A, B> ab_tmp;
+ auto z = signature_tuple_helper<0, 2, A, B>::get(entry, ab_tmp);
+ if(z)
+ {
+ ab.first = std::move(std::get<0>(ab_tmp));
+ ab.second = std::move(std::get<1>(ab_tmp));
+ }
+ return z;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling std::vector template type
*
* This marshals container's content as DBUS a ascii character type code.
*/
- template < typename A >
- struct signature< std::vector< A > > : signature_helper<signature<std::vector<A>>>
- {
- static constexpr auto name_v = concat("vector<", signature<A>::name_v, ">");
- static constexpr auto sig_v = concat("a", signature<A>::sig_v);
+template<typename A>
+struct signature<std::vector<A>> : signature_helper<signature<std::vector<A>>>
+{
+ static constexpr auto name_v = concat("vector<", signature<A>::name_v, ">");
+ static constexpr auto sig_v = concat("a", signature<A>::sig_v);
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::vector< A >& v)
- {
- auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', std::string{signature< A >::sig()});
- assert(lst);
- for (auto& a : v)
- {
- signature< A >::set(lst, a);
- }
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::vector<A>& v)
+ {
+ auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', std::string{signature<A>::sig()});
+ assert(lst);
+ for(auto& a : v)
+ {
+ signature<A>::set(lst, a);
+ }
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::vector< A >& v)
- {
- auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
- if (!s) return false;
- v.clear();
- A a;
- while (signature< A >::get(s, a))
- v.push_back(std::move(a));
-
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::vector<A>& v)
+ {
+ auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
+ if(!s) return false;
+ v.clear();
+ A a;
+ while(signature<A>::get(s, a))
+ v.push_back(std::move(a));
+
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling std::array template type
*
* This marshals container's content as DBUS a ascii character type code.
*/
- template < typename A, size_t N >
- struct signature< std::array< A, N > > : signature_helper<signature<std::array<A, N>>>
- {
- static constexpr auto name_v = concat("array<", signature<A>::name_v, ", ", to_string<N>::value, ">");
- static constexpr auto sig_v = concat("a", signature<A>::sig_v);
+template<typename A, size_t N>
+struct signature<std::array<A, N>> : signature_helper<signature<std::array<A, N>>>
+{
+ static constexpr auto name_v = concat("array<", signature<A>::name_v, ", ", to_string<N>::value, ">");
+ static constexpr auto sig_v = concat("a", signature<A>::sig_v);
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::array< A, N >& v)
- {
- auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', std::string{signature< A >::sig()});
- assert(lst);
- for (auto& a : v)
- {
- signature< A >::set(lst, a);
- }
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::array<A, N>& v)
+ {
+ auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', std::string{signature<A>::sig()});
+ assert(lst);
+ for(auto& a : v)
+ {
+ signature<A>::set(lst, a);
+ }
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::array< A, N >& v)
- {
- auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
- if (!s)
- return false;
- for (auto& a : v)
- {
- if (!signature< A >::get(s, a))
- return false;
- }
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::array<A, N>& v)
+ {
+ auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
+ if(!s)
+ return false;
+ for(auto& a : v)
+ {
+ if(!signature<A>::get(s, a))
+ return false;
+ }
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling EldbusVariant type
*
* This marshals variant's content as DBUS v ascii character type code.
*/
- template < typename A >
- struct signature< EldbusVariant< A > > : signature_helper<signature<EldbusVariant<A>>>
- {
- static constexpr auto name_v = concat("variant<", signature<A>::name_v, ">");
- static constexpr auto sig_v = concat("v");
+template<typename A>
+struct signature<EldbusVariant<A>> : signature_helper<signature<EldbusVariant<A>>>
+{
+ static constexpr auto name_v = concat("variant<", signature<A>::name_v, ">");
+ static constexpr auto sig_v = concat("v");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const EldbusVariant< A >& v)
- {
- set(iter, v.value);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const EldbusVariant<A>& v)
+ {
+ set(iter, v.value);
+ }
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
- {
- auto var = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'v', std::string{signature< A >::sig()});
- signature< A >::set(var, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
+ {
+ auto var = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'v', std::string{signature<A>::sig()});
+ signature<A>::set(var, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, EldbusVariant< A >& v)
- {
- auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'v');
- if (!s)
- return false;
- return signature< A >::get(s, v.value);
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, EldbusVariant<A>& v)
+ {
+ auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'v');
+ if(!s)
+ return false;
+ return signature<A>::get(s, v.value);
+ }
+};
- /**
+/**
* @brief Signature class for marshalling std::unordered_map template type
*
* This marshals container's content as DBUS {} ascii character type code.
* User can receive such values as std::vector of std::pair<key, value> values.
* Order of such values is unspecified.
*/
- template < typename A, typename B >
- struct signature< std::unordered_map< A, B > > : signature_helper<signature<std::unordered_map<A, B>>>
- {
- static constexpr auto name_v = concat("unordered_map<", signature<A>::name_v, ", ", signature<B>::name_v, ">");
- static constexpr auto sig_v = concat("a{", signature_tuple_helper<0, 2, A, B>::sig_v, "}");
+template<typename A, typename B>
+struct signature<std::unordered_map<A, B>> : signature_helper<signature<std::unordered_map<A, B>>>
+{
+ static constexpr auto name_v = concat("unordered_map<", signature<A>::name_v, ", ", signature<B>::name_v, ">");
+ static constexpr auto sig_v = concat("a{", signature_tuple_helper<0, 2, A, B>::sig_v, "}");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::unordered_map< A, B >& v)
- {
- auto sig = "{" + std::string{signature_tuple_helper< 0, 2, A, B >::sig()} + "}";
- auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', sig);
- assert(lst);
- for (auto& a : v)
- {
- signature< std::pair< A, B > >::set(lst, a, true);
- }
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::unordered_map<A, B>& v)
+ {
+ auto sig = "{" + std::string{signature_tuple_helper<0, 2, A, B>::sig()} + "}";
+ auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', sig);
+ assert(lst);
+ for(auto& a : v)
+ {
+ signature<std::pair<A, B>>::set(lst, a, true);
+ }
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::unordered_map< A, B >& v)
- {
- auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
- v.clear();
- if (!s)
- return false;
- std::pair< A, B > a;
- while (signature< std::pair< A, B > >::get(s, a))
- v.insert(std::move(a));
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::unordered_map<A, B>& v)
+ {
+ auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
+ v.clear();
+ if(!s)
+ return false;
+ std::pair<A, B> a;
+ while(signature<std::pair<A, B>>::get(s, a))
+ v.insert(std::move(a));
+ return true;
+ }
+};
- /**
+/**
* @brief Signature class for marshalling std::unordered_map template type
*
* This marshals container's content as DBUS {} ascii character type code.
* User can receive such values as std::vector of std::pair<key, value> values.
* Order of such values is unspecified.
*/
- template < typename A, typename B >
- struct signature< std::map< A, B > > : signature_helper<signature<std::map<A, B>>>
- {
- static constexpr auto name_v = concat("map<", signature<A>::name_v, ", ", signature<B>::name_v, ">");
- static constexpr auto sig_v = concat("a{", signature_tuple_helper<0, 2, A, B>::sig_v, "}");
+template<typename A, typename B>
+struct signature<std::map<A, B>> : signature_helper<signature<std::map<A, B>>>
+{
+ static constexpr auto name_v = concat("map<", signature<A>::name_v, ", ", signature<B>::name_v, ">");
+ static constexpr auto sig_v = concat("a{", signature_tuple_helper<0, 2, A, B>::sig_v, "}");
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const std::map< A, B >& v)
- {
- auto sig = "{" + std::string{signature_tuple_helper< 0, 2, A, B >::sig()} + "}";
- auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', sig);
- assert(lst);
- for (auto& a : v)
- {
- signature< std::pair< A, B > >::set(lst, a, true);
- }
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const std::map<A, B>& v)
+ {
+ auto sig = "{" + std::string{signature_tuple_helper<0, 2, A, B>::sig()} + "}";
+ auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', sig);
+ assert(lst);
+ for(auto& a : v)
+ {
+ signature<std::pair<A, B>>::set(lst, a, true);
+ }
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static bool get(const DBusWrapper::MessageIterPtr& iter, std::map< A, B >& v)
- {
- auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
- if (!s)
- return false;
- std::pair< A, B > a;
- while (signature< std::pair< A, B > >::get(s, a))
- v.insert(std::move(a));
- return true;
- }
- };
+ static bool get(const DBusWrapper::MessageIterPtr& iter, std::map<A, B>& v)
+ {
+ auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a');
+ if(!s)
+ return false;
+ std::pair<A, B> a;
+ while(signature<std::pair<A, B>>::get(s, a))
+ v.insert(std::move(a));
+ return true;
+ }
+};
- /**
+/**
* @brief Signature helper class for marshalling const reference types
*/
- template < typename A >
- struct signature< const A& > : signature_helper<signature<const A &>>
- {
- static constexpr auto name_v = concat("const ", signature<A>::name_v, "&");
- static constexpr auto sig_v = signature<A>::sig_v;
+template<typename A>
+struct signature<const A&> : signature_helper<signature<const A&>>
+{
+ static constexpr auto name_v = concat("const ", signature<A>::name_v, "&");
+ static constexpr auto sig_v = signature<A>::sig_v;
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
- {
- signature< A >::set(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
+ {
+ signature<A>::set(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static void get(const DBusWrapper::MessageIterPtr& iter, A& v)
- {
- signature< A >::get(iter, v);
- }
- };
+ static void get(const DBusWrapper::MessageIterPtr& iter, A& v)
+ {
+ signature<A>::get(iter, v);
+ }
+};
- /**
+/**
* @brief Signature helper class for marshalling reference types
*/
- template < typename A >
- struct signature< A& > : signature_helper<signature<A &>>
- {
- static constexpr auto name_v = concat(signature<A>::name_v, "&");
- static constexpr auto sig_v = signature<A>::sig_v;
+template<typename A>
+struct signature<A&> : signature_helper<signature<A&>>
+{
+ static constexpr auto name_v = concat(signature<A>::name_v, "&");
+ static constexpr auto sig_v = signature<A>::sig_v;
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
- {
- signature< A >::set(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
+ {
+ signature<A>::set(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static void get(const DBusWrapper::MessageIterPtr& iter, A& v)
- {
- signature< A >::get(iter, v);
- }
- };
+ static void get(const DBusWrapper::MessageIterPtr& iter, A& v)
+ {
+ signature<A>::get(iter, v);
+ }
+};
- /**
+/**
* @brief Signature helper class for marshalling const types
*/
- template < typename A >
- struct signature< const A > : signature_helper<signature<const A>>
- {
- static constexpr auto name_v = concat("const ", signature<A>::name_v);
- static constexpr auto sig_v = signature<A>::sig_v;
+template<typename A>
+struct signature<const A> : signature_helper<signature<const A>>
+{
+ static constexpr auto name_v = concat("const ", signature<A>::name_v);
+ static constexpr auto sig_v = signature<A>::sig_v;
- /**
+ /**
* @brief Marshals value v as marshalled type into message
*/
- static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
- {
- signature< A >::set(iter, v);
- }
+ static void set(const DBusWrapper::MessageIterPtr& iter, const A& v)
+ {
+ signature<A>::set(iter, v);
+ }
- /**
+ /**
* @brief Marshals value from marshalled type into variable v
*/
- static void get(const DBusWrapper::MessageIterPtr& iter, A& v)
- {
- signature< A >::get(iter, v);
- }
- };
+ static void get(const DBusWrapper::MessageIterPtr& iter, A& v)
+ {
+ signature<A>::get(iter, v);
+ }
+};
- using CallId = DBusWrapper::CallId;
+using CallId = DBusWrapper::CallId;
- template < typename ValueType >
- ValueType unpackValues(CallId callId, const DBusWrapper::MessagePtr& msg)
- {
- static const std::string sig{signature< ValueType >::sig().data()};
+template<typename ValueType>
+ValueType unpackValues(CallId callId, const DBusWrapper::MessagePtr& msg)
+{
+ static const std::string sig{signature<ValueType>::sig().data()};
- auto iter = DBUS_W->eldbus_message_iter_get_impl(msg, false);
- ValueType r;
+ auto iter = DBUS_W->eldbus_message_iter_get_impl(msg, false);
+ ValueType r;
- if (iter)
- {
- if (!signature< ValueType >::get(iter, r))
- {
- DBUS_DEBUG("ValueType is %s", signature< ValueType >::name().data());
- r = Error{ "call " + std::to_string(callId.id) + ": failed to unpack values, got signature '" +
- DBUS_W->eldbus_message_signature_get_impl(msg) + "', expected '" + sig + "'" };
- }
- }
- else
- {
- r = Error{ "call " + std::to_string(callId.id) + ": failed to get iterator" };
- }
- return r;
+ if(iter)
+ {
+ if(!signature<ValueType>::get(iter, r))
+ {
+ DBUS_DEBUG("ValueType is %s", signature<ValueType>::name().data());
+ r = Error{"call " + std::to_string(callId.id) + ": failed to unpack values, got signature '" +
+ DBUS_W->eldbus_message_signature_get_impl(msg) + "', expected '" + sig + "'"};
}
+ }
+ else
+ {
+ r = Error{"call " + std::to_string(callId.id) + ": failed to get iterator"};
+ }
+ return r;
+}
- inline void packValues_helper(const DBusWrapper::MessageIterPtr&) {}
+inline void packValues_helper(const DBusWrapper::MessageIterPtr&)
+{
+}
- template < typename A, typename... ARGS >
- void packValues_helper(const DBusWrapper::MessageIterPtr& iter, A&& a, ARGS&&... r)
- {
- signature< A >::set(iter, std::forward< A >(a));
- packValues_helper(iter, std::forward< ARGS >(r)...);
- }
+template<typename A, typename... ARGS>
+void packValues_helper(const DBusWrapper::MessageIterPtr& iter, A&& a, ARGS&&... r)
+{
+ signature<A>::set(iter, std::forward<A>(a));
+ packValues_helper(iter, std::forward<ARGS>(r)...);
+}
- template < typename... ARGS >
- void packValues(CallId callId, const DBusWrapper::MessagePtr& msg, ARGS&&... r)
- {
- auto iter = DBUS_W->eldbus_message_iter_get_impl(msg, true);
- packValues_helper(iter, std::forward< ARGS >(r)...);
- }
+template<typename... ARGS>
+void packValues(CallId callId, const DBusWrapper::MessagePtr& msg, ARGS&&... r)
+{
+ auto iter = DBUS_W->eldbus_message_iter_get_impl(msg, true);
+ packValues_helper(iter, std::forward<ARGS>(r)...);
+}
- struct ConnectionState
- {
- DBusWrapper::ConnectionPtr connection;
- DBusWrapper::ObjectPtr object;
- DBusWrapper::ProxyPtr proxy, propertiesProxy;
- };
+struct ConnectionState
+{
+ DBusWrapper::ConnectionPtr connection;
+ DBusWrapper::ObjectPtr object;
+ DBusWrapper::ProxyPtr proxy, propertiesProxy;
+};
- template < typename RETTYPE, typename... ARGS >
- RETTYPE call(CallId callId, const ConnectionState& connectionState, bool property, const std::string& funcName, const ARGS&... args)
- {
- const auto& proxy = property ? connectionState.propertiesProxy : connectionState.proxy;
- if (!proxy)
- {
- DBUS_DEBUG("call %d: not initialized", callId.id);
- return Error{ "not initialized" };
- }
+template<typename RETTYPE, typename... ARGS>
+RETTYPE call(CallId callId, const ConnectionState& connectionState, bool property, const std::string& funcName, const ARGS&... args)
+{
+ const auto& proxy = property ? connectionState.propertiesProxy : connectionState.proxy;
+ if(!proxy)
+ {
+ DBUS_DEBUG("call %d: not initialized", callId.id);
+ return Error{"not initialized"};
+ }
- DBUS_DEBUG("call %d: calling '%s'", callId.id, funcName.c_str());
- auto msg = DBUS_W->eldbus_proxy_method_call_new_impl(proxy, funcName);
- if (!msg)
- {
- DBUS_DEBUG("call %d: failed", callId.id);
- return Error{ "failed to create message" };
- }
+ DBUS_DEBUG("call %d: calling '%s'", callId.id, funcName.c_str());
+ auto msg = DBUS_W->eldbus_proxy_method_call_new_impl(proxy, funcName);
+ if(!msg)
+ {
+ DBUS_DEBUG("call %d: failed", callId.id);
+ return Error{"failed to create message"};
+ }
- detail::packValues(callId, msg, args...);
- auto reply = DBUS_W->eldbus_proxy_send_and_block_impl(proxy, msg);
- DBUS_DEBUG("call %d: calling '%s' done", callId.id, funcName.c_str());
- if (!reply)
- {
- DBUS_DEBUG("call %d: failed", callId.id);
- return Error{ "eldbus returned null as reply" };
- }
- std::string errname, errmsg;
- if (DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg))
- {
- DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str());
- return Error{ errname + ": " + errmsg };
- }
- DBUS_DEBUG("call %d: got reply with signature '%s'", callId.id,
- DBUS_W->eldbus_message_signature_get_impl(reply).c_str());
- return detail::unpackValues< RETTYPE >(callId, reply);
- }
+ detail::packValues(callId, msg, args...);
+ auto reply = DBUS_W->eldbus_proxy_send_and_block_impl(proxy, msg);
+ DBUS_DEBUG("call %d: calling '%s' done", callId.id, funcName.c_str());
+ if(!reply)
+ {
+ DBUS_DEBUG("call %d: failed", callId.id);
+ return Error{"eldbus returned null as reply"};
+ }
+ std::string errname, errmsg;
+ if(DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg))
+ {
+ DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str());
+ return Error{errname + ": " + errmsg};
+ }
+ DBUS_DEBUG("call %d: got reply with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(reply).c_str());
+ return detail::unpackValues<RETTYPE>(callId, reply);
+}
- template < typename RETTYPE, typename... ARGS >
- void asyncCall(CallId callId, const ConnectionState& connectionState,
- bool property, const std::string& funcName,
- std::function< void(RETTYPE) > callback, const ARGS&... args)
- {
- const auto& proxy = property ? connectionState.propertiesProxy : connectionState.proxy;
- if (!proxy)
- {
- DBUS_DEBUG("call %d: not initialized", callId.id);
- callback(Error{ "not initialized" });
- return;
- }
+template<typename RETTYPE, typename... ARGS>
+void asyncCall(CallId callId, const ConnectionState& connectionState, bool property, const std::string& funcName, std::function<void(RETTYPE)> callback, const ARGS&... args)
+{
+ const auto& proxy = property ? connectionState.propertiesProxy : connectionState.proxy;
+ if(!proxy)
+ {
+ DBUS_DEBUG("call %d: not initialized", callId.id);
+ callback(Error{"not initialized"});
+ return;
+ }
- auto msg = DBUS_W->eldbus_proxy_method_call_new_impl(proxy, funcName);
- if (!msg)
- {
- DBUS_DEBUG("call %d: failed", callId.id);
- callback(Error{ "failed to create message" });
- return;
- }
+ auto msg = DBUS_W->eldbus_proxy_method_call_new_impl(proxy, funcName);
+ if(!msg)
+ {
+ DBUS_DEBUG("call %d: failed", callId.id);
+ callback(Error{"failed to create message"});
+ return;
+ }
- detail::packValues(callId, msg, args...);
- auto pending = DBUS_W->eldbus_proxy_send_impl(proxy, msg, [callback, callId, proxy](const DBusWrapper::MessagePtr& reply) {
- DBUS_DEBUG("call %d: calling done", callId.id);
- if (!reply)
- {
- DBUS_DEBUG("call %d: failed", callId.id);
- callback(Error{ "eldbus returned null as reply" });
- }
- else
- {
- std::string errname, errmsg;
- if (DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg))
- {
- DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str());
- callback(Error{ errname + ": " + errmsg });
- }
- else
- {
- DBUS_DEBUG("call %d: got reply with signature '%s'", callId.id,
- DBUS_W->eldbus_message_signature_get_impl(reply).c_str());
- callback(detail::unpackValues< RETTYPE >(callId, reply));
- }
- }
- }
- );
- if (pending)
+ detail::packValues(callId, msg, args...);
+ auto pending = DBUS_W->eldbus_proxy_send_impl(proxy, msg, [callback, callId, proxy](const DBusWrapper::MessagePtr& reply) {
+ DBUS_DEBUG("call %d: calling done", callId.id);
+ if(!reply)
+ {
+ DBUS_DEBUG("call %d: failed", callId.id);
+ callback(Error{"eldbus returned null as reply"});
+ }
+ else
+ {
+ std::string errname, errmsg;
+ if(DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg))
{
- DBUS_DEBUG("call %d: call sent", callId.id);
+ DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str());
+ callback(Error{errname + ": " + errmsg});
}
else
{
- DBUS_DEBUG("call %d: failed to send call", callId.id);
- callback(Error{ "failed to send call" });
+ DBUS_DEBUG("call %d: got reply with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(reply).c_str());
+ callback(detail::unpackValues<RETTYPE>(callId, reply));
}
}
+ });
+ if(pending)
+ {
+ DBUS_DEBUG("call %d: call sent", callId.id);
+ }
+ else
+ {
+ DBUS_DEBUG("call %d: failed to send call", callId.id);
+ callback(Error{"failed to send call"});
+ }
+}
- inline void displayDebugCallInfo(CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName)
- {
- DBUS_DEBUG("call %d: %s iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str());
- }
-
- inline void displayDebugCallInfoSignal(CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName)
- {
- DBUS_DEBUG("call %d: %s signal iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str());
- }
+inline void displayDebugCallInfo(CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName)
+{
+ DBUS_DEBUG("call %d: %s iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str());
+}
- inline void displayDebugCallInfoProperty(CallId callId, const std::string& funcName, std::string info, const std::string& interfaceName,
- const std::string& propertyName)
- {
- DBUS_DEBUG("call %d: %s iname = %s pname = %s", callId.id, info.c_str(), interfaceName.c_str(), propertyName.c_str());
- }
+inline void displayDebugCallInfoSignal(CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName)
+{
+ DBUS_DEBUG("call %d: %s signal iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str());
+}
- using StringStorage = DBusWrapper::StringStorage;
+inline void displayDebugCallInfoProperty(CallId callId, const std::string& funcName, std::string info, const std::string& interfaceName, const std::string& propertyName)
+{
+ DBUS_DEBUG("call %d: %s iname = %s pname = %s", callId.id, info.c_str(), interfaceName.c_str(), propertyName.c_str());
+}
- template < typename A, typename... ARGS >
- struct EldbusArgGenerator_Helper
- {
- static void add(std::vector< std::pair<std::string, std::string> >& r)
- {
- auto s = r.size();
- auto sig = std::string{signature< A >::sig()};
- assert(!sig.empty());
- auto name = "p" + std::to_string(s + 1);
- r.push_back({ std::move(sig), std::move(name) });
- EldbusArgGenerator_Helper<ARGS...>::add(r);
- }
- };
+using StringStorage = DBusWrapper::StringStorage;
- template <>
- struct EldbusArgGenerator_Helper< void >
- {
- static void add(std::vector< std::pair<std::string, std::string> >&)
- {
- }
- };
+template<typename A, typename... ARGS>
+struct EldbusArgGenerator_Helper
+{
+ static void add(std::vector<std::pair<std::string, std::string>>& r)
+ {
+ auto s = r.size();
+ auto sig = std::string{signature<A>::sig()};
+ assert(!sig.empty());
+ auto name = "p" + std::to_string(s + 1);
+ r.push_back({std::move(sig), std::move(name)});
+ EldbusArgGenerator_Helper<ARGS...>::add(r);
+ }
+};
- template <>
- struct EldbusArgGenerator_Helper< ValueOrError< void >, void >
- {
- static void add(std::vector< std::pair<std::string, std::string> >&)
- {
- }
- };
- template <>
- struct EldbusArgGenerator_Helper< ValueOrError<>, void >
- {
- static void add(std::vector< std::pair<std::string, std::string> >&)
- {
- }
- };
+template<>
+struct EldbusArgGenerator_Helper<void>
+{
+ static void add(std::vector<std::pair<std::string, std::string>>&)
+ {
+ }
+};
- template < typename... ARGS >
- struct EldbusArgGenerator_Helper< std::tuple< ARGS... > >
- {
- static void add(std::vector< std::pair<std::string, std::string> >& r)
- {
- EldbusArgGenerator_Helper< ARGS..., void >::add(r);
- }
- };
+template<>
+struct EldbusArgGenerator_Helper<ValueOrError<void>, void>
+{
+ static void add(std::vector<std::pair<std::string, std::string>>&)
+ {
+ }
+};
+template<>
+struct EldbusArgGenerator_Helper<ValueOrError<>, void>
+{
+ static void add(std::vector<std::pair<std::string, std::string>>&)
+ {
+ }
+};
- template < typename RetType >
- struct dbus_interface_return_type_traits
- {
- using type = ValueOrError< RetType >;
- };
+template<typename... ARGS>
+struct EldbusArgGenerator_Helper<std::tuple<ARGS...>>
+{
+ static void add(std::vector<std::pair<std::string, std::string>>& r)
+ {
+ EldbusArgGenerator_Helper<ARGS..., void>::add(r);
+ }
+};
- template < typename... ARGS >
- struct dbus_interface_return_type_traits< ValueOrError< ARGS... > >
- {
- using type = ValueOrError< ARGS... >;
- };
+template<typename RetType>
+struct dbus_interface_return_type_traits
+{
+ using type = ValueOrError<RetType>;
+};
- template < typename T >
- struct dbus_interface_traits;
- template < typename RetType, typename... ARGS >
- struct dbus_interface_traits< RetType(ARGS...) >
- {
- using Ret = typename dbus_interface_return_type_traits< RetType >::type;
- using SyncCB = std::function< Ret(ARGS...) >;
- using AsyncCB = std::function< void(std::function< void(Ret) >, ARGS...) >;
- using VEArgs = ValueOrError< ARGS... >;
- };
+template<typename... ARGS>
+struct dbus_interface_return_type_traits<ValueOrError<ARGS...>>
+{
+ using type = ValueOrError<ARGS...>;
+};
- template < typename T >
- struct EldbusArgGenerator_Args;
- template < typename RetType, typename... ARGS >
- struct EldbusArgGenerator_Args< RetType(ARGS...) >
- {
- static std::string name()
- {
- return std::string{signature_tuple_helper< 0, sizeof...(ARGS), ARGS... >::name()};
- }
- static std::vector< std::pair<std::string, std::string> > get()
- {
- std::vector< std::pair<std::string, std::string> > tmp;
- EldbusArgGenerator_Helper< ARGS..., void >::add(tmp);
- return tmp;
- }
- };
+template<typename T>
+struct dbus_interface_traits;
+template<typename RetType, typename... ARGS>
+struct dbus_interface_traits<RetType(ARGS...)>
+{
+ using Ret = typename dbus_interface_return_type_traits<RetType>::type;
+ using SyncCB = std::function<Ret(ARGS...)>;
+ using AsyncCB = std::function<void(std::function<void(Ret)>, ARGS...)>;
+ using VEArgs = ValueOrError<ARGS...>;
+};
- template < typename T >
- struct EldbusArgGenerator_ReturnType;
- template < typename RetType, typename... ARGS >
- struct EldbusArgGenerator_ReturnType< RetType(ARGS...) >
- {
- static std::string name()
- {
- return std::string{signature< RetType >::name()};
- }
- static std::vector< std::pair<std::string, std::string> > get()
- {
- std::vector< std::pair<std::string, std::string> > tmp;
- EldbusArgGenerator_Helper< RetType, void >::add(tmp);
- return tmp;
- }
- };
+template<typename T>
+struct EldbusArgGenerator_Args;
+template<typename RetType, typename... ARGS>
+struct EldbusArgGenerator_Args<RetType(ARGS...)>
+{
+ static std::string name()
+ {
+ return std::string{signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name()};
+ }
+ static std::vector<std::pair<std::string, std::string>> get()
+ {
+ std::vector<std::pair<std::string, std::string>> tmp;
+ EldbusArgGenerator_Helper<ARGS..., void>::add(tmp);
+ return tmp;
+ }
+};
- template < typename T >
- struct EldbusArgGenerator_ReturnType;
- template < typename... ARGS >
- struct EldbusArgGenerator_ReturnType< void(ARGS...) >
- {
- static std::string name()
- {
- return "";
- }
- static std::vector< std::pair<std::string, std::string> > get()
- {
- return {};
- }
- };
+template<typename T>
+struct EldbusArgGenerator_ReturnType;
+template<typename RetType, typename... ARGS>
+struct EldbusArgGenerator_ReturnType<RetType(ARGS...)>
+{
+ static std::string name()
+ {
+ return std::string{signature<RetType>::name()};
+ }
+ static std::vector<std::pair<std::string, std::string>> get()
+ {
+ std::vector<std::pair<std::string, std::string>> tmp;
+ EldbusArgGenerator_Helper<RetType, void>::add(tmp);
+ return tmp;
+ }
+};
+template<typename T>
+struct EldbusArgGenerator_ReturnType;
+template<typename... ARGS>
+struct EldbusArgGenerator_ReturnType<void(ARGS...)>
+{
+ static std::string name()
+ {
+ return "";
+ }
+ static std::vector<std::pair<std::string, std::string>> get()
+ {
+ return {};
}
+};
- using ConnectionType = DBusWrapper::ConnectionType;
+} // namespace detail
- /**
+using ConnectionType = DBusWrapper::ConnectionType;
+
+/**
* @brief Class representing client's end of DBUS connection
*
* Allows calling (synchronous and asynchronous) methods on selected interface
* Allows (synchronous and asynchronous) setting / getting properties.
* Allows registering signals.
- */
- class DBusClient
- {
- struct ConnectionInfo
- {
- std::string interfaceName, busName, pathName;
- };
- public:
- /**
+ */
+class DBusClient
+{
+ struct ConnectionInfo
+ {
+ std::string interfaceName, busName, pathName;
+ };
+
+public:
+ /**
* @brief Default constructor, creates non-connected object.
*/
- DBusClient() = default;
+ DBusClient() = default;
- /**
+ /**
* @brief Connects to dbus choosen by tp, using given arguments
*
* @param bus_name name of the bus to connect to
* @param path_name object's path
* @param interface_name interface name
*/
- DBusClient(std::string busName_, std::string pathName_, std::string interfaceName_,
- ConnectionType tp);
+ DBusClient(std::string busName_, std::string pathName_, std::string interfaceName_, ConnectionType tp);
- /**
+ /**
* @brief Connects to dbus using connection conn
*
* @param bus_name name of the bus to connect to
* @param interface_name interface name
* @param conn connection object from getDBusConnectionByType call
*/
- DBusClient(std::string busName_, std::string pathName_, std::string interfaceName_,
- const DBusWrapper::ConnectionPtr& conn = {});
+ DBusClient(std::string busName_, std::string pathName_, std::string interfaceName_, const DBusWrapper::ConnectionPtr& conn = {});
- /**
+ /**
* @brief Destructor object.
*
* All signals added will be disconnected.
* All asynchronous calls will be cancelled, their callback's will be called
* with failure message.
*/
- ~DBusClient() = default;
- DBusClient(const DBusClient&) = delete;
- DBusClient(DBusClient&&) = default;
+ ~DBusClient() = default;
+ DBusClient(const DBusClient&) = delete;
+ DBusClient(DBusClient&&) = default;
- DBusClient& operator=(DBusClient&&) = default;
- DBusClient& operator=(const DBusClient&) = delete;
+ DBusClient& operator=(DBusClient&&) = default;
+ DBusClient& operator=(const DBusClient&) = delete;
- /**
+ /**
* @brief bool operator
*
* Returns true, if object is connected to DBUS
*/
- explicit operator bool() const
- {
- return bool(connectionState->proxy);
- }
+ explicit operator bool() const
+ {
+ return bool(connectionState->proxy);
+ }
- /**
+ /**
* @brief Helper class for calling a method
*
* Template type T defines both arguments sent to the method
* defines method, which takes two arguments (two floats) and return
* single value of type int.
*/
- template < typename T >
- struct Method
- {
- using RetType = typename detail::dbus_interface_traits< T >::Ret;
- const detail::ConnectionState& connectionState;
- std::string funcName;
- std::string info;
- std::shared_ptr< ConnectionInfo > connectionInfo;
+ template<typename T>
+ struct Method
+ {
+ using RetType = typename detail::dbus_interface_traits<T>::Ret;
+ const detail::ConnectionState& connectionState;
+ std::string funcName;
+ std::string info;
+ std::shared_ptr<ConnectionInfo> connectionInfo;
- /**
+ /**
* @brief Executes synchronous call on DBUS's method
*
* The function returns ValueOrError<...> object, which
*
* @param args arguments to pass to the method
*/
- template < typename... ARGS >
- RetType call(const ARGS&... args)
- {
- detail::CallId callId;
- detail::displayDebugCallInfo(callId, funcName, info, connectionInfo->interfaceName);
- return detail::call< RetType >(callId, connectionState, false, funcName, args...);
- }
+ template<typename... ARGS>
+ RetType call(const ARGS&... args)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfo(callId, funcName, info, connectionInfo->interfaceName);
+ return detail::call<RetType>(callId, connectionState, false, funcName, args...);
+ }
- /**
+ /**
* @brief Executes asynchronous call on DBUS's method
*
* The function calls callback with either received values or error message.
* @param callback callback functor, which will be called with return value(s) or error message
* @param args arguments to pass to the method
*/
- template < typename... ARGS >
- void asyncCall(std::function< void(RetType) > callback, const ARGS&... args)
- {
- detail::CallId callId;
- detail::displayDebugCallInfo(callId, funcName, info, connectionInfo->interfaceName);
- detail::asyncCall< RetType >(callId, connectionState, false, funcName, std::move(callback), args...);
- }
- };
+ template<typename... ARGS>
+ void asyncCall(std::function<void(RetType)> callback, const ARGS&... args)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfo(callId, funcName, info, connectionInfo->interfaceName);
+ detail::asyncCall<RetType>(callId, connectionState, false, funcName, std::move(callback), args...);
+ }
+ };
- /**
+ /**
* @brief Helper class for calling a property
*
* Template type T defines type of the value hidden under property.
* Note, that library automatically wraps both sent and received value into
* DBUS's wrapper type.
*/
- template < typename T >
- struct Property
- {
- using RetType = typename detail::dbus_interface_return_type_traits< T >::type;
- using VariantRetType = typename detail::dbus_interface_return_type_traits< EldbusVariant< T > >::type;
- const detail::ConnectionState& connectionState;
- std::string propName;
- std::string info;
- std::shared_ptr< ConnectionInfo > connectionInfo;
-
- /**
+ template<typename T>
+ struct Property
+ {
+ using RetType = typename detail::dbus_interface_return_type_traits<T>::type;
+ using VariantRetType = typename detail::dbus_interface_return_type_traits<EldbusVariant<T>>::type;
+ const detail::ConnectionState& connectionState;
+ std::string propName;
+ std::string info;
+ std::shared_ptr<ConnectionInfo> connectionInfo;
+
+ /**
* @brief executes synchronous get on property
*
* The function returns ValueOrError<...> object, which
* contains either received values or error message.
*/
- RetType get()
- {
- detail::CallId callId;
- detail::displayDebugCallInfoProperty(callId, "Get", info, connectionInfo->interfaceName, propName);
- auto z = detail::call< VariantRetType >(callId, connectionState, true, "Get", connectionInfo->interfaceName, propName);
- if (!z)
- return z.getError();
- return { std::get< 0 >(z.getValues()).value };
- }
+ RetType get()
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfoProperty(callId, "Get", info, connectionInfo->interfaceName, propName);
+ auto z = detail::call<VariantRetType>(callId, connectionState, true, "Get", connectionInfo->interfaceName, propName);
+ if(!z)
+ return z.getError();
+ return {std::get<0>(z.getValues()).value};
+ }
- /**
+ /**
* @brief executes asynchronous get on property
*
* The function calls callback with either received values or error message.
*
* @param callback callback functor, which will be called with return value(s) or error message
*/
- void asyncGet(std::function< void(RetType) > callback)
- {
- detail::CallId callId;
- detail::displayDebugCallInfoProperty(callId, "Get", info, connectionInfo->interfaceName, propName);
- auto cc = [callback](VariantRetType reply) {
- if (reply)
- callback(std::move(std::get< 0 >(reply.getValues()).value));
- else
- callback(reply.getError());
- };
- detail::asyncCall< VariantRetType >(callId, connectionState, true, "Get", std::move(cc), connectionInfo->interfaceName, propName);
- }
+ void asyncGet(std::function<void(RetType)> callback)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfoProperty(callId, "Get", info, connectionInfo->interfaceName, propName);
+ auto cc = [callback](VariantRetType reply) {
+ if(reply)
+ callback(std::move(std::get<0>(reply.getValues()).value));
+ else
+ callback(reply.getError());
+ };
+ detail::asyncCall<VariantRetType>(callId, connectionState, true, "Get", std::move(cc), connectionInfo->interfaceName, propName);
+ }
- /**
+ /**
* @brief executes synchronous set on property
*
* The function returns ValueOrError<void> object, with
* possible error message.
*/
- ValueOrError< void > set(const T& r)
- {
- detail::CallId callId;
- detail::displayDebugCallInfoProperty(callId, "Set", info, connectionInfo->interfaceName, propName);
- EldbusVariant< T > variantValue{ std::move(r) };
- return detail::call< ValueOrError< void > >(callId, connectionState, true, "Set", connectionInfo->interfaceName, propName, variantValue);
- }
+ ValueOrError<void> set(const T& r)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfoProperty(callId, "Set", info, connectionInfo->interfaceName, propName);
+ EldbusVariant<T> variantValue{std::move(r)};
+ return detail::call<ValueOrError<void>>(callId, connectionState, true, "Set", connectionInfo->interfaceName, propName, variantValue);
+ }
- /**
+ /**
* @brief executes asynchronous get on property
*
* The function calls callback with either received values or error message.
*
* @param callback callback functor, which will be called with return value(s) or error message
*/
- void asyncSet(std::function< void(ValueOrError< void >) > callback, const T& r)
- {
- detail::CallId callId;
- detail::displayDebugCallInfoProperty(callId, "Set", info, connectionInfo->interfaceName, propName);
- EldbusVariant< T > variantValue{ std::move(r) };
- detail::asyncCall< ValueOrError< void > >(callId, connectionState, true, "Set", std::move(callback), connectionInfo->interfaceName, propName, variantValue);
- }
- };
+ void asyncSet(std::function<void(ValueOrError<void>)> callback, const T& r)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfoProperty(callId, "Set", info, connectionInfo->interfaceName, propName);
+ EldbusVariant<T> variantValue{std::move(r)};
+ detail::asyncCall<ValueOrError<void>>(callId, connectionState, true, "Set", std::move(callback), connectionInfo->interfaceName, propName, variantValue);
+ }
+ };
- /**
+ /**
* @brief Constructs Property<...> object for calling properties
*
* The function constructs and returns proxy object for calling property.
*
* @param propName property name to set and / or query
*/
- template < typename PropertyType >
- Property< PropertyType > property(std::string propName)
- {
- return Property< PropertyType >{*connectionState, std::move(propName), info, connectionInfo};
- }
+ template<typename PropertyType>
+ Property<PropertyType> property(std::string propName)
+ {
+ return Property<PropertyType>{*connectionState, std::move(propName), info, connectionInfo};
+ }
- /**
+ /**
* @brief Constructs Method<...> object for calling methods
*
* The function constructs and returns proxy object for calling method.
*
* @param funcName function name to call
*/
- template < typename MethodType >
- Method< MethodType > method(std::string funcName)
- {
- return Method< MethodType >{*connectionState, std::move(funcName), info, connectionInfo};
- }
+ template<typename MethodType>
+ Method<MethodType> method(std::string funcName)
+ {
+ return Method<MethodType>{*connectionState, std::move(funcName), info, connectionInfo};
+ }
- /**
+ /**
* @brief Registers notification callback, when property has changed
*
* The callback will be called with new value, when property's value has changed.
* Note, that template type V must match expected type, otherwise undefined behavior will occur,
* there's no check for this.
*/
- template < typename V >
- void addPropertyChangedEvent(std::string propertyName, std::function< void(V) > callback)
- {
- detail::CallId callId;
- detail::displayDebugCallInfoSignal(callId, propertyName, info, connectionInfo->interfaceName);
- DBUS_DEBUG("call %d: adding property", callId.id);
- auto& cI = this->connectionInfo;
- DBUS_W->add_property_changed_event_listener_impl(connectionState->proxy, cI->interfaceName, propertyName,
- [callback](const _Eina_Value* newValue) {
- V val = 0;
- if (!getFromEinaValue(newValue, &val))
- {
- DBUS_DEBUG("unable to get property's value");
- return;
- }
- callback(val);
- });
- }
+ template<typename V>
+ void addPropertyChangedEvent(std::string propertyName, std::function<void(V)> callback)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfoSignal(callId, propertyName, info, connectionInfo->interfaceName);
+ DBUS_DEBUG("call %d: adding property", callId.id);
+ auto& cI = this->connectionInfo;
+ DBUS_W->add_property_changed_event_listener_impl(connectionState->proxy, cI->interfaceName, propertyName, [callback](const _Eina_Value* newValue) {
+ V val = 0;
+ if(!getFromEinaValue(newValue, &val))
+ {
+ DBUS_DEBUG("unable to get property's value");
+ return;
+ }
+ callback(val);
+ });
+ }
- /**
+ /**
* @brief Registers callback on the DBUS' signal
*
* The function registers callback signalName. When signal comes, callback will be called.
* @param signalName name of the signal to register
* @param callback callback to call
*/
- template < typename SignalType >
- void addSignal(std::string signalName, std::function< SignalType > callback)
- {
- detail::CallId callId;
- detail::displayDebugCallInfoSignal(callId, signalName, info, connectionInfo->interfaceName);
- DBUS_W->eldbus_proxy_signal_handler_add_impl(connectionState->proxy, signalName,
- [callId, callback, signalName](const DBusWrapper::MessagePtr& msg) -> void {
- std::string errname, aux;
- if (DBUS_W->eldbus_message_error_get_impl(msg, errname, aux))
- {
- DBUS_DEBUG("call %d: Eldbus error: %s %s", callId.id, errname.c_str(), aux.c_str());
- return;
- }
- DBUS_DEBUG("call %d: received signal with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(msg).c_str());
- using ParamsType = typename detail::dbus_interface_traits< SignalType >::VEArgs;
- auto params = detail::unpackValues< ParamsType >(callId, msg);
- if (!params)
- {
- DBUS_DEBUG("call %d: failed: %s", callId.id, params.getError().message.c_str());
- return;
- }
- try
- {
- std::apply(callback, params.getValues());
- }
- catch (const Dali::DaliException &e)
- {
- DBUS_DEBUG("unhandled exception");
- assert(0);
- }
- });
- }
+ template<typename SignalType>
+ void addSignal(std::string signalName, std::function<SignalType> callback)
+ {
+ detail::CallId callId;
+ detail::displayDebugCallInfoSignal(callId, signalName, info, connectionInfo->interfaceName);
+ DBUS_W->eldbus_proxy_signal_handler_add_impl(connectionState->proxy, signalName, [callId, callback, signalName](const DBusWrapper::MessagePtr& msg) -> void {
+ std::string errname, aux;
+ if(DBUS_W->eldbus_message_error_get_impl(msg, errname, aux))
+ {
+ DBUS_DEBUG("call %d: Eldbus error: %s %s", callId.id, errname.c_str(), aux.c_str());
+ return;
+ }
+ DBUS_DEBUG("call %d: received signal with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(msg).c_str());
+ using ParamsType = typename detail::dbus_interface_traits<SignalType>::VEArgs;
+ auto params = detail::unpackValues<ParamsType>(callId, msg);
+ if(!params)
+ {
+ DBUS_DEBUG("call %d: failed: %s", callId.id, params.getError().message.c_str());
+ return;
+ }
+ try
+ {
+ std::apply(callback, params.getValues());
+ }
+ catch(const Dali::DaliException& e)
+ {
+ DBUS_DEBUG("unhandled exception");
+ assert(0);
+ }
+ });
+ }
- private:
- std::unique_ptr<detail::ConnectionState> connectionState{ new detail::ConnectionState };
- std::string info;
- std::shared_ptr< ConnectionInfo > connectionInfo;
+private:
+ std::unique_ptr<detail::ConnectionState> connectionState{new detail::ConnectionState};
+ std::string info;
+ std::shared_ptr<ConnectionInfo> connectionInfo;
- static bool getFromEinaValue(const _Eina_Value* v, void* dst);
- };
+ static bool getFromEinaValue(const _Eina_Value* v, void* dst);
+};
- /**
+/**
* @brief Helper class describing DBUS's server interface
*
*/
- class DBusInterfaceDescription
- {
- friend class DBusServer;
+class DBusInterfaceDescription
+{
+ friend class DBusServer;
- public:
- using MethodInfo = DBusWrapper::MethodInfo;
- using SignalInfo = DBusWrapper::SignalInfo;
- using PropertyInfo = DBusWrapper::PropertyInfo;
- using SignalId = DBusWrapper::SignalId;
+public:
+ using MethodInfo = DBusWrapper::MethodInfo;
+ using SignalInfo = DBusWrapper::SignalInfo;
+ using PropertyInfo = DBusWrapper::PropertyInfo;
+ using SignalId = DBusWrapper::SignalId;
- /**
+ /**
* @brief Creates empty interface description with given name
*
* @param interfaceName name of the interface
*/
- DBusInterfaceDescription(std::string interfaceName);
+ DBusInterfaceDescription(std::string interfaceName);
- /**
+ /**
* @brief adds new, synchronous method to the interface
*
* When method memberName is called on DBUS, callback functor will be called
* @param memberName name of the method
* @param callback functor, which will be called
*/
- template < typename T >
- void addMethod(const std::string& memberName, typename detail::dbus_interface_traits< T >::SyncCB callback)
- {
- detail::CallId callId;
- MethodInfo mi;
- methods.push_back(std::move(mi));
- auto& z = methods.back();
- z.in = detail::EldbusArgGenerator_Args< T >::get();
- z.out = detail::EldbusArgGenerator_ReturnType< T >::get();
- z.memberName = memberName;
- DBUS_DEBUG("call %d: method %s, in %s, out %s", callId.id, memberName.c_str(),
- detail::EldbusArgGenerator_Args< T >::name().c_str(),
- detail::EldbusArgGenerator_ReturnType< T >::name().c_str());
- z.callback = construct< T >(callId, callback);
- z.id = callId;
- }
+ template<typename T>
+ void addMethod(const std::string& memberName, typename detail::dbus_interface_traits<T>::SyncCB callback)
+ {
+ detail::CallId callId;
+ MethodInfo mi;
+ methods.push_back(std::move(mi));
+ auto& z = methods.back();
+ z.in = detail::EldbusArgGenerator_Args<T>::get();
+ z.out = detail::EldbusArgGenerator_ReturnType<T>::get();
+ z.memberName = memberName;
+ DBUS_DEBUG("call %d: method %s, in %s, out %s", callId.id, memberName.c_str(), detail::EldbusArgGenerator_Args<T>::name().c_str(), detail::EldbusArgGenerator_ReturnType<T>::name().c_str());
+ z.callback = construct<T>(callId, callback);
+ z.id = callId;
+ }
- /**
+ /**
* @brief adds new, synchronous property to the interface
*
* When property memberName is called on DBUS, respective callback functor will be called
* @param getter functor, which will be called when property is being read
* @param setter functor, which will be called when property is being set
*/
- template < typename T >
- void addProperty(const std::string& memberName, std::function< ValueOrError< T >() > getter, std::function< ValueOrError< void >(T) > setter)
- {
- properties.push_back({});
- auto& z = properties.back();
- z.memberName = memberName;
- z.typeSignature = detail::signature< T >::sig();
- if (getter)
- {
- detail::CallId getterId;
- z.getterId = getterId;
- DBUS_DEBUG("call %d: property %s (get) type %s", getterId.id, memberName.c_str(), detail::signature< T >::name().data());
- z.getCallback = [=](const DBusWrapper::MessagePtr& src, const DBusWrapper::MessageIterPtr& dst) -> std::string {
+ template<typename T>
+ void addProperty(const std::string& memberName, std::function<ValueOrError<T>()> getter, std::function<ValueOrError<void>(T)> setter)
+ {
+ properties.push_back({});
+ auto& z = properties.back();
+ z.memberName = memberName;
+ z.typeSignature = detail::signature<T>::sig();
+ if(getter)
+ {
+ detail::CallId getterId;
+ z.getterId = getterId;
+ DBUS_DEBUG("call %d: property %s (get) type %s", getterId.id, memberName.c_str(), detail::signature<T>::name().data());
+ z.getCallback = [=](const DBusWrapper::MessagePtr& src, const DBusWrapper::MessageIterPtr& dst) -> std::string {
+ try
+ {
+ auto v = std::apply(getter, std::tuple<>{});
+ if(v)
+ {
+ detail::signature<T>::set(dst, std::get<0>(v.getValues()));
+ DBUS_DEBUG("call %d: success", getterId.id);
+ return "";
+ }
+ DBUS_DEBUG("call %d: failed: %s", getterId.id, v.getError().message.c_str());
+ return v.getError().message;
+ }
+ catch(std::exception& e)
+ {
+ return std::string("unhandled exception (") + e.what() + ")";
+ }
+ catch(const Dali::DaliException& e)
+ {
+ return std::string("unhandled exception (") + e.condition + ")";
+ }
+ };
+ }
+ if(setter)
+ {
+ detail::CallId setterId;
+ z.setterId = setterId;
+ DBUS_DEBUG("call %d: property %s (set) type %s", setterId.id, memberName.c_str(), detail::signature<T>::name().data());
+ z.setCallback = [=](const DBusWrapper::MessagePtr& src, const DBusWrapper::MessageIterPtr& src_iter) -> std::string {
+ std::tuple<T> value;
+ auto src_signature = DBUS_W->eldbus_message_iter_signature_get_impl(src_iter);
+ if(detail::signature<T>::get(src_iter, std::get<0>(value)))
+ {
try
{
- auto v = std::apply(getter, std::tuple<>{});
- if (v)
+ auto v = std::apply(setter, std::move(value));
+ if(v)
{
- detail::signature< T >::set(dst, std::get< 0 >(v.getValues()));
- DBUS_DEBUG("call %d: success", getterId.id);
+ DBUS_DEBUG("call %d: success", setterId.id);
return "";
}
- DBUS_DEBUG("call %d: failed: %s", getterId.id, v.getError().message.c_str());
+ DBUS_DEBUG("call %d: failed: %s", setterId.id, v.getError().message.c_str());
return v.getError().message;
}
- catch (std::exception & e)
+ catch(std::exception& e)
{
return std::string("unhandled exception (") + e.what() + ")";
}
- catch (const Dali::DaliException &e)
+ catch(const Dali::DaliException& e)
{
return std::string("unhandled exception (") + e.condition + ")";
}
- };
- }
- if (setter)
- {
- detail::CallId setterId;
- z.setterId = setterId;
- DBUS_DEBUG("call %d: property %s (set) type %s", setterId.id, memberName.c_str(), detail::signature< T >::name().data());
- z.setCallback = [=](const DBusWrapper::MessagePtr& src, const DBusWrapper::MessageIterPtr& src_iter) -> std::string {
- std::tuple< T > value;
- auto src_signature = DBUS_W->eldbus_message_iter_signature_get_impl(src_iter);
- if (detail::signature< T >::get(src_iter, std::get< 0 >(value)))
- {
- try
- {
- auto v = std::apply(setter, std::move(value));
- if (v)
- {
- DBUS_DEBUG("call %d: success", setterId.id);
- return "";
- }
- DBUS_DEBUG("call %d: failed: %s", setterId.id, v.getError().message.c_str());
- return v.getError().message;
- }
- catch (std::exception & e)
- {
- return std::string("unhandled exception (") + e.what() + ")";
- }
- catch (const Dali::DaliException &e)
- {
- return std::string("unhandled exception (") + e.condition + ")";
- }
- }
- DBUS_DEBUG("call %d: failed to unpack values, got signature '%s', expected '%s'", setterId.id,
- src_signature.c_str(), detail::signature< T >::sig().data());
- return "call " + std::to_string(setterId.id) + ": failed to unpack values, got signature '" +
- src_signature + "', expected '" + std::string{detail::signature< T >::sig()} + "'";
- };
- }
+ }
+ DBUS_DEBUG("call %d: failed to unpack values, got signature '%s', expected '%s'", setterId.id, src_signature.c_str(), detail::signature<T>::sig().data());
+ return "call " + std::to_string(setterId.id) + ": failed to unpack values, got signature '" +
+ src_signature + "', expected '" + std::string{detail::signature<T>::sig()} + "'";
+ };
}
+ }
- /**
+ /**
* @brief adds new signal to the interface
*
* Template types ARGS defines values, which will be emited with the signal
*
* @param memberName name of the method
*/
- template < typename... ARGS >
- SignalId addSignal(const std::string& memberName)
- {
- detail::CallId callId;
- signals.push_back({});
- auto& z = signals.back();
- z.memberName = memberName;
- z.args = detail::EldbusArgGenerator_Args< void(ARGS...) >::get(DBUS_W->Strings);
- z.id = callId;
- DBUS_DEBUG("call %d: signal %s", callId.id, memberName.c_str());
- return SignalId{ callId };
- }
+ template<typename... ARGS>
+ SignalId addSignal(const std::string& memberName)
+ {
+ detail::CallId callId;
+ signals.push_back({});
+ auto& z = signals.back();
+ z.memberName = memberName;
+ z.args = detail::EldbusArgGenerator_Args<void(ARGS...)>::get(DBUS_W->Strings);
+ z.id = callId;
+ DBUS_DEBUG("call %d: signal %s", callId.id, memberName.c_str());
+ return SignalId{callId};
+ }
- private:
- std::vector< MethodInfo > methods;
- std::vector< PropertyInfo > properties;
- std::vector< SignalInfo > signals;
- std::string interfaceName;
+private:
+ std::vector<MethodInfo> methods;
+ std::vector<PropertyInfo> properties;
+ std::vector<SignalInfo> signals;
+ std::string interfaceName;
- template < typename T >
- std::function< DBusWrapper::MessagePtr(const DBusWrapper::MessagePtr & msg) > construct(detail::CallId callId,
- typename detail::dbus_interface_traits< T >::SyncCB callback)
- {
- using VEArgs = typename detail::dbus_interface_traits< T >::VEArgs;
- return [=](const DBusWrapper::MessagePtr& msg) -> DBusWrapper::MessagePtr {
- DBUS_DEBUG("call %d: entering", callId.id);
- DBusWrapper::MessagePtr ret = {};
- auto args = detail::unpackValues< VEArgs >(callId, msg);
- if (args)
+ template<typename T>
+ std::function<DBusWrapper::MessagePtr(const DBusWrapper::MessagePtr& msg)> construct(detail::CallId callId,
+ typename detail::dbus_interface_traits<T>::SyncCB callback)
+ {
+ using VEArgs = typename detail::dbus_interface_traits<T>::VEArgs;
+ return [=](const DBusWrapper::MessagePtr& msg) -> DBusWrapper::MessagePtr {
+ DBUS_DEBUG("call %d: entering", callId.id);
+ DBusWrapper::MessagePtr ret = {};
+ auto args = detail::unpackValues<VEArgs>(callId, msg);
+ if(args)
+ {
+ try
{
- try
- {
- auto v = std::apply(callback, std::move(args.getValues()));
- if (v)
- {
- DBUS_DEBUG("call %d: success", callId.id);
- ret = DBUS_W->eldbus_message_method_return_new_impl(msg);
- detail::packValues(callId, ret, v);
- }
- else
- {
- DBUS_DEBUG("call %d: failed: %s", callId.id, v.getError().message.c_str());
- ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", v.getError().message);
- }
- }
- catch (std::exception & e)
+ auto v = std::apply(callback, std::move(args.getValues()));
+ if(v)
{
- auto txt = std::string("unhandled exception (") + e.what() + ")";
- DBUS_DEBUG("call %d: failed: %s", callId.id, txt.c_str());
- ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", txt);
+ DBUS_DEBUG("call %d: success", callId.id);
+ ret = DBUS_W->eldbus_message_method_return_new_impl(msg);
+ detail::packValues(callId, ret, v);
}
- catch (const Dali::DaliException &e)
+ else
{
- auto txt = std::string("unhandled exception (") + e.condition + ")";
- DBUS_DEBUG("call %d: failed: %s", callId.id, txt.c_str());
- ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", txt);
+ DBUS_DEBUG("call %d: failed: %s", callId.id, v.getError().message.c_str());
+ ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", v.getError().message);
}
}
- else
+ catch(std::exception& e)
{
- std::ostringstream err;
- err << "expected signature '" << detail::signature< VEArgs >::sig() << "', got '" << DBUS_W->eldbus_message_signature_get_impl(msg) << "'";
- auto str = err.str();
- DBUS_DEBUG("call %d: failed: %s", callId.id, str.c_str());
- ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.InvalidArgs", str);
+ auto txt = std::string("unhandled exception (") + e.what() + ")";
+ DBUS_DEBUG("call %d: failed: %s", callId.id, txt.c_str());
+ ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", txt);
}
- return ret;
- };
- }
- };
+ catch(const Dali::DaliException& e)
+ {
+ auto txt = std::string("unhandled exception (") + e.condition + ")";
+ DBUS_DEBUG("call %d: failed: %s", callId.id, txt.c_str());
+ ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", txt);
+ }
+ }
+ else
+ {
+ std::ostringstream err;
+ err << "expected signature '" << detail::signature<VEArgs>::sig() << "', got '" << DBUS_W->eldbus_message_signature_get_impl(msg) << "'";
+ auto str = err.str();
+ DBUS_DEBUG("call %d: failed: %s", callId.id, str.c_str());
+ ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.InvalidArgs", str);
+ }
+ return ret;
+ };
+ }
+};
- /**
+/**
* @brief Class representing server's end of DBUS connection
*
* Allows listening (synchronously and asynchronously) on methods on selected interface
* Allows listening (synchronously and asynchronously) on setting / getting properties.
* Allows emiting signals.
*/
- class DBusServer
- {
- public:
- /**
+class DBusServer
+{
+public:
+ /**
* @brief Constructs non-connected dbus server.
*/
- DBusServer() = default;
+ DBusServer() = default;
- /**
+ /**
* @brief Constructs dbus server on either system or user dbus connection.
*/
- DBusServer(ConnectionType tp);
+ DBusServer(ConnectionType tp);
- /**
+ /**
* @brief Constructs dbus server on connection from getDBusConnectionByType
*/
- DBusServer(const DBusWrapper::ConnectionPtr& conn);
+ DBusServer(const DBusWrapper::ConnectionPtr& conn);
- /**
+ /**
* @brief Destructor
*
* Destructor will properly destroy everything. Destructor will cancel
* pending replies.
*/
- ~DBusServer() = default;
+ ~DBusServer() = default;
- DBusServer(const DBusServer&) = delete;
- DBusServer(DBusServer&&) = default;
+ DBusServer(const DBusServer&) = delete;
+ DBusServer(DBusServer&&) = default;
- DBusServer& operator=(DBusServer&&) = default;
- DBusServer& operator=(const DBusServer&) = delete;
+ DBusServer& operator=(DBusServer&&) = default;
+ DBusServer& operator=(const DBusServer&) = delete;
- /**
+ /**
* @brief Registers interface on given path name
*
* @param pathName path object to register interface on.
* @param dscr
* @param fallback
*/
- void addInterface(const std::string& pathName, DBusInterfaceDescription& dscr, bool fallback = false);
+ void addInterface(const std::string& pathName, DBusInterfaceDescription& dscr, bool fallback = false);
- /**
+ /**
* @brief Gets bus name of the current connection (must be connected)
*/
- std::string getBusName() const;
+ std::string getBusName() const;
- /**
+ /**
* @brief Returns connection object for this dbus server object
*
* @return connection object
*/
- DBusWrapper::ConnectionPtr getConnection();
+ DBusWrapper::ConnectionPtr getConnection();
- /**
+ /**
* @brief Emits signal
*
* Emits signal based only on data passed to the function
* @param signal identifier of the signal
* @param args values to emit
*/
- template < typename... ARGS >
- void emit2(const std::string& path, const std::string& interfaceName,
- const std::string& signalName, const ARGS&... args)
- {
- auto msg = DBUS_W->eldbus_message_signal_new_impl(path, interfaceName, signalName);
- detail::CallId id;
- detail::packValues(id, msg, args...);
- DBUS_W->eldbus_connection_send_impl(connection, msg);
- }
+ template<typename... ARGS>
+ void emit2(const std::string& path, const std::string& interfaceName, const std::string& signalName, const ARGS&... args)
+ {
+ auto msg = DBUS_W->eldbus_message_signal_new_impl(path, interfaceName, signalName);
+ detail::CallId id;
+ detail::packValues(id, msg, args...);
+ DBUS_W->eldbus_connection_send_impl(connection, msg);
+ }
- /**
+ /**
* @brief Returns current object path, when handling call to property / method
*
* User can call this function from inside callback used to handle property / method calls.
* };
* \endcode
*/
- static std::string getCurrentObjectPath() { return currentObjectPath; }
+ static std::string getCurrentObjectPath()
+ {
+ return currentObjectPath;
+ }
- /**
+ /**
* @brief Returns current connection object, when handling call to property / method
*
* User can call this function from inside callback used to handle property / method calls.
* };
* \endcode
*/
- static const DBusWrapper::ConnectionPtr& getCurrentConnection() { return currentConnection; }
+ static const DBusWrapper::ConnectionPtr& getCurrentConnection()
+ {
+ return currentConnection;
+ }
- /// \cond
- class CurrentObjectSetter
+ /// \cond
+ class CurrentObjectSetter
+ {
+ public:
+ CurrentObjectSetter(DBusWrapper::ConnectionPtr con, std::string path)
{
- public:
- CurrentObjectSetter(DBusWrapper::ConnectionPtr con, std::string path)
- {
- currentObjectPath = std::move(path);
- currentConnection = std::move(con);
- }
- ~CurrentObjectSetter()
- {
- currentObjectPath = "";
- currentConnection = {};
- }
- CurrentObjectSetter(const CurrentObjectSetter&) = delete;
- CurrentObjectSetter(CurrentObjectSetter&&) = delete;
- void operator=(const CurrentObjectSetter&) = delete;
- void operator=(CurrentObjectSetter&&) = delete;
- };
-
- private:
- DBusWrapper::ConnectionPtr connection;
- struct DestructorObject {
- std::vector<std::function<void()>> destructors;
- ~DestructorObject() {
- for (auto& a : destructors) a();
- }
- };
-
- std::unique_ptr<DestructorObject> destructorObject{ new DestructorObject() };
- static thread_local std::string currentObjectPath;
- static thread_local DBusWrapper::ConnectionPtr currentConnection;
+ currentObjectPath = std::move(path);
+ currentConnection = std::move(con);
+ }
+ ~CurrentObjectSetter()
+ {
+ currentObjectPath = "";
+ currentConnection = {};
+ }
+ CurrentObjectSetter(const CurrentObjectSetter&) = delete;
+ CurrentObjectSetter(CurrentObjectSetter&&) = delete;
+ void operator=(const CurrentObjectSetter&) = delete;
+ void operator=(CurrentObjectSetter&&) = delete;
+ };
+private:
+ DBusWrapper::ConnectionPtr connection;
+ struct DestructorObject
+ {
+ std::vector<std::function<void()>> destructors;
+ ~DestructorObject()
+ {
+ for(auto& a : destructors) a();
+ }
};
- DBusWrapper::ConnectionPtr getDBusConnectionByType(ConnectionType tp);
- DBusWrapper::ConnectionPtr getDBusConnectionByName(const std::string& name);
- std::string getConnectionName(const DBusWrapper::ConnectionPtr&);
-}
+ std::unique_ptr<DestructorObject> destructorObject{new DestructorObject()};
+ static thread_local std::string currentObjectPath;
+ static thread_local DBusWrapper::ConnectionPtr currentConnection;
+};
+
+DBusWrapper::ConnectionPtr getDBusConnectionByType(ConnectionType tp);
+DBusWrapper::ConnectionPtr getDBusConnectionByName(const std::string& name);
+std::string getConnectionName(const DBusWrapper::ConnectionPtr&);
+} // namespace DBus
namespace std
{
- template < size_t INDEX, typename... ARGS >
- inline auto get(DBus::ValueOrError< ARGS... >& v) -> decltype(std::get< INDEX >(v.getValues()))&
- {
- return std::get< INDEX >(v.getValues());
- }
+template<size_t INDEX, typename... ARGS>
+inline auto get(DBus::ValueOrError<ARGS...>& v) -> decltype(std::get<INDEX>(v.getValues()))&
+{
+ return std::get<INDEX>(v.getValues());
+}
- template < size_t INDEX, typename... ARGS >
- inline auto get(const DBus::ValueOrError< ARGS... >& v) -> decltype(std::get< INDEX >(v.getValues()))
- {
- return std::get< INDEX >(v.getValues());
- }
+template<size_t INDEX, typename... ARGS>
+inline auto get(const DBus::ValueOrError<ARGS...>& v) -> decltype(std::get<INDEX>(v.getValues()))
+{
+ return std::get<INDEX>(v.getValues());
}
+} // namespace std
#endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_DBUS_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.
*
*/
-#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
#define DALI_INTERNAL_ACCESSIBILITY_COMMON_TTS_PLAYER_FACTORY_H
/*
- * 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;
namespace TtsPlayerFactory
{
-
/**
* Factory function that ought to be overriden by platform implementation.
* @return
} // namespace TtsPlayerFactory
-} // namespaceAdaptor
+} // 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/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
#define DALI_INTERNAL_ACCESSIBILITY_COMMON_TTS_PLAYER_IMPL_H
/*
- * 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
{
-
/**
* Text-to-speech player
*/
class TtsPlayer : public Dali::BaseObject
{
-
public:
-
/**
* Create a TtsPlayer with the given mode.
* This should only be called once by the Adaptor class for each given mode.
inline Internal::Adaptor::TtsPlayer& GetImplementation(Dali::TtsPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
+ DALI_ASSERT_ALWAYS(player && "TtsPlayer handle is empty");
BaseObject& handle = player.GetBaseObject();
inline const Internal::Adaptor::TtsPlayer& GetImplementation(const Dali::TtsPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "TtsPlayer handle is empty" );
+ DALI_ASSERT_ALWAYS(player && "TtsPlayer handle is empty");
const BaseObject& handle = player.GetBaseObject();
SET( adaptor_accessibility_atspi_dummy_src_files
${adaptor_accessibility_dir}/bridge/dummy-atspi.cpp
)
+
+# module: accessibility, backend: macos
+SET( adaptor_accessibility_macos_src_files
+ ${adaptor_accessibility_dir}/generic/tts-player-factory-generic.cpp
+ ${adaptor_accessibility_dir}/generic/tts-player-impl-generic.cpp
+)
/*
- * 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
#define DALI_INTERNAL_ACCESSIBILITY_GENERIC_TTS_PLAYER_IMPL_GENERIC_H
/*
- * 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 <string>
#include <memory>
+#include <string>
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/base-object.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Text-to-speech player
*/
class TtsPlayerGeneric : public Dali::Internal::Adaptor::TtsPlayer
{
-
public:
-
/**
* Create a TtsPlayer with the given mode.
* This should only be called once by the Adaptor class for each given mode.
~TtsPlayerGeneric() override;
private:
-
Dali::TtsPlayer::StateChangedSignalType mStateChangedSignal; ///< Signal emitted when the TTS state changes (non-functional, for interface compatibility).
#if defined(DEBUG_ENABLED)
/*
- * 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:
{
#define DALI_INTERNAL_ACCESSIBILITY_TIZEN_TTS_PLAYER_IMPL_TIZEN_H
/*
- * 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 <tts.h>
-#include <string>
#include <memory>
+#include <string>
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/tts-player.h>
#include <dali/internal/accessibility/common/tts-player-impl.h>
+#include <dali/public-api/adaptor-framework/tts-player.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Text-to-speech player
*/
class TtsPlayerTizen : public Dali::Internal::Adaptor::TtsPlayer
{
-
public:
-
/**
* Create a TtsPlayer with the given mode.
* This should only be called once by the Adaptor class for each given mode.
~TtsPlayerTizen() override;
private:
-
/**
* Private Constructor; see also TtsPlayer::New()
* @param mode the mode of tts-player
* @param[in] previous The previous state
* @param[in] current The current state
*/
- void EmitStateChangedSignal( tts_state_e previous, tts_state_e current );
+ void EmitStateChangedSignal(tts_state_e previous, tts_state_e current);
/**
* Called when the state of TTS is changed.
* @param[in] current A current state
* @param[in] userData The user data passed from the callback registration function.
*/
- static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData);
+ static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void* userData);
// Undefined
TtsPlayerTizen(const TtsPlayerTizen&);
TtsPlayerTizen& operator=(TtsPlayerTizen&);
private:
-
Dali::TtsPlayer::StateChangedSignalType mStateChangedSignal; ///< Signal emitted when the TTS state changes
- bool mInitialized; ///< Whether the TTS player is initialised successfully or not
- std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
- tts_h mTtsHandle; ///< The handle of TTS
- int mUtteranceId; ///< The utterance ID
+ bool mInitialized; ///< Whether the TTS player is initialised successfully or not
+ std::string mUnplayedString; ///< The text that can not be played because tts engine is not yet initialized
+ tts_h mTtsHandle; ///< The handle of TTS
+ int mUtteranceId; ///< The utterance ID
Dali::TtsPlayer::Mode mTtsMode; ///< The current mode of tts engine
/*
- * 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
#define DALI_FILE_LOADER_IMPL_GENERIC_H
/*
- * 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 = Dali::FileLoader::BINARY);
int ReadFile(const std::string& filename, Dali::Vector<uint8_t>& memblock, Dali::FileLoader::FileType fileType = Dali::FileLoader::BINARY);
std::streampos GetFileSize(const std::string& filename);
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_FILE_LOADER_IMPL_GENERIC_H
#define DALI_FILE_STREAM_IMPL_GENERIC_H
/*
- * 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
{
-
class FileStream::Impl
{
public:
private:
std::string mFileName;
- uint8_t mMode;
- uint8_t* mBuffer; // external buffer, not owned
- size_t mDataSize;
+ uint8_t mMode;
+ uint8_t* mBuffer; // external buffer, not owned
+ size_t mDataSize;
Dali::Vector<char> mFileBuffer; // for internal usage only
- FILE* mFile;
- std::fstream mFileStream;
- std::stringstream mBufferStream;
+ FILE* mFile;
+ std::fstream mFileStream;
+ std::stringstream mBufferStream;
};
-} // Dali
+} // namespace Dali
#endif // DALI_FILE_STREAM_IMPL_GENERIC_H
/*
- * 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;
}
#define DALI_INTEGRATION_ANDROID_FRAMEWORK_IMPL_H
/*
- * 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
{
-
/// Android application events
enum
{
/**
* @copydoc Dali::Integration::AndroidFramework::SetNativeApplication()
*/
- void SetNativeApplication( android_app* application );
+ void SetNativeApplication(android_app* application);
/**
* @copydoc Dali::Integration::AndroidFramework::GetNativeApplication()
/**
* @copydoc Dali::Integration::AndroidFramework::SetJVM()
*/
- void SetJVM( JavaVM* jvm );
+ void SetJVM(JavaVM* jvm);
/**
* @copydoc Dali::Integration::AndroidFramework::GetJVM()
/**
* @copydoc Dali::Integration::AndroidFramework::SetApplicationAssets()
*/
- void SetApplicationAssets( AAssetManager* assets );
+ void SetApplicationAssets(AAssetManager* assets);
/**
* @copydoc Dali::Integration::AndroidFramework::GetApplicationAssets()
/**
* copydoc Dali::Integration::AndroidFramework::SetInternalDataPath()
*/
- void SetInternalDataPath( const std::string& path );
+ void SetInternalDataPath(const std::string& path);
/**
* copydoc Dali::Integration::AndroidFramework::GetInternalDataPath()
/**
* @copydoc Dali::Integration::AndroidFramework::SetApplicationConfiguration()
*/
- void SetApplicationConfiguration( AConfiguration* configuration );
+ void SetApplicationConfiguration(AConfiguration* configuration);
/**
* @copydoc Dali::Integration::AndroidFramework::GetApplicationConfiguration()
/**
* @copydoc Dali::Integration::AndroidFramework::SetApplicationWindow()
*/
- void SetApplicationWindow( ANativeWindow* window );
+ void SetApplicationWindow(ANativeWindow* window);
/**
* @copydoc Dali::Integration::AndroidFramework::GetApplicationWindow()
/**
* @copydoc Dali::Integration::AndroidFramework::OnWindowCreated()
*/
- void OnWindowCreated( ANativeWindow* window );
+ void OnWindowCreated(ANativeWindow* window);
/**
* @copydoc Dali::Integration::AndroidFramework::OnWindowDestroyed()
*/
- void OnWindowDestroyed( ANativeWindow* window );
+ void OnWindowDestroyed(ANativeWindow* window);
/**
* @copydoc Dali::Integration::AndroidFramework::Get()
/**
* @brief Sets an internal framework.
*/
- void SetFramework( Framework* framework ) { mFramework = framework; }
+ void SetFramework(Framework* framework)
+ {
+ mFramework = framework;
+ }
/**
* @brief Gets an internal framework.
*
* @return a pointer to the internal framework
*/
- Framework* GetFramework() { return mFramework; }
+ Framework* GetFramework()
+ {
+ return mFramework;
+ }
/**
* Virtual destructor.
virtual ~AndroidFramework();
// Not copyable or movable
- AndroidFramework( const AndroidFramework& ) = delete; ///< Deleted copy constructor
- AndroidFramework( AndroidFramework&& ) = delete; ///< Deleted move constructor
- AndroidFramework& operator=( const AndroidFramework& ) = delete; ///< Deleted copy assignment operator
- AndroidFramework& operator=( AndroidFramework&& ) = delete; ///< Deleted move assignment operator
+ AndroidFramework(const AndroidFramework&) = delete; ///< Deleted copy constructor
+ AndroidFramework(AndroidFramework&&) = delete; ///< Deleted move constructor
+ AndroidFramework& operator=(const AndroidFramework&) = delete; ///< Deleted copy assignment operator
+ AndroidFramework& operator=(AndroidFramework&&) = delete; ///< Deleted move assignment operator
private:
- AndroidFramework( Dali::Integration::AndroidFramework* androidFramework );
+ AndroidFramework(Dali::Integration::AndroidFramework* androidFramework);
Dali::Integration::AndroidFramework* mAndroidFramework;
- Framework* mFramework;
+ Framework* mFramework;
- android_app* mNativeApplication;
- ANativeWindow* mWindow;
- AAssetManager* mAssets;
- std::string mInternalDataPath;
+ android_app* mNativeApplication;
+ ANativeWindow* mWindow;
+ AAssetManager* mAssets;
+ std::string mInternalDataPath;
AConfiguration* mConfiguration;
- JavaVM* mJVM;
+ JavaVM* mJVM;
public:
- static AndroidFramework& GetImplementation( Dali::Integration::AndroidFramework& androidFramework ) { return *androidFramework.mImpl; }
- static Framework& GetFramework( Dali::Integration::AndroidFramework& androidFramework ) { return *androidFramework.mImpl->mFramework; }
+ static AndroidFramework& GetImplementation(Dali::Integration::AndroidFramework& androidFramework)
+ {
+ return *androidFramework.mImpl;
+ }
+ static Framework& GetFramework(Dali::Integration::AndroidFramework& androidFramework)
+ {
+ return *androidFramework.mImpl->mFramework;
+ }
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTEGRATION_ANDROID_FRAMEWORK_IMPL_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.
#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/integration-api/debug.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/actors/layer.h>
#include <dali/public-api/events/key-event.h>
-#include <dali/devel-api/events/key-event-devel.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);
}
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
+/// Recursively removes constraints from an actor and all it's children.
+void RemoveAllConstraints(Dali::Actor actor)
+{
+ if(actor)
+ {
+ const auto childCount = actor.GetChildCount();
+ for(auto i = 0u; i < childCount; ++i)
+ {
+ Dali::Actor child = actor.GetChildAt(i);
+ RemoveAllConstraints(child);
+ }
+ actor.RemoveConstraints();
+ }
+}
+
+/// Removes constraints from all actors in all windows.
+void RemoveAllConstraints(const Dali::WindowContainer& windows)
+{
+ for(auto& window : windows)
+ {
+ RemoveAllConstraints(window.GetRootLayer());
+ }
+}
+
} // Unnamed namespace
/**
*/
struct Framework::Impl
{
-
struct IdleCallback
{
- int timestamp;
- int timeout;
- int id;
+ int timestamp;
+ int timeout;
+ int id;
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 )
+ 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)
{
}
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 );
-
- switch ( action & AMOTION_EVENT_ACTION_MASK )
+ 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)
{
- 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_RESET:
+ {
mObserver.OnReset();
break;
+ }
case APP_RESUME:
+ {
mObserver.OnResume();
adaptor = &Dali::Adaptor::Get();
adaptor->Resume();
break;
+ }
case APP_WINDOW_DESTROYED:
- mObserver.OnSurfaceDestroyed( data );
+ {
+ mObserver.OnSurfaceDestroyed(data);
break;
+ }
case APP_PAUSE:
+ {
adaptor = &Dali::Adaptor::Get();
adaptor->Pause();
mObserver.OnPause();
break;
+ }
case APP_LANGUAGE_CHANGE:
+ {
mObserver.OnLanguageChanged();
break;
+ }
case APP_DESTROYED:
+ {
+ adaptor = &Dali::Adaptor::Get();
+ // Need to remove constraints before Terminate is called as the constraint function
+ // can be destroyed before the constraints get a chance to clean up.
+ RemoveAllConstraints(adaptor->GetWindows());
mObserver.OnTerminate();
mInitialised = false;
break;
+ }
default:
+ {
break;
+ }
}
return 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.
#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) 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/adaptor/common/adaptor-builder-impl.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/internal/graphics/gles/egl-graphics-factory.h>
#include <dali/internal/window-system/common/display-utils.h>
-
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-AdaptorBuilder::AdaptorBuilder()
+AdaptorBuilder::AdaptorBuilder(EnvironmentOptions& environmentOptions)
+: mEnvironmentOptions(environmentOptions)
{
// Construct Graphics Factory
- mGraphicsFactory = Utils::MakeUnique< GraphicsFactory >();
+ mGraphicsFactory = Utils::MakeUnique<GraphicsFactory>(environmentOptions);
}
GraphicsFactory& AdaptorBuilder::GetGraphicsFactory() const
#define DALI_INTERNAL_ADAPTOR_BUILDER_IMPL_H
/*
- * 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 INCLUDES
-#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/graphics/gles/egl-graphics-factory.h>
-
+#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of the Adaptor Builder class.
*/
class AdaptorBuilder
{
public:
-
/**
* Constructor
*/
- AdaptorBuilder();
-
+ AdaptorBuilder(EnvironmentOptions& environmentOptions);
/**
* Destructor
*/
- ~AdaptorBuilder() {};
-
+ ~AdaptorBuilder(){};
public:
-
/**
* @return reference to the GraphicsFactory object
*/
GraphicsFactory& GetGraphicsFactory() const;
-
private:
// Eliminate copy and assigned operations
AdaptorBuilder(const AdaptorBuilder&) = delete;
AdaptorBuilder& operator=(AdaptorBuilder&) = delete;
-
private:
- std::unique_ptr< GraphicsFactory > mGraphicsFactory; ///< GraphicsFactory object
-
+ std::unique_ptr<GraphicsFactory> mGraphicsFactory; ///< GraphicsFactory object
+ EnvironmentOptions& mEnvironmentOptions;
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_BUILDER_IMPL_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.
*/
// CLASS HEADER
+#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/addons/common/addon-manager-impl.h>
#include <dali/internal/addons/common/addon-manager-factory.h>
-#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
+#include <dali/internal/addons/common/addon-manager-impl.h>
// EXTERNAL INCLUDES
-#include <errno.h>
-#include <sys/stat.h>
-#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/object/any.h>
-#include <dali/public-api/object/object-registry.h>
-#include <dali/public-api/events/wheel-event.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/common/stage.h>
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/core.h>
+#include <dali/integration-api/addon-manager.h>
#include <dali/integration-api/context-notifier.h>
-#include <dali/integration-api/profiling.h>
-#include <dali/integration-api/input-options.h>
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/debug.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/wheel-event-integ.h>
+#include <dali/integration-api/input-options.h>
#include <dali/integration-api/processor-interface.h>
-#include <dali/integration-api/addon-manager.h>
+#include <dali/integration-api/profiling.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/events/wheel-event.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/object-registry.h>
+#include <errno.h>
+#include <sys/stat.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
-#include <dali/internal/system/common/thread-controller.h>
-#include <dali/internal/system/common/performance-interface-factory.h>
#include <dali/internal/adaptor/common/lifecycle-observer.h>
#include <dali/internal/adaptor/common/thread-controller-interface.h>
+#include <dali/internal/system/common/performance-interface-factory.h>
+#include <dali/internal/system/common/thread-controller.h>
+#include <dali/public-api/dali-adaptor-common.h>
#include <dali/internal/graphics/gles/egl-graphics-factory.h>
#include <dali/internal/graphics/gles/egl-graphics.h> // Temporary until Core is abstracted
#include <dali/devel-api/text-abstraction/font-client.h>
-#include <dali/internal/system/common/callback-manager.h>
#include <dali/internal/accessibility/common/tts-player-impl.h>
-#include <dali/internal/window-system/common/event-handler.h>
-#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
-#include <dali/internal/graphics/gles/gl-implementation.h>
-#include <dali/internal/graphics/gles/egl-sync-implementation.h>
-#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/clipboard/common/clipboard-impl.h>
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+#include <dali/internal/graphics/gles/egl-sync-implementation.h>
+#include <dali/internal/graphics/gles/gl-implementation.h>
+#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
+#include <dali/internal/system/common/callback-manager.h>
#include <dali/internal/system/common/object-profiler.h>
#include <dali/internal/window-system/common/display-connection.h>
#include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
+#include <dali/internal/window-system/common/event-handler.h>
#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
#include <dali/internal/system/common/logging.h>
-#include <dali/internal/system/common/locale-utils.h>
#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
#include <dali/internal/imaging/common/image-loader.h>
+#include <dali/internal/system/common/locale-utils.h>
#include <dali/internal/system/common/configuration-manager.h>
#include <dali/internal/system/common/environment-variables.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
} // unnamed namespace
-Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode )
+Dali::Adaptor* Adaptor::New(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode)
{
Dali::Adaptor* adaptor = new Dali::Adaptor;
- Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions, threadMode );
- adaptor->mImpl = impl;
+ Adaptor* impl = new Adaptor(window, *adaptor, surface, environmentOptions, threadMode);
+ adaptor->mImpl = impl;
- Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder();
- auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
+ Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder(*environmentOptions);
+ auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
- impl->Initialize( graphicsFactory );
+ impl->Initialize(graphicsFactory);
delete mAdaptorBuilder; // Not needed anymore as the graphics interface has now been created
return adaptor;
}
-Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New(Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions)
{
- Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window );
- Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), environmentOptions, ThreadMode::NORMAL );
- windowImpl.SetAdaptor( *adaptor );
+ Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation(window);
+ Dali::Adaptor* adaptor = New(window, windowImpl.GetSurface(), environmentOptions, ThreadMode::NORMAL);
+ windowImpl.SetAdaptor(*adaptor);
return adaptor;
}
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode )
+Dali::Adaptor* Adaptor::New(GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode)
{
- Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
- Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions, threadMode ); // Impl adaptor
- adaptor->mImpl = impl;
+ Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
+ Adaptor* impl = new Adaptor(window, *adaptor, surface, environmentOptions, threadMode); // Impl adaptor
+ adaptor->mImpl = impl;
- impl->Initialize( graphicsFactory );
+ impl->Initialize(graphicsFactory);
return adaptor;
} // Called second
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New(GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions)
{
- Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window );
- Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), environmentOptions, ThreadMode::NORMAL );
- windowImpl.SetAdaptor( *adaptor );
+ Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation(window);
+ Dali::Adaptor* adaptor = New(graphicsFactory, window, windowImpl.GetSurface(), environmentOptions, ThreadMode::NORMAL);
+ windowImpl.SetAdaptor(*adaptor);
return adaptor;
} // Called first
-void Adaptor::Initialize( GraphicsFactory& graphicsFactory )
+void Adaptor::Initialize(GraphicsFactory& graphicsFactory)
{
// all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
- Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
- mEnvironmentOptions->SetLogFunction( logFunction );
+ Dali::Integration::Log::LogFunction logFunction(Dali::TizenPlatform::LogMessage);
+ mEnvironmentOptions->SetLogFunction(logFunction);
mEnvironmentOptions->InstallLogFunction(); // install logging for main thread
mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
std::string path;
- GetDataStoragePath( path );
- mPlatformAbstraction->SetDataStoragePath( path );
+ GetDataStoragePath(path);
+ mPlatformAbstraction->SetDataStoragePath(path);
- if( mEnvironmentOptions->PerformanceServerRequired() )
+ if(mEnvironmentOptions->PerformanceServerRequired())
{
- mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
+ mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface(*this, *mEnvironmentOptions);
}
- mEnvironmentOptions->CreateTraceManager( mPerformanceInterface );
+ mEnvironmentOptions->CreateTraceManager(mPerformanceInterface);
mEnvironmentOptions->InstallTraceFunction(); // install tracing for main thread
mCallbackManager = CallbackManager::New();
Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front();
- DALI_ASSERT_DEBUG( defaultWindow->GetSurface() && "Surface not initialized" );
-
- mGraphics = std::unique_ptr< GraphicsInterface >( &graphicsFactory.Create() );
- mGraphics->Initialize( mEnvironmentOptions );
-
- GraphicsInterface* graphics = mGraphics.get(); // This interface is temporary until Core has been updated to match
- auto eglGraphics = static_cast<EglGraphics *>( graphics );
+ DALI_ASSERT_DEBUG(defaultWindow->GetSurface() && "Surface not initialized");
- // This will only be created once
- eglGraphics->Create();
-
- GlImplementation& mGLES = eglGraphics->GetGlesInterface();
- EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation();
- EglContextHelperImplementation& eglContextHelperImpl = eglGraphics->GetContextHelperImplementation();
+ mGraphics = std::unique_ptr<GraphicsInterface>(&graphicsFactory.Create());
// Create the AddOnManager
- mAddOnManager.reset( Dali::Internal::AddOnManagerFactory::CreateAddOnManager() );
-
- mCore = Integration::Core::New( *this,
- *mPlatformAbstraction,
- mGLES,
- eglSyncImpl,
- eglContextHelperImpl,
- ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
- mGraphics->GetDepthBufferRequired(),
- mGraphics->GetStencilBufferRequired(),
- mGraphics->GetPartialUpdateRequired() );
+ mAddOnManager.reset(Dali::Internal::AddOnManagerFactory::CreateAddOnManager());
+ mCore = Integration::Core::New(*this,
+ *mPlatformAbstraction,
+ mGraphics->GetController(),
+ (0u != mEnvironmentOptions->GetRenderToFboInterval()) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
+ mGraphics->GetDepthBufferRequired(),
+ mGraphics->GetStencilBufferRequired(),
+ mGraphics->GetPartialUpdateRequired());
- defaultWindow->SetAdaptor( Get() );
+ defaultWindow->SetAdaptor(Get());
- Dali::Integration::SceneHolder defaultSceneHolder( defaultWindow );
+ Dali::Integration::SceneHolder defaultSceneHolder(defaultWindow);
- mWindowCreatedSignal.Emit( defaultSceneHolder );
+ mWindowCreatedSignal.Emit(defaultSceneHolder);
const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
- if( 0u < timeInterval )
+ if(0u < timeInterval)
{
- mObjectProfiler = new ObjectProfiler( mCore->GetObjectRegistry(), timeInterval );
+ mObjectProfiler = new ObjectProfiler(mCore->GetObjectRegistry(), timeInterval);
}
- mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
+ mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &Adaptor::ProcessCoreEvents), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
- mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow->GetSurface()->GetSurfaceType() );
+ mDisplayConnection = Dali::DisplayConnection::New(*mGraphics, defaultWindow->GetSurface()->GetSurfaceType());
- mThreadController = new ThreadController( *this, *mEnvironmentOptions, mThreadMode );
+ mThreadController = new ThreadController(*this, *mEnvironmentOptions, mThreadMode);
// Should be called after Core creation
- if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
+ if(mEnvironmentOptions->GetPanGestureLoggingLevel())
{
- Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
+ Integration::EnableProfiling(Dali::Integration::PROFILING_TYPE_PAN_GESTURE);
}
- if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
+ if(mEnvironmentOptions->GetPanGesturePredictionMode() >= 0)
{
Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
}
- if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
+ if(mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0)
{
Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
}
- if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0)
{
Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
}
- if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0)
{
Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
}
- if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
+ if(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0)
{
Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
}
- if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0)
{
Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
}
- if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
+ if(mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f)
{
Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
}
- if( mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0)
{
- Integration::SetPanGestureUseActualTimes( mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false );
+ Integration::SetPanGestureUseActualTimes(mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false);
}
- if( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0)
{
- Integration::SetPanGestureInterpolationTimeRange( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() );
+ Integration::SetPanGestureInterpolationTimeRange(mEnvironmentOptions->GetPanGestureInterpolationTimeRange());
}
- if( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0)
{
- Integration::SetPanGestureScalarOnlyPredictionEnabled( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false );
+ Integration::SetPanGestureScalarOnlyPredictionEnabled(mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false);
}
- if( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0)
{
- Integration::SetPanGestureTwoPointPredictionEnabled( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false );
+ Integration::SetPanGestureTwoPointPredictionEnabled(mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false);
}
- if( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0)
{
- Integration::SetPanGestureTwoPointInterpolatePastTime( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() );
+ Integration::SetPanGestureTwoPointInterpolatePastTime(mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime());
}
- if( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f )
+ if(mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f)
{
- Integration::SetPanGestureTwoPointVelocityBias( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() );
+ Integration::SetPanGestureTwoPointVelocityBias(mEnvironmentOptions->GetPanGestureTwoPointVelocityBias());
}
- if( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f )
+ if(mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f)
{
- Integration::SetPanGestureTwoPointAccelerationBias( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() );
+ Integration::SetPanGestureTwoPointAccelerationBias(mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias());
}
- if( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0 )
+ if(mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0)
{
- Integration::SetPanGestureMultitapSmoothingRange( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() );
+ Integration::SetPanGestureMultitapSmoothingRange(mEnvironmentOptions->GetPanGestureMultitapSmoothingRange());
}
- if( mEnvironmentOptions->GetMinimumPanDistance() >= 0 )
+ if(mEnvironmentOptions->GetMinimumPanDistance() >= 0)
{
- Integration::SetPanGestureMinimumDistance( mEnvironmentOptions->GetMinimumPanDistance() );
+ Integration::SetPanGestureMinimumDistance(mEnvironmentOptions->GetMinimumPanDistance());
}
- if( mEnvironmentOptions->GetMinimumPanEvents() >= 0 )
+ if(mEnvironmentOptions->GetMinimumPanEvents() >= 0)
{
- Integration::SetPanGestureMinimumPanEvents( mEnvironmentOptions->GetMinimumPanEvents() );
+ Integration::SetPanGestureMinimumPanEvents(mEnvironmentOptions->GetMinimumPanEvents());
}
- if( mEnvironmentOptions->GetMinimumPinchDistance() >= 0 )
+ if(mEnvironmentOptions->GetMinimumPinchDistance() >= 0)
{
- Integration::SetPinchGestureMinimumDistance( mEnvironmentOptions->GetMinimumPinchDistance() );
+ Integration::SetPinchGestureMinimumDistance(mEnvironmentOptions->GetMinimumPinchDistance());
}
- if( mEnvironmentOptions->GetMinimumPinchTouchEvents() >= 0 )
+ if(mEnvironmentOptions->GetMinimumPinchTouchEvents() >= 0)
{
- Integration::SetPinchGestureMinimumTouchEvents( mEnvironmentOptions->GetMinimumPinchTouchEvents() );
+ Integration::SetPinchGestureMinimumTouchEvents(mEnvironmentOptions->GetMinimumPinchTouchEvents());
}
- if( mEnvironmentOptions->GetMinimumPinchTouchEventsAfterStart() >= 0 )
+ if(mEnvironmentOptions->GetMinimumPinchTouchEventsAfterStart() >= 0)
{
- Integration::SetPinchGestureMinimumTouchEventsAfterStart( mEnvironmentOptions->GetMinimumPinchTouchEventsAfterStart() );
+ Integration::SetPinchGestureMinimumTouchEventsAfterStart(mEnvironmentOptions->GetMinimumPinchTouchEventsAfterStart());
}
- if( mEnvironmentOptions->GetMinimumRotationTouchEvents() >= 0 )
+ if(mEnvironmentOptions->GetMinimumRotationTouchEvents() >= 0)
{
- Integration::SetRotationGestureMinimumTouchEvents( mEnvironmentOptions->GetMinimumRotationTouchEvents() );
+ Integration::SetRotationGestureMinimumTouchEvents(mEnvironmentOptions->GetMinimumRotationTouchEvents());
}
- if( mEnvironmentOptions->GetMinimumRotationTouchEventsAfterStart() >= 0 )
+ if(mEnvironmentOptions->GetMinimumRotationTouchEventsAfterStart() >= 0)
{
- Integration::SetRotationGestureMinimumTouchEventsAfterStart( mEnvironmentOptions->GetMinimumRotationTouchEventsAfterStart() );
+ Integration::SetRotationGestureMinimumTouchEventsAfterStart(mEnvironmentOptions->GetMinimumRotationTouchEventsAfterStart());
}
- if( mEnvironmentOptions->GetLongPressMinimumHoldingTime() >= 0 )
+ if(mEnvironmentOptions->GetLongPressMinimumHoldingTime() >= 0)
{
- Integration::SetLongPressMinimumHoldingTime( mEnvironmentOptions->GetLongPressMinimumHoldingTime() );
+ Integration::SetLongPressMinimumHoldingTime(mEnvironmentOptions->GetLongPressMinimumHoldingTime());
}
std::string systemCachePath = GetSystemCachePath();
- if( ! systemCachePath.empty() )
+ if(!systemCachePath.empty())
{
- const int dir_err = mkdir( systemCachePath.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH );
- if ( 0 != dir_err && errno != EEXIST )
+ const int dir_err = mkdir(systemCachePath.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if(0 != dir_err && errno != EEXIST)
{
- DALI_LOG_ERROR( "Error creating system cache directory: %s!\n", systemCachePath.c_str() );
- exit( 1 );
+ DALI_LOG_ERROR("Error creating system cache directory: %s!\n", systemCachePath.c_str());
+ exit(1);
}
}
- mConfigurationManager = Utils::MakeUnique<ConfigurationManager>( systemCachePath, eglGraphics, mThreadController );
+ mConfigurationManager = Utils::MakeUnique<ConfigurationManager>(systemCachePath, mGraphics.get(), mThreadController);
auto appName = GetApplicationPackageName();
- auto bridge = Accessibility::Bridge::GetCurrentBridge();
- bridge->SetApplicationName( appName );
+ auto bridge = Accessibility::Bridge::GetCurrentBridge();
+ bridge->SetApplicationName(appName);
bridge->Initialize();
- Dali::Stage::GetCurrent().KeyEventSignal().Connect( &accessibilityObserver, &AccessibilityObserver::OnAccessibleKeyEvent );
+ Dali::Stage::GetCurrent().KeyEventSignal().Connect(&accessibilityObserver, &AccessibilityObserver::OnAccessibleKeyEvent);
}
-void Adaptor::AccessibilityObserver::OnAccessibleKeyEvent( const Dali::KeyEvent& event )
+void Adaptor::AccessibilityObserver::OnAccessibleKeyEvent(const Dali::KeyEvent& event)
{
Accessibility::KeyEventType type;
- if( event.GetState() == Dali::KeyEvent::DOWN )
+ if(event.GetState() == Dali::KeyEvent::DOWN)
{
type = Accessibility::KeyEventType::KEY_PRESSED;
}
- else if( event.GetState() == Dali::KeyEvent::UP )
+ else if(event.GetState() == Dali::KeyEvent::UP)
{
type = Accessibility::KeyEventType::KEY_RELEASED;
}
{
return;
}
- Dali::Accessibility::Bridge::GetCurrentBridge()->Emit( type, event.GetKeyCode(), event.GetKeyName(), event.GetTime(), !event.GetKeyString().empty() );
+ Dali::Accessibility::Bridge::GetCurrentBridge()->Emit(type, event.GetKeyCode(), event.GetKeyName(), event.GetTime(), !event.GetKeyString().empty());
}
Adaptor::~Adaptor()
// set to NULL first as we do not want any access to Adaptor as it is being destroyed.
gThreadLocalAdaptor = NULL;
- 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)->OnDestroy();
}
Dali::Integration::Log::UninstallLogFunction();
// Delete environment options if we own it
- if( mEnvironmentOptionsOwned )
+ if(mEnvironmentOptionsOwned)
{
delete mEnvironmentOptions;
}
void Adaptor::Start()
{
// It doesn't support restart after stop at this moment to support restarting, need more testing
- if( READY != mState )
+ if(READY != mState)
{
return;
}
unsigned int dpiHor, dpiVer;
dpiHor = dpiVer = 0;
- defaultWindow->GetSurface()->GetDpi( dpiHor, dpiVer );
+ defaultWindow->GetSurface()->GetDpi(dpiHor, dpiVer);
// set the DPI value for font rendering
FontClient fontClient = FontClient::Get();
- fontClient.SetDpi( dpiHor, dpiVer );
+ fontClient.SetDpi(dpiHor, dpiVer);
// Initialize the thread controller
mThreadController->Initialize();
// Set max texture size
- if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
+ if(mEnvironmentOptions->GetMaxTextureSize() > 0)
{
- Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
+ Dali::TizenPlatform::ImageLoader::SetMaxTextureSize(mEnvironmentOptions->GetMaxTextureSize());
}
else
{
unsigned int maxTextureSize = mConfigurationManager->GetMaxTextureSize();
- Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( maxTextureSize );
+ Dali::TizenPlatform::ImageLoader::SetMaxTextureSize(maxTextureSize);
}
- // Set cached isAdvancedBlendEquationSupported
- GraphicsInterface* graphics = mGraphics.get(); // This interface is temporary until Core has been updated to match
- auto eglGraphics = static_cast<EglGraphics *>( graphics );
- GlImplementation& mGLES = eglGraphics->GetGlesInterface();
- mGLES.SetIsAdvancedBlendEquationSupported( mConfigurationManager->IsAdvancedBlendEquationSupported() );
- mGLES.SetShadingLanguageVersion( mConfigurationManager->GetShadingLanguageVersion() );
+ // cache advanced blending and shader language version
+ mGraphics->CacheConfigurations(*mConfigurationManager.get());
ProcessCoreEvents(); // Ensure any startup messages are processed.
// Initialize the image loader plugin
Internal::Adaptor::ImageLoaderPluginProxy::Initialize();
- 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)->OnStart();
}
- if (mAddOnManager)
+ if(mAddOnManager)
{
mAddOnManager->Start();
}
void Adaptor::Pause()
{
// Only pause the adaptor if we're actually running.
- if( RUNNING == mState )
+ if(RUNNING == mState)
{
// Inform observers that we are about to be paused.
- 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)->OnPause();
}
// Extensions
- if (mAddOnManager)
+ if(mAddOnManager)
{
mAddOnManager->Pause();
}
// Pause all windows event handlers when adaptor paused
- for( auto window : mWindows )
+ for(auto window : mWindows)
{
window->Pause();
}
// Ensure any messages queued during pause callbacks are processed by doing another update.
RequestUpdateOnce();
- DALI_LOG_RELEASE_INFO( "Adaptor::Pause: Paused\n" );
+ DALI_LOG_RELEASE_INFO("Adaptor::Pause: Paused\n");
}
else
{
- DALI_LOG_RELEASE_INFO( "Adaptor::Pause: Not paused [%d]\n", mState );
+ DALI_LOG_RELEASE_INFO("Adaptor::Pause: Not paused [%d]\n", mState);
}
}
void Adaptor::Resume()
{
// Only resume the adaptor if we are in the suspended state.
- if( PAUSED == mState )
+ if(PAUSED == mState)
{
mState = RUNNING;
// Reset the event handlers when adaptor resumed
- for( auto window : mWindows )
+ for(auto window : mWindows)
{
window->Resume();
}
// Resume AddOnManager
- if (mAddOnManager)
+ if(mAddOnManager)
{
mAddOnManager->Resume();
}
// Inform observers that we have resumed.
- 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)->OnResume();
}
// Do at end to ensure our first update/render after resumption includes the processed messages as well
mThreadController->Resume();
- DALI_LOG_RELEASE_INFO( "Adaptor::Resume: Resumed\n");
+ DALI_LOG_RELEASE_INFO("Adaptor::Resume: Resumed\n");
}
else
{
- DALI_LOG_RELEASE_INFO( "Adaptor::Resume: Not resumed [%d]\n", mState );
+ DALI_LOG_RELEASE_INFO("Adaptor::Resume: Not resumed [%d]\n", mState);
}
}
void Adaptor::Stop()
{
- if( RUNNING == mState ||
- PAUSED == mState ||
- PAUSED_WHILE_HIDDEN == mState )
+ if(RUNNING == mState ||
+ PAUSED == mState ||
+ PAUSED_WHILE_HIDDEN == mState)
{
- 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)->OnStop();
}
- if (mAddOnManager)
+ if(mAddOnManager)
{
mAddOnManager->Stop();
}
mThreadController->Stop();
// Delete the TTS player
- for( int i =0; i < Dali::TtsPlayer::MODE_NUM; i++ )
+ for(int i = 0; i < Dali::TtsPlayer::MODE_NUM; i++)
{
- if( mTtsPlayers[i] )
+ if(mTtsPlayers[i])
{
mTtsPlayers[i].Reset();
}
mState = STOPPED;
- DALI_LOG_RELEASE_INFO( "Adaptor::Stop\n" );
+ DALI_LOG_RELEASE_INFO("Adaptor::Stop\n");
}
}
mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
}
-void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
+void Adaptor::FeedTouchPoint(TouchPoint& point, int timeStamp)
{
- Integration::Point convertedPoint( point );
- mWindows.front()->FeedTouchPoint( convertedPoint, timeStamp );
+ Integration::Point convertedPoint(point);
+ mWindows.front()->FeedTouchPoint(convertedPoint, timeStamp);
}
-void Adaptor::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
+void Adaptor::FeedWheelEvent(Dali::WheelEvent& wheelEvent)
{
- Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >( wheelEvent.GetType() ), wheelEvent.GetDirection(), wheelEvent.GetModifiers(), wheelEvent.GetPoint(), wheelEvent.GetDelta(), wheelEvent.GetTime() );
- mWindows.front()->FeedWheelEvent( event );
+ Integration::WheelEvent event(static_cast<Integration::WheelEvent::Type>(wheelEvent.GetType()), wheelEvent.GetDirection(), wheelEvent.GetModifiers(), wheelEvent.GetPoint(), wheelEvent.GetDelta(), wheelEvent.GetTime());
+ mWindows.front()->FeedWheelEvent(event);
}
-void Adaptor::FeedKeyEvent( Dali::KeyEvent& keyEvent )
+void Adaptor::FeedKeyEvent(Dali::KeyEvent& keyEvent)
{
- Integration::KeyEvent convertedEvent( 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() );
- mWindows.front()->FeedKeyEvent( convertedEvent );
+ Integration::KeyEvent convertedEvent(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());
+ mWindows.front()->FeedKeyEvent(convertedEvent);
}
-void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface )
+void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface)
{
- Internal::Adaptor::SceneHolder* windowImpl = &Dali::GetImplementation( window );
- for( auto windowPtr : mWindows )
+ Internal::Adaptor::SceneHolder* windowImpl = &Dali::GetImplementation(window);
+ for(auto windowPtr : mWindows)
{
- if( windowPtr == windowImpl ) // the window is not deleted
+ if(windowPtr == windowImpl) // the window is not deleted
{
- mResizedSignal.Emit( mAdaptor );
+ mResizedSignal.Emit(mAdaptor);
- windowImpl->SetSurface( &newSurface );
+ windowImpl->SetSurface(&newSurface);
// Flush the event queue to give the update-render thread chance
// to start processing messages for new camera setup etc as soon as possible
ProcessCoreEvents();
// This method blocks until the render thread has completed the replace.
- mThreadController->ReplaceSurface( &newSurface );
+ mThreadController->ReplaceSurface(&newSurface);
break;
}
}
}
-void Adaptor::DeleteSurface( Dali::RenderSurfaceInterface& surface )
+void Adaptor::DeleteSurface(Dali::RenderSurfaceInterface& surface)
{
// Flush the event queue to give the update-render thread chance
// to start processing messages for new camera setup etc as soon as possible
ProcessCoreEvents();
// This method blocks until the render thread has finished rendering the current surface.
- mThreadController->DeleteSurface( &surface );
+ mThreadController->DeleteSurface(&surface);
}
Dali::RenderSurfaceInterface& Adaptor::GetSurface() const
Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
{
- if( !mTtsPlayers[mode] )
+ if(!mTtsPlayers[mode])
{
// Create the TTS player when it needed, because it can reduce launching time.
mTtsPlayers[mode] = TtsPlayer::New(mode);
return mTtsPlayers[mode];
}
-bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd )
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue, bool forceAdd)
{
bool idleAdded(false);
// Only add an idle if the Adaptor is actually running
- if( RUNNING == mState || READY == mState || forceAdd )
+ if(RUNNING == mState || READY == mState || forceAdd)
{
- idleAdded = mCallbackManager->AddIdleCallback( callback, hasReturnValue );
+ idleAdded = mCallbackManager->AddIdleCallback(callback, hasReturnValue);
}
return idleAdded;
}
-void Adaptor::RemoveIdle( CallbackBase* callback )
+void Adaptor::RemoveIdle(CallbackBase* callback)
{
- mCallbackManager->RemoveIdleCallback( callback );
+ mCallbackManager->RemoveIdleCallback(callback);
}
void Adaptor::ProcessIdle()
{
- bool idleProcessed = mCallbackManager->ProcessIdle();
+ bool idleProcessed = mCallbackManager->ProcessIdle();
mNotificationOnIdleInstalled = mNotificationOnIdleInstalled && !idleProcessed;
}
-void Adaptor::SetPreRenderCallback( CallbackBase* callback )
+void Adaptor::SetPreRenderCallback(CallbackBase* callback)
{
- mThreadController->SetPreRenderCallback( callback );
+ mThreadController->SetPreRenderCallback(callback);
}
-bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow )
+bool Adaptor::AddWindow(Dali::Integration::SceneHolder childWindow)
{
- Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( childWindow );
- windowImpl.SetAdaptor( Get() );
+ Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation(childWindow);
+ windowImpl.SetAdaptor(Get());
// ChildWindow is set to the layout direction of the default window.
- windowImpl.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection );
+ windowImpl.GetRootLayer().SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection);
// Add the new Window to the container - the order is not important
- mWindows.push_back( &windowImpl );
+ mWindows.push_back(&windowImpl);
Dali::RenderSurfaceInterface* surface = windowImpl.GetSurface();
- mThreadController->AddSurface( surface );
+ mThreadController->AddSurface(surface);
- mWindowCreatedSignal.Emit( childWindow );
+ mWindowCreatedSignal.Emit(childWindow);
return true;
}
-bool Adaptor::RemoveWindow( Dali::Integration::SceneHolder* childWindow )
+bool Adaptor::RemoveWindow(Dali::Integration::SceneHolder* childWindow)
{
- Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( *childWindow );
- for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation(*childWindow);
+ for(WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter)
{
- if( *iter == &windowImpl )
+ if(*iter == &windowImpl)
{
- mWindows.erase( iter );
+ mWindows.erase(iter);
return true;
}
}
return false;
}
-bool Adaptor::RemoveWindow( std::string childWindowName )
+bool Adaptor::RemoveWindow(std::string childWindowName)
{
- for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ for(WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter)
{
- if( ( *iter )->GetName() == childWindowName )
+ if((*iter)->GetName() == childWindowName)
{
- mWindows.erase( iter );
+ mWindows.erase(iter);
return true;
}
}
return false;
}
-bool Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* childWindow )
+bool Adaptor::RemoveWindow(Internal::Adaptor::SceneHolder* childWindow)
{
- for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ for(WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter)
{
- if( ( *iter )->GetId() == childWindow->GetId() )
+ if((*iter)->GetId() == childWindow->GetId())
{
- mWindows.erase( iter );
+ mWindows.erase(iter);
return true;
}
}
Dali::Adaptor& Adaptor::Get()
{
- DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
+ DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
return gThreadLocalAdaptor->mAdaptor;
}
return *mCore;
}
-void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
+void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
{
- mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
+ mThreadController->SetRenderRefreshRate(numberOfVSyncsPerRender);
}
Dali::DisplayConnection& Adaptor::GetDisplayConnectionInterface()
{
- DALI_ASSERT_DEBUG( mDisplayConnection && "Display connection not created" );
+ DALI_ASSERT_DEBUG(mDisplayConnection && "Display connection not created");
return *mDisplayConnection;
}
GraphicsInterface& Adaptor::GetGraphicsInterface()
{
- DALI_ASSERT_DEBUG( mGraphics && "Graphics interface not created" );
- return *( mGraphics.get() );
+ DALI_ASSERT_DEBUG(mGraphics && "Graphics interface not created");
+ return *(mGraphics.get());
}
Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
Dali::RenderSurfaceInterface* Adaptor::GetRenderSurfaceInterface()
{
- if( !mWindows.empty() )
+ if(!mWindows.empty())
{
return mWindows.front()->GetSurface();
}
Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
{
- DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
+ DALI_ASSERT_DEBUG(mPlatformAbstraction && "PlatformAbstraction not created");
return *mPlatformAbstraction;
}
-void Adaptor::GetWindowContainerInterface( WindowContainer& windows )
+void Adaptor::GetWindowContainerInterface(WindowContainer& windows)
{
windows = mWindows;
}
void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
{
- if( mTtsPlayers[mode] )
+ if(mTtsPlayers[mode])
{
mTtsPlayers[mode].Reset();
}
return mWindows.front()->GetNativeHandle();
}
-Any Adaptor::GetNativeWindowHandle( Dali::Actor actor )
+Any Adaptor::GetNativeWindowHandle(Dali::Actor actor)
{
Any nativeWindowHandle;
- Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor );
+ Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
- for( auto sceneHolder : mWindows )
+ for(auto sceneHolder : mWindows)
{
- if ( scene == sceneHolder->GetScene() )
+ if(scene == sceneHolder->GetScene())
{
nativeWindowHandle = sceneHolder->GetNativeHandle();
break;
{
Any display;
- if (mGraphics)
+ if(mGraphics)
{
- GraphicsInterface* graphics = mGraphics.get(); // This interface is temporary until Core has been updated to match
- auto eglGraphics = static_cast<EglGraphics *>( graphics );
+ GraphicsInterface* graphics = mGraphics.get(); // This interface is temporary until Core has been updated to match
+ auto eglGraphics = static_cast<EglGraphics*>(graphics);
EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- display = eglImpl.GetDisplay();
+ display = eglImpl.GetDisplay();
}
return display;
mUseRemoteSurface = useRemoteSurface;
}
-void Adaptor::AddObserver( LifeCycleObserver& observer )
+void Adaptor::AddObserver(LifeCycleObserver& 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 Adaptor::RemoveObserver( LifeCycleObserver& observer )
+void Adaptor::RemoveObserver(LifeCycleObserver& 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);
}
}
void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
{
- if( mCore )
+ if(mCore)
{
mCore->QueueEvent(event);
}
void Adaptor::ProcessCoreEvents()
{
- if( mCore )
+ if(mCore)
{
- if( mPerformanceInterface )
+ if(mPerformanceInterface)
{
- mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
+ mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_START);
}
mCore->ProcessEvents();
- if( mPerformanceInterface )
+ if(mPerformanceInterface)
{
- mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
+ mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_END);
}
}
}
-void Adaptor::RequestUpdate( bool forceUpdate )
+void Adaptor::RequestUpdate(bool forceUpdate)
{
- switch( mState )
+ switch(mState)
{
case RUNNING:
{
case PAUSED:
case PAUSED_WHILE_HIDDEN:
{
- if( forceUpdate )
+ if(forceUpdate)
{
// Update (and resource upload) without rendering
- mThreadController->RequestUpdateOnce( UpdateMode::SKIP_RENDER );
+ mThreadController->RequestUpdateOnce(UpdateMode::SKIP_RENDER);
}
break;
}
}
}
-void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
+void Adaptor::RequestProcessEventsOnIdle(bool forceProcess)
{
// Only request a notification if the Adaptor is actually running
// and we haven't installed the idle notification
- if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) )
+ if((!mNotificationOnIdleInstalled) && (RUNNING == mState || READY == mState || forceProcess))
{
- mNotificationOnIdleInstalled = AddIdleEnterer( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
+ mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), forceProcess);
}
}
{
Dali::Accessibility::Bridge::GetCurrentBridge()->ApplicationShown();
- if( PAUSED_WHILE_HIDDEN == mState )
+ if(PAUSED_WHILE_HIDDEN == mState)
{
// Adaptor can now be resumed
mState = PAUSED;
// Force a render task
RequestUpdateOnce();
}
- else if( RUNNING == mState )
+ else if(RUNNING == mState)
{
// Force a render task
RequestUpdateOnce();
- DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowShown: Update requested.\n" );
+ DALI_LOG_RELEASE_INFO("Adaptor::OnWindowShown: Update requested.\n");
}
- else if( PAUSED_WHILE_INITIALIZING == mState )
+ else if(PAUSED_WHILE_INITIALIZING == mState)
{
// Change the state to READY again. It will be changed to RUNNING after the adaptor is started.
mState = READY;
}
else
{
- DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowShown: Adaptor is not paused state.[%d]\n", mState );
+ DALI_LOG_RELEASE_INFO("Adaptor::OnWindowShown: Adaptor is not paused state.[%d]\n", mState);
}
}
{
Dali::Accessibility::Bridge::GetCurrentBridge()->ApplicationHidden();
- if( RUNNING == mState || READY == mState )
+ if(RUNNING == mState || READY == mState)
{
bool allWindowsHidden = true;
- for( auto window : mWindows )
+ for(auto window : mWindows)
{
- if ( window->IsVisible() )
+ if(window->IsVisible())
{
allWindowsHidden = false;
break;
}
// Only pause the adaptor when all the windows are hidden
- if( allWindowsHidden )
+ if(allWindowsHidden)
{
- if( mState == RUNNING )
+ if(mState == RUNNING)
{
Pause();
// Adaptor cannot be resumed until any window is shown
mState = PAUSED_WHILE_HIDDEN;
}
- else // mState is READY
+ else // mState is READY
{
// Pause the adaptor after the state gets RUNNING
mState = PAUSED_WHILE_INITIALIZING;
}
else
{
- DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowHidden: Some windows are shown. Don't pause adaptor.\n" );
+ DALI_LOG_RELEASE_INFO("Adaptor::OnWindowHidden: Some windows are shown. Don't pause adaptor.\n");
}
}
else
{
- DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowHidden: Adaptor is not running state.[%d]\n", mState );
+ DALI_LOG_RELEASE_INFO("Adaptor::OnWindowHidden: Adaptor is not running state.[%d]\n", mState);
}
}
// Dali::Internal::Adaptor::Adaptor::OnDamaged
-void Adaptor::OnDamaged( const DamageArea& area )
+void Adaptor::OnDamaged(const DamageArea& area)
{
// This is needed for the case where Dali window is partially obscured
- RequestUpdate( false );
+ RequestUpdate(false);
}
-void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
{
- mResizedSignal.Emit( mAdaptor );
+ mResizedSignal.Emit(mAdaptor);
}
-void Adaptor::SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
{
// Nofify surface resizing before flushing event queue
mThreadController->ResizeSurface();
// Process after surface is created (registering to remote surface provider if required)
SurfaceInitialized();
- if( mState != PAUSED_WHILE_INITIALIZING )
+ if(mState != PAUSED_WHILE_INITIALIZING)
{
mState = RUNNING;
- DALI_LOG_RELEASE_INFO( "Adaptor::NotifySceneCreated: Adaptor is running\n" );
+ DALI_LOG_RELEASE_INFO("Adaptor::NotifySceneCreated: Adaptor is running\n");
}
else
{
mState = PAUSED_WHILE_HIDDEN;
- DALI_LOG_RELEASE_INFO( "Adaptor::NotifySceneCreated: Adaptor is paused\n" );
+ DALI_LOG_RELEASE_INFO("Adaptor::NotifySceneCreated: Adaptor is paused\n");
}
}
void Adaptor::NotifyLanguageChanged()
{
- mLanguageChangedSignal.Emit( mAdaptor );
+ mLanguageChangedSignal.Emit(mAdaptor);
}
void Adaptor::RenderOnce()
{
- if( mThreadController )
+ if(mThreadController)
{
UpdateMode updateMode;
- if( mThreadMode == ThreadMode::NORMAL )
+ if(mThreadMode == ThreadMode::NORMAL)
{
updateMode = UpdateMode::NORMAL;
}
ProcessCoreEvents();
}
- mThreadController->RequestUpdateOnce( updateMode );
+ mThreadController->RequestUpdateOnce(updateMode);
}
}
return *mEnvironmentOptions;
}
-void Adaptor::RegisterProcessor( Integration::Processor& processor )
+void Adaptor::RegisterProcessor(Integration::Processor& processor)
{
GetCore().RegisterProcessor(processor);
}
-void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+void Adaptor::UnregisterProcessor(Integration::Processor& processor)
{
GetCore().UnregisterProcessor(processor);
}
void Adaptor::RequestUpdateOnce()
{
- if( mThreadController )
+ if(mThreadController)
{
- mThreadController->RequestUpdateOnce( UpdateMode::NORMAL );
+ mThreadController->RequestUpdateOnce(UpdateMode::NORMAL);
}
}
return false;
}
-Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor )
+Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor)
{
- Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor );
+ Dali::Integration::Scene scene = Dali::Integration::Scene::Get(actor);
- for( auto window : mWindows )
+ for(auto window : mWindows)
{
- if ( scene == window->GetScene() )
+ if(scene == window->GetScene())
{
return window;
}
{
Dali::WindowContainer windows;
- for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter)
{
// Downcast to Dali::Window
- Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( *iter ) );
- if ( window )
+ Dali::Window window(dynamic_cast<Dali::Internal::Adaptor::Window*>(*iter));
+ if(window)
{
- windows.push_back( window );
+ windows.push_back(window);
}
}
{
Dali::SceneHolderList sceneHolderList;
- for( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter )
+ for(auto iter = mWindows.begin(); iter != mWindows.end(); ++iter)
{
- sceneHolderList.push_back( Dali::Integration::SceneHolder( *iter ) );
+ sceneHolderList.push_back(Dali::Integration::SceneHolder(*iter));
}
return sceneHolderList;
Dali::ObjectRegistry Adaptor::GetObjectRegistry() const
{
Dali::ObjectRegistry registry;
- if( mCore )
+ if(mCore)
{
registry = mCore->GetObjectRegistry();
}
return registry;
}
-Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode )
+Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode)
: mResizedSignal(),
mLanguageChangedSignal(),
mWindowCreatedSignal(),
- mAdaptor( adaptor ),
- mState( READY ),
- mCore( nullptr ),
- mThreadController( nullptr ),
- mGraphics( nullptr ),
- mDisplayConnection( nullptr ),
+ mAdaptor(adaptor),
+ mState(READY),
+ mCore(nullptr),
+ mThreadController(nullptr),
+ mGraphics(nullptr),
+ mDisplayConnection(nullptr),
mWindows(),
- mConfigurationManager( nullptr ),
- mPlatformAbstraction( nullptr ),
- mCallbackManager( nullptr ),
- mNotificationOnIdleInstalled( false ),
- mNotificationTrigger( nullptr ),
+ mConfigurationManager(nullptr),
+ mPlatformAbstraction(nullptr),
+ mCallbackManager(nullptr),
+ mNotificationOnIdleInstalled(false),
+ mNotificationTrigger(nullptr),
mDaliFeedbackPlugin(),
- mFeedbackController( nullptr ),
+ mFeedbackController(nullptr),
mTtsPlayers(),
mObservers(),
- mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
- mPerformanceInterface( nullptr ),
+ mEnvironmentOptions(environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
+ mPerformanceInterface(nullptr),
mKernelTracer(),
mSystemTracer(),
- mObjectProfiler( nullptr ),
+ mObjectProfiler(nullptr),
mSocketFactory(),
- mThreadMode( threadMode ),
- mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
- mUseRemoteSurface( false ),
- mRootLayoutDirection( Dali::LayoutDirection::LEFT_TO_RIGHT )
+ mThreadMode(threadMode),
+ mEnvironmentOptionsOwned(environmentOptions ? false : true /* If not provided then we own the object */),
+ mUseRemoteSurface(false),
+ mRootLayoutDirection(Dali::LayoutDirection::LEFT_TO_RIGHT)
{
- DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
- mWindows.insert( mWindows.begin(), &Dali::GetImplementation( window ) );
+ DALI_ASSERT_ALWAYS(!IsAvailable() && "Cannot create more than one Adaptor per thread");
+ mWindows.insert(mWindows.begin(), &Dali::GetImplementation(window));
gThreadLocalAdaptor = this;
}
-void Adaptor::SetRootLayoutDirection( std::string locale )
+void Adaptor::SetRootLayoutDirection(std::string locale)
{
- mRootLayoutDirection = static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) );
- for ( auto& window : mWindows )
+ mRootLayoutDirection = static_cast<LayoutDirection::Type>(Internal::Adaptor::Locale::GetDirection(std::string(locale)));
+ for(auto& window : mWindows)
{
Dali::Actor root = window->GetRootLayer();
- root.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection );
+ root.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection);
}
}
-bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd )
+bool Adaptor::AddIdleEnterer(CallbackBase* callback, bool forceAdd)
{
- bool idleAdded( false );
+ bool idleAdded(false);
// Only add an idle if the Adaptor is actually running
- if( RUNNING == mState || READY == mState || forceAdd )
+ if(RUNNING == mState || READY == mState || forceAdd)
{
- idleAdded = mCallbackManager->AddIdleEntererCallback( callback );
+ idleAdded = mCallbackManager->AddIdleEntererCallback(callback);
}
- if( !idleAdded )
+ if(!idleAdded)
{
// Delete callback
delete callback;
return idleAdded;
}
-void Adaptor::RemoveIdleEnterer( CallbackBase* callback )
+void Adaptor::RemoveIdleEnterer(CallbackBase* callback)
{
- mCallbackManager->RemoveIdleEntererCallback( callback );
+ mCallbackManager->RemoveIdleEntererCallback(callback);
}
} // namespace Adaptor
#define DALI_INTERNAL_ADAPTOR_IMPL_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.
*/
// EXTERNAL INCLUDES
+#include <dali/integration-api/render-controller.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/math/rect.h>
-#include <dali/public-api/signals/callback.h>
#include <dali/public-api/math/uint-16-pair.h>
-#include <dali/integration-api/render-controller.h>
+#include <dali/public-api/signals/callback.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/tts-player.h>
#include <dali/devel-api/adaptor-framework/clipboard.h>
-#include <dali/integration-api/scene.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
+#include <dali/integration-api/scene.h>
#include <dali/internal/adaptor/common/adaptor-internal-services.h>
#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/legacy/common/tizen-platform-abstraction.h>
#include <dali/internal/system/common/system-trace.h>
#include <dali/internal/window-system/common/damage-observer.h>
#include <dali/internal/window-system/common/window-visibility-observer.h>
+#include <dali/public-api/adaptor-framework/tts-player.h>
#include <string>
namespace Dali
{
-
class RenderSurfaceInterface;
namespace Accessibility
class GlAbstraction;
class Processor;
class AddOnManager;
-}
+} // namespace Integration
namespace Internal
{
-
namespace Adaptor
{
class DisplayConnection;
public WindowVisibilityObserver
{
public:
-
- using AdaptorSignalType = Dali::Adaptor::AdaptorSignalType;
+ using AdaptorSignalType = Dali::Adaptor::AdaptorSignalType;
using WindowCreatedSignalType = Dali::Adaptor::WindowCreatedSignalType;
- using SurfaceSize = Uint16Pair; ///< Surface size type
+ using SurfaceSize = Uint16Pair; ///< Surface size type
/**
* Creates a New Adaptor
* @param[in] environmentOptions A pointer to the environment options. If NULL then one is created.
* @param[in] threadMode The thread mode
*/
- static Dali::Adaptor* New( Dali::Integration::SceneHolder window,
- Dali::RenderSurfaceInterface* surface,
- EnvironmentOptions* environmentOptions,
- ThreadMode threadMode );
+ static Dali::Adaptor* New(Dali::Integration::SceneHolder window,
+ Dali::RenderSurfaceInterface* surface,
+ EnvironmentOptions* environmentOptions,
+ ThreadMode threadMode);
/**
* Creates a New Adaptor
* @param[in] window The window handle
* @param[in] environmentOptions A pointer to the environment options. If NULL then one is created.
*/
- static Dali::Adaptor* New( Dali::Integration::SceneHolder window,
- EnvironmentOptions* environmentOptions );
+ static Dali::Adaptor* New(Dali::Integration::SceneHolder window,
+ EnvironmentOptions* environmentOptions);
/**
* Creates a New Adaptor
* @param[in] environmentOptions A pointer to the environment options. If NULL then one is created.
* @param[in] threadMode The thread mode
*/
- static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
- Dali::Integration::SceneHolder window,
- Dali::RenderSurfaceInterface* surface,
- EnvironmentOptions* environmentOptions,
- ThreadMode threadMode );
+ static Dali::Adaptor* New(GraphicsFactory& graphicsFactory,
+ Dali::Integration::SceneHolder window,
+ Dali::RenderSurfaceInterface* surface,
+ EnvironmentOptions* environmentOptions,
+ ThreadMode threadMode);
/**
* Creates a New Adaptor
* @param[in] window The window handle
* @param[in] environmentOptions A pointer to the environment options. If NULL then one is created.
*/
- static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
- Dali::Integration::SceneHolder window,
- EnvironmentOptions* environmentOptions );
+ static Dali::Adaptor* New(GraphicsFactory& graphicsFactory,
+ Dali::Integration::SceneHolder window,
+ EnvironmentOptions* environmentOptions);
/**
* 2-step initialisation, this should be called after creating an adaptor instance.
* @param[in] graphicsFactory A factory that creates the graphics interface
*/
- void Initialize( GraphicsFactory& graphicsFactory );
+ void Initialize(GraphicsFactory& graphicsFactory);
/**
* Virtual destructor.
/**
* @copydoc Dali::EventFeeder::FeedTouchPoint()
*/
- virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
+ virtual void FeedTouchPoint(TouchPoint& point, int timeStamp);
/**
* @copydoc Dali::EventFeeder::FeedWheelEvent()
*/
- virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
+ virtual void FeedWheelEvent(Dali::WheelEvent& wheelEvent);
/**
* @copydoc Dali::EventFeeder::FeedKeyEvent()
*/
- virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent );
+ virtual void FeedKeyEvent(Dali::KeyEvent& keyEvent);
/**
* @copydoc Dali::Adaptor::ReplaceSurface()
*/
- virtual void ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface );
+ virtual void ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface);
/**
* @copydoc Dali::Adaptor::GetSurface()
/**
* @copydoc Dali::Adaptor::AddIdle()
*/
- virtual bool AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd );
+ virtual bool AddIdle(CallbackBase* callback, bool hasReturnValue, bool forceAdd);
/**
* Adds a new Window instance to the Adaptor
* @param[in] childWindow The child window instance
*/
- virtual bool AddWindow( Dali::Integration::SceneHolder childWindow );
+ virtual bool AddWindow(Dali::Integration::SceneHolder childWindow);
/**
* Removes an existing Window instance from the Adaptor
* @param[in] window The Window instance
*/
- virtual bool RemoveWindow( Dali::Integration::SceneHolder* childWindow );
+ virtual bool RemoveWindow(Dali::Integration::SceneHolder* childWindow);
/**
* Removes an existing Window instance from the Adaptor
* @param[in] windowName The Window name
* @note If two Windows have the same name, the first one that matches will be removed
*/
- virtual bool RemoveWindow( std::string childWindowName );
+ virtual bool RemoveWindow(std::string childWindowName);
/**
* @copydoc Dali::Adaptor::RemoveIdle()
*/
- virtual void RemoveIdle( CallbackBase* callback );
+ virtual void RemoveIdle(CallbackBase* callback);
/**
* @copydoc Dali::Adaptor::ProcessIdle()
/**
* Sets a pre-render callback.
*/
- void SetPreRenderCallback( CallbackBase* callback );
+ void SetPreRenderCallback(CallbackBase* callback);
/**
* Removes an existing Window instance from the Adaptor
* @param[in] childWindow The Window instance
*/
- bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
+ bool RemoveWindow(Dali::Internal::Adaptor::SceneHolder* childWindow);
/**
* @brief Deletes the rendering surface
* @param[in] surface to delete
*/
- void DeleteSurface( Dali::RenderSurfaceInterface& surface );
+ void DeleteSurface(Dali::RenderSurfaceInterface& surface);
/**
* @brief Retrieve the window that the given actor is added to.
* @param[in] actor The actor
* @return The window the actor is added to or a null pointer if the actor is not added to any widnow.
*/
- Dali::Internal::Adaptor::SceneHolder* GetWindow( Dali::Actor& actor );
+ Dali::Internal::Adaptor::SceneHolder* GetWindow(Dali::Actor& actor);
/**
* @copydoc Dali::Adaptor::GetWindows()
Dali::ObjectRegistry GetObjectRegistry() const;
public:
-
/**
* @return the Core instance
*/
/**
* @copydoc Dali::Adaptor::SetRenderRefreshRate()
*/
- void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender );
+ void SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender);
/**
* Return the PlatformAbstraction.
* @param[in] actor The actor
* @return native window handle
*/
- Any GetNativeWindowHandle( Dali::Actor actor );
+ Any GetNativeWindowHandle(Dali::Actor actor);
/**
* Get the native display associated with the graphics backend
void SetUseRemoteSurface(bool useRemoteSurface);
public:
-
/**
* Adds an adaptor observer so that we can observe the adaptor's lifetime events.
* @param[in] observer The observer.
* @note Observers should remove themselves when they are destroyed.
*/
- void AddObserver( LifeCycleObserver& observer );
+ void AddObserver(LifeCycleObserver& observer);
/**
* Removes the observer from the adaptor.
* @param[in] observer The observer to remove.
* @note Observers should remove themselves when they are destroyed.
*/
- void RemoveObserver( LifeCycleObserver& observer );
+ void RemoveObserver(LifeCycleObserver& observer);
/**
* Emits the Notification event to the Dali core.
/**
* Gets AppId of current application
*/
- void GetAppId( std::string& appId );
+ void GetAppId(std::string& appId);
+
+ /**
+ * Gets path for resource storage.
+ * @param[out] path Path for resource storage
+ */
+ void GetResourceStoragePath(std::string& path);
/**
* @copydoc Dali::Adaptor::SurfaceResizePrepare
*/
- void SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
+ void SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize);
/**
* @copydoc Dali::Adaptor::SurfaceResizeComplete
*/
- void SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
+ void SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize);
/**
* Sets layout direction of root by system language
* @param[in] locale System locale
*/
- void SetRootLayoutDirection( std::string locale );
+ void SetRootLayoutDirection(std::string locale);
/**
* @copydoc Dali::Adaptor::RenderOnce
/**
* @copydoc Dali::Adaptor::RegisterProcessor
*/
- void RegisterProcessor( Integration::Processor& processor );
+ void RegisterProcessor(Integration::Processor& processor);
/**
* @coydoc Dali::Adaptor::UnregisterProcessor
*/
- void UnregisterProcessor( Integration::Processor& processor );
+ void UnregisterProcessor(Integration::Processor& processor);
/**
* Check MultipleWindow is supported
*/
bool IsMultipleWindowSupported() const;
-public: //AdaptorInternalServices
-
+public: //AdaptorInternalServices
/**
* @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPlatformAbstractionInterface()
*/
/**
* copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetWindowContainerInterface()
*/
- void GetWindowContainerInterface( WindowContainer& windows ) override;
+ void GetWindowContainerInterface(WindowContainer& windows) override;
public: // Signals
-
/**
* @copydoc Dali::Adaptor::SignalResized
*/
}
public: // From Dali::Internal::Adaptor::CoreEventInterface
-
/**
* @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
*/
void ProcessCoreEvents() override;
private: // From Dali::Internal::Adaptor::CoreEventInterface
-
/**
* @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
*/
void QueueCoreEvent(const Dali::Integration::Event& event) override;
private: // From Dali::Integration::RenderController
-
/**
* @copydoc Dali::Integration::RenderController::RequestUpdate()
*/
- void RequestUpdate( bool forceUpdate ) override;
+ void RequestUpdate(bool forceUpdate) override;
/**
* @copydoc Dali::Integration::RenderController::RequestProcessEventsOnIdle()
*/
- void RequestProcessEventsOnIdle( bool forceProcess ) override;
+ void RequestProcessEventsOnIdle(bool forceProcess) override;
public: // From Dali::Internal::Adaptor::WindowVisibilityObserver
-
/**
* Called when the window becomes fully or partially visible.
*/
void OnWindowHidden() override;
private: // From Dali::Internal::Adaptor::DamageObserver
-
/**
* @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged()
*/
- void OnDamaged( const DamageArea& area ) override;
+ void OnDamaged(const DamageArea& area) override;
private:
-
// Undefined
Adaptor(const Adaptor&) = delete;
Adaptor& operator=(Adaptor&) = delete;
private:
-
/**
* Assigns the render surface to the adaptor
*
*/
- void SetSurface(Dali::RenderSurfaceInterface *surface);
+ void SetSurface(Dali::RenderSurfaceInterface* surface);
/**
* called after surface is created
* @endcode
* This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
*/
- bool AddIdleEnterer( CallbackBase* callback, bool forceAdd );
+ bool AddIdleEnterer(CallbackBase* callback, bool forceAdd);
/**
* Removes a previously added the idle enterer callback.
*/
- void RemoveIdleEnterer( CallbackBase* callback );
+ void RemoveIdleEnterer(CallbackBase* callback);
private:
-
/**
* Constructor
* @param[in] window window handle
* @param[in] environmentOptions A pointer to the environment options. If NULL then one is created.
* @param[in] threadMode The ThreadMode of the Adaptor
*/
- Adaptor( Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode );
+ Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode);
private: // Types
-
enum State
{
READY, ///< Initial state before Adaptor::Start is called.
// There is no weak handle for BaseHandle in DALi, but we can't ref count the window here,
// so we have to store the raw pointer.
- using WindowContainer = std::vector<Dali::Internal::Adaptor::SceneHolder*>;
+ using WindowContainer = std::vector<Dali::Internal::Adaptor::SceneHolder*>;
using ObserverContainer = std::vector<LifeCycleObserver*>;
-private: // Data
-
- AdaptorSignalType mResizedSignal; ///< Resized signal.
- AdaptorSignalType mLanguageChangedSignal; ///< Language changed signal.
- WindowCreatedSignalType mWindowCreatedSignal; ///< Window created signal.
-
- Dali::Adaptor& mAdaptor; ///< Reference to public adaptor instance.
- State mState; ///< Current state of the adaptor
- Dali::Integration::Core* mCore; ///< Dali Core
- ThreadController* mThreadController; ///< Controls the threads
-
- std::unique_ptr< GraphicsInterface > mGraphics; ///< Graphics interface
- Dali::DisplayConnection* mDisplayConnection; ///< Display connection
- WindowContainer mWindows; ///< A container of all the Windows that are currently created
-
- std::unique_ptr<ConfigurationManager> mConfigurationManager; ///< Configuration manager
-
- TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction
-
- CallbackManager* mCallbackManager; ///< Used to install callbacks
- bool mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
- TriggerEventInterface* mNotificationTrigger; ///< Notification event trigger
- FeedbackPluginProxy* mDaliFeedbackPlugin; ///< Used to access feedback support
- FeedbackController* mFeedbackController; ///< Plays feedback effects for Dali-Toolkit UI Controls.
- Dali::TtsPlayer mTtsPlayers[Dali::TtsPlayer::MODE_NUM]; ///< Provides TTS support
- ObserverContainer mObservers; ///< A list of adaptor observer pointers
- EnvironmentOptions* mEnvironmentOptions; ///< environment options
- PerformanceInterface* mPerformanceInterface; ///< Performance interface
- KernelTrace mKernelTracer; ///< Kernel tracer
- SystemTrace mSystemTracer; ///< System tracer
- ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling
- SocketFactory mSocketFactory; ///< Socket factory
- ThreadMode mThreadMode; ///< The thread mode
- const bool mEnvironmentOptionsOwned:1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
- bool mUseRemoteSurface:1; ///< whether the remoteSurface is used or not
- Dali::LayoutDirection::Type mRootLayoutDirection; ///< LayoutDirection of window
-
- std::unique_ptr<Integration::AddOnManager> mAddOnManager; ///< Pointer to the addon manager
+private: // Data
+ AdaptorSignalType mResizedSignal; ///< Resized signal.
+ AdaptorSignalType mLanguageChangedSignal; ///< Language changed signal.
+ WindowCreatedSignalType mWindowCreatedSignal; ///< Window created signal.
+
+ Dali::Adaptor& mAdaptor; ///< Reference to public adaptor instance.
+ State mState; ///< Current state of the adaptor
+ Dali::Integration::Core* mCore; ///< Dali Core
+ ThreadController* mThreadController; ///< Controls the threads
+
+ std::unique_ptr<GraphicsInterface> mGraphics; ///< Graphics interface
+ Dali::DisplayConnection* mDisplayConnection; ///< Display connection
+ WindowContainer mWindows; ///< A container of all the Windows that are currently created
+
+ std::unique_ptr<ConfigurationManager> mConfigurationManager; ///< Configuration manager
+
+ TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction
+
+ CallbackManager* mCallbackManager; ///< Used to install callbacks
+ bool mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
+ TriggerEventInterface* mNotificationTrigger; ///< Notification event trigger
+ FeedbackPluginProxy* mDaliFeedbackPlugin; ///< Used to access feedback support
+ FeedbackController* mFeedbackController; ///< Plays feedback effects for Dali-Toolkit UI Controls.
+ Dali::TtsPlayer mTtsPlayers[Dali::TtsPlayer::MODE_NUM]; ///< Provides TTS support
+ ObserverContainer mObservers; ///< A list of adaptor observer pointers
+ EnvironmentOptions* mEnvironmentOptions; ///< environment options
+ PerformanceInterface* mPerformanceInterface; ///< Performance interface
+ KernelTrace mKernelTracer; ///< Kernel tracer
+ SystemTrace mSystemTracer; ///< System tracer
+ ObjectProfiler* mObjectProfiler; ///< Tracks object lifetime for profiling
+ SocketFactory mSocketFactory; ///< Socket factory
+ ThreadMode mThreadMode; ///< The thread mode
+ const bool mEnvironmentOptionsOwned : 1; ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
+ bool mUseRemoteSurface : 1; ///< whether the remoteSurface is used or not
+ Dali::LayoutDirection::Type mRootLayoutDirection; ///< LayoutDirection of window
+
+ std::unique_ptr<Integration::AddOnManager> mAddOnManager; ///< Pointer to the addon manager
class AccessibilityObserver : public ConnectionTracker
{
public:
- void OnAccessibleKeyEvent( const Dali::KeyEvent& event );
+ void OnAccessibleKeyEvent(const Dali::KeyEvent& event);
};
AccessibilityObserver accessibilityObserver;
public:
- inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) { return *adaptor.mImpl; }
+ inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor)
+ {
+ return *adaptor.mImpl;
+ }
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_IMPL_H
#define DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_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 Internal
{
-
namespace Adaptor
{
-
class SceneHolder;
using WindowContainer = std::vector<Internal::Adaptor::SceneHolder*>;
*/
class AdaptorInternalServices
{
-
public:
-
/**
* @return core
*/
* Used to access the list of windows from the Render thread
* @param[out] windows The list of created windows
*/
- virtual void GetWindowContainerInterface( WindowContainer& windows ) = 0;
+ virtual void GetWindowContainerInterface(WindowContainer& windows) = 0;
protected:
-
/**
* constructor
*/
- AdaptorInternalServices()
- {
- };
+ AdaptorInternalServices(){};
/**
* virtual destructor
*/
- virtual ~AdaptorInternalServices()
- {
- };
+ virtual ~AdaptorInternalServices(){};
// Undefined copy constructor.
- AdaptorInternalServices( const AdaptorInternalServices& ) = delete;
+ AdaptorInternalServices(const AdaptorInternalServices&) = delete;
// Undefined assignment operator.
- AdaptorInternalServices& operator=( const AdaptorInternalServices& ) = delete;
+ AdaptorInternalServices& operator=(const AdaptorInternalServices&) = delete;
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_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.
#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/internal/adaptor/common/application-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/object/object-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/object-registry.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
#include <dali/devel-api/adaptor-framework/style-monitor.h>
#include <dali/devel-api/text-abstraction/font-client.h>
-#include <dali/devel-api/adaptor-framework/accessibility-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/system/common/command-line-options.h>
#include <dali/internal/adaptor/common/framework.h>
#include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
+#include <dali/internal/system/common/command-line-options.h>
+#include <dali/internal/window-system/common/render-surface-factory.h>
#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
-#include <dali/internal/window-system/common/render-surface-factory.h>
// To disable a macro with the same name from one of OpenGL headers
#undef Status
namespace Dali
{
-
namespace TizenPlatform
{
class TizenPlatformAbstraction;
namespace Internal
{
-
namespace Adaptor
{
-
-ApplicationPtr Application::gPreInitializedApplication( NULL );
+ApplicationPtr Application::gPreInitializedApplication(NULL);
ApplicationPtr Application::New(
- int* argc,
- char **argv[],
- const std::string& stylesheet,
+ int* argc,
+ char** argv[],
+ const std::string& stylesheet,
Dali::Application::WINDOW_MODE windowMode,
- const PositionSize& positionSize,
- Framework::Type applicationType)
+ const PositionSize& positionSize,
+ Framework::Type applicationType)
{
- ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode, positionSize, applicationType ) );
+ ApplicationPtr application(new Application(argc, argv, stylesheet, windowMode, positionSize, applicationType));
return application;
}
-void Application::PreInitialize( int* argc, char** argv[] )
+void Application::PreInitialize(int* argc, char** argv[])
{
- if( !gPreInitializedApplication )
+ if(!gPreInitializedApplication)
{
Dali::TextAbstraction::FontClientPreInitialize();
- gPreInitializedApplication = new Application ( argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL );
- gPreInitializedApplication->CreateWindow(); // Only create window
+ gPreInitializedApplication = new Application(argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL);
+ gPreInitializedApplication->CreateWindow(); // Only create window
gPreInitializedApplication->mLaunchpadState = Launchpad::PRE_INITIALIZED;
}
}
-Application::Application( int* argc, char** argv[], const std::string& stylesheet,
- Dali::Application::WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType )
+Application::Application(int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType)
: mInitSignal(),
mTerminateSignal(),
mPauseSignal(),
mAppControlSignal(),
mLanguageChangedSignal(),
mRegionChangedSignal(),
- mEventLoop( nullptr ),
- mFramework( nullptr ),
- mCommandLineOptions( nullptr ),
- mAdaptorBuilder( nullptr ),
- mAdaptor( nullptr ),
+ mEventLoop(nullptr),
+ mFramework(nullptr),
+ mCommandLineOptions(nullptr),
+ mAdaptorBuilder(nullptr),
+ mAdaptor(nullptr),
mMainWindow(),
- mMainWindowMode( windowMode ),
+ mMainWindowMode(windowMode),
mMainWindowName(),
- mStylesheet( stylesheet ),
+ mStylesheet(stylesheet),
mEnvironmentOptions(),
- mWindowPositionSize( positionSize ),
- mLaunchpadState( Launchpad::NONE ),
- mSlotDelegate( this )
+ mWindowPositionSize(positionSize),
+ mLaunchpadState(Launchpad::NONE),
+ mSlotDelegate(this)
{
// Get mName from environment options
mMainWindowName = mEnvironmentOptions.GetWindowName();
- if( mMainWindowName.empty() && argc && ( *argc > 0 ) )
+ if(mMainWindowName.empty() && argc && (*argc > 0))
{
// Set mName from command-line args if environment option not set
mMainWindowName = (*argv)[0];
}
mCommandLineOptions = new CommandLineOptions(argc, argv);
- mFramework = new Framework( *this, argc, argv, applicationType );
- mUseRemoteSurface = (applicationType == Framework::WATCH);
+ mFramework = new Framework(*this, argc, argv, applicationType);
+ mUseRemoteSurface = (applicationType == Framework::WATCH);
}
Application::~Application()
{
SingletonService service = SingletonService::Get();
// Note this can be false i.e. if Application has never created a Core instance
- if( service )
+ if(service)
{
service.UnregisterAll();
}
void Application::CreateWindow()
{
- if( mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0 )
+ if(mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0)
{
- if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 )
+ if(mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0)
{
// Command line options override environment options and full screen
- mWindowPositionSize.width = mCommandLineOptions->stageWidth;
+ mWindowPositionSize.width = mCommandLineOptions->stageWidth;
mWindowPositionSize.height = mCommandLineOptions->stageHeight;
}
- else if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() )
+ else if(mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight())
{
// Environment options override full screen functionality if command line arguments not provided
- mWindowPositionSize.width = mEnvironmentOptions.GetWindowWidth();
+ mWindowPositionSize.width = mEnvironmentOptions.GetWindowWidth();
mWindowPositionSize.height = mEnvironmentOptions.GetWindowHeight();
}
}
const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName();
Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT);
- mMainWindow = Dali::Window( window );
+ mMainWindow = Dali::Window(window);
// Quit the application when the window is closed
- GetImplementation( mMainWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit );
+ GetImplementation(mMainWindow).DeleteRequestSignal().Connect(mSlotDelegate, &Application::Quit);
}
void Application::CreateAdaptor()
{
- DALI_ASSERT_ALWAYS( mMainWindow && "Window required to create adaptor" );
+ DALI_ASSERT_ALWAYS(mMainWindow && "Window required to create adaptor");
auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
- Integration::SceneHolder sceneHolder = Integration::SceneHolder( &Dali::GetImplementation( mMainWindow ) );
+ Integration::SceneHolder sceneHolder = Integration::SceneHolder(&Dali::GetImplementation(mMainWindow));
- mAdaptor = Adaptor::New( graphicsFactory, sceneHolder, &mEnvironmentOptions );
+ mAdaptor = Adaptor::New(graphicsFactory, sceneHolder, &mEnvironmentOptions);
- Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
+ Adaptor::GetImplementation(*mAdaptor).SetUseRemoteSurface(mUseRemoteSurface);
}
void Application::CreateAdaptorBuilder()
{
- mAdaptorBuilder = new AdaptorBuilder();
+ mAdaptorBuilder = new AdaptorBuilder(mEnvironmentOptions);
}
void Application::MainLoop()
{
// Actually quit the application.
// Force a call to Quit even if adaptor is not running.
- Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle( MakeCallback( this, &Application::QuitFromMainLoop ), false, true );
+ Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle(MakeCallback(this, &Application::QuitFromMainLoop), false, true);
}
void Application::QuitFromMainLoop()
void Application::OnInit()
{
- mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) );
+ mFramework->AddAbortCallback(MakeCallback(this, &Application::QuitFromMainLoop));
CreateAdaptorBuilder();
// If an application was pre-initialized, a window was made in advance
- if( mLaunchpadState == Launchpad::NONE )
+ if(mLaunchpadState == Launchpad::NONE)
{
CreateWindow();
}
mAdaptor->Start();
Accessibility::Accessible::SetObjectRegistry(mAdaptor->GetObjectRegistry());
- if( ! mStylesheet.empty() )
+ if(!mStylesheet.empty())
{
- Dali::StyleMonitor::Get().SetTheme( mStylesheet );
+ Dali::StyleMonitor::Get().SetTheme(mStylesheet);
}
// Wire up the LifecycleController
Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
- InitSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnInit );
- TerminateSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnTerminate );
- PauseSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnPause );
- ResumeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResume );
- ResetSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnReset );
- LanguageChangedSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnLanguageChanged );
+ InitSignal().Connect(&GetImplementation(lifecycleController), &LifecycleController::OnInit);
+ TerminateSignal().Connect(&GetImplementation(lifecycleController), &LifecycleController::OnTerminate);
+ PauseSignal().Connect(&GetImplementation(lifecycleController), &LifecycleController::OnPause);
+ ResumeSignal().Connect(&GetImplementation(lifecycleController), &LifecycleController::OnResume);
+ ResetSignal().Connect(&GetImplementation(lifecycleController), &LifecycleController::OnReset);
+ LanguageChangedSignal().Connect(&GetImplementation(lifecycleController), &LifecycleController::OnLanguageChanged);
Dali::Application application(this);
- mInitSignal.Emit( application );
+ mInitSignal.Emit(application);
mAdaptor->NotifySceneCreated();
}
// delete the window as ecore_x has been destroyed by AppCore
Dali::Application application(this);
- mTerminateSignal.Emit( application );
+ mTerminateSignal.Emit(application);
- if( mAdaptor )
+ if(mAdaptor)
{
// Ensure that the render-thread is not using the surface(window) after we delete it
mAdaptor->Stop();
// DALi just delivers the framework Pause event to the application, but not actually pause DALi core.
// Pausing DALi core only occurs on the Window Hidden framework event
Dali::Application application(this);
- mPauseSignal.Emit( application );
+ mPauseSignal.Emit(application);
}
void Application::OnResume()
// Emit the signal first so the application can queue any messages before we do an update/render
// This ensures we do not just redraw the last frame before pausing if that's not required
Dali::Application application(this);
- mResumeSignal.Emit( application );
+ mResumeSignal.Emit(application);
// DALi just delivers the framework Resume event to the application.
// Resuming DALi core only occurs on the Window Show framework event
// Trigger processing of events queued up while paused
- CoreEventInterface& coreEventInterface = Internal::Adaptor::Adaptor::GetImplementation( GetAdaptor() );
+ CoreEventInterface& coreEventInterface = Internal::Adaptor::Adaptor::GetImplementation(GetAdaptor());
coreEventInterface.ProcessCoreEvents();
}
* because Application class already handled initialization in OnInit(), OnReset do nothing.
*/
Dali::Application application(this);
- mResetSignal.Emit( application );
+ mResetSignal.Emit(application);
}
-void Application::OnAppControl(void *data)
+void Application::OnAppControl(void* data)
{
Dali::Application application(this);
- mAppControlSignal.Emit( application , data );
+ mAppControlSignal.Emit(application, data);
}
void Application::OnLanguageChanged()
{
mAdaptor->NotifyLanguageChanged();
Dali::Application application(this);
- mLanguageChangedSignal.Emit( application );
+ mLanguageChangedSignal.Emit(application);
}
void Application::OnRegionChanged()
{
Dali::Application application(this);
- mRegionChangedSignal.Emit( application );
+ mRegionChangedSignal.Emit(application);
}
-void Application::OnBatteryLow( Dali::DeviceStatus::Battery::Status status )
+void Application::OnBatteryLow(Dali::DeviceStatus::Battery::Status status)
{
Dali::Application application(this);
- mLowBatterySignal.Emit( status );
+ mLowBatterySignal.Emit(status);
}
-void Application::OnMemoryLow( Dali::DeviceStatus::Memory::Status status )
+void Application::OnMemoryLow(Dali::DeviceStatus::Memory::Status status)
{
Dali::Application application(this);
- mLowMemorySignal.Emit( status );
+ mLowMemorySignal.Emit(status);
}
-void Application::OnSurfaceCreated( Any newSurface )
+void Application::OnSurfaceCreated(Any newSurface)
{
- void* newWindow = AnyCast< void* >( newSurface );
- void* oldWindow = AnyCast< void* >( mMainWindow.GetNativeHandle() );
- if( oldWindow != newWindow )
+ void* newWindow = AnyCast<void*>(newSurface);
+ void* oldWindow = AnyCast<void*>(mMainWindow.GetNativeHandle());
+ if(oldWindow != newWindow)
{
- auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
- std::unique_ptr< WindowRenderSurface > newSurfacePtr
- = renderSurfaceFactory->CreateWindowRenderSurface( PositionSize(), newSurface, true );
+ auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
+ std::unique_ptr<WindowRenderSurface> newSurfacePtr = renderSurfaceFactory->CreateWindowRenderSurface(PositionSize(), newSurface, true);
- mAdaptor->ReplaceSurface( mMainWindow, *newSurfacePtr.release() );
+ mAdaptor->ReplaceSurface(mMainWindow, *newSurfacePtr.release());
}
}
-void Application::OnSurfaceDestroyed( Any surface )
+void Application::OnSurfaceDestroyed(Any surface)
{
}
-bool Application::AddIdle( CallbackBase* callback, bool hasReturnValue )
+bool Application::AddIdle(CallbackBase* callback, bool hasReturnValue)
{
- return mAdaptor->AddIdle( callback, hasReturnValue );
+ return mAdaptor->AddIdle(callback, hasReturnValue);
}
std::string Application::GetRegion() const
Dali::ObjectRegistry Application::GetObjectRegistry() const
{
Dali::ObjectRegistry objectRegistry;
- if( mAdaptor )
+ if(mAdaptor)
{
objectRegistry = mAdaptor->GetObjectRegistry();
}
return Internal::Adaptor::Framework::GetDataPath();
}
-void Application::SetStyleSheet( const std::string& stylesheet )
+void Application::SetStyleSheet(const std::string& stylesheet)
{
mStylesheet = stylesheet;
}
-void Application::SetCommandLineOptions( int* argc, char **argv[] )
+void Application::SetCommandLineOptions(int* argc, char** argv[])
{
delete mCommandLineOptions;
- mCommandLineOptions = new CommandLineOptions( argc, argv );
+ mCommandLineOptions = new CommandLineOptions(argc, argv);
- mFramework->SetCommandLineOptions( argc, argv );
+ mFramework->SetCommandLineOptions(argc, argv);
}
ApplicationPtr Application::GetPreInitializedApplication()
#define DALI_INTERNAL_APPLICATION_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.
#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/application.h>
#include <dali/devel-api/common/singleton-service.h>
+#include <dali/public-api/adaptor-framework/application.h>
+#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
#include <dali/internal/adaptor/common/framework.h>
#include <dali/internal/system/common/environment-options.h>
-#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
namespace Launchpad
{
-
/**
* @brief Launchpad is used to improve application launch performance.
* When an application is pre-initialized, so files are preloaded, some functions are initialized and a window is made in advance.
*/
enum State
{
- NONE, ///< The default state
- PRE_INITIALIZED ///< Application is pre-initialized.
+ NONE, ///< The default state
+ PRE_INITIALIZED ///< Application is pre-initialized.
};
} // namespace Launchpad
class Application : public BaseObject, public Framework::Observer
{
public:
-
typedef Dali::Application::LowBatterySignalType LowBatterySignalType;
- typedef Dali::Application::LowMemorySignalType LowMemorySignalType;
- typedef Dali::Application::AppSignalType AppSignalType;
+ typedef Dali::Application::LowMemorySignalType LowMemorySignalType;
+ typedef Dali::Application::AppSignalType AppSignalType;
typedef Dali::Application::AppControlSignalType AppControlSignalType;
- typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
+ typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
/**
* Create a new application
* @param[in] positionSize A position and a size of the window
* @param[in] applicationType A member of Dali::Framework::Type
*/
- static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet,
- WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType );
+ static ApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType);
/**
* @copydoc Dali::DevelApplication::PreInitialize()
*/
- static void PreInitialize( int* argc, char** argv[] );
+ static void PreInitialize(int* argc, char** argv[]);
public:
-
/**
* @copydoc Dali::Application::MainLoop()
*/
/**
* @copydoc Dali::Application::AddIdle()
*/
- bool AddIdle( CallbackBase* callback, bool hasReturnValue );
+ bool AddIdle(CallbackBase* callback, bool hasReturnValue);
/**
* @copydoc Dali::Application::GetAdaptor();
static ApplicationPtr GetPreInitializedApplication();
public: // From Framework::Observer
-
/**
* Called when the framework is initialised.
*/
* Called when the framework received AppControlSignal.
* @param[in] The bundle data of AppControl event.
*/
- void OnAppControl(void *data) override;
+ void OnAppControl(void* data) override;
/**
* Called when the framework informs the application that it should reset itself.
/**
* Called when the framework informs the application that the battery level of the device is low.
*/
- void OnBatteryLow( Dali::DeviceStatus::Battery::Status status ) override;
+ void OnBatteryLow(Dali::DeviceStatus::Battery::Status status) override;
/**
* Called when the framework informs the application that the memory level of the device is low.
*/
- void OnMemoryLow( Dali::DeviceStatus::Memory::Status status ) override;
+ void OnMemoryLow(Dali::DeviceStatus::Memory::Status status) override;
/**
* Called when the framework informs the application that the platform surface is created.
*/
- void OnSurfaceCreated( Any newSurface ) override;
+ void OnSurfaceCreated(Any newSurface) override;
/**
* Called when the framework informs the application that the platform surface is destroyed.
*/
- void OnSurfaceDestroyed( Any newSurface ) override;
+ void OnSurfaceDestroyed(Any newSurface) override;
public:
-
/**
* Sets a user defined theme file.
* This should be called before initialization.
* @param[in] stylesheet The path to user defined theme file
*/
- void SetStyleSheet( const std::string& stylesheet );
+ void SetStyleSheet(const std::string& stylesheet);
/**
* Sets a command line options.
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
*/
- void SetCommandLineOptions( int* argc, char **argv[] );
-
-public: // Signals
+ void SetCommandLineOptions(int* argc, char** argv[]);
+public: // Signals
/**
* @copydoc Dali::Application::InitSignal()
*/
- Dali::Application::AppSignalType& InitSignal() { return mInitSignal; }
+ Dali::Application::AppSignalType& InitSignal()
+ {
+ return mInitSignal;
+ }
/**
* @copydoc Dali::Application::TerminateSignal()
*/
- Dali::Application::AppSignalType& TerminateSignal() { return mTerminateSignal; }
+ Dali::Application::AppSignalType& TerminateSignal()
+ {
+ return mTerminateSignal;
+ }
/**
* @copydoc Dali::Application::PauseSignal()
*/
- Dali::Application::AppSignalType& PauseSignal() { return mPauseSignal; }
+ Dali::Application::AppSignalType& PauseSignal()
+ {
+ return mPauseSignal;
+ }
/**
* @copydoc Dali::Application::ResumeSignal()
*/
- Dali::Application::AppSignalType& ResumeSignal() { return mResumeSignal; }
+ Dali::Application::AppSignalType& ResumeSignal()
+ {
+ return mResumeSignal;
+ }
/**
* @copydoc Dali::Application::ResetSignal()
*/
- Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
+ Dali::Application::AppSignalType& ResetSignal()
+ {
+ return mResetSignal;
+ }
/**
* @copydoc Dali::Application::AppControlSignal()
*/
- Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
+ Dali::Application::AppControlSignalType& AppControlSignal()
+ {
+ return mAppControlSignal;
+ }
/**
* @copydoc Dali::Application::LanguageChangedSignal()
*/
- Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
+ Dali::Application::AppSignalType& LanguageChangedSignal()
+ {
+ return mLanguageChangedSignal;
+ }
/**
* @copydoc Dali::Application::RegionChangedSignal()
*/
- Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
+ Dali::Application::AppSignalType& RegionChangedSignal()
+ {
+ return mRegionChangedSignal;
+ }
/**
* @copydoc Dali::Application::LowBatterySignal()
*/
- Dali::Application::LowBatterySignalType& LowBatterySignal() { return mLowBatterySignal; }
+ Dali::Application::LowBatterySignalType& LowBatterySignal()
+ {
+ return mLowBatterySignal;
+ }
/**
* @copydoc Dali::Application:::LowMemorySignal()
*/
- Dali::Application::LowMemorySignalType& LowMemorySignal() { return mLowMemorySignal; }
+ Dali::Application::LowMemorySignalType& LowMemorySignal()
+ {
+ return mLowMemorySignal;
+ }
protected:
-
/**
* Private Constructor
* @param[in] argc A pointer to the number of arguments
* @param[in] positionSize A position and a size of the window
* @param[in] applicationType A member of Dali::Framework::Type
*/
- Application( int* argc, char **argv[], const std::string& stylesheet,
- WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType );
+ Application(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType);
/**
* Destructor
void QuitFromMainLoop();
private:
-
- AppSignalType mInitSignal;
- AppSignalType mTerminateSignal;
- AppSignalType mPauseSignal;
- AppSignalType mResumeSignal;
- AppSignalType mResetSignal;
- AppControlSignalType mAppControlSignal;
- AppSignalType mLanguageChangedSignal;
- AppSignalType mRegionChangedSignal;
- LowBatterySignalType mLowBatterySignal;
- LowMemorySignalType mLowMemorySignal;
-
- EventLoop* mEventLoop;
- Framework* mFramework;
-
- CommandLineOptions* mCommandLineOptions;
-
- Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder; ///< The adaptor builder
+ AppSignalType mInitSignal;
+ AppSignalType mTerminateSignal;
+ AppSignalType mPauseSignal;
+ AppSignalType mResumeSignal;
+ AppSignalType mResetSignal;
+ AppControlSignalType mAppControlSignal;
+ AppSignalType mLanguageChangedSignal;
+ AppSignalType mRegionChangedSignal;
+ LowBatterySignalType mLowBatterySignal;
+ LowMemorySignalType mLowMemorySignal;
+
+ EventLoop* mEventLoop;
+ Framework* mFramework;
+
+ CommandLineOptions* mCommandLineOptions;
+
+ Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder; ///< The adaptor builder
Dali::Adaptor* mAdaptor;
// The Main Window is that window created by the Application during initial startup
// (previously this was the only window)
- Dali::Window mMainWindow; ///< Main Window instance
- Dali::Application::WINDOW_MODE mMainWindowMode; ///< Window mode of the main window
- std::string mMainWindowName; ///< Name of the main window as obtained from environment options
+ Dali::Window mMainWindow; ///< Main Window instance
+ Dali::Application::WINDOW_MODE mMainWindowMode; ///< Window mode of the main window
+ std::string mMainWindowName; ///< Name of the main window as obtained from environment options
- std::string mStylesheet;
- EnvironmentOptions mEnvironmentOptions;
- PositionSize mWindowPositionSize;
- Launchpad::State mLaunchpadState;
- bool mUseRemoteSurface;
+ std::string mStylesheet;
+ EnvironmentOptions mEnvironmentOptions;
+ PositionSize mWindowPositionSize;
+ Launchpad::State mLaunchpadState;
+ bool mUseRemoteSurface;
- SlotDelegate< Application > mSlotDelegate;
+ SlotDelegate<Application> mSlotDelegate;
- static ApplicationPtr gPreInitializedApplication;
+ static ApplicationPtr gPreInitializedApplication;
};
inline Application& GetImplementation(Dali::Application& application)
return static_cast<const Internal::Adaptor::Application&>(handle);
}
-
} // namespace Adaptor
} // namespace Internal
#define DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_DEBUG_H
/*
- * 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
{
// Uncomment next line for FULL logging of the ThreadSynchronization class in release mode
#define ENABLE_UPDATE_RENDER_THREAD_LOGGING
#define ENABLE_EVENT_LOGGING
-#define DEBUG_LEVEL_COUNTER Debug::Verbose
-#define DEBUG_LEVEL_UPDATE_RENDER Debug::General
-#define DEBUG_LEVEL_EVENT Debug::Concise
+#define DEBUG_LEVEL_COUNTER Debug::Verbose
+#define DEBUG_LEVEL_UPDATE_RENDER Debug::General
+#define DEBUG_LEVEL_EVENT Debug::Concise
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_THREAD_SYNC" );
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_THREAD_SYNC");
#define LOG_THREAD_SYNC(level, color, format, ...) \
- DALI_LOG_INFO( gLogFilter, level, "%s" format "%s\n", color, ## __VA_ARGS__, COLOR_CLEAR )
+ DALI_LOG_INFO(gLogFilter, level, "%s" format "%s\n", color, ##__VA_ARGS__, COLOR_CLEAR)
-#define LOG_THREAD_SYNC_TRACE(color) \
- Dali::Integration::Log::TraceObj debugTraceObj( gLogFilter, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR ); \
- if( ! gLogFilter->IsTraceEnabled() ) { LOG_THREAD_SYNC( Debug::Concise, color, "%s", __FUNCTION__ ); }
+#define LOG_THREAD_SYNC_TRACE(color) \
+ Dali::Integration::Log::TraceObj debugTraceObj(gLogFilter, "%s%s%s", color, __FUNCTION__, COLOR_CLEAR); \
+ if(!gLogFilter->IsTraceEnabled()) \
+ { \
+ LOG_THREAD_SYNC(Debug::Concise, color, "%s", __FUNCTION__); \
+ }
-#define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...) \
- Dali::Integration::Log::TraceObj debugTraceObj( gLogFilter, "%s%s: " format "%s", color, __FUNCTION__, ## __VA_ARGS__, COLOR_CLEAR ); \
- if( ! gLogFilter->IsTraceEnabled() ) { LOG_THREAD_SYNC( Debug::Concise, color, "%s: " format, __FUNCTION__, ## __VA_ARGS__ ); }
+#define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...) \
+ Dali::Integration::Log::TraceObj debugTraceObj(gLogFilter, "%s%s: " format "%s", color, __FUNCTION__, ##__VA_ARGS__, COLOR_CLEAR); \
+ if(!gLogFilter->IsTraceEnabled()) \
+ { \
+ LOG_THREAD_SYNC(Debug::Concise, color, "%s: " format, __FUNCTION__, ##__VA_ARGS__); \
+ }
-#elif defined( RELEASE_BUILD_LOGGING )
+#elif defined(RELEASE_BUILD_LOGGING)
#define ENABLE_LOG_IN_COLOR
#define ENABLE_COUNTER_LOGGING
#define ENABLE_UPDATE_RENDER_THREAD_LOGGING
#define ENABLE_EVENT_LOGGING
-#define DEBUG_LEVEL_COUNTER 0
-#define DEBUG_LEVEL_UPDATE_RENDER 0
-#define DEBUG_LEVEL_EVENT 0
+#define DEBUG_LEVEL_COUNTER 0
+#define DEBUG_LEVEL_UPDATE_RENDER 0
+#define DEBUG_LEVEL_EVENT 0
#define LOG_THREAD_SYNC(level, color, format, ...) \
- Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ## __VA_ARGS__, COLOR_CLEAR )
+ Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s" format "%s\n", color, ##__VA_ARGS__, COLOR_CLEAR)
#define LOG_THREAD_SYNC_TRACE(color) \
- Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s%s%s\n", color, __FUNCTION__, COLOR_CLEAR )
+ Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s%s%s\n", color, __FUNCTION__, COLOR_CLEAR)
#define LOG_THREAD_SYNC_TRACE_FMT(color, format, ...) \
- Dali::Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo, "%s%s: " format "%s\n", color, __FUNCTION__, ## __VA_ARGS__, COLOR_CLEAR )
+ Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s%s: " format "%s\n", color, __FUNCTION__, ##__VA_ARGS__, COLOR_CLEAR)
#else
#endif // DEBUG_ENABLED
#ifdef ENABLE_LOG_IN_COLOR
-#define COLOR_YELLOW "\033[33m"
-#define COLOR_LIGHT_RED "\033[91m"
-#define COLOR_LIGHT_YELLOW "\033[93m"
-#define COLOR_WHITE "\033[97m"
-#define COLOR_CLEAR "\033[0m"
+#define COLOR_YELLOW "\033[33m"
+#define COLOR_LIGHT_RED "\033[91m"
+#define COLOR_LIGHT_YELLOW "\033[93m"
+#define COLOR_WHITE "\033[97m"
+#define COLOR_CLEAR "\033[0m"
#else
#define COLOR_YELLOW
#define COLOR_LIGHT_RED
#endif
#ifdef ENABLE_COUNTER_LOGGING
-#define LOG_COUNTER_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ## __VA_ARGS__)
-#define LOG_COUNTER_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ## __VA_ARGS__)
+#define LOG_COUNTER_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_RED, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
+#define LOG_COUNTER_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_COUNTER, COLOR_LIGHT_YELLOW, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
#else
#define LOG_COUNTER_EVENT(format, ...)
#define LOG_COUNTER_UPDATE_RENDER(format, ...)
#endif
#ifdef ENABLE_UPDATE_RENDER_THREAD_LOGGING
-#define LOG_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_UPDATE_RENDER, COLOR_YELLOW, "%s: " format, __FUNCTION__, ## __VA_ARGS__)
-#define LOG_UPDATE_RENDER_TRACE LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
-#define LOG_UPDATE_RENDER_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ## __VA_ARGS__)
+#define LOG_UPDATE_RENDER(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_UPDATE_RENDER, COLOR_YELLOW, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
+#define LOG_UPDATE_RENDER_TRACE LOG_THREAD_SYNC_TRACE(COLOR_YELLOW)
+#define LOG_UPDATE_RENDER_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_YELLOW, format, ##__VA_ARGS__)
#else
#define LOG_UPDATE_RENDER(format, ...)
#define LOG_UPDATE_RENDER_TRACE
#endif
#ifdef ENABLE_EVENT_LOGGING
-#define LOG_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_EVENT, COLOR_WHITE, "%s: " format, __FUNCTION__, ## __VA_ARGS__)
-#define LOG_EVENT_TRACE LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
-#define LOG_EVENT_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ## __VA_ARGS__)
+#define LOG_EVENT(format, ...) LOG_THREAD_SYNC(DEBUG_LEVEL_EVENT, COLOR_WHITE, "%s: " format, __FUNCTION__, ##__VA_ARGS__)
+#define LOG_EVENT_TRACE LOG_THREAD_SYNC_TRACE(COLOR_WHITE)
+#define LOG_EVENT_TRACE_FMT(format, ...) LOG_THREAD_SYNC_TRACE_FMT(COLOR_WHITE, format, ##__VA_ARGS__)
#else
#define LOG_EVENT(format, ...)
#define LOG_EVENT_TRACE
/*
- * 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/adaptor/common/combined-update-render-controller.h>
// EXTERNAL INCLUDES
-#include <errno.h>
#include <dali/integration-api/platform-abstraction.h>
+#include <errno.h>
#include <unistd.h>
+#include "dali/public-api/common/dali-common.h"
// INTERNAL INCLUDES
-#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
#include <dali/devel-api/adaptor-framework/thread-settings.h>
+#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
#include <dali/internal/adaptor/common/adaptor-internal-services.h>
#include <dali/internal/adaptor/common/combined-update-render-controller-debug.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/graphics/gles/egl-implementation.h>
-#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/system/common/time-service.h>
#include <dali/internal/window-system/common/window-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
const unsigned int CREATED_THREAD_COUNT = 1u;
const int CONTINUOUS = -1;
-const int ONCE = 1;
+const int ONCE = 1;
-const unsigned int TRUE = 1u;
+const unsigned int TRUE = 1u;
const unsigned int FALSE = 0u;
-const unsigned int MILLISECONDS_PER_SECOND( 1e+3 );
-const float NANOSECONDS_TO_SECOND( 1e-9f );
-const unsigned int NANOSECONDS_PER_SECOND( 1e+9 );
-const unsigned int NANOSECONDS_PER_MILLISECOND( 1e+6 );
+const unsigned int MILLISECONDS_PER_SECOND(1e+3);
+const float NANOSECONDS_TO_SECOND(1e-9f);
+const unsigned int NANOSECONDS_PER_SECOND(1e+9);
+const unsigned int NANOSECONDS_PER_MILLISECOND(1e+6);
// The following values will get calculated at compile time
-const float DEFAULT_FRAME_DURATION_IN_SECONDS( 1.0f / 60.0f );
-const uint64_t DEFAULT_FRAME_DURATION_IN_MILLISECONDS( DEFAULT_FRAME_DURATION_IN_SECONDS * MILLISECONDS_PER_SECOND );
-const uint64_t DEFAULT_FRAME_DURATION_IN_NANOSECONDS( DEFAULT_FRAME_DURATION_IN_SECONDS * NANOSECONDS_PER_SECOND );
+const float DEFAULT_FRAME_DURATION_IN_SECONDS(1.0f / 60.0f);
+const uint64_t DEFAULT_FRAME_DURATION_IN_MILLISECONDS(DEFAULT_FRAME_DURATION_IN_SECONDS* MILLISECONDS_PER_SECOND);
+const uint64_t DEFAULT_FRAME_DURATION_IN_NANOSECONDS(DEFAULT_FRAME_DURATION_IN_SECONDS* NANOSECONDS_PER_SECOND);
/**
* Handles the use case when an update-request is received JUST before we process a sleep-request. If we did not have an update-request count then
// EVENT THREAD
///////////////////////////////////////////////////////////////////////////////////////////////////
-CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode )
-: mFpsTracker( environmentOptions ),
- mUpdateStatusLogger( environmentOptions ),
- mEventThreadSemaphore(),
- mGraphicsInitializeSemaphore(),
- mSurfaceSemaphore(),
+CombinedUpdateRenderController::CombinedUpdateRenderController(AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode)
+: mFpsTracker(environmentOptions),
+ mUpdateStatusLogger(environmentOptions),
+ mEventThreadSemaphore(0),
+ mSurfaceSemaphore(0),
mUpdateRenderThreadWaitCondition(),
- mAdaptorInterfaces( adaptorInterfaces ),
- mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ),
- mCore( adaptorInterfaces.GetCore() ),
- mEnvironmentOptions( environmentOptions ),
- mNotificationTrigger( adaptorInterfaces.GetProcessCoreEventsTrigger() ),
- mSleepTrigger( NULL ),
- mPreRenderCallback( NULL ),
- mUpdateRenderThread( NULL ),
- mDefaultFrameDelta( 0.0f ),
- mDefaultFrameDurationMilliseconds( 0u ),
- mDefaultFrameDurationNanoseconds( 0u ),
- mDefaultHalfFrameNanoseconds( 0u ),
- mUpdateRequestCount( 0u ),
- mRunning( FALSE ),
- mThreadMode( threadMode ),
- mUpdateRenderRunCount( 0 ),
- mDestroyUpdateRenderThread( FALSE ),
- mUpdateRenderThreadCanSleep( FALSE ),
- mPendingRequestUpdate( FALSE ),
- mUseElapsedTimeAfterWait( FALSE ),
- mNewSurface( NULL ),
- mDeletedSurface( nullptr ),
- mPostRendering( FALSE ),
- mSurfaceResized( FALSE ),
- mForceClear( FALSE ),
- mUploadWithoutRendering( FALSE ),
- mFirstFrameAfterResume( FALSE )
+ mAdaptorInterfaces(adaptorInterfaces),
+ mPerformanceInterface(adaptorInterfaces.GetPerformanceInterface()),
+ mCore(adaptorInterfaces.GetCore()),
+ mEnvironmentOptions(environmentOptions),
+ mNotificationTrigger(adaptorInterfaces.GetProcessCoreEventsTrigger()),
+ mSleepTrigger(NULL),
+ mPreRenderCallback(NULL),
+ mUpdateRenderThread(NULL),
+ mDefaultFrameDelta(0.0f),
+ mDefaultFrameDurationMilliseconds(0u),
+ mDefaultFrameDurationNanoseconds(0u),
+ mDefaultHalfFrameNanoseconds(0u),
+ mUpdateRequestCount(0u),
+ mRunning(FALSE),
+ mThreadMode(threadMode),
+ mUpdateRenderRunCount(0),
+ mDestroyUpdateRenderThread(FALSE),
+ mUpdateRenderThreadCanSleep(FALSE),
+ mPendingRequestUpdate(FALSE),
+ mUseElapsedTimeAfterWait(FALSE),
+ mNewSurface(NULL),
+ mDeletedSurface(nullptr),
+ mPostRendering(FALSE),
+ mSurfaceResized(0),
+ mForceClear(FALSE),
+ mUploadWithoutRendering(FALSE),
+ mFirstFrameAfterResume(FALSE)
{
LOG_EVENT_TRACE;
// Initialise frame delta/duration variables first
- SetRenderRefreshRate( environmentOptions.GetRenderRefreshRate() );
+ SetRenderRefreshRate(environmentOptions.GetRenderRefreshRate());
// Set the thread-synchronization interface on the render-surface
Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
- if( currentSurface )
+ if(currentSurface)
{
- currentSurface->SetThreadSynchronization( *this );
+ currentSurface->SetThreadSynchronization(*this);
}
- mSleepTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &CombinedUpdateRenderController::ProcessSleepRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER );
-
- // Initialize to 0 so that it just waits if sem_post has not been called
- sem_init( &mEventThreadSemaphore, 0, 0 );
- sem_init( &mGraphicsInitializeSemaphore, 0, 0 );
- sem_init( &mSurfaceSemaphore, 0, 0 );
+ mSleepTrigger = TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &CombinedUpdateRenderController::ProcessSleepRequest), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
}
CombinedUpdateRenderController::~CombinedUpdateRenderController()
LOG_EVENT_TRACE;
// Ensure Update/Render Thread not already created
- DALI_ASSERT_ALWAYS( ! mUpdateRenderThread );
+ DALI_ASSERT_ALWAYS(!mUpdateRenderThread);
// Create Update/Render Thread
+ ConditionalWait::ScopedLock lock(mGraphicsInitializeWait);
mUpdateRenderThread = new pthread_t();
- int error = pthread_create( mUpdateRenderThread, NULL, InternalUpdateRenderThreadEntryFunc, this );
- DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() when creating UpdateRenderThread" );
+ int error = pthread_create(mUpdateRenderThread, NULL, InternalUpdateRenderThreadEntryFunc, this);
+ DALI_ASSERT_ALWAYS(!error && "Return code from pthread_create() when creating UpdateRenderThread");
// The Update/Render thread will now run and initialise the graphics interface etc. and will then wait for Start to be called
// When this function returns, the application initialisation on the event thread should occur
{
LOG_EVENT_TRACE;
- DALI_ASSERT_ALWAYS( !mRunning && mUpdateRenderThread );
+ DALI_ASSERT_ALWAYS(!mRunning && mUpdateRenderThread);
// Wait until all threads created in Initialise are up and running
- for( unsigned int i = 0; i < CREATED_THREAD_COUNT; ++i )
+ for(unsigned int i = 0; i < CREATED_THREAD_COUNT; ++i)
{
- sem_wait( &mEventThreadSemaphore );
+ mEventThreadSemaphore.Acquire();
}
+ mRunning = TRUE;
+
+ LOG_EVENT("Startup Complete, starting Update/Render Thread");
+
+ RunUpdateRenderThread(CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL);
+
Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
- if( currentSurface )
+ if(currentSurface)
{
currentSurface->StartRender();
}
- mRunning = TRUE;
-
- LOG_EVENT( "Startup Complete, starting Update/Render Thread" );
-
- RunUpdateRenderThread( CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL );
-
- DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Start\n" );
+ DALI_LOG_RELEASE_INFO("CombinedUpdateRenderController::Start\n");
}
void CombinedUpdateRenderController::Pause()
PauseUpdateRenderThread();
- AddPerformanceMarker( PerformanceInterface::PAUSED );
+ AddPerformanceMarker(PerformanceInterface::PAUSED);
- DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Pause\n" );
+ DALI_LOG_RELEASE_INFO("CombinedUpdateRenderController::Pause\n");
}
void CombinedUpdateRenderController::Resume()
{
LOG_EVENT_TRACE;
- if( !mRunning && IsUpdateRenderThreadPaused() )
+ if(!mRunning && IsUpdateRenderThreadPaused())
{
- LOG_EVENT( "Resuming" );
+ LOG_EVENT("Resuming");
- RunUpdateRenderThread( CONTINUOUS, AnimationProgression::USE_ELAPSED_TIME, UpdateMode::NORMAL );
+ RunUpdateRenderThread(CONTINUOUS, AnimationProgression::USE_ELAPSED_TIME, UpdateMode::NORMAL);
- AddPerformanceMarker( PerformanceInterface::RESUME );
+ AddPerformanceMarker(PerformanceInterface::RESUME);
- mRunning = TRUE;
- mForceClear = TRUE;
+ mRunning = TRUE;
+ mForceClear = TRUE;
mFirstFrameAfterResume = TRUE;
- DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" );
+ DALI_LOG_RELEASE_INFO("CombinedUpdateRenderController::Resume\n");
}
else
{
- DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume: Already resumed [%d, %d, %d]\n", mRunning, mUpdateRenderRunCount, mUpdateRenderThreadCanSleep );
+ DALI_LOG_RELEASE_INFO("CombinedUpdateRenderController::Resume: Already resumed [%d, %d, %d]\n", mRunning, mUpdateRenderRunCount, mUpdateRenderThreadCanSleep);
}
}
// Stop Rendering and the Update/Render Thread
Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
- if( currentSurface )
+ if(currentSurface)
{
currentSurface->StopRender();
}
StopUpdateRenderThread();
- if( mUpdateRenderThread )
+ if(mUpdateRenderThread)
{
- LOG_EVENT( "Destroying UpdateRenderThread" );
+ LOG_EVENT("Destroying UpdateRenderThread");
// wait for the thread to finish
- pthread_join( *mUpdateRenderThread, NULL );
+ pthread_join(*mUpdateRenderThread, NULL);
delete mUpdateRenderThread;
mUpdateRenderThread = NULL;
mRunning = FALSE;
- DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Stop\n" );
+ DALI_LOG_RELEASE_INFO("CombinedUpdateRenderController::Stop\n");
}
void CombinedUpdateRenderController::RequestUpdate()
LOG_EVENT_TRACE;
// Increment the update-request count to the maximum
- if( mUpdateRequestCount < MAXIMUM_UPDATE_REQUESTS )
+ if(mUpdateRequestCount < MAXIMUM_UPDATE_REQUESTS)
{
++mUpdateRequestCount;
}
- if( mRunning && IsUpdateRenderThreadPaused() )
+ if(mRunning && IsUpdateRenderThreadPaused())
{
- LOG_EVENT( "Processing" );
+ LOG_EVENT("Processing");
- RunUpdateRenderThread( CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL );
+ RunUpdateRenderThread(CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL);
}
- ConditionalWait::ScopedLock updateLock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock updateLock(mUpdateRenderThreadWaitCondition);
mPendingRequestUpdate = TRUE;
}
-void CombinedUpdateRenderController::RequestUpdateOnce( UpdateMode updateMode )
+void CombinedUpdateRenderController::RequestUpdateOnce(UpdateMode updateMode)
{
// Increment the update-request count to the maximum
- if( mUpdateRequestCount < MAXIMUM_UPDATE_REQUESTS )
+ if(mUpdateRequestCount < MAXIMUM_UPDATE_REQUESTS)
{
++mUpdateRequestCount;
}
- if( IsUpdateRenderThreadPaused() || updateMode == UpdateMode::FORCE_RENDER )
+ if(IsUpdateRenderThreadPaused() || updateMode == UpdateMode::FORCE_RENDER)
{
LOG_EVENT_TRACE;
// Run Update/Render once
- RunUpdateRenderThread( ONCE, AnimationProgression::NONE, updateMode );
+ RunUpdateRenderThread(ONCE, AnimationProgression::NONE, updateMode);
}
}
-void CombinedUpdateRenderController::ReplaceSurface( Dali::RenderSurfaceInterface* newSurface )
+void CombinedUpdateRenderController::ReplaceSurface(Dali::RenderSurfaceInterface* newSurface)
{
LOG_EVENT_TRACE;
- if( mUpdateRenderThread )
+ if(mUpdateRenderThread)
{
// Set the ThreadSyncronizationInterface on the new surface
- newSurface->SetThreadSynchronization( *this );
+ newSurface->SetThreadSynchronization(*this);
- LOG_EVENT( "Starting to replace the surface, event-thread blocked" );
+ LOG_EVENT("Starting to replace the surface, event-thread blocked");
// Start replacing the surface.
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will replace the surface now
- mNewSurface = newSurface;
- mUpdateRenderThreadWaitCondition.Notify( lock );
+ mNewSurface = newSurface;
+ mUpdateRenderThreadWaitCondition.Notify(lock);
}
// Wait until the surface has been replaced
- sem_wait( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Acquire();
- LOG_EVENT( "Surface replaced, event-thread continuing" );
+ LOG_EVENT("Surface replaced, event-thread continuing");
}
}
-void CombinedUpdateRenderController::DeleteSurface( Dali::RenderSurfaceInterface* surface )
+void CombinedUpdateRenderController::DeleteSurface(Dali::RenderSurfaceInterface* surface)
{
LOG_EVENT_TRACE;
- if( mUpdateRenderThread )
+ if(mUpdateRenderThread)
{
- LOG_EVENT( "Starting to delete the surface, event-thread blocked" );
+ LOG_EVENT("Starting to delete the surface, event-thread blocked");
// Start replacing the surface.
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
- mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will delete the surface now
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
+ mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will delete the surface now
mDeletedSurface = surface;
- mUpdateRenderThreadWaitCondition.Notify( lock );
+ mUpdateRenderThreadWaitCondition.Notify(lock);
}
// Wait until the surface has been deleted
- sem_wait( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Acquire();
- LOG_EVENT( "Surface deleted, event-thread continuing" );
+ LOG_EVENT("Surface deleted, event-thread continuing");
}
}
void CombinedUpdateRenderController::WaitForGraphicsInitialization()
{
+ ConditionalWait::ScopedLock lk(mGraphicsInitializeWait);
LOG_EVENT_TRACE;
- if( mUpdateRenderThread )
+ if(mUpdateRenderThread)
{
- LOG_EVENT( "Waiting for graphics initialisation, event-thread blocked" );
+ LOG_EVENT("Waiting for graphics initialisation, event-thread blocked");
// Wait until the graphics has been initialised
- sem_wait( &mGraphicsInitializeSemaphore );
+ mGraphicsInitializeWait.Wait(lk);
- LOG_EVENT( "graphics initialised, event-thread continuing" );
+ LOG_EVENT("graphics initialised, event-thread continuing");
}
}
{
LOG_EVENT_TRACE;
- LOG_EVENT( "Resize the surface" );
+ LOG_EVENT("Resize the surface");
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will resize the surface now
- mSurfaceResized = TRUE;
- mUpdateRenderThreadWaitCondition.Notify( lock );
+ // Surface is resized and the surface resized count is increased.
+ mSurfaceResized++;
+ mUpdateRenderThreadWaitCondition.Notify(lock);
}
}
-void CombinedUpdateRenderController::SetRenderRefreshRate( unsigned int numberOfFramesPerRender )
+void CombinedUpdateRenderController::SetRenderRefreshRate(unsigned int numberOfFramesPerRender)
{
// Not protected by lock, but written to rarely so not worth adding a lock when reading
- mDefaultFrameDelta = numberOfFramesPerRender * DEFAULT_FRAME_DURATION_IN_SECONDS;
- mDefaultFrameDurationMilliseconds = uint64_t( numberOfFramesPerRender ) * DEFAULT_FRAME_DURATION_IN_MILLISECONDS;
- mDefaultFrameDurationNanoseconds = uint64_t( numberOfFramesPerRender ) * DEFAULT_FRAME_DURATION_IN_NANOSECONDS;
- mDefaultHalfFrameNanoseconds = mDefaultFrameDurationNanoseconds / 2u;
+ mDefaultFrameDelta = numberOfFramesPerRender * DEFAULT_FRAME_DURATION_IN_SECONDS;
+ mDefaultFrameDurationMilliseconds = uint64_t(numberOfFramesPerRender) * DEFAULT_FRAME_DURATION_IN_MILLISECONDS;
+ mDefaultFrameDurationNanoseconds = uint64_t(numberOfFramesPerRender) * DEFAULT_FRAME_DURATION_IN_NANOSECONDS;
+ mDefaultHalfFrameNanoseconds = mDefaultFrameDurationNanoseconds / 2u;
- LOG_EVENT( "mDefaultFrameDelta(%.6f), mDefaultFrameDurationMilliseconds(%lld), mDefaultFrameDurationNanoseconds(%lld)", mDefaultFrameDelta, mDefaultFrameDurationMilliseconds, mDefaultFrameDurationNanoseconds );
+ LOG_EVENT("mDefaultFrameDelta(%.6f), mDefaultFrameDurationMilliseconds(%lld), mDefaultFrameDurationNanoseconds(%lld)", mDefaultFrameDelta, mDefaultFrameDurationMilliseconds, mDefaultFrameDurationNanoseconds);
}
-void CombinedUpdateRenderController::SetPreRenderCallback( CallbackBase* callback )
+void CombinedUpdateRenderController::SetPreRenderCallback(CallbackBase* callback)
{
LOG_EVENT_TRACE;
- LOG_EVENT( "Set PreRender Callback" );
+ LOG_EVENT("Set PreRender Callback");
- ConditionalWait::ScopedLock updateLock( mUpdateRenderThreadWaitCondition );
- if( mPreRenderCallback )
+ ConditionalWait::ScopedLock updateLock(mUpdateRenderThreadWaitCondition);
+ if(mPreRenderCallback)
{
delete mPreRenderCallback;
}
mPreRenderCallback = callback;
}
-void CombinedUpdateRenderController::AddSurface( Dali::RenderSurfaceInterface* surface )
+void CombinedUpdateRenderController::AddSurface(Dali::RenderSurfaceInterface* surface)
{
LOG_EVENT_TRACE;
- LOG_EVENT( "Surface is added" );
- if( mUpdateRenderThread )
+ LOG_EVENT("Surface is added");
+ if(mUpdateRenderThread)
{
// Set the ThreadSyncronizationInterface on the added surface
- surface->SetThreadSynchronization( *this );
+ surface->SetThreadSynchronization(*this);
}
}
// EVENT THREAD
///////////////////////////////////////////////////////////////////////////////////////////////////
-void CombinedUpdateRenderController::RunUpdateRenderThread( int numberOfCycles, AnimationProgression animationProgression, UpdateMode updateMode )
+void CombinedUpdateRenderController::RunUpdateRenderThread(int numberOfCycles, AnimationProgression animationProgression, UpdateMode updateMode)
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
- switch( mThreadMode )
+ switch(mThreadMode)
{
case ThreadMode::NORMAL:
{
- mUpdateRenderRunCount = numberOfCycles;
- mUseElapsedTimeAfterWait = ( animationProgression == AnimationProgression::USE_ELAPSED_TIME );
+ mUpdateRenderRunCount = numberOfCycles;
+ mUseElapsedTimeAfterWait = (animationProgression == AnimationProgression::USE_ELAPSED_TIME);
break;
}
case ThreadMode::RUN_IF_REQUESTED:
{
- if( updateMode != UpdateMode::FORCE_RENDER )
+ if(updateMode != UpdateMode::FORCE_RENDER)
{
// Render only if the update mode is FORCE_RENDER which means the application requests it.
// We don't want to awake the update thread.
return;
}
- mUpdateRenderRunCount++; // Increase the update request count
- mUseElapsedTimeAfterWait = TRUE; // The elapsed time should be used. We want animations to proceed.
+ mUpdateRenderRunCount++; // Increase the update request count
+ mUseElapsedTimeAfterWait = TRUE; // The elapsed time should be used. We want animations to proceed.
break;
}
}
mUpdateRenderThreadCanSleep = FALSE;
- mUploadWithoutRendering = ( updateMode == UpdateMode::SKIP_RENDER );
- LOG_COUNTER_EVENT( "mUpdateRenderRunCount: %d, mUseElapsedTimeAfterWait: %d", mUpdateRenderRunCount, mUseElapsedTimeAfterWait );
- mUpdateRenderThreadWaitCondition.Notify( lock );
+ mUploadWithoutRendering = (updateMode == UpdateMode::SKIP_RENDER);
+ LOG_COUNTER_EVENT("mUpdateRenderRunCount: %d, mUseElapsedTimeAfterWait: %d", mUpdateRenderRunCount, mUseElapsedTimeAfterWait);
+ mUpdateRenderThreadWaitCondition.Notify(lock);
}
void CombinedUpdateRenderController::PauseUpdateRenderThread()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mUpdateRenderRunCount = 0;
}
void CombinedUpdateRenderController::StopUpdateRenderThread()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mDestroyUpdateRenderThread = TRUE;
- mUpdateRenderThreadWaitCondition.Notify( lock );
+ mUpdateRenderThreadWaitCondition.Notify(lock);
}
bool CombinedUpdateRenderController::IsUpdateRenderThreadPaused()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
- if( mThreadMode == ThreadMode::RUN_IF_REQUESTED )
+ if(mThreadMode == ThreadMode::RUN_IF_REQUESTED)
{
return !mRunning || mUpdateRenderThreadCanSleep;
}
- return ( mUpdateRenderRunCount != CONTINUOUS ) || // Report paused if NOT continuously running
- mUpdateRenderThreadCanSleep; // Report paused if sleeping
+ return (mUpdateRenderRunCount != CONTINUOUS) || // Report paused if NOT continuously running
+ mUpdateRenderThreadCanSleep; // Report paused if sleeping
}
void CombinedUpdateRenderController::ProcessSleepRequest()
LOG_EVENT_TRACE;
// Decrement Update request count
- if( mUpdateRequestCount > 0 )
+ if(mUpdateRequestCount > 0)
{
--mUpdateRequestCount;
}
// Can sleep if our update-request count is 0
// Update/Render thread can choose to carry on updating if it determines more update/renders are required
- if( mUpdateRequestCount == 0 )
+ if(mUpdateRequestCount == 0)
{
- LOG_EVENT( "Going to sleep" );
+ LOG_EVENT("Going to sleep");
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mUpdateRenderThreadCanSleep = TRUE;
}
}
// Install a function for tracing
mEnvironmentOptions.InstallTraceFunction();
- LOG_UPDATE_RENDER( "THREAD CREATED" );
-
- // Initialize EGL & OpenGL
- Dali::DisplayConnection& displayConnection = mAdaptorInterfaces.GetDisplayConnectionInterface();
- displayConnection.Initialize();
-
- // EGL has been initialised at this point
- NotifyGraphicsInitialised();
-
- RenderSurfaceInterface* currentSurface = nullptr;
+ LOG_UPDATE_RENDER("THREAD CREATED");
+ // Initialize graphics
GraphicsInterface& graphics = mAdaptorInterfaces.GetGraphicsInterface();
- EglGraphics* eglGraphics = static_cast<EglGraphics *>(&graphics);
-
- // This will only be created once
- EglInterface* eglInterface = &eglGraphics->GetEglInterface();
+ graphics.Initialize();
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( *eglInterface );
-
- // Try to use OpenGL es 3.0
- // ChooseConfig returns false here when the device only support gles 2.0.
- // Because eglChooseConfig with gles 3.0 setting fails when the device only support gles 2.0 and Our default setting is gles 3.0.
- if( !eglImpl.ChooseConfig( true, COLOR_DEPTH_32 ) )
- {
- // Retry to use OpenGL es 2.0
- eglGraphics->SetGlesVersion( 20 );
- eglImpl.ChooseConfig( true, COLOR_DEPTH_32 );
- }
-
- // Check whether surfaceless context is supported
- bool isSurfacelessContextSupported = eglImpl.IsSurfacelessContextSupported();
- eglGraphics->SetIsSurfacelessContextSupported( isSurfacelessContextSupported );
+ Dali::DisplayConnection& displayConnection = mAdaptorInterfaces.GetDisplayConnectionInterface();
+ displayConnection.Initialize(); //@todo Move InitializeGraphics code into graphics implementation
- if ( isSurfacelessContextSupported )
- {
- // Create a surfaceless OpenGL context for shared resources
- eglImpl.CreateContext();
- eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() );
- }
- else
- {
- currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
- if( currentSurface )
- {
- currentSurface->InitializeGraphics();
- currentSurface->MakeContextCurrent();
- }
- }
+ NotifyGraphicsInitialised();
- GlImplementation& gles = eglGraphics->GetGlesInterface();
- gles.ContextCreated();
- eglGraphics->SetGlesVersion( gles.GetGlesVersion() );
+ //@todo Vk swaps this around, but we need to support surfaceless context for multi-window
+ graphics.ConfigureSurface(mAdaptorInterfaces.GetRenderSurfaceInterface());
// Tell core it has a context
mCore.ContextCreated();
// Update time
uint64_t lastFrameTime;
- TimeService::GetNanoseconds( lastFrameTime );
+ TimeService::GetNanoseconds(lastFrameTime);
- LOG_UPDATE_RENDER( "THREAD INITIALISED" );
+ LOG_UPDATE_RENDER("THREAD INITIALISED");
- bool useElapsedTime = true;
- bool updateRequired = true;
- uint64_t timeToSleepUntil = 0;
- int extraFramesDropped = 0;
+ bool useElapsedTime = true;
+ bool updateRequired = true;
+ uint64_t timeToSleepUntil = 0;
+ int extraFramesDropped = 0;
const unsigned int renderToFboInterval = mEnvironmentOptions.GetRenderToFboInterval();
- const bool renderToFboEnabled = 0u != renderToFboInterval;
- unsigned int frameCount = 0u;
+ const bool renderToFboEnabled = 0u != renderToFboInterval;
+ unsigned int frameCount = 0u;
- while( UpdateRenderReady( useElapsedTime, updateRequired, timeToSleepUntil ) )
+ while(UpdateRenderReady(useElapsedTime, updateRequired, timeToSleepUntil))
{
LOG_UPDATE_RENDER_TRACE;
// Performance statistics are logged upon a VSYNC tick so use this point for a VSync marker
- AddPerformanceMarker( PerformanceInterface::VSYNC );
+ AddPerformanceMarker(PerformanceInterface::VSYNC);
uint64_t currentFrameStartTime = 0;
- TimeService::GetNanoseconds( currentFrameStartTime );
+ TimeService::GetNanoseconds(currentFrameStartTime);
uint64_t timeSinceLastFrame = currentFrameStartTime - lastFrameTime;
// Optional FPS Tracking when continuously rendering
- if( useElapsedTime && mFpsTracker.Enabled() )
+ if(useElapsedTime && mFpsTracker.Enabled())
{
float absoluteTimeSinceLastRender = timeSinceLastFrame * NANOSECONDS_TO_SECOND;
- mFpsTracker.Track( absoluteTimeSinceLastRender );
+ mFpsTracker.Track(absoluteTimeSinceLastRender);
}
lastFrameTime = currentFrameStartTime; // Store frame start time
//////////////////////////////
Dali::RenderSurfaceInterface* newSurface = ShouldSurfaceBeReplaced();
- if( DALI_UNLIKELY( newSurface ) )
+ if(DALI_UNLIKELY(newSurface))
{
- LOG_UPDATE_RENDER_TRACE_FMT( "Replacing Surface" );
+ LOG_UPDATE_RENDER_TRACE_FMT("Replacing Surface");
// This is designed for replacing pixmap surfaces, but should work for window as well
// we need to delete the surface and renderable (pixmap / window)
// Then create a new pixmap/window and new surface
SurfaceReplaced();
}
- const bool isRenderingToFbo = renderToFboEnabled && ( ( 0u == frameCount ) || ( 0u != frameCount % renderToFboInterval ) );
+ const bool isRenderingToFbo = renderToFboEnabled && ((0u == frameCount) || (0u != frameCount % renderToFboInterval));
++frameCount;
//////////////////////////////
// UPDATE
//////////////////////////////
- const unsigned int currentTime = currentFrameStartTime / NANOSECONDS_PER_MILLISECOND;
+ const unsigned int currentTime = currentFrameStartTime / NANOSECONDS_PER_MILLISECOND;
const unsigned int nextFrameTime = currentTime + mDefaultFrameDurationMilliseconds;
uint64_t noOfFramesSinceLastUpdate = 1;
- float frameDelta = 0.0f;
- if( useElapsedTime )
+ float frameDelta = 0.0f;
+ if(useElapsedTime)
{
- if( mThreadMode == ThreadMode::RUN_IF_REQUESTED )
+ if(mThreadMode == ThreadMode::RUN_IF_REQUESTED)
{
extraFramesDropped = 0;
- while( timeSinceLastFrame >= mDefaultFrameDurationNanoseconds )
+ while(timeSinceLastFrame >= mDefaultFrameDurationNanoseconds)
{
- timeSinceLastFrame -= mDefaultFrameDurationNanoseconds;
- extraFramesDropped++;
+ timeSinceLastFrame -= mDefaultFrameDurationNanoseconds;
+ extraFramesDropped++;
}
}
frameDelta = mDefaultFrameDelta * noOfFramesSinceLastUpdate;
}
- LOG_UPDATE_RENDER( "timeSinceLastFrame(%llu) noOfFramesSinceLastUpdate(%u) frameDelta(%.6f)", timeSinceLastFrame, noOfFramesSinceLastUpdate, frameDelta );
+ LOG_UPDATE_RENDER("timeSinceLastFrame(%llu) noOfFramesSinceLastUpdate(%u) frameDelta(%.6f)", timeSinceLastFrame, noOfFramesSinceLastUpdate, frameDelta);
Integration::UpdateStatus updateStatus;
- AddPerformanceMarker( PerformanceInterface::UPDATE_START );
- mCore.Update( frameDelta,
- currentTime,
- nextFrameTime,
- updateStatus,
- renderToFboEnabled,
- isRenderingToFbo );
- AddPerformanceMarker( PerformanceInterface::UPDATE_END );
+ AddPerformanceMarker(PerformanceInterface::UPDATE_START);
+ mCore.Update(frameDelta,
+ currentTime,
+ nextFrameTime,
+ updateStatus,
+ renderToFboEnabled,
+ isRenderingToFbo);
+ AddPerformanceMarker(PerformanceInterface::UPDATE_END);
unsigned int keepUpdatingStatus = updateStatus.KeepUpdating();
// Tell the event-thread to wake up (if asleep) and send a notification event to Core if required
- if( updateStatus.NeedsNotification() )
+ if(updateStatus.NeedsNotification())
{
mNotificationTrigger.Trigger();
- LOG_UPDATE_RENDER( "Notification Triggered" );
- }
-
- // Check resize
- bool surfaceResized = false;
- bool shouldSurfaceBeResized = ShouldSurfaceBeResized();
- if( DALI_UNLIKELY( shouldSurfaceBeResized ) )
- {
- if( updateStatus.SurfaceRectChanged() )
- {
- LOG_UPDATE_RENDER_TRACE_FMT( "Resizing Surface" );
- SurfaceResized();
- surfaceResized = true;
- }
+ LOG_UPDATE_RENDER("Notification Triggered");
}
// Optional logging of update/render status
- mUpdateStatusLogger.Log( keepUpdatingStatus );
+ mUpdateStatusLogger.Log(keepUpdatingStatus);
//////////////////////////////
// RENDER
mAdaptorInterfaces.GetDisplayConnectionInterface().ConsumeEvents();
- if( mPreRenderCallback != NULL )
+ if(mPreRenderCallback != NULL)
{
bool keepCallback = CallbackBase::ExecuteReturn<bool>(*mPreRenderCallback);
- if( ! keepCallback )
+ if(!keepCallback)
{
delete mPreRenderCallback;
mPreRenderCallback = NULL;
}
}
- if( eglImpl.IsSurfacelessContextSupported() )
- {
- // Make the shared surfaceless context as current before rendering
- eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() );
- }
+ graphics.ActivateResourceContext();
- if( mFirstFrameAfterResume )
+ if(mFirstFrameAfterResume)
{
// mFirstFrameAfterResume is set to true when the thread is resumed
- // Let eglImplementation know the first frame after thread initialized or resumed.
- eglImpl.SetFirstFrameAfterResume();
+ // Let graphics know the first frame after thread initialized or resumed.
+ graphics.SetFirstFrameAfterResume();
mFirstFrameAfterResume = FALSE;
}
Integration::RenderStatus renderStatus;
- AddPerformanceMarker( PerformanceInterface::RENDER_START );
+ AddPerformanceMarker(PerformanceInterface::RENDER_START);
// Upload shared resources
- mCore.PreRender( renderStatus, mForceClear, mUploadWithoutRendering );
+ mCore.PreRender(renderStatus, mForceClear, mUploadWithoutRendering);
- if ( !mUploadWithoutRendering )
+ if(!mUploadWithoutRendering)
{
// Go through each window
WindowContainer windows;
- mAdaptorInterfaces.GetWindowContainerInterface( windows );
+ mAdaptorInterfaces.GetWindowContainerInterface(windows);
+
+ bool sceneSurfaceResized;
- for( auto&& window : windows )
+ for(auto&& window : windows)
{
- Dali::Integration::Scene scene = window->GetScene();
+ Dali::Integration::Scene scene = window->GetScene();
Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
- if ( scene && windowSurface )
+ if(scene && windowSurface)
{
Integration::RenderStatus windowRenderStatus;
+ // Get Surface Resized flag
+ sceneSurfaceResized = scene.IsSurfaceRectChanged();
+
windowSurface->InitializeGraphics();
// clear previous frame damaged render items rects, buffer history is tracked on surface level
mDamagedRects.clear();
// Collect damage rects
- mCore.PreRender( scene, mDamagedRects );
+ mCore.PreRender(scene, mDamagedRects);
// Render off-screen frame buffers first if any
- mCore.RenderScene( windowRenderStatus, scene, true );
+ mCore.RenderScene(windowRenderStatus, scene, true);
Rect<int> clippingRect; // Empty for fbo rendering
- // Switch to the EGL context of the surface, merge damaged areas for previous frames
- windowSurface->PreRender( surfaceResized, mDamagedRects, clippingRect ); // Switch GL context
+ // Switch to the context of the surface, merge damaged areas for previous frames
+ windowSurface->PreRender(sceneSurfaceResized, mDamagedRects, clippingRect); // Switch GL context
- if (clippingRect.IsEmpty())
+ if(clippingRect.IsEmpty())
{
mDamagedRects.clear();
}
// Render the surface
- mCore.RenderScene( windowRenderStatus, scene, false, clippingRect );
+ mCore.RenderScene(windowRenderStatus, scene, false, clippingRect);
- if( windowRenderStatus.NeedsPostRender() )
+ if(windowRenderStatus.NeedsPostRender())
{
- windowSurface->PostRender( false, false, surfaceResized, mDamagedRects ); // Swap Buffer with damage
+ windowSurface->PostRender(false, false, sceneSurfaceResized, mDamagedRects); // Swap Buffer with damage
+ }
+
+ // If surface is resized, the surface resized count is decreased.
+ if(DALI_UNLIKELY(sceneSurfaceResized))
+ {
+ SurfaceResized();
}
}
}
}
- mCore.PostRender( mUploadWithoutRendering );
+ mCore.PostRender(mUploadWithoutRendering);
//////////////////////////////
// DELETE SURFACE
//////////////////////////////
Dali::RenderSurfaceInterface* deletedSurface = ShouldSurfaceBeDeleted();
- if( DALI_UNLIKELY( deletedSurface ) )
+ if(DALI_UNLIKELY(deletedSurface))
{
- LOG_UPDATE_RENDER_TRACE_FMT( "Deleting Surface" );
+ LOG_UPDATE_RENDER_TRACE_FMT("Deleting Surface");
deletedSurface->DestroySurface();
SurfaceDeleted();
}
- AddPerformanceMarker( PerformanceInterface::RENDER_END );
+ AddPerformanceMarker(PerformanceInterface::RENDER_END);
mForceClear = false;
// Trigger event thread to request Update/Render thread to sleep if update not required
- if( ( Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus ) && !renderStatus.NeedsUpdate() )
+ if((Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus) && !renderStatus.NeedsUpdate())
{
mSleepTrigger->Trigger();
updateRequired = false;
- LOG_UPDATE_RENDER( "Sleep Triggered" );
+ LOG_UPDATE_RENDER("Sleep Triggered");
}
else
{
extraFramesDropped = 0;
- if (timeToSleepUntil == 0)
+ if(timeToSleepUntil == 0)
{
// If this is the first frame after the thread is initialized or resumed, we
// use the actual time the current frame starts from to calculate the time to
// Check the current time at the end of the frame
uint64_t currentFrameEndTime = 0;
- TimeService::GetNanoseconds( currentFrameEndTime );
- while ( currentFrameEndTime > timeToSleepUntil + mDefaultFrameDurationNanoseconds )
+ TimeService::GetNanoseconds(currentFrameEndTime);
+ while(currentFrameEndTime > timeToSleepUntil + mDefaultFrameDurationNanoseconds)
{
- // We are more than one frame behind already, so just drop the next frames
- // until the sleep-until time is later than the current time so that we can
- // catch up.
- timeToSleepUntil += mDefaultFrameDurationNanoseconds;
- extraFramesDropped++;
+ // We are more than one frame behind already, so just drop the next frames
+ // until the sleep-until time is later than the current time so that we can
+ // catch up.
+ timeToSleepUntil += mDefaultFrameDurationNanoseconds;
+ extraFramesDropped++;
}
}
// Render to FBO is intended to measure fps above 60 so sleep is not wanted.
- if( 0u == renderToFboInterval )
+ if(0u == renderToFboInterval)
{
// Sleep until at least the the default frame duration has elapsed. This will return immediately if the specified end-time has already passed.
- TimeService::SleepUntil( timeToSleepUntil );
+ TimeService::SleepUntil(timeToSleepUntil);
}
}
mCore.ContextDestroyed();
WindowContainer windows;
- mAdaptorInterfaces.GetWindowContainerInterface( windows );
+ mAdaptorInterfaces.GetWindowContainerInterface(windows);
// Destroy surfaces
- for( auto&& window : windows )
+ for(auto&& window : windows)
{
Dali::RenderSurfaceInterface* surface = window->GetSurface();
surface->DestroySurface();
}
- // Shutdown EGL
- eglInterface->TerminateGles();
+ graphics.Shutdown();
- LOG_UPDATE_RENDER( "THREAD DESTROYED" );
+ LOG_UPDATE_RENDER("THREAD DESTROYED");
// Uninstall the logging function
mEnvironmentOptions.UnInstallLogFunction();
}
-bool CombinedUpdateRenderController::UpdateRenderReady( bool& useElapsedTime, bool updateRequired, uint64_t& timeToSleepUntil )
+bool CombinedUpdateRenderController::UpdateRenderReady(bool& useElapsedTime, bool updateRequired, uint64_t& timeToSleepUntil)
{
useElapsedTime = true;
- ConditionalWait::ScopedLock updateLock( mUpdateRenderThreadWaitCondition );
- while( ( ! mUpdateRenderRunCount || // Should try to wait if event-thread has paused the Update/Render thread
- ( mUpdateRenderThreadCanSleep && ! updateRequired && ! mPendingRequestUpdate ) ) && // Ensure we wait if we're supposed to be sleeping AND do not require another update
- ! mDestroyUpdateRenderThread && // Ensure we don't wait if the update-render-thread is supposed to be destroyed
- ! mNewSurface && // Ensure we don't wait if we need to replace the surface
- ! mDeletedSurface && // Ensure we don't wait if we need to delete the surface
- ! mSurfaceResized ) // Ensure we don't wait if we need to resize the surface
+ ConditionalWait::ScopedLock updateLock(mUpdateRenderThreadWaitCondition);
+ while((!mUpdateRenderRunCount || // Should try to wait if event-thread has paused the Update/Render thread
+ (mUpdateRenderThreadCanSleep && !updateRequired && !mPendingRequestUpdate)) && // Ensure we wait if we're supposed to be sleeping AND do not require another update
+ !mDestroyUpdateRenderThread && // Ensure we don't wait if the update-render-thread is supposed to be destroyed
+ !mNewSurface && // Ensure we don't wait if we need to replace the surface
+ !mDeletedSurface && // Ensure we don't wait if we need to delete the surface
+ !mSurfaceResized) // Ensure we don't wait if we need to resize the surface
{
- LOG_UPDATE_RENDER( "WAIT: mUpdateRenderRunCount: %d", mUpdateRenderRunCount );
- LOG_UPDATE_RENDER( " mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
- LOG_UPDATE_RENDER( " mDestroyUpdateRenderThread: %d", mDestroyUpdateRenderThread );
- LOG_UPDATE_RENDER( " mNewSurface: %d", mNewSurface );
- LOG_UPDATE_RENDER( " mDeletedSurface: %d", mDeletedSurface );
- LOG_UPDATE_RENDER( " mSurfaceResized: %d", mSurfaceResized );
+ LOG_UPDATE_RENDER("WAIT: mUpdateRenderRunCount: %d", mUpdateRenderRunCount);
+ LOG_UPDATE_RENDER(" mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate);
+ LOG_UPDATE_RENDER(" mDestroyUpdateRenderThread: %d", mDestroyUpdateRenderThread);
+ LOG_UPDATE_RENDER(" mNewSurface: %d", mNewSurface);
+ LOG_UPDATE_RENDER(" mDeletedSurface: %d", mDeletedSurface);
+ LOG_UPDATE_RENDER(" mSurfaceResized: %d", mSurfaceResized);
// Reset the time when the thread is waiting, so the sleep-until time for
// the first frame after resuming should be based on the actual start time
// of the first frame.
timeToSleepUntil = 0;
- mUpdateRenderThreadWaitCondition.Wait( updateLock );
+ mUpdateRenderThreadWaitCondition.Wait(updateLock);
- if( ! mUseElapsedTimeAfterWait )
+ if(!mUseElapsedTimeAfterWait)
{
useElapsedTime = false;
}
}
- LOG_COUNTER_UPDATE_RENDER( "mUpdateRenderRunCount: %d", mUpdateRenderRunCount );
- LOG_COUNTER_UPDATE_RENDER( "mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
- LOG_COUNTER_UPDATE_RENDER( "mDestroyUpdateRenderThread: %d", mDestroyUpdateRenderThread );
- LOG_COUNTER_UPDATE_RENDER( "mNewSurface: %d", mNewSurface );
- LOG_COUNTER_UPDATE_RENDER( "mDeletedSurface: %d", mDeletedSurface );
- LOG_COUNTER_UPDATE_RENDER( "mSurfaceResized: %d", mSurfaceResized );
+ LOG_COUNTER_UPDATE_RENDER("mUpdateRenderRunCount: %d", mUpdateRenderRunCount);
+ LOG_COUNTER_UPDATE_RENDER("mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate);
+ LOG_COUNTER_UPDATE_RENDER("mDestroyUpdateRenderThread: %d", mDestroyUpdateRenderThread);
+ LOG_COUNTER_UPDATE_RENDER("mNewSurface: %d", mNewSurface);
+ LOG_COUNTER_UPDATE_RENDER("mDeletedSurface: %d", mDeletedSurface);
+ LOG_COUNTER_UPDATE_RENDER("mSurfaceResized: %d", mSurfaceResized);
- mUseElapsedTimeAfterWait = FALSE;
+ mUseElapsedTimeAfterWait = FALSE;
mUpdateRenderThreadCanSleep = FALSE;
- mPendingRequestUpdate = FALSE;
+ mPendingRequestUpdate = FALSE;
// If we've been asked to run Update/Render cycles a finite number of times then decrement so we wait after the
// requested number of cycles
- if( mUpdateRenderRunCount > 0 )
+ if(mUpdateRenderRunCount > 0)
{
--mUpdateRenderRunCount;
}
// Keep the update-render thread alive if this thread is NOT to be destroyed
- return ! mDestroyUpdateRenderThread;
+ return !mDestroyUpdateRenderThread;
}
Dali::RenderSurfaceInterface* CombinedUpdateRenderController::ShouldSurfaceBeReplaced()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
Dali::RenderSurfaceInterface* newSurface = mNewSurface;
- mNewSurface = NULL;
+ mNewSurface = NULL;
return newSurface;
}
void CombinedUpdateRenderController::SurfaceReplaced()
{
// Just increment the semaphore
- sem_post( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Release(1);
}
Dali::RenderSurfaceInterface* CombinedUpdateRenderController::ShouldSurfaceBeDeleted()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
Dali::RenderSurfaceInterface* deletedSurface = mDeletedSurface;
- mDeletedSurface = NULL;
+ mDeletedSurface = NULL;
return deletedSurface;
}
void CombinedUpdateRenderController::SurfaceDeleted()
{
// Just increment the semaphore
- sem_post( &mSurfaceSemaphore );
-}
-
-bool CombinedUpdateRenderController::ShouldSurfaceBeResized()
-{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
- return mSurfaceResized;
+ mSurfaceSemaphore.Release(1);
}
void CombinedUpdateRenderController::SurfaceResized()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
- mSurfaceResized = FALSE;
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
+ if(mSurfaceResized)
+ {
+ mSurfaceResized--;
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void CombinedUpdateRenderController::NotifyThreadInitialised()
{
// Just increment the semaphore
- sem_post( &mEventThreadSemaphore );
+ mEventThreadSemaphore.Release(1);
}
void CombinedUpdateRenderController::NotifyGraphicsInitialised()
{
- sem_post( &mGraphicsInitializeSemaphore );
+ mGraphicsInitializeWait.Notify();
}
-void CombinedUpdateRenderController::AddPerformanceMarker( PerformanceInterface::MarkerType type )
+void CombinedUpdateRenderController::AddPerformanceMarker(PerformanceInterface::MarkerType type)
{
- if( mPerformanceInterface )
+ if(mPerformanceInterface)
{
- mPerformanceInterface->AddMarker( type );
+ mPerformanceInterface->AddMarker(type);
}
}
void CombinedUpdateRenderController::PostRenderComplete()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mPostRendering = FALSE;
- mUpdateRenderThreadWaitCondition.Notify( lock );
+ mUpdateRenderThreadWaitCondition.Notify(lock);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void CombinedUpdateRenderController::PostRenderStarted()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
mPostRendering = TRUE;
}
void CombinedUpdateRenderController::PostRenderWaitForCompletion()
{
- ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
- while( mPostRendering &&
- ! mNewSurface && // We should NOT wait if we're replacing the surface
- ! mDeletedSurface && // We should NOT wait if we're deleting the surface
- ! mDestroyUpdateRenderThread )
+ ConditionalWait::ScopedLock lock(mUpdateRenderThreadWaitCondition);
+ while(mPostRendering &&
+ !mNewSurface && // We should NOT wait if we're replacing the surface
+ !mDeletedSurface && // We should NOT wait if we're deleting the surface
+ !mDestroyUpdateRenderThread)
{
- mUpdateRenderThreadWaitCondition.Wait( lock );
+ mUpdateRenderThreadWaitCondition.Wait(lock);
}
}
#define DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_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.
*/
// EXTERNAL INCLUDES
+#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/devel-api/threading/semaphore.h>
+#include <dali/integration-api/core.h>
#include <pthread.h>
#include <semaphore.h>
-#include <atomic>
#include <stdint.h>
-#include <dali/devel-api/threading/conditional-wait.h>
-#include <dali/integration-api/core.h>
+#include <atomic>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
namespace Dali
{
-
class RenderSurfaceInterface;
class TriggerEventInterface;
namespace Internal
{
-
namespace Adaptor
{
-
class AdaptorInternalServices;
class EnvironmentOptions;
public ThreadSynchronizationInterface
{
public:
-
/**
* Constructor
*/
- CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode );
+ CombinedUpdateRenderController(AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode);
/**
* Non virtual destructor. Not intended as base class.
/**
* @copydoc ThreadControllerInterface::RequestUpdateOnce()
*/
- void RequestUpdateOnce( UpdateMode updateMode ) override;
+ void RequestUpdateOnce(UpdateMode updateMode) override;
/**
* @copydoc ThreadControllerInterface::ReplaceSurface()
*/
- void ReplaceSurface( Dali::RenderSurfaceInterface* surface ) override;
+ void ReplaceSurface(Dali::RenderSurfaceInterface* surface) override;
/**
* @copydoc ThreadControllerInterface::DeleteSurface()
*/
- void DeleteSurface( Dali::RenderSurfaceInterface* surface ) override;
+ void DeleteSurface(Dali::RenderSurfaceInterface* surface) override;
/**
* @copydoc ThreadControllerInterface::ResizeSurface()
/**
* @copydoc ThreadControllerInterface::SetRenderRefreshRate()
*/
- void SetRenderRefreshRate( unsigned int numberOfFramesPerRender ) override;
+ void SetRenderRefreshRate(unsigned int numberOfFramesPerRender) override;
/**
* @copydoc ThreadControllerInterface::SetPreRenderCallback
*/
- void SetPreRenderCallback( CallbackBase* callback ) override;
+ void SetPreRenderCallback(CallbackBase* callback) override;
/**
* @copydoc ThreadControllerInterface::AddSurface()
*/
- void AddSurface( Dali::RenderSurfaceInterface* surface ) override;
+ void AddSurface(Dali::RenderSurfaceInterface* surface) override;
private:
-
// Undefined copy constructor.
- CombinedUpdateRenderController( const CombinedUpdateRenderController& );
+ CombinedUpdateRenderController(const CombinedUpdateRenderController&);
// Undefined assignment operator.
- CombinedUpdateRenderController& operator=( const CombinedUpdateRenderController& );
+ CombinedUpdateRenderController& operator=(const CombinedUpdateRenderController&);
/////////////////////////////////////////////////////////////////////////////////////////////////
// EventThread
enum AnimationProgression
{
- USE_ELAPSED_TIME, ///< Animation progression using elapsed time
- NONE ///< No animation progression
+ USE_ELAPSED_TIME, ///< Animation progression using elapsed time
+ NONE ///< No animation progression
};
/**
* @param[in] animationProgression Whether to progress animation using time elapsed since the last frame.
* @param[in] updateMode The update mode (i.e. either update & render or skip rendering)
*/
- inline void RunUpdateRenderThread( int numberOfCycles, AnimationProgression animationProgression, UpdateMode updateMode );
+ inline void RunUpdateRenderThread(int numberOfCycles, AnimationProgression animationProgression, UpdateMode updateMode);
/**
* Pauses the Update/Render Thread.
* @param[out] timeToSleepUntil The time remaining in nanoseconds to keep the thread sleeping before resuming.
* @return false, if the thread should stop.
*/
- bool UpdateRenderReady( bool& useElapsedTime, bool updateRequired, uint64_t& timeToSleepUntil );
+ bool UpdateRenderReady(bool& useElapsedTime, bool updateRequired, uint64_t& timeToSleepUntil);
/**
* Checks to see if the surface needs to be replaced.
void SurfaceDeleted();
/**
- * Checks to see if the surface needs to be resized.
- * This will lock the mutex in mUpdateRenderThreadWaitCondition.
- *
- * @return true if the surface should be resized, false otherwise
- */
- bool ShouldSurfaceBeResized();
-
- /**
* Called by the Update/Render thread after a surface has been resized.
*
* This will lock the mutex in mEventThreadWaitCondition
* Helper for the thread calling the entry function
* @param[in] This A pointer to the current object
*/
- static void* InternalUpdateRenderThreadEntryFunc( void* This )
+ static void* InternalUpdateRenderThreadEntryFunc(void* This)
{
- ( static_cast<CombinedUpdateRenderController*>( This ) )->UpdateRenderThread();
+ (static_cast<CombinedUpdateRenderController*>(This))->UpdateRenderThread();
return NULL;
}
* Helper to add a performance marker to the performance server (if it's active)
* @param[in] type performance marker type
*/
- void AddPerformanceMarker( PerformanceInterface::MarkerType type );
+ void AddPerformanceMarker(PerformanceInterface::MarkerType type);
/////////////////////////////////////////////////////////////////////////////////////////////////
// POST RENDERING - ThreadSynchronizationInterface overrides
void PostRenderWaitForCompletion() override;
private:
+ FpsTracker mFpsTracker; ///< Object that tracks the FPS
+ UpdateStatusLogger mUpdateStatusLogger; ///< Object that logs the update-status as required.
- FpsTracker mFpsTracker; ///< Object that tracks the FPS
- UpdateStatusLogger mUpdateStatusLogger; ///< Object that logs the update-status as required.
-
- sem_t mEventThreadSemaphore; ///< Used by the event thread to ensure all threads have been initialised.
- sem_t mGraphicsInitializeSemaphore; ///< Used by the render thread to ensure the graphics has been initialised.
- sem_t mSurfaceSemaphore; ///< Used by the event thread to ensure the surface has been deleted or replaced.
+ Semaphore<> mEventThreadSemaphore; ///< Used by the event thread to ensure all threads have been initialised, and when replacing the surface.
+ ConditionalWait mGraphicsInitializeWait; ///< Used by the render thread to ensure the graphics has been initialised.
+ Semaphore<> mSurfaceSemaphore; ///< Used by the event thread to ensure the surface has been deleted or replaced.
- ConditionalWait mUpdateRenderThreadWaitCondition; ///< The wait condition for the update-render-thread.
+ ConditionalWait mUpdateRenderThreadWaitCondition; ///< The wait condition for the update-render-thread.
- AdaptorInternalServices& mAdaptorInterfaces; ///< The adaptor internal interface
- PerformanceInterface* mPerformanceInterface; ///< The performance logging interface
- Integration::Core& mCore; ///< Dali core reference
- const EnvironmentOptions& mEnvironmentOptions; ///< Environment options
- TriggerEventInterface& mNotificationTrigger; ///< Reference to notification event trigger
- TriggerEventInterface* mSleepTrigger; ///< Used by the update-render thread to trigger the event thread when it no longer needs to do any updates
- CallbackBase* mPreRenderCallback; ///< Used by Update/Render thread when PreRender is about to be called on graphics.
+ AdaptorInternalServices& mAdaptorInterfaces; ///< The adaptor internal interface
+ PerformanceInterface* mPerformanceInterface; ///< The performance logging interface
+ Integration::Core& mCore; ///< Dali core reference
+ const EnvironmentOptions& mEnvironmentOptions; ///< Environment options
+ TriggerEventInterface& mNotificationTrigger; ///< Reference to notification event trigger
+ TriggerEventInterface* mSleepTrigger; ///< Used by the update-render thread to trigger the event thread when it no longer needs to do any updates
+ CallbackBase* mPreRenderCallback; ///< Used by Update/Render thread when PreRender is about to be called on graphics.
- pthread_t* mUpdateRenderThread; ///< The Update/Render thread.
+ pthread_t* mUpdateRenderThread; ///< The Update/Render thread.
- float mDefaultFrameDelta; ///< Default time delta between each frame (used for animations). Not protected by lock, but written to rarely so not worth adding a lock when reading.
+ float mDefaultFrameDelta; ///< Default time delta between each frame (used for animations). Not protected by lock, but written to rarely so not worth adding a lock when reading.
// TODO: mDefaultFrameDurationMilliseconds is defined as uint64_t, the only place where it is used, it is converted to an unsigned int!!!
- uint64_t mDefaultFrameDurationMilliseconds; ///< Default duration of a frame (used for predicting the time of the next frame). Not protected by lock, but written to rarely so not worth adding a lock when reading.
- uint64_t mDefaultFrameDurationNanoseconds; ///< Default duration of a frame (used for sleeping if not enough time elapsed). Not protected by lock, but written to rarely so not worth adding a lock when reading.
- uint64_t mDefaultHalfFrameNanoseconds; ///< Is half of mDefaultFrameDurationNanoseconds. Using a member variable avoids having to do the calculation every frame. Not protected by lock, but written to rarely so not worth adding a lock when reading.
+ uint64_t mDefaultFrameDurationMilliseconds; ///< Default duration of a frame (used for predicting the time of the next frame). Not protected by lock, but written to rarely so not worth adding a lock when reading.
+ uint64_t mDefaultFrameDurationNanoseconds; ///< Default duration of a frame (used for sleeping if not enough time elapsed). Not protected by lock, but written to rarely so not worth adding a lock when reading.
+ uint64_t mDefaultHalfFrameNanoseconds; ///< Is half of mDefaultFrameDurationNanoseconds. Using a member variable avoids having to do the calculation every frame. Not protected by lock, but written to rarely so not worth adding a lock when reading.
- unsigned int mUpdateRequestCount; ///< Count of update-requests we have received to ensure we do not go to sleep too early.
- unsigned int mRunning; ///< Read and set on the event-thread only to state whether we are running.
+ unsigned int mUpdateRequestCount; ///< Count of update-requests we have received to ensure we do not go to sleep too early.
+ unsigned int mRunning; ///< Read and set on the event-thread only to state whether we are running.
- ThreadMode mThreadMode; ///< Whether the thread runs continuously or runs when it is requested.
+ ThreadMode mThreadMode; ///< Whether the thread runs continuously or runs when it is requested.
//
// NOTE: cannot use booleans as these are used from multiple threads, must use variable with machine word size for atomic read/write
//
- volatile int mUpdateRenderRunCount; ///< The number of times Update/Render cycle should run. If -1, then will run continuously (set by the event-thread, read by v-sync-thread).
- volatile unsigned int mDestroyUpdateRenderThread; ///< Whether the Update/Render thread be destroyed (set by the event-thread, read by the update-render-thread).
- volatile unsigned int mUpdateRenderThreadCanSleep; ///< Whether the Update/Render thread can sleep (set by the event-thread, read by the update-render-thread).
- volatile unsigned int mPendingRequestUpdate; ///< Is set as soon as an RequestUpdate is made and unset when the next update happens (set by the event-thread and update-render thread, read by the update-render-thread).
- ///< Ensures we do not go to sleep if we have not processed the most recent update-request.
+ volatile int mUpdateRenderRunCount; ///< The number of times Update/Render cycle should run. If -1, then will run continuously (set by the event-thread, read by v-sync-thread).
+ volatile unsigned int mDestroyUpdateRenderThread; ///< Whether the Update/Render thread be destroyed (set by the event-thread, read by the update-render-thread).
+ volatile unsigned int mUpdateRenderThreadCanSleep; ///< Whether the Update/Render thread can sleep (set by the event-thread, read by the update-render-thread).
+ volatile unsigned int mPendingRequestUpdate; ///< Is set as soon as an RequestUpdate is made and unset when the next update happens (set by the event-thread and update-render thread, read by the update-render-thread).
+ ///< Ensures we do not go to sleep if we have not processed the most recent update-request.
- volatile unsigned int mUseElapsedTimeAfterWait; ///< Whether we should use the elapsed time after waiting (set by the event-thread, read by the update-render-thread).
+ volatile unsigned int mUseElapsedTimeAfterWait; ///< Whether we should use the elapsed time after waiting (set by the event-thread, read by the update-render-thread).
- Dali::RenderSurfaceInterface* volatile mNewSurface; ///< Will be set to the new-surface if requested (set by the event-thread, read & cleared by the update-render thread).
- Dali::RenderSurfaceInterface* volatile mDeletedSurface; ///< Will be set to the deleted surface if requested (set by the event-thread, read & cleared by the update-render thread).
+ Dali::RenderSurfaceInterface* volatile mNewSurface; ///< Will be set to the new-surface if requested (set by the event-thread, read & cleared by the update-render thread).
+ Dali::RenderSurfaceInterface* volatile mDeletedSurface; ///< Will be set to the deleted surface if requested (set by the event-thread, read & cleared by the update-render thread).
- volatile unsigned int mPostRendering; ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
- volatile unsigned int mSurfaceResized; ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
- volatile unsigned int mForceClear; ///< Will be set to clear forcibly
+ volatile unsigned int mPostRendering; ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
+ volatile unsigned int mSurfaceResized; ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
+ volatile unsigned int mForceClear; ///< Will be set to clear forcibly
- volatile unsigned int mUploadWithoutRendering; ///< Will be set to upload the resource only (with no rendering)
+ volatile unsigned int mUploadWithoutRendering; ///< Will be set to upload the resource only (with no rendering)
- volatile unsigned int mFirstFrameAfterResume; ///< Will be set to check the first frame after resume (for log)
+ volatile unsigned int mFirstFrameAfterResume; ///< Will be set to check the first frame after resume (for log)
- std::vector<Rect<int>> mDamagedRects; ///< Keeps collected damaged render items rects for one render pass
+ std::vector<Rect<int>> mDamagedRects; ///< Keeps collected damaged render items rects for one render pass
};
} // namespace Adaptor
#define DALI_INTERNAL_FRAMEWORK_H
/*
- * 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 <string>
#include <dali/public-api/signals/callback.h>
+#include <string>
#ifdef APPCORE_WATCH_AVAILABLE
#include <dali/public-api/watch/watch-application.h>
#endif
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* The Framework class is ideally placed to provide key API required by Applications.
*
class Framework
{
public:
-
enum Type
{
- NORMAL, ///< normal appFramework
- WATCH, ///< watch appFramework
- WIDGET, ///< widget appFramework
- COMPONENT ///< component appFramework
+ NORMAL, ///< normal appFramework
+ WATCH, ///< watch appFramework
+ WIDGET, ///< widget appFramework
+ COMPONENT ///< component appFramework
};
/**
class Observer
{
public:
-
/**
* Invoked when the application is to be initialised.
*/
- virtual void OnInit() {}
+ virtual void OnInit()
+ {
+ }
/**
* Invoked when the application is to be terminated.
*/
- virtual void OnTerminate() {}
+ virtual void OnTerminate()
+ {
+ }
/**
* Invoked when the application is to be paused.
*/
- virtual void OnPause() {}
+ virtual void OnPause()
+ {
+ }
/**
* Invoked when the application is to be resumed.
*/
- virtual void OnResume() {}
+ virtual void OnResume()
+ {
+ }
/**
* Invoked when the application is to be reset.
*/
- virtual void OnReset() {}
+ virtual void OnReset()
+ {
+ }
/**
* Invoked when the AppControl message is received.
* @param[in] The bundle data of AppControl message.
*/
- virtual void OnAppControl(void *) {}
+ virtual void OnAppControl(void*)
+ {
+ }
#ifdef APPCORE_WATCH_AVAILABLE
/**
* Invoked at every second
*/
- virtual void OnTimeTick(WatchTime&) {}
+ virtual void OnTimeTick(WatchTime&)
+ {
+ }
/**
* Invoked at every second in ambient mode
*/
- virtual void OnAmbientTick(WatchTime&) {}
+ virtual void OnAmbientTick(WatchTime&)
+ {
+ }
/**
* Invoked when the device enters or exits ambient mode
*/
- virtual void OnAmbientChanged(bool ambient) {}
+ virtual void OnAmbientChanged(bool ambient)
+ {
+ }
#endif
/**
* Invoked when the language of the device is changed.
*/
- virtual void OnLanguageChanged() {}
+ virtual void OnLanguageChanged()
+ {
+ }
/**
* Invoked when the region is changed.
*/
- virtual void OnRegionChanged() {}
+ virtual void OnRegionChanged()
+ {
+ }
/**
* Invoked when the battery level of the device is low.
*/
- virtual void OnBatteryLow( Dali::DeviceStatus::Battery::Status status ) {}
+ virtual void OnBatteryLow(Dali::DeviceStatus::Battery::Status status)
+ {
+ }
/**
* Invoked when the memory level of the device is low.
*/
- virtual void OnMemoryLow( Dali::DeviceStatus::Memory::Status status ) {}
+ virtual void OnMemoryLow(Dali::DeviceStatus::Memory::Status status)
+ {
+ }
/**
* Invoked when the platform surface is created.
*/
- virtual void OnSurfaceCreated( Any newSurface ) {}
+ virtual void OnSurfaceCreated(Any newSurface)
+ {
+ }
/**
* Invoked when the platform surface is destroyed.
*/
- virtual void OnSurfaceDestroyed( Any newSurface ) {}
+ virtual void OnSurfaceDestroyed(Any newSurface)
+ {
+ }
#ifdef COMPONENT_APPLICATION_SUPPORT
/**
* Invoked when the component application is created.
*/
- virtual Any OnCreate() { return nullptr; }
+ virtual Any OnCreate()
+ {
+ return nullptr;
+ }
#endif
};
public:
-
/**
* Constructor
* @param[in] observer The observer of the Framework.
* @param[in] argv A pointer the the argument list.
* @param[in] type The type of application
*/
- Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
+ Framework(Observer& observer, int* argc, char*** argv, Type type = NORMAL);
/**
* Destructor
~Framework();
public:
-
/**
* Runs the main loop of framework
*/
* @note Only one callback can be registered. The last callback to be set will be called on abort.
* @note The ownership of callback is passed onto this class.
*/
- void AddAbortCallback( CallbackBase* callback );
+ void AddAbortCallback(CallbackBase* callback);
/**
* Gets bundle name which was passed in app_reset callback.
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
*/
- void SetCommandLineOptions( int* argc, char **argv[] )
+ void SetCommandLineOptions(int* argc, char** argv[])
{
mArgc = argc;
mArgv = argv;
}
-
/**
* Gets the path at which application resources are stored.
*/
/**
* Sets system language.
*/
- void SetLanguage( const std::string& language );
+ void SetLanguage(const std::string& language);
/**
* Sets system region.
*/
- void SetRegion( const std::string& region );
+ void SetRegion(const std::string& region);
/**
* Gets system language.
* @param[in] callback The callback.
* @return The callback id.
*/
- unsigned int AddIdle( int timeout, void* data, bool ( *callback )( void *data ) );
+ unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data));
/**
* Called by the adaptor when an idle callback is removed.
* @param[in] id The callback id.
*/
- void RemoveIdle( unsigned int id );
+ void RemoveIdle(unsigned int id);
private:
-
// Undefined
Framework(const Framework&);
Framework& operator=(Framework&);
private:
-
/**
* Called when the application is created.
*/
void InitThreads();
private:
- Observer& mObserver;
- bool mInitialised;
- bool mPaused;
- bool mRunning;
- int* mArgc;
- char*** mArgv;
- std::string mBundleName;
- std::string mBundleId;
- AbortHandler mAbortHandler;
+ Observer& mObserver;
+ bool mInitialised;
+ bool mPaused;
+ bool mRunning;
+ int* mArgc;
+ char*** mArgv;
+ std::string mBundleName;
+ std::string mBundleId;
+ AbortHandler mAbortHandler;
private: // impl members
-
struct Impl;
Impl* mImpl;
};
/*
- * 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();
}
#define DALI_INTERNAL_LIFECYCLE_CONTROLLER_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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/lifecycle-controller.h>
namespace Dali
{
-
class Adaptor;
namespace Internal
{
-
namespace Adaptor
{
-
/**
* This provides signals that are emitted according the lifecylce of the program.
*/
class LifecycleController : public BaseObject, public ConnectionTracker
{
public:
-
// Creation & Destruction
/**
Dali::LifecycleController::LifecycleSignalType& LanguageChangedSignal();
public:
-
/**
* Called when the framework is initialised.
*
* @param[in] app The application instance
*/
- void OnInit( Dali::Application& app );
+ void OnInit(Dali::Application& app);
/**
* Called when the framework is terminated.
*
* @param[in] app The application instance
*/
- void OnTerminate( Dali::Application& app );
+ void OnTerminate(Dali::Application& app);
/**
* Called when the framework is paused.
*
* @param[in] app The application instance
*/
- void OnPause( Dali::Application& app );
+ void OnPause(Dali::Application& app);
/**
* Called when the framework resumes from a paused state.
*
* @param[in] app The application instance
*/
- void OnResume( Dali::Application& app );
+ void OnResume(Dali::Application& app);
/**
* Called when the framework informs the application that it should reset itself.
*
* @param[in] app The application instance
*/
- void OnReset( Dali::Application& app );
+ void OnReset(Dali::Application& app);
/**
* Called when the framework informs the application that the language of the device has changed.
*
* @param[in] app The application instance
*/
- void OnLanguageChanged( Dali::Application& app );
+ void OnLanguageChanged(Dali::Application& app);
protected:
-
/**
* Virtual Destructor.
*/
~LifecycleController() override;
private:
-
/**
* Emit the init signal.
*/
void EmitLanguageChangedSignal();
private:
-
// Signals
Dali::LifecycleController::LifecycleSignalType mInitSignal;
Dali::LifecycleController::LifecycleSignalType mTerminateSignal;
Dali::LifecycleController::LifecycleSignalType mResumeSignal;
Dali::LifecycleController::LifecycleSignalType mResetSignal;
Dali::LifecycleController::LifecycleSignalType mLanguageChangedSignal;
-
};
} // namespace Adaptor
#define DALI_INTERNAL_BASE_LIFECYCLE_OBSERVER_H
/*
- * 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
{
-
/**
* Adaptor life cycle observer
*/
virtual void OnDestroy() = 0;
protected:
-
/**
* Constructor
*/
}
private:
-
// Undefined copy constructor.
- LifeCycleObserver( const LifeCycleObserver& );
+ LifeCycleObserver(const LifeCycleObserver&);
// Undefined assignment operator.
- LifeCycleObserver& operator=( const LifeCycleObserver& );
-
+ LifeCycleObserver& operator=(const LifeCycleObserver&);
};
-
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_BASE_LIFECYCLE_OBSERVER_H
#define DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_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
{
-
class RenderSurfaceInterface;
namespace Internal
{
-
namespace Adaptor
{
-
enum class UpdateMode
{
- NORMAL, ///< Update and render
- SKIP_RENDER, ///< Update and resource upload but no rendering
- FORCE_RENDER ///< Force update and render
+ NORMAL, ///< Update and render
+ SKIP_RENDER, ///< Update and resource upload but no rendering
+ FORCE_RENDER ///< Force update and render
};
enum class ThreadMode
{
- NORMAL, ///< The thread runs continuously
- RUN_IF_REQUESTED ///< The threads runs when it is requested
+ NORMAL, ///< The thread runs continuously
+ RUN_IF_REQUESTED ///< The threads runs when it is requested
};
/**
class ThreadControllerInterface
{
public:
-
/**
* Virtual destructor. Not intended as base class.
*/
- virtual ~ThreadControllerInterface() { }
+ virtual ~ThreadControllerInterface()
+ {
+ }
/**
* Initializes the thread controller
* If Adaptor is paused, we do one update/render and return to pause
* @param updateMode The update mode (i.e. i.e. either update & render or skip rendering)
*/
- virtual void RequestUpdateOnce( UpdateMode updateMode ) = 0;
+ virtual void RequestUpdateOnce(UpdateMode updateMode) = 0;
/**
* Replaces the surface.
* @param surface new surface
*/
- virtual void ReplaceSurface( Dali::RenderSurfaceInterface* surface ) = 0;
+ virtual void ReplaceSurface(Dali::RenderSurfaceInterface* surface) = 0;
/**
* Deletes the surface.
* @param[in] surface The surface to be deleted
*/
- virtual void DeleteSurface( Dali::RenderSurfaceInterface* surface ) = 0;
+ virtual void DeleteSurface(Dali::RenderSurfaceInterface* surface) = 0;
/**
* Resize the surface.
/**
* @copydoc Dali::Adaptor::SetRenderRefreshRate()
*/
- virtual void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) = 0;
+ virtual void SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender) = 0;
/**
* @copydoc Dali::Adaptor::SetPreRenderCallback()
*/
- virtual void SetPreRenderCallback( CallbackBase* callback ) = 0;
+ virtual void SetPreRenderCallback(CallbackBase* callback) = 0;
/**
* @brief Adds the new surface.
* @param surface new surface
*/
- virtual void AddSurface( Dali::RenderSurfaceInterface* surface ) = 0;
+ virtual void AddSurface(Dali::RenderSurfaceInterface* surface) = 0;
protected:
-
/**
* Constructor
*/
- ThreadControllerInterface() { }
+ ThreadControllerInterface()
+ {
+ }
private:
-
// Undefined copy constructor.
- ThreadControllerInterface( const ThreadControllerInterface& );
+ ThreadControllerInterface(const ThreadControllerInterface&);
// Undefined assignment operator.
- ThreadControllerInterface& operator=( const ThreadControllerInterface& );
+ ThreadControllerInterface& operator=(const ThreadControllerInterface&);
};
} // namespace Adaptor
#define DALI_INTERNAL_ADAPTOR_THREADING_MODE_H
/*
- * 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 ThreadingMode
{
enum Type
{
- COMBINED_UPDATE_RENDER = 1, ///< Three threads: Event, V-Sync & a Joint Update/Render thread.
+ COMBINED_UPDATE_RENDER = 1, ///< Three threads: Event, V-Sync & a Joint Update/Render thread.
};
};
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_THREADING_MODE_H
${adaptor_adaptor_dir}/tizen-wayland/component-application.cpp
${adaptor_adaptor_dir}/tizen-wayland/component-application-impl.cpp
)
+
+# module: adaptor, backend: macos
+SET( adaptor_adaptor_macos_src_files
+ ${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
+ ${adaptor_adaptor_dir}/macos/framework-mac.mm
+)
/*
- * 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 = "";
}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+
+#include "extern-definitions.h"
+
+// CLASS HEADER
+#include <dali/internal/adaptor/common/framework.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/system/common/callback-manager.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+/// Application Status Enum
+enum
+{
+ APP_CREATE,
+ APP_TERMINATE,
+ APP_PAUSE,
+ APP_RESUME,
+ APP_RESET,
+ APP_LANGUAGE_CHANGE,
+};
+
+} // Unnamed namespace
+
+/**
+ * Impl to hide WindowsSystem data members
+ */
+struct Framework::Impl
+{
+ // Constructor
+
+ Impl(void* data)
+ : mAbortCallBack( nullptr ),
+ mLanguage( "NOT_SUPPORTED" ),
+ mRegion( "NOT_SUPPORTED" )
+ {
+ }
+
+ ~Impl()
+ {
+ delete mAbortCallBack;
+ }
+
+ std::string GetLanguage() const
+ {
+ return mLanguage;
+ }
+
+ std::string GetRegion() const
+ {
+ return mRegion;
+ }
+
+ void SetAbortCallback( CallbackBase *base )
+ {
+ mAbortCallBack = base;
+ }
+
+ bool ExecuteCallback()
+ {
+ if( nullptr != mAbortCallBack )
+ {
+ CallbackBase::Execute( *mAbortCallBack );
+ return true;
+ }
+
+ return false;
+ }
+
+private:
+ // Undefined
+ Impl( const Impl& impl ) = delete;
+
+ // Undefined
+ Impl& operator=( const Impl& impl ) = delete;
+
+private:
+ // Data
+ CallbackBase* mAbortCallBack;
+ 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)
+{
+ InitThreads();
+ mImpl = new Impl(this);
+
+ // ensures the NSApp global object is initialized
+ [NSApplication sharedApplication];
+
+ // this is needed for applications without a bundle
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ // make sure we can become the key window
+ [NSApp activateIgnoringOtherApps:YES];
+}
+
+Framework::~Framework()
+{
+ if (mRunning)
+ {
+ Quit();
+ }
+
+ delete mImpl;
+}
+
+void Framework::Run()
+{
+ mRunning = true;
+ AppStatusHandler(APP_CREATE, nullptr);
+ [NSApp run];
+ mRunning = false;
+}
+
+void Framework::Quit()
+{
+ AppStatusHandler(APP_TERMINATE, nullptr);
+}
+
+bool Framework::IsMainLoopRunning()
+{
+ return mRunning;
+}
+
+void Framework::AddAbortCallback( CallbackBase* callback )
+{
+ mImpl->SetAbortCallback( callback );
+}
+
+std::string Framework::GetBundleName() const
+{
+ return mBundleName;
+}
+
+void Framework::SetBundleName(const std::string& name)
+{
+ mBundleName = name;
+}
+
+std::string Framework::GetBundleId() const
+{
+ return mBundleId;
+}
+
+std::string Framework::GetResourcePath()
+{
+ // "DALI_APPLICATION_PACKAGE" is used by macOS specifically to get the already configured Application package path.
+ const char* macEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
+ char* value = getenv( macEnvironmentVariable );
+
+ std::string resourcePath;
+ if ( value != NULL )
+ {
+ resourcePath = value;
+ }
+
+ if( resourcePath.back() != '/' )
+ {
+ resourcePath+="/";
+ }
+
+ return resourcePath;
+}
+
+std::string Framework::GetDataPath()
+{
+ return app_get_data_path();
+}
+
+void Framework::SetBundleId(const std::string& id)
+{
+ mBundleId = id;
+}
+
+void Framework::AbortCallback( )
+{
+ // if an abort call back has been installed run it.
+ if( false == mImpl->ExecuteCallback() )
+ {
+ Quit();
+ }
+}
+
+bool Framework::AppStatusHandler(int type, void *)
+{
+ switch (type)
+ {
+ case APP_CREATE:
+ {
+ mInitialised = true;
+ mObserver.OnInit();
+ break;
+ }
+
+ case APP_RESET:
+ mObserver.OnReset();
+ break;
+
+ case APP_RESUME:
+ mObserver.OnResume();
+ break;
+
+ case APP_TERMINATE:
+ mObserver.OnTerminate();
+ break;
+
+ case APP_PAUSE:
+ mObserver.OnPause();
+ break;
+
+ case APP_LANGUAGE_CHANGE:
+ mObserver.OnLanguageChanged();
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+void Framework::InitThreads()
+{
+}
+
+std::string Framework::GetLanguage() const
+{
+ return mImpl->GetLanguage();
+}
+
+std::string Framework::GetRegion() const
+{
+ return mImpl->GetRegion();
+}
+
+} // 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
{
-
-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::GetDataStoragePath( std::string& path)
+void Adaptor::GetResourceStoragePath(std::string& path)
{
#ifdef USE_APPFW
- char *pathInt = app_get_data_path();
- if ( pathInt )
+ char* pathInt = app_get_resource_path();
+ if(pathInt)
{
path = pathInt;
- free( pathInt );
+ free(pathInt);
}
else
{
path = "";
}
#endif
+}
+void Adaptor::GetDataStoragePath(std::string& path)
+{
+#ifdef USE_APPFW
+ char* pathInt = app_get_data_path();
+ if(pathInt)
+ {
+ path = 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)
{
}
#define DALI_INTERNAL_COMPONENT_APPLICATION_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 Internal
{
-
namespace Adaptor
{
-
class ComponentApplication;
typedef IntrusivePtr<ComponentApplication> ComponentApplicationPtr;
* @param[in] windowMode A member of WINDOW_MODE
* @return A handle to the ComponentApplication
*/
- static ComponentApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ static ComponentApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode);
/**
* @brief The default constructor.
*/
- ComponentApplication( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ ComponentApplication(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode);
/**
* @brief Undefined copy constructor.
*/
- ComponentApplication( const ComponentApplication& ) = default;
+ ComponentApplication(const ComponentApplication&) = default;
/**
* @brief Destructor
/**
*@brief Undefined assignment operator.
*/
- ComponentApplication& operator=( const ComponentApplication& ) = delete;
+ ComponentApplication& operator=(const ComponentApplication&) = delete;
-public: // From Framework::Observer
+public: // From Framework::Observer
/**
* Called when the framework is Component Application Created.
*/
Any OnCreate() override;
public:
- CreateSignal mCreateSignal;
+ CreateSignal mCreateSignal;
};
inline ComponentApplication& GetImplementation(Dali::ComponentApplication& application)
return static_cast<const Internal::Adaptor::ComponentApplication&>(handle);
}
-
} // namespace Adaptor
} // 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.
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());
}
#define DALI_INTERNAL_ADAPTOR_TIZEN_WAYLAND_DALI_ECORE_WAYLAND_H
/*
- * 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.
#pragma GCC system_header
#include <Ecore_Wayland.h>
-
-
#endif /* DALI_INTERNAL_ADAPTOR_TIZEN_WAYLAND_DALI_ECORE_WAYLAND_H */
#define DALI_INTERNAL_ADAPTOR_TIZEN_WAYLAND_DALI_ECORE_WL2_H
/*
- * 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.
#pragma GCC system_header
#include <Ecore_Wl2.h>
-
-
#endif /* DALI_INTERNAL_ADAPTOR_TIZEN_WAYLAND_DALI_ECORE_WL2_H */
/*
- * 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
#define DALI_INTERNAL_WATCH_APPLICATION_H
/*
- * 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/public-api/watch/watch-application.h>
#include <dali/internal/adaptor/common/application-impl.h>
+#include <dali/public-api/watch/watch-application.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
class WatchApplication;
typedef IntrusivePtr<WatchApplication> WatchApplicationPtr;
* @param[in] stylesheet The path to user defined theme file
* @param[in] windowMode A member of Dali::Watch::WINDOW_MODE
*/
- static WatchApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ static WatchApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode);
/**
* Private Constructor
* @param[in] stylesheet The path to user defined theme file
* @param[in] windowMode A member of Dali::Watch::WINDOW_MODE
*/
- WatchApplication( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ WatchApplication(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode);
/**
* Destructor
void OnAmbientChanged(bool ambient);
private:
-
// @brief Undefined copy constructor.
- WatchApplication( const WatchApplication& );
+ WatchApplication(const WatchApplication&);
// @brief Undefined assignment operator.
- WatchApplication& operator=( const WatchApplication& );
+ WatchApplication& operator=(const WatchApplication&);
public:
-
// Signals
- WatchTimeSignal mTickSignal;
- WatchTimeSignal mAmbientTickSignal;
- WatchBoolSignal mAmbientChangeSignal;
+ WatchTimeSignal mTickSignal;
+ WatchTimeSignal mAmbientTickSignal;
+ WatchBoolSignal mAmbientChangeSignal;
private:
- WatchApplicationState mState;
+ WatchApplicationState mState;
};
inline WatchApplication& GetImplementation(Dali::WatchApplication& watch)
return static_cast<const Internal::Adaptor::WatchApplication&>(handle);
}
-
} // namespace Adaptor
} // 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.
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
#define DALI_INTERNAL_ADDON_MANAGER_IMPL
/*
- * 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/addon-manager.h>
+#include <memory>
#include <string>
#include <vector>
-#include <memory>
namespace Dali
{
class AddOnManager
{
protected:
-
/**
* @brief Constructor
*/
* @brief Registers the dispatch table with AddOnManager.
* @param[in] dispatchTable Pointer to the valid dispatch table
*/
- virtual void RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable ) = 0;
+ virtual void RegisterAddOnDispatchTable(const AddOnDispatchTable* dispatchTable) = 0;
/**
* @brief Retrieves list of the available AddOns
* @param[out]] info Output reference
* @return True on success, False if extension info cannot be retrieved
*/
- virtual bool GetAddOnInfo(const std::string& name, AddOnInfo& info ) = 0;
+ virtual bool GetAddOnInfo(const std::string& name, AddOnInfo& info) = 0;
/**
* @brief Loads and initialises specified AddOns
* @param[in] extensionNames Array of extension names
* @return vector of initialised AddOnLibrary handles
*/
- virtual std::vector<Dali::AddOnLibrary> LoadAddOns( const std::vector<std::string>& addonNames ) = 0;
+ virtual std::vector<Dali::AddOnLibrary> LoadAddOns(const std::vector<std::string>& addonNames) = 0;
/**
* @brief Returns AddOn global function pointer
* @param[in] procName Name of the function to retrieve
* @return Pointer to the function or null if function doesn't exist
*/
- virtual void* GetGlobalProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) = 0;
+ virtual void* GetGlobalProc(const Dali::AddOnLibrary& addonHandle, const char* procName) = 0;
/**
* @brief Returns addon instance function pointer
* @param[in] procName Name of the function to retrieve
* @return Pointer to the function or null if function doesn't exist
*/
- virtual void* GetInstanceProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) = 0;
+ virtual void* GetInstanceProc(const Dali::AddOnLibrary& addonHandle, const char* procName) = 0;
/**
* @brief Pause lifecycle event
* Implementation is optional and depends whether AddOn needs to handle lifecycle event.
*/
- virtual void Pause() {}
+ virtual void Pause()
+ {
+ }
/**
* @brief Resume lifecycle event
* Implementation is optional and depends whether AddOn needs to handle lifecycle event.
*/
- virtual void Resume() {}
+ virtual void Resume()
+ {
+ }
/**
* @brief Start lifecycle event
* Implementation is optional and depends whether AddOn needs to handle lifecycle event.
*/
- virtual void Start() {}
+ virtual void Start()
+ {
+ }
/**
* @brief Stop lifecycle event
* Implementation is optional and depends whether AddOn needs to handle lifecycle event.
*/
- virtual void Stop() {}
+ virtual void Stop()
+ {
+ }
};
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_CMAKE_EXTENSION_MANAGER_IMPL
/*
- * 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
#define DALI_ADAPTOR_COMMON_ADDON_MANAGER
/*
- * 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
{
class AddOnManager;
namespace Adaptor
{
-
class AddOnManager : public Dali::Integration::AddOnManager
{
public:
-
/**
* @brief Constructor
* @param impl Pointer to the platform specific implementation
* event callbacks.
* @param[in] dispatchTable Valid pointer to the DispatchTable object
*/
- void RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable ) override;
+ void RegisterAddOnDispatchTable(const AddOnDispatchTable* dispatchTable) override;
/**
* @brief Retrieves list of all the extensions available
* @param[out]] info Output reference
* @return True on success, False if extension info cannot be retrieved
*/
- bool GetAddOnInfo(const std::string& name, AddOnInfo& info ) override;
+ bool GetAddOnInfo(const std::string& name, AddOnInfo& info) override;
/**
* @brief Loads and initialises specified extensions
* @param[in] extensionNames Array of extension names
* @return vector of initialised extension handles
*/
- std::vector<AddOnLibrary> LoadAddOns( const std::vector<std::string>& addonNames ) override;
+ std::vector<AddOnLibrary> LoadAddOns(const std::vector<std::string>& addonNames) override;
/**
* @brief Returns addon global function pointer
* @param[in] procName Name of the function to retrieve
* @return Pointer to the function or null if function doesn't exist
*/
- void* GetGlobalProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) override;
+ void* GetGlobalProc(const Dali::AddOnLibrary& addonHandle, const char* procName) override;
/**
* @brief Returns addon instance function pointer
* @param[in] procName Name of the function to retrieve
* @return Pointer to the function or null if function doesn't exist
*/
- void* GetInstanceProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) override;
+ void* GetInstanceProc(const Dali::AddOnLibrary& addonHandle, const char* procName) override;
/**
* @brief Lifecycle pause function
void Stop() override;
private:
-
std::unique_ptr<Internal::AddOnManager> mImpl; /// Implementation of the AddOnManager
-
};
-} // namespace Internal
+} // namespace Adaptor
} // namespace Dali
#endif // DALI_ADAPTOR_COMMON_ADDON_MANAGER
/*
- * 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];
#ifndef DALI_ADDON_MANAGER_IMPL_LINUX
#define DALI_ADDON_MANAGER_IMPL_LINUX
/*
- * 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/common/vector-wrapper.h>
-#include <string>
#include <memory>
+#include <string>
namespace Dali
{
namespace Internal
{
-
/**
* Implementation of AddOnManager for Linux based platforms (ie. Tizen, Ubuntu)
*/
class AddOnManagerLinux : public Internal::AddOnManager
{
public:
-
/**
* @copydoc Dali::Internal::AddOnManager()
*/
/**
* @copydoc Dali::Internal::AddOnManager::RegisterAddOnDispatchTable()
*/
- void RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable ) override;
+ void RegisterAddOnDispatchTable(const AddOnDispatchTable* dispatchTable) override;
/**
* @copydoc Dali::Internal::AddOnManager::EnumerateAddOns()
/**
* @copydoc Dali::Internal::AddOnManager::GetAddOnInfo()
*/
- bool GetAddOnInfo(const std::string& name, AddOnInfo& info ) override;
+ bool GetAddOnInfo(const std::string& name, AddOnInfo& info) override;
/**
* @copydoc Dali::Internal::AddOnManager::LoadAddOns()
*/
- std::vector<Dali::AddOnLibrary> LoadAddOns( const std::vector<std::string>& extensionNames ) override;
+ std::vector<Dali::AddOnLibrary> LoadAddOns(const std::vector<std::string>& extensionNames) override;
/**
* @copydoc Dali::Internal::AddOnManager::GetGlobalProc()
*/
- void* GetGlobalProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) override;
+ void* GetGlobalProc(const Dali::AddOnLibrary& addonHandle, const char* procName) override;
/**
* @copydoc Dali::Internal::AddOnManager::GetInstanceProc()
*/
- void* GetInstanceProc( const Dali::AddOnLibrary& addonHandle, const char* procName ) override;
+ void* GetInstanceProc(const Dali::AddOnLibrary& addonHandle, const char* procName) override;
/**
* @copydoc Dali::Internal::AddOnManager::Pause()
void Stop() override;
private:
-
/**
* @brief Invokes lifecycle event handling function based on incoming event
* @param[in] lifecycleEvent The lifecycle event
*/
- void InvokeLifecycleFunction( uint32_t lifecycleEvent );
+ void InvokeLifecycleFunction(uint32_t lifecycleEvent);
/**
* @struct Lifecycle callback structure
*/
struct LifecycleCallback
{
- const static uint32_t EVENT_PAUSE = 0u; ///< pause event
+ const static uint32_t EVENT_PAUSE = 0u; ///< pause event
const static uint32_t EVENT_RESUME = 1u; ///< resume event
- const static uint32_t EVENT_START = 2u; ///< start event
- const static uint32_t EVENT_STOP = 3u; ///< stop event
+ const static uint32_t EVENT_START = 2u; ///< start event
+ const static uint32_t EVENT_STOP = 3u; ///< stop event
/**
* @brief Constructor
functionName = funcName;
}
- std::string functionName; ///< Name of lifecycle function
- void(*function)() = nullptr; ///< Lifecycle function pointer
- bool initialized { false }; ///< Flag indicates whether LifecycleCallback is initialized
+ std::string functionName; ///< Name of lifecycle function
+ void (*function)() = nullptr; ///< Lifecycle function pointer
+ bool initialized{false}; ///< Flag indicates whether LifecycleCallback is initialized
};
/**
struct AddOnCacheEntry
{
std::string addOnLib{};
- AddOnInfo info{};
+ AddOnInfo info{};
// library handle
- void* libHandle {nullptr};
+ void* libHandle{nullptr};
// main function pointers
- void(*GetAddOnInfo)(AddOnInfo& ) = nullptr; ///< Returns AddOnInfo structure
- void*(*GetInstanceProc)( const char* ) = nullptr; ///< Returns pointer of instance function (member funtion)
- void*(*GetGlobalProc)( const char* ) = nullptr; ///< Returns pointer of global function (non-member function)
+ void (*GetAddOnInfo)(AddOnInfo&) = nullptr; ///< Returns AddOnInfo structure
+ void* (*GetInstanceProc)(const char*) = nullptr; ///< Returns pointer of instance function (member funtion)
+ void* (*GetGlobalProc)(const char*) = nullptr; ///< Returns pointer of global function (non-member function)
// lifecycle functions
std::vector<LifecycleCallback> lifecycleCallbacks =
- {
- LifecycleCallback{ "OnPause" },
- LifecycleCallback{ "OnResume" },
- LifecycleCallback{ "OnStart" },
- LifecycleCallback{ "OnStop" },
- };
+ {
+ LifecycleCallback{"OnPause"},
+ LifecycleCallback{"OnResume"},
+ LifecycleCallback{"OnStart"},
+ LifecycleCallback{"OnStop"},
+ };
bool opened{false};
};
std::vector<AddOnCacheEntry> mAddOnCache;
- std::vector<std::string> mAddOnNames;
+ std::vector<std::string> mAddOnNames;
};
-
-}
-}
+} // namespace Internal
+} // namespace Dali
#endif //DALI_CMAKE_EXTENSION_MANAGER_IMPL_UBUNTU
/*
- * 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);
}
}
#define DALI_INTERNAL_CLIPBOARD_EVENT_NOTIFIER_H
/*
- * 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 <string>
-#include <dali/public-api/object/base-object.h>
#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/object/base-object.h>
+#include <string>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* This class listens to Clipboard events.
*/
class ClipboardEventNotifier : public Dali::BaseObject
{
public:
-
typedef Dali::ClipboardEventNotifier::ClipboardEventSignalType ClipboardEventSignalType;
// Creation
* Sets the selected content.
* @param[in] content A string that represents the content that has been selected.
*/
- void SetContent( const std::string& content );
+ void SetContent(const std::string& content);
/**
* Clears the stored content.
void EmitContentSelectedSignal();
public: // Signals
-
/**
* @copydoc Dali::ClipboardEventNotifier::ContentSelectedSignal
*/
}
private:
-
// Construction & Destruction
/**
~ClipboardEventNotifier() override;
// Undefined
- ClipboardEventNotifier( const ClipboardEventNotifier& );
- ClipboardEventNotifier& operator=( ClipboardEventNotifier& );
+ ClipboardEventNotifier(const ClipboardEventNotifier&);
+ ClipboardEventNotifier& operator=(ClipboardEventNotifier&);
private:
-
- std::string mContent; ///< The current selected content.
+ std::string mContent; ///< The current selected content.
ClipboardEventSignalType mContentSelectedSignal;
public:
-
// Helpers for public-api forwarding methods
inline static Internal::Adaptor::ClipboardEventNotifier& GetImplementation(Dali::ClipboardEventNotifier& detector)
{
- DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "ClipboardEventNotifier handle is empty");
BaseObject& handle = detector.GetBaseObject();
inline static const Internal::Adaptor::ClipboardEventNotifier& GetImplementation(const Dali::ClipboardEventNotifier& detector)
{
- DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );
+ DALI_ASSERT_ALWAYS(detector && "ClipboardEventNotifier handle is empty");
const BaseObject& handle = detector.GetBaseObject();
return static_cast<const Internal::Adaptor::ClipboardEventNotifier&>(handle);
}
-
};
} // namespace Adaptor
#define DALI_INTERNAL_CLIPBOARD_H
/*
- * 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
{
-
/**
* Implementation of the Clip Board
*/
-class Clipboard : public Dali::BaseObject
+class Clipboard : public Dali::BaseObject
{
public:
-
// Hide the specific windowing system
struct Impl;
/**
* @copydoc Dali::Clipboard::SetItem()
*/
- bool SetItem(const std::string &itemData);
+ bool SetItem(const std::string& itemData);
/**
* @copydoc Dali::Clipboard::RequestItem()
* @param[in] event information pointer
* @return The buffer pointer for send or receive data
*/
- char* ExcuteBuffered( bool type, void *event );
+ char* ExcuteBuffered(bool type, void* event);
private:
-
// Undefined
- Clipboard( const Clipboard& );
- Clipboard& operator=( Clipboard& );
+ Clipboard(const Clipboard&);
+ Clipboard& operator=(Clipboard&);
private:
-
Impl* mImpl;
public:
-
}; // class clipboard
} // namespace Adaptor
inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
{
- DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
+ DALI_ASSERT_ALWAYS(clipboard && "Clipboard handle is empty");
BaseObject& handle = clipboard.GetBaseObject();
return static_cast<Internal::Adaptor::Clipboard&>(handle);
}
-inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
+inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
{
- DALI_ASSERT_ALWAYS( clipboard && "Clipboard handle is empty" );
+ DALI_ASSERT_ALWAYS(clipboard && "Clipboard handle is empty");
const BaseObject& handle = clipboard.GetBaseObject();
return static_cast<const Internal::Adaptor::Clipboard&>(handle);
}
${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
)
+# module: clipboard, backend: macos
+SET( adaptor_clipboard_macos_src_files
+ ${adaptor_clipboard_dir}/generic/clipboard-impl-generic.cpp
+)
/*
- * 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;
}
#define DALI_INTERNAL_EGL_IMAGE_EXTENSIONS_H
/*
- * 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.
*/
~EglImageExtensions();
-
-public: // EGLImageKHR extension support
-
+public: // EGLImageKHR extension support
/**
* If the EGL Image extension is available this function returns a
* EGLImageKHR
private:
EglImplementation* mEglImplementation;
- bool mImageKHRInitialized; ///< Flag for whether extended KHR functions loaded
- bool mImageKHRInitializeFailed; ///< Flag to avoid trying to reload extended KHR functions, if
- /// it fails the first time
+ bool mImageKHRInitialized; ///< Flag for whether extended KHR functions loaded
+ bool mImageKHRInitializeFailed; ///< Flag to avoid trying to reload extended KHR functions, if
+ /// it fails the first time
};
} // namespace Adaptor
#define DALI_INTERNAL_BASE_GRAPHICS_FACTORY_INTERFACE_H
/*
- * 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 INCLUDES
-#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/graphics/common/graphics-interface.h>
+#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Factory interface for creating Graphics Factory implementation
*/
/**
* Virtual protected destructor - no deletion through this interface
*/
- virtual ~GraphicsFactoryInterface() {};
+ virtual ~GraphicsFactoryInterface(){};
};
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_BASE_GRAPHICS_FACTORY_INTERFACE_H
#define DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H
/*
- * 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 INCLUDES
-#include <dali/internal/system/common/environment-options.h>
+#include <dali/graphics-api/graphics-controller.h>
#include <dali/integration-api/core-enumerations.h>
+#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
+class RenderSurfaceInterface;
namespace Internal
{
-
namespace Adaptor
{
+class ConfigurationManager;
/**
* Factory interface for creating Graphics Factory implementation
class GraphicsInterface
{
public:
-
/**
* Constructor
*/
GraphicsInterface()
- : mDepthBufferRequired( Integration::DepthBufferAvailable::FALSE ),
- mStencilBufferRequired( Integration::StencilBufferAvailable::FALSE ),
- mPartialUpdateRequired( Integration::PartialUpdateAvailable::FALSE )
- {
- };
+ : mDepthBufferRequired(Integration::DepthBufferAvailable::FALSE),
+ mStencilBufferRequired(Integration::StencilBufferAvailable::FALSE),
+ mPartialUpdateRequired(Integration::PartialUpdateAvailable::FALSE){};
/**
* Destructor
*/
- virtual ~GraphicsInterface() {}
+ virtual ~GraphicsInterface() = default;
+
+ /**
+ * Returns controller object
+ * @return
+ */
+ virtual Dali::Graphics::Controller& GetController() = 0;
+
+ /**
+ * Initialize the graphics subsystem, configured from environment
+ */
+ virtual void Initialize() = 0;
+
+ /**
+ * Initialize the graphics subsystem, providing explicit parameters.
+ *
+ * @param[in] depth True if depth buffer is required
+ * @param[in] stencil True if stencil buffer is required
+ * @param[in] partialRendering True if partial rendering is required
+ * @param[in] msaa level of anti-aliasing required (-1 = off)
+ */
+ virtual void Initialize(bool depth, bool stencil, bool partialRendering, int msaa) = 0;
/**
- * Initialize the graphics interface
- * @param[in] environmentOptions The environment options.
+ * Configure the graphics surface
+ *
+ * @param[in] surface The surface to configure, or NULL if not present
*/
- virtual void Initialize( EnvironmentOptions* environmentOptions ) = 0;
+ virtual void ConfigureSurface(Dali::RenderSurfaceInterface* surface) = 0;
/**
- * Destroy the Graphics Factory implementation
+ * Activate the resource context
+ */
+ virtual void ActivateResourceContext() = 0;
+
+ /**
+ * Inform graphics interface that this is the first frame after a resume.
+ */
+ virtual void SetFirstFrameAfterResume() = 0;
+
+ /**
+ * Shut down the graphics implementation
+ */
+ virtual void Shutdown() = 0;
+
+ /**
+ * Destroy the Graphics implementation
*/
virtual void Destroy() = 0;
return mPartialUpdateRequired;
};
-protected:
+ /**
+ * @return true if advanced blending options are supported
+ */
+ virtual bool IsAdvancedBlendEquationSupported() = 0;
+
+ /**
+ * @return true if graphics subsystem is initialized
+ */
+ virtual bool IsInitialized() = 0;
+
+ /**
+ * @return true if a separate resource context is supported
+ */
+ virtual bool IsResourceContextSupported() = 0;
- Integration::DepthBufferAvailable mDepthBufferRequired; ///< Whether the depth buffer is required
- Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
- Integration::PartialUpdateAvailable mPartialUpdateRequired; ///< Whether the partial update is required
+ /**
+ * @return the maximum texture size
+ */
+ virtual uint32_t GetMaxTextureSize() = 0;
+
+ /**
+ * @return the version number of the shader language
+ */
+ virtual uint32_t GetShaderLanguageVersion() = 0;
+
+ /**
+ * Store cached configurations
+ */
+ virtual void CacheConfigurations(ConfigurationManager& configurationManager) = 0;
+
+protected:
+ Integration::DepthBufferAvailable mDepthBufferRequired; ///< Whether the depth buffer is required
+ Integration::StencilBufferAvailable mStencilBufferRequired; ///< Whether the stencil buffer is required
+ Integration::PartialUpdateAvailable mPartialUpdateRequired; ///< Whether the partial update is required
};
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H
${adaptor_graphics_dir}/gles/gl-proxy-implementation.cpp
${adaptor_graphics_dir}/gles/egl-graphics-factory.cpp
${adaptor_graphics_dir}/gles/egl-graphics.cpp
+ ${adaptor_graphics_dir}/gles/egl-graphics-controller.cpp
)
# module: graphics, backend: tizen
${adaptor_graphics_dir}/windows-gl/egl-image-extensions.cpp
)
+# module: graphics, backend: macos
+SET( adaptor_graphics_macos_src_files
+ ${adaptor_graphics_dir}/macos/egl-image-extensions.cpp
+)
/*
- * 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
#define DALI_INTERNAL_ADAPTOR_EGL_CONTEXT_HELPER_IMPLEMENTATION_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 Integration
{
class RenderSurface;
{
namespace Adaptor
{
-
class EglImplementation;
/**
* Initialize with the Egl implementation.
* @param[in] impl The EGL implementation (to access the EGL context)
*/
- void Initialize( EglImplementation* impl );
+ void Initialize(EglImplementation* impl);
/**
* @copydoc Dali::Integration::GlContextHelperAbstraction::MakeSurfacelessContextCurrent()
void WaitClient() override;
private:
-
EglImplementation* mEglImplementation; ///< Egl implementation (to access the EGL context)
};
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
#define DALI_INTERNAL_EGL_DEBUG_H
/*
- * 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 Egl
{
+void PrintError(EGLint error);
-void PrintError( EGLint error);
-
-} // namespace Egl
+} // namespace Egl
-} // namespace Adaptor
+} // namespace Adaptor
-} // namespace Internal
+} // namespace Internal
-} // namespace Dali
+} // namespace Dali
#endif //DALI_INTERNAL_EGL_DEBUG_H
namespace Dali
{
-
class EglInterface;
namespace Internal
{
namespace Adaptor
{
-
/**
* Factory interface for creating EGL implementation
*/
/**
* Virtual protected destructor - no deletion through this interface
*/
- virtual ~EglFactoryInterface() {};
+ virtual ~EglFactoryInterface(){};
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali/internal/graphics/gles/egl-graphics-controller.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+void EglGraphicsController::InitializeGLES(Integration::GlAbstraction& glAbstraction)
+{
+ mGlAbstraction = &glAbstraction;
+}
+
+void EglGraphicsController::Initialize(Integration::GlSyncAbstraction& glSyncAbstraction,
+ Integration::GlContextHelperAbstraction& glContextHelperAbstraction)
+{
+ mGlSyncAbstraction = &glSyncAbstraction;
+ mGlContextHelperAbstraction = &glContextHelperAbstraction;
+}
+
+Integration::GlAbstraction& EglGraphicsController::GetGlAbstraction()
+{
+ DALI_ASSERT_DEBUG(mGlAbstraction && "Graphics controller not initialized");
+ return *mGlAbstraction;
+}
+
+Integration::GlSyncAbstraction& EglGraphicsController::GetGlSyncAbstraction()
+{
+ DALI_ASSERT_DEBUG(mGlSyncAbstraction && "Graphics controller not initialized");
+ return *mGlSyncAbstraction;
+}
+
+Integration::GlContextHelperAbstraction& EglGraphicsController::GetGlContextHelperAbstraction()
+{
+ DALI_ASSERT_DEBUG(mGlContextHelperAbstraction && "Graphics controller not initialized");
+ return *mGlContextHelperAbstraction;
+}
+
+} // namespace Graphics
+} // namespace Dali
--- /dev/null
+#ifndef DALI_EGL_GRAPHICS_CONTROLLER_H
+#define DALI_EGL_GRAPHICS_CONTROLLER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali/graphics-api/graphics-controller.h>
+
+namespace Dali
+{
+namespace Integration
+{
+class GlAbstraction;
+class GlSyncAbstraction;
+class GlContextHelperAbstraction;
+} // namespace Integration
+
+namespace Graphics
+{
+/**
+ * EGL Implementation of the graphics controller.
+ *
+ * Temporarily holds the old GL abstractions whilst dali-core is migrated to the new API.
+ */
+class EglGraphicsController : public Graphics::Controller
+{
+public:
+ EglGraphicsController() = default;
+
+ virtual ~EglGraphicsController() = default;
+
+ /**
+ * Initialize the GLES abstraction. This can be called from the main thread.
+ */
+ void InitializeGLES(Integration::GlAbstraction& glAbstraction);
+
+ /**
+ * Initialize with a reference to the GL abstractions.
+ *
+ * Note, this is now executed in the render thread, after core initialization
+ */
+ void Initialize(Integration::GlSyncAbstraction& glSyncAbstraction,
+ Integration::GlContextHelperAbstraction& glContextHelperAbstraction);
+
+ Integration::GlAbstraction& GetGlAbstraction() override;
+ Integration::GlSyncAbstraction& GetGlSyncAbstraction() override;
+ Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override;
+
+private:
+ Integration::GlAbstraction* mGlAbstraction{nullptr};
+ Integration::GlSyncAbstraction* mGlSyncAbstraction{nullptr};
+ Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr};
+};
+
+} // namespace Graphics
+
+} // namespace Dali
+
+#endif //DALI_EGL_GRAPHICS_CONTROLLER_H
/*
- * 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/gles/egl-graphics-factory.h>
#include <dali/internal/graphics/gles/egl-graphics.h>
{
namespace Adaptor
{
-
-GraphicsFactory::GraphicsFactory()
+GraphicsFactory::GraphicsFactory(EnvironmentOptions& environmentOptions)
+: mEnvironmentOptions(environmentOptions)
{
}
GraphicsInterface& GraphicsFactory::Create()
{
- GraphicsInterface* eglGraphicsInterface = new EglGraphics;
+ GraphicsInterface* eglGraphicsInterface = new EglGraphics(mEnvironmentOptions);
return *eglGraphicsInterface;
}
/* Deleted by EglGraphics */
}
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_GRAPHICS_FACTORY_H
/*
- * 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/graphics-factory-interface.h>
+// INTERNAL INCLUDES
+#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class GraphicsFactory : public GraphicsFactoryInterface
{
public:
-
/**
* Constructor
*/
- GraphicsFactory();
+ GraphicsFactory(EnvironmentOptions& environmentOptions);
/**
* Destructor
* @copydoc Dali::Internal::Adaptor::GraphicsFactoryInterface::Destroy()
*/
void Destroy() override;
+
+private:
+ EnvironmentOptions& mEnvironmentOptions;
};
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_GRAPHICS_FACTORY_H
/*
- * 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/gles/egl-graphics.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include <dali/internal/system/common/configuration-manager.h>
+#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
namespace Dali
{
namespace Adaptor
{
-
-EglGraphics::EglGraphics( )
-: mMultiSamplingLevel( 0 )
+EglGraphics::EglGraphics(EnvironmentOptions& environmentOptions)
+: mMultiSamplingLevel(0)
{
+ mDepthBufferRequired = static_cast<Integration::DepthBufferAvailable>(environmentOptions.DepthBufferRequired());
+ mStencilBufferRequired = static_cast<Integration::StencilBufferAvailable>(environmentOptions.StencilBufferRequired());
+ mPartialUpdateRequired = static_cast<Integration::PartialUpdateAvailable>(environmentOptions.PartialUpdateRequired());
+ mMultiSamplingLevel = environmentOptions.GetMultiSamplingLevel();
+
+ if(environmentOptions.GetGlesCallTime() > 0)
+ {
+ mGLES = Utils::MakeUnique<GlProxyImplementation>(environmentOptions);
+ }
+ else
+ {
+ mGLES.reset(new GlImplementation());
+ }
+
+ mGraphicsController.InitializeGLES(*mGLES.get());
}
EglGraphics::~EglGraphics()
{
}
-void EglGraphics::SetGlesVersion( const int32_t glesVersion )
+void EglGraphics::SetGlesVersion(const int32_t glesVersion)
{
- mEglImplementation->SetGlesVersion( glesVersion );
- mGLES->SetGlesVersion( glesVersion );
+ if(mEglImplementation)
+ {
+ mEglImplementation->SetGlesVersion(glesVersion);
+ }
+
+ mGLES->SetGlesVersion(glesVersion);
}
-void EglGraphics::SetIsSurfacelessContextSupported( const bool isSupported )
+void EglGraphics::SetIsSurfacelessContextSupported(const bool isSupported)
{
- mGLES->SetIsSurfacelessContextSupported( isSupported );
+ mGLES->SetIsSurfacelessContextSupported(isSupported);
}
-void EglGraphics::Initialize( EnvironmentOptions* environmentOptions )
+void EglGraphics::ActivateResourceContext()
{
- if( environmentOptions->GetGlesCallTime() > 0 )
+ if(mEglImplementation && mEglImplementation->IsSurfacelessContextSupported())
{
- mGLES = Utils::MakeUnique< GlProxyImplementation >( *environmentOptions );
+ // Make the shared surfaceless context as current before rendering
+ mEglImplementation->MakeContextCurrent(EGL_NO_SURFACE, mEglImplementation->GetContext());
}
- else
+}
+
+void EglGraphics::SetFirstFrameAfterResume()
+{
+ if(mEglImplementation)
{
- mGLES.reset ( new GlImplementation() );
+ mEglImplementation->SetFirstFrameAfterResume();
}
+}
- mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( environmentOptions->DepthBufferRequired() );
- mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( environmentOptions->StencilBufferRequired() );
- mPartialUpdateRequired = static_cast< Integration::PartialUpdateAvailable >( environmentOptions->PartialUpdateRequired() );
-
- mMultiSamplingLevel = environmentOptions->GetMultiSamplingLevel();
-
- mEglSync = Utils::MakeUnique< EglSyncImplementation >();
+void EglGraphics::Initialize()
+{
+ EglInitialize();
- mEglContextHelper = Utils::MakeUnique< EglContextHelperImplementation >();
+ // Sync and context helper require EGL to be initialized first (can't execute in the constructor)
+ mGraphicsController.Initialize(*mEglSync.get(), *mEglContextHelper.get());
}
-void EglGraphics::Initialize( bool depth, bool stencil, int msaa )
+void EglGraphics::Initialize(bool depth, bool stencil, bool partialRendering, int msaa)
{
- mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( depth );
- mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( stencil );
+ mDepthBufferRequired = static_cast<Integration::DepthBufferAvailable>(depth);
+ mStencilBufferRequired = static_cast<Integration::StencilBufferAvailable>(stencil);
+ mPartialUpdateRequired = static_cast<Integration::PartialUpdateAvailable>(partialRendering);
+ mMultiSamplingLevel = msaa;
- mMultiSamplingLevel = msaa;
+ EglInitialize();
+}
- mEglSync = std::unique_ptr<EglSyncImplementation>( new EglSyncImplementation() );
+void EglGraphics::EglInitialize()
+{
+ mEglSync = Utils::MakeUnique<EglSyncImplementation>();
+ mEglContextHelper = Utils::MakeUnique<EglContextHelperImplementation>();
+ mEglImplementation = Utils::MakeUnique<EglImplementation>(mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired, mPartialUpdateRequired);
+ mEglImageExtensions = Utils::MakeUnique<EglImageExtensions>(mEglImplementation.get());
- mEglContextHelper = std::unique_ptr<EglContextHelperImplementation>( new EglContextHelperImplementation() );
+ mEglSync->Initialize(mEglImplementation.get()); // The sync impl needs the EglDisplay
+ mEglContextHelper->Initialize(mEglImplementation.get()); // The context helper impl needs the EglContext
}
-EglInterface* EglGraphics::Create()
+void EglGraphics::ConfigureSurface(Dali::RenderSurfaceInterface* surface)
{
- mEglImplementation = Utils::MakeUnique< EglImplementation >( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired, mPartialUpdateRequired );
- mEglImageExtensions = Utils::MakeUnique< EglImageExtensions >( mEglImplementation.get() );
+ DALI_ASSERT_ALWAYS(mEglImplementation && "EGLImplementation not created");
+
+ // Try to use OpenGL es 3.0
+ // ChooseConfig returns false here when the device only support gles 2.0.
+ // Because eglChooseConfig with gles 3.0 setting fails when the device only support gles 2.0 and Our default setting is gles 3.0.
+ if(!mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32))
+ {
+ // Retry to use OpenGL es 2.0
+ SetGlesVersion(20);
+ mEglImplementation->ChooseConfig(true, COLOR_DEPTH_32);
+ }
+
+ // Check whether surfaceless context is supported
+ bool isSurfacelessContextSupported = mEglImplementation->IsSurfacelessContextSupported();
+ SetIsSurfacelessContextSupported(isSurfacelessContextSupported);
- mEglSync->Initialize( mEglImplementation.get() ); // The sync impl needs the EglDisplay
+ RenderSurfaceInterface* currentSurface = nullptr;
+ if(isSurfacelessContextSupported)
+ {
+ // Create a surfaceless OpenGL context for shared resources
+ mEglImplementation->CreateContext();
+ mEglImplementation->MakeContextCurrent(EGL_NO_SURFACE, mEglImplementation->GetContext());
+ }
+ else
+ {
+ currentSurface = surface;
+ if(currentSurface)
+ {
+ currentSurface->InitializeGraphics();
+ currentSurface->MakeContextCurrent();
+ }
+ }
- mEglContextHelper->Initialize( mEglImplementation.get() ); // The context helper impl needs the EglContext
+ mGLES->ContextCreated();
+ SetGlesVersion(mGLES->GetGlesVersion());
+}
- return mEglImplementation.get();
+void EglGraphics::Shutdown()
+{
+ if(mEglImplementation)
+ {
+ mEglImplementation->TerminateGles();
+ }
}
void EglGraphics::Destroy()
Integration::GlAbstraction& EglGraphics::GetGlAbstraction() const
{
- DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
+ DALI_ASSERT_DEBUG(mGLES && "GLImplementation not created");
return *mGLES;
}
EglImplementation& EglGraphics::GetEglImplementation() const
{
- DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
+ DALI_ASSERT_ALWAYS(mEglImplementation && "EGLImplementation not created");
return *mEglImplementation;
}
EglInterface& EglGraphics::GetEglInterface() const
{
- DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
+ DALI_ASSERT_ALWAYS(mEglImplementation && "EGLImplementation not created");
EglInterface* eglInterface = mEglImplementation.get();
return *eglInterface;
}
EglSyncImplementation& EglGraphics::GetSyncImplementation()
{
- DALI_ASSERT_DEBUG( mEglSync && "EglSyncImplementation not created" );
+ DALI_ASSERT_DEBUG(mEglSync && "EglSyncImplementation not created");
return *mEglSync;
}
EglContextHelperImplementation& EglGraphics::GetContextHelperImplementation()
{
- DALI_ASSERT_DEBUG( mEglContextHelper && "EglContextHelperImplementation not created" );
+ DALI_ASSERT_DEBUG(mEglContextHelper && "EglContextHelperImplementation not created");
return *mEglContextHelper;
}
EglImageExtensions* EglGraphics::GetImageExtensions()
{
- DALI_ASSERT_DEBUG( mEglImageExtensions && "EglImageExtensions not created" );
+ DALI_ASSERT_DEBUG(mEglImageExtensions && "EglImageExtensions not created");
return mEglImageExtensions.get();
}
-} // Adaptor
-} // Internal
-} // Dali
+Graphics::Controller& EglGraphics::GetController()
+{
+ return mGraphicsController;
+}
+
+void EglGraphics::CacheConfigurations(ConfigurationManager& configurationManager)
+{
+ mGLES->SetIsAdvancedBlendEquationSupported(configurationManager.IsAdvancedBlendEquationSupported());
+ mGLES->SetShadingLanguageVersion(configurationManager.GetShadingLanguageVersion());
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
/*
- * 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/egl-interface.h>
#include <dali/internal/graphics/common/egl-image-extensions.h>
#include <dali/internal/graphics/common/graphics-interface.h>
-#include <dali/internal/graphics/gles/gl-implementation.h>
-#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
#include <dali/internal/graphics/gles/egl-context-helper-implementation.h>
+#include <dali/internal/graphics/gles/egl-graphics-controller.h>
#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/graphics/gles/egl-sync-implementation.h>
+#include <dali/internal/graphics/gles/gl-implementation.h>
+#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
+class EnvironmentOptions;
+class ConfigurationManager;
class EglGraphics : public GraphicsInterface
{
public:
-
/**
* Constructor
*/
- EglGraphics();
+ EglGraphics(EnvironmentOptions& environmentOptions);
/**
* Destructor
/**
* @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize()
*/
- void Initialize( EnvironmentOptions* environmentOptions ) override;
+ void Initialize() override;
/**
- * Initialize the graphics interface with specific input parameters
- * @param[in] depth The flag to enable depth buffer
- * @param[in] stencil The flag to enable stencil buffer
- * @param[in] msaa The value of multi sampleing bit
+ * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize(bool,bool,bool,int)
*/
- void Initialize( bool depth, bool stencil, int msaa );
+ void Initialize(bool depth, bool stencil, bool partialRendering, int msaa);
/**
- * Creates the graphics interface for EGL
- * @return The graphics interface for EGL
+ * @copydoc Dali::Internal::Adaptor::GraphicsInterface::ConfigureSurface()
*/
- EglInterface* Create();
+ void ConfigureSurface(Dali::RenderSurfaceInterface* surface) override;
/**
* Set gles version
* Default version is gles 3.0
*/
- void SetGlesVersion( const int32_t glesVersion );
+ void SetGlesVersion(const int32_t glesVersion);
/**
* Set whether the surfaceless context is supported
* @param[in] isSupported Whether the surfaceless context is supported
*/
- void SetIsSurfacelessContextSupported( const bool isSupported );
+ void SetIsSurfacelessContextSupported(const bool isSupported);
+
+ /**
+ * Activate the resource context (shared surfaceless context)
+ */
+ void ActivateResourceContext() override;
+
+ /**
+ * Inform graphics interface that this is the first frame after a resume.
+ * (For debug only)
+ */
+ void SetFirstFrameAfterResume() override;
/**
* Gets the GL abstraction
EglImageExtensions* GetImageExtensions();
/**
+ * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Shutdown()
+ */
+ void Shutdown() override;
+
+ /**
* @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
*/
void Destroy() override;
+ Graphics::Controller& GetController() override;
+
+ bool IsAdvancedBlendEquationSupported() override
+ {
+ return mGLES->IsAdvancedBlendEquationSupported();
+ }
+
+ /**
+ * @return true if graphics subsystem is initialized
+ */
+ bool IsInitialized() override
+ {
+ return mEglImplementation && mEglImplementation->IsGlesInitialized();
+ }
+
+ bool IsResourceContextSupported() override
+ {
+ return mEglImplementation && mEglImplementation->IsSurfacelessContextSupported();
+ }
+
+ uint32_t GetMaxTextureSize() override
+ {
+ return mGLES->GetMaxTextureSize();
+ }
+
+ uint32_t GetShaderLanguageVersion() override
+ {
+ return mGLES->GetShadingLanguageVersion();
+ }
+
+ void CacheConfigurations(ConfigurationManager& configurationManager) override;
+
private:
// Eliminate copy and assigned operations
EglGraphics(const EglGraphics& rhs) = delete;
EglGraphics& operator=(const EglGraphics& rhs) = delete;
+ /**
+ * Initialize graphics subsystems
+ */
+ void EglInitialize();
private:
- std::unique_ptr< GlImplementation > mGLES; ///< GL implementation
- std::unique_ptr< EglImplementation > mEglImplementation; ///< EGL implementation
- std::unique_ptr< EglImageExtensions > mEglImageExtensions; ///< EGL image extension
- std::unique_ptr< EglSyncImplementation > mEglSync; ///< GlSyncAbstraction implementation for EGL
- std::unique_ptr< EglContextHelperImplementation > mEglContextHelper; ///< GlContextHelperAbstraction implementation for EGL
-
- int mMultiSamplingLevel; ///< The multiple sampling level
+ Graphics::EglGraphicsController mGraphicsController; ///< Graphics Controller for Dali Core
+ std::unique_ptr<GlImplementation> mGLES; ///< GL implementation
+ std::unique_ptr<EglImplementation> mEglImplementation; ///< EGL implementation
+ std::unique_ptr<EglImageExtensions> mEglImageExtensions; ///< EGL image extension
+ std::unique_ptr<EglSyncImplementation> mEglSync; ///< GlSyncAbstraction implementation for EGL
+ std::unique_ptr<EglContextHelperImplementation> mEglContextHelper; ///< GlContextHelperAbstraction implementation for EGL
+
+ int mMultiSamplingLevel; ///< The multiple sampling level
};
} // 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.
*
*/
-
// 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");
}
#define DALI_INTERNAL_EGL_IMPLEMENTATION_H
/*
- * 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/public-api/common/list-wrapper.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/integration-api/core-enumerations.h>
#include <dali/internal/graphics/common/egl-include.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/math/rect.h>
-#include <dali/integration-api/core-enumerations.h>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/egl-interface.h>
{
namespace Adaptor
{
-
/**
* EglImplementation class provides an EGL implementation.
*/
class EglImplementation : public EglInterface
{
public:
-
/**
* Constructor
* @param[in] multiSamplingLevel The Multi-sampling level required
* @param[in] stencilBufferRequired Whether the stencil buffer is required
* @param[in] partialUpdatedRequired Whether the partial update is required
*/
- EglImplementation( int multiSamplingLevel,
- Integration::DepthBufferAvailable depthBufferRequired,
- Integration::StencilBufferAvailable stencilBufferRequired,
- Integration::PartialUpdateAvailable partialUpdateRequired );
+ EglImplementation(int multiSamplingLevel,
+ Integration::DepthBufferAvailable depthBufferRequired,
+ Integration::StencilBufferAvailable stencilBufferRequired,
+ Integration::PartialUpdateAvailable partialUpdateRequired);
/**
* Destructor
~EglImplementation() override;
public:
-
/**
* (Called from RenderSurface, not RenderThread, so not in i/f, hence, not virtual)
* Initialize GL
* @param isOwnSurface whether the surface is own or not
* @return true on success, false on failure
*/
- bool InitializeGles( EGLNativeDisplayType display, bool isOwnSurface = true );
+ bool InitializeGles(EGLNativeDisplayType display, bool isOwnSurface = true);
/**
* Create the OpenGL context for the shared resource.
* Create the OpenGL context for the window.
* @return true if successful
*/
- bool CreateWindowContext( EGLContext& mEglContext );
+ bool CreateWindowContext(EGLContext& mEglContext);
/**
* Destroy the OpenGL context.
*/
- void DestroyContext( EGLContext& eglContext );
+ void DestroyContext(EGLContext& eglContext);
/**
* Destroy the OpenGL surface.
*/
- void DestroySurface( EGLSurface& eglSurface );
+ void DestroySurface(EGLSurface& eglSurface);
/**
* Make the OpenGL context current
*/
- void MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext ) override;
+ void MakeContextCurrent(EGLSurface eglSurface, EGLContext eglContext) override;
/**
* clear the OpenGL context
* @param pixmap The pixmap to replace the current surface
* @param eglSurface The eglSurface to replace the current OpenGL surface.
*/
- void MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface );
+ void MakeCurrent(EGLNativePixmapType pixmap, EGLSurface eglSurface);
/**
* Terminate GL
/**
* Performs an OpenGL swap buffers command
*/
- void SwapBuffers( EGLSurface& eglSurface ) override;
+ void SwapBuffers(EGLSurface& eglSurface) override;
/**
* Gets current back buffer age
*/
- EGLint GetBufferAge( EGLSurface& eglSurface ) const;
+ EGLint GetBufferAge(EGLSurface& eglSurface) const;
/**
* Performs an OpenGL set damage command with damaged rects
*/
- void SetDamageRegion( EGLSurface& eglSurface, std::vector< Rect< int > >& damagedRects );
+ void SetDamageRegion(EGLSurface& eglSurface, std::vector<Rect<int>>& damagedRects);
/**
* Performs an OpenGL swap buffers command with damaged rects
*/
- virtual void SwapBuffers( EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects );
+ virtual void SwapBuffers(EGLSurface& eglSurface, const std::vector<Rect<int>>& damagedRects);
/**
* Performs an OpenGL copy buffers command
*/
- void CopyBuffers( EGLSurface& eglSurface ) override;
+ void CopyBuffers(EGLSurface& eglSurface) override;
/**
* Performs an EGL wait GL command
* @param colorDepth Bit per pixel value (ex. 32 or 24)
* @return true if the eglChooseConfig is succeed.
*/
- bool ChooseConfig( bool isWindowType, ColorDepth depth );
+ bool ChooseConfig(bool isWindowType, ColorDepth depth);
/**
* Create an OpenGL surface using a window
* @param colorDepth Bit per pixel value (ex. 32 or 24)
* @return Handle to an on-screen EGL window surface (the requester has an ownership of this egl surface)
*/
- EGLSurface CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth );
+ EGLSurface CreateSurfaceWindow(EGLNativeWindowType window, ColorDepth depth);
/**
* Create the OpenGL surface using a pixmap
* @param colorDepth Bit per pixel value (ex. 32 or 24)
* @return Handle to an off-screen EGL pixmap surface (the requester has an ownership of this egl surface)
*/
- EGLSurface CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth );
+ EGLSurface CreateSurfacePixmap(EGLNativePixmapType pixmap, ColorDepth depth);
/**
* Replaces the render surface
* @return true if the context was lost due to a change in display
* between old surface and new surface
*/
- bool ReplaceSurfaceWindow( EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext );
+ bool ReplaceSurfaceWindow(EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext);
/**
* Replaces the render surface
* @return true if the context was lost due to a change in x-display
* between old surface and new surface
*/
- bool ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLSurface& eglSurface );
+ bool ReplaceSurfacePixmap(EGLNativePixmapType pixmap, EGLSurface& eglSurface);
/**
* Sets gles version
*/
- void SetGlesVersion( const int32_t glesVersion );
+ void SetGlesVersion(const int32_t glesVersion);
/**
* Sets Whether the frame is the first after Resume.
bool IsPartialUpdateRequired() const;
private:
-
- Vector<EGLint> mContextAttribs;
+ Vector<EGLint> mContextAttribs;
EGLNativeDisplayType mEglNativeDisplay;
- EGLNativeWindowType mEglNativeWindow;
+ EGLNativeWindowType mEglNativeWindow;
- EGLNativePixmapType mCurrentEglNativePixmap;
+ EGLNativePixmapType mCurrentEglNativePixmap;
- EGLDisplay mEglDisplay;
- EGLConfig mEglConfig;
- EGLContext mEglContext; ///< The resource context holding assets such as textures to be shared
+ EGLDisplay mEglDisplay;
+ EGLConfig mEglConfig;
+ EGLContext mEglContext; ///< The resource context holding assets such as textures to be shared
typedef std::vector<EGLContext> EglWindowContextContainer;
- EglWindowContextContainer mEglWindowContexts; ///< The EGL context for the window
+ EglWindowContextContainer mEglWindowContexts; ///< The EGL context for the window
- EGLSurface mCurrentEglSurface;
- EGLContext mCurrentEglContext;
+ EGLSurface mCurrentEglSurface;
+ EGLContext mCurrentEglContext;
typedef std::vector<EGLSurface> EglWindowSurfaceContainer;
- EglWindowSurfaceContainer mEglWindowSurfaces; ///< The EGL surface for the window
+ EglWindowSurfaceContainer mEglWindowSurfaces; ///< The EGL surface for the window
- int32_t mMultiSamplingLevel;
- int32_t mGlesVersion;
+ int32_t mMultiSamplingLevel;
+ int32_t mGlesVersion;
- ColorDepth mColorDepth;
+ ColorDepth mColorDepth;
- bool mGlesInitialized;
- bool mIsOwnSurface;
- bool mIsWindow;
- bool mDepthBufferRequired;
- bool mStencilBufferRequired;
- bool mPartialUpdateRequired;
- bool mIsSurfacelessContextSupported;
- bool mIsKhrCreateContextSupported;
+ bool mGlesInitialized;
+ bool mIsOwnSurface;
+ bool mIsWindow;
+ bool mDepthBufferRequired;
+ bool mStencilBufferRequired;
+ bool mPartialUpdateRequired;
+ bool mIsSurfacelessContextSupported;
+ bool mIsKhrCreateContextSupported;
- uint32_t mSwapBufferCountAfterResume;
- PFNEGLSETDAMAGEREGIONKHRPROC mEglSetDamageRegionKHR;
+ uint32_t mSwapBufferCountAfterResume;
+ PFNEGLSETDAMAGEREGIONKHRPROC mEglSetDamageRegionKHR;
PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC mEglSwapBuffersWithDamageKHR;
-
};
} // 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.
#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
#define DALI_INTERNAL_ADAPTOR_EGL_SYNC_IMPLEMENTATION_H
/*
- * 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/integration-api/gl-sync-abstraction.h>
#include <dali/internal/graphics/common/egl-include.h>
#include <dali/public-api/common/dali-vector.h>
-#include <dali/integration-api/gl-sync-abstraction.h>
// INTERNAL INCLUDES
#include <dali/public-api/dali-adaptor-common.h>
/**
* Constructor
*/
- EglSyncObject( EglImplementation& eglSyncImpl );
+ EglSyncObject(EglImplementation& eglSyncImpl);
/**
* Destructor
EglImplementation& mEglImplementation;
};
-
/**
* GlSyncImplementation is a concrete implementation for GlSyncAbstraction.
* It provides fence syncing for resources such as FrameBuffers using EGL extensions
* Initialize the sync object with the Egl implementation.
* @param[in] impl The EGL implementation (to access display)
*/
- void Initialize( EglImplementation* impl );
+ void Initialize(EglImplementation* impl);
/**
* @copydoc Dali::Integration::GlSyncAbstraction::CreateSyncObject()
void InitializeEglSync();
private:
- typedef Vector<EglSyncObject*> SyncContainer;
- typedef SyncContainer::Iterator SyncIter;
+ typedef Vector<EglSyncObject*> SyncContainer;
+ typedef SyncContainer::Iterator SyncIter;
- EglImplementation* mEglImplementation; ///< Egl implementation (to get display)
- bool mSyncInitialized; ///< Flag to perform initialization on first use
- bool mSyncInitializeFailed; ///< Flag to avoid reloading functions if failed once
+ EglImplementation* mEglImplementation; ///< Egl implementation (to get display)
+ bool mSyncInitialized; ///< Flag to perform initialization on first use
+ bool mSyncInitializeFailed; ///< Flag to avoid reloading functions if failed once
SyncContainer mSyncObjects;
};
/*
- * 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
}
#define DALI_INTERNAL_GL_EXTENSION_H
/*
- * 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 <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-
+#include <GLES3/gl3.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* GlExtensions class provides GL extensions support
*/
class GlExtensions
{
public:
-
/**
* Constructor
*/
*/
~GlExtensions();
-
public:
-
/**
* If the GL extension is available this function discards specified data in attachments
* from being copied from the target to improve performance.
* @param numAttachments is the count of attachments
* @param attachments is a pointer to the attachments
*/
- void DiscardFrameBuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+ void DiscardFrameBuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments);
/**
* GLES extension
* @param[out] binaryFormat The format of the program binary
* @param[out] binary The actual program bytecode
*/
- void GetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
+ void GetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
/**
* GLES extension
* @param[in] binary The program bytecode
* @param[in] length The number of bytes in binary
*/
- void ProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+ void ProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length);
/**
* KHR extension
* Specify a boundary between passes when using advanced blend equations.
*/
- bool BlendBarrierKHR ();
+ bool BlendBarrierKHR();
private:
-
/**
* Lazy Initialize extensions on first use
*/
#ifdef GL_OES_get_program_binary
PFNGLGETPROGRAMBINARYOESPROC mGlGetProgramBinaryOES;
- PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
+ PFNGLPROGRAMBINARYOESPROC mGlProgramBinaryOES;
#endif
#ifdef GL_KHR_blend_equation_advanced
#endif
bool mInitialized;
-
};
} // namespace Adaptor
#define DALI_INTERNAL_GL_IMPLEMENTATION_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.
*/
// EXTERNAL INCLUDES
-#include <memory>
-#include <cstdlib>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-#include <dali/integration-api/gl-abstraction.h>
#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/integration-api/gl-abstraction.h>
#include <dali/internal/graphics/common/egl-include.h>
+#include <cstdlib>
+#include <memory>
// INTERNAL INCLUDES
#include <dali/internal/graphics/gles/gles-abstraction.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
-const int32_t INITIAL_GLES_VERSION = 30;
+const int32_t INITIAL_GLES_VERSION = 30;
const int32_t GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED = 32;
-const char* KHR_BLEND_EQUATION_ADVANCED = "GL_KHR_blend_equation_advanced";
+const char* KHR_BLEND_EQUATION_ADVANCED = "GL_KHR_blend_equation_advanced";
const char* FRAGMENT_SHADER_ADVANCED_BLEND_EQUATION_PREFIX =
"#extension GL_KHR_blend_equation_advanced : enable\n"
const char* FRAGMENT_SHADER_OUTPUT_COLOR_STRING =
"out mediump vec4 fragColor;\n";
-}
+} // namespace
/**
* GlImplementation is a concrete implementation for GlAbstraction.
*/
class GlImplementation : public Dali::Integration::GlAbstraction
{
-
public:
GlImplementation()
- : mContextCreatedWaitCondition(),
- mMaxTextureSize( 0 ),
- mVertexShaderPrefix(""),
- mGlesVersion( INITIAL_GLES_VERSION ),
- mShadingLanguageVersion( 100 ),
- mShadingLanguageVersionCached( false ),
- mIsSurfacelessContextSupported( false ),
- mIsAdvancedBlendEquationSupportedCached( false ),
- mIsAdvancedBlendEquationSupported( false ),
- mIsContextCreated( false )
+ : mContextCreatedWaitCondition(),
+ mMaxTextureSize(0),
+ mVertexShaderPrefix(""),
+ mGlesVersion(INITIAL_GLES_VERSION),
+ mShadingLanguageVersion(100),
+ mShadingLanguageVersionCached(false),
+ mIsSurfacelessContextSupported(false),
+ mIsAdvancedBlendEquationSupportedCached(false),
+ mIsAdvancedBlendEquationSupported(false),
+ mIsContextCreated(false)
{
- mImpl.reset( new Gles3Implementation() );
+ mImpl.reset(new Gles3Implementation());
}
- virtual ~GlImplementation() {}
+ virtual ~GlImplementation()
+ {
+ }
void PreRender() override
{
void ContextCreated()
{
- glGetIntegerv( GL_MAX_TEXTURE_SIZE, &mMaxTextureSize );
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
GLint majorVersion, minorVersion;
- glGetIntegerv( GL_MAJOR_VERSION, &majorVersion );
- glGetIntegerv( GL_MINOR_VERSION, &minorVersion );
+ glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
+ glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
mGlesVersion = majorVersion * 10 + minorVersion;
- if( mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED )
+ if(mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED)
{
mIsAdvancedBlendEquationSupported = true;
}
else
{
// when mIsAdvancedBlendEquationSupported is cached, we don't need to check all the extensions.
- if( !mIsAdvancedBlendEquationSupportedCached )
+ if(!mIsAdvancedBlendEquationSupportedCached)
{
const char* const extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
std::istringstream stream(extensionStr);
- std::string currentExtension;
+ std::string currentExtension;
while(std::getline(stream, currentExtension, ' '))
{
if(currentExtension == KHR_BLEND_EQUATION_ADVANCED)
if(!mShadingLanguageVersionCached)
{
std::istringstream shadingLanguageVersionStream(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
- std::string token;
- uint32_t tokenCount = 0;
+ std::string token;
+ uint32_t tokenCount = 0;
while(std::getline(shadingLanguageVersionStream, token, ' '))
{
if(tokenCount == 3 && token == "ES")
}
{
- ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
+ ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
mIsContextCreated = true;
- mContextCreatedWaitCondition.Notify( lock );
+ mContextCreatedWaitCondition.Notify(lock);
}
}
- void SetGlesVersion( const int32_t glesVersion )
+ void SetGlesVersion(const int32_t glesVersion)
{
- if( mGlesVersion / 10 != glesVersion / 10 )
+ if(mGlesVersion / 10 != glesVersion / 10)
{
mGlesVersion = glesVersion;
- if( mGlesVersion >= 30 )
+ if(mGlesVersion >= 30)
{
- mImpl.reset( new Gles3Implementation() );
+ mImpl.reset(new Gles3Implementation());
}
else
{
- mImpl.reset( new Gles2Implementation() );
+ mImpl.reset(new Gles2Implementation());
}
}
}
- void SetIsSurfacelessContextSupported( const bool isSupported )
+ void SetIsSurfacelessContextSupported(const bool isSupported)
{
mIsSurfacelessContextSupported = isSupported;
}
bool IsAdvancedBlendEquationSupported()
{
- ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
+ ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
if(!mIsContextCreated && !mIsAdvancedBlendEquationSupportedCached)
{
- mContextCreatedWaitCondition.Wait( lock );
+ mContextCreatedWaitCondition.Wait(lock);
}
return mIsAdvancedBlendEquationSupported;
}
{
if(mShaderVersionPrefix == "")
{
- mShaderVersionPrefix = "#version " + std::to_string( GetShadingLanguageVersion() );
+ mShaderVersionPrefix = "#version " + std::to_string(GetShadingLanguageVersion());
if(GetShadingLanguageVersion() < 300)
{
mShaderVersionPrefix += "\n";
return mFragmentShaderPrefix;
}
- bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const override
+ bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override
{
- bool convert = ( ( imageGlFormat == GL_RGB ) && ( textureGlFormat == GL_RGBA ) );
- if( mGlesVersion >= 30 )
+ bool convert = ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
+ if(mGlesVersion >= 30)
{
// Don't convert manually from RGB to RGBA if GLES >= 3.0 and a sub-image is uploaded.
- convert = ( convert && !isSubImage );
+ convert = (convert && !isSubImage);
}
return convert;
}
int GetMaxTextureSize()
{
- ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
- if( !mIsContextCreated )
+ ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
+ if(!mIsContextCreated)
{
- mContextCreatedWaitCondition.Wait( lock );
+ mContextCreatedWaitCondition.Wait(lock);
}
return mMaxTextureSize;
}
int GetGlesVersion()
{
- ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
- if( !mIsContextCreated )
+ ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
+ if(!mIsContextCreated)
{
- mContextCreatedWaitCondition.Wait( lock );
+ mContextCreatedWaitCondition.Wait(lock);
}
return mGlesVersion;
}
- void SetShadingLanguageVersion( int shadingLanguageVersion )
+ void SetShadingLanguageVersion(int shadingLanguageVersion)
{
- mShadingLanguageVersion = shadingLanguageVersion;
+ mShadingLanguageVersion = shadingLanguageVersion;
mShadingLanguageVersionCached = true;
}
int GetShadingLanguageVersion()
{
- ConditionalWait::ScopedLock lock( mContextCreatedWaitCondition );
- if( !mIsContextCreated && !mShadingLanguageVersionCached )
+ ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
+ if(!mIsContextCreated && !mShadingLanguageVersionCached)
{
- mContextCreatedWaitCondition.Wait( lock );
+ mContextCreatedWaitCondition.Wait(lock);
}
return mShadingLanguageVersion;
}
/* OpenGL ES 2.0 */
- void ActiveTexture( GLenum texture ) override
+ void ActiveTexture(GLenum texture) override
{
- glActiveTexture( texture );
+ glActiveTexture(texture);
}
- void AttachShader( GLuint program, GLuint shader ) override
+ void AttachShader(GLuint program, GLuint shader) override
{
- glAttachShader( program, shader );
+ glAttachShader(program, shader);
}
- void BindAttribLocation( GLuint program, GLuint index, const char* name ) override
+ void BindAttribLocation(GLuint program, GLuint index, const char* name) override
{
- glBindAttribLocation( program, index, name );
+ glBindAttribLocation(program, index, name);
}
- void BindBuffer( GLenum target, GLuint buffer ) override
+ void BindBuffer(GLenum target, GLuint buffer) override
{
- glBindBuffer( target, buffer );
+ glBindBuffer(target, buffer);
}
- void BindFramebuffer( GLenum target, GLuint framebuffer ) override
+ void BindFramebuffer(GLenum target, GLuint framebuffer) override
{
- glBindFramebuffer( target, framebuffer );
+ glBindFramebuffer(target, framebuffer);
}
- void BindRenderbuffer( GLenum target, GLuint renderbuffer ) override
+ void BindRenderbuffer(GLenum target, GLuint renderbuffer) override
{
- glBindRenderbuffer( target, renderbuffer );
+ glBindRenderbuffer(target, renderbuffer);
}
- void BindTexture( GLenum target, GLuint texture ) override
+ void BindTexture(GLenum target, GLuint texture) override
{
- glBindTexture( target, texture );
+ glBindTexture(target, texture);
}
- void BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) override
+ void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
{
- glBlendColor( red, green, blue, alpha );
+ glBlendColor(red, green, blue, alpha);
}
- void BlendEquation( GLenum mode ) override
+ void BlendEquation(GLenum mode) override
{
- glBlendEquation( mode );
+ glBlendEquation(mode);
}
- void BlendEquationSeparate( GLenum modeRGB, GLenum modeAlpha ) override
+ void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) override
{
- glBlendEquationSeparate( modeRGB, modeAlpha );
+ glBlendEquationSeparate(modeRGB, modeAlpha);
}
- void BlendFunc( GLenum sfactor, GLenum dfactor ) override
+ void BlendFunc(GLenum sfactor, GLenum dfactor) override
{
- glBlendFunc( sfactor, dfactor );
+ glBlendFunc(sfactor, dfactor);
}
- void BlendFuncSeparate( GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha ) override
+ void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) override
{
- glBlendFuncSeparate( srcRGB, dstRGB, srcAlpha, dstAlpha );
+ glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
- void BufferData( GLenum target, GLsizeiptr size, const void* data, GLenum usage ) override
+ void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage) override
{
- glBufferData( target, size, data, usage );
+ glBufferData(target, size, data, usage);
}
- void BufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const void* data ) override
+ void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data) override
{
- glBufferSubData( target, offset, size, data );
+ glBufferSubData(target, offset, size, data);
}
- GLenum CheckFramebufferStatus( GLenum target ) override
+ GLenum CheckFramebufferStatus(GLenum target) override
{
- return glCheckFramebufferStatus( target );
+ return glCheckFramebufferStatus(target);
}
- void Clear( GLbitfield mask ) override
+ void Clear(GLbitfield mask) override
{
- glClear( mask );
+ glClear(mask);
}
- void ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) override
+ void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) override
{
- glClearColor( red, green, blue, alpha );
+ glClearColor(red, green, blue, alpha);
}
- void ClearDepthf( GLclampf depth ) override
+ void ClearDepthf(GLclampf depth) override
{
- glClearDepthf( depth );
+ glClearDepthf(depth);
}
- void ClearStencil( GLint s ) override
+ void ClearStencil(GLint s) override
{
- glClearStencil( s );
+ glClearStencil(s);
}
- void ColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) override
+ void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) override
{
- glColorMask( red, green, blue, alpha );
+ glColorMask(red, green, blue, alpha);
}
- void CompileShader( GLuint shader ) override
+ void CompileShader(GLuint shader) override
{
- glCompileShader( shader );
+ glCompileShader(shader);
}
- void CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data ) override
+ void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) override
{
- glCompressedTexImage2D( target, level, internalformat, width, height, border, imageSize, data );
+ glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
}
- void CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data ) override
+ void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) override
{
- glCompressedTexSubImage2D( target, level, xoffset, yoffset, width, height, format, imageSize, data );
+ glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
- void CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ) override
+ void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) override
{
- glCopyTexImage2D( target, level, internalformat, x, y, width, height, border );
+ glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
}
- void CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
+ glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
- GLuint CreateProgram( void ) override
+ GLuint CreateProgram(void) override
{
return glCreateProgram();
}
- GLuint CreateShader( GLenum type ) override
+ GLuint CreateShader(GLenum type) override
{
- return glCreateShader( type );
+ return glCreateShader(type);
}
- void CullFace( GLenum mode ) override
+ void CullFace(GLenum mode) override
{
- glCullFace( mode );
+ glCullFace(mode);
}
- void DeleteBuffers( GLsizei n, const GLuint* buffers ) override
+ void DeleteBuffers(GLsizei n, const GLuint* buffers) override
{
- glDeleteBuffers( n, buffers );
+ glDeleteBuffers(n, buffers);
}
- void DeleteFramebuffers( GLsizei n, const GLuint* framebuffers ) override
+ void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override
{
- glDeleteFramebuffers( n, framebuffers );
+ glDeleteFramebuffers(n, framebuffers);
}
- void DeleteProgram( GLuint program ) override
+ void DeleteProgram(GLuint program) override
{
- glDeleteProgram( program );
+ glDeleteProgram(program);
}
- void DeleteRenderbuffers( GLsizei n, const GLuint* renderbuffers ) override
+ void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) override
{
- glDeleteRenderbuffers( n, renderbuffers );
+ glDeleteRenderbuffers(n, renderbuffers);
}
- void DeleteShader( GLuint shader ) override
+ void DeleteShader(GLuint shader) override
{
- glDeleteShader( shader );
+ glDeleteShader(shader);
}
- void DeleteTextures( GLsizei n, const GLuint* textures ) override
+ void DeleteTextures(GLsizei n, const GLuint* textures) override
{
- glDeleteTextures( n, textures );
+ glDeleteTextures(n, textures);
}
- void DepthFunc( GLenum func ) override
+ void DepthFunc(GLenum func) override
{
- glDepthFunc( func );
+ glDepthFunc(func);
}
- void DepthMask( GLboolean flag ) override
+ void DepthMask(GLboolean flag) override
{
- glDepthMask( flag );
+ glDepthMask(flag);
}
- void DepthRangef( GLclampf zNear, GLclampf zFar ) override
+ void DepthRangef(GLclampf zNear, GLclampf zFar) override
{
- glDepthRangef( zNear, zFar );
+ glDepthRangef(zNear, zFar);
}
- void DetachShader( GLuint program, GLuint shader ) override
+ void DetachShader(GLuint program, GLuint shader) override
{
- glDetachShader( program, shader );
+ glDetachShader(program, shader);
}
- void Disable( GLenum cap ) override
+ void Disable(GLenum cap) override
{
- glDisable( cap );
+ glDisable(cap);
}
- void DisableVertexAttribArray( GLuint index ) override
+ void DisableVertexAttribArray(GLuint index) override
{
- glDisableVertexAttribArray( index );
+ glDisableVertexAttribArray(index);
}
- void DrawArrays( GLenum mode, GLint first, GLsizei count ) override
+ void DrawArrays(GLenum mode, GLint first, GLsizei count) override
{
- glDrawArrays( mode, first, count );
+ glDrawArrays(mode, first, count);
}
- void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices ) override
+ void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) override
{
- glDrawElements( mode, count, type, indices );
+ glDrawElements(mode, count, type, indices);
}
- void Enable( GLenum cap ) override
+ void Enable(GLenum cap) override
{
- glEnable( cap );
+ glEnable(cap);
}
- void EnableVertexAttribArray( GLuint index ) override
+ void EnableVertexAttribArray(GLuint index) override
{
- glEnableVertexAttribArray( index );
+ glEnableVertexAttribArray(index);
}
- void Finish( void ) override
+ void Finish(void) override
{
glFinish();
}
- void Flush( void ) override
+ void Flush(void) override
{
glFlush();
}
- void FramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer ) override
+ void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) override
{
- glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
+ glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
}
- void FramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level ) override
+ void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) override
{
- glFramebufferTexture2D( target, attachment, textarget, texture, level );
+ glFramebufferTexture2D(target, attachment, textarget, texture, level);
}
- void FrontFace( GLenum mode ) override
+ void FrontFace(GLenum mode) override
{
- glFrontFace( mode );
+ glFrontFace(mode);
}
- void GenBuffers( GLsizei n, GLuint* buffers ) override
+ void GenBuffers(GLsizei n, GLuint* buffers) override
{
- glGenBuffers( n, buffers );
+ glGenBuffers(n, buffers);
}
- void GenerateMipmap( GLenum target ) override
+ void GenerateMipmap(GLenum target) override
{
- glGenerateMipmap( target );
+ glGenerateMipmap(target);
}
- void GenFramebuffers( GLsizei n, GLuint* framebuffers ) override
+ void GenFramebuffers(GLsizei n, GLuint* framebuffers) override
{
- glGenFramebuffers( n, framebuffers );
+ glGenFramebuffers(n, framebuffers);
}
- void GenRenderbuffers( GLsizei n, GLuint* renderbuffers ) override
+ void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override
{
- glGenRenderbuffers( n, renderbuffers );
+ glGenRenderbuffers(n, renderbuffers);
}
- void GenTextures( GLsizei n, GLuint* textures ) override
+ void GenTextures(GLsizei n, GLuint* textures) override
{
- glGenTextures( n, textures );
+ glGenTextures(n, textures);
}
- void GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name ) override
+ void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
{
- glGetActiveAttrib( program, index, bufsize, length, size, type, name );
+ glGetActiveAttrib(program, index, bufsize, length, size, type, name);
}
- void GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name ) override
+ void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
{
- glGetActiveUniform( program, index, bufsize, length, size, type, name );
+ glGetActiveUniform(program, index, bufsize, length, size, type, name);
}
- void GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders ) override
+ void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) override
{
- glGetAttachedShaders( program, maxcount, count, shaders );
+ glGetAttachedShaders(program, maxcount, count, shaders);
}
- int GetAttribLocation( GLuint program, const char* name ) override
+ int GetAttribLocation(GLuint program, const char* name) override
{
- return glGetAttribLocation( program, name );
+ return glGetAttribLocation(program, name);
}
- void GetBooleanv( GLenum pname, GLboolean* params ) override
+ void GetBooleanv(GLenum pname, GLboolean* params) override
{
- glGetBooleanv( pname, params );
+ glGetBooleanv(pname, params);
}
- void GetBufferParameteriv( GLenum target, GLenum pname, GLint* params ) override
+ void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) override
{
- glGetBufferParameteriv( target, pname, params );
+ glGetBufferParameteriv(target, pname, params);
}
- GLenum GetError( void ) override
+ GLenum GetError(void) override
{
return glGetError();
}
- void GetFloatv( GLenum pname, GLfloat* params ) override
+ void GetFloatv(GLenum pname, GLfloat* params) override
{
- glGetFloatv( pname, params );
+ glGetFloatv(pname, params);
}
- void GetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params ) override
+ void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) override
{
- glGetFramebufferAttachmentParameteriv( target, attachment, pname, params );
+ glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
}
- void GetIntegerv( GLenum pname, GLint* params ) override
+ void GetIntegerv(GLenum pname, GLint* params) override
{
- glGetIntegerv( pname, params );
+ glGetIntegerv(pname, params);
}
- void GetProgramiv( GLuint program, GLenum pname, GLint* params ) override
+ void GetProgramiv(GLuint program, GLenum pname, GLint* params) override
{
- glGetProgramiv( program, pname, params );
+ glGetProgramiv(program, pname, params);
}
- void GetProgramInfoLog( GLuint program, GLsizei bufsize, GLsizei* length, char* infolog ) override
+ void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) override
{
- glGetProgramInfoLog( program, bufsize, length, infolog );
+ glGetProgramInfoLog(program, bufsize, length, infolog);
}
- void GetRenderbufferParameteriv( GLenum target, GLenum pname, GLint* params ) override
+ void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) override
{
- glGetRenderbufferParameteriv( target, pname, params );
+ glGetRenderbufferParameteriv(target, pname, params);
}
- void GetShaderiv( GLuint shader, GLenum pname, GLint* params ) override
+ void GetShaderiv(GLuint shader, GLenum pname, GLint* params) override
{
- glGetShaderiv( shader, pname, params );
+ glGetShaderiv(shader, pname, params);
}
- void GetShaderInfoLog( GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog ) override
+ void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) override
{
- glGetShaderInfoLog( shader, bufsize, length, infolog );
+ glGetShaderInfoLog(shader, bufsize, length, infolog);
}
- void GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision ) override
+ void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) override
{
- glGetShaderPrecisionFormat( shadertype, precisiontype, range, precision );
+ glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
}
- void GetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* source ) override
+ void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) override
{
- glGetShaderSource( shader, bufsize, length, source );
+ glGetShaderSource(shader, bufsize, length, source);
}
- const GLubyte* GetString( GLenum name ) override
+ const GLubyte* GetString(GLenum name) override
{
- return glGetString( name );
+ return glGetString(name);
}
- void GetTexParameterfv( GLenum target, GLenum pname, GLfloat* params ) override
+ void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) override
{
- glGetTexParameterfv( target, pname, params );
+ glGetTexParameterfv(target, pname, params);
}
- void GetTexParameteriv( GLenum target, GLenum pname, GLint* params ) override
+ void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) override
{
- glGetTexParameteriv( target, pname, params );
+ glGetTexParameteriv(target, pname, params);
}
- void GetUniformfv( GLuint program, GLint location, GLfloat* params ) override
+ void GetUniformfv(GLuint program, GLint location, GLfloat* params) override
{
- glGetUniformfv( program, location, params );
+ glGetUniformfv(program, location, params);
}
- void GetUniformiv( GLuint program, GLint location, GLint* params ) override
+ void GetUniformiv(GLuint program, GLint location, GLint* params) override
{
- glGetUniformiv( program, location, params );
+ glGetUniformiv(program, location, params);
}
- int GetUniformLocation( GLuint program, const char* name ) override
+ int GetUniformLocation(GLuint program, const char* name) override
{
- return glGetUniformLocation( program, name );
+ return glGetUniformLocation(program, name);
}
- void GetVertexAttribfv( GLuint index, GLenum pname, GLfloat* params ) override
+ void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) override
{
- glGetVertexAttribfv( index, pname, params );
+ glGetVertexAttribfv(index, pname, params);
}
- void GetVertexAttribiv( GLuint index, GLenum pname, GLint* params ) override
+ void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) override
{
- glGetVertexAttribiv( index, pname, params );
+ glGetVertexAttribiv(index, pname, params);
}
- void GetVertexAttribPointerv( GLuint index, GLenum pname, void** pointer ) override
+ void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) override
{
- glGetVertexAttribPointerv( index, pname, pointer );
+ glGetVertexAttribPointerv(index, pname, pointer);
}
- void Hint( GLenum target, GLenum mode ) override
+ void Hint(GLenum target, GLenum mode) override
{
- glHint( target, mode );
+ glHint(target, mode);
}
- GLboolean IsBuffer( GLuint buffer ) override
+ GLboolean IsBuffer(GLuint buffer) override
{
- return glIsBuffer( buffer );
+ return glIsBuffer(buffer);
}
- GLboolean IsEnabled( GLenum cap ) override
+ GLboolean IsEnabled(GLenum cap) override
{
- return glIsEnabled( cap );
+ return glIsEnabled(cap);
}
- GLboolean IsFramebuffer( GLuint framebuffer ) override
+ GLboolean IsFramebuffer(GLuint framebuffer) override
{
- return glIsFramebuffer( framebuffer );
+ return glIsFramebuffer(framebuffer);
}
- GLboolean IsProgram( GLuint program ) override
+ GLboolean IsProgram(GLuint program) override
{
- return glIsProgram( program );
+ return glIsProgram(program);
}
- GLboolean IsRenderbuffer( GLuint renderbuffer ) override
+ GLboolean IsRenderbuffer(GLuint renderbuffer) override
{
- return glIsRenderbuffer( renderbuffer );
+ return glIsRenderbuffer(renderbuffer);
}
- GLboolean IsShader( GLuint shader ) override
+ GLboolean IsShader(GLuint shader) override
{
- return glIsShader( shader );
+ return glIsShader(shader);
}
- GLboolean IsTexture( GLuint texture ) override
+ GLboolean IsTexture(GLuint texture) override
{
- return glIsTexture( texture );
+ return glIsTexture(texture);
}
- void LineWidth( GLfloat width ) override
+ void LineWidth(GLfloat width) override
{
- glLineWidth( width );
+ glLineWidth(width);
}
- void LinkProgram( GLuint program ) override
+ void LinkProgram(GLuint program) override
{
- glLinkProgram( program );
+ glLinkProgram(program);
}
- void PixelStorei( GLenum pname, GLint param ) override
+ void PixelStorei(GLenum pname, GLint param) override
{
- glPixelStorei( pname, param );
+ glPixelStorei(pname, param);
}
- void PolygonOffset( GLfloat factor, GLfloat units ) override
+ void PolygonOffset(GLfloat factor, GLfloat units) override
{
- glPolygonOffset( factor, units );
+ glPolygonOffset(factor, units);
}
- void ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels ) override
+ void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) override
{
- glReadPixels( x, y, width, height, format, type, pixels );
+ glReadPixels(x, y, width, height, format, type, pixels);
}
- void ReleaseShaderCompiler( void ) override
+ void ReleaseShaderCompiler(void) override
{
glReleaseShaderCompiler();
}
- void RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) override
{
- glRenderbufferStorage( target, internalformat, width, height );
+ glRenderbufferStorage(target, internalformat, width, height);
}
- void SampleCoverage( GLclampf value, GLboolean invert ) override
+ void SampleCoverage(GLclampf value, GLboolean invert) override
{
- glSampleCoverage( value, invert );
+ glSampleCoverage(value, invert);
}
- void Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) override
{
- glScissor( x, y, width, height );
+ glScissor(x, y, width, height);
}
- void ShaderBinary( GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length ) override
+ void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) override
{
- glShaderBinary( n, shaders, binaryformat, binary, length );
+ glShaderBinary(n, shaders, binaryformat, binary, length);
}
- void ShaderSource( GLuint shader, GLsizei count, const char** string, const GLint* length ) override
+ void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) override
{
- glShaderSource( shader, count, string, length );
+ glShaderSource(shader, count, string, length);
}
- void StencilFunc( GLenum func, GLint ref, GLuint mask ) override
+ void StencilFunc(GLenum func, GLint ref, GLuint mask) override
{
- glStencilFunc( func, ref, mask );
+ glStencilFunc(func, ref, mask);
}
- void StencilFuncSeparate( GLenum face, GLenum func, GLint ref, GLuint mask ) override
+ void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) override
{
- glStencilFuncSeparate( face, func, ref, mask );
+ glStencilFuncSeparate(face, func, ref, mask);
}
- void StencilMask( GLuint mask ) override
+ void StencilMask(GLuint mask) override
{
- glStencilMask( mask );
+ glStencilMask(mask);
}
- void StencilMaskSeparate( GLenum face, GLuint mask ) override
+ void StencilMaskSeparate(GLenum face, GLuint mask) override
{
- glStencilMaskSeparate( face, mask );
+ glStencilMaskSeparate(face, mask);
}
- void StencilOp( GLenum fail, GLenum zfail, GLenum zpass ) override
+ void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) override
{
- glStencilOp( fail, zfail, zpass );
+ glStencilOp(fail, zfail, zpass);
}
- void StencilOpSeparate( GLenum face, GLenum fail, GLenum zfail, GLenum zpass ) override
+ void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) override
{
- glStencilOpSeparate( face, fail, zfail, zpass );
+ glStencilOpSeparate(face, fail, zfail, zpass);
}
- void TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels ) override
+ void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) override
{
- glTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
+ glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
}
- void TexParameterf( GLenum target, GLenum pname, GLfloat param ) override
+ void TexParameterf(GLenum target, GLenum pname, GLfloat param) override
{
- glTexParameterf( target, pname, param );
+ glTexParameterf(target, pname, param);
}
- void TexParameterfv( GLenum target, GLenum pname, const GLfloat* params ) override
+ void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) override
{
- glTexParameterfv( target, pname, params );
+ glTexParameterfv(target, pname, params);
}
- void TexParameteri( GLenum target, GLenum pname, GLint param ) override
+ void TexParameteri(GLenum target, GLenum pname, GLint param) override
{
- glTexParameteri( target, pname, param );
+ glTexParameteri(target, pname, param);
}
- void TexParameteriv( GLenum target, GLenum pname, const GLint* params ) override
+ void TexParameteriv(GLenum target, GLenum pname, const GLint* params) override
{
- glTexParameteriv( target, pname, params );
+ glTexParameteriv(target, pname, params);
}
- void TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels ) override
+ void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) override
{
- glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
+ glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
}
- void Uniform1f( GLint location, GLfloat x ) override
+ void Uniform1f(GLint location, GLfloat x) override
{
- glUniform1f( location, x );
+ glUniform1f(location, x);
}
- void Uniform1fv( GLint location, GLsizei count, const GLfloat* v ) override
+ void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override
{
- glUniform1fv( location, count, v );
+ glUniform1fv(location, count, v);
}
- void Uniform1i( GLint location, GLint x ) override
+ void Uniform1i(GLint location, GLint x) override
{
- glUniform1i( location, x );
+ glUniform1i(location, x);
}
- void Uniform1iv( GLint location, GLsizei count, const GLint* v ) override
+ void Uniform1iv(GLint location, GLsizei count, const GLint* v) override
{
- glUniform1iv( location, count, v );
+ glUniform1iv(location, count, v);
}
- void Uniform2f( GLint location, GLfloat x, GLfloat y ) override
+ void Uniform2f(GLint location, GLfloat x, GLfloat y) override
{
- glUniform2f( location, x, y );
+ glUniform2f(location, x, y);
}
- void Uniform2fv( GLint location, GLsizei count, const GLfloat* v ) override
+ void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override
{
- glUniform2fv( location, count, v );
+ glUniform2fv(location, count, v);
}
- void Uniform2i( GLint location, GLint x, GLint y ) override
+ void Uniform2i(GLint location, GLint x, GLint y) override
{
- glUniform2i( location, x, y );
+ glUniform2i(location, x, y);
}
- void Uniform2iv( GLint location, GLsizei count, const GLint* v ) override
+ void Uniform2iv(GLint location, GLsizei count, const GLint* v) override
{
- glUniform2iv( location, count, v );
+ glUniform2iv(location, count, v);
}
- void Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z ) override
+ void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override
{
- glUniform3f( location, x, y, z );
+ glUniform3f(location, x, y, z);
}
- void Uniform3fv( GLint location, GLsizei count, const GLfloat* v ) override
+ void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override
{
- glUniform3fv( location, count, v );
+ glUniform3fv(location, count, v);
}
- void Uniform3i( GLint location, GLint x, GLint y, GLint z ) override
+ void Uniform3i(GLint location, GLint x, GLint y, GLint z) override
{
- glUniform3i( location, x, y, z );
+ glUniform3i(location, x, y, z);
}
- void Uniform3iv( GLint location, GLsizei count, const GLint* v ) override
+ void Uniform3iv(GLint location, GLsizei count, const GLint* v) override
{
- glUniform3iv( location, count, v );
+ glUniform3iv(location, count, v);
}
- void Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override
+ void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
{
- glUniform4f( location, x, y, z, w );
+ glUniform4f(location, x, y, z, w);
}
- void Uniform4fv( GLint location, GLsizei count, const GLfloat* v ) override
+ void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override
{
- glUniform4fv( location, count, v );
+ glUniform4fv(location, count, v);
}
- void Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w ) override
+ void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override
{
- glUniform4i( location, x, y, z, w );
+ glUniform4i(location, x, y, z, w);
}
- void Uniform4iv( GLint location, GLsizei count, const GLint* v ) override
+ void Uniform4iv(GLint location, GLsizei count, const GLint* v) override
{
- glUniform4iv( location, count, v );
+ glUniform4iv(location, count, v);
}
- void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix2fv( location, count, transpose, value );
+ glUniformMatrix2fv(location, count, transpose, value);
}
- void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix3fv( location, count, transpose, value );
+ glUniformMatrix3fv(location, count, transpose, value);
}
- void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix4fv( location, count, transpose, value );
+ glUniformMatrix4fv(location, count, transpose, value);
}
- void UseProgram( GLuint program ) override
+ void UseProgram(GLuint program) override
{
- glUseProgram( program );
+ glUseProgram(program);
}
- void ValidateProgram( GLuint program ) override
+ void ValidateProgram(GLuint program) override
{
- glValidateProgram( program );
+ glValidateProgram(program);
}
- void VertexAttrib1f( GLuint indx, GLfloat x ) override
+ void VertexAttrib1f(GLuint indx, GLfloat x) override
{
- glVertexAttrib1f( indx, x );
+ glVertexAttrib1f(indx, x);
}
- void VertexAttrib1fv( GLuint indx, const GLfloat* values ) override
+ void VertexAttrib1fv(GLuint indx, const GLfloat* values) override
{
- glVertexAttrib1fv( indx, values );
+ glVertexAttrib1fv(indx, values);
}
- void VertexAttrib2f( GLuint indx, GLfloat x, GLfloat y ) override
+ void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) override
{
- glVertexAttrib2f( indx, x, y );
+ glVertexAttrib2f(indx, x, y);
}
- void VertexAttrib2fv( GLuint indx, const GLfloat* values ) override
+ void VertexAttrib2fv(GLuint indx, const GLfloat* values) override
{
- glVertexAttrib2fv( indx, values );
+ glVertexAttrib2fv(indx, values);
}
- void VertexAttrib3f( GLuint indx, GLfloat x, GLfloat y, GLfloat z ) override
+ void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) override
{
- glVertexAttrib3f( indx, x, y, z );
+ glVertexAttrib3f(indx, x, y, z);
}
- void VertexAttrib3fv( GLuint indx, const GLfloat* values ) override
+ void VertexAttrib3fv(GLuint indx, const GLfloat* values) override
{
- glVertexAttrib3fv( indx, values );
+ glVertexAttrib3fv(indx, values);
}
- void VertexAttrib4f( GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override
+ void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override
{
- glVertexAttrib4f( indx, x, y, z, w );
+ glVertexAttrib4f(indx, x, y, z, w);
}
- void VertexAttrib4fv( GLuint indx, const GLfloat* values ) override
+ void VertexAttrib4fv(GLuint indx, const GLfloat* values) override
{
- glVertexAttrib4fv( indx, values );
+ glVertexAttrib4fv(indx, values);
}
- void VertexAttribPointer( GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr ) override
+ void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override
{
- glVertexAttribPointer( indx, size, type, normalized, stride, ptr );
+ glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
- void Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override
{
- glViewport( x, y, width, height );
+ glViewport(x, y, width, height);
}
/* OpenGL ES 3.0 */
- void ReadBuffer( GLenum mode ) override
+ void ReadBuffer(GLenum mode) override
{
- mImpl->ReadBuffer( mode );
+ mImpl->ReadBuffer(mode);
}
- void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices ) override
+ void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
{
- mImpl->DrawRangeElements( mode, start, end, count, type, indices );
+ mImpl->DrawRangeElements(mode, start, end, count, type, indices);
}
- void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels ) override
+ void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
{
- mImpl->TexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels );
+ mImpl->TexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
}
- void TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels ) override
+ void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) override
{
- mImpl->TexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels );
+ mImpl->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
}
- void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- mImpl->CopyTexSubImage3D( target, level, xoffset, yoffset, zoffset, x, y, width, height );
+ mImpl->CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
}
- void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data ) override
+ void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
{
- mImpl->CompressedTexImage3D( target, level, internalformat, width, height, depth, border, imageSize, data );
+ mImpl->CompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
}
- void CompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data ) override
+ void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) override
{
- mImpl->CompressedTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data );
+ mImpl->CompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
}
- void GenQueries( GLsizei n, GLuint* ids ) override
+ void GenQueries(GLsizei n, GLuint* ids) override
{
- mImpl->GenQueries( n, ids );
+ mImpl->GenQueries(n, ids);
}
- void DeleteQueries( GLsizei n, const GLuint* ids ) override
+ void DeleteQueries(GLsizei n, const GLuint* ids) override
{
- mImpl->DeleteQueries( n, ids );
+ mImpl->DeleteQueries(n, ids);
}
- GLboolean IsQuery( GLuint id ) override
+ GLboolean IsQuery(GLuint id) override
{
- return mImpl->IsQuery( id );
+ return mImpl->IsQuery(id);
}
- void BeginQuery( GLenum target, GLuint id ) override
+ void BeginQuery(GLenum target, GLuint id) override
{
- mImpl->BeginQuery( target, id );
+ mImpl->BeginQuery(target, id);
}
- void EndQuery( GLenum target ) override
+ void EndQuery(GLenum target) override
{
- mImpl->EndQuery( target );
+ mImpl->EndQuery(target);
}
- void GetQueryiv( GLenum target, GLenum pname, GLint* params ) override
+ void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
{
- mImpl->GetQueryiv( target, pname, params );
+ mImpl->GetQueryiv(target, pname, params);
}
- void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params ) override
+ void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
{
- mImpl->GetQueryObjectuiv( id, pname, params );
+ mImpl->GetQueryObjectuiv(id, pname, params);
}
- GLboolean UnmapBuffer( GLenum target ) override
+ GLboolean UnmapBuffer(GLenum target) override
{
- return mImpl->UnmapBuffer( target );
+ return mImpl->UnmapBuffer(target);
}
- void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params ) override
+ void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
{
- mImpl->GetBufferPointerv( target, pname, params );
+ mImpl->GetBufferPointerv(target, pname, params);
}
- void DrawBuffers( GLsizei n, const GLenum* bufs ) override
+ void DrawBuffers(GLsizei n, const GLenum* bufs) override
{
- mImpl->DrawBuffers( n, bufs );
+ mImpl->DrawBuffers(n, bufs);
}
- void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- mImpl->UniformMatrix2x3fv( location, count, transpose, value );
+ mImpl->UniformMatrix2x3fv(location, count, transpose, value);
}
- void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- mImpl->UniformMatrix3x2fv( location, count, transpose, value );
+ mImpl->UniformMatrix3x2fv(location, count, transpose, value);
}
- void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- mImpl->UniformMatrix2x4fv( location, count, transpose, value );
+ mImpl->UniformMatrix2x4fv(location, count, transpose, value);
}
- void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- mImpl->UniformMatrix4x2fv( location, count, transpose, value );
+ mImpl->UniformMatrix4x2fv(location, count, transpose, value);
}
- void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- mImpl->UniformMatrix3x4fv( location, count, transpose, value );
+ mImpl->UniformMatrix3x4fv(location, count, transpose, value);
}
- void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- mImpl->UniformMatrix4x3fv( location, count, transpose, value );
+ mImpl->UniformMatrix4x3fv(location, count, transpose, value);
}
- void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter ) override
+ void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
{
- mImpl->BlitFramebuffer( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter );
+ mImpl->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
- void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
{
- mImpl->RenderbufferStorageMultisample( target, samples, internalformat, width, height );
+ mImpl->RenderbufferStorageMultisample(target, samples, internalformat, width, height);
}
- void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) override
+ void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
{
- mImpl->FramebufferTextureLayer( target, attachment, texture, level, layer );
+ mImpl->FramebufferTextureLayer(target, attachment, texture, level, layer);
}
- GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access ) override
+ GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
{
- return mImpl->MapBufferRange( target, offset, length, access );
+ return mImpl->MapBufferRange(target, offset, length, access);
}
- void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length ) override
+ void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
{
- mImpl->FlushMappedBufferRange( target, offset, length );
+ mImpl->FlushMappedBufferRange(target, offset, length);
}
- void BindVertexArray( GLuint array ) override
+ void BindVertexArray(GLuint array) override
{
- mImpl->BindVertexArray( array );
+ mImpl->BindVertexArray(array);
}
- void DeleteVertexArrays( GLsizei n, const GLuint* arrays ) override
+ void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
{
- mImpl->DeleteVertexArrays( n, arrays );
+ mImpl->DeleteVertexArrays(n, arrays);
}
- void GenVertexArrays( GLsizei n, GLuint* arrays ) override
+ void GenVertexArrays(GLsizei n, GLuint* arrays) override
{
- mImpl->GenVertexArrays( n, arrays );
+ mImpl->GenVertexArrays(n, arrays);
}
- GLboolean IsVertexArray( GLuint array ) override
+ GLboolean IsVertexArray(GLuint array) override
{
- return mImpl->IsVertexArray( array );
+ return mImpl->IsVertexArray(array);
}
- void GetIntegeri_v( GLenum target, GLuint index, GLint* data ) override
+ void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
{
- mImpl->GetIntegeri_v( target, index, data );
+ mImpl->GetIntegeri_v(target, index, data);
}
- void BeginTransformFeedback( GLenum primitiveMode ) override
+ void BeginTransformFeedback(GLenum primitiveMode) override
{
- mImpl->BeginTransformFeedback( primitiveMode );
+ mImpl->BeginTransformFeedback(primitiveMode);
}
- void EndTransformFeedback( void ) override
+ void EndTransformFeedback(void) override
{
mImpl->EndTransformFeedback();
}
- void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size ) override
+ void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
{
- mImpl->BindBufferRange( target, index, buffer, offset, size );
+ mImpl->BindBufferRange(target, index, buffer, offset, size);
}
- void BindBufferBase( GLenum target, GLuint index, GLuint buffer ) override
+ void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
{
- mImpl->BindBufferBase( target, index, buffer );
+ mImpl->BindBufferBase(target, index, buffer);
}
- void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode ) override
+ void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
{
- mImpl->TransformFeedbackVaryings( program, count, varyings, bufferMode );
+ mImpl->TransformFeedbackVaryings(program, count, varyings, bufferMode);
}
- void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name ) override
+ void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
{
- mImpl->GetTransformFeedbackVarying( program, index, bufSize, length, size, type, name );
+ mImpl->GetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
}
- void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) override
+ void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
{
- mImpl->VertexAttribIPointer( index, size, type, stride, pointer );
+ mImpl->VertexAttribIPointer(index, size, type, stride, pointer);
}
- void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params ) override
+ void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
{
- mImpl->GetVertexAttribIiv( index, pname, params );
+ mImpl->GetVertexAttribIiv(index, pname, params);
}
- void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params ) override
+ void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
{
- mImpl->GetVertexAttribIuiv( index, pname, params );
+ mImpl->GetVertexAttribIuiv(index, pname, params);
}
- void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w ) override
+ void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
{
- mImpl->VertexAttribI4i( index, x, y, z, w );
+ mImpl->VertexAttribI4i(index, x, y, z, w);
}
- void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w ) override
+ void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
{
- mImpl->VertexAttribI4ui( index, x, y, z, w );
+ mImpl->VertexAttribI4ui(index, x, y, z, w);
}
- void VertexAttribI4iv( GLuint index, const GLint* v ) override
+ void VertexAttribI4iv(GLuint index, const GLint* v) override
{
- mImpl->VertexAttribI4iv( index, v );
+ mImpl->VertexAttribI4iv(index, v);
}
- void VertexAttribI4uiv( GLuint index, const GLuint* v ) override
+ void VertexAttribI4uiv(GLuint index, const GLuint* v) override
{
- mImpl->VertexAttribI4uiv( index, v );
+ mImpl->VertexAttribI4uiv(index, v);
}
- void GetUniformuiv( GLuint program, GLint location, GLuint* params ) override
+ void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
{
- mImpl->GetUniformuiv( program, location, params );
+ mImpl->GetUniformuiv(program, location, params);
}
- GLint GetFragDataLocation( GLuint program, const GLchar *name ) override
+ GLint GetFragDataLocation(GLuint program, const GLchar* name) override
{
- return mImpl->GetFragDataLocation( program, name );
+ return mImpl->GetFragDataLocation(program, name);
}
- void Uniform1ui( GLint location, GLuint v0 ) override
+ void Uniform1ui(GLint location, GLuint v0) override
{
- mImpl->Uniform1ui( location, v0 );
+ mImpl->Uniform1ui(location, v0);
}
- void Uniform2ui( GLint location, GLuint v0, GLuint v1 ) override
+ void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
{
- mImpl->Uniform2ui( location, v0, v1 );
+ mImpl->Uniform2ui(location, v0, v1);
}
- void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) override
+ void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
{
- mImpl->Uniform3ui( location, v0, v1, v2 );
+ mImpl->Uniform3ui(location, v0, v1, v2);
}
- void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) override
+ void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
{
- mImpl->Uniform4ui( location, v0, v1, v2, v3 );
+ mImpl->Uniform4ui(location, v0, v1, v2, v3);
}
- void Uniform1uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
{
- mImpl->Uniform1uiv( location, count, value );
+ mImpl->Uniform1uiv(location, count, value);
}
- void Uniform2uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
{
- mImpl->Uniform2uiv( location, count, value );
+ mImpl->Uniform2uiv(location, count, value);
}
- void Uniform3uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
{
- mImpl->Uniform3uiv( location, count, value );
+ mImpl->Uniform3uiv(location, count, value);
}
- void Uniform4uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
{
- mImpl->Uniform4uiv( location, count, value );
+ mImpl->Uniform4uiv(location, count, value);
}
- void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value ) override
+ void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
{
- mImpl->ClearBufferiv( buffer, drawbuffer, value );
+ mImpl->ClearBufferiv(buffer, drawbuffer, value);
}
- void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value ) override
+ void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
{
- mImpl->ClearBufferuiv( buffer, drawbuffer, value );
+ mImpl->ClearBufferuiv(buffer, drawbuffer, value);
}
- void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value ) override
+ void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
{
- mImpl->ClearBufferfv( buffer, drawbuffer, value );
+ mImpl->ClearBufferfv(buffer, drawbuffer, value);
}
- void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil ) override
+ void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
{
- mImpl->ClearBufferfi( buffer, drawbuffer, depth, stencil );
+ mImpl->ClearBufferfi(buffer, drawbuffer, depth, stencil);
}
- const GLubyte* GetStringi( GLenum name, GLuint index ) override
+ const GLubyte* GetStringi(GLenum name, GLuint index) override
{
- return mImpl->GetStringi( name, index );
+ return mImpl->GetStringi(name, index);
}
- void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size ) override
+ void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
{
- mImpl->CopyBufferSubData( readTarget, writeTarget, readOffset, writeOffset, size );
+ mImpl->CopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
- void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices ) override
+ void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
{
- mImpl->GetUniformIndices( program, uniformCount, uniformNames, uniformIndices );
+ mImpl->GetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
}
- void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params ) override
+ void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
{
- mImpl->GetActiveUniformsiv( program, uniformCount, uniformIndices, pname, params );
+ mImpl->GetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
}
- GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName ) override
+ GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
{
- return mImpl->GetUniformBlockIndex( program, uniformBlockName );
+ return mImpl->GetUniformBlockIndex(program, uniformBlockName);
}
- void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) override
+ void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
{
- mImpl->GetActiveUniformBlockiv( program, uniformBlockIndex, pname, params );
+ mImpl->GetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
}
- void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName ) override
+ void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
{
- mImpl->GetActiveUniformBlockName( program, uniformBlockIndex, bufSize, length, uniformBlockName );
+ mImpl->GetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
}
- void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) override
+ void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
{
- mImpl->UniformBlockBinding( program, uniformBlockIndex, uniformBlockBinding );
+ mImpl->UniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
}
- void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount ) override
+ void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
{
- mImpl->DrawArraysInstanced( mode, first, count, instanceCount );
+ mImpl->DrawArraysInstanced(mode, first, count, instanceCount);
}
- void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount ) override
+ void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
{
- mImpl->DrawElementsInstanced( mode, count, type, indices, instanceCount );
+ mImpl->DrawElementsInstanced(mode, count, type, indices, instanceCount);
}
- GLsync FenceSync( GLenum condition, GLbitfield flags ) override
+ GLsync FenceSync(GLenum condition, GLbitfield flags) override
{
- return mImpl->FenceSync( condition, flags );
+ return mImpl->FenceSync(condition, flags);
}
- GLboolean IsSync( GLsync sync ) override
+ GLboolean IsSync(GLsync sync) override
{
- return mImpl->IsSync( sync );
+ return mImpl->IsSync(sync);
}
- void DeleteSync( GLsync sync ) override
+ void DeleteSync(GLsync sync) override
{
- mImpl->DeleteSync( sync );
+ mImpl->DeleteSync(sync);
}
- GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
+ GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
{
- return mImpl->ClientWaitSync( sync, flags, timeout );
+ return mImpl->ClientWaitSync(sync, flags, timeout);
}
- void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
+ void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
{
- mImpl->WaitSync( sync, flags, timeout );
+ mImpl->WaitSync(sync, flags, timeout);
}
- void GetInteger64v( GLenum pname, GLint64* params ) override
+ void GetInteger64v(GLenum pname, GLint64* params) override
{
- mImpl->GetInteger64v( pname, params );
+ mImpl->GetInteger64v(pname, params);
}
- void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) override
+ void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
{
- mImpl->GetSynciv( sync, pname, bufSize, length, values );
+ mImpl->GetSynciv(sync, pname, bufSize, length, values);
}
- void GetInteger64i_v( GLenum target, GLuint index, GLint64* data ) override
+ void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
{
- mImpl->GetInteger64i_v( target, index, data );
+ mImpl->GetInteger64i_v(target, index, data);
}
- void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params ) override
+ void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
{
- mImpl->GetBufferParameteri64v( target, pname, params );
+ mImpl->GetBufferParameteri64v(target, pname, params);
}
- void GenSamplers( GLsizei count, GLuint* samplers ) override
+ void GenSamplers(GLsizei count, GLuint* samplers) override
{
- mImpl->GenSamplers( count, samplers );
+ mImpl->GenSamplers(count, samplers);
}
- void DeleteSamplers( GLsizei count, const GLuint* samplers ) override
+ void DeleteSamplers(GLsizei count, const GLuint* samplers) override
{
- mImpl->DeleteSamplers( count, samplers );
+ mImpl->DeleteSamplers(count, samplers);
}
- GLboolean IsSampler( GLuint sampler ) override
+ GLboolean IsSampler(GLuint sampler) override
{
- return mImpl->IsSampler( sampler );
+ return mImpl->IsSampler(sampler);
}
- void BindSampler( GLuint unit, GLuint sampler ) override
+ void BindSampler(GLuint unit, GLuint sampler) override
{
- mImpl->BindSampler( unit, sampler );
+ mImpl->BindSampler(unit, sampler);
}
- void SamplerParameteri( GLuint sampler, GLenum pname, GLint param ) override
+ void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
{
- mImpl->SamplerParameteri( sampler, pname, param );
+ mImpl->SamplerParameteri(sampler, pname, param);
}
- void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param ) override
+ void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
{
- mImpl->SamplerParameteriv( sampler, pname, param );
+ mImpl->SamplerParameteriv(sampler, pname, param);
}
- void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) override
+ void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
{
- mImpl->SamplerParameterf( sampler, pname, param );
+ mImpl->SamplerParameterf(sampler, pname, param);
}
- void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param ) override
+ void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
{
- mImpl->SamplerParameterfv( sampler, pname, param );
+ mImpl->SamplerParameterfv(sampler, pname, param);
}
- void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params ) override
+ void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
{
- mImpl->GetSamplerParameteriv( sampler, pname, params );
+ mImpl->GetSamplerParameteriv(sampler, pname, params);
}
- void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params ) override
+ void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
{
- mImpl->GetSamplerParameterfv( sampler, pname, params );
+ mImpl->GetSamplerParameterfv(sampler, pname, params);
}
- void VertexAttribDivisor( GLuint index, GLuint divisor ) override
+ void VertexAttribDivisor(GLuint index, GLuint divisor) override
{
- mImpl->VertexAttribDivisor( index, divisor );
+ mImpl->VertexAttribDivisor(index, divisor);
}
- void BindTransformFeedback( GLenum target, GLuint id ) override
+ void BindTransformFeedback(GLenum target, GLuint id) override
{
- mImpl->BindTransformFeedback( target, id );
+ mImpl->BindTransformFeedback(target, id);
}
- void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids ) override
+ void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
{
- mImpl->DeleteTransformFeedbacks( n, ids );
+ mImpl->DeleteTransformFeedbacks(n, ids);
}
- void GenTransformFeedbacks( GLsizei n, GLuint* ids ) override
+ void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
{
- mImpl->GenTransformFeedbacks( n, ids );
+ mImpl->GenTransformFeedbacks(n, ids);
}
- GLboolean IsTransformFeedback( GLuint id ) override
+ GLboolean IsTransformFeedback(GLuint id) override
{
- return mImpl->IsTransformFeedback( id );
+ return mImpl->IsTransformFeedback(id);
}
- void PauseTransformFeedback( void ) override
+ void PauseTransformFeedback(void) override
{
mImpl->PauseTransformFeedback();
}
- void ResumeTransformFeedback( void ) override
+ void ResumeTransformFeedback(void) override
{
mImpl->ResumeTransformFeedback();
}
- void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary ) override
+ void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
{
- mImpl->GetProgramBinary( program, bufSize, length, binaryFormat, binary );
+ mImpl->GetProgramBinary(program, bufSize, length, binaryFormat, binary);
}
- void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length ) override
+ void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
{
- mImpl->ProgramBinary( program, binaryFormat, binary, length );
+ mImpl->ProgramBinary(program, binaryFormat, binary, length);
}
- void ProgramParameteri( GLuint program, GLenum pname, GLint value ) override
+ void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
{
- mImpl->ProgramParameteri( program, pname, value );
+ mImpl->ProgramParameteri(program, pname, value);
}
- void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments ) override
+ void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
{
- mImpl->InvalidateFramebuffer( target, numAttachments, attachments );
+ mImpl->InvalidateFramebuffer(target, numAttachments, attachments);
}
- void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- mImpl->InvalidateSubFramebuffer( target, numAttachments, attachments, x, y, width, height );
+ mImpl->InvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
}
- void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
{
- mImpl->TexStorage2D( target, levels, internalformat, width, height );
+ mImpl->TexStorage2D(target, levels, internalformat, width, height);
}
- void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) override
+ void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
{
- mImpl->TexStorage3D( target, levels, internalformat, width, height, depth );
+ mImpl->TexStorage3D(target, levels, internalformat, width, height, depth);
}
- void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) override
+ void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
{
- mImpl->GetInternalformativ( target, internalformat, pname, bufSize, params );
+ mImpl->GetInternalformativ(target, internalformat, pname, bufSize, params);
}
void BlendBarrier(void)
private:
std::unique_ptr<GlesAbstraction> mImpl;
- ConditionalWait mContextCreatedWaitCondition;
- GLint mMaxTextureSize;
- std::string mShaderVersionPrefix;
- std::string mVertexShaderPrefix;
- std::string mFragmentShaderPrefix;
- int32_t mGlesVersion;
- int32_t mShadingLanguageVersion;
- bool mShadingLanguageVersionCached;
- bool mIsSurfacelessContextSupported;
- bool mIsAdvancedBlendEquationSupportedCached;
- bool mIsAdvancedBlendEquationSupported;
- bool mIsContextCreated;
+ ConditionalWait mContextCreatedWaitCondition;
+ GLint mMaxTextureSize;
+ std::string mShaderVersionPrefix;
+ std::string mVertexShaderPrefix;
+ std::string mFragmentShaderPrefix;
+ int32_t mGlesVersion;
+ int32_t mShadingLanguageVersion;
+ bool mShadingLanguageVersionCached;
+ bool mIsSurfacelessContextSupported;
+ bool mIsAdvancedBlendEquationSupportedCached;
+ bool mIsAdvancedBlendEquationSupported;
+ bool mIsContextCreated;
};
} // namespace Adaptor
/*
- * 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
{
-const int NUM_FRAMES_PER_SECOND( 60 );
+const int NUM_FRAMES_PER_SECOND(60);
}
-
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-
-Sampler::Sampler( const char* description )
-: mDescription( description ),
- mAccumulatedSquare( 0 ),
- mAccumulated( 0 ),
- mNumSamples( 0 ),
- mMin( 0.0f ),
- mMax( 0.0f ),
- mCurrentFrameCount( 0 )
+Sampler::Sampler(const char* description)
+: mDescription(description),
+ mAccumulatedSquare(0),
+ mAccumulated(0),
+ mNumSamples(0),
+ mMin(0.0f),
+ mMax(0.0f),
+ mCurrentFrameCount(0)
{
}
void Sampler::Reset()
{
mAccumulatedSquare = 0;
- mAccumulated = 0;
- mNumSamples = 0;
- mMin = 0.0f;
- mMax = 0.0f;
+ mAccumulated = 0;
+ mNumSamples = 0;
+ mMin = 0.0f;
+ mMax = 0.0f;
mCurrentFrameCount = 0;
}
void Sampler::Accumulate()
{
- if( mNumSamples == 0 )
+ if(mNumSamples == 0)
{
mMin = mCurrentFrameCount;
mMax = mCurrentFrameCount;
}
else
{
- if( mCurrentFrameCount < mMin )
+ if(mCurrentFrameCount < mMin)
{
mMin = mCurrentFrameCount;
}
- if( mCurrentFrameCount > mMax )
+ if(mCurrentFrameCount > mMax)
{
mMax = mCurrentFrameCount;
}
mNumSamples++;
mAccumulated += mCurrentFrameCount;
- mAccumulatedSquare += ( mCurrentFrameCount * mCurrentFrameCount );
+ mAccumulatedSquare += (mCurrentFrameCount * mCurrentFrameCount);
mCurrentFrameCount = 0;
}
const char* Sampler::GetDescription() const
float Sampler::GetMeanValue() const
{
float meanValue = 0;
- if( mNumSamples > 0 )
+ if(mNumSamples > 0)
{
- meanValue = static_cast<double>( mAccumulated ) / static_cast<double>( mNumSamples );
+ meanValue = static_cast<double>(mAccumulated) / static_cast<double>(mNumSamples);
}
return meanValue;
}
float Sampler::GetStandardDeviation() const
{
float standardDeviation = 0.0f;
- if( mNumSamples > 0 )
+ if(mNumSamples > 0)
{
- standardDeviation = sqrtf( mNumSamples * mAccumulatedSquare - ( mAccumulated * mAccumulated ) ) / mNumSamples;
+ standardDeviation = sqrtf(mNumSamples * mAccumulatedSquare - (mAccumulated * mAccumulated)) / mNumSamples;
}
return standardDeviation;
}
return mAccumulated;
}
-ObjectCounter::ObjectCounter( const char* description )
-: mDescription( description ),
- mCount( 0 ),
- mPeak( 0 )
-{}
+ObjectCounter::ObjectCounter(const char* description)
+: mDescription(description),
+ mCount(0),
+ mPeak(0)
+{
+}
void ObjectCounter::Increment()
{
++mCount;
- if( mCount > mPeak )
+ if(mCount > mPeak)
{
mPeak = mCount;
}
return mDescription;
}
-GlProxyImplementation::GlProxyImplementation( EnvironmentOptions& environmentOptions )
-: mEnvironmentOptions( environmentOptions ),
- mActiveTextureSampler( "ActiveTexture calls" ),
- mClearSampler( "Clear calls" ),
- mBindBufferSampler( "Bind buffers" ),
- mBindTextureSampler( "Bind textures" ),
- mDrawSampler( "Draw calls" ),
- mUniformSampler( "Uniform sets" ),
- mUseProgramSampler( "Used programs" ),
- mBufferCount( "Buffer Count" ),
- mTextureCount( "Texture Count" ),
- mProgramCount( "Program Count" ),
- mCurrentFrameCount( 0 ),
- mTotalFrameCount( 0 )
+GlProxyImplementation::GlProxyImplementation(const EnvironmentOptions& environmentOptions)
+: mEnvironmentOptions(environmentOptions),
+ mActiveTextureSampler("ActiveTexture calls"),
+ mClearSampler("Clear calls"),
+ mBindBufferSampler("Bind buffers"),
+ mBindTextureSampler("Bind textures"),
+ mDrawSampler("Draw calls"),
+ mUniformSampler("Uniform sets"),
+ mUseProgramSampler("Used programs"),
+ mBufferCount("Buffer Count"),
+ mTextureCount("Texture Count"),
+ mProgramCount("Program Count"),
+ mCurrentFrameCount(0),
+ mTotalFrameCount(0)
{
}
mTotalFrameCount++;
mCurrentFrameCount++;
- if( mCurrentFrameCount >= mEnvironmentOptions.GetGlesCallTime() * NUM_FRAMES_PER_SECOND )
+ if(mCurrentFrameCount >= mEnvironmentOptions.GetGlesCallTime() * NUM_FRAMES_PER_SECOND)
{
mCurrentFrameCount = 0;
LogResults();
- if( !mEnvironmentOptions.GetGlesCallAccumulate() )
+ if(!mEnvironmentOptions.GetGlesCallAccumulate())
{
ResetSamplers();
}
}
}
-void GlProxyImplementation::Clear( GLbitfield mask )
+void GlProxyImplementation::Clear(GLbitfield mask)
{
mClearSampler.Increment();
GlImplementation::Clear(mask);
void GlProxyImplementation::GenBuffers(GLsizei n, GLuint* buffers)
{
mBufferCount.Increment();
- GlImplementation::GenBuffers( n, buffers );
+ GlImplementation::GenBuffers(n, buffers);
}
-void GlProxyImplementation::DeleteBuffers( GLsizei n, const GLuint* buffers )
+void GlProxyImplementation::DeleteBuffers(GLsizei n, const GLuint* buffers)
{
mBufferCount.Decrement();
- GlImplementation::DeleteBuffers( n, buffers );
+ GlImplementation::DeleteBuffers(n, buffers);
}
-void GlProxyImplementation::BindBuffer( GLenum target, GLuint buffer )
+void GlProxyImplementation::BindBuffer(GLenum target, GLuint buffer)
{
mBindBufferSampler.Increment();
- GlImplementation::BindBuffer( target, buffer );
+ GlImplementation::BindBuffer(target, buffer);
}
-void GlProxyImplementation::GenTextures( GLsizei n, GLuint* textures )
+void GlProxyImplementation::GenTextures(GLsizei n, GLuint* textures)
{
mTextureCount.Increment();
- GlImplementation::GenTextures( n, textures );
+ GlImplementation::GenTextures(n, textures);
}
-void GlProxyImplementation::DeleteTextures( GLsizei n, const GLuint* textures )
+void GlProxyImplementation::DeleteTextures(GLsizei n, const GLuint* textures)
{
mTextureCount.Decrement();
- GlImplementation::DeleteTextures( n, textures );
+ GlImplementation::DeleteTextures(n, textures);
}
-void GlProxyImplementation::ActiveTexture( GLenum texture )
+void GlProxyImplementation::ActiveTexture(GLenum texture)
{
mActiveTextureSampler.Increment();
- GlImplementation::ActiveTexture( texture );
+ GlImplementation::ActiveTexture(texture);
}
-void GlProxyImplementation::BindTexture( GLenum target, GLuint texture )
+void GlProxyImplementation::BindTexture(GLenum target, GLuint texture)
{
mBindTextureSampler.Increment();
- GlImplementation::BindTexture(target,texture);
+ GlImplementation::BindTexture(target, texture);
}
-void GlProxyImplementation::DrawArrays( GLenum mode, GLint first, GLsizei count )
+void GlProxyImplementation::DrawArrays(GLenum mode, GLint first, GLsizei count)
{
mDrawSampler.Increment();
- GlImplementation::DrawArrays( mode, first, count );
+ GlImplementation::DrawArrays(mode, first, count);
}
-void GlProxyImplementation::DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices )
+void GlProxyImplementation::DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
{
mDrawSampler.Increment();
- GlImplementation::DrawElements( mode, count, type, indices );
+ GlImplementation::DrawElements(mode, count, type, indices);
}
-void GlProxyImplementation::Uniform1f( GLint location, GLfloat x )
+void GlProxyImplementation::Uniform1f(GLint location, GLfloat x)
{
mUniformSampler.Increment();
- GlImplementation::Uniform1f( location, x );
+ GlImplementation::Uniform1f(location, x);
}
-void GlProxyImplementation::Uniform1fv( GLint location, GLsizei count, const GLfloat* v )
+void GlProxyImplementation::Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform1fv( location, count, v );
+ GlImplementation::Uniform1fv(location, count, v);
}
-void GlProxyImplementation::Uniform1i( GLint location, GLint x )
+void GlProxyImplementation::Uniform1i(GLint location, GLint x)
{
mUniformSampler.Increment();
- GlImplementation::Uniform1i( location, x );
+ GlImplementation::Uniform1i(location, x);
}
-void GlProxyImplementation::Uniform1iv( GLint location, GLsizei count, const GLint* v )
+void GlProxyImplementation::Uniform1iv(GLint location, GLsizei count, const GLint* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform1iv( location, count, v );
+ GlImplementation::Uniform1iv(location, count, v);
}
-void GlProxyImplementation::Uniform2f( GLint location, GLfloat x, GLfloat y)
+void GlProxyImplementation::Uniform2f(GLint location, GLfloat x, GLfloat y)
{
mUniformSampler.Increment();
- GlImplementation::Uniform2f( location, x, y );
+ GlImplementation::Uniform2f(location, x, y);
}
-void GlProxyImplementation::Uniform2fv( GLint location, GLsizei count, const GLfloat* v )
+void GlProxyImplementation::Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform2fv( location, count, v );
+ GlImplementation::Uniform2fv(location, count, v);
}
-void GlProxyImplementation::Uniform2i( GLint location, GLint x, GLint y )
+void GlProxyImplementation::Uniform2i(GLint location, GLint x, GLint y)
{
mUniformSampler.Increment();
- GlImplementation::Uniform2i( location, x, y );
+ GlImplementation::Uniform2i(location, x, y);
}
-void GlProxyImplementation::Uniform2iv( GLint location, GLsizei count, const GLint* v )
+void GlProxyImplementation::Uniform2iv(GLint location, GLsizei count, const GLint* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform2iv( location, count, v );
+ GlImplementation::Uniform2iv(location, count, v);
}
-void GlProxyImplementation::Uniform3f( GLint location, GLfloat x, GLfloat y, GLfloat z )
+void GlProxyImplementation::Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
{
mUniformSampler.Increment();
- GlImplementation::Uniform3f( location, x, y, z );
+ GlImplementation::Uniform3f(location, x, y, z);
}
-void GlProxyImplementation::Uniform3fv( GLint location, GLsizei count, const GLfloat* v )
+void GlProxyImplementation::Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform3fv( location, count, v );
+ GlImplementation::Uniform3fv(location, count, v);
}
-void GlProxyImplementation::Uniform3i( GLint location, GLint x, GLint y, GLint z )
+void GlProxyImplementation::Uniform3i(GLint location, GLint x, GLint y, GLint z)
{
mUniformSampler.Increment();
- GlImplementation::Uniform3i( location, x, y, z );
+ GlImplementation::Uniform3i(location, x, y, z);
}
-void GlProxyImplementation::Uniform3iv( GLint location, GLsizei count, const GLint* v )
+void GlProxyImplementation::Uniform3iv(GLint location, GLsizei count, const GLint* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform3iv( location, count, v );
+ GlImplementation::Uniform3iv(location, count, v);
}
-void GlProxyImplementation::Uniform4f( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+void GlProxyImplementation::Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
mUniformSampler.Increment();
- GlImplementation::Uniform4f( location, x, y, z, w );
+ GlImplementation::Uniform4f(location, x, y, z, w);
}
-void GlProxyImplementation::Uniform4fv( GLint location, GLsizei count, const GLfloat* v )
+void GlProxyImplementation::Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform4fv( location, count, v );
+ GlImplementation::Uniform4fv(location, count, v);
}
-void GlProxyImplementation::Uniform4i( GLint location, GLint x, GLint y, GLint z, GLint w )
+void GlProxyImplementation::Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
{
mUniformSampler.Increment();
- GlImplementation::Uniform4i( location, x, y, z, w );
+ GlImplementation::Uniform4i(location, x, y, z, w);
}
-void GlProxyImplementation::Uniform4iv( GLint location, GLsizei count, const GLint* v )
+void GlProxyImplementation::Uniform4iv(GLint location, GLsizei count, const GLint* v)
{
mUniformSampler.Increment();
- GlImplementation::Uniform4iv( location, count, v );
+ GlImplementation::Uniform4iv(location, count, v);
}
-void GlProxyImplementation::UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
+void GlProxyImplementation::UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
mUniformSampler.Increment();
- GlImplementation::UniformMatrix2fv( location, count, transpose, value );
+ GlImplementation::UniformMatrix2fv(location, count, transpose, value);
}
-void GlProxyImplementation::UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
+void GlProxyImplementation::UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
mUniformSampler.Increment();
- GlImplementation::UniformMatrix3fv( location, count, transpose, value );
+ GlImplementation::UniformMatrix3fv(location, count, transpose, value);
}
-void GlProxyImplementation::UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value )
+void GlProxyImplementation::UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
{
mUniformSampler.Increment();
- GlImplementation::UniformMatrix4fv( location, count, transpose, value);
+ GlImplementation::UniformMatrix4fv(location, count, transpose, value);
}
-GLuint GlProxyImplementation::CreateProgram( void )
+GLuint GlProxyImplementation::CreateProgram(void)
{
mProgramCount.Increment();
return GlImplementation::CreateProgram();
}
-void GlProxyImplementation::DeleteProgram( GLuint program )
+void GlProxyImplementation::DeleteProgram(GLuint program)
{
mProgramCount.Decrement();
- GlImplementation::DeleteProgram( program );
+ GlImplementation::DeleteProgram(program);
}
-void GlProxyImplementation::UseProgram( GLuint program )
+void GlProxyImplementation::UseProgram(GLuint program)
{
mUseProgramSampler.Increment();
- GlImplementation::UseProgram( program );
+ GlImplementation::UseProgram(program);
}
void GlProxyImplementation::AccumulateSamples()
void GlProxyImplementation::LogResults()
{
- Debug::LogMessage( Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mTotalFrameCount );
- LogCalls( mActiveTextureSampler );
- LogCalls( mClearSampler );
- LogCalls( mBindBufferSampler );
- LogCalls( mBindTextureSampler );
- LogCalls( mDrawSampler );
- LogCalls( mUniformSampler );
- LogCalls( mUseProgramSampler );
- Debug::LogMessage( Debug::DebugInfo, "OpenGL ES Object Count:\n" );
- LogObjectCounter( mBufferCount );
- LogObjectCounter( mTextureCount );
- LogObjectCounter( mProgramCount );
+ Debug::LogMessage(Debug::DebugInfo, "OpenGL ES statistics sampled over %d frames) operations per frame:\n", mTotalFrameCount);
+ LogCalls(mActiveTextureSampler);
+ LogCalls(mClearSampler);
+ LogCalls(mBindBufferSampler);
+ LogCalls(mBindTextureSampler);
+ LogCalls(mDrawSampler);
+ LogCalls(mUniformSampler);
+ LogCalls(mUseProgramSampler);
+ Debug::LogMessage(Debug::DebugInfo, "OpenGL ES Object Count:\n");
+ LogObjectCounter(mBufferCount);
+ LogObjectCounter(mTextureCount);
+ LogObjectCounter(mProgramCount);
}
-void GlProxyImplementation::LogCalls( const Sampler& sampler )
+void GlProxyImplementation::LogCalls(const Sampler& sampler)
{
- Debug::LogMessage( Debug::DebugInfo, " %s : Mean %5.2f (Min:%5.2f, Max:%5.2f, StdDev:%5.2f, Actual:%d)\n",
- sampler.GetDescription(),
- sampler.GetMeanValue(), sampler.GetMin(), sampler.GetMax(),
- sampler.GetStandardDeviation(),
- sampler.GetCount() );
+ Debug::LogMessage(Debug::DebugInfo, " %s : Mean %5.2f (Min:%5.2f, Max:%5.2f, StdDev:%5.2f, Actual:%d)\n", sampler.GetDescription(), sampler.GetMeanValue(), sampler.GetMin(), sampler.GetMax(), sampler.GetStandardDeviation(), sampler.GetCount());
}
-void GlProxyImplementation::LogObjectCounter( const ObjectCounter& sampler )
+void GlProxyImplementation::LogObjectCounter(const ObjectCounter& sampler)
{
- Debug::LogMessage( Debug::DebugInfo, " %s : %u (Peak:%u)\n",
- sampler.GetDescription(),
- sampler.GetCount(),
- sampler.GetPeak() );
+ Debug::LogMessage(Debug::DebugInfo, " %s : %u (Peak:%u)\n", sampler.GetDescription(), sampler.GetCount(), sampler.GetPeak());
}
void GlProxyImplementation::ResetSamplers()
#define DALI_INTERNAL_GL_PROXY_IMPLEMENTATION_H
/*
- * 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 Sampler
{
public:
-
/**
* Constructor
* @param description to write to the log
*/
- Sampler( const char* description );
+ Sampler(const char* description);
/**
* Increment the counter for this frame
uint64_t GetCount() const;
private: // Data
-
const char* mDescription;
- uint64_t mAccumulatedSquare;
- uint64_t mAccumulated;
- uint64_t mNumSamples;
- float mMin;
- float mMax;
+ uint64_t mAccumulatedSquare;
+ uint64_t mAccumulated;
+ uint64_t mNumSamples;
+ float mMin;
+ float mMax;
unsigned int mCurrentFrameCount;
};
class ObjectCounter
{
public:
- ObjectCounter( const char* description );
+ ObjectCounter(const char* description);
/**
* Increment the counter
const char* GetDescription() const;
private:
- const char* mDescription;
+ const char* mDescription;
unsigned int mCount;
unsigned int mPeak;
};
class GlProxyImplementation : public GlImplementation
{
public:
-
/**
* Constructor
* @param environmentOptions to check how often to log results
*/
- GlProxyImplementation( EnvironmentOptions& environmentOptions );
+ GlProxyImplementation(const EnvironmentOptions& environmentOptions);
/**
* Virtual destructor
void PostRender() override;
/* OpenGL ES 2.0 API */
- void Clear( GLbitfield mask ) override;
-
- void GenBuffers( GLsizei n, GLuint* buffers ) override;
- void DeleteBuffers( GLsizei n, const GLuint* buffers ) override;
- void BindBuffer( GLenum target, GLuint buffer ) override;
-
- void GenTextures( GLsizei n, GLuint* textures ) override;
- void DeleteTextures( GLsizei n, const GLuint* textures ) override;
- void ActiveTexture( GLenum texture ) override;
- void BindTexture( GLenum target, GLuint texture ) override;
-
- void DrawArrays( GLenum mode, GLint first, GLsizei count ) override;
- void DrawElements( GLenum mode, GLsizei count, GLenum type, const void* indices ) override;
-
- void Uniform1f ( GLint location, GLfloat x ) override;
- void Uniform1fv( GLint location, GLsizei count, const GLfloat* v ) override;
- void Uniform1i ( GLint location, GLint x ) override;
- void Uniform1iv( GLint location, GLsizei count, const GLint* v ) override;
- void Uniform2f ( GLint location, GLfloat x, GLfloat y ) override;
- void Uniform2fv( GLint location, GLsizei count, const GLfloat* v ) override;
- void Uniform2i ( GLint location, GLint x, GLint y ) override;
- void Uniform2iv( GLint location, GLsizei count, const GLint* v ) override;
- void Uniform3f ( GLint location, GLfloat x, GLfloat y, GLfloat z ) override;
- void Uniform3fv( GLint location, GLsizei count, const GLfloat* v ) override;
- void Uniform3i ( GLint location, GLint x, GLint y, GLint z ) override;
- void Uniform3iv( GLint location, GLsizei count, const GLint* v ) override;
- void Uniform4f ( GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) override;
- void Uniform4fv( GLint location, GLsizei count, const GLfloat* v ) override;
- void Uniform4i ( GLint location, GLint x, GLint y, GLint z, GLint w ) override;
- void Uniform4iv( GLint location, GLsizei count, const GLint* v ) override;
- void UniformMatrix2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override;
- void UniformMatrix3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override;
- void UniformMatrix4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override;
-
- GLuint CreateProgram( void ) override;
- void DeleteProgram( GLuint program ) override;
- void UseProgram( GLuint program ) override;
+ void Clear(GLbitfield mask) override;
+
+ void GenBuffers(GLsizei n, GLuint* buffers) override;
+ void DeleteBuffers(GLsizei n, const GLuint* buffers) override;
+ void BindBuffer(GLenum target, GLuint buffer) override;
+
+ void GenTextures(GLsizei n, GLuint* textures) override;
+ void DeleteTextures(GLsizei n, const GLuint* textures) override;
+ void ActiveTexture(GLenum texture) override;
+ void BindTexture(GLenum target, GLuint texture) override;
+
+ void DrawArrays(GLenum mode, GLint first, GLsizei count) override;
+ void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices) override;
+
+ void Uniform1f(GLint location, GLfloat x) override;
+ void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) override;
+ void Uniform1i(GLint location, GLint x) override;
+ void Uniform1iv(GLint location, GLsizei count, const GLint* v) override;
+ void Uniform2f(GLint location, GLfloat x, GLfloat y) override;
+ void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override;
+ void Uniform2i(GLint location, GLint x, GLint y) override;
+ void Uniform2iv(GLint location, GLsizei count, const GLint* v) override;
+ void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override;
+ void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override;
+ void Uniform3i(GLint location, GLint x, GLint y, GLint z) override;
+ void Uniform3iv(GLint location, GLsizei count, const GLint* v) override;
+ void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override;
+ void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override;
+ void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override;
+ void Uniform4iv(GLint location, GLsizei count, const GLint* v) override;
+ void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override;
+ void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override;
+ void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override;
+
+ GLuint CreateProgram(void) override;
+ void DeleteProgram(GLuint program) override;
+ void UseProgram(GLuint program) override;
private: // Helpers
-
void AccumulateSamples();
void LogResults();
- void LogCalls( const Sampler& sampler );
- void LogObjectCounter( const ObjectCounter& sampler );
+ void LogCalls(const Sampler& sampler);
+ void LogObjectCounter(const ObjectCounter& sampler);
void ResetSamplers();
private: // Data
-
- EnvironmentOptions& mEnvironmentOptions;
- Sampler mActiveTextureSampler;
- Sampler mClearSampler;
- Sampler mBindBufferSampler;
- Sampler mBindTextureSampler;
- Sampler mDrawSampler;
- Sampler mUniformSampler;
- Sampler mUseProgramSampler;
- ObjectCounter mBufferCount;
- ObjectCounter mTextureCount;
- ObjectCounter mProgramCount;
+ const EnvironmentOptions& mEnvironmentOptions;
+ Sampler mActiveTextureSampler;
+ Sampler mClearSampler;
+ Sampler mBindBufferSampler;
+ Sampler mBindTextureSampler;
+ Sampler mDrawSampler;
+ Sampler mUniformSampler;
+ Sampler mUseProgramSampler;
+ ObjectCounter mBufferCount;
+ ObjectCounter mTextureCount;
+ ObjectCounter mProgramCount;
int mCurrentFrameCount;
int mTotalFrameCount;
#define DALI_INTERNAL_GLES_ABSTRACTION_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 Internal
{
-
namespace Adaptor
{
-
class GlesAbstraction
{
-
public:
-
/**
* Destructor
*/
- virtual ~GlesAbstraction() {};
+ virtual ~GlesAbstraction(){};
- virtual void ReadBuffer( GLenum mode ) = 0;
+ virtual void ReadBuffer(GLenum mode) = 0;
- virtual void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices ) = 0;
+ virtual void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) = 0;
- virtual void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels ) = 0;
+ virtual void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) = 0;
- virtual void TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels ) = 0;
+ virtual void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) = 0;
- virtual void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) = 0;
+ virtual void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = 0;
- virtual void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data ) = 0;
+ virtual void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) = 0;
- virtual void CompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data ) = 0;
+ virtual void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) = 0;
- virtual void GenQueries( GLsizei n, GLuint* ids ) = 0;
+ virtual void GenQueries(GLsizei n, GLuint* ids) = 0;
- virtual void DeleteQueries( GLsizei n, const GLuint* ids ) = 0;
+ virtual void DeleteQueries(GLsizei n, const GLuint* ids) = 0;
- virtual GLboolean IsQuery( GLuint id ) = 0;
+ virtual GLboolean IsQuery(GLuint id) = 0;
- virtual void BeginQuery( GLenum target, GLuint id ) = 0;
+ virtual void BeginQuery(GLenum target, GLuint id) = 0;
- virtual void EndQuery( GLenum target ) = 0;
+ virtual void EndQuery(GLenum target) = 0;
- virtual void GetQueryiv( GLenum target, GLenum pname, GLint* params ) = 0;
+ virtual void GetQueryiv(GLenum target, GLenum pname, GLint* params) = 0;
- virtual void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params ) = 0;
+ virtual void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) = 0;
- virtual GLboolean UnmapBuffer( GLenum target ) = 0;
+ virtual GLboolean UnmapBuffer(GLenum target) = 0;
- virtual void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params ) = 0;
+ virtual void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) = 0;
- virtual void DrawBuffers( GLsizei n, const GLenum* bufs ) = 0;
+ virtual void DrawBuffers(GLsizei n, const GLenum* bufs) = 0;
- virtual void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) = 0;
+ virtual void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0;
- virtual void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) = 0;
+ virtual void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0;
- virtual void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) = 0;
+ virtual void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0;
- virtual void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) = 0;
+ virtual void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0;
- virtual void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) = 0;
+ virtual void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0;
- virtual void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) = 0;
+ virtual void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = 0;
- virtual void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter ) = 0;
+ virtual void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = 0;
- virtual void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height ) = 0;
+ virtual void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = 0;
- virtual void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) = 0;
+ virtual void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) = 0;
- virtual GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access ) = 0;
+ virtual GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) = 0;
- virtual void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length ) = 0;
+ virtual void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) = 0;
- virtual void BindVertexArray( GLuint array ) = 0;
+ virtual void BindVertexArray(GLuint array) = 0;
- virtual void DeleteVertexArrays( GLsizei n, const GLuint* arrays ) = 0;
+ virtual void DeleteVertexArrays(GLsizei n, const GLuint* arrays) = 0;
- virtual void GenVertexArrays( GLsizei n, GLuint* arrays ) = 0;
+ virtual void GenVertexArrays(GLsizei n, GLuint* arrays) = 0;
- virtual GLboolean IsVertexArray( GLuint array ) = 0;
+ virtual GLboolean IsVertexArray(GLuint array) = 0;
- virtual void GetIntegeri_v( GLenum target, GLuint index, GLint* data ) = 0;
+ virtual void GetIntegeri_v(GLenum target, GLuint index, GLint* data) = 0;
- virtual void BeginTransformFeedback( GLenum primitiveMode ) = 0;
+ virtual void BeginTransformFeedback(GLenum primitiveMode) = 0;
- virtual void EndTransformFeedback( void ) = 0;
+ virtual void EndTransformFeedback(void) = 0;
- virtual void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size ) = 0;
+ virtual void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) = 0;
- virtual void BindBufferBase( GLenum target, GLuint index, GLuint buffer ) = 0;
+ virtual void BindBufferBase(GLenum target, GLuint index, GLuint buffer) = 0;
- virtual void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode ) = 0;
+ virtual void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) = 0;
- virtual void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name ) = 0;
+ virtual void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) = 0;
- virtual void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) = 0;
+ virtual void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = 0;
- virtual void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params ) = 0;
+ virtual void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) = 0;
- virtual void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params ) = 0;
+ virtual void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) = 0;
- virtual void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w ) = 0;
+ virtual void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) = 0;
- virtual void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w ) = 0;
+ virtual void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) = 0;
- virtual void VertexAttribI4iv( GLuint index, const GLint* v ) = 0;
+ virtual void VertexAttribI4iv(GLuint index, const GLint* v) = 0;
- virtual void VertexAttribI4uiv( GLuint index, const GLuint* v ) = 0;
+ virtual void VertexAttribI4uiv(GLuint index, const GLuint* v) = 0;
- virtual void GetUniformuiv( GLuint program, GLint location, GLuint* params ) = 0;
+ virtual void GetUniformuiv(GLuint program, GLint location, GLuint* params) = 0;
- virtual GLint GetFragDataLocation( GLuint program, const GLchar *name ) = 0;
+ virtual GLint GetFragDataLocation(GLuint program, const GLchar* name) = 0;
- virtual void Uniform1ui( GLint location, GLuint v0 ) = 0;
+ virtual void Uniform1ui(GLint location, GLuint v0) = 0;
- virtual void Uniform2ui( GLint location, GLuint v0, GLuint v1 ) = 0;
+ virtual void Uniform2ui(GLint location, GLuint v0, GLuint v1) = 0;
- virtual void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) = 0;
+ virtual void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) = 0;
- virtual void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) = 0;
+ virtual void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) = 0;
- virtual void Uniform1uiv( GLint location, GLsizei count, const GLuint* value ) = 0;
+ virtual void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) = 0;
- virtual void Uniform2uiv( GLint location, GLsizei count, const GLuint* value ) = 0;
+ virtual void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) = 0;
- virtual void Uniform3uiv( GLint location, GLsizei count, const GLuint* value ) = 0;
+ virtual void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) = 0;
- virtual void Uniform4uiv( GLint location, GLsizei count, const GLuint* value ) = 0;
+ virtual void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) = 0;
- virtual void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value ) = 0;
+ virtual void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) = 0;
- virtual void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value ) = 0;
+ virtual void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) = 0;
- virtual void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value ) = 0;
+ virtual void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) = 0;
- virtual void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil ) = 0;
+ virtual void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = 0;
- virtual const GLubyte* GetStringi( GLenum name, GLuint index ) = 0;
+ virtual const GLubyte* GetStringi(GLenum name, GLuint index) = 0;
- virtual void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size ) = 0;
+ virtual void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) = 0;
- virtual void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices ) = 0;
+ virtual void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) = 0;
- virtual void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params ) = 0;
+ virtual void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) = 0;
- virtual GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName ) = 0;
+ virtual GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) = 0;
- virtual void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) = 0;
+ virtual void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) = 0;
- virtual void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName ) = 0;
+ virtual void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) = 0;
- virtual void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) = 0;
+ virtual void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = 0;
- virtual void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount ) = 0;
+ virtual void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) = 0;
- virtual void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount ) = 0;
+ virtual void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) = 0;
- virtual GLsync FenceSync( GLenum condition, GLbitfield flags ) = 0;
+ virtual GLsync FenceSync(GLenum condition, GLbitfield flags) = 0;
- virtual GLboolean IsSync( GLsync sync ) = 0;
+ virtual GLboolean IsSync(GLsync sync) = 0;
- virtual void DeleteSync( GLsync sync ) = 0;
+ virtual void DeleteSync(GLsync sync) = 0;
- virtual GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) = 0;
+ virtual GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) = 0;
- virtual void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) = 0;
+ virtual void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) = 0;
- virtual void GetInteger64v( GLenum pname, GLint64* params ) = 0;
+ virtual void GetInteger64v(GLenum pname, GLint64* params) = 0;
- virtual void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) = 0;
+ virtual void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) = 0;
- virtual void GetInteger64i_v( GLenum target, GLuint index, GLint64* data ) = 0;
+ virtual void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) = 0;
- virtual void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params ) = 0;
+ virtual void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) = 0;
- virtual void GenSamplers( GLsizei count, GLuint* samplers ) = 0;
+ virtual void GenSamplers(GLsizei count, GLuint* samplers) = 0;
- virtual void DeleteSamplers( GLsizei count, const GLuint* samplers ) = 0;
+ virtual void DeleteSamplers(GLsizei count, const GLuint* samplers) = 0;
- virtual GLboolean IsSampler( GLuint sampler ) = 0;
+ virtual GLboolean IsSampler(GLuint sampler) = 0;
- virtual void BindSampler( GLuint unit, GLuint sampler ) = 0;
+ virtual void BindSampler(GLuint unit, GLuint sampler) = 0;
- virtual void SamplerParameteri( GLuint sampler, GLenum pname, GLint param ) = 0;
+ virtual void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) = 0;
- virtual void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param ) = 0;
+ virtual void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) = 0;
- virtual void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) = 0;
+ virtual void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) = 0;
- virtual void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param ) = 0;
+ virtual void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) = 0;
- virtual void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params ) = 0;
+ virtual void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) = 0;
- virtual void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params ) = 0;
+ virtual void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) = 0;
- virtual void VertexAttribDivisor( GLuint index, GLuint divisor ) = 0;
+ virtual void VertexAttribDivisor(GLuint index, GLuint divisor) = 0;
- virtual void BindTransformFeedback( GLenum target, GLuint id ) = 0;
+ virtual void BindTransformFeedback(GLenum target, GLuint id) = 0;
- virtual void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids ) = 0;
+ virtual void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) = 0;
- virtual void GenTransformFeedbacks( GLsizei n, GLuint* ids ) = 0;
+ virtual void GenTransformFeedbacks(GLsizei n, GLuint* ids) = 0;
- virtual GLboolean IsTransformFeedback( GLuint id ) = 0;
+ virtual GLboolean IsTransformFeedback(GLuint id) = 0;
- virtual void PauseTransformFeedback( void ) = 0;
+ virtual void PauseTransformFeedback(void) = 0;
- virtual void ResumeTransformFeedback( void ) = 0;
+ virtual void ResumeTransformFeedback(void) = 0;
- virtual void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary ) = 0;
+ virtual void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) = 0;
- virtual void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length ) = 0;
+ virtual void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) = 0;
- virtual void ProgramParameteri( GLuint program, GLenum pname, GLint value ) = 0;
+ virtual void ProgramParameteri(GLuint program, GLenum pname, GLint value) = 0;
- virtual void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments ) = 0;
+ virtual void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) = 0;
- virtual void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height ) = 0;
+ virtual void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) = 0;
- virtual void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height ) = 0;
+ virtual void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) = 0;
- virtual void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) = 0;
+ virtual void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0;
- virtual void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) = 0;
+ virtual void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) = 0;
- virtual void BlendBarrier( void ) = 0;
+ virtual void BlendBarrier(void) = 0;
};
} // namespace Adaptor
#define DALI_INTERNAL_GLES2_IMPLEMENTATION_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.
*
*/
- // EXTERNAL INCLUDES
+// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class Gles2Implementation : public GlesAbstraction
{
-
public:
- Gles2Implementation() {}
+ Gles2Implementation()
+ {
+ }
- ~Gles2Implementation() override {}
+ ~Gles2Implementation() override
+ {
+ }
- void ReadBuffer( GLenum mode ) override
+ void ReadBuffer(GLenum mode) override
{
- DALI_LOG_ERROR( "glReadBuffer is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glReadBuffer is not supported in OpenGL es 2.0\n");
}
- void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices ) override
+ void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
{
- DALI_LOG_ERROR( "glDrawRangeElements is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDrawRangeElements is not supported in OpenGL es 2.0\n");
}
- void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels ) override
+ void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
{
- DALI_LOG_ERROR( "glTexImage3D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glTexImage3D is not supported in OpenGL es 2.0\n");
}
- void TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels ) override
+ void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) override
{
- DALI_LOG_ERROR( "glTexSubImage3D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glTexSubImage3D is not supported in OpenGL es 2.0\n");
}
- void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- DALI_LOG_ERROR( "glCopyTexSubImage3D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glCopyTexSubImage3D is not supported in OpenGL es 2.0\n");
}
- void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data ) override
+ void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
{
- DALI_LOG_ERROR( "glCompressedTexImage3D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glCompressedTexImage3D is not supported in OpenGL es 2.0\n");
}
- void CompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data ) override
+ void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) override
{
- DALI_LOG_ERROR( "glCompressedTexSubImage3D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glCompressedTexSubImage3D is not supported in OpenGL es 2.0\n");
}
- void GenQueries( GLsizei n, GLuint* ids ) override
+ void GenQueries(GLsizei n, GLuint* ids) override
{
- DALI_LOG_ERROR( "glGenQueries is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGenQueries is not supported in OpenGL es 2.0\n");
}
- void DeleteQueries( GLsizei n, const GLuint* ids ) override
+ void DeleteQueries(GLsizei n, const GLuint* ids) override
{
- DALI_LOG_ERROR( "glDeleteQueries is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDeleteQueries is not supported in OpenGL es 2.0\n");
}
- GLboolean IsQuery( GLuint id ) override
+ GLboolean IsQuery(GLuint id) override
{
- DALI_LOG_ERROR( "glIsQuery is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glIsQuery is not supported in OpenGL es 2.0\n");
return 0;
}
- void BeginQuery( GLenum target, GLuint id ) override
+ void BeginQuery(GLenum target, GLuint id) override
{
- DALI_LOG_ERROR( "glBeginQuery is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBeginQuery is not supported in OpenGL es 2.0\n");
}
- void EndQuery( GLenum target ) override
+ void EndQuery(GLenum target) override
{
- DALI_LOG_ERROR( "glEndQuery is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glEndQuery is not supported in OpenGL es 2.0\n");
}
- void GetQueryiv( GLenum target, GLenum pname, GLint* params ) override
+ void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
{
- DALI_LOG_ERROR( "glGetQueryiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetQueryiv is not supported in OpenGL es 2.0\n");
}
- void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params ) override
+ void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
{
- DALI_LOG_ERROR( "glGetQueryObjectuiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetQueryObjectuiv is not supported in OpenGL es 2.0\n");
}
- GLboolean UnmapBuffer( GLenum target ) override
+ GLboolean UnmapBuffer(GLenum target) override
{
- DALI_LOG_ERROR( "glUnmapBuffer is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUnmapBuffer is not supported in OpenGL es 2.0\n");
return 0;
}
- void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params ) override
+ void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
{
- DALI_LOG_ERROR( "glGetBufferPointerv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetBufferPointerv is not supported in OpenGL es 2.0\n");
}
- void DrawBuffers( GLsizei n, const GLenum* bufs ) override
+ void DrawBuffers(GLsizei n, const GLenum* bufs) override
{
- DALI_LOG_ERROR( "glDrawBuffers is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDrawBuffers is not supported in OpenGL es 2.0\n");
}
- void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glUniformMatrix2x3fv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformMatrix2x3fv is not supported in OpenGL es 2.0\n");
}
- void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glUniformMatrix3x2fv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformMatrix3x2fv is not supported in OpenGL es 2.0\n");
}
- void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glUniformMatrix2x4fv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformMatrix2x4fv is not supported in OpenGL es 2.0\n");
}
- void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glUniformMatrix4x2fv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformMatrix4x2fv is not supported in OpenGL es 2.0\n");
}
- void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glUniformMatrix3x4fv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformMatrix3x4fv is not supported in OpenGL es 2.0\n");
}
- void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glUniformMatrix4x3fv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformMatrix4x3fv is not supported in OpenGL es 2.0\n");
}
- void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter ) override
+ void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
{
- DALI_LOG_ERROR( "glBlitFramebuffer is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBlitFramebuffer is not supported in OpenGL es 2.0\n");
}
- void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
{
- DALI_LOG_ERROR( "glRenderbufferStorageMultisample is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glRenderbufferStorageMultisample is not supported in OpenGL es 2.0\n");
}
- void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) override
+ void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
{
- DALI_LOG_ERROR( "glFramebufferTextureLayer is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glFramebufferTextureLayer is not supported in OpenGL es 2.0\n");
}
- GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access ) override
+ GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
{
- DALI_LOG_ERROR( "glMapBufferRange is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glMapBufferRange is not supported in OpenGL es 2.0\n");
return NULL;
}
- void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length ) override
+ void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
{
- DALI_LOG_ERROR( "glFlushMappedBufferRange is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glFlushMappedBufferRange is not supported in OpenGL es 2.0\n");
}
- void BindVertexArray( GLuint array ) override
+ void BindVertexArray(GLuint array) override
{
- DALI_LOG_ERROR( "glBindVertexArray is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBindVertexArray is not supported in OpenGL es 2.0\n");
}
- void DeleteVertexArrays( GLsizei n, const GLuint* arrays ) override
+ void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
{
- DALI_LOG_ERROR( "glDeleteVertexArrays is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDeleteVertexArrays is not supported in OpenGL es 2.0\n");
}
- void GenVertexArrays( GLsizei n, GLuint* arrays ) override
+ void GenVertexArrays(GLsizei n, GLuint* arrays) override
{
- DALI_LOG_ERROR( "glGenVertexArrays is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGenVertexArrays is not supported in OpenGL es 2.0\n");
}
- GLboolean IsVertexArray( GLuint array ) override
+ GLboolean IsVertexArray(GLuint array) override
{
- DALI_LOG_ERROR( "glIsVertexArray is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glIsVertexArray is not supported in OpenGL es 2.0\n");
return 0;
}
- void GetIntegeri_v( GLenum target, GLuint index, GLint* data ) override
+ void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
{
- DALI_LOG_ERROR( "glGetIntegeri_v is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetIntegeri_v is not supported in OpenGL es 2.0\n");
}
- void BeginTransformFeedback( GLenum primitiveMode ) override
+ void BeginTransformFeedback(GLenum primitiveMode) override
{
- DALI_LOG_ERROR( "glBeginTransformFeedback is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBeginTransformFeedback is not supported in OpenGL es 2.0\n");
}
- void EndTransformFeedback( void ) override
+ void EndTransformFeedback(void) override
{
- DALI_LOG_ERROR( "glEndTransformFeedback is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glEndTransformFeedback is not supported in OpenGL es 2.0\n");
}
- void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size ) override
+ void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
{
- DALI_LOG_ERROR( "glBindBufferRange is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBindBufferRange is not supported in OpenGL es 2.0\n");
}
- void BindBufferBase( GLenum target, GLuint index, GLuint buffer ) override
+ void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
{
- DALI_LOG_ERROR( "glBindBufferBase is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBindBufferBase is not supported in OpenGL es 2.0\n");
}
- void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode ) override
+ void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
{
- DALI_LOG_ERROR( "glTransformFeedbackVaryings is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glTransformFeedbackVaryings is not supported in OpenGL es 2.0\n");
}
- void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name ) override
+ void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
{
- DALI_LOG_ERROR( "glGetTransformFeedbackVarying is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetTransformFeedbackVarying is not supported in OpenGL es 2.0\n");
}
- void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) override
+ void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
{
- DALI_LOG_ERROR( "glVertexAttribIPointer is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glVertexAttribIPointer is not supported in OpenGL es 2.0\n");
}
- void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params ) override
+ void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
{
- DALI_LOG_ERROR( "glGetVertexAttribIiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetVertexAttribIiv is not supported in OpenGL es 2.0\n");
}
- void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params ) override
+ void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
{
- DALI_LOG_ERROR( "glGetVertexAttribIuiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetVertexAttribIuiv is not supported in OpenGL es 2.0\n");
}
- void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w ) override
+ void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
{
- DALI_LOG_ERROR( "glVertexAttribI4i is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glVertexAttribI4i is not supported in OpenGL es 2.0\n");
}
- void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w ) override
+ void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
{
- DALI_LOG_ERROR( "glVertexAttribI4ui is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glVertexAttribI4ui is not supported in OpenGL es 2.0\n");
}
- void VertexAttribI4iv( GLuint index, const GLint* v ) override
+ void VertexAttribI4iv(GLuint index, const GLint* v) override
{
- DALI_LOG_ERROR( "glVertexAttribI4iv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glVertexAttribI4iv is not supported in OpenGL es 2.0\n");
}
- void VertexAttribI4uiv( GLuint index, const GLuint* v ) override
+ void VertexAttribI4uiv(GLuint index, const GLuint* v) override
{
- DALI_LOG_ERROR( "glVertexAttribI4uiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glVertexAttribI4uiv is not supported in OpenGL es 2.0\n");
}
- void GetUniformuiv( GLuint program, GLint location, GLuint* params ) override
+ void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
{
- DALI_LOG_ERROR( "glGetUniformuiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetUniformuiv is not supported in OpenGL es 2.0\n");
}
- GLint GetFragDataLocation( GLuint program, const GLchar *name ) override
+ GLint GetFragDataLocation(GLuint program, const GLchar* name) override
{
- DALI_LOG_ERROR( "glGetFragDataLocation is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetFragDataLocation is not supported in OpenGL es 2.0\n");
return -1;
}
- void Uniform1ui( GLint location, GLuint v0 ) override
+ void Uniform1ui(GLint location, GLuint v0) override
{
- DALI_LOG_ERROR( "glUniform1ui is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform1ui is not supported in OpenGL es 2.0\n");
}
- void Uniform2ui( GLint location, GLuint v0, GLuint v1 ) override
+ void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
{
- DALI_LOG_ERROR( "glUniform2ui is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform2ui is not supported in OpenGL es 2.0\n");
}
- void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) override
+ void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
{
- DALI_LOG_ERROR( "glUniform3ui is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform3ui is not supported in OpenGL es 2.0\n");
}
- void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) override
+ void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
{
- DALI_LOG_ERROR( "glUniform4ui is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform4ui is not supported in OpenGL es 2.0\n");
}
- void Uniform1uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
{
- DALI_LOG_ERROR( "glUniform1uiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform1uiv is not supported in OpenGL es 2.0\n");
}
- void Uniform2uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
{
- DALI_LOG_ERROR( "glUniform2uiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform2uiv is not supported in OpenGL es 2.0\n");
}
- void Uniform3uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
{
- DALI_LOG_ERROR( "glUniform3uiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform3uiv is not supported in OpenGL es 2.0\n");
}
- void Uniform4uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
{
- DALI_LOG_ERROR( "glUniform4uiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniform4uiv is not supported in OpenGL es 2.0\n");
}
- void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value ) override
+ void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
{
- DALI_LOG_ERROR( "glClearBufferiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glClearBufferiv is not supported in OpenGL es 2.0\n");
}
- void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value ) override
+ void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
{
- DALI_LOG_ERROR( "glClearBufferuiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glClearBufferuiv is not supported in OpenGL es 2.0\n");
}
- void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value ) override
+ void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
{
- DALI_LOG_ERROR( "glClearBufferfv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glClearBufferfv is not supported in OpenGL es 2.0\n");
}
- void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil ) override
+ void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
{
- DALI_LOG_ERROR( "glClearBufferfi is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glClearBufferfi is not supported in OpenGL es 2.0\n");
}
- const GLubyte* GetStringi( GLenum name, GLuint index ) override
+ const GLubyte* GetStringi(GLenum name, GLuint index) override
{
- DALI_LOG_ERROR( "glGetStringi is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetStringi is not supported in OpenGL es 2.0\n");
return NULL;
}
- void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size ) override
+ void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
{
- DALI_LOG_ERROR( "glCopyBufferSubData is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glCopyBufferSubData is not supported in OpenGL es 2.0\n");
}
- void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices ) override
+ void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
{
- DALI_LOG_ERROR( "glGetUniformIndices is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetUniformIndices is not supported in OpenGL es 2.0\n");
}
- void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params ) override
+ void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
{
- DALI_LOG_ERROR( "glGetActiveUniformsiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetActiveUniformsiv is not supported in OpenGL es 2.0\n");
}
- GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName ) override
+ GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
{
- DALI_LOG_ERROR( "glGetUniformBlockIndex is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetUniformBlockIndex is not supported in OpenGL es 2.0\n");
return 0;
}
- void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) override
+ void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
{
- DALI_LOG_ERROR( "glGetActiveUniformBlockiv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetActiveUniformBlockiv is not supported in OpenGL es 2.0\n");
}
- void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName ) override
+ void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
{
- DALI_LOG_ERROR( "glGetActiveUniformBlockName is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetActiveUniformBlockName is not supported in OpenGL es 2.0\n");
}
- void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) override
+ void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
{
- DALI_LOG_ERROR( "glUniformBlockBinding is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glUniformBlockBinding is not supported in OpenGL es 2.0\n");
}
- void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount ) override
+ void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
{
- DALI_LOG_ERROR( "glDrawArraysInstanced is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDrawArraysInstanced is not supported in OpenGL es 2.0\n");
}
- void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount ) override
+ void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
{
- DALI_LOG_ERROR( "glDrawElementsInstanced is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDrawElementsInstanced is not supported in OpenGL es 2.0\n");
}
- GLsync FenceSync( GLenum condition, GLbitfield flags ) override
+ GLsync FenceSync(GLenum condition, GLbitfield flags) override
{
- DALI_LOG_ERROR( "glFenceSync is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glFenceSync is not supported in OpenGL es 2.0\n");
return NULL;
}
- GLboolean IsSync( GLsync sync ) override
+ GLboolean IsSync(GLsync sync) override
{
- DALI_LOG_ERROR( "glIsSync is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glIsSync is not supported in OpenGL es 2.0\n");
return 0;
}
- void DeleteSync( GLsync sync ) override
+ void DeleteSync(GLsync sync) override
{
- DALI_LOG_ERROR( "glDeleteSync is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDeleteSync is not supported in OpenGL es 2.0\n");
}
- GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
+ GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
{
- DALI_LOG_ERROR( "glClientWaitSync is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glClientWaitSync is not supported in OpenGL es 2.0\n");
return 0;
}
- void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
+ void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
{
- DALI_LOG_ERROR( "glWaitSync is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glWaitSync is not supported in OpenGL es 2.0\n");
}
- void GetInteger64v( GLenum pname, GLint64* params ) override
+ void GetInteger64v(GLenum pname, GLint64* params) override
{
- DALI_LOG_ERROR( "glGetInteger64v is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetInteger64v is not supported in OpenGL es 2.0\n");
}
- void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) override
+ void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
{
- DALI_LOG_ERROR( "glGetSynciv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetSynciv is not supported in OpenGL es 2.0\n");
}
- void GetInteger64i_v( GLenum target, GLuint index, GLint64* data ) override
+ void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
{
- DALI_LOG_ERROR( "glGetInteger64i_v is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetInteger64i_v is not supported in OpenGL es 2.0\n");
}
- void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params ) override
+ void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
{
- DALI_LOG_ERROR( "glGetBufferParameteri64v is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetBufferParameteri64v is not supported in OpenGL es 2.0\n");
}
- void GenSamplers( GLsizei count, GLuint* samplers ) override
+ void GenSamplers(GLsizei count, GLuint* samplers) override
{
- DALI_LOG_ERROR( "glGenSamplers is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGenSamplers is not supported in OpenGL es 2.0\n");
}
- void DeleteSamplers( GLsizei count, const GLuint* samplers ) override
+ void DeleteSamplers(GLsizei count, const GLuint* samplers) override
{
- DALI_LOG_ERROR( "glDeleteSamplers is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDeleteSamplers is not supported in OpenGL es 2.0\n");
}
- GLboolean IsSampler( GLuint sampler ) override
+ GLboolean IsSampler(GLuint sampler) override
{
- DALI_LOG_ERROR( "glIsSampler is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glIsSampler is not supported in OpenGL es 2.0\n");
return 0;
}
- void BindSampler( GLuint unit, GLuint sampler ) override
+ void BindSampler(GLuint unit, GLuint sampler) override
{
- DALI_LOG_ERROR( "glBindSampler is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBindSampler is not supported in OpenGL es 2.0\n");
}
- void SamplerParameteri( GLuint sampler, GLenum pname, GLint param ) override
+ void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
{
- DALI_LOG_ERROR( "glSamplerParameteri is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glSamplerParameteri is not supported in OpenGL es 2.0\n");
}
- void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param ) override
+ void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
{
- DALI_LOG_ERROR( "glSamplerParameteriv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glSamplerParameteriv is not supported in OpenGL es 2.0\n");
}
- void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) override
+ void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
{
- DALI_LOG_ERROR( "glSamplerParameterf is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glSamplerParameterf is not supported in OpenGL es 2.0\n");
}
- void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param ) override
+ void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
{
- DALI_LOG_ERROR( "glSamplerParameterfv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glSamplerParameterfv is not supported in OpenGL es 2.0\n");
}
- void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params ) override
+ void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
{
- DALI_LOG_ERROR( "glGetSamplerParameteriv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetSamplerParameteriv is not supported in OpenGL es 2.0\n");
}
- void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params ) override
+ void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
{
- DALI_LOG_ERROR( "glGetSamplerParameterfv is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetSamplerParameterfv is not supported in OpenGL es 2.0\n");
}
- void VertexAttribDivisor( GLuint index, GLuint divisor ) override
+ void VertexAttribDivisor(GLuint index, GLuint divisor) override
{
- DALI_LOG_ERROR( "glVertexAttribDivisor is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glVertexAttribDivisor is not supported in OpenGL es 2.0\n");
}
- void BindTransformFeedback( GLenum target, GLuint id ) override
+ void BindTransformFeedback(GLenum target, GLuint id) override
{
- DALI_LOG_ERROR( "glBindTransformFeedback is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glBindTransformFeedback is not supported in OpenGL es 2.0\n");
}
- void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids ) override
+ void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
{
- DALI_LOG_ERROR( "glDeleteTransformFeedbacks is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glDeleteTransformFeedbacks is not supported in OpenGL es 2.0\n");
}
- void GenTransformFeedbacks( GLsizei n, GLuint* ids ) override
+ void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
{
- DALI_LOG_ERROR( "glGenTransformFeedbacks is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGenTransformFeedbacks is not supported in OpenGL es 2.0\n");
}
- GLboolean IsTransformFeedback( GLuint id ) override
+ GLboolean IsTransformFeedback(GLuint id) override
{
- DALI_LOG_ERROR( "glIsTransformFeedback is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glIsTransformFeedback is not supported in OpenGL es 2.0\n");
return 0;
}
- void PauseTransformFeedback( void ) override
+ void PauseTransformFeedback(void) override
{
- DALI_LOG_ERROR( "glPauseTransformFeedback is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glPauseTransformFeedback is not supported in OpenGL es 2.0\n");
}
- void ResumeTransformFeedback( void ) override
+ void ResumeTransformFeedback(void) override
{
- DALI_LOG_ERROR( "glResumeTransformFeedback is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glResumeTransformFeedback is not supported in OpenGL es 2.0\n");
}
- void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary ) override
+ void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
{
- mGlExtensions.GetProgramBinaryOES( program, bufSize, length, binaryFormat, binary );
+ mGlExtensions.GetProgramBinaryOES(program, bufSize, length, binaryFormat, binary);
}
- void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length ) override
+ void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
{
- mGlExtensions.ProgramBinaryOES( program, binaryFormat, binary, length );
+ mGlExtensions.ProgramBinaryOES(program, binaryFormat, binary, length);
}
- void ProgramParameteri( GLuint program, GLenum pname, GLint value ) override
+ void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
{
- DALI_LOG_ERROR( "glProgramParameteri is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glProgramParameteri is not supported in OpenGL es 2.0\n");
}
- void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments ) override
+ void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
{
- mGlExtensions.DiscardFrameBuffer( target, numAttachments, attachments );
+ mGlExtensions.DiscardFrameBuffer(target, numAttachments, attachments);
}
- void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- DALI_LOG_ERROR( "glInvalidateSubFramebuffer is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glInvalidateSubFramebuffer is not supported in OpenGL es 2.0\n");
}
- void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
{
- DALI_LOG_ERROR( "glTexStorage2D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glTexStorage2D is not supported in OpenGL es 2.0\n");
}
- void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) override
+ void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
{
- DALI_LOG_ERROR( "glTexStorage3D is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glTexStorage3D is not supported in OpenGL es 2.0\n");
}
- void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) override
+ void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
{
- DALI_LOG_ERROR( "glGetInternalformativ is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("glGetInternalformativ is not supported in OpenGL es 2.0\n");
}
- void BlendBarrier( void ) override
+ void BlendBarrier(void) override
{
- DALI_LOG_ERROR( "BlendBarrier is not supported in OpenGL es 2.0\n" );
+ DALI_LOG_ERROR("BlendBarrier is not supported in OpenGL es 2.0\n");
}
private:
#define DALI_INTERNAL_GLES3_IMPLEMENTATION_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.
*
*/
- // EXTERNAL INCLUDES
+// EXTERNAL INCLUDES
#include <GLES3/gl3.h>
#include <GLES3/gl32.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class Gles3Implementation : public GlesAbstraction
{
-
public:
- Gles3Implementation() {}
+ Gles3Implementation()
+ {
+ }
- ~Gles3Implementation() override {}
+ ~Gles3Implementation() override
+ {
+ }
- void ReadBuffer( GLenum mode ) override
+ void ReadBuffer(GLenum mode) override
{
- glReadBuffer( mode );
+ glReadBuffer(mode);
}
- void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices ) override
+ void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
{
- glDrawRangeElements( mode, start, end, count, type, indices );
+ glDrawRangeElements(mode, start, end, count, type, indices);
}
- void TexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels ) override
+ void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
{
- glTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels );
+ glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
}
- void TexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels ) override
+ void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) override
{
- glTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels );
+ glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
}
- void CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- glCopyTexSubImage3D( target, level, xoffset, yoffset, zoffset, x, y, width, height );
+ glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
}
- void CompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data ) override
+ void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
{
- glCompressedTexImage3D( target, level, internalformat, width, height, depth, border, imageSize, data );
+ glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
}
- void CompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data ) override
+ void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) override
{
- glCompressedTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data );
+ glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
}
- void GenQueries( GLsizei n, GLuint* ids ) override
+ void GenQueries(GLsizei n, GLuint* ids) override
{
- glGenQueries( n, ids );
+ glGenQueries(n, ids);
}
- void DeleteQueries( GLsizei n, const GLuint* ids ) override
+ void DeleteQueries(GLsizei n, const GLuint* ids) override
{
- glDeleteQueries( n, ids );
+ glDeleteQueries(n, ids);
}
- GLboolean IsQuery( GLuint id ) override
+ GLboolean IsQuery(GLuint id) override
{
- return glIsQuery( id );
+ return glIsQuery(id);
}
- void BeginQuery( GLenum target, GLuint id ) override
+ void BeginQuery(GLenum target, GLuint id) override
{
- glBeginQuery( target, id );
+ glBeginQuery(target, id);
}
- void EndQuery( GLenum target ) override
+ void EndQuery(GLenum target) override
{
- glEndQuery( target );
+ glEndQuery(target);
}
- void GetQueryiv( GLenum target, GLenum pname, GLint* params ) override
+ void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
{
- glGetQueryiv( target, pname, params );
+ glGetQueryiv(target, pname, params);
}
- void GetQueryObjectuiv( GLuint id, GLenum pname, GLuint* params ) override
+ void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
{
- glGetQueryObjectuiv( id, pname, params );
+ glGetQueryObjectuiv(id, pname, params);
}
- GLboolean UnmapBuffer( GLenum target ) override
+ GLboolean UnmapBuffer(GLenum target) override
{
- return glUnmapBuffer( target );
+ return glUnmapBuffer(target);
}
- void GetBufferPointerv( GLenum target, GLenum pname, GLvoid** params ) override
+ void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
{
- glGetBufferPointerv( target, pname, params );
+ glGetBufferPointerv(target, pname, params);
}
- void DrawBuffers( GLsizei n, const GLenum* bufs ) override
+ void DrawBuffers(GLsizei n, const GLenum* bufs) override
{
- glDrawBuffers( n, bufs );
+ glDrawBuffers(n, bufs);
}
- void UniformMatrix2x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix2x3fv( location, count, transpose, value );
+ glUniformMatrix2x3fv(location, count, transpose, value);
}
- void UniformMatrix3x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix3x2fv( location, count, transpose, value );
+ glUniformMatrix3x2fv(location, count, transpose, value);
}
- void UniformMatrix2x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix2x4fv( location, count, transpose, value );
+ glUniformMatrix2x4fv(location, count, transpose, value);
}
- void UniformMatrix4x2fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix4x2fv( location, count, transpose, value );
+ glUniformMatrix4x2fv(location, count, transpose, value);
}
- void UniformMatrix3x4fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix3x4fv( location, count, transpose, value );
+ glUniformMatrix3x4fv(location, count, transpose, value);
}
- void UniformMatrix4x3fv( GLint location, GLsizei count, GLboolean transpose, const GLfloat* value ) override
+ void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
{
- glUniformMatrix4x3fv( location, count, transpose, value );
+ glUniformMatrix4x3fv(location, count, transpose, value);
}
- void BlitFramebuffer( GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter ) override
+ void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
{
- glBlitFramebuffer( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter );
+ glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
- void RenderbufferStorageMultisample( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
{
- glRenderbufferStorageMultisample( target, samples, internalformat, width, height );
+ glRenderbufferStorageMultisample(target, samples, internalformat, width, height);
}
- void FramebufferTextureLayer( GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer ) override
+ void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
{
- glFramebufferTextureLayer( target, attachment, texture, level, layer );
+ glFramebufferTextureLayer(target, attachment, texture, level, layer);
}
- GLvoid* MapBufferRange( GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access ) override
+ GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
{
- return glMapBufferRange( target, offset, length, access );
+ return glMapBufferRange(target, offset, length, access);
}
- void FlushMappedBufferRange( GLenum target, GLintptr offset, GLsizeiptr length ) override
+ void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
{
- glFlushMappedBufferRange( target, offset, length );
+ glFlushMappedBufferRange(target, offset, length);
}
- void BindVertexArray( GLuint array ) override
+ void BindVertexArray(GLuint array) override
{
- glBindVertexArray( array );
+ glBindVertexArray(array);
}
- void DeleteVertexArrays( GLsizei n, const GLuint* arrays ) override
+ void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
{
- glDeleteVertexArrays( n, arrays );
+ glDeleteVertexArrays(n, arrays);
}
- void GenVertexArrays( GLsizei n, GLuint* arrays ) override
+ void GenVertexArrays(GLsizei n, GLuint* arrays) override
{
- glGenVertexArrays( n, arrays );
+ glGenVertexArrays(n, arrays);
}
- GLboolean IsVertexArray( GLuint array ) override
+ GLboolean IsVertexArray(GLuint array) override
{
- return glIsVertexArray( array );
+ return glIsVertexArray(array);
}
- void GetIntegeri_v( GLenum target, GLuint index, GLint* data ) override
+ void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
{
- glGetIntegeri_v( target, index, data );
+ glGetIntegeri_v(target, index, data);
}
- void BeginTransformFeedback( GLenum primitiveMode ) override
+ void BeginTransformFeedback(GLenum primitiveMode) override
{
- glBeginTransformFeedback( primitiveMode );
+ glBeginTransformFeedback(primitiveMode);
}
- void EndTransformFeedback( void ) override
+ void EndTransformFeedback(void) override
{
glEndTransformFeedback();
}
- void BindBufferRange( GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size ) override
+ void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
{
- glBindBufferRange( target, index, buffer, offset, size );
+ glBindBufferRange(target, index, buffer, offset, size);
}
- void BindBufferBase( GLenum target, GLuint index, GLuint buffer ) override
+ void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
{
- glBindBufferBase( target, index, buffer );
+ glBindBufferBase(target, index, buffer);
}
- void TransformFeedbackVaryings( GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode ) override
+ void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
{
- glTransformFeedbackVaryings( program, count, varyings, bufferMode );
+ glTransformFeedbackVaryings(program, count, varyings, bufferMode);
}
- void GetTransformFeedbackVarying( GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name ) override
+ void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
{
- glGetTransformFeedbackVarying( program, index, bufSize, length, size, type, name );
+ glGetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
}
- void VertexAttribIPointer( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) override
+ void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
{
- glVertexAttribIPointer( index, size, type, stride, pointer );
+ glVertexAttribIPointer(index, size, type, stride, pointer);
}
- void GetVertexAttribIiv( GLuint index, GLenum pname, GLint* params ) override
+ void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
{
- glGetVertexAttribIiv( index, pname, params );
+ glGetVertexAttribIiv(index, pname, params);
}
- void GetVertexAttribIuiv( GLuint index, GLenum pname, GLuint* params ) override
+ void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
{
- glGetVertexAttribIuiv( index, pname, params );
+ glGetVertexAttribIuiv(index, pname, params);
}
- void VertexAttribI4i( GLuint index, GLint x, GLint y, GLint z, GLint w ) override
+ void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
{
- glVertexAttribI4i( index, x, y, z, w );
+ glVertexAttribI4i(index, x, y, z, w);
}
- void VertexAttribI4ui( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w ) override
+ void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
{
- glVertexAttribI4ui( index, x, y, z, w );
+ glVertexAttribI4ui(index, x, y, z, w);
}
- void VertexAttribI4iv( GLuint index, const GLint* v ) override
+ void VertexAttribI4iv(GLuint index, const GLint* v) override
{
- glVertexAttribI4iv( index, v );
+ glVertexAttribI4iv(index, v);
}
- void VertexAttribI4uiv( GLuint index, const GLuint* v ) override
+ void VertexAttribI4uiv(GLuint index, const GLuint* v) override
{
- glVertexAttribI4uiv( index, v );
+ glVertexAttribI4uiv(index, v);
}
- void GetUniformuiv( GLuint program, GLint location, GLuint* params ) override
+ void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
{
- glGetUniformuiv( program, location, params );
+ glGetUniformuiv(program, location, params);
}
- GLint GetFragDataLocation( GLuint program, const GLchar *name ) override
+ GLint GetFragDataLocation(GLuint program, const GLchar* name) override
{
- return glGetFragDataLocation( program, name );
+ return glGetFragDataLocation(program, name);
}
- void Uniform1ui( GLint location, GLuint v0 ) override
+ void Uniform1ui(GLint location, GLuint v0) override
{
- glUniform1ui( location, v0 );
+ glUniform1ui(location, v0);
}
- void Uniform2ui( GLint location, GLuint v0, GLuint v1 ) override
+ void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
{
- glUniform2ui( location, v0, v1 );
+ glUniform2ui(location, v0, v1);
}
- void Uniform3ui( GLint location, GLuint v0, GLuint v1, GLuint v2 ) override
+ void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
{
- glUniform3ui( location, v0, v1, v2 );
+ glUniform3ui(location, v0, v1, v2);
}
- void Uniform4ui( GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3 ) override
+ void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
{
- glUniform4ui( location, v0, v1, v2, v3 );
+ glUniform4ui(location, v0, v1, v2, v3);
}
- void Uniform1uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
{
- glUniform1uiv( location, count, value );
+ glUniform1uiv(location, count, value);
}
- void Uniform2uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
{
- glUniform2uiv( location, count, value );
+ glUniform2uiv(location, count, value);
}
- void Uniform3uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
{
- glUniform3uiv( location, count, value );
+ glUniform3uiv(location, count, value);
}
- void Uniform4uiv( GLint location, GLsizei count, const GLuint* value ) override
+ void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
{
- glUniform4uiv( location, count, value );
+ glUniform4uiv(location, count, value);
}
- void ClearBufferiv( GLenum buffer, GLint drawbuffer, const GLint* value ) override
+ void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
{
- glClearBufferiv( buffer, drawbuffer, value );
+ glClearBufferiv(buffer, drawbuffer, value);
}
- void ClearBufferuiv( GLenum buffer, GLint drawbuffer, const GLuint* value ) override
+ void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
{
- glClearBufferuiv( buffer, drawbuffer, value );
+ glClearBufferuiv(buffer, drawbuffer, value);
}
- void ClearBufferfv( GLenum buffer, GLint drawbuffer, const GLfloat* value ) override
+ void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
{
- glClearBufferfv( buffer, drawbuffer, value );
+ glClearBufferfv(buffer, drawbuffer, value);
}
- void ClearBufferfi( GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil ) override
+ void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
{
- glClearBufferfi( buffer, drawbuffer, depth, stencil );
+ glClearBufferfi(buffer, drawbuffer, depth, stencil);
}
- const GLubyte* GetStringi( GLenum name, GLuint index ) override
+ const GLubyte* GetStringi(GLenum name, GLuint index) override
{
- return glGetStringi( name, index );
+ return glGetStringi(name, index);
}
- void CopyBufferSubData( GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size ) override
+ void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
{
- glCopyBufferSubData( readTarget, writeTarget, readOffset, writeOffset, size );
+ glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
}
- void GetUniformIndices( GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices ) override
+ void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
{
- glGetUniformIndices( program, uniformCount, uniformNames, uniformIndices );
+ glGetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
}
- void GetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params ) override
+ void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
{
- glGetActiveUniformsiv( program, uniformCount, uniformIndices, pname, params );
+ glGetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
}
- GLuint GetUniformBlockIndex( GLuint program, const GLchar* uniformBlockName ) override
+ GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
{
- return glGetUniformBlockIndex( program, uniformBlockName );
+ return glGetUniformBlockIndex(program, uniformBlockName);
}
- void GetActiveUniformBlockiv( GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params ) override
+ void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
{
- glGetActiveUniformBlockiv( program, uniformBlockIndex, pname, params );
+ glGetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
}
- void GetActiveUniformBlockName( GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName ) override
+ void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
{
- glGetActiveUniformBlockName( program, uniformBlockIndex, bufSize, length, uniformBlockName );
+ glGetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
}
- void UniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding ) override
+ void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
{
- glUniformBlockBinding( program, uniformBlockIndex, uniformBlockBinding );
+ glUniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
}
- void DrawArraysInstanced( GLenum mode, GLint first, GLsizei count, GLsizei instanceCount ) override
+ void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
{
- glDrawArraysInstanced( mode, first, count, instanceCount );
+ glDrawArraysInstanced(mode, first, count, instanceCount);
}
- void DrawElementsInstanced( GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount ) override
+ void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
{
- glDrawElementsInstanced( mode, count, type, indices, instanceCount );
+ glDrawElementsInstanced(mode, count, type, indices, instanceCount);
}
- GLsync FenceSync( GLenum condition, GLbitfield flags ) override
+ GLsync FenceSync(GLenum condition, GLbitfield flags) override
{
- return glFenceSync( condition, flags );
+ return glFenceSync(condition, flags);
}
- GLboolean IsSync( GLsync sync ) override
+ GLboolean IsSync(GLsync sync) override
{
- return glIsSync( sync );
+ return glIsSync(sync);
}
- void DeleteSync( GLsync sync ) override
+ void DeleteSync(GLsync sync) override
{
- glDeleteSync( sync );
+ glDeleteSync(sync);
}
- GLenum ClientWaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
+ GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
{
- return glClientWaitSync( sync, flags, timeout );
+ return glClientWaitSync(sync, flags, timeout);
}
- void WaitSync( GLsync sync, GLbitfield flags, GLuint64 timeout ) override
+ void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
{
- glWaitSync( sync, flags, timeout );
+ glWaitSync(sync, flags, timeout);
}
- void GetInteger64v( GLenum pname, GLint64* params ) override
+ void GetInteger64v(GLenum pname, GLint64* params) override
{
- glGetInteger64v( pname, params );
+ glGetInteger64v(pname, params);
}
- void GetSynciv( GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values ) override
+ void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
{
- glGetSynciv( sync, pname, bufSize, length, values );
+ glGetSynciv(sync, pname, bufSize, length, values);
}
- void GetInteger64i_v( GLenum target, GLuint index, GLint64* data ) override
+ void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
{
- glGetInteger64i_v( target, index, data );
+ glGetInteger64i_v(target, index, data);
}
- void GetBufferParameteri64v( GLenum target, GLenum pname, GLint64* params ) override
+ void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
{
- glGetBufferParameteri64v( target, pname, params );
+ glGetBufferParameteri64v(target, pname, params);
}
- void GenSamplers( GLsizei count, GLuint* samplers ) override
+ void GenSamplers(GLsizei count, GLuint* samplers) override
{
- glGenSamplers( count, samplers );
+ glGenSamplers(count, samplers);
}
- void DeleteSamplers( GLsizei count, const GLuint* samplers ) override
+ void DeleteSamplers(GLsizei count, const GLuint* samplers) override
{
- glDeleteSamplers( count, samplers );
+ glDeleteSamplers(count, samplers);
}
- GLboolean IsSampler( GLuint sampler ) override
+ GLboolean IsSampler(GLuint sampler) override
{
- return glIsSampler( sampler );
+ return glIsSampler(sampler);
}
- void BindSampler( GLuint unit, GLuint sampler ) override
+ void BindSampler(GLuint unit, GLuint sampler) override
{
- glBindSampler( unit, sampler );
+ glBindSampler(unit, sampler);
}
- void SamplerParameteri( GLuint sampler, GLenum pname, GLint param ) override
+ void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
{
- glSamplerParameteri( sampler, pname, param );
+ glSamplerParameteri(sampler, pname, param);
}
- void SamplerParameteriv( GLuint sampler, GLenum pname, const GLint* param ) override
+ void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
{
- glSamplerParameteriv( sampler, pname, param );
+ glSamplerParameteriv(sampler, pname, param);
}
- void SamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) override
+ void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
{
- glSamplerParameterf( sampler, pname, param );
+ glSamplerParameterf(sampler, pname, param);
}
- void SamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat* param ) override
+ void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
{
- glSamplerParameterfv( sampler, pname, param );
+ glSamplerParameterfv(sampler, pname, param);
}
- void GetSamplerParameteriv( GLuint sampler, GLenum pname, GLint* params ) override
+ void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
{
- glGetSamplerParameteriv( sampler, pname, params );
+ glGetSamplerParameteriv(sampler, pname, params);
}
- void GetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat* params ) override
+ void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
{
- glGetSamplerParameterfv( sampler, pname, params );
+ glGetSamplerParameterfv(sampler, pname, params);
}
- void VertexAttribDivisor( GLuint index, GLuint divisor ) override
+ void VertexAttribDivisor(GLuint index, GLuint divisor) override
{
- glVertexAttribDivisor( index, divisor );
+ glVertexAttribDivisor(index, divisor);
}
- void BindTransformFeedback( GLenum target, GLuint id ) override
+ void BindTransformFeedback(GLenum target, GLuint id) override
{
- glBindTransformFeedback( target, id );
+ glBindTransformFeedback(target, id);
}
- void DeleteTransformFeedbacks( GLsizei n, const GLuint* ids ) override
+ void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
{
- glDeleteTransformFeedbacks( n, ids );
+ glDeleteTransformFeedbacks(n, ids);
}
- void GenTransformFeedbacks( GLsizei n, GLuint* ids ) override
+ void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
{
- glGenTransformFeedbacks( n, ids );
+ glGenTransformFeedbacks(n, ids);
}
- GLboolean IsTransformFeedback( GLuint id ) override
+ GLboolean IsTransformFeedback(GLuint id) override
{
- return glIsTransformFeedback( id );
+ return glIsTransformFeedback(id);
}
- void PauseTransformFeedback( void ) override
+ void PauseTransformFeedback(void) override
{
glPauseTransformFeedback();
}
- void ResumeTransformFeedback( void ) override
+ void ResumeTransformFeedback(void) override
{
glResumeTransformFeedback();
}
- void GetProgramBinary( GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary ) override
+ void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
{
- glGetProgramBinary( program, bufSize, length, binaryFormat, binary );
+ glGetProgramBinary(program, bufSize, length, binaryFormat, binary);
}
- void ProgramBinary( GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length ) override
+ void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
{
- glProgramBinary( program, binaryFormat, binary, length );
+ glProgramBinary(program, binaryFormat, binary, length);
}
- void ProgramParameteri( GLuint program, GLenum pname, GLint value ) override
+ void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
{
- glProgramParameteri( program, pname, value );
+ glProgramParameteri(program, pname, value);
}
- void InvalidateFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments ) override
+ void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
{
- glInvalidateFramebuffer( target, numAttachments, attachments );
+ glInvalidateFramebuffer(target, numAttachments, attachments);
}
- void InvalidateSubFramebuffer( GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height ) override
+ void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
{
- glInvalidateSubFramebuffer( target, numAttachments, attachments, x, y, width, height );
+ glInvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
}
- void TexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height ) override
+ void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
{
- glTexStorage2D( target, levels, internalformat, width, height );
+ glTexStorage2D(target, levels, internalformat, width, height);
}
- void TexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth ) override
+ void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
{
- glTexStorage3D( target, levels, internalformat, width, height, depth );
+ glTexStorage3D(target, levels, internalformat, width, height, depth);
}
- void GetInternalformativ( GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params ) override
+ void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
{
- glGetInternalformativ( target, internalformat, pname, bufSize, params );
+ glGetInternalformativ(target, internalformat, pname, bufSize, params);
}
- void BlendBarrier( void ) override
+ void BlendBarrier(void) override
{
if(!mGlExtensions.BlendBarrierKHR())
{
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-implementation.h>
+
+namespace Dali::Internal::Adaptor
+{
+EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
+: mEglImplementation(eglImpl),
+ mImageKHRInitialized(false),
+ mImageKHRInitializeFailed(false)
+{
+ DALI_ASSERT_ALWAYS(eglImpl && "EGL Implementation not instantiated");
+}
+
+EglImageExtensions::~EglImageExtensions()
+{
+}
+
+void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
+{
+ DALI_LOG_ERROR(" does not support CreateImageKHR\n");
+ return NULL;
+}
+
+void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
+{
+ DALI_LOG_ERROR(" does not support DestroyImageKHR\n");
+}
+
+void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
+{
+ DALI_LOG_ERROR(" does not support TargetTextureKHR\n");
+}
+
+void EglImageExtensions::InitializeEglImageKHR()
+{
+ DALI_LOG_ERROR(" does not support InitializeEglImageKHR\n");
+}
+
+} // namespace Dali::Internal::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
#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)
{
}
#define DALI_INTERNAL_FEEDBACK_PLAYER_H
/*
- * 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 <string>
#include <dali/public-api/object/base-object.h>
+#include <string>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/feedback-player.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class FeedbackPluginProxy;
/**
*/
class FeedbackPlayer : public Dali::BaseObject
{
-
public:
-
/**
* Create a FeedbackPlayer.
* This should only be called once by the Adaptor class.
/**
* @copydoc Dali::FeedbackPlayer::PlayFile()
*/
- void PlayFile( const std::string& filePath );
+ void PlayFile(const std::string& filePath);
/**
* @copydoc Dali::FeedbackPlayer::Stop()
/**
* @copydoc Dali::FeedbackPlayer::PlaySound()
*/
- int PlaySound( const std::string& fileName );
+ int PlaySound(const std::string& fileName);
/**
* @copydoc Dali::FeedbackPlayer::StopSound()
*/
- void StopSound( int handle );
+ void StopSound(int handle);
/**
* @copydoc Dali::FeedbackPlayer::PlayFeedbackPattern()
*/
- void PlayFeedbackPattern( int type, int pattern );
+ void PlayFeedbackPattern(int type, int pattern);
/**
* @copydoc Dali::FeedbackPlayer::LoadFile()
bool LoadFile(const std::string& filename, std::string& data);
private:
-
/**
* Private Constructor; see also FeedbackPlayer::New()
*/
FeedbackPlayer& operator=(FeedbackPlayer&);
private:
-
FeedbackPluginProxy mPlugin;
};
inline Internal::Adaptor::FeedbackPlayer& GetImplementation(Dali::FeedbackPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "FeedbackPlayer handle is empty" );
+ DALI_ASSERT_ALWAYS(player && "FeedbackPlayer handle is empty");
BaseObject& handle = player.GetBaseObject();
inline const Internal::Adaptor::FeedbackPlayer& GetImplementation(const Dali::FeedbackPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "FeedbackPlayer handle is empty" );
+ DALI_ASSERT_ALWAYS(player && "FeedbackPlayer handle is empty");
const BaseObject& handle = player.GetBaseObject();
#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;
}
#define DALI_INTERNAL_FEEDBACK_PLUGIN_PROXY_H
/*
- * 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
{
-
-typedef Dali::FeedbackPlugin::SoundStopCallBack SoundStopCallBack;
+typedef Dali::FeedbackPlugin::SoundStopCallBack SoundStopCallBack;
typedef Dali::FeedbackPlugin::CreateFeedbackPlugin CreateFeedbackPlugin;
/**
class FeedbackPluginProxy
{
public:
-
/**
* The default feedback plugin proxy.
*/
- static const char * const DEFAULT_OBJECT_NAME;
+ static const char* const DEFAULT_OBJECT_NAME;
public:
-
/**
* Constructor.
*/
- FeedbackPluginProxy( const std::string& sharedObjectName );
+ FeedbackPluginProxy(const std::string& sharedObjectName);
/**
* The destructor
/**
* @copydoc Dali::Integration::FeedbackPlugin::PlayHaptic()
*/
- void PlayHaptic( const std::string& filePath );
+ void PlayHaptic(const std::string& filePath);
/**
* @copydoc Dali::FeedbackPlugin::PlayHapticMonotone()
*/
- void PlayHapticMonotone( unsigned int duration );
+ void PlayHapticMonotone(unsigned int duration);
/**
* @copydoc Dali::FeedbackPlugin::StopHaptic()
/**
* @copydoc Dali::FeedbackPlugin::PlaySound()
*/
- int PlaySound( const std::string& fileName );
+ int PlaySound(const std::string& fileName);
/**
* @copydoc Dali::FeedbackPlugin::StopSound()
*/
- void StopSound( int handle );
+ void StopSound(int handle);
/**
* @copydoc Dali::FeedbackPlugin::PlayFeedbackPattern()
*/
- void PlayFeedbackPattern( int type, int pattern );
+ void PlayFeedbackPattern(int type, int pattern);
private:
-
/**
* Dynamically loads the feedback plugin.
*/
void Initialize();
private:
-
- bool mInitializeAttempted;
- void* mLibHandle;
- std::string mSharedObjectName;
+ bool mInitializeAttempted;
+ void* mLibHandle;
+ std::string mSharedObjectName;
CreateFeedbackPlugin* mCreatePluginFunctionPtr;
Dali::FeedbackPlugin* mFeedbackPlugin;
};
/*
- * 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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_ANDROID_H
/*
- * 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
{
-
class NativeImageSourceFactoryAndroid : public NativeImageSourceFactory
{
public:
+ std::unique_ptr<NativeImageSource> CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) override;
- std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
-
- std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
-
+ std::unique_ptr<NativeImageSourceQueue> CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue) override;
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_ANDROID_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.
// 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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_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 Internal
{
-
namespace Adaptor
{
class EglImageExtensions;
class NativeImageSourceAndroid : public Internal::Adaptor::NativeImageSource
{
public:
-
/**
* Create a new NativeImageSource internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSource contains either: Android hardware buffer or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceAndroid* New( uint32_t width,
- uint32_t height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ static NativeImageSourceAndroid* New(uint32_t width,
+ uint32_t height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
*/
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override;
+ bool GetPixels(std::vector<unsigned char>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- void SetSource( Any source ) override;
+ void SetSource(Any source) override;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
+ bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) override;
/**
* destructor
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
*/
- uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
+ uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
bool ReleaseBuffer() override;
private:
-
/**
* Private constructor; @see NativeImageSource::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- NativeImageSourceAndroid( uint32_t width,
- uint32_t height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ NativeImageSourceAndroid(uint32_t width,
+ uint32_t height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* 2nd phase construction.
void GetPixmapDetails();
private:
-
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image heights
- bool mOwnPixmap; ///< Whether we created pixmap or not
- AHardwareBuffer* mPixmap; ///<
- bool mBlendingRequired; ///< Whether blending is required
- Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
- void* mEglImageKHR; ///< From EGL extension
- EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ AHardwareBuffer* mPixmap; ///<
+ bool mBlendingRequired; ///< Whether blending is required
+ Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
+ void* mEglImageKHR; ///< From EGL extension
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
};
} // 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/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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_ANDROID_H
/*
- * 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 EglGraphics;
class EglImageExtensions;
/**
* Dali internal NativeImageSourceQueue.
*/
-class NativeImageSourceQueueAndroid: public Internal::Adaptor::NativeImageSourceQueue
+class NativeImageSourceQueueAndroid : public Internal::Adaptor::NativeImageSourceQueue
{
public:
-
/**
* Create a new NativeImageSourceQueueAndroid internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceQueueAndroid* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ static NativeImageSourceQueueAndroid* New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
/**
* @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
/**
* @copydoc Dali::NativeImageSourceQueue::SetSize
*/
- void SetSize( uint32_t width, uint32_t height ) override;
+ void SetSize(uint32_t width, uint32_t height) override;
/**
* @copydoc Dali::NativeImageSourceQueue::IgnoreSourceImage
bool SourceChanged() const override;
private:
-
/**
* Private constructor; @see NativeImageSourceQueue::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
*/
- NativeImageSourceQueueAndroid( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ NativeImageSourceQueueAndroid(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
private:
-
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image height
-
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image height
};
} // 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.
* 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
#define DALI_INTERNAL_ADAPTOR_ALPHA_MASK_H
/*
- * 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
{
-
/**
* Apply the mask to a buffer's alpha channel
* @param[in] buffer The buffer to apply the mask to
* @param[in] mask The mask to apply
*/
-void ApplyMaskToAlphaChannel( PixelBuffer& buffer, const PixelBuffer& mask );
+void ApplyMaskToAlphaChannel(PixelBuffer& buffer, const PixelBuffer& mask);
/**
* Create a new PixelBuffer with an alpha channel large enough to handle the alpha from
* @param[in] mask The mask to apply
* @return A new pixel buffer containing the masked image
*/
-PixelBufferPtr CreateNewMaskedBuffer( const PixelBuffer& buffer, const PixelBuffer& mask );
+PixelBufferPtr CreateNewMaskedBuffer(const PixelBuffer& buffer, const PixelBuffer& mask);
} //namespace Adaptor
} //namespace Internal
#define DALI_INTERNAL_ANIMATED_IMAGE_LOADING_IMPL_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.
*/
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/math/uint-16-pair.h>
-#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/devel-api/adaptor-framework/animated-image-loading.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
class AnimatedImageLoading;
typedef IntrusivePtr<AnimatedImageLoading> AnimatedImageLoadingPtr;
class AnimatedImageLoading : public BaseObject
{
public:
-
/**
* @copydoc Dali::AnimatedImageLoading::New()
*/
- static AnimatedImageLoadingPtr New( const std::string& url, bool isLocalResource );
+ static AnimatedImageLoadingPtr New(const std::string& url, bool isLocalResource);
AnimatedImageLoading() = default;
// Moveable but not copyable
- AnimatedImageLoading( const AnimatedImageLoading& );
- AnimatedImageLoading& operator=( const AnimatedImageLoading& );
- AnimatedImageLoading( AnimatedImageLoading&& ) = default;
- AnimatedImageLoading& operator=( AnimatedImageLoading&& ) = default;
+ AnimatedImageLoading(const AnimatedImageLoading&);
+ AnimatedImageLoading& operator =(const AnimatedImageLoading&);
+ AnimatedImageLoading(AnimatedImageLoading&&) = default;
+ AnimatedImageLoading& operator=(AnimatedImageLoading&&) = default;
/**
* @brief Destructor
/**
* @copydoc Dali::AnimatedImageLoading::LoadNextNFrames()
*/
- virtual bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData ) = 0;
+ virtual bool LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData) = 0;
/**
* @copydoc Dali::AnimatedImageLoading::LoadFrame()
*/
- virtual Dali::Devel::PixelBuffer LoadFrame( uint32_t frameIndex ) = 0;
+ virtual Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex) = 0;
/**
* @copydoc Dali::AnimatedImageLoading::GetImageSize()
/**
* @copydoc Dali::AnimatedImageLoading::LoadFrameDelays()
*/
- virtual uint32_t GetFrameInterval( uint32_t frameIndex ) const = 0;
+ virtual uint32_t GetFrameInterval(uint32_t frameIndex) const = 0;
/**
* @copydoc Dali::AnimatedImageLoading::GetUrl()
// Helpers for api forwarding methods
-inline Internal::Adaptor::AnimatedImageLoading& GetImplementation( Dali::AnimatedImageLoading& handle)
+inline Internal::Adaptor::AnimatedImageLoading& GetImplementation(Dali::AnimatedImageLoading& handle)
{
- DALI_ASSERT_ALWAYS( handle && "AnimatedImageLoading handle is empty" );
+ DALI_ASSERT_ALWAYS(handle && "AnimatedImageLoading handle is empty");
BaseObject& object = handle.GetBaseObject();
- return static_cast< Internal::Adaptor::AnimatedImageLoading& >( object );
+ return static_cast<Internal::Adaptor::AnimatedImageLoading&>(object);
}
-inline const Internal::Adaptor::AnimatedImageLoading& GetImplementation( const Dali::AnimatedImageLoading& handle )
+inline const Internal::Adaptor::AnimatedImageLoading& GetImplementation(const Dali::AnimatedImageLoading& handle)
{
- DALI_ASSERT_ALWAYS( handle && "AnimatedImageLoading handle is empty" );
+ DALI_ASSERT_ALWAYS(handle && "AnimatedImageLoading handle is empty");
const BaseObject& object = handle.GetBaseObject();
- return static_cast< const Internal::Adaptor::AnimatedImageLoading& >( object );
+ return static_cast<const Internal::Adaptor::AnimatedImageLoading&>(object);
}
} // 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;
}
#define DALI_TIZEN_PLATFORM_NETWORK_FILE_DOWNLOAD_H
/*
- * 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/public-api/common/dali-vector.h>
-#include <string>
-#include <mutex> //c++11
#include <stdint.h> // uint8
+#include <mutex> //c++11
+#include <string>
namespace Dali
{
-
namespace TizenPlatform
{
-
namespace Network
{
-
/**
* Set up the cURL environment - this will ensure curl_global_init is called on startup
* and curl_global_cleanup is called on shutdown.
// Moveable but not copyable
- CurlEnvironment( const CurlEnvironment& ) = delete;
- CurlEnvironment& operator=( const CurlEnvironment& ) = delete;
- CurlEnvironment( CurlEnvironment&& ) = default;
- CurlEnvironment& operator=( CurlEnvironment&& ) = default;
+ CurlEnvironment(const CurlEnvironment&) = delete;
+ CurlEnvironment& operator=(const CurlEnvironment&) = delete;
+ CurlEnvironment(CurlEnvironment&&) = default;
+ CurlEnvironment& operator=(CurlEnvironment&&) = default;
};
-
/**
* Download a requested file into a memory buffer.
*
* @return true on success, false on failure
*
*/
-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);
} // namespace Network
/*
- * 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
#define DALI_INTERNAL_ADAPTOR_GAUSSIAN_BLUR_H
/*
- * 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
{
-
/**
* Perform a one dimension Gaussian blur convolution and write its output buffer transposed.
*
* @param[in] bufferHeight The height of the buffer
* @param[in] blurRadius The radius for Gaussian blur
*/
-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);
/**
* Perform Gaussian blur on a buffer.
* @param[in] buffer The buffer to apply the Gaussian blur to
* @param[in] blurRadius The radius for Gaussian blur
*/
-void PerformGaussianBlurRGBA( PixelBuffer& buffer, const float blurRadius );
+void PerformGaussianBlurRGBA(PixelBuffer& buffer, const float blurRadius);
} //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/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;
}
#define DALI_INTERNAL_GIF_LOADING_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.
*
*/
// EXTERNAL INCLUDES
-#include <cstdint>
-#include <memory>
-#include <dali/public-api/math/rect.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/uint-16-pair.h>
+#include <cstdint>
+#include <memory>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/internal/imaging/common/animated-image-loading-impl.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Class to manage loading frames of an animated gif in small chunks. Lazy initializes only when
* data is actually needed.
* is released. (This is to speed up frame loads, which would otherwise have to re-acquire the
* data from disk)
*/
-class GifLoading: public Internal::Adaptor::AnimatedImageLoading
+class GifLoading : public Internal::Adaptor::AnimatedImageLoading
{
public:
-
/**
* Create a GifLoading with the given url and resourceType.
* @param[in] url The url of the gif image to load
* @param[in] isLocalResource The true or false whether this is a local resource.
* @return A newly created GifLoading.
*/
- static AnimatedImageLoadingPtr New( const std::string& url, bool isLocalResource );
+ static AnimatedImageLoadingPtr New(const std::string& url, bool isLocalResource);
/**
* @brief Constructor
* @param[in] url The url of the gif image to load
* @param[in] isLocalResource The true or false whether this is a local resource.
*/
- GifLoading( const std::string& url, bool isLocalResource );
+ GifLoading(const std::string& url, bool isLocalResource);
/**
* @brief Destructor
* @param[out] pixelData The vector in which to return the frame data
* @return True if the frame data was successfully loaded
*/
- bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData ) override;
+ bool LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData) override;
- /**
+ /**
* @brief Load the next Frame of the animated image.
*
* @note This function will load the entire animated image into memory if not already loaded.
* @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle.
*/
- Dali::Devel::PixelBuffer LoadFrame( uint32_t frameIndex ) override;
+ Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex) override;
/**
* @brief Get the size of a gif image.
*
* @return The time interval of the frame(microsecond).
*/
- uint32_t GetFrameInterval( uint32_t frameIndex ) const override;
+ uint32_t GetFrameInterval(uint32_t frameIndex) const override;
/**
* @brief Get the animated image file URL
/*
- * 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
#define DALI_TIZEN_PLATFORM_NETWORK_UTILS_H
/*
- * 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
{
-
namespace Network
{
-
/**
* @brief Tests if a string starts with either http:// or https://
* @param[in] path string
* @return true if the path is a http url
*/
-bool IsHttpUrl( const std::string& path );
+bool IsHttpUrl(const std::string& path);
-} // Network
+} // namespace Network
} // 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/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
#define DALI_INTERNAL_IMAGE_LOADING_PLUGIN_PROXY_H
/*
- * 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 ImageLoaderPluginProxy
{
+using CreateImageLoaderPlugin = Dali::ImageLoaderPlugin::CreateImageLoaderPlugin;
+using DestroyImageLoaderPlugin = Dali::ImageLoaderPlugin::DestroyImageLoaderPlugin;
- using CreateImageLoaderPlugin = Dali::ImageLoaderPlugin::CreateImageLoaderPlugin;
- using DestroyImageLoaderPlugin = Dali::ImageLoaderPlugin::DestroyImageLoaderPlugin;
-
-
- /**
+/**
* @brief Initialize
*/
- void Initialize();
-
+void Initialize();
- /**
+/**
* @brief Destroy
*/
- void Destroy();
+void Destroy();
- /**
+/**
* @brief BitmapLoaderLookup
*/
- const ImageLoader::BitmapLoader* BitmapLoaderLookup( const std::string& filename );
-
+const ImageLoader::BitmapLoader* BitmapLoaderLookup(const std::string& filename);
} // namespace ImageLoaderPluginProxy
/*
- * 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
#define DALI_TIZEN_PLATFORM_IMAGE_LOADER_H
/*
- * 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/public-api/images/image-operations.h>
-#include <dali/integration-api/resource-types.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/bitmap.h>
+#include <dali/integration-api/resource-types.h>
+#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/images/pixel-data.h>
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <string>
namespace Dali
namespace Integration
{
typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
-} // Integration
+} // namespace Integration
namespace TizenPlatform
{
* @param[out] bitmap Pointer to write bitmap to
* @return true on success, false on failure
*/
-bool ConvertStreamToBitmap( const Integration::BitmapResourceType& resource, std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer );
+bool ConvertStreamToBitmap(const Integration::BitmapResourceType& resource, std::string path, FILE* const fp, Dali::Devel::PixelBuffer& pixelBuffer);
/**
* Convert a bitmap and write to a file stream.
* @param[out] pixelData Reference to PixelData object.
* @return true on success, false on failure
*/
-bool ConvertBitmapToStream( std::string path, FILE * const fp, Dali::Devel::PixelBuffer& pixelBuffer );
+bool ConvertBitmapToStream(std::string path, FILE* const fp, Dali::Devel::PixelBuffer& pixelBuffer);
/**
* Loads an image synchronously
* @param path to the image
* @return bitmap
*/
-Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path );
+Integration::ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& path);
/**
* @returns the closest image size
*/
-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);
/**
* @returns the closest image size
*/
-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);
/**
* @brief Set the maximum texture size. Then size can be kwown by GL_MAX_TEXTURE_SIZE.
*
* @param [in] size The maximum texture size to set
*/
-void SetMaxTextureSize( unsigned int size );
+void SetMaxTextureSize(unsigned int size);
/**
* @brief Get the maximum texture size.
*/
bool MaxTextureSizeUpdated();
-} // ImageLoader
-} // TizenPlatform
-} // Dali
+} // namespace ImageLoader
+} // namespace TizenPlatform
+} // namespace Dali
#endif // DALI_TIZEN_PLATFORM_IMAGE_LOADER_H
/*
- * 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) 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 <stdint.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/integration-api/bitmap.h>
#include <dali/public-api/images/image-operations.h>
#include <third-party/resampler/resampler.h>
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
namespace Dali
{
{
namespace Platform
{
-
/**
* @brief Identify which combination of x and y dimensions matter in terminating iterative box filtering.
*/
* @param[in] requestedDimensions Width and 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( ImageDimensions rawDimensions, ImageDimensions requestedDimensions );
+ImageDimensions CalculateDesiredDimensions(ImageDimensions rawDimensions, ImageDimensions requestedDimensions);
/**
* @defgroup BitmapOperations Bitmap-to-Bitmap Image operations.
* bitmap passed-in, or the original bitmap passed in if the attributes
* have no effect.
*/
-Dali::Devel::PixelBuffer ApplyAttributesToBitmap( Dali::Devel::PixelBuffer bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode = FittingMode::DEFAULT, SamplingMode::Type samplingMode = SamplingMode::DEFAULT );
+Dali::Devel::PixelBuffer ApplyAttributesToBitmap(Dali::Devel::PixelBuffer bitmap, ImageDimensions dimensions, FittingMode::Type fittingMode = FittingMode::DEFAULT, SamplingMode::Type samplingMode = SamplingMode::DEFAULT);
/**
* @brief Apply downscaling to a bitmap according to requested attributes.
* @note The input bitmap pixel buffer may be modified and used as scratch working space for efficiency, so it must be discarded.
**/
-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);
/**@}*/
/**
* @param[out] outWidth The resulting width after downscaling.
* @param[out] outHeight The resulting height after downscaling.
*/
-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 );
+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);
/**
* @brief Destructive in-place downscaling by a power of 2 factor.
* @param[out] outWidth The resulting width after downscaling.
* @param[out] outHeight The resulting height after downscaling.
*/
-void DownscaleInPlacePow2RGB888( unsigned char * pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned int& outWidth,
- unsigned int& outHeight );
+void DownscaleInPlacePow2RGB888(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned int& outWidth,
+ unsigned int& outHeight);
/**
* @copydoc DownscaleInPlacePow2RGB888
*/
-void DownscaleInPlacePow2RGBA8888( unsigned char * pixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned int desiredWidth,
- unsigned int desiredHeight,
- BoxDimensionTest dimensionTest,
- unsigned int& outWidth,
- unsigned int& outHeight );
+void DownscaleInPlacePow2RGBA8888(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned int& outWidth,
+ unsigned int& outHeight);
/**
* @copydoc DownscaleInPlacePow2RGB888
*
* For the 2-byte packed 16 bit format RGB565.
*/
-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);
/**
* @copydoc DownscaleInPlacePow2RGB888
*
* 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 int& outWidth,
- unsigned int& outHeight );
+void DownscaleInPlacePow2ComponentPair(unsigned char* pixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight,
+ BoxDimensionTest dimensionTest,
+ unsigned int& outWidth,
+ unsigned int& outHeight);
/**
* @copydoc DownscaleInPlacePow2RGB888
*
* For single-byte formats such as lum8 or alpha8.
*/
-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);
/**
* @brief Rescales an input image into the exact output dimensions passed-in.
* @note inPixels is allowed to alias outPixels if this is a downscaling,
* but not for upscaling.
*/
-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);
/**
* @copydoc PointSample
*
* Specialised for 4-byte formats like RGBA8888 and BGRA8888.
*/
-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);
/**
* @copydoc PointSample
*
* Specialised for 3-byte formats like RGB888 and BGR888.
*/
-void PointSample3BPP( const unsigned char * inPixels,
- unsigned int inputWidth,
- unsigned int inputHeight,
- unsigned char * outPixels,
- unsigned int desiredWidth,
- unsigned int desiredHeight );
+void PointSample3BPP(const unsigned char* inPixels,
+ unsigned int inputWidth,
+ unsigned int inputHeight,
+ unsigned char* outPixels,
+ unsigned int desiredWidth,
+ unsigned int desiredHeight);
/**
* @copydoc PointSample
*
* Specialised for 2-byte formats like 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);
/**
* @copydoc PointSample
*
* Specialised for 1-byte formats like L8 and 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);
/**
* @brief Resample input image to output image using a bilinear filter.
* @pre inPixels must not alias outPixels. The input image should be a totally
* separate buffer from the input one.
*/
-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);
/**
* @copydoc LinearSample
*
* Specialised for one byte per pixel formats.
*/
-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);
/**
* @copydoc LinearSample
*
* Specialised for two byte per pixel formats.
*/
-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);
/**
* @copydoc LinearSample
*
* Specialised for RGB565 16 bit pixel format.
*/
-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);
/**
* @copydoc LinearSample
*
* Specialised for three byte per pixel formats like RGB888.
*/
-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);
/**
* @copydoc LinearSample
* Specialised for four byte per pixel formats like RGBA8888.
* @note, If used on RGBA8888, the A component will be blended independently.
*/
-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);
/**
* @brief Resamples the input image with the Lanczos algorithm.
* @param[out] outPixels Pointer to the output image buffer.
* @param[in] desiredDimensions The output dimensions of the image.
*/
-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);
/**
* @brief Resamples the input image with the Lanczos algorithm.
* @param[out] outPixels Pointer to the output image buffer.
* @param[in] desiredDimensions The output dimensions of the image.
*/
-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);
/**
* @brief Resamples the input image with the Lanczos algorithm.
* @param[out] outPixels Pointer to the output image buffer.
* @param[in] desiredDimensions The output dimensions of the image.
*/
-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);
/**
* @brief Rotates the input image with an implementation of the 'Rotate by Shear' algorithm.
* @param[out] widthOut The width of the output buffer.
* @param[out] heightOut The height of the output buffer.
*/
-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);
/**
* @brief Applies to the input image a horizontal shear transformation.
* @param[out] widthOut The width of the output buffer.
* @param[out] heightOut The height of the output buffer.
*/
-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);
/**@}*/
* @param[in,out] pixels The array of pixels to work on.
* @param[i] width The number of pixels in the array passed-in.
*/
-void HalveScanlineInPlaceRGB888( unsigned char * pixels, unsigned int width );
+void HalveScanlineInPlaceRGB888(unsigned char* pixels, unsigned int width);
/**
* @copydoc HalveScanlineInPlaceRGB888
*/
-void HalveScanlineInPlaceRGBA8888( unsigned char * pixels, unsigned int width );
+void HalveScanlineInPlaceRGBA8888(unsigned char* pixels, unsigned int width);
/**
* @copydoc HalveScanlineInPlaceRGB888
*/
-void HalveScanlineInPlaceRGB565( unsigned char * pixels, unsigned int width );
+void HalveScanlineInPlaceRGB565(unsigned char* pixels, unsigned int width);
/**
* @copydoc HalveScanlineInPlaceRGB888
*/
-void HalveScanlineInPlace2Bytes( unsigned char * pixels, unsigned int width );
+void HalveScanlineInPlace2Bytes(unsigned char* pixels, unsigned int width);
/**
* @copydoc HalveScanlineInPlaceRGB888
*/
-void HalveScanlineInPlace1Byte( unsigned char * pixels, unsigned int width );
+void HalveScanlineInPlace1Byte(unsigned char* pixels, unsigned int width);
/**
* @brief Average pixels at corresponding offsets in two scanlines.
* @param[out] outputScanline Destination for the averaged pixels.
* @param[in] width The widths of all the scanlines passed-in.
*/
-void AverageScanlines1( const unsigned char * scanline1,
- const unsigned char * scanline2,
- unsigned char* outputScanline,
- /** Image width in pixels (1 byte == 1 pixel: e.g. lum8 or alpha8).*/
- unsigned int width );
+void AverageScanlines1(const unsigned char* scanline1,
+ const unsigned char* scanline2,
+ unsigned char* outputScanline,
+ /** Image width in pixels (1 byte == 1 pixel: e.g. lum8 or alpha8).*/
+ unsigned int width);
/**
* @copydoc AverageScanlines1
*/
-void AverageScanlines2( const unsigned char * scanline1,
- const unsigned char * scanline2,
- unsigned char* outputScanline,
- /** Image width in pixels (2 bytes == 1 pixel: e.g. lum8alpha8).*/
- unsigned int width );
+void AverageScanlines2(const unsigned char* scanline1,
+ const unsigned char* scanline2,
+ unsigned char* outputScanline,
+ /** Image width in pixels (2 bytes == 1 pixel: e.g. lum8alpha8).*/
+ unsigned int width);
/**
* @copydoc AverageScanlines1
*/
-void AverageScanlines3( const unsigned char * scanline1,
- const unsigned char * scanline2,
- unsigned char* outputScanline,
- /** Image width in pixels (3 bytes == 1 pixel: e.g. RGB888).*/
- unsigned int width );
+void AverageScanlines3(const unsigned char* scanline1,
+ const unsigned char* scanline2,
+ unsigned char* outputScanline,
+ /** Image width in pixels (3 bytes == 1 pixel: e.g. RGB888).*/
+ unsigned int width);
/**
* @copydoc AverageScanlines1
*/
-void AverageScanlinesRGBA8888( const unsigned char * scanline1,
- const unsigned char * scanline2,
- unsigned char * outputScanline,
- unsigned int width );
+void AverageScanlinesRGBA8888(const unsigned char* scanline1,
+ const unsigned char* scanline2,
+ unsigned char* outputScanline,
+ unsigned int width);
/**
* @copydoc AverageScanlines1
*/
-void AverageScanlinesRGB565( const unsigned char * scanline1,
- const unsigned char * scanline2,
- unsigned char* outputScanline,
- unsigned int width );
+void AverageScanlinesRGB565(const unsigned char* scanline1,
+ const unsigned char* scanline2,
+ unsigned char* outputScanline,
+ unsigned int width);
/**@}*/
/**
* @param[in] a First component to average.
* @param[in] b Second component to average.
**/
-inline unsigned int AverageComponent( unsigned int a, unsigned int b )
+inline unsigned int AverageComponent(unsigned int a, unsigned int b)
{
unsigned int avg = (a + b) >> 1u;
return avg;
* @param[in] a First pixel to average.
* @param[in] b Second pixel to average
**/
-inline uint32_t AveragePixelRGBA8888( uint32_t a, uint32_t b )
+inline uint32_t AveragePixelRGBA8888(uint32_t a, uint32_t b)
{
const unsigned int avg =
- ((AverageComponent( (a & 0xff000000) >> 1u, (b & 0xff000000) >> 1u ) << 1u) & 0xff000000 ) +
- (AverageComponent( a & 0x00ff0000, b & 0x00ff0000 ) & 0x00ff0000 ) +
- (AverageComponent( a & 0x0000ff00, b & 0x0000ff00 ) & 0x0000ff00 ) +
- (AverageComponent( a & 0x000000ff, b & 0x000000ff ) );
+ ((AverageComponent((a & 0xff000000) >> 1u, (b & 0xff000000) >> 1u) << 1u) & 0xff000000) +
+ (AverageComponent(a & 0x00ff0000, b & 0x00ff0000) & 0x00ff0000) +
+ (AverageComponent(a & 0x0000ff00, b & 0x0000ff00) & 0x0000ff00) +
+ (AverageComponent(a & 0x000000ff, b & 0x000000ff));
return avg;
///@ToDo: Optimise by trying return (((a ^ b) & 0xfefefefeUL) >> 1) + (a & b);
///@ToDo: Optimise for ARM using the single ARMV6 instruction: UHADD8 R4, R0, R5. This is not Neon. It runs in the normal integer pipeline so there is no downside like a stall moving between integer and copro.
* @param b[in] Low 16 bits hold a color value as RGB565 to average with parameter a.
* @return The average color of the two RGB565 pixels passed in, in the low 16 bits of the returned value.
**/
-inline uint32_t AveragePixelRGB565( uint32_t a, uint32_t b )
+inline uint32_t AveragePixelRGB565(uint32_t a, uint32_t b)
{
const unsigned int avg =
- (AverageComponent( a & 0xf800, b & 0xf800 ) & 0xf800 ) +
- (AverageComponent( a & 0x7e0, b & 0x7e0 ) & 0x7e0 ) +
- (AverageComponent( a & 0x1f, b & 0x1f ) );
+ (AverageComponent(a & 0xf800, b & 0xf800) & 0xf800) +
+ (AverageComponent(a & 0x7e0, b & 0x7e0) & 0x7e0) +
+ (AverageComponent(a & 0x1f, b & 0x1f));
return avg;
}
/** @return The weighted blend of two integers as a 16.16 fixed-point number, given a 0.16 fixed-point blending factor. */
-inline unsigned int WeightedBlendIntToFixed1616(unsigned int a, unsigned int b, unsigned int fractBlend )
+inline unsigned int WeightedBlendIntToFixed1616(unsigned int a, unsigned int b, unsigned int fractBlend)
{
- DALI_ASSERT_DEBUG( fractBlend <= 65535u && "Factor should be in 0.16 fixed-point." );
+ DALI_ASSERT_DEBUG(fractBlend <= 65535u && "Factor should be in 0.16 fixed-point.");
const unsigned int weightedAFixed = a * (65535u - fractBlend);
const unsigned int weightedBFixed = b * fractBlend;
- const unsigned blended = (weightedAFixed + weightedBFixed);
+ const unsigned blended = (weightedAFixed + weightedBFixed);
return blended;
}
/** @brief Blend two 16.16 inputs to give a 16.32 output. */
-inline uint64_t WeightedBlendFixed1616ToFixed1632(unsigned int a, unsigned int b, unsigned int fractBlend )
+inline uint64_t WeightedBlendFixed1616ToFixed1632(unsigned int a, unsigned int b, unsigned int fractBlend)
{
- DALI_ASSERT_DEBUG( fractBlend <= 65535u && "Factor should be in 0.16 fixed-point." );
+ DALI_ASSERT_DEBUG(fractBlend <= 65535u && "Factor should be in 0.16 fixed-point.");
// Blend while promoting intermediates to 16.32 fixed point:
const uint64_t weightedAFixed = uint64_t(a) * (65535u - fractBlend);
const uint64_t weightedBFixed = uint64_t(b) * fractBlend;
- const uint64_t blended = (weightedAFixed + weightedBFixed);
+ const uint64_t blended = (weightedAFixed + weightedBFixed);
return blended;
}
/**
* @brief Blend 4 taps into one value using horizontal and vertical weights.
*/
-inline unsigned int BilinearFilter1Component(unsigned int tl, unsigned int tr, unsigned int bl, unsigned int br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical )
+inline unsigned int BilinearFilter1Component(unsigned int tl, unsigned int tr, unsigned int bl, unsigned int br, unsigned int fractBlendHorizontal, unsigned int fractBlendVertical)
{
- DALI_ASSERT_DEBUG( fractBlendHorizontal <= 65535u && "Factor should be in 0.16 fixed-point." );
- DALI_ASSERT_DEBUG( fractBlendVertical <= 65535u && "Factor should be in 0.16 fixed-point." );
+ DALI_ASSERT_DEBUG(fractBlendHorizontal <= 65535u && "Factor should be in 0.16 fixed-point.");
+ DALI_ASSERT_DEBUG(fractBlendVertical <= 65535u && "Factor should be in 0.16 fixed-point.");
- const unsigned int topBlend = WeightedBlendIntToFixed1616( tl, tr, fractBlendHorizontal );
- const unsigned int botBlend = WeightedBlendIntToFixed1616( bl, br, fractBlendHorizontal );
- const uint64_t blended2x2 = WeightedBlendFixed1616ToFixed1632( topBlend, botBlend, fractBlendVertical );
- const unsigned int rounded = (blended2x2 + (1u << 31u) ) >> 32u;
+ const unsigned int topBlend = WeightedBlendIntToFixed1616(tl, tr, fractBlendHorizontal);
+ const unsigned int botBlend = WeightedBlendIntToFixed1616(bl, br, fractBlendHorizontal);
+ const uint64_t blended2x2 = WeightedBlendFixed1616ToFixed1632(topBlend, botBlend, fractBlendVertical);
+ const unsigned int rounded = (blended2x2 + (1u << 31u)) >> 32u;
return rounded;
}
/*
- * 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;
}
#define DALI_TIZEN_PLATFORM_LOADER_ASTC_H
/*
- * 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 <cstdio>
#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
class PixelBuffer;
}
-
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Astc
const unsigned char MAGIC_BYTE_2 = 0xAB;
} // namespace Astc
-
/**
* Loads a compressed bitmap image from a ASTC file without decoding it.
* This function checks the header first
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return True if file loaded successfully, false otherwise
*/
-bool LoadBitmapFromAstc( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromAstc(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* Loads the header of a ASTC file and fills in the width and height appropriately.
* @param[out] height Is set with the height of the image
* @return True if the header was read successfully, false otherwise
*/
-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);
} // namespace TizenPlatform
/*
- * 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;
}
#define DALI_TIZEN_PLATFORM_LOADER_BMP_H
/*
- * 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 <cstdio>
#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
class PixelBuffer;
}
-
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Bmp
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file decoded successfully, false otherwise
*/
-bool LoadBitmapFromBmp( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromBmp(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* Loads the header of a BMP file and fills in the width and height appropriately.
* @param[out] height Is set with the height of the image
* @return true if the file's header was read successully, false otherwise
*/
-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);
} // namespace TizenPlatform
/*
- * 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;
}
#define DALI_TIZEN_PLATFORM_LOADER_GIF_H
/*
- * 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 <cstdio>
#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
class PixelBuffer;
}
-
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Gif
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file decoded successfully, false otherwise
*/
-bool LoadBitmapFromGif( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromGif(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* Loads the header of a GIF file and fills in the width and height appropriately.
* @param[in/out] height Is set with the height of the image
* @return true if the file's header was read successully, false otherwise
*/
-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);
} // namespace TizenPlatform
/*
- * 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
#define DALI_TIZEN_PLATFORM_LOADER_ICO_H
/*
- * 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 <cstdio>
#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Ico
//00 00 01 00 01 00 20 20
const unsigned char MAGIC_BYTE_1 = 0x00;
const unsigned char MAGIC_BYTE_2 = 0x00;
-}
+} // namespace Ico
/**
* @param[in] input Information about the input image (including file pointer)
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file decoded successfully, false otherwise
*/
-bool LoadBitmapFromIco( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromIco(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* @param[in] input Information about the input image (including file pointer)
* @param[out] height of image
* @return true if header loaded successfully, false otherwise
*/
-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);
} // namespace TizenPlatform
/*
- * 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
+ ROTATE_180, //< 180-degree rotation 0th-Row = bottom & 0th-Column = right
+ FLIP_VERTICAL, //< vertical flip 0th-Row = bottom & 0th-Column = left
+ TRANSPOSE, //< transpose across UL-to-LR axis 0th-Row = left & 0th-Column = top
+ ROTATE_90, //< 90-degree clockwise rotation 0th-Row = right & 0th-Column = top
+ TRANSVERSE, //< transpose across UR-to-LL axis 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)
};
template<size_t N>
-void FlipVertical(PixelArray buffer, int width, int height)
+void Rotate180(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);
}
}
template<size_t N>
-void Transpose(PixelArray buffer, int width, int height)
+void FlipVertical(PixelArray buffer, int width, int height)
{
//Transform vertically only
for(auto iy = 0; iy < height / 2; ++iy)
{
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);
}
}
template<size_t N>
-void Transverse(PixelArray buffer, int width, int height)
+void Transpose(PixelArray buffer, int width, int height)
{
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;)
}
template<size_t N>
-void Rotate180(PixelArray buffer, int width, int height)
+void Transverse(PixelArray buffer, int width, int height)
{
using PixelT = PixelType<N>;
Vector<PixelT> data;
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:
{
}
case 3:
{
- transform = JpegTransform::FLIP_VERTICAL;
+ transform = JpegTransform::ROTATE_180;
break;
}
case 4:
{
- transform = JpegTransform::TRANSPOSE;
+ transform = JpegTransform::FLIP_VERTICAL;
break;
}
case 5:
{
- transform = JpegTransform::TRANSVERSE;
+ transform = JpegTransform::TRANSPOSE;
break;
}
case 6:
}
case 7:
{
- transform = JpegTransform::ROTATE_180;
+ transform = JpegTransform::TRANSVERSE;
break;
}
case 8:
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::TRANSPOSE || transform == JpegTransform::ROTATE_90 || transform == JpegTransform::TRANSVERSE || transform == JpegTransform::ROTATE_270)
{
- 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 )
- {
- success = LoadJpegHeader( fp, width, height );
- }
- else
+
+ unsigned int headerWidth;
+ unsigned int headerHeight;
+
+ success = LoadJpegHeader(fp, headerWidth, headerHeight);
+ if(success)
{
- // Double check we get the same width/height from the header
- unsigned int headerWidth;
- unsigned int headerHeight;
- if( LoadJpegHeader( fp, headerWidth, headerHeight ) )
- {
- auto transform = JpegTransform::NONE;
+ 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 postXformImageHeight = headerHeight;
+ transform = ConvertExifOrientation(exifData.get());
+ }
+ }
- success = TransformSize( requiredWidth, requiredHeight, input.scalingParameters.scalingMode, input.scalingParameters.samplingMode, transform, preXformImageWidth, preXformImageHeight, postXformImageWidth, postXformImageHeight );
- if(success)
- {
- width = postXformImageWidth;
- height = postXformImageHeight;
- }
+ if(requiredWidth == 0 && requiredHeight == 0)
+ {
+ if(transform == JpegTransform::TRANSPOSE || transform == JpegTransform::ROTATE_90 || transform == JpegTransform::TRANSVERSE || transform == JpegTransform::ROTATE_270)
+ {
+ std::swap(headerWidth, headerHeight);
}
- else
+ }
+ else
+ {
+ 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);
+ if(success)
{
- success = true;
- width = headerWidth;
- height = headerHeight;
+ headerWidth = postXformImageWidth;
+ headerHeight = postXformImageHeight;
}
}
+ width = headerWidth;
+ height = headerHeight;
}
+
return success;
}
-
} // namespace TizenPlatform
} // namespace Dali
#define DALI_TIZEN_PLATFORM_LOADER_JPEG_H
/*
- * 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 <stdio.h>
+#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <dali/internal/legacy/tizen/image-encoder.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/pixel.h>
-#include <dali/internal/legacy/tizen/image-encoder.h>
-#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <stdio.h>
namespace Dali
{
class PixelBuffer;
}
-
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Jpeg
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file decoded successfully, false otherwise
*/
-bool LoadBitmapFromJpeg( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromJpeg(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* Loads the header of a JPEG file and fills in the width and height appropriately.
* @param[in/out] height Is set with the height of the image
* @return true if the file's header was read successully, false otherwise
*/
-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);
/**
* Encode raw pixel data to JPEG format.
* @param[in] pixelFormat Input pixel format (must be Pixel::RGB888)
* @param[in] quality JPEG quality on usual 1 to 100 scale.
*/
-bool EncodeToJpeg(const unsigned char* pixelBuffer, Vector< unsigned char >& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, unsigned quality = 80);
+bool EncodeToJpeg(const unsigned char* pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, unsigned quality = 80);
} // namespace TizenPlatform
/*
- * 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;
}
#define DALI_TIZEN_PLATFORM_LOADER_KTX_H
/*
- * 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 <cstdio>
#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Ktx
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file loaded successfully, false otherwise
*/
-bool LoadBitmapFromKtx( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromKtx(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* Loads the header of a KTX file and fills in the width and height appropriately.
* @param[out] height Is set with the height of the image
* @return true if the file's header was read successully, false otherwise
*/
-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);
} // namespace TizenPlatform
/*
- * 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));
+ if(!rows)
+ {
+ DALI_LOG_ERROR("malloc is failed\n");
+ return false;
+ }
+
+ 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);
#define DALI_TIZEN_PLATFORM_LOADER_PNG_H
/*
- * 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 <cstdio>
+#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <dali/internal/legacy/tizen/image-encoder.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/pixel.h>
-#include <dali/internal/legacy/tizen/image-encoder.h>
-#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
namespace TizenPlatform
{
-
class ResourceLoadingClient;
namespace Png
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file decoded successfully, false otherwise
*/
-bool LoadBitmapFromPng( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* Loads the header of a PNG file and fills in the width and height appropriately.
* @param[out] height Is set with the height of the image
* @return true if the file's header was read successully, false otherwise
*/
-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);
/**
* Encode raw pixel data to PNG format.
* @param[in] height Image height
* @param[in] pixelFormat Input pixel format (must be Pixel::RGB888)
*/
-bool EncodeToPng( const unsigned char* pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat );
+bool EncodeToPng(const unsigned char* pixelBuffer, Vector<unsigned char>& encodedPixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat);
} // namespace TizenPlatform
/*
- * 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
#define DALI_TIZEN_PLATFORM_LOADER_WBMP_H
/*
- * 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 <cstdio>
#include <dali/devel-api/adaptor-framework/image-loader-input.h>
+#include <cstdio>
namespace Dali
{
-
namespace Devel
{
class PixelBuffer;
namespace TizenPlatform
{
-
class ResourceLoadingClient;
/**
* @param[out] bitmap The bitmap class where the decoded image will be stored
* @return true if file decoded successfully, false otherwise
*/
-bool LoadBitmapFromWbmp( const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap );
+bool LoadBitmapFromWbmp(const Dali::ImageLoader::Input& input, Dali::Devel::PixelBuffer& bitmap);
/**
* @param[in] input Information about the input image (including file pointer)
* @param[out] height of image
* @return true if header loaded successfully, false otherwise
*/
-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);
} // namespace TizenPlatform
#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
#define DALI_NATIVE_BITMAP_BUFFER_H
/*
- * 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 HEADERS
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/public-api/images/pixel.h>
#include <dali/integration-api/gl-abstraction.h>
#include <dali/integration-api/lockless-buffer.h>
#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/images/native-image-interface.h>
+#include <dali/public-api/images/pixel.h>
// INTERNAL HEADERS
#include <dali/internal/adaptor/common/adaptor-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class NativeBitmapBuffer;
typedef IntrusivePtr<NativeBitmapBuffer> NativeBitmapBufferPtr;
*/
class NativeBitmapBuffer : public NativeImageInterface
{
-
public:
/**
* Constructor.
* @param height height of image
* @param pixelFormat pixel format for image
*/
- NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
+ NativeBitmapBuffer(Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat);
/**
* virtual destructor
* @param[in] size size of data in bytes
* @return true if successful, false if currently reading from buffer in render thread
*/
- void Write( const unsigned char* src, size_t size );
+ void Write(const unsigned char* src, size_t size);
public:
/**
*/
bool SourceChanged() const override;
-
private:
- NativeBitmapBuffer( const NativeBitmapBuffer& ); ///< not defined
- NativeBitmapBuffer& operator =( const NativeBitmapBuffer& ); ///< not defined
- NativeBitmapBuffer(); ///< not defined
+ NativeBitmapBuffer(const NativeBitmapBuffer&); ///< not defined
+ NativeBitmapBuffer& operator=(const NativeBitmapBuffer&); ///< not defined
+ NativeBitmapBuffer(); ///< not defined
private:
- Integration::GlAbstraction* mGlAbstraction; ///< GlAbstraction used
+ Integration::GlAbstraction* mGlAbstraction; ///< GlAbstraction used
- Integration::LocklessBuffer* mBuffer; ///< bitmap data double buffered
- unsigned int mWidth; ///< Image width
- unsigned int mHeight; ///< Image height
- Pixel::Format mPixelFormat; ///< Image pixelformat
+ Integration::LocklessBuffer* mBuffer; ///< bitmap data double buffered
+ unsigned int mWidth; ///< Image width
+ unsigned int mHeight; ///< Image height
+ Pixel::Format mPixelFormat; ///< Image pixelformat
const unsigned char* mLastReadBuffer; ///< last buffer that was read
};
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
/*
- * 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>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
namespace Dali
{
{
namespace Adaptor
{
-
class NativeImageSource;
class NativeImageSourceQueue;
class NativeImageSourceFactory
{
public:
-
- NativeImageSourceFactory() = default;
+ NativeImageSourceFactory() = default;
virtual ~NativeImageSourceFactory() = default;
- virtual std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) = 0;
-
- virtual std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) = 0;
+ virtual std::unique_ptr<NativeImageSource> CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) = 0;
+ virtual std::unique_ptr<NativeImageSourceQueue> CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue) = 0;
};
-extern std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory();
+extern std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory();
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_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.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/devel-api/adaptor-framework/bitmap-saver.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Dali internal NativeImageSource.
*/
class NativeImageSource
{
public:
-
static constexpr uint32_t DEFAULT_QUALITY = 100;
/**
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSource* New(uint32_t width,
- uint32_t height,
+ static NativeImageSource* New(uint32_t width,
+ uint32_t height,
Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
*/
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- virtual bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const = 0;
+ virtual bool GetPixels(std::vector<unsigned char>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const = 0;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- virtual void SetSource( Any source ) = 0;
+ virtual void SetSource(Any source) = 0;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- virtual bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) = 0;
+ virtual bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) = 0;
/**
* destructor
/**
* @brief Dali::DevelNativeImageSource::AcquireBuffer()
*/
- virtual uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) = 0;
+ virtual uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) = 0;
/**
* @brief Dali::DevelNativeImageSource::ReleaseBuffer()
/**
* @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
*/
- inline bool EncodeToFile( const std::string& filename ) const
+ inline bool EncodeToFile(const std::string& filename) const
{
- return EncodeToFile( filename, DEFAULT_QUALITY );
+ return EncodeToFile(filename, DEFAULT_QUALITY);
}
/**
* @param[in] quality The quality of encoded jpeg image
* @return @c true if the pixels were written, and @c false otherwise
*/
- inline bool EncodeToFile( const std::string& filename, const uint32_t quality ) const
+ inline bool EncodeToFile(const std::string& filename, const uint32_t quality) const
{
- std::vector< uint8_t > pixbuf;
- uint32_t width( 0 ), height( 0 );
- Pixel::Format pixelFormat;
+ std::vector<uint8_t> pixbuf;
+ uint32_t width(0), height(0);
+ Pixel::Format pixelFormat;
- if( GetPixels( pixbuf, width, height, pixelFormat ) )
+ if(GetPixels(pixbuf, width, height, pixelFormat))
{
- return Dali::EncodeToFile( &pixbuf[0], filename, pixelFormat, width, height, quality );
+ return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height, quality);
}
return false;
}
public:
- inline static Internal::Adaptor::NativeImageSource& GetImplementation( Dali::NativeImageSource& image ) { return *image.mImpl; }
+ inline static Internal::Adaptor::NativeImageSource& GetImplementation(Dali::NativeImageSource& image)
+ {
+ return *image.mImpl;
+ }
};
} // namespace Adaptor
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_H
/*
- * 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
{
-
/**
* Dali internal NativeImageSourceQueue.
*/
class NativeImageSourceQueue
{
public:
-
/**
* @copydoc Dali::NativeImageSourceQueue::New()
*/
- static NativeImageSourceQueue* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ static NativeImageSourceQueue* New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
/**
* @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
/**
* @copydoc Dali::NativeImageSourceQueue::SetSize
*/
- virtual void SetSize( uint32_t width, uint32_t height ) = 0;
+ virtual void SetSize(uint32_t width, uint32_t height) = 0;
/**
* @copydoc Dali::NativeImageSourceQueue::IgnoreSourceImage
/*
- * 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
#define DALI_INTERNAL_ADAPTOR_PIXEL_BUFFER_H
/*
- * 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 PixelBuffer;
typedef IntrusivePtr<PixelBuffer> PixelBufferPtr;
class PixelBuffer : public BaseObject
{
public:
-
/**
* @brief Create a PixelBuffer object with a pre-allocated buffer.
* The PixelBuffer object owns this buffer, which may be retrieved
* @param [in] height Buffer height in pixels
* @param [in] pixelFormat The pixel format
*/
- static PixelBufferPtr New( unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat );
+ static PixelBufferPtr New(unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat);
/**
* @brief Create a PixelBuffer object. For internal use only.
* @param [in] pixelFormat The pixel format
* @param [in] releaseFunction The function used to release the memory.
*/
- static PixelBufferPtr New( unsigned char* buffer,
- unsigned int bufferSize,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat );
+ static PixelBufferPtr New(unsigned char* buffer,
+ unsigned int bufferSize,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat);
/**
* Convert a pixelBuffer object into a PixelData object.
* @param[in] pixelBuffer The buffer to convert
* @return the pixelData
*/
- static Dali::PixelData Convert( PixelBuffer& pixelBuffer );
+ static Dali::PixelData Convert(PixelBuffer& pixelBuffer);
/**
* @brief Constructor.
* @param [in] height Buffer height in pixels
* @param [in] pixelFormat The pixel format
*/
- PixelBuffer( unsigned char* buffer,
- unsigned int bufferSize,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat );
+ PixelBuffer(unsigned char* buffer,
+ unsigned int bufferSize,
+ unsigned int width,
+ unsigned int height,
+ Pixel::Format pixelFormat);
protected:
-
/**
* @brief Destructor.
*
~PixelBuffer() override;
public:
-
/**
* Get the width of the buffer in pixels.
* @return The width of the buffer in pixels
* @param[in] cropToMask Whether to crop the output to the mask size (true) or scale the
* mask to the content size (false)
*/
- void ApplyMask( const PixelBuffer& mask, float contentScale, bool cropToMask );
+ void ApplyMask(const PixelBuffer& mask, float contentScale, bool cropToMask);
/**
* @brief Apply a Gaussian blur to the current buffer with the given radius.
*
* @param[in] blurRadius The radius for Gaussian blur
*/
- void ApplyGaussianBlur( const float blurRadius );
+ void ApplyGaussianBlur(const float blurRadius);
/**
* Crops this buffer to the given crop rectangle. Assumes the crop rectangle
* @param[in] y The top left corner's y
* @param[in] cropDimensions The dimensions of the crop
*/
- void Crop( uint16_t x, uint16_t y, ImageDimensions cropDimensions );
+ void Crop(uint16_t x, uint16_t y, ImageDimensions cropDimensions);
/**
* Resizes the buffer to the given dimensions. Uses either Lanczos4 for downscaling
* or Mitchell for upscaling
* @param[in] outDimensions The new dimensions
*/
- void Resize( ImageDimensions outDimensions );
+ void Resize(ImageDimensions outDimensions);
/**
* Multiplies the image's color values by the alpha value. This provides better
*
* @param map Property map containing Exif fields
*/
- void SetMetadata( const Property::Map& map );
+ void SetMetadata(const Property::Map& map);
/**
* @brief Returns image metadata as a property map
* Allocates fixed amount of memory for the pixel data. Used by compressed formats.
* @param[in] size Size of memory to be allocated
*/
- void AllocateFixedSize( uint32_t size );
+ void AllocateFixedSize(uint32_t size);
/**
* @copydoc Devel::PixelBuffer::Rotate()
*/
- bool Rotate( Degree angle );
+ bool Rotate(Degree angle);
/**
* @copydoc Devel::PixelBuffer::IsAlphaPreMultiplied()
/*
* Undefined assignment operator.
*/
- PixelBuffer& operator= (const PixelBuffer& other);
+ PixelBuffer& operator=(const PixelBuffer& other);
/**
* Internal method to apply the mask to this buffer. Expects that they are the same size.
*/
- void ApplyMaskInternal( const PixelBuffer& mask );
+ void ApplyMaskInternal(const PixelBuffer& mask);
/**
* Takes ownership of the other object's pixel buffer.
*/
- void TakeOwnershipOfBuffer( PixelBuffer& pixelBuffer );
+ void TakeOwnershipOfBuffer(PixelBuffer& pixelBuffer);
/**
* Release the buffer
* Scales this buffer buffer by the given factor, and crops at the center to the
* given dimensions.
*/
- void ScaleAndCrop( float scaleFactor, ImageDimensions cropDimensions );
+ void ScaleAndCrop(float scaleFactor, ImageDimensions cropDimensions);
/**
* Creates a new buffer which is a crop of the passed in buffer,
* @param[in] cropDimensions The dimensions of the crop
* @return the new pixel buffer
*/
- static PixelBufferPtr NewCrop( const PixelBuffer& inBuffer, uint16_t x, uint16_t y, ImageDimensions cropDimensions );
+ static PixelBufferPtr NewCrop(const PixelBuffer& inBuffer, uint16_t x, uint16_t y, ImageDimensions cropDimensions);
/**
* Creates a new buffer which is a resized version of the passed in buffer.
* @param[in] outDimensions The new dimensions
* @return a new buffer of the given size.
*/
- static PixelBufferPtr NewResize( const PixelBuffer& inBuffer, ImageDimensions outDimensions );
+ static PixelBufferPtr NewResize(const PixelBuffer& inBuffer, ImageDimensions outDimensions);
private:
-
- std::unique_ptr<Property::Map> mMetadata; ///< Metadata fields
- unsigned char* mBuffer; ///< The raw pixel data
- unsigned int mBufferSize; ///< Buffer sized in bytes
- unsigned int mWidth; ///< Buffer width in pixels
- unsigned int mHeight; ///< Buffer height in pixels
- Pixel::Format mPixelFormat; ///< Pixel format
- bool mPreMultiplied; ///< PreMultiplied
+ std::unique_ptr<Property::Map> mMetadata; ///< Metadata fields
+ unsigned char* mBuffer; ///< The raw pixel data
+ unsigned int mBufferSize; ///< Buffer sized in bytes
+ unsigned int mWidth; ///< Buffer width in pixels
+ unsigned int mHeight; ///< Buffer height in pixels
+ Pixel::Format mPixelFormat; ///< Pixel format
+ bool mPreMultiplied; ///< PreMultiplied
};
} // namespace Adaptor
/**
* Helper methods for public API
*/
-inline Internal::Adaptor::PixelBuffer& GetImplementation( Devel::PixelBuffer& handle )
+inline Internal::Adaptor::PixelBuffer& GetImplementation(Devel::PixelBuffer& handle)
{
- DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+ DALI_ASSERT_ALWAYS(handle && "handle is empty");
BaseObject& object = handle.GetBaseObject();
- return static_cast<Internal::Adaptor::PixelBuffer&>( object );
+ return static_cast<Internal::Adaptor::PixelBuffer&>(object);
}
-inline const Internal::Adaptor::PixelBuffer& GetImplementation( const Devel::PixelBuffer& handle )
+inline const Internal::Adaptor::PixelBuffer& GetImplementation(const Devel::PixelBuffer& handle)
{
- DALI_ASSERT_ALWAYS( handle && "handle is empty" );
+ DALI_ASSERT_ALWAYS(handle && "handle is empty");
const BaseObject& object = handle.GetBaseObject();
- return static_cast<const Internal::Adaptor::PixelBuffer&>( object );
+ return static_cast<const Internal::Adaptor::PixelBuffer&>(object);
}
} // 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
#define DALI_INTERNAL_ADAPTOR_PIXEL_MANIPULATION_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 Internal
{
-
namespace Adaptor
{
-
enum Channel
{
LUMINANCE,
* @param[in] channel The channel to test for
* @return true if the channel exists
*/
-bool HasChannel( Dali::Pixel::Format pixelFormat, Channel channel );
-
+bool HasChannel(Dali::Pixel::Format pixelFormat, Channel channel);
/**
* Read a colour channel from the pixel with the given pixel format.
* @param[in] channel The channel to read
* @return the channel value
*/
-unsigned int ReadChannel( unsigned char* pixelData,
- Dali::Pixel::Format pixelFormat,
- Channel channel );
+unsigned int ReadChannel(unsigned char* pixelData,
+ Dali::Pixel::Format pixelFormat,
+ Channel channel);
/**
* Write a colour channel to the pixel with the given pixel format.
* @param[in] channel The channel to write
* @param[in] channelValue the value to write to the channel
*/
-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);
/**
* Convert the colors in the source pixel from their natural format to RGBA8888.
* @param[in] destOffset The offset of the pixel to write
*/
void ConvertColorChannelsToRGBA8888(
- unsigned char* srcBuffer, int srcOffset, Dali::Pixel::Format srcFormat,
- unsigned char* destBuffer, int destOffset );
+ unsigned char* srcBuffer, int srcOffset, Dali::Pixel::Format srcFormat, unsigned char* destBuffer, int destOffset);
/**
* Convert the alpha in the source pixel to A8.
* @param[in] srcFormat The pixel format of the source pixel
* @return the alpha value in the range 0-255
*/
-int ConvertAlphaChannelToA8( unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat );
-
-
-} // Adaptor
-} // Internal
-} // Dali
+int ConvertAlphaChannelToA8(unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat);
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_PIXEL_MANIPULATION_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.
#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];
}
#define DALI_INTERNAL_WEBP_LOADING_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.
*
*/
// EXTERNAL INCLUDES
-#include <cstdint>
-#include <memory>
-#include <dali/public-api/math/rect.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/uint-16-pair.h>
+#include <cstdint>
+#include <memory>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/internal/imaging/common/animated-image-loading-impl.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Class to manage loading frames of an animated webp in small chunks. Lazy initializes only when
* data is actually needed.
* is released. (This is to speed up frame loads, which would otherwise have to re-acquire the
* data from disk)
*/
-class WebPLoading: public Internal::Adaptor::AnimatedImageLoading
+class WebPLoading : public Internal::Adaptor::AnimatedImageLoading
{
public:
-
/**
* Create a WebPLoading with the given url and resourceType.
* @param[in] url The url of the webp image to load
* @param[in] isLocalResource The true or false whether this is a local resource.
* @return A newly created WebPLoading.
*/
- static AnimatedImageLoadingPtr New( const std::string& url, bool isLocalResource );
+ static AnimatedImageLoadingPtr New(const std::string& url, bool isLocalResource);
/**
* @brief Constructor
* @param[in] url The url of the webp image to load
* @param[in] isLocalResource The true or false whether this is a local resource.
*/
- WebPLoading( const std::string& url, bool isLocalResource );
-
+ WebPLoading(const std::string& url, bool isLocalResource);
/**
* @brief Destructor
* @param[out] pixelData The vector in which to return the frame data
* @return True if the frame data was successfully loaded
*/
- bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData ) override;
+ bool LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData) override;
- /**
+ /**
* @brief Load the next Frame of the animated image.
*
* @note This function will load the entire animated image into memory if not already loaded.
* @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle.
*/
- Dali::Devel::PixelBuffer LoadFrame( uint32_t frameIndex ) override;
+ Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex) override;
/**
* @brief Get the size of a webp image.
*
* @return The time interval of the frame(microsecond).
*/
- uint32_t GetFrameInterval( uint32_t frameIndex ) const override;
+ uint32_t GetFrameInterval(uint32_t frameIndex) const override;
std::string GetUrl() const override;
${adaptor_imaging_dir}/windows/native-image-source-factory-win.cpp
${adaptor_imaging_dir}/windows/native-image-source-impl-win.cpp
)
+
+# module: imaging, backend: macos
+SET( adaptor_imaging_macos_src_files
+ ${adaptor_imaging_dir}/common/file-download.cpp
+ ${adaptor_imaging_dir}/macos/native-image-source-factory-mac.cpp
+ ${adaptor_imaging_dir}/macos/native-image-source-impl-mac.cpp
+)
+
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/imaging/macos/native-image-source-factory-mac.h>
+
+// INTERNAL HEADERS
+#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>
+NativeImageSourceFactoryCocoa::CreateNativeImageSource(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource)
+{
+ return std::unique_ptr<NativeImageSource>(NativeImageSourceCocoa::New(
+ width,
+ height,
+ depth,
+ nativeImageSource));
+}
+
+std::unique_ptr<NativeImageSourceQueue>
+NativeImageSourceFactoryCocoa::CreateNativeImageSourceQueue(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSourceQueue::ColorDepth depth,
+ Any nativeImageSourceQueue)
+{
+ return std::unique_ptr<NativeImageSourceQueue>(nullptr);
+}
+
+// this should be created from somewhere
+std::unique_ptr<NativeImageSourceFactory> GetNativeImageSourceFactory()
+{
+ // returns native image source factory
+ return std::unique_ptr<NativeImageSourceFactoryCocoa>(new NativeImageSourceFactoryCocoa());
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/imaging/common/native-image-source-factory.h>
+
+namespace Dali::Internal::Adaptor
+{
+class NativeImageSourceFactoryCocoa : public NativeImageSourceFactory
+{
+public:
+ std::unique_ptr<NativeImageSource> CreateNativeImageSource(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource) override;
+
+ std::unique_ptr<NativeImageSourceQueue> CreateNativeImageSourceQueue(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSourceQueue::ColorDepth depth,
+ Any nativeImageSourceQueue) override;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/imaging/macos/native-image-source-impl-mac.h>
+
+// EXTERNAL INCLUDES
+#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>
+
+namespace Dali::Internal::Adaptor
+{
+using Dali::Integration::PixelBuffer;
+
+NativeImageSourceCocoa* NativeImageSourceCocoa::New(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource)
+{
+ return new NativeImageSourceCocoa(width, height, depth, nativeImageSource);
+}
+
+NativeImageSourceCocoa::NativeImageSourceCocoa(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource)
+: mImage(MakeRef<CGImageRef>(nullptr))
+{
+ DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
+ DALI_ASSERT_ALWAYS(nativeImageSource.Empty());
+
+ CFStringRef colorSpaceName;
+ CGImageAlphaInfo alphaInfo;
+ std::size_t bitsPerPixel;
+
+ switch(depth)
+ {
+ case Dali::NativeImageSource::COLOR_DEPTH_8:
+ colorSpaceName = kCGColorSpaceGenericGray;
+ alphaInfo = kCGImageAlphaNone;
+ bitsPerPixel = 8;
+ break;
+ case Dali::NativeImageSource::COLOR_DEPTH_16:
+ colorSpaceName = kCGColorSpaceSRGB;
+ alphaInfo = kCGImageAlphaNone;
+ bitsPerPixel = 16;
+ break;
+ case Dali::NativeImageSource::COLOR_DEPTH_24:
+ colorSpaceName = kCGColorSpaceSRGB;
+ alphaInfo = kCGImageAlphaNone;
+ bitsPerPixel = 24;
+ break;
+ case Dali::NativeImageSource::COLOR_DEPTH_32:
+ default:
+ colorSpaceName = kCGColorSpaceSRGB;
+ alphaInfo = kCGImageAlphaLast;
+ bitsPerPixel = 32;
+ break;
+ }
+
+ // round to next 16 bytes boundary
+ std::size_t bytesPerRow = width & ~0xf;
+ bytesPerRow = bytesPerRow ? bytesPerRow + 16 : width;
+
+ auto dataProvider = MakeRef(CGDataProviderCreateWithData(nullptr, nullptr, 0, nullptr));
+ auto colorSpace = MakeRef(CGColorSpaceCreateWithName(colorSpaceName));
+ mImage = MakeRef(CGImageCreate(
+ width,
+ height,
+ 8,
+ bitsPerPixel,
+ bytesPerRow,
+ colorSpace.get(),
+ alphaInfo,
+ dataProvider.get(),
+ nullptr,
+ true,
+ kCGRenderingIntentDefault));
+
+ if(mImage)
+ {
+ colorSpace.release();
+ dataProvider.release();
+ }
+
+ DALI_ASSERT_ALWAYS(mImage.get());
+}
+
+NativeImageSourceCocoa::~NativeImageSourceCocoa()
+{
+}
+
+Any NativeImageSourceCocoa::GetNativeImageSource() const
+{
+ return Any();
+}
+
+bool NativeImageSourceCocoa::GetPixels(
+ std::vector<uint8_t>& pixbuf,
+ unsigned& width,
+ unsigned& height,
+ Pixel::Format& pixelFormat) const
+{
+ width = CGImageGetWidth(mImage.get());
+ height = CGImageGetHeight(mImage.get());
+ return true;
+}
+
+void NativeImageSourceCocoa::SetSource(Any source)
+{
+}
+
+bool NativeImageSourceCocoa::IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth)
+{
+ return true;
+}
+
+bool NativeImageSourceCocoa::CreateResource()
+{
+ return false;
+}
+
+void NativeImageSourceCocoa::DestroyResource()
+{
+}
+
+unsigned int NativeImageSourceCocoa::TargetTexture()
+{
+ return 0;
+}
+
+void NativeImageSourceCocoa::PrepareTexture()
+{
+}
+
+const char* NativeImageSourceCocoa::GetCustomFragmentPrefix() const
+{
+ return nullptr;
+}
+
+const char* NativeImageSourceCocoa::GetCustomSamplerTypename() const
+{
+ return nullptr;
+}
+
+int NativeImageSourceCocoa::GetTextureTarget() const
+{
+ return GL_TEXTURE_2D;
+}
+
+Any NativeImageSourceCocoa::GetNativeImageHandle() const
+{
+ return Any(mImage.get());
+}
+
+unsigned int NativeImageSourceCocoa::GetWidth() const
+{
+ return CGImageGetWidth(mImage.get());
+}
+
+unsigned int NativeImageSourceCocoa::GetHeight() const
+{
+ return CGImageGetHeight(mImage.get());
+}
+
+bool NativeImageSourceCocoa::RequiresBlending() const
+{
+ const auto alphaInfo = CGImageGetAlphaInfo(mImage.get());
+ 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)
+{
+ return nullptr;
+}
+
+bool NativeImageSourceCocoa::ReleaseBuffer()
+{
+ return false;
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+
+#include <CoreGraphics/CoreGraphics.h>
+#include <dali/internal/imaging/common/native-image-source-impl.h>
+#include <extern-definitions.h>
+
+namespace Dali::Internal::Adaptor
+{
+class EglImageExtensions;
+
+/**
+ * Dali internal NativeImageSource.
+ */
+class NativeImageSourceCocoa : public Internal::Adaptor::NativeImageSource
+{
+public:
+ /**
+ * Create a new NativeImageSource internally.
+ * Depending on hardware the width and height may have to be a power of two.
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] depth color depth of the image.
+ * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static NativeImageSourceCocoa* New(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetNativeImageSource()
+ */
+ Any GetNativeImageSource() const override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetPixels()
+ */
+ bool GetPixels(
+ std::vector<unsigned char>& pixbuf,
+ unsigned int& width,
+ unsigned int& height,
+ Pixel::Format& pixelFormat) const override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::SetSource( Any source )
+ */
+ void SetSource(Any source) override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
+ */
+ bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) override;
+
+ /**
+ * destructor
+ */
+ ~NativeImageSourceCocoa() override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::CreateResource()
+ */
+ bool CreateResource() override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::DestroyResource()
+ */
+ void DestroyResource() override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::TargetTexture()
+ */
+ unsigned int TargetTexture() override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::PrepareTexture()
+ */
+ void PrepareTexture() override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetWidth()
+ */
+ unsigned int GetWidth() const override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetHeight()
+ */
+ unsigned int GetHeight() const override;
+
+ /**
+ * @copydoc Dali::NativeImageSource::RequiresBlending()
+ */
+ bool RequiresBlending() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
+ */
+ const char* GetCustomFragmentPrefix() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
+ */
+ const char* GetCustomSamplerTypename() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetTextureTarget()
+ */
+ int GetTextureTarget() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
+ */
+ Any GetNativeImageHandle() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::SourceChanged()
+ */
+ bool SourceChanged() const override;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::GetExtension()
+ */
+ NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
+ {
+ return nullptr;
+ }
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
+ */
+ uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
+ */
+ bool ReleaseBuffer() override;
+
+private:
+ /**
+ * Private constructor; @see NativeImageSource::New()
+ * @param[in] width The width of the image.
+ * @param[in] height The height of the image.
+ * @param[in] colour depth of the image.
+ * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
+ */
+ NativeImageSourceCocoa(
+ unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
+
+private:
+ CFRef<CGImageRef> mImage;
+};
+
+} // 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.
{
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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_TIZEN_H
/*
- * 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
{
-
class NativeImageSourceFactoryTizen : public NativeImageSourceFactory
{
public:
+ std::unique_ptr<NativeImageSource> CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) override;
- std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
-
- std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
-
+ std::unique_ptr<NativeImageSourceQueue> CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue) override;
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_TIZEN_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.
// 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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_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.
*/
// EXTERNAL INCLUDES
-#include <tbm_surface.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/public-api/common/dali-vector.h>
+#include <tbm_surface.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/internal/imaging/common/native-image-source-impl.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class EglGraphics;
class EglImageExtensions;
/**
* Dali internal NativeImageSource.
*/
-class NativeImageSourceTizen: public Internal::Adaptor::NativeImageSource
+class NativeImageSourceTizen : public Internal::Adaptor::NativeImageSource
{
public:
-
/**
* Create a new NativeImageSource internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSource contains tbm_surface_h or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceTizen* New(uint32_t width,
- uint32_t height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ static NativeImageSourceTizen* New(uint32_t width,
+ uint32_t height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override;
+ bool GetPixels(std::vector<unsigned char>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- void SetSource( Any source ) override;
+ void SetSource(Any source) override;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
+ bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) override;
/**
* destructor
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
*/
- uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
+ uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
bool ReleaseBuffer() override;
private:
-
/**
* Private constructor; @see NativeImageSource::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- NativeImageSourceTizen(uint32_t width,
- unsigned int height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ NativeImageSourceTizen(uint32_t width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
void Initialize();
- tbm_surface_h GetSurfaceFromAny( Any source ) const;
+ tbm_surface_h GetSurfaceFromAny(Any source) const;
- bool CheckBlending( tbm_format format );
+ bool CheckBlending(tbm_format format);
void DestroySurface();
private:
-
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image height
- bool mOwnTbmSurface; ///< Whether we created pixmap or not
- tbm_surface_h mTbmSurface;
- tbm_format mTbmFormat;
- bool mBlendingRequired; ///< Whether blending is required
- Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
- void* mEglImageKHR; ///< From EGL extension
- EglGraphics* mEglGraphics; ///< EGL Graphics
- EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
- bool mSetSource;
- mutable Dali::Mutex mMutex;
- bool mIsBufferAcquired; ///< Whether AcquireBuffer is called
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image height
+ bool mOwnTbmSurface; ///< Whether we created pixmap or not
+ tbm_surface_h mTbmSurface;
+ tbm_format mTbmFormat;
+ bool mBlendingRequired; ///< Whether blending is required
+ Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
+ void* mEglImageKHR; ///< From EGL extension
+ EglGraphics* mEglGraphics; ///< EGL Graphics
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
+ bool mSetSource;
+ mutable Dali::Mutex mMutex;
+ bool mIsBufferAcquired; ///< Whether AcquireBuffer is called
};
} // 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 <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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
/*
- * 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 EglGraphics;
class EglImageExtensions;
/**
* Dali internal NativeImageSource.
*/
-class NativeImageSourceQueueTizen: public Internal::Adaptor::NativeImageSourceQueue
+class NativeImageSourceQueueTizen : public Internal::Adaptor::NativeImageSourceQueue
{
public:
-
/**
* Create a new NativeImageSourceQueueTizen internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceQueueTizen* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ static NativeImageSourceQueueTizen* New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
/**
* @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
/**
* @copydoc Dali::NativeImageSourceQueue::SetSize
*/
- void SetSize( uint32_t width, uint32_t height ) override;
+ void SetSize(uint32_t width, uint32_t height) override;
/**
* @copydoc Dali::NativeImageSourceQueue::IgnoreSourceImage
}
private:
-
/**
* Private constructor; @see NativeImageSourceQueue::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
*/
- NativeImageSourceQueueTizen( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ NativeImageSourceQueueTizen(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
- void Initialize( Dali::NativeImageSourceQueue::ColorDepth depth );
+ void Initialize(Dali::NativeImageSourceQueue::ColorDepth depth);
void ResetEglImageList();
- tbm_surface_queue_h GetSurfaceFromAny( Any source ) const;
+ tbm_surface_queue_h GetSurfaceFromAny(Any source) const;
- bool CheckBlending( int format );
+ bool CheckBlending(int format);
private:
-
- typedef std::pair< tbm_surface_h, void* > EglImagePair;
-
- Dali::Mutex mMutex; ///< Mutex
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image height
- tbm_surface_queue_h mTbmQueue; ///< Tbm surface queue handle
- tbm_surface_h mConsumeSurface; ///< The current tbm surface
- std::vector< EglImagePair > mEglImages; ///< EGL Image vector
- EglGraphics* mEglGraphics; ///< EGL Graphics
- EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
- bool mOwnTbmQueue; ///< Whether we created tbm queue
- bool mBlendingRequired; ///< Whether blending is required
+ typedef std::pair<tbm_surface_h, void*> EglImagePair;
+
+ Dali::Mutex mMutex; ///< Mutex
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image height
+ tbm_surface_queue_h mTbmQueue; ///< Tbm surface queue handle
+ tbm_surface_h mConsumeSurface; ///< The current tbm surface
+ std::vector<EglImagePair> mEglImages; ///< EGL Image vector
+ EglGraphics* mEglGraphics; ///< EGL Graphics
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
+ bool mOwnTbmQueue; ///< Whether we created tbm queue
+ bool mBlendingRequired; ///< Whether blending is required
};
} // 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 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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
/*
- * 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
{
-
class NativeImageSourceFactoryX : public NativeImageSourceFactory
{
public:
+ std::unique_ptr<NativeImageSource> CreateNativeImageSource(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) override;
- std::unique_ptr< NativeImageSource > CreateNativeImageSource( uint32_t width, uint32_t height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
-
- std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( uint32_t width, uint32_t height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
-
+ std::unique_ptr<NativeImageSourceQueue> CreateNativeImageSourceQueue(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue) override;
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_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.
#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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_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 Internal
{
-
namespace Adaptor
{
class EglImageExtensions;
class NativeImageSourceX : public Internal::Adaptor::NativeImageSource
{
public:
-
/**
* Create a new NativeImageSource internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceX* New( uint32_t width,
- uint32_t height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ static NativeImageSourceX* New(uint32_t width,
+ uint32_t height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
*/
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override;
+ bool GetPixels(std::vector<unsigned char>& pixbuf, uint32_t& width, uint32_t& height, Pixel::Format& pixelFormat) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- void SetSource( Any source ) override;
+ void SetSource(Any source) override;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
+ bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) override;
/**
* destructor
*/
bool SourceChanged() const override;
-
/**
* @copydoc Dali::NativeImageInterface::GetExtension()
*/
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
*/
- uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
+ uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
bool ReleaseBuffer() override;
private:
-
/**
* Private constructor; @see NativeImageSource::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- NativeImageSourceX( uint32_t width,
- uint32_t height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ NativeImageSourceX(uint32_t width,
+ uint32_t height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* 2nd phase construction.
void GetPixmapDetails();
private:
-
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image heights
- bool mOwnPixmap; ///< Whether we created pixmap or not
- Ecore_X_Pixmap mPixmap; ///< From Xlib
- bool mBlendingRequired; ///< Whether blending is required
- Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
- void* mEglImageKHR; ///< From EGL extension
- EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ Ecore_X_Pixmap mPixmap; ///< From Xlib
+ bool mBlendingRequired; ///< Whether blending is required
+ Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
+ void* mEglImageKHR; ///< From EGL extension
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
};
} // 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/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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
/*
- * 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 EglGraphics;
class EglImageExtensions;
/**
* Dali internal NativeImageSourceQueue.
*/
-class NativeImageSourceQueueX: public Internal::Adaptor::NativeImageSourceQueue
+class NativeImageSourceQueueX : public Internal::Adaptor::NativeImageSourceQueue
{
public:
-
/**
* Create a new NativeImageSourceQueueX internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceQueueX* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ static NativeImageSourceQueueX* New(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
/**
* @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
/**
* @copydoc Dali::NativeImageSourceQueue::SetSize
*/
- void SetSize( uint32_t width, uint32_t height ) override;
+ void SetSize(uint32_t width, uint32_t height) override;
/**
* @copydoc Dali::NativeImageSourceQueue::IgnoreSourceImage
}
private:
-
/**
* Private constructor; @see NativeImageSourceQueue::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
*/
- NativeImageSourceQueueX( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+ NativeImageSourceQueueX(uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue);
private:
-
- uint32_t mWidth; ///< image width
- uint32_t mHeight; ///< image height
-
+ uint32_t mWidth; ///< image width
+ uint32_t mHeight; ///< image height
};
} // namespace Adaptor
/*\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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
/*
- * 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
{
-
class NativeImageSourceFactoryWin : public NativeImageSourceFactory
{
public:
+ std::unique_ptr<NativeImageSource> CreateNativeImageSource(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource) override;
- std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
- Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
-
- std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
- Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
-
+ std::unique_ptr<NativeImageSourceQueue> CreateNativeImageSourceQueue(unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue) override;
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_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.
#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
#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_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 Internal
{
-
namespace Adaptor
{
class EglImageExtensions;
class NativeImageSourceWin : public Internal::Adaptor::NativeImageSource
{
public:
-
/**
* Create a new NativeImageSource internally.
* Depending on hardware the width and height may have to be a power of two.
* @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSourceWin* New(unsigned int width,
- unsigned int height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ static NativeImageSourceWin* New(unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
*/
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
+ bool GetPixels(std::vector<unsigned char>& pixbuf, unsigned int& width, unsigned int& height, Pixel::Format& pixelFormat) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- void SetSource( Any source ) override;
+ void SetSource(Any source) override;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
+ bool IsColorDepthSupported(Dali::NativeImageSource::ColorDepth colorDepth) override;
/**
* destructor
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::AcquireBuffer()
*/
- uint8_t* AcquireBuffer( uint16_t& width, uint16_t& height, uint16_t& stride ) override;
+ uint8_t* AcquireBuffer(uint16_t& width, uint16_t& height, uint16_t& stride) override;
/**
* @copydoc Dali::Internal::Adaptor::NativeImageSource::ReleaseBuffer()
bool ReleaseBuffer() override;
private:
-
/**
* Private constructor; @see NativeImageSource::New()
* @param[in] width The width of the image.
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
*/
- NativeImageSourceWin(unsigned int width,
- unsigned int height,
- Dali::NativeImageSource::ColorDepth depth,
- Any nativeImageSource);
+ NativeImageSourceWin(unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
/**
* 2nd phase construction.
void GetPixmapDetails();
private:
-
- unsigned int mWidth; ///< image width
- unsigned int mHeight; ///< image heights
- bool mOwnPixmap; ///< Whether we created pixmap or not
- unsigned int mPixmap; ///< From Windows
- bool mBlendingRequired; ///< Whether blending is required
- Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
- void* mEglImageKHR; ///< From EGL extension
- EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
+ unsigned int mWidth; ///< image width
+ unsigned int mHeight; ///< image heights
+ bool mOwnPixmap; ///< Whether we created pixmap or not
+ unsigned int mPixmap; ///< From Windows
+ bool mBlendingRequired; ///< Whether blending is required
+ Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
+ void* mEglImageKHR; ///< From EGL extension
+ EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
};
} // namespace Adaptor
#define DALI_INTERNAL_INPUT_COMMON_INPUT_METHOD_CONTEXT_FACTORY_H
/*
- * 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
{
-
namespace InputMethodContextFactory
{
-
// Factory function creating new InputMethodContext
// Symbol exists but may be overriden during linking
-InputMethodContextPtr CreateInputMethodContext( Dali::Actor actor );
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor);
-}
-}
-}
+} // namespace InputMethodContextFactory
+} // namespace Adaptor
+} // namespace Internal
-}
+} // namespace Dali
#endif //DALI_INTERNAL_INPUT_COMMON_INPUT_METHOD_CONTEXT_FACTORY_H
/*
- * 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
#define DALI_INTERNAL_INPUT_COMMON_INPUT_METHOD_CONTEXT_IMPL_H
/*
- * 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 <functional>
-#include <memory>
+#include <dali/integration-api/events/key-event-integ.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/key-event-integ.h>
+#include <functional>
+#include <memory>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/input-method-context.h>
namespace Dali
{
-
class RenderSurface;
namespace Internal
{
-
namespace Adaptor
{
class InputMethodContext;
-typedef IntrusivePtr< InputMethodContext > InputMethodContextPtr;
+typedef IntrusivePtr<InputMethodContext> InputMethodContextPtr;
using ImfContext = void;
class InputMethodContext : public Dali::BaseObject
{
-
public:
-
- using ActivatedSignalType = Dali::InputMethodContext::ActivatedSignalType;
- using KeyboardEventSignalType = Dali::InputMethodContext::KeyboardEventSignalType;
- using StatusSignalType = Dali::InputMethodContext::StatusSignalType;
- using VoidSignalType = Dali::InputMethodContext::VoidSignalType;
- using KeyboardTypeSignalType = Dali::InputMethodContext::KeyboardTypeSignalType;
+ using ActivatedSignalType = Dali::InputMethodContext::ActivatedSignalType;
+ using KeyboardEventSignalType = Dali::InputMethodContext::KeyboardEventSignalType;
+ using StatusSignalType = Dali::InputMethodContext::StatusSignalType;
+ using VoidSignalType = Dali::InputMethodContext::VoidSignalType;
+ using KeyboardTypeSignalType = Dali::InputMethodContext::KeyboardTypeSignalType;
using LanguageChangedSignalType = Dali::InputMethodContext::LanguageChangedSignalType;
using KeyboardResizedSignalType = Dali::InputMethodContext::KeyboardResizedSignalType;
using ContentReceivedSignalType = Dali::InputMethodContext::ContentReceivedSignalType;
public:
-
/**
* Create a new input method context instance.
*/
- static InputMethodContextPtr New( Dali::Actor actor );
+ static InputMethodContextPtr New(Dali::Actor actor);
/**
* Initialize the object.
*/
- virtual void Initialize() {}
+ virtual void Initialize()
+ {
+ }
/**
* Connect Callbacks required for InputMethodContext.
* If you don't connect InputMethodContext callbacks, you can't get the key events.
* The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
*/
- virtual void ConnectCallbacks() {}
+ virtual void ConnectCallbacks()
+ {
+ }
/**
* Disconnect Callbacks attached to input method context.
*/
- virtual void DisconnectCallbacks() {}
+ virtual void DisconnectCallbacks()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::Finalize()
*/
- virtual void Finalize() {}
+ virtual void Finalize()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::Activate()
*/
- virtual void Activate() {}
+ virtual void Activate()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::Deactivate()
*/
- virtual void Deactivate() {}
+ virtual void Deactivate()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::Reset()
*/
- virtual void Reset() {}
+ virtual void Reset()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetContext()
*/
- virtual ImfContext* GetContext() { return nullptr; }
+ virtual ImfContext* GetContext()
+ {
+ return nullptr;
+ }
/**
* @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
*/
- virtual bool RestoreAfterFocusLost() const { return false; }
+ virtual bool RestoreAfterFocusLost() const
+ {
+ return false;
+ }
/**
* @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
*/
- virtual void SetRestoreAfterFocusLost( bool toggle ) {}
+ virtual void SetRestoreAfterFocusLost(bool toggle)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::PreEditChanged()
*/
- virtual void PreEditChanged( void *data, ImfContext* imfContext, void *eventInfo ) {}
+ virtual void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::CommitReceived()
*/
- virtual void CommitReceived( void *data, ImfContext* imfContext, void *eventInfo ) {}
+ virtual void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::RetrieveSurrounding()
*/
/*Eina_Bool*/
- virtual bool RetrieveSurrounding( void *data, ImfContext* imfContext, char** text, int* cursorPosition ) { return false; }
+ virtual bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition)
+ {
+ return false;
+ }
/**
* @copydoc Dali::InputMethodContext::DeleteSurrounding()
*/
- virtual void DeleteSurrounding( void *data, ImfContext* imfContext, void *eventInfo ) {}
+ virtual void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::SendPrivateCommand()
*/
- virtual void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) {}
+ virtual void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::SendCommitContent()
*/
- virtual void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) {}
+ virtual void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo)
+ {
+ }
// Cursor related
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- virtual void NotifyCursorPosition() {}
+ virtual void NotifyCursorPosition()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::SetCursorPosition()
*/
- virtual void SetCursorPosition( unsigned int cursorPosition ) {}
+ virtual void SetCursorPosition(unsigned int cursorPosition)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetCursorPosition()
*/
- virtual unsigned int GetCursorPosition() const { return 0; }
+ virtual unsigned int GetCursorPosition() const
+ {
+ return 0;
+ }
/**
* @copydoc Dali::InputMethodContext::SetSurroundingText()
*/
- virtual void SetSurroundingText( const std::string& text ) {}
+ virtual void SetSurroundingText(const std::string& text)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetSurroundingText()
/**
* @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
*/
- virtual void NotifyTextInputMultiLine( bool multiLine ) {}
+ virtual void NotifyTextInputMultiLine(bool multiLine)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetTextDirection()
*/
- virtual Dali::InputMethodContext::TextDirection GetTextDirection() { return Dali::InputMethodContext::TextDirection(); }
+ virtual Dali::InputMethodContext::TextDirection GetTextDirection()
+ {
+ return Dali::InputMethodContext::TextDirection();
+ }
/**
* @copydoc Dali::InputMethodContext::GetInputMethodArea()
*/
- virtual Dali::Rect<int> GetInputMethodArea() { return Dali::Rect<int>(); }
+ virtual Dali::Rect<int> GetInputMethodArea()
+ {
+ return Dali::Rect<int>();
+ }
/**
* @copydoc Dali::InputMethodContext::ApplyOptions()
*/
- virtual void ApplyOptions( const InputMethodOptions& options ) {}
+ virtual void ApplyOptions(const InputMethodOptions& options)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::SetInputPanelData()
*/
- virtual void SetInputPanelData( const std::string& data ) {}
+ virtual void SetInputPanelData(const std::string& data)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetInputPanelData()
*/
- virtual void GetInputPanelData( std::string& data ) {}
+ virtual void GetInputPanelData(std::string& data)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetInputPanelState()
*/
- virtual Dali::InputMethodContext::State GetInputPanelState() { return Dali::InputMethodContext::State(); }
+ virtual Dali::InputMethodContext::State GetInputPanelState()
+ {
+ return Dali::InputMethodContext::State();
+ }
/**
* @copydoc Dali::InputMethodContext::SetReturnKeyState()
*/
- virtual void SetReturnKeyState( bool visible ) {}
+ virtual void SetReturnKeyState(bool visible)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
*/
- virtual void AutoEnableInputPanel( bool enabled ) {}
+ virtual void AutoEnableInputPanel(bool enabled)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::ShowInputPanel()
*/
- virtual void ShowInputPanel() {}
+ virtual void ShowInputPanel()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::HideInputPanel()
*/
- virtual void HideInputPanel() {}
+ virtual void HideInputPanel()
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetKeyboardType()
*/
- virtual Dali::InputMethodContext::KeyboardType GetKeyboardType() { return Dali::InputMethodContext::KeyboardType(); }
+ virtual Dali::InputMethodContext::KeyboardType GetKeyboardType()
+ {
+ return Dali::InputMethodContext::KeyboardType();
+ }
/**
* @copydoc Dali::InputMethodContext::GetInputPanelLocale()
*/
- virtual std::string GetInputPanelLocale() { return std::string(); }
+ virtual std::string GetInputPanelLocale()
+ {
+ return std::string();
+ }
/**
* @copydoc Dali::InputMethodContext::SetContentMIMETypes()
*/
- virtual void SetContentMIMETypes( const std::string& mimeTypes ) {}
+ virtual void SetContentMIMETypes(const std::string& mimeTypes)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::FilterEventKey()
*/
- virtual bool FilterEventKey( const Dali::KeyEvent& keyEvent ) { return false; }
+ virtual bool FilterEventKey(const Dali::KeyEvent& keyEvent)
+ {
+ return false;
+ }
/**
* @copydoc Dali::InputMethodContext::AllowTextPrediction()
*/
- virtual void AllowTextPrediction( bool prediction ) {}
+ virtual void AllowTextPrediction(bool prediction)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
*/
- virtual bool IsTextPredictionAllowed() const { return false; }
+ virtual bool IsTextPredictionAllowed() const
+ {
+ return false;
+ }
/**
* @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
*/
- virtual void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) {}
+ virtual void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
*/
- virtual Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const { return Dali::InputMethodContext::InputPanelLanguage(); }
+ virtual Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const
+ {
+ return Dali::InputMethodContext::InputPanelLanguage();
+ }
/**
* @copydoc Dali::InputMethodContext::SetInputPanelPosition()
*/
- virtual void SetInputPanelPosition( unsigned int x, unsigned int y ) {}
+ virtual void SetInputPanelPosition(unsigned int x, unsigned int y)
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- virtual void GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const {}
-
-public: // Signals
+ virtual void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const
+ {
+ }
+public: // Signals
/**
* @copydoc Dali::InputMethodContext::ActivatedSignal()
*/
- ActivatedSignalType& ActivatedSignal() { return mActivatedSignal; }
+ ActivatedSignalType& ActivatedSignal()
+ {
+ return mActivatedSignal;
+ }
/**
* @copydoc Dali::InputMethodContext::EventReceivedSignal()
*/
- KeyboardEventSignalType& EventReceivedSignal() { return mEventSignal; }
+ KeyboardEventSignalType& EventReceivedSignal()
+ {
+ return mEventSignal;
+ }
/**
* @copydoc Dali::InputMethodContext::StatusChangedSignal()
*/
- StatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
+ StatusSignalType& StatusChangedSignal()
+ {
+ return mKeyboardStatusSignal;
+ }
/**
* @copydoc Dali::InputMethodContext::ResizedSignal()
*/
- KeyboardResizedSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
+ KeyboardResizedSignalType& ResizedSignal()
+ {
+ return mKeyboardResizeSignal;
+ }
/**
* @copydoc Dali::InputMethodContext::LanguageChangedSignal()
*/
- LanguageChangedSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
+ LanguageChangedSignalType& LanguageChangedSignal()
+ {
+ return mKeyboardLanguageChangedSignal;
+ }
/**
* @copydoc Dali::InputMethodContext::KeyboardTypeChangedSignal()
*/
- KeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
+ KeyboardTypeSignalType& KeyboardTypeChangedSignal()
+ {
+ return mKeyboardTypeChangedSignal;
+ }
/**
* @copydoc Dali::InputMethodContext::ContentReceivedSignal()
*/
- ContentReceivedSignalType& ContentReceivedSignal() { return mContentReceivedSignal; }
+ ContentReceivedSignalType& ContentReceivedSignal()
+ {
+ return mContentReceivedSignal;
+ }
public:
-
/**
* Constructor
*/
~InputMethodContext() override = default;
private:
-
- InputMethodContext( const InputMethodContext& ) = delete;
- InputMethodContext& operator=( InputMethodContext& ) = delete;
+ InputMethodContext(const InputMethodContext&) = delete;
+ InputMethodContext& operator=(InputMethodContext&) = delete;
protected:
/**
};
};
- using OperationList = std::vector< std::function<void()> >;
+ using OperationList = std::vector<std::function<void()> >;
/**
* @brief Apply backup operations to the InputMethodContext
void ApplyBackupOperations();
protected:
-
- ActivatedSignalType mActivatedSignal;
- KeyboardEventSignalType mEventSignal;
- StatusSignalType mKeyboardStatusSignal;
- KeyboardResizedSignalType mKeyboardResizeSignal;
- LanguageChangedSignalType mKeyboardLanguageChangedSignal;
- KeyboardTypeSignalType mKeyboardTypeChangedSignal;
- ContentReceivedSignalType mContentReceivedSignal;
- OperationList mBackupOperations;
+ ActivatedSignalType mActivatedSignal;
+ KeyboardEventSignalType mEventSignal;
+ StatusSignalType mKeyboardStatusSignal;
+ KeyboardResizedSignalType mKeyboardResizeSignal;
+ LanguageChangedSignalType mKeyboardLanguageChangedSignal;
+ KeyboardTypeSignalType mKeyboardTypeChangedSignal;
+ ContentReceivedSignalType mContentReceivedSignal;
+ OperationList mBackupOperations;
public:
-
inline static Internal::Adaptor::InputMethodContext& GetImplementation(Dali::InputMethodContext& inputMethodContext)
{
- DALI_ASSERT_ALWAYS( inputMethodContext && "InputMethodContext handle is empty" );
+ DALI_ASSERT_ALWAYS(inputMethodContext && "InputMethodContext handle is empty");
BaseObject& handle = inputMethodContext.GetBaseObject();
inline static const Internal::Adaptor::InputMethodContext& GetImplementation(const Dali::InputMethodContext& inputMethodContext)
{
- DALI_ASSERT_ALWAYS( inputMethodContext && "InputMethodContext handle is empty" );
+ DALI_ASSERT_ALWAYS(inputMethodContext && "InputMethodContext handle is empty");
const BaseObject& handle = inputMethodContext.GetBaseObject();
return static_cast<const Internal::Adaptor::InputMethodContext&>(handle);
}
-
};
-
} // namespace Adaptor
} // namespace Internal
/*
- * 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
#define DALI_KEY_IMPL_H
/*
- * 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/public-api/adaptor-framework/key.h>
-#include <dali/devel-api/adaptor-framework/key-extension-plugin.h>
#include <dali/devel-api/adaptor-framework/key-devel.h>
+#include <dali/devel-api/adaptor-framework/key-extension-plugin.h>
+#include <dali/public-api/adaptor-framework/key.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of the Key matching
*/
namespace KeyLookup
{
-
struct KeyLookup
{
- const char* keyName; ///< XF86 key name
+ const char* keyName; ///< XF86 key name
const Dali::KEY daliKeyCode; ///< Dali key code
- const bool deviceButton; ///< Whether the key is from a button on the device
+ const bool deviceButton; ///< Whether the key is from a button on the device
};
-extern KeyLookup KeyLookupTable[];
+extern KeyLookup KeyLookupTable[];
extern const std::size_t KEY_LOOKUP_COUNT;
/**
* @copydoc Dali::IsKey()
*/
-bool IsKey( const Dali::KeyEvent& keyEvent, Dali::KEY daliKey );
+bool IsKey(const Dali::KeyEvent& keyEvent, Dali::KEY daliKey);
/**
* Check if a the given key name string is a button on the device itself.
* @param keyName A pointer to the key name
* @return true if the key is matched, false if not
*/
-bool IsDeviceButton( const char* keyName );
+bool IsDeviceButton(const char* keyName);
/**
* Get a key name from a dali key code.
* @param daliKey The dali key code
* @return The key name. NULL if the daliKey does not exist in the supported key lookup table.
*/
-const char* GetKeyName( Dali::KEY daliKey );
+const char* GetKeyName(Dali::KEY daliKey);
/**
* @copydoc Dali::DevelKey::GetDaliKeyCode()
*/
-int GetDaliKeyCode( const char* keyName );
+int GetDaliKeyCode(const char* 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
#define DALI_INTERNAL_PHYSICAL_KEYBOARD_H
/*
- * 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 PhysicalKeyboard : public BaseObject
{
public:
-
/**
* Creates a new instance of the PhysicalKeyboard.
*/
* keyboard then the parameter should be true.
* @param[in] fromPhysicalKeyboard true if received from a physical keyboard, false otherwise.
*/
- void KeyReceived( bool fromPhysicalKeyboard );
+ void KeyReceived(bool fromPhysicalKeyboard);
// Signals
/**
* @copydoc Dali::PhysicalKeyboard::StatusChangedSignal()
*/
- Dali::PhysicalKeyboard::PhysicalKeyboardSignalType& StatusChangedSignal() { return mStatusChangedSignal; }
+ Dali::PhysicalKeyboard::PhysicalKeyboardSignalType& StatusChangedSignal()
+ {
+ return mStatusChangedSignal;
+ }
protected:
-
/**
* A reference counted object may only be deleted by calling Unreference()
*/
~PhysicalKeyboard() override;
private:
-
// Undefined
- PhysicalKeyboard( const PhysicalKeyboard& );
- PhysicalKeyboard& operator=( PhysicalKeyboard& );
+ PhysicalKeyboard(const PhysicalKeyboard&);
+ PhysicalKeyboard& operator=(PhysicalKeyboard&);
/**
* Constructor
PhysicalKeyboard();
private:
-
Dali::PhysicalKeyboard::PhysicalKeyboardSignalType mStatusChangedSignal; ///< Status changed signal
- bool mAttached; ///< true if the physical keyboard is attached, false otherwise
+ bool mAttached; ///< true if the physical keyboard is attached, false otherwise
};
} // namespace Adaptor
// Helpers for public-api forwarding methods
-inline static Internal::Adaptor::PhysicalKeyboard& GetImplementation( PhysicalKeyboard& keyboard )
+inline static Internal::Adaptor::PhysicalKeyboard& GetImplementation(PhysicalKeyboard& keyboard)
{
- DALI_ASSERT_ALWAYS( keyboard && "PhysicalKeyboard handle is empty" );
+ DALI_ASSERT_ALWAYS(keyboard && "PhysicalKeyboard handle is empty");
BaseObject& handle = keyboard.GetBaseObject();
- return static_cast< Internal::Adaptor::PhysicalKeyboard& >( handle );
+ return static_cast<Internal::Adaptor::PhysicalKeyboard&>(handle);
}
-inline static const Internal::Adaptor::PhysicalKeyboard& GetImplementation( const PhysicalKeyboard& keyboard )
+inline static const Internal::Adaptor::PhysicalKeyboard& GetImplementation(const PhysicalKeyboard& keyboard)
{
- DALI_ASSERT_ALWAYS( keyboard && "PhysicalKeyboard handle is empty" );
+ DALI_ASSERT_ALWAYS(keyboard && "PhysicalKeyboard handle is empty");
const BaseObject& handle = keyboard.GetBaseObject();
- return static_cast< const Internal::Adaptor::PhysicalKeyboard& >( handle );
+ return static_cast<const Internal::Adaptor::PhysicalKeyboard&>(handle);
}
} // namespace Dali
#define DALI_INTERNAL_VIRTUAL_KEYBOARD_H
/*
- * 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
{
-
/**
* Implementation of the virtual keyboard namespace
*/
namespace VirtualKeyboard
{
-
/**
* @copydoc Dali::VirtualKeyboard::Show()
*/
/**
* @copydoc Dali::VirtualKeyboard::ApplySettings()
*/
-void ApplySettings( const Property::Map& settingsMap );
+void ApplySettings(const Property::Map& settingsMap);
/**
* @copydoc Dali::VirtualKeyboard::SetReturnKeyType()
*/
-void SetReturnKeyType( const Dali::InputMethod::ButtonAction::Type type );
+void SetReturnKeyType(const Dali::InputMethod::ButtonAction::Type type);
/**
* @copydoc Dali::VirtualKeyboard::GetReturnKeyType()
${adaptor_input_dir}/windows/key-mapping-win.cpp
${adaptor_input_dir}/windows/virtual-keyboard-impl-win.cpp
)
+
+# module: input, backend: macos
+SET( adaptor_input_macos_src_files
+ ${adaptor_input_dir}/macos/input-method-context-factory-mac.cpp
+ ${adaptor_input_dir}/macos/input-method-context-impl-mac.cpp
+ ${adaptor_input_dir}/macos/key-mapping-mac.cpp
+ ${adaptor_input_dir}/macos/virtual-keyboard-impl-mac.cpp
+)
/*
- * 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
#define __DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_GENERIC_H
/*
- * 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
{
-
/**
* @brief Satisfies input API requirements for platforms without input method context support
*/
* @param[in] actor The actor that uses the new InputMethodContext instance.
* @return InputMethodContext pointer
*/
- static InputMethodContextPtr New( Dali::Actor actor );
+ static InputMethodContextPtr New(Dali::Actor actor);
/**
* Constructor
* @param[in] actor The actor that uses the new InputMethodContext instance.
*/
- explicit InputMethodContextGeneric( Dali::Actor actor );
+ explicit InputMethodContextGeneric(Dali::Actor actor);
public:
-
/**
* @brief Initializes member data.
*/
/**
* @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
*/
- void SetRestoreAfterFocusLost( bool toggle ) override;
+ void SetRestoreAfterFocusLost(bool toggle) override;
/**
* @copydoc Dali::InputMethodContext::PreEditChanged()
*/
- void PreEditChanged( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- void CommitReceived( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;
+ bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
/**
* @copydoc Dali::InputMethodContext::DeleteSurrounding()
*/
- void DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::SendPrivateCommand()
*/
- void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::SendCommitContent()
*/
- void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override;
// Cursor related
/**
/**
* @copydoc Dali::InputMethodContext::SetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition ) override;
+ void SetCursorPosition(unsigned int cursorPosition) override;
/**
* @copydoc Dali::InputMethodContext::GetCursorPosition()
/**
* @copydoc Dali::InputMethodContext::SetSurroundingText()
*/
- void SetSurroundingText( const std::string& text ) override;
+ void SetSurroundingText(const std::string& text) override;
/**
* @copydoc Dali::InputMethodContext::GetSurroundingText()
/**
* @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
*/
- void NotifyTextInputMultiLine( bool multiLine ) override;
+ void NotifyTextInputMultiLine(bool multiLine) override;
/**
* @copydoc Dali::InputMethodContext::GetTextDirection()
/**
* @copydoc Dali::InputMethodContext::ApplyOptions()
*/
- void ApplyOptions( const InputMethodOptions& options ) override;
+ void ApplyOptions(const InputMethodOptions& options) override;
/**
* @copydoc Dali::InputMethodContext::SetInputPanelData()
*/
- void SetInputPanelData( const std::string& data ) override;
+ void SetInputPanelData(const std::string& data) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelData()
*/
- void GetInputPanelData( std::string& data ) override;
+ void GetInputPanelData(std::string& data) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelState()
/**
* @copydoc Dali::InputMethodContext::SetReturnKeyState()
*/
- void SetReturnKeyState( bool visible ) override;
+ void SetReturnKeyState(bool visible) override;
/**
* @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
*/
- void AutoEnableInputPanel( bool enabled ) override;
+ void AutoEnableInputPanel(bool enabled) override;
/**
* @copydoc Dali::InputMethodContext::ShowInputPanel()
/**
* @copydoc Dali::InputMethodContext::SetContentMIMETypes()
*/
- void SetContentMIMETypes( const std::string& mimeTypes ) override;
+ void SetContentMIMETypes(const std::string& mimeTypes) override;
/**
* @copydoc Dali::InputMethodContext::FilterEventKey()
*/
- bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
+ bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
/**
* @copydoc Dali::InputMethodContext::AllowTextPrediction()
*/
- void AllowTextPrediction( bool prediction ) override;
+ void AllowTextPrediction(bool prediction) override;
/**
* @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
/**
* @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
*/
- void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
+ void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
/**
* @copydoc Dali::InputMethodContext::SetInputPanelPosition()
*/
- void SetInputPanelPosition( unsigned int x, unsigned int y ) override;
+ void SetInputPanelPosition(unsigned int x, unsigned int y) override;
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- void GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const override;
+ void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
public:
-
/**
* Destructor.
*/
virtual ~InputMethodContextGeneric();
private:
-
// Undefined copy constructor
- InputMethodContextGeneric( const InputMethodContextGeneric& inputMethodContext) = delete;
+ InputMethodContextGeneric(const InputMethodContextGeneric& inputMethodContext) = delete;
// Undefined assignment operator
- InputMethodContextGeneric& operator=( const InputMethodContextGeneric& inputMethodContext ) = delete;
+ InputMethodContextGeneric& operator=(const InputMethodContextGeneric& inputMethodContext) = delete;
};
} // 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 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;
}
#define DALI_INTERNAL_INPUT_LINUX_DALI_ECORE_IMF_H
/*
- * 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.
#pragma GCC system_header
#include <Ecore_IMF.h>
-
-
#endif /* DALI_INTERNAL_INPUT_LINUX_DALI_ECORE_IMF_H */
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#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 Internal
+{
+namespace Adaptor
+{
+class InputMethodContext;
+
+namespace InputMethodContextFactory
+{
+// InputMethodContext Factory to be implemented by the platform
+InputMethodContextPtr CreateInputMethodContext(Dali::Actor actor)
+{
+ return Dali::Internal::Adaptor::InputMethodContextCocoa::New(actor);
+}
+
+} // namespace InputMethodContextFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/input/macos/input-method-context-impl-mac.h>
+
+// EXTERNAL INCLUDES
+#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/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");
+#endif
+} // namespace
+
+InputMethodContextPtr InputMethodContextCocoa::New(Dali::Actor actor)
+{
+ InputMethodContextPtr manager;
+
+ if(actor && Adaptor::IsAvailable())
+ {
+ manager = new InputMethodContextCocoa(actor);
+ }
+
+ return manager;
+}
+
+void InputMethodContextCocoa::Finalize()
+{
+}
+
+InputMethodContextCocoa::InputMethodContextCocoa(Dali::Actor actor)
+: mIMFCursorPosition(0),
+ mSurroundingText(),
+ mRestoreAfterFocusLost(false),
+ mIdleCallbackConnected(false)
+{
+ actor.OnSceneSignal().Connect(this, &InputMethodContextCocoa::OnStaged);
+}
+
+InputMethodContextCocoa::~InputMethodContextCocoa()
+{
+ Finalize();
+}
+
+void InputMethodContextCocoa::Initialize()
+{
+ ConnectCallbacks();
+}
+
+// Callbacks for predicitive text support.
+void InputMethodContextCocoa::ConnectCallbacks()
+{
+}
+
+void InputMethodContextCocoa::DisconnectCallbacks()
+{
+}
+
+void InputMethodContextCocoa::Activate()
+{
+ // Reset mIdleCallbackConnected
+ mIdleCallbackConnected = false;
+}
+
+void InputMethodContextCocoa::Deactivate()
+{
+ mIdleCallbackConnected = false;
+}
+
+void InputMethodContextCocoa::Reset()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::Reset\n");
+}
+
+ImfContext* InputMethodContextCocoa::GetContext()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetContext\n");
+
+ return NULL;
+}
+
+bool InputMethodContextCocoa::RestoreAfterFocusLost() const
+{
+ return mRestoreAfterFocusLost;
+}
+
+void InputMethodContextCocoa::SetRestoreAfterFocusLost(bool toggle)
+{
+ mRestoreAfterFocusLost = toggle;
+}
+
+/**
+ * Called when an InputMethodContext Pre-Edit changed event is received.
+ * 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)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::PreEditChanged\n");
+}
+
+void InputMethodContextCocoa::CommitReceived(void*, ImfContext* imfContext, void* eventInfo)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::CommitReceived\n");
+
+ if(Dali::Adaptor::IsAvailable())
+ {
+ 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);
+
+ if(callbackData.update)
+ {
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
+
+ NotifyCursorPosition();
+ }
+ }
+}
+
+/**
+ * Called when an InputMethodContext retrieve surround event is received.
+ * 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)
+{
+ 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);
+
+ if(callbackData.update)
+ {
+ if(text)
+ {
+ *text = strdup(callbackData.currentText.c_str());
+ }
+
+ if(cursorPosition)
+ {
+ mIMFCursorPosition = static_cast<int>(callbackData.cursorPosition);
+ *cursorPosition = mIMFCursorPosition;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * 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)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::DeleteSurrounding\n");
+}
+
+void InputMethodContextCocoa::NotifyCursorPosition()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::NotifyCursorPosition\n");
+}
+
+void InputMethodContextCocoa::SetCursorPosition(unsigned int cursorPosition)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetCursorPosition\n");
+
+ mIMFCursorPosition = static_cast<int>(cursorPosition);
+}
+
+unsigned int InputMethodContextCocoa::GetCursorPosition() const
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetCursorPosition\n");
+
+ return static_cast<unsigned int>(mIMFCursorPosition);
+}
+
+void InputMethodContextCocoa::SetSurroundingText(const std::string& text)
+{
+ 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");
+
+ return mSurroundingText;
+}
+
+void InputMethodContextCocoa::NotifyTextInputMultiLine(bool multiLine)
+{
+}
+
+Dali::InputMethodContext::TextDirection InputMethodContextCocoa::GetTextDirection()
+{
+ Dali::InputMethodContext::TextDirection direction(Dali::InputMethodContext::LEFT_TO_RIGHT);
+
+ return direction;
+}
+
+Rect<int> InputMethodContextCocoa::GetInputMethodArea()
+{
+ int xPos, yPos, width, height;
+
+ width = height = xPos = yPos = 0;
+
+ return Rect<int>(xPos, yPos, width, height);
+}
+
+void InputMethodContextCocoa::ApplyOptions(const InputMethodOptions& options)
+{
+ using namespace Dali::InputMethod::Category;
+
+ int index;
+
+ if(mOptions.CompareAndSet(PANEL_LAYOUT, options, index))
+ {
+ }
+ if(mOptions.CompareAndSet(BUTTON_ACTION, options, index))
+ {
+ }
+ if(mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index))
+ {
+ }
+ if(mOptions.CompareAndSet(VARIATION, options, index))
+ {
+ }
+}
+
+void InputMethodContextCocoa::SetInputPanelData(const std::string& data)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelData\n");
+}
+
+void InputMethodContextCocoa::GetInputPanelData(std::string& data)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelData\n");
+}
+
+Dali::InputMethodContext::State InputMethodContextCocoa::GetInputPanelState()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelState\n");
+ return Dali::InputMethodContext::DEFAULT;
+}
+
+void InputMethodContextCocoa::SetReturnKeyState(bool visible)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetReturnKeyState\n");
+}
+
+void InputMethodContextCocoa::AutoEnableInputPanel(bool enabled)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::AutoEnableInputPanel\n");
+}
+
+void InputMethodContextCocoa::ShowInputPanel()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::ShowInputPanel\n");
+}
+
+void InputMethodContextCocoa::HideInputPanel()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::HideInputPanel\n");
+}
+
+Dali::InputMethodContext::KeyboardType InputMethodContextCocoa::GetKeyboardType()
+{
+ return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD;
+}
+
+std::string InputMethodContextCocoa::GetInputPanelLocale()
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelLocale\n");
+
+ std::string locale = "";
+ return locale;
+}
+
+void InputMethodContextCocoa::SetContentMIMETypes(const std::string& mimeTypes)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetContentMIMETypes\n");
+}
+
+bool InputMethodContextCocoa::FilterEventKey(const Dali::KeyEvent& keyEvent)
+{
+ bool eventHandled(false);
+
+ if(!KeyLookup::IsDeviceButton(keyEvent.GetKeyName().c_str()))
+ {
+ //check whether it's key down or key up event
+ if(keyEvent.GetState() == Dali::KeyEvent::DOWN)
+ {
+ eventHandled = ProcessEventKeyDown(keyEvent);
+ }
+ else if(keyEvent.GetState() == Dali::KeyEvent::UP)
+ {
+ eventHandled = ProcessEventKeyUp(keyEvent);
+ }
+ }
+
+ return eventHandled;
+}
+
+void InputMethodContextCocoa::SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelLanguage\n");
+}
+
+Dali::InputMethodContext::InputPanelLanguage InputMethodContextCocoa::GetInputPanelLanguage() const
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetInputPanelLanguage\n");
+ return Dali::InputMethodContext::InputPanelLanguage::AUTOMATIC;
+}
+
+void InputMethodContextCocoa::SetInputPanelPosition(unsigned int x, unsigned int y)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::SetInputPanelPosition\n");
+}
+
+void InputMethodContextCocoa::GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const
+{
+ DALI_LOG_INFO(gLogFilter, Debug::General, "InputMethodContextCocoa::GetPreeditStyle\n");
+ attrs = mPreeditAttrs;
+}
+
+bool InputMethodContextCocoa::ProcessEventKeyDown(const Dali::KeyEvent& keyEvent)
+{
+ bool eventHandled(false);
+ return eventHandled;
+}
+
+bool InputMethodContextCocoa::ProcessEventKeyUp(const Dali::KeyEvent& keyEvent)
+{
+ bool eventHandled(false);
+ return eventHandled;
+}
+
+void InputMethodContextCocoa::OnStaged(Dali::Actor actor)
+{
+ // Reset
+ Finalize();
+ Initialize();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/input-method-context.h>
+#include <dali/internal/input/common/input-method-context-impl.h>
+
+namespace Dali
+{
+class RenderSurface;
+
+namespace Internal
+{
+namespace Adaptor
+{
+class InputMethodContextCocoa : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker
+{
+public:
+ /**
+ * @brief Creates a new InputMethodContext handle
+ *
+ * @param[in] actor The actor that uses the new InputMethodContext instance.
+ * @return InputMethodContext pointer
+ */
+ static InputMethodContextPtr New(Dali::Actor actor);
+
+ /**
+ * Constructor
+ * @param[in] win32Window, The window is created by application.
+ */
+ explicit InputMethodContextCocoa(Dali::Actor actor);
+
+public:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize() override;
+
+ /**
+ * Connect Callbacks required for InputMethodContext.
+ * If you don't connect InputMethodContext callbacks, you can't get the key events.
+ * The events are PreeditChanged, Commit and DeleteSurrounding.
+ */
+ void ConnectCallbacks() override;
+
+ /**
+ * Disconnect Callbacks attached to input method context.
+ */
+ void DisconnectCallbacks() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::Finalize()
+ */
+ void Finalize() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::Activate()
+ */
+ void Activate() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::Deactivate()
+ */
+ void Deactivate() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::Reset()
+ */
+ void Reset() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetContext()
+ */
+ ImfContext* GetContext() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
+ */
+ bool RestoreAfterFocusLost() const override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
+ */
+ void SetRestoreAfterFocusLost(bool toggle) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::PreEditChanged()
+ */
+ void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
+ */
+ void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
+ */
+ bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::DeleteSurrounding()
+ */
+ void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SendPrivateCommand()
+ */
+ void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override
+ {
+ }
+
+ /**
+ * @copydoc Dali::InputMethodContext::SendCommitContent()
+ */
+ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override
+ {
+ }
+
+ // Cursor related
+ /**
+ * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
+ */
+ void NotifyCursorPosition() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetCursorPosition()
+ */
+ void SetCursorPosition(unsigned int cursorPosition) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetCursorPosition()
+ */
+ unsigned int GetCursorPosition() const override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetSurroundingText()
+ */
+ void SetSurroundingText(const std::string& text) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetSurroundingText()
+ */
+ const std::string& GetSurroundingText() const override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
+ */
+ void NotifyTextInputMultiLine(bool multiLine) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetTextDirection()
+ */
+ Dali::InputMethodContext::TextDirection GetTextDirection() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetInputMethodArea()
+ */
+ Dali::Rect<int> GetInputMethodArea() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::ApplyOptions()
+ */
+ void ApplyOptions(const InputMethodOptions& options) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetInputPanelData()
+ */
+ void SetInputPanelData(const std::string& data) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetInputPanelData()
+ */
+ void GetInputPanelData(std::string& data) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetInputPanelState()
+ */
+ Dali::InputMethodContext::State GetInputPanelState() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetReturnKeyState()
+ */
+ void SetReturnKeyState(bool visible) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
+ */
+ void AutoEnableInputPanel(bool enabled) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::ShowInputPanel()
+ */
+ void ShowInputPanel() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::HideInputPanel()
+ */
+ void HideInputPanel() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetKeyboardType()
+ */
+ Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
+ */
+ std::string GetInputPanelLocale() override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
+ */
+ void SetContentMIMETypes(const std::string& mimeTypes) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::FilterEventKey()
+ */
+ bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
+ */
+ void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
+ */
+ Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::SetInputPanelPosition()
+ */
+ void SetInputPanelPosition(unsigned int x, unsigned int y) override;
+
+ /**
+ * @copydoc Dali::InputMethodContext::GetPreeditStyle()
+ */
+ void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
+
+private:
+ /**
+ * @brief Process event key down, whether filter a key to isf.
+ *
+ * @param[in] keyEvent The event key to be handled.
+ * @return Whether the event key is handled.
+ */
+ bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);
+
+ /**
+ * @brief Process event key up, whether filter a key to isf.
+ *
+ * @param[in] keyEvent The event key to be handled.
+ * @return Whether the event key is handled.
+ */
+ bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);
+
+ /**
+ * Called when the binded actor is added to a window.
+ */
+ void OnStaged(Dali::Actor actor);
+
+public:
+ /**
+ * Destructor.
+ */
+ virtual ~InputMethodContextCocoa();
+
+private:
+ // Undefined copy constructor
+ InputMethodContextCocoa(const InputMethodContextCocoa& inputMethodContext) = delete;
+
+ // Undefined assignment operator
+ InputMethodContextCocoa& operator=(const InputMethodContextCocoa& inputMethodContext) = delete;
+
+private:
+ int mIMFCursorPosition;
+ std::string mSurroundingText;
+
+ bool mRestoreAfterFocusLost : 1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
+ bool mIdleCallbackConnected : 1; ///< Whether the idle callback is already connected.
+ InputMethodOptions mOptions;
+
+ Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/input/common/key-impl.h>
+
+namespace Dali::Internal::Adaptor::KeyLookup
+{
+// matches a DALI_KEY enum, to key name
+// clang-format off
+KeyLookup KeyLookupTable[]=
+{
+ { "Escape", DALI_KEY_ESCAPE, false },
+ { "Command", DALI_KEY_MENU, false },
+ { "Cancel", DALI_KEY_CANCEL, false },
+ { "Backspace", DALI_KEY_BACKSPACE, false },
+ { "Up", DALI_KEY_CURSOR_UP, false },
+ { "Left", DALI_KEY_CURSOR_LEFT, false },
+ { "Right", DALI_KEY_CURSOR_RIGHT, false },
+ { "Down", DALI_KEY_CURSOR_DOWN, false },
+ { "Shift", DALI_KEY_SHIFT_LEFT, 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));
+
+} // namespace Dali::Internal::Adaptor::KeyLookup
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/input/common/virtual-keyboard-impl.h>
+
+namespace Dali::Internal::Adaptor::VirtualKeyboard
+{
+void Show()
+{
+}
+
+void Hide()
+{
+}
+
+bool IsVisible()
+{
+ return false;
+}
+
+void ApplySettings(const Property::Map& settingsMap)
+{
+}
+
+void EnablePrediction(const bool enable)
+{
+}
+
+bool IsPredictionEnabled()
+{
+ return false;
+}
+
+Rect<int> GetSizeAndPosition()
+{
+ Rect<int> ret;
+ return ret;
+}
+
+Dali::VirtualKeyboard::StatusSignalType& StatusChangedSignal()
+{
+ static Dali::VirtualKeyboard::StatusSignalType ret;
+ return ret;
+}
+
+Dali::VirtualKeyboard::KeyboardResizedSignalType& ResizedSignal()
+{
+ static Dali::VirtualKeyboard::KeyboardResizedSignalType ret;
+ return ret;
+}
+
+Dali::VirtualKeyboard::LanguageChangedSignalType& LanguageChangedSignal()
+{
+ static Dali::VirtualKeyboard::LanguageChangedSignalType ret;
+ return ret;
+}
+
+Dali::VirtualKeyboard::TextDirection GetTextDirection()
+{
+ return Dali::VirtualKeyboard::LEFT_TO_RIGHT;
+}
+
+void RotateTo(int angle)
+{
+}
+
+void SetReturnKeyType(const InputMethod::ButtonAction::Type type)
+{
+}
+
+Dali::InputMethod::ButtonAction::Type GetReturnKeyType()
+{
+ return Dali::InputMethod::ButtonAction::DEFAULT;
+}
+
+} // namespace Dali::Internal::Adaptor::VirtualKeyboard
/*
- * 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;
}
#define DALI_INTERNAL_ECORE_VIRTUAL_KEYBOARD_H
/*
- * 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
{
-
/**
* Implementation of the virtual keyboard namespace
*/
namespace VirtualKeyboard
{
-
/**
* Connect the virtual keyboard callbacks.
* To get the virtual keyboard callbacks then you have to connect these callback.
* If you don't connect callbacks, you can't get virtual keyboard signals.
* The signals are StatusChangedSignal, ResizedSignal and LanguageChangedSignal.
*/
-void ConnectCallbacks( Ecore_IMF_Context *imfContext );
+void ConnectCallbacks(Ecore_IMF_Context* imfContext);
/**
* Disconnect the virtual keyboard callbacks.
* The signals are StatusChangedSignal, ResizedSignal and LanguageChangedSignal.
*/
-void DisconnectCallbacks( Ecore_IMF_Context *imfContext );
+void DisconnectCallbacks(Ecore_IMF_Context* imfContext);
} // namespace VirtualKeyboard
/*
- * 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
#define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H
/*
- * 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/linux/dali-ecore-imf.h>
#include <dali/internal/system/linux/dali-ecore.h>
+#include <dali/integration-api/events/key-event-integ.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/key-event-integ.h>
// INTERNAL INCLUDES
#include <dali/internal/input/common/input-method-context-impl.h>
namespace Dali
{
-
class RenderSurface;
namespace Internal
{
-
namespace Adaptor
{
-
class InputMethodContextEcoreWl : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker
{
public:
-
/**
* @brief Creates a new InputMethodContext handle
*
* @param[in] actor The actor that uses the new InputMethodContext instance.
* @return InputMethodContext pointer
*/
- static InputMethodContextPtr New( Dali::Actor actor );
+ static InputMethodContextPtr New(Dali::Actor actor);
/**
* @brief Initializes member data.
void Initialize() override;
public:
-
/**
* @copydoc Dali::InputMethodContext::Finalize()
*/
/**
* @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
*/
- void SetRestoreAfterFocusLost( bool toggle ) override;
+ void SetRestoreAfterFocusLost(bool toggle) override;
/**
* @copydoc Dali::InputMethodContext::PreEditChanged()
*/
- void PreEditChanged( void *data, ImfContext *imfContext, void *eventInfo ) override;
+ void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- void CommitReceived( void *data, ImfContext *imfContext, void *eventInfo ) override;
+ void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- bool RetrieveSurrounding( void *data, ImfContext *imfContext, char** text, int* cursorPosition ) override;
+ bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
/**
* @copydoc Dali::InputMethodContext::DeleteSurrounding()
*/
- void DeleteSurrounding( void *data, ImfContext *imfContext, void *eventInfo ) override;
+ void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
- /**
+ /**
* @copydoc Dali::InputMethodContext::SendPrivateCommand()
*/
- void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::SendCommitContent()
*/
- void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override;
// Cursor related
/**
/**
* @copydoc Dali::InputMethodContext::SetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition ) override;
+ void SetCursorPosition(unsigned int cursorPosition) override;
/**
* @copydoc Dali::InputMethodContext::GetCursorPosition()
/**
* @copydoc Dali::InputMethodContext::SetSurroundingText()
*/
- void SetSurroundingText( const std::string& text ) override;
+ void SetSurroundingText(const std::string& text) override;
/**
* @copydoc Dali::InputMethodContext::GetSurroundingText()
/**
* @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
*/
- void NotifyTextInputMultiLine( bool multiLine ) override;
+ void NotifyTextInputMultiLine(bool multiLine) override;
/**
* @copydoc Dali::InputMethodContext::GetTextDirection()
/**
* @copydoc Dali::InputMethodContext::ApplyOptions()
*/
- void ApplyOptions( const InputMethodOptions& options ) override;
+ void ApplyOptions(const InputMethodOptions& options) override;
/**
* @copydoc Dali::InputMethodContext::SetInputPanelData()
*/
- void SetInputPanelData( const std::string& data ) override;
+ void SetInputPanelData(const std::string& data) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelData()
*/
- void GetInputPanelData( std::string& data ) override;
+ void GetInputPanelData(std::string& data) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelState()
/**
* @copydoc Dali::InputMethodContext::SetReturnKeyState()
*/
- void SetReturnKeyState( bool visible ) override;
+ void SetReturnKeyState(bool visible) override;
/**
* @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
*/
- void AutoEnableInputPanel( bool enabled ) override;
+ void AutoEnableInputPanel(bool enabled) override;
/**
* @copydoc Dali::InputMethodContext::ShowInputPanel()
/**
* @copydoc Dali::InputMethodContext::SetContentMIMETypes()
*/
- void SetContentMIMETypes( const std::string& mimeTypes ) override;
+ void SetContentMIMETypes(const std::string& mimeTypes) override;
/**
* @copydoc Dali::InputMethodContext::FilterEventKey()
*/
- bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
+ bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
/**
* @copydoc Dali::InputMethodContext::AllowTextPrediction()
*/
- void AllowTextPrediction( bool prediction ) override;
+ void AllowTextPrediction(bool prediction) override;
/**
* @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
/**
* @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
*/
- void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
+ void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
/**
* @copydoc Dali::InputMethodContext::SetInputPanelPosition()
*/
- void SetInputPanelPosition( unsigned int x, unsigned int y ) override;
+ void SetInputPanelPosition(unsigned int x, unsigned int y) override;
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- void GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const override;
+ void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
private:
/**
void DeleteContext();
private:
-
/**
* @brief Process event key down, whether filter a key to isf.
*
* @param[in] keyEvent The event key to be handled.
* @return Whether the event key is handled.
*/
- bool ProcessEventKeyDown( const Dali::KeyEvent& keyEvent );
+ bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);
/**
* @brief Process event key up, whether filter a key to isf.
* @param[in] keyEvent The event key to be handled.
* @return Whether the event key is handled.
*/
- bool ProcessEventKeyUp( const Dali::KeyEvent& keyEvent );
+ bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);
/**
* Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
* @param[in] ecoreModifier the Ecore_Event_Modifier input.
* @return the Ecore_IMF_Keyboard_Modifiers output.
*/
- Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
+ Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier);
/**
* EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
* @param[in] modifier the Ecore_Event_Modifier input.
* @return the Ecore_IMF_Keyboard_Locks output.
*/
- Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
+ Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock(unsigned int modifier);
/**
* Called when the binded actor is added to a window.
*/
- void OnStaged( Dali::Actor actor );
+ void OnStaged(Dali::Actor actor);
private:
/**
* @brief Constructor.
*/
- explicit InputMethodContextEcoreWl( Dali::Actor actor );
+ explicit InputMethodContextEcoreWl(Dali::Actor actor);
protected:
/**
private:
// Undefined copy constructor
- explicit InputMethodContextEcoreWl( const InputMethodContextEcoreWl& inputMethodContext) = delete;
+ explicit InputMethodContextEcoreWl(const InputMethodContextEcoreWl& inputMethodContext) = delete;
// Undefined assignment operator
- InputMethodContextEcoreWl& operator=( const InputMethodContextEcoreWl& inputMethodContext ) = delete;
+ InputMethodContextEcoreWl& operator=(const InputMethodContextEcoreWl& inputMethodContext) = delete;
private:
Ecore_IMF_Context* mIMFContext;
- int mIMFCursorPosition;
- std::string mSurroundingText;
+ int mIMFCursorPosition;
+ std::string mSurroundingText;
- bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
- bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
+ bool mRestoreAfterFocusLost : 1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
+ bool mIdleCallbackConnected : 1; ///< Whether the idle callback is already connected.
std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
- InputMethodOptions mOptions;
+ InputMethodOptions mOptions;
+
Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data
int mWindowId;
};
-
} // 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.
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)
{
}
#define DALI_INTERNAL_INPUT_UBUNTU_X11_DALI_ECORE_INPUT_H
/*
- * 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.
#pragma GCC system_header
#include <Ecore_Input.h>
-
-
#endif /* DALI_INTERNAL_INPUT_UBUNTU_X11_DALI_ECORE_INPUT_H */
/*
- * 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
#define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_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
{
-
class RenderSurface;
namespace Internal
{
-
namespace Adaptor
{
-
class InputMethodContextX : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker
{
public:
* @param[in] actor The actor that uses the new InputMethodContext instance.
* @return InputMethodContext pointer
*/
- static InputMethodContextPtr New( Dali::Actor actor );
+ static InputMethodContextPtr New(Dali::Actor actor);
/**
* Constructor
* @param[in] actor The actor that uses the new InputMethodContext instance.
*/
- explicit InputMethodContextX( Dali::Actor actor );
+ explicit InputMethodContextX(Dali::Actor actor);
public:
-
/**
* @brief Initializes member data.
*/
/**
* @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
*/
- void SetRestoreAfterFocusLost( bool toggle ) override;
+ void SetRestoreAfterFocusLost(bool toggle) override;
/**
* @copydoc Dali::InputMethodContext::PreEditChanged()
*/
- void PreEditChanged( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- void CommitReceived( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()
*/
- bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;
+ bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
/**
* @copydoc Dali::InputMethodContext::DeleteSurrounding()
*/
- void DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo ) override;
+ void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
/**
* @copydoc Dali::InputMethodContext::SendPrivateCommand()
*/
- void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override
- {}
+ void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override
+ {
+ }
/**
* @copydoc Dali::InputMethodContext::SendCommitContent()
*/
- void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override
- {}
+ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override
+ {
+ }
// Cursor related
/**
/**
* @copydoc Dali::InputMethodContext::SetCursorPosition()
*/
- void SetCursorPosition( unsigned int cursorPosition ) override;
+ void SetCursorPosition(unsigned int cursorPosition) override;
/**
* @copydoc Dali::InputMethodContext::GetCursorPosition()
/**
* @copydoc Dali::InputMethodContext::SetSurroundingText()
*/
- void SetSurroundingText( const std::string& text ) override;
+ void SetSurroundingText(const std::string& text) override;
/**
* @copydoc Dali::InputMethodContext::GetSurroundingText()
/**
* @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
*/
- void NotifyTextInputMultiLine( bool multiLine ) override;
+ void NotifyTextInputMultiLine(bool multiLine) override;
/**
* @copydoc Dali::InputMethodContext::GetTextDirection()
/**
* @copydoc Dali::InputMethodContext::ApplyOptions()
*/
- void ApplyOptions( const InputMethodOptions& options ) override;
+ void ApplyOptions(const InputMethodOptions& options) override;
/**
* @copydoc Dali::InputMethodContext::SetInputPanelData()
*/
- void SetInputPanelData( const std::string& data ) override;
+ void SetInputPanelData(const std::string& data) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelData()
*/
- void GetInputPanelData( std::string& data ) override;
+ void GetInputPanelData(std::string& data) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelState()
/**
* @copydoc Dali::InputMethodContext::SetReturnKeyState()
*/
- void SetReturnKeyState( bool visible ) override;
+ void SetReturnKeyState(bool visible) override;
/**
* @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
*/
- void AutoEnableInputPanel( bool enabled ) override;
+ void AutoEnableInputPanel(bool enabled) override;
/**
* @copydoc Dali::InputMethodContext::ShowInputPanel()
/**
* @copydoc Dali::InputMethodContext::SetContentMIMETypes()
*/
- void SetContentMIMETypes( const std::string& mimeTypes ) override;
+ void SetContentMIMETypes(const std::string& mimeTypes) override;
/**
* @copydoc Dali::InputMethodContext::FilterEventKey()
*/
- bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
+ bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
/**
* @copydoc Dali::InputMethodContext::AllowTextPrediction()
*/
- void AllowTextPrediction( bool prediction ) override;
+ void AllowTextPrediction(bool prediction) override;
/**
* @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
/**
* @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
*/
- void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
+ void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
/**
* @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
/**
* @copydoc Dali::InputMethodContext::SetInputPanelPosition()
*/
- void SetInputPanelPosition( unsigned int x, unsigned int y ) override;
+ void SetInputPanelPosition(unsigned int x, unsigned int y) override;
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- void GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const override;
+ void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
private:
/**
void DeleteContext();
private:
-
/**
* @brief Process event key down, whether filter a key to isf.
*
* @param[in] keyEvent The event key to be handled.
* @return Whether the event key is handled.
*/
- bool ProcessEventKeyDown( const Dali::KeyEvent& keyEvent );
+ bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);
/**
* @brief Process event key up, whether filter a key to isf.
* @param[in] keyEvent The event key to be handled.
* @return Whether the event key is handled.
*/
- bool ProcessEventKeyUp( const Dali::KeyEvent& keyEvent );
+ bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);
/**
* Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
* @param[in] ecoreModifier the Ecore_Event_Modifier input.
* @return the Ecore_IMF_Keyboard_Modifiers output.
*/
- Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
+ Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier);
/**
* EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
* @param[in] modifier the Ecore_Event_Modifier input.
* @return the Ecore_IMF_Keyboard_Locks output.
*/
- Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
+ Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock(unsigned int modifier);
/**
* Called when the binded actor is added to a window.
*/
- void OnStaged( Dali::Actor actor );
+ void OnStaged(Dali::Actor actor);
public:
-
/**
* Destructor.
*/
virtual ~InputMethodContextX();
private:
-
// Undefined copy constructor
- InputMethodContextX( const InputMethodContextX& inputMethodContext) = delete;
+ InputMethodContextX(const InputMethodContextX& inputMethodContext) = delete;
// Undefined assignment operator
- InputMethodContextX& operator=( const InputMethodContextX& inputMethodContext ) = delete;
+ InputMethodContextX& operator=(const InputMethodContextX& inputMethodContext) = delete;
private:
Ecore_IMF_Context* mIMFContext;
- Ecore_X_Window mEcoreXwin;
- int mIMFCursorPosition;
- std::string mSurroundingText;
+ Ecore_X_Window mEcoreXwin;
+ int mIMFCursorPosition;
+ std::string mSurroundingText;
+
+ bool mRestoreAfterFocusLost : 1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
+ bool mIdleCallbackConnected : 1; ///< Whether the idle callback is already connected.
+ InputMethodOptions mOptions;
- bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
- bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
- InputMethodOptions mOptions;
Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data
};
/*
- * 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
#define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r
\r
/*\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
class RenderSurface;\r
\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker\r
{\r
public:\r
* @param[in] actor The actor that uses the new InputMethodContext instance.\r
* @return InputMethodContext pointer\r
*/\r
- static InputMethodContextPtr New( Dali::Actor actor );\r
+ static InputMethodContextPtr New(Dali::Actor actor);\r
\r
/**\r
* Constructor\r
* @param[in] win32Window, The window is created by application.\r
*/\r
- explicit InputMethodContextWin( Dali::Actor actor );\r
+ explicit InputMethodContextWin(Dali::Actor actor);\r
\r
public:\r
-\r
/**\r
* @brief Initializes member data.\r
*/\r
/**\r
* @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()\r
*/\r
- void SetRestoreAfterFocusLost( bool toggle ) override;\r
+ void SetRestoreAfterFocusLost(bool toggle) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::PreEditChanged()\r
*/\r
- void PreEditChanged( void* data, ImfContext* imfContext, void* eventInfo ) override;\r
+ void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
*/\r
- void CommitReceived( void* data, ImfContext* imfContext, void* eventInfo ) override;\r
+ void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
*/\r
- bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;\r
+ bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::DeleteSurrounding()\r
*/\r
- void DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo ) override;\r
+ void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::SendPrivateCommand()\r
*/\r
- void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override\r
- {}\r
+ void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override\r
+ {\r
+ }\r
\r
/**\r
* @copydoc Dali::InputMethodContext::SendCommitContent()\r
*/\r
- void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override\r
- {}\r
+ void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override\r
+ {\r
+ }\r
\r
// Cursor related\r
/**\r
/**\r
* @copydoc Dali::InputMethodContext::SetCursorPosition()\r
*/\r
- void SetCursorPosition( unsigned int cursorPosition ) override;\r
+ void SetCursorPosition(unsigned int cursorPosition) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetCursorPosition()\r
/**\r
* @copydoc Dali::InputMethodContext::SetSurroundingText()\r
*/\r
- void SetSurroundingText( const std::string& text ) override;\r
+ void SetSurroundingText(const std::string& text) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetSurroundingText()\r
/**\r
* @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()\r
*/\r
- void NotifyTextInputMultiLine( bool multiLine ) override;\r
+ void NotifyTextInputMultiLine(bool multiLine) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetTextDirection()\r
/**\r
* @copydoc Dali::InputMethodContext::ApplyOptions()\r
*/\r
- void ApplyOptions( const InputMethodOptions& options ) override;\r
+ void ApplyOptions(const InputMethodOptions& options) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::SetInputPanelData()\r
*/\r
- void SetInputPanelData( const std::string& data ) override;\r
+ void SetInputPanelData(const std::string& data) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetInputPanelData()\r
*/\r
- void GetInputPanelData( std::string& data ) override;\r
+ void GetInputPanelData(std::string& data) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetInputPanelState()\r
/**\r
* @copydoc Dali::InputMethodContext::SetReturnKeyState()\r
*/\r
- void SetReturnKeyState( bool visible ) override;\r
+ void SetReturnKeyState(bool visible) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::AutoEnableInputPanel()\r
*/\r
- void AutoEnableInputPanel( bool enabled ) override;\r
+ void AutoEnableInputPanel(bool enabled) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::ShowInputPanel()\r
/**\r
* @copydoc Dali::InputMethodContext::SetContentMIMETypes()\r
*/\r
- void SetContentMIMETypes( const std::string& mimeTypes ) override;\r
+ void SetContentMIMETypes(const std::string& mimeTypes) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::FilterEventKey()\r
*/\r
- bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;\r
+ bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::SetInputPanelLanguage()\r
*/\r
- void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;\r
+ void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetInputPanelLanguage()\r
/**\r
* @copydoc Dali::InputMethodContext::SetInputPanelPosition()\r
*/\r
- void SetInputPanelPosition( unsigned int x, unsigned int y ) override;\r
+ void SetInputPanelPosition(unsigned int x, unsigned int y) override;\r
\r
/**\r
* @copydoc Dali::InputMethodContext::GetPreeditStyle()\r
*/\r
- void GetPreeditStyle( Dali::InputMethodContext::PreEditAttributeDataContainer& attrs ) const override;\r
+ void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;\r
\r
private:\r
/**\r
* Context created the first time and kept until deleted.\r
* @param[in] win32Window, The window is created by application.\r
*/\r
- void CreateContext( WinWindowHandle win32Window );\r
+ void CreateContext(WinWindowHandle win32Window);\r
\r
/**\r
* @copydoc Dali::InputMethodContext::DeleteContext()\r
void DeleteContext();\r
\r
private:\r
-\r
/**\r
* @brief Process event key down, whether filter a key to isf.\r
*\r
* @param[in] keyEvent The event key to be handled.\r
* @return Whether the event key is handled.\r
*/\r
- bool ProcessEventKeyDown( const Dali::KeyEvent& keyEvent );\r
+ bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);\r
\r
/**\r
* @brief Process event key up, whether filter a key to isf.\r
* @param[in] keyEvent The event key to be handled.\r
* @return Whether the event key is handled.\r
*/\r
- bool ProcessEventKeyUp( const Dali::KeyEvent& keyEvent );\r
+ bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);\r
\r
/**\r
* Called when the binded actor is added to a window.\r
*/\r
- void OnStaged( Dali::Actor actor );\r
+ void OnStaged(Dali::Actor actor);\r
\r
public:\r
-\r
/**\r
* Destructor.\r
*/\r
virtual ~InputMethodContextWin();\r
\r
private:\r
-\r
// Undefined copy constructor\r
- InputMethodContextWin( const InputMethodContextWin& inputMethodContext) = delete;\r
+ InputMethodContextWin(const InputMethodContextWin& inputMethodContext) = delete;\r
\r
// Undefined assignment operator\r
- InputMethodContextWin& operator=( const InputMethodContextWin& inputMethodContext ) = delete;\r
+ InputMethodContextWin& operator=(const InputMethodContextWin& inputMethodContext) = delete;\r
\r
private:\r
WinWindowHandle mWin32Window;\r
- int mIMFCursorPosition;\r
- std::string mSurroundingText;\r
+ int mIMFCursorPosition;\r
+ std::string mSurroundingText;\r
+\r
+ bool mRestoreAfterFocusLost : 1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
+ bool mIdleCallbackConnected : 1; ///< Whether the idle callback is already connected.\r
+ InputMethodOptions mOptions;\r
\r
- bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
- bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.\r
- InputMethodOptions mOptions;\r
Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data\r
};\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.
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/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 = LoadFile( 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( mResourceLoader && result == false )
+ if(result == false)
{
path = mDataStoragePath;
path += filename;
- result = LoadFile( 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
#define DALI_TIZEN_PLATFORM_ABSTRACTION_H
/*
- * 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/public-api/adaptor-framework/timer.h>
#include <dali/public-api/dali-adaptor-common.h>
-
// EXTERNAL INCLUDES
+#include <dali/integration-api/platform-abstraction.h>
#include <cstdint>
-#include <string>
#include <memory>
-#include <dali/integration-api/platform-abstraction.h>
+#include <string>
namespace Dali
{
-
class CallbackBase;
namespace TizenPlatform
*/
class TizenPlatformAbstraction : public Integration::PlatformAbstraction
{
-
public: // Construction & Destruction
-
/**
* Constructor
*/
~TizenPlatformAbstraction() override;
public: // PlatformAbstraction overrides
-
/**
* @copydoc PlatformAbstraction::GetClosestImageSize()
*/
- ImageDimensions GetClosestImageSize( const std::string& filename,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection ) override;
+ ImageDimensions GetClosestImageSize(const std::string& filename,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection) override;
/**
* @copydoc PlatformAbstraction::GetClosestImageSize()
*/
- ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- SamplingMode::Type samplingMode,
- bool orientationCorrection ) override;
+ ImageDimensions GetClosestImageSize(Integration::ResourcePointer resourceBuffer,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ SamplingMode::Type samplingMode,
+ bool orientationCorrection) override;
/**
* @copydoc PlatformAbstraction::LoadImageSynchronously()
/**
* @copydoc PlatformAbstraction::DecodeBuffer()
*/
- Integration::BitmapPtr DecodeBuffer( const Integration::BitmapResourceType& resource, uint8_t * buffer, size_t size ) override;
+ Integration::BitmapPtr DecodeBuffer(const Integration::BitmapResourceType& resource, uint8_t* buffer, size_t size) override;
/**
* @copydoc PlatformAbstraction::LoadShaderBinaryFile()
*/
- bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const override;
+ bool LoadShaderBinaryFile(const std::string& filename, Dali::Vector<unsigned char>& buffer) const override;
/**
* @copydoc PlatformAbstraction::SaveShaderBinaryFile()
*/
- bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const override;
+ bool SaveShaderBinaryFile(const std::string& filename, const unsigned char* buffer, unsigned int numBytes) const override;
/**
* @copydoc PlatformAbstraction::StartTimer()
*/
- uint32_t StartTimer( uint32_t milliseconds, CallbackBase* callback ) override;
+ uint32_t StartTimer(uint32_t milliseconds, CallbackBase* callback) override;
/**
* @copydoc PlatformAbstraction::CancelTimer()
*/
- void CancelTimer ( uint32_t timerId ) override;
+ void CancelTimer(uint32_t timerId) override;
/**
* Sets path for data/resource storage.
* @param[in] path data/resource storage path
*/
- void SetDataStoragePath( const std::string& path );
+ void SetDataStoragePath(const std::string& path);
/**
* Clears the timers that have completed
void CleanupTimers();
private:
-
struct TimerCallback;
/*
*/
void RunTimerFunction(TimerCallback& timerPtr);
- TizenPlatformAbstraction( const TizenPlatformAbstraction& ); ///< Undefined
- TizenPlatformAbstraction& operator=( const TizenPlatformAbstraction& ); ///< Undefined
+ TizenPlatformAbstraction(const TizenPlatformAbstraction&); ///< Undefined
+ TizenPlatformAbstraction& operator=(const TizenPlatformAbstraction&); ///< Undefined
std::string mDataStoragePath;
- std::vector< std::unique_ptr< TimerCallback > > mTimerPairsWaiting;
- std::vector< std::unique_ptr< TimerCallback > > mTimerPairsSpent;
+ std::vector<std::unique_ptr<TimerCallback> > mTimerPairsWaiting;
+ std::vector<std::unique_ptr<TimerCallback> > mTimerPairsSpent;
};
/**
* @param numBytes to store
* @return true if successful, false otherwise
*/
-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);
-} // namespace TizenPlatform
+} // namespace TizenPlatform
-} // namespace Dali
+} // namespace Dali
#endif // DALI_TIZEN_PLATFORM_ABSTRACTION_H
{
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
#define DALI_TIZEN_PLATFORM_DATA_COMPRESSION_H
/*
- * 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
{
namespace DataCompression
{
-
/**
* Return the maximum size of a buffer required to hold a number of bytes.
* Required because compressing data, can end up being bigger
* @param outputLength size of the output buffer in bytes
* @param encodedSize number of bytes written to outputBuffer
*/
-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);
/**
* RLE Decodes an array of data.
* @param[in] outputLength size of output data in bytes
* @param[out] decodedSize the number of bytes decoded into outputBuffer
*/
-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);
} // namespace DataCompression
#define DALI_TIZEN_PLATFORM_IMAGE_ENCODER_H
/*
- * 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
{
-
/**
* Used file format
*/
#define DALI_TIZEN_PLATFORM_CAPABILITIES_H
/*
- * 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
{
-
/**
* Returns true if non power of two textures are supported.
*/
/**
* Returns the size that a textures dimension should have for a specific image size.
*/
-inline unsigned int GetTextureDimension( unsigned int size )
+inline unsigned int GetTextureDimension(unsigned int size)
{
#ifdef NON_POWER_OF_TWO_TEXTURES
return size;
#else
#error "NPOT are standard in GLES 2.0 if mipmaps are not used, they are standard with mipmaps and no restrictions in GLES 3.0, requiring them simplifies image handling code."
- return NextPowerOfTwo( size );
+ return NextPowerOfTwo(size);
#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.
#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
#define DALI_INTERNAL_ADAPTOR_AUTOMATION_H
/*
- * 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 <string>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* @brief The automation functions allow a way to control Dali via a network socket.
*
*/
namespace Automation
{
-
/**
* @brief Sets properties on an Actor.
* No ClientSendDataInterface required, as no response is sent back
* @param[in] message set property message
*/
-void SetProperty( const std::string& message );
-
+void SetProperty(const std::string& message);
/**
* @brief Dumps the actor tree to the client
* @param[in] clientId unique network client id
* @param[in] sendData interface to transmit data to the client
*/
-void DumpScene( unsigned int clientId, ClientSendDataInterface* sendData );
-
+void DumpScene(unsigned int clientId, ClientSendDataInterface* sendData);
} // namespace Automation
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif
#define DALI_INTERNAL_ADAPTOR_CLIENT_SEND_DATA_INTERFACE_H
/*
- * 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
{
-
/**
* @brief Abstract interface used to transmit data to a client
*/
class ClientSendDataInterface
{
public:
-
/**
* @brief Sends data to the client
* @param[in] data pointer to some data
* @param[in] bufferSizeInBytes how big the buffer is in bytes
* @param[in] clientId unique client id to send the data to
*/
- virtual void SendData( const char* const data, unsigned int bufferSizeInBytes, unsigned int clientId ) = 0;
-
+ virtual void SendData(const char* const data, unsigned int bufferSizeInBytes, unsigned int clientId) = 0;
protected:
-
/**
* @brief Constructor
*/
}
private:
-
// Undefined copy constructor.
- ClientSendDataInterface( const ClientSendDataInterface& );
+ ClientSendDataInterface(const ClientSendDataInterface&);
// Undefined assignment operator.
- ClientSendDataInterface& operator=( const ClientSendDataInterface& );
-
+ ClientSendDataInterface& operator=(const ClientSendDataInterface&);
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_CLIENT_SEND_DATA_INTERFACE_H
/*
- * 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
#define DALI_INTERNAL_ADAPTOR_NETWORK_PERFORMANCE_CLIENT_H
/*
- * 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 <pthread.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/performance-marker.h>
+#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
#include <dali/internal/network/common/client-send-data-interface.h>
#include <dali/internal/network/common/socket-factory-interface.h>
-#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
-
+#include <dali/internal/system/common/performance-marker.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* @brief Network Performance client
*
class NetworkPerformanceClient
{
public:
-
/**
* @brief Constructor
* @param thread thread pointer
* @param sendDataInterface used to send data to the socket from main thread
* @param SocketFactoryInterface used to delete the socket when the client is destroyed
*/
- NetworkPerformanceClient( pthread_t* thread,
- SocketInterface *socket,
- unsigned int clientId,
- ClientSendDataInterface& sendDataInterface,
- SocketFactoryInterface& socketFactory );
+ NetworkPerformanceClient(pthread_t* thread,
+ SocketInterface* socket,
+ unsigned int clientId,
+ ClientSendDataInterface& sendDataInterface,
+ SocketFactoryInterface& socketFactory);
/**
* @brief Destructor
* @brief Write data to a socket. Can be called from any thread
* @copydoc Dali::SocketInterface::Send
*/
- bool WriteSocket( const void* buffer, unsigned int bufferSizeInBytes );
+ bool WriteSocket(const void* buffer, unsigned int bufferSizeInBytes);
/**
* @brief Process a command
* @param buffer pointer to command data
* @param bufferSizeInBytes how big the buffer is in bytes
*/
- void ProcessCommand( char* buffer, unsigned int bufferSizeInBytes );
+ void ProcessCommand(char* buffer, unsigned int bufferSizeInBytes);
/**
* @brief Write a marker to the socket, if this client is filtering this marker.
* @param marker
*/
- bool TransmitMarker( const PerformanceMarker& marker, const char* const description );
+ bool TransmitMarker(const PerformanceMarker& marker, const char* const description);
/**
* @brief If the client is waiting inside a select statement, this will cause it
pthread_t* GetThread();
private:
-
- pthread_t* mThread; ///< thread for the client
- SocketInterface* mSocket; ///< socket interface
- PerformanceMarker::MarkerFilter mMarkerBitmask; ///< What markers are currently filtered
- ClientSendDataInterface& mSendDataInterface; ///< used to send data to a client from the main event thread
- SocketFactoryInterface& mSocketFactoryInterface; ///< used to delete the socket
- unsigned int mClientId; ///< unique client id
- bool mConsoleClient; ///< if connected via a console then all responses are in ASCII, not binary packed data.
-
+ pthread_t* mThread; ///< thread for the client
+ SocketInterface* mSocket; ///< socket interface
+ PerformanceMarker::MarkerFilter mMarkerBitmask; ///< What markers are currently filtered
+ ClientSendDataInterface& mSendDataInterface; ///< used to send data to a client from the main event thread
+ SocketFactoryInterface& mSocketFactoryInterface; ///< used to delete the socket
+ unsigned int mClientId; ///< unique client id
+ bool mConsoleClient; ///< if connected via a console then all responses are in ASCII, not binary packed data.
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_NETWORK_PERFORMANCE_CLIENT_H
/*
- * 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 )
#define DALI_INTERNAL_ADAPTOR_NETWORK_PERFORMANCE_PROTOCOL_H
/*
- * 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 PerformanceProtocol
{
-
-const unsigned int MAX_COMMAND_STRING_LENGTH = 256; ///< maximum length of a command including null terminator
+const unsigned int MAX_COMMAND_STRING_LENGTH = 256; ///< maximum length of a command including null terminator
/**
* @brief List of commands id's
*/
enum CommandId
{
- HELP_MESSAGE = 0, ///< help message
- ENABLE_METRIC = 1, ///< enable metric
- DISABLE_METRIC = 2, ///< disable metric
- LIST_METRICS_AVAILABLE = 3, ///< list metrics that are available
+ HELP_MESSAGE = 0, ///< help message
+ ENABLE_METRIC = 1, ///< enable metric
+ DISABLE_METRIC = 2, ///< disable metric
+ LIST_METRICS_AVAILABLE = 3, ///< list metrics that are available
ENABLE_TIME_MARKER_BIT_MASK = 4, ///< bit mask of time markers to enable
- SET_PROPERTIES = 5, ///< set property
- DUMP_SCENE_GRAPH = 6, ///< dump the scene graph
- UNKNOWN_COMMAND = 4096
+ SET_PROPERTIES = 5, ///< set property
+ DUMP_SCENE_GRAPH = 6, ///< dump the scene graph
+ UNKNOWN_COMMAND = 4096
};
-
-typedef char CommandString[ MAX_COMMAND_STRING_LENGTH ];
+typedef char CommandString[MAX_COMMAND_STRING_LENGTH];
/**
* @brief given a command id, get the command string
* @param[out] commandString command string
* @return true on success, false on failure
*/
-bool GetCommandString( CommandId commandId, CommandString& commandString );
+bool GetCommandString(CommandId commandId, CommandString& commandString);
/**
* @brief given a command string, get the command id and an integer parameter if it exists
* @param[out] stringParam string parameter
* @param true on success, false on failure
*/
-bool GetCommandId( const char* const commandString,
- unsigned int lengthInBytes,
- CommandId& commandId,
- unsigned int& intParam,
- std::string& stringParam);
+bool GetCommandId(const char* const commandString,
+ unsigned int lengthInBytes,
+ CommandId& commandId,
+ unsigned int& intParam,
+ std::string& stringParam);
/**
* @return the protocol help message for console users
/*
- * 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
#define DALI_INTERNAL_ADAPTOR_NETWORK_PERFORMANCE_SERVER_H
/*
- * 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 <pthread.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/public-api/common/dali-vector.h>
+#include <pthread.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/environment-options.h>
-#include <dali/internal/network/common/network-performance-client.h>
#include <dali/internal/adaptor/common/adaptor-internal-services.h>
+#include <dali/internal/network/common/network-performance-client.h>
+#include <dali/internal/system/common/environment-options.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class SocketInterface;
class PerformanceMarker;
*/
class NetworkPerformanceServer : public ClientSendDataInterface
{
-
public:
-
/**
* @brief Constructor
* @param[in] adaptorServices adaptor internal services
* @param[in] logOptions log options
*/
- NetworkPerformanceServer( AdaptorInternalServices& adaptorServices, const EnvironmentOptions& logOptions );
-
+ NetworkPerformanceServer(AdaptorInternalServices& adaptorServices, const EnvironmentOptions& logOptions);
/**
* @brief Start the server, to be called form Dali main thread
* @pre Can be called from any thread
*
*/
- void TransmitMarker( const PerformanceMarker& marker, const char* const description );
+ void TransmitMarker(const PerformanceMarker& marker, const char* const description);
/**
* Destructor
*/
- ~NetworkPerformanceServer();
-
-protected: // ClientSendDataInterface
+ ~NetworkPerformanceServer();
+protected: // ClientSendDataInterface
/**
* @copydoc ClientSendDataInterface::ClientSendDataInterface()
*/
- void SendData( const char* const data, unsigned int bufferSizeInBytes, unsigned int clientId ) override;
+ void SendData(const char* const data, unsigned int bufferSizeInBytes, unsigned int clientId) override;
private:
-
/**
* Helper for the thread calling the entry function.
* @param[in] This A pointer to the current RenderThread object
*/
- static void* ConnectionListenerFunc( void* This )
+ static void* ConnectionListenerFunc(void* This)
{
- ( static_cast<NetworkPerformanceServer*>( This ) )->ConnectionListener();
+ (static_cast<NetworkPerformanceServer*>(This))->ConnectionListener();
return NULL;
}
* Helper for the thread calling the entry function.
* @param[in] This A pointer to the current RenderThread object
*/
- static void* ClientThreadFunc( void* data );
+ static void* ClientThreadFunc(void* data);
/**
* @brief Client thread function
* @param client network client object
*/
- void ClientThread( NetworkPerformanceClient* client );
+ void ClientThread(NetworkPerformanceClient* client);
/**
* @brief Stop all client threads
* @param clientThread client thread
* @return client
*/
- NetworkPerformanceClient* AddClient( SocketInterface* clientSocket, pthread_t* clientThread );
+ NetworkPerformanceClient* AddClient(SocketInterface* clientSocket, pthread_t* clientThread);
/**
* @brief Delete a client from the client list
* @param client network client
*/
- void DeleteClient( NetworkPerformanceClient* client );
-
- NetworkPerformanceServer( const NetworkPerformanceServer& ); ///< undefined copy constructor
- NetworkPerformanceServer& operator=( const NetworkPerformanceServer& ); ///< undefined assignment operator
-
- SocketFactoryInterface& mSocketFactory; ///< used to create sockets
- const EnvironmentOptions& mLogOptions; ///< log options
- Dali::Vector< NetworkPerformanceClient* > mClients; ///< list of connected clients
- pthread_t mServerThread; ///< thread that listens for new connections
- SocketInterface* mListeningSocket; ///< socket used to listen for new connections
- Dali::Mutex mClientListMutex; ///< mutex
- unsigned int mClientUniqueId; ///< increments for every client connection
- volatile unsigned int mClientCount; ///< client count
- bool mLogFunctionInstalled; ///< whether the log function is installed
-
+ void DeleteClient(NetworkPerformanceClient* client);
+
+ NetworkPerformanceServer(const NetworkPerformanceServer&); ///< undefined copy constructor
+ NetworkPerformanceServer& operator=(const NetworkPerformanceServer&); ///< undefined assignment operator
+
+ SocketFactoryInterface& mSocketFactory; ///< used to create sockets
+ const EnvironmentOptions& mLogOptions; ///< log options
+ Dali::Vector<NetworkPerformanceClient*> mClients; ///< list of connected clients
+ pthread_t mServerThread; ///< thread that listens for new connections
+ SocketInterface* mListeningSocket; ///< socket used to listen for new connections
+ Dali::Mutex mClientListMutex; ///< mutex
+ unsigned int mClientUniqueId; ///< increments for every client connection
+ volatile unsigned int mClientCount; ///< client count
+ bool mLogFunctionInstalled; ///< whether the log function is installed
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif //DALI_INTERNAL_ADAPTOR_NETWORK_PERFORMANCE_SERVER_H
#define DALI_INTERNAL_ADAPTOR_BASE_SOCKET_FACTORY_INTERFACE_H
/*
- * 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
{
-
/**
* @brief abstract class to create and destroy sockets
*/
class SocketFactoryInterface
{
public:
-
/**
* @brief Create a new socket
* @param protocol network protocol
* @return true on success, false on failure
*/
- virtual SocketInterface* NewSocket( SocketInterface::Protocol protocol ) = 0;
+ virtual SocketInterface* NewSocket(SocketInterface::Protocol protocol) = 0;
- /**
+ /**
* @brief destroy a socket
* @param[in] socket socket to destroy
*/
- virtual void DestroySocket( SocketInterface* socket ) = 0;
+ virtual void DestroySocket(SocketInterface* socket) = 0;
protected:
-
/**
* @brief Constructor
*/
- SocketFactoryInterface( )
+ SocketFactoryInterface()
{
}
}
private:
-
// Undefined copy constructor.
- SocketFactoryInterface( const SocketFactoryInterface& );
+ SocketFactoryInterface(const SocketFactoryInterface&);
// Undefined assignment operator.
- SocketFactoryInterface& operator=( const SocketFactoryInterface& );
-
+ SocketFactoryInterface& operator=(const SocketFactoryInterface&);
};
-
-
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_BASE_SOCKET_FACTORY_INTERFACE_H
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
#ifndef DALI_INTERNAL_ADAPTOR_SOCKET_FACTORY_H
#define DALI_INTERNAL_ADAPTOR_SOCKET_FACTORY_H
/*
- * 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
{
-
/**
* @brief concrete implementation of the socket factory interface
*/
class SocketFactory : public SocketFactoryInterface
{
public:
-
-
/**
* @brief Constructor
*/
- SocketFactory( )
+ SocketFactory()
{
}
/**
* @copydoc SocketFactoryInterface::NewSocket()
*/
- SocketInterface* NewSocket( SocketInterface::Protocol protocol ) override;
+ SocketInterface* NewSocket(SocketInterface::Protocol protocol) override;
/**
* @copydoc SocketFactoryInterface::DestroySocket()
*/
- void DestroySocket( SocketInterface* socket ) override;
-
+ void DestroySocket(SocketInterface* socket) override;
};
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_SOCKET_FACTORY_H
/*
- * 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
#define DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H
/*
- * 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
{
-
/**
* @brief Concrete implementation of a socket under Linux.
*
class Socket : public SocketInterface
{
public:
-
/**
* @brief Constructor
* @param protocol network protocol
* @param fileDescriptor option file descriptor if the socket is already open
*/
- Socket( Protocol protocol , int fileDescriptor = -1 );
+ Socket(Protocol protocol, int fileDescriptor = -1);
/**
* @copydoc Dali::Internal::Adaptor::SocketIsOpen()
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::Bind
*/
- bool Bind( uint16_t port ) override;
+ bool Bind(uint16_t port) override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::Listen
*/
- bool Listen( int blacklog) override;
+ bool Listen(int blacklog) override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::Accept
*/
- SocketInterface* Accept() const override;
+ SocketInterface* Accept() const override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::Select
*/
- SelectReturn Select( ) override;
+ SelectReturn Select() override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::ExitSelect
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::Recieve
*/
- bool Read( void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead ) override;
+ bool Read(void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead) override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::Send
*/
- bool Write( const void* buffer, unsigned int bufferLength ) override;
+ bool Write(const void* buffer, unsigned int bufferLength) override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::ReuseAddress
*/
- bool ReuseAddress( bool reUse ) override;
+ bool ReuseAddress(bool reUse) override;
/**
* @copydoc Dali::Internal::Adaptor::SocketInterface::SetBufferSize
*
*/
- bool SetBufferSize( SocketInterface::BufferType type, unsigned int bufferSizeInBytes ) override;
+ bool SetBufferSize(SocketInterface::BufferType type, unsigned int bufferSizeInBytes) override;
/**
* @brief Virtual destructor
virtual ~Socket();
private:
-
-
/**
* @brief Helper to create the quit pipe
*/
*/
void DeleteQuitPipe();
- int mSocketFileDescriptor; ///< file descriptor
- int mQuitPipe[2]; ///< Pipe to inform Select to quit.
- bool mBound:1; ///< whether the socket is bound
- bool mListening:1; ///< whether the socket is being listen to
- bool mQuitPipeCreated:1; ///< whether the quit pipe has been created
- bool mBlocked:1; ///< whether the socket is blocked waiting for a connection
+ int mSocketFileDescriptor; ///< file descriptor
+ int mQuitPipe[2]; ///< Pipe to inform Select to quit.
+ bool mBound : 1; ///< whether the socket is bound
+ bool mListening : 1; ///< whether the socket is being listen to
+ bool mQuitPipeCreated : 1; ///< whether the quit pipe has been created
+ bool mBlocked : 1; ///< whether the socket is blocked waiting for a connection
};
+} // namespace Adaptor
+} // namespace Internal
-} // Adaptor
-
-} // Internal
-
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_SOCKET_IMPL_H
#define DALI_INTERNAL_ADAPTOR_BASE_SOCKET_INTERFACE_H
/*
- * 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
{
-
/**
* @brief Abstract socket interface.
* The typical usage is:
class SocketInterface
{
public:
-
/**
* @brief Protocol type
*/
enum Protocol
{
- TCP, ///< Reliable, connection oriented
- UDP, ///< Connection less, no guarantees of packet delivery, ordering
+ TCP, ///< Reliable, connection oriented
+ UDP, ///< Connection less, no guarantees of packet delivery, ordering
};
/**
* @param[in] port network port
* @return true on success, false on failure
*/
- virtual bool Bind( uint16_t port ) = 0;
+ virtual bool Bind(uint16_t port) = 0;
/**
* @brief Indicate a willingness to accept incoming connection requests
* @param[in] backlog maximum length of the queue of pending connections.
* @return true on success, false on failure
*/
- virtual bool Listen( int blacklog) = 0;
+ virtual bool Listen(int blacklog) = 0;
/**
* @brief Wait for connection request and make connection
*/
enum SelectReturn
{
- DATA_AVAILABLE, ///< Data is available to read
- QUIT, ///< ExitSelect() has been called on the socket
- ERROR ///< Socket error
+ DATA_AVAILABLE, ///< Data is available to read
+ QUIT, ///< ExitSelect() has been called on the socket
+ ERROR ///< Socket error
};
/**
* @param[out] bytesRead number of bytes read
* @return true on success, false on failure
*/
- virtual bool Read( void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead ) = 0;
+ virtual bool Read(void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead) = 0;
/**
* @brief Send data to the socket
* @param[in] bufferSizeInBytes buffer size in write
* @return true on success, false on failure
*/
- virtual bool Write( const void* buffer, unsigned int bufferSizeInBytes ) = 0;
+ virtual bool Write(const void* buffer, unsigned int bufferSizeInBytes) = 0;
//
// Common socket options. Please add more as required.
* @param[in] reuse flag.
* @return true on success, false on failure
*/
- virtual bool ReuseAddress( bool reUse ) = 0;
+ virtual bool ReuseAddress(bool reUse) = 0;
/**
* @brief Socket buffer type
*/
enum BufferType
{
- SEND_BUFFER, ///< (SO_SNDBUF) Send buffer size
- RECIEVE_BUFFER ///< (SO_RCVBUF) Size of buffer allocated to hold data arriving to the socket
+ SEND_BUFFER, ///< (SO_SNDBUF) Send buffer size
+ RECIEVE_BUFFER ///< (SO_RCVBUF) Size of buffer allocated to hold data arriving to the socket
};
/**
* @param[in] size buffer size
* @return true on success, false on failure
*/
- virtual bool SetBufferSize( BufferType type, unsigned int size ) = 0;
+ virtual bool SetBufferSize(BufferType type, unsigned int size) = 0;
protected:
-
/**
* @brief Constructor
*/
- SocketInterface( )
+ SocketInterface()
{
}
}
private:
-
// Undefined copy constructor.
- SocketInterface( const SocketInterface& );
+ SocketInterface(const SocketInterface&);
// Undefined assignment operator.
- SocketInterface& operator=( const SocketInterface& );
-
+ SocketInterface& operator=(const SocketInterface&);
};
-
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_BASE_SOCKET_INTERFACE_H
#define DALI_INTERNAL_BASE_TRACE_INTERFACE_H
/*
- * 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 <string>
-
// INTERNAL INCLUDES
#include <dali/internal/system/common/performance-marker.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Abstract Tracing Interface.
* Used to log trace messages.
*/
class TraceInterface
{
-
public:
-
/**
* Write a trace message
* @param marker performance marker
* @param traceMessage trace message
*/
- virtual void Trace( const PerformanceMarker& marker, const std::string& traceMessage ) = 0;
+ virtual void Trace(const PerformanceMarker& marker, const std::string& traceMessage) = 0;
protected:
-
/**
* Constructor
*/
}
// Undefined copy constructor.
- TraceInterface( const TraceInterface& );
+ TraceInterface(const TraceInterface&);
// Undefined assignment operator.
- TraceInterface& operator=( const TraceInterface& );
+ TraceInterface& operator=(const TraceInterface&);
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_BASE_TRACE_INTERFACE_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.
#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();
}
#define DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_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.
*/
// EXTERNAL INCLUDES
-#include <memory>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/object/base-object.h>
+#include <memory>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/offscreen-application.h>
namespace Internal
{
-
/**
* Implementation of the OffscreenApplication class.
*/
class OffscreenApplication : public BaseObject
{
public:
-
using OffscreenApplicationSignalType = Dali::OffscreenApplication::OffscreenApplicationSignalType;
/**
* @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
* @param[in] renderMode The RenderMode of the OffscreenApplication
*/
- static IntrusivePtr<OffscreenApplication> New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
+ static IntrusivePtr<OffscreenApplication> New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
public:
-
/**
* Destructor
*/
*/
void RenderOnce();
-public: // Signals
-
+public: // Signals
/**
* @copydoc Dali::OffscreenApplication::InitSignal()
*/
* @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
* @param[in] renderMode The RenderMode of the OffscreenApplication
*/
- OffscreenApplication( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode );
+ OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
// Undefined
- OffscreenApplication( const OffscreenApplication& ) = delete;
- OffscreenApplication& operator=( OffscreenApplication& ) = delete;
- OffscreenApplication& operator=( const OffscreenApplication& ) = delete;
- OffscreenApplication& operator=( OffscreenApplication&& ) = delete;
+ OffscreenApplication(const OffscreenApplication&) = delete;
+ OffscreenApplication& operator=(OffscreenApplication&) = delete;
+ OffscreenApplication& operator=(const OffscreenApplication&) = delete;
+ OffscreenApplication& operator=(OffscreenApplication&&) = delete;
private:
- std::unique_ptr< Dali::Adaptor > mAdaptor;
- Dali::OffscreenWindow mDefaultWindow;
+ std::unique_ptr<Dali::Adaptor> mAdaptor;
+ Dali::OffscreenWindow mDefaultWindow;
- OffscreenApplicationSignalType mInitSignal;
- OffscreenApplicationSignalType mTerminateSignal;
+ OffscreenApplicationSignalType mInitSignal;
+ OffscreenApplicationSignalType mTerminateSignal;
};
-inline OffscreenApplication& GetImplementation( Dali::OffscreenApplication& offscreenApplication )
+inline OffscreenApplication& GetImplementation(Dali::OffscreenApplication& offscreenApplication)
{
- DALI_ASSERT_ALWAYS( offscreenApplication && "OffscreenApplication handle is empty" );
+ DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
BaseObject& handle = offscreenApplication.GetBaseObject();
- return static_cast<OffscreenApplication&>( handle );
+ return static_cast<OffscreenApplication&>(handle);
}
-inline const OffscreenApplication& GetImplementation( const Dali::OffscreenApplication& offscreenApplication )
+inline const OffscreenApplication& GetImplementation(const Dali::OffscreenApplication& offscreenApplication)
{
- DALI_ASSERT_ALWAYS( offscreenApplication && "OffscreenApplication handle is empty" );
+ DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
const BaseObject& handle = offscreenApplication.GetBaseObject();
- return static_cast<const OffscreenApplication&>( handle );
+ return static_cast<const OffscreenApplication&>(handle);
}
} // 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.
// 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()
#define DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_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.
*/
// EXTERNAL INCLUDES
-#include <memory>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/signals/connection-tracker.h>
+#include <memory>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/offscreen-window.h>
namespace Internal
{
-
/**
* Implementation of the OffscreenWindow class.
*/
public ConnectionTracker
{
public:
- using WindowSize = Dali::OffscreenWindow::WindowSize;
+ using WindowSize = Dali::OffscreenWindow::WindowSize;
using PostRenderSignalType = Dali::OffscreenWindow::PostRenderSignalType;
/**
* @param[in] surface The native surface handle of your platform
* @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
*/
- static OffscreenWindow* New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent );
+ static OffscreenWindow* New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent);
OffscreenWindow() = default;
public:
-
/**
* Destructor
*/
/**
* @copydoc Dali::OffscreenWindow::GetLayer
*/
- Dali::Layer GetLayer( uint32_t depth ) const;
+ Dali::Layer GetLayer(uint32_t depth) const;
/**
* @copydoc Dali::OffscreenWindow::GetSize
* @brief Initialize the OffscreenWindow
* @param[in] isDefaultWindow Whether the OffscreenWindow is a default one or not
*/
- void Initialize( bool isDefaultWindow );
-
-public: // Signals
+ void Initialize(bool isDefaultWindow);
+public: // Signals
/**
* @copydoc Dali::OffscreenWindow::PostRenderSignal
*/
NativeRenderSurface* GetNativeRenderSurface() const;
private:
-
- /**
+ /**
* Private constructor
*
* @param[in] width The initial width of the OffscreenWindow
* @param[in] surface The native surface handle
* @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
*/
- OffscreenWindow( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent );
+ OffscreenWindow(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent);
// Undefined
- OffscreenWindow( const OffscreenWindow& );
- OffscreenWindow& operator=( OffscreenWindow& );
+ OffscreenWindow(const OffscreenWindow&);
+ OffscreenWindow& operator=(OffscreenWindow&);
/*
* @brief Initialize the OffscreenWindow (for internal use)
void Initialize();
private:
-
- std::unique_ptr< TriggerEventInterface > mRenderNotification;
- PostRenderSignalType mPostRenderSignal;
+ std::unique_ptr<TriggerEventInterface> mRenderNotification;
+ PostRenderSignalType mPostRenderSignal;
};
-inline OffscreenWindow& GetImplementation( Dali::OffscreenWindow& offscreenWindow )
+inline OffscreenWindow& GetImplementation(Dali::OffscreenWindow& offscreenWindow)
{
- DALI_ASSERT_ALWAYS( offscreenWindow && "Dali::OffscreenWindow handle is empty" );
+ DALI_ASSERT_ALWAYS(offscreenWindow && "Dali::OffscreenWindow handle is empty");
BaseObject& handle = offscreenWindow.GetBaseObject();
- return static_cast<OffscreenWindow&>( handle );
+ return static_cast<OffscreenWindow&>(handle);
}
-inline const OffscreenWindow& GetImplementation( const Dali::OffscreenWindow& offscreenWindow )
+inline const OffscreenWindow& GetImplementation(const Dali::OffscreenWindow& offscreenWindow)
{
- DALI_ASSERT_ALWAYS( offscreenWindow && "Dali::OffscreenWindow handle is empty" );
+ DALI_ASSERT_ALWAYS(offscreenWindow && "Dali::OffscreenWindow handle is empty");
const BaseObject& handle = offscreenWindow.GetBaseObject();
- return static_cast<const OffscreenWindow&>( handle );
+ return static_cast<const OffscreenWindow&>(handle);
}
} // 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/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
#define DALI_SENSOR_COMMON_TILT_SENSOR_FACTORY_H
/*
- * 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 TiltSensorFactory
{
-
/**
* Creates new instance of tilt sensor implementation
* @return pointer to tilt sensor implementation instance
*/
Dali::TiltSensor Get();
-} // TiltSensorFactory
+} // namespace TiltSensorFactory
} // 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
{
-
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;
}
#define DALI_SENSOR_COMMON_TILT_SENSOR_IMPL_H
/*
- * 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/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/devel-api/adaptor-framework/tilt-sensor.h>
+#include <dali/public-api/adaptor-framework/timer.h>
#include <deque>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* TiltSensor provides pitch & roll values when the device is tilted.
*/
class TiltSensor : public Dali::BaseObject
{
public:
-
/**
* Constructor
*/
/**
* @copydoc Dali::TiltSensor::SetUpdateFrequency()
*/
- virtual void SetUpdateFrequency( float frequencyHertz );
+ virtual void SetUpdateFrequency(float frequencyHertz);
/**
* @copydoc Dali::TiltSensor::GetUpdateFrequency()
* @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.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
};
} // namespace Adaptor
inline Internal::Adaptor::TiltSensor& GetImplementation(Dali::TiltSensor& sensor)
{
- DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
+ DALI_ASSERT_ALWAYS(sensor && "TiltSensor handle is empty");
BaseObject& handle = sensor.GetBaseObject();
inline const Internal::Adaptor::TiltSensor& GetImplementation(const Dali::TiltSensor& sensor)
{
- DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
+ DALI_ASSERT_ALWAYS(sensor && "TiltSensor handle is empty");
const BaseObject& handle = sensor.GetBaseObject();
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);
}
}
}
#define DALI_SENSOR_TIZEN_TILT_SENSOR_IMPL_TIZEN_H
/*
- * 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.
#define SENSOR_ENABLED
#endif
-#include <deque>
-#include <dali/public-api/object/base-object.h>
#include <dali/internal/sensor/common/tilt-sensor-impl.h>
+#include <dali/public-api/object/base-object.h>
+#include <deque>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/devel-api/adaptor-framework/tilt-sensor.h>
+#include <dali/public-api/adaptor-framework/timer.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* TiltSensorTizen provides pitch & roll values when the device is tilted.
*/
class TiltSensorTizen : public Dali::Internal::Adaptor::TiltSensor
{
public:
-
typedef Dali::TiltSensor::TiltedSignalType TiltedSignalType;
/**
/**
* @copydoc Dali::TiltSensor::SetUpdateFrequency()
*/
- void SetUpdateFrequency( float frequencyHertz ) override;
+ void SetUpdateFrequency(float frequencyHertz) override;
/**
* @copydoc Dali::TiltSensor::GetUpdateFrequency()
* @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.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
/**
* Update sensor data
* @param[in] event sensor event data
*/
#ifdef SENSOR_ENABLED
- void Update(sensor_event_s *event);
+ void Update(sensor_event_s* event);
#endif
-
private:
-
enum State
{
DISCONNECTED,
float mFrequencyHertz;
#ifdef SENSOR_ENABLED
- sensor_type_e mSensorType;
- sensor_h mSensor;
+ sensor_type_e mSensorType;
+ sensor_h mSensor;
sensor_listener_h mSensorListener;
#else
- int mSensorType;
+ int mSensorType;
int* mSensor;
int* mSensorListener;
#endif
- float mRoll;
- float mPitch;
+ float mRoll;
+ float mPitch;
Quaternion mRotation;
Radian mRotationThreshold;
{
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 <deque>
#include <dali/public-api/object/base-object.h>
+#include <deque>
// INTERNAL INCLUDES
-#include <dali/internal/sensor/common/tilt-sensor-impl.h>
#include <dali/devel-api/adaptor-framework/tilt-sensor.h>
+#include <dali/internal/sensor/common/tilt-sensor-impl.h>
#include <dali/public-api/adaptor-framework/timer.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* TiltSensor provides pitch & roll values when the device is tilted.
*/
class TiltSensorUbuntu : public Dali::Internal::Adaptor::TiltSensor
{
public:
-
typedef Dali::TiltSensor::TiltedSignalType TiltedSignalType;
/**
/**
* @copydoc Dali::TiltSensor::SetUpdateFrequency()
*/
- void SetUpdateFrequency( float frequencyHertz ) override;
+ void SetUpdateFrequency(float frequencyHertz) override;
/**
* @copydoc Dali::TiltSensor::GetUpdateFrequency()
* @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.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
private:
-
/**
* Private constructor; see also TiltSensor::New()
*/
TiltSensorUbuntu& operator=(TiltSensorUbuntu&) = delete;
private:
-
- float mFrequencyHertz;
- Dali::Timer mTimer;
- SlotDelegate< TiltSensorUbuntu > mTimerSlot;
+ float mFrequencyHertz;
+ Dali::Timer mTimer;
+ SlotDelegate<TiltSensorUbuntu> mTimerSlot;
int mSensorFrameworkHandle;
- float mRoll;
- float mPitch;
+ float mRoll;
+ float mPitch;
Quaternion mRotation;
Radian mRotationThreshold;
// 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);
}
}
#define DALI_INTERNAL_STYLE_MONITOR_H
/*
- * 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/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
#include <dali/devel-api/text-abstraction/font-client.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/style-monitor.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* This holds the platform's style information.
* It provides a signal when any aspect of the default style changes on the device.
class StyleMonitor : public BaseObject
{
public:
-
// Creation & Destruction
/**
* Informs the Style Monitor that the style has changed.
* @param[in] styleChange The details of the change.
*/
- void StyleChanged( StyleChange::Type styleChange );
+ void StyleChanged(StyleChange::Type styleChange);
// Style Information
/**
* @copydoc Dali::StyleMonitor::LoadThemeFile()
*/
- bool LoadThemeFile( const std::string& filename, std::string& output );
+ bool LoadThemeFile(const std::string& filename, std::string& output);
// Signals
Dali::StyleMonitor::StyleChangeSignalType& StyleChangeSignal();
protected:
-
/**
* Virtual Destructor.
*/
~StyleMonitor() override;
private:
-
/**
* Emit the style change signal.
* @param[in] styleChange The details of the style change
*/
- inline void EmitStyleChangeSignal( StyleChange::Type styleChange );
+ inline void EmitStyleChangeSignal(StyleChange::Type styleChange);
private:
-
Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal; ///< Emitted when the style changes
TextAbstraction::FontClient mFontClient;
- std::string mDefaultFontFamily; ///< The system default font family
- std::string mDefaultFontStyle; ///< The default font style
- std::string mUserDefinedThemeFilePath; ///< String containing the user defined theme file path
- int mDefaultFontSize; ///< The default accessibility font size e.g. 0 is smallest
+ std::string mDefaultFontFamily; ///< The system default font family
+ std::string mDefaultFontStyle; ///< The default font style
+ std::string mUserDefinedThemeFilePath; ///< String containing the user defined theme file path
+ int mDefaultFontSize; ///< The default accessibility font size e.g. 0 is smallest
};
} // 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/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
-
-
#define __DALI_ANDROID_CALLBACK_MANAGER_H__
/*
- * 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/internal/system/common/callback-manager.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
struct CallbackData;
/**
*/
class AndroidCallbackManager : public CallbackManager
{
-
public:
-
- /**
+ /**
* @brief constructor
*/
- AndroidCallbackManager();
+ AndroidCallbackManager();
- /**
+ /**
* @brief destructor
*/
- ~AndroidCallbackManager() = default;
+ ~AndroidCallbackManager() = default;
- /**
+ /**
* @copydoc CallbackManager::AddIdleCallback()
*/
- bool AddIdleCallback( CallbackBase* callback, bool hasReturnValue ) override;
+ bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) override;
- /**
+ /**
* @copydoc CallbackManager::RemoveIdleCallback()
*/
- void RemoveIdleCallback( CallbackBase* callback ) override;
+ void RemoveIdleCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::ProcessIdle()
*/
- bool ProcessIdle() override;
+ bool ProcessIdle() override;
- /**
+ /**
* @copydoc CallbackManager::ProcessIdle()
*/
- void ClearIdleCallbacks() override;
+ void ClearIdleCallbacks() override;
- /**
+ /**
* @copydoc CallbackManager::AddIdleEntererCallback()
*/
- bool AddIdleEntererCallback( CallbackBase* callback ) override;
+ bool AddIdleEntererCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::RemoveIdleEntererCallback()
*/
- void RemoveIdleEntererCallback( CallbackBase* callback ) override;
+ void RemoveIdleEntererCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::Start()
*/
- void Start() override;
+ void Start() override;
- /**
+ /**
* @copydoc CallbackManager::Stop()
*/
- void Stop() override;
+ void Stop() override;
private:
-
- /**
+ /**
* @brief Remove all idle call backs that are pending
* Called by Stop()
* Always called from the main thread
*/
- void RemoveAllCallbacks();
+ void RemoveAllCallbacks();
- /**
+ /**
* @brief Removes a single call back from the container
* Always called from main thread
* @param callbackData callback data
*/
- void RemoveCallbackFromContainer(CallbackData *callbackData);
+ void RemoveCallbackFromContainer(CallbackData* callbackData);
- /**
+ /**
* @brief Remove a standard call back from ecore
* Always called from main thread
* @param callbackData callback data
*/
- void RemoveStandardCallback(CallbackData *callbackData);
-
+ void RemoveStandardCallback(CallbackData* callbackData);
- typedef std::list<CallbackData *> CallbackList;
+ typedef std::list<CallbackData*> CallbackList;
- bool mRunning; ///< flag is set to true if when running
- CallbackList mCallbackContainer; ///< container of live idle callbacks
+ bool mRunning; ///< flag is set to true if when running
+ CallbackList mCallbackContainer; ///< container of live idle callbacks
};
} // 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
{
-
/**
* 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
#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_ANDROID_H
/*
- * 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 Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of the WidgetApplicationAndroid class.
*/
class WidgetApplicationAndroid : public WidgetApplication
{
public:
-
- typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction > CreateWidgetFunctionPair;
- typedef std::vector< CreateWidgetFunctionPair > CreateWidgetFunctionContainer;
+ typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
+ typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
/**
* Create a new widget application
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+ static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
public:
-
/**
* @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
*/
- void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) override;
+ void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
protected:
-
/**
* Private Constructor
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- WidgetApplicationAndroid( int* argc, char **argv[], const std::string& stylesheet );
+ WidgetApplicationAndroid(int* argc, char** argv[], const std::string& stylesheet);
/**
* Destructor
{
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
#define DALI_INTERNAL_ADAPTOR_ABORT_HANDLER_H
/*
- * 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 <signal.h>
#include <dali/public-api/signals/callback.h>
+#include <signal.h>
// INTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/application.h>
+#if !defined(_NSIG) && defined(NSIG)
+#define _NSIG NSIG
+#endif
+
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-
/**
* Class to listen to system signals and trigger an abort callback
* when they occur.
* @param[in] callback The function to call when abort signals occur
* @note The ownership of callback is passed onto this class.
*/
- AbortHandler( CallbackBase* callback );
+ AbortHandler(CallbackBase* callback);
/**
* Destructor
* @param[in] signum The signal number (from signum.h)
* @return true if the signal handler was installed ok
*/
- bool AbortOnSignal( int signum );
+ bool AbortOnSignal(int signum);
private:
/**
* Signal handler - Called when signal is received.
* Stops the application.
*/
- static void SignalHandler( int signum );
+ static void SignalHandler(int signum);
/**
* Default constructor - undefined
AbortHandler& operator=(const AbortHandler& rhs);
private:
- using SignalHandlerFuncPtr = void( * )( int );
+ using SignalHandlerFuncPtr = void (*)(int);
// _NSIG comes from the signal.h linux system header, defining the number of signals.
- SignalHandlerFuncPtr mSignalOldHandlers[_NSIG-1];
- unsigned long long mSignalMask;
+ SignalHandlerFuncPtr mSignalOldHandlers[_NSIG - 1];
+ unsigned long long mSignalMask;
- CallbackBase* mCallback;
+ CallbackBase* mCallback;
- static AbortHandler* gInstance;
+ static AbortHandler* gInstance;
};
} // Namespace Adaptor
{
namespace Internal
{
-
/**
* @brief Atomic write to an aligned memory location in cacheable memory.
*
* aligned to a 4 byte boundary.
* @param value A value to assign to the memory location in address.
*/
-inline void AtomicWriteToCacheableAlignedAddress( volatile uint32_t * const address, const uint32_t value )
+inline void AtomicWriteToCacheableAlignedAddress(volatile uint32_t* const address, const uint32_t value)
{
- DALI_ASSERT_DEBUG( ptrdiff_t(address) % 4 == 0 && "Address must be 32 bit aligned" );
+ DALI_ASSERT_DEBUG(ptrdiff_t(address) % 4 == 0 && "Address must be 32 bit aligned");
*address = value;
}
* aligned to a 4 byte boundary.
* @return The value stored at the memory location in address.
*/
-inline uint32_t AtomicReadFromCacheableAlignedAddress( const volatile uint32_t * const address )
+inline uint32_t AtomicReadFromCacheableAlignedAddress(const volatile uint32_t* const address)
{
- DALI_ASSERT_DEBUG( ptrdiff_t(address) % 4 == 0 && "Address must be 32 bit aligned" );
+ DALI_ASSERT_DEBUG(ptrdiff_t(address) % 4 == 0 && "Address must be 32 bit aligned");
return *address;
}
#define DALI_INTERNAL_CALLBACK_MANAGER_H
/*
- * 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
{
-
/**
* Abstract interface to install call backs in to an applications main loop.
*/
class CallbackManager
{
-
public:
-
- /**
+ /**
* Create a new call back interface
*/
- static CallbackManager* New();
+ static CallbackManager* New();
- /**
+ /**
* Virtual destructor
*/
- virtual ~CallbackManager() {}
+ virtual ~CallbackManager()
+ {
+ }
- /**
+ /**
* @brief Adds a @p callback to be run on idle.
* @note Must be called from the main thread only.
*
*
* @return true on success
*/
- virtual bool AddIdleCallback( CallbackBase* callback, bool hasReturnValue ) = 0;
+ virtual bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) = 0;
- /**
+ /**
* @brief Removes a previously added @p callback.
* @note Must be called from main thread only.
*
*
* @param[in] callback The callback to be removed.
*/
- virtual void RemoveIdleCallback( CallbackBase* callback ) = 0;
+ virtual void RemoveIdleCallback(CallbackBase* callback) = 0;
- /**
+ /**
* @brief Processes the idle callbacks.
*
* @return whether a DALi callback has been processed.
*/
- virtual bool ProcessIdle() = 0;
+ virtual bool ProcessIdle() = 0;
- /**
+ /**
* @brief Clears the container of callbacks.
*/
- virtual void ClearIdleCallbacks() = 0;
+ virtual void ClearIdleCallbacks() = 0;
- /**
+ /**
* @brief Adds a @p callback to be run when entering an idle state.
* @note Must be called from the main thread only.
*
*
* @return true on success
*/
- virtual bool AddIdleEntererCallback( CallbackBase* callback ) = 0;
+ virtual bool AddIdleEntererCallback(CallbackBase* callback) = 0;
- /**
+ /**
* @brief Removes a previously added the idle enterer callback.
* @note Must be called from main thread only.
*
*
* @param[in] callback The callback to be removed.
*/
- virtual void RemoveIdleEntererCallback( CallbackBase* callback ) = 0;
+ virtual void RemoveIdleEntererCallback(CallbackBase* callback) = 0;
- /**
+ /**
* Starts the callback manager.
*/
- virtual void Start() = 0;
+ virtual void Start() = 0;
- /**
+ /**
* Stop the callback manager and can remove all pending callbacks synchronously.
* This call will synchronise with the main loop and not return
* until all call backs have been deleted.
*/
- virtual void Stop() = 0;
+ virtual void Stop() = 0;
protected:
-
- /**
+ /**
* constructor
*/
- CallbackManager() {}
+ CallbackManager()
+ {
+ }
private:
+ // Undefined copy constructor.
+ CallbackManager(const CallbackManager&);
- // Undefined copy constructor.
- CallbackManager( const CallbackManager& );
-
- // Undefined assignment operator.
- CallbackManager& operator=( const CallbackManager& );
-
+ // Undefined assignment operator.
+ CallbackManager& operator=(const CallbackManager&);
};
} // 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/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
#define DALI_INTERNAL_CAPTURE_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.
*/
// EXTERNAL INCLUDES
-#include <string>
-#include <memory>
-#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/render-tasks/render-task.h>
-#include <dali/public-api/rendering/texture.h>
#include <dali/public-api/rendering/frame-buffer.h>
+#include <dali/public-api/rendering/texture.h>
+#include <memory>
+#include <string>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
-#include <dali/public-api/capture/capture.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
#include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/capture/capture.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class Capture;
typedef IntrusivePtr<Capture> CapturePtr;
class Capture : public BaseObject, public ConnectionTracker
{
public:
-
static constexpr uint32_t DEFAULT_QUALITY = 100;
/**
*/
Capture();
- Capture( Dali::CameraActor cameraActor );
+ Capture(Dali::CameraActor cameraActor);
/**
* @copydoc Dali::Capture::New
/**
* @copydoc Dali::Capture::New
*/
- static CapturePtr New( Dali::CameraActor cameraActor );
+ static CapturePtr New(Dali::CameraActor cameraActor);
/**
* @copydoc Dali::Capture::Start
*/
- void 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 Start(Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string& path, const Dali::Vector4& clearColor, const uint32_t quality);
/**
* @copydoc Dali::Capture::Start
*/
- void Start( Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor );
+ void Start(Dali::Actor source, const Dali::Vector2& position, const Dali::Vector2& size, const std::string& path, const Dali::Vector4& clearColor);
/**
* @copydoc Dali::Capture::SetImageQuality
*/
- void SetImageQuality( uint32_t quality );
+ void SetImageQuality(uint32_t quality);
/**
* @copydoc Dali::Capture::GetNativeImageSource
Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
protected:
-
/**
* @brief A reference counted object may only be deleted by calling Unreference()
*/
/**
* @brief Create native image source.
*/
- void CreateNativeImageSource( const Dali::Vector2& size );
+ void CreateNativeImageSource(const Dali::Vector2& size);
/**
* @brief Delete native image source.
* @param[in] source sub-scene tree to be captured.
* @param[in] clearColor background color
*/
- void SetupRenderTask( const Dali::Vector2& position, const Dali::Vector2& size, Dali::Actor source, const Dali::Vector4& clearColor );
+ void SetupRenderTask(const Dali::Vector2& position, const Dali::Vector2& size, Dali::Actor source, const Dali::Vector4& clearColor);
/**
* @brief Unset render task.
* @param[in] clearColor color to clear background surface.
* @param[in] source sub-scene tree to be captured.
*/
- void SetupResources( const Dali::Vector2& position, const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source );
+ void SetupResources(const Dali::Vector2& position, const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source);
/**
* @brief Unset resources for capture.
*
* @param[in] task is used for capture.
*/
- void OnRenderFinished( Dali::RenderTask& task );
+ void OnRenderFinished(Dali::RenderTask& task);
/**
* @brief Callback when timer is finished.
bool SaveFile();
private:
-
// Undefined
- Capture( const Capture& );
+ Capture(const Capture&);
// Undefined
- Capture& operator=( const Capture& rhs );
+ Capture& operator=(const Capture& rhs);
private:
- uint32_t mQuality;
- Dali::Texture mNativeTexture;
- Dali::FrameBuffer mFrameBuffer;
- Dali::RenderTask mRenderTask;
- Dali::Actor mSource;
- Dali::CameraActor mCameraActor;
- Dali::Timer mTimer; ///< For timeout.
- Dali::Capture::CaptureFinishedSignalType mFinishedSignal;
- std::string mPath;
- Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< pointer to surface image
- bool mFileSave;
+ uint32_t mQuality;
+ Dali::Texture mNativeTexture;
+ Dali::FrameBuffer mFrameBuffer;
+ Dali::RenderTask mRenderTask;
+ Dali::Actor mSource;
+ Dali::CameraActor mCameraActor;
+ Dali::Timer mTimer; ///< For timeout.
+ Dali::Capture::CaptureFinishedSignalType mFinishedSignal;
+ std::string mPath;
+ Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< pointer to surface image
+ bool mFileSave;
};
-} // End of namespace Adaptor
-} // End of namespace Internal
+} // End of namespace Adaptor
+} // End of namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::Adaptor::Capture& GetImpl( Dali::Capture& captureWorker)
+inline Internal::Adaptor::Capture& GetImpl(Dali::Capture& captureWorker)
{
- DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
+ DALI_ASSERT_ALWAYS(captureWorker && "Capture handle is empty");
BaseObject& handle = captureWorker.GetBaseObject();
- return static_cast< Internal::Adaptor::Capture& >( handle );
+ return static_cast<Internal::Adaptor::Capture&>(handle);
}
-inline const Internal::Adaptor::Capture& GetImpl( const Dali::Capture& captureWorker )
+inline const Internal::Adaptor::Capture& GetImpl(const Dali::Capture& captureWorker)
{
- DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
+ DALI_ASSERT_ALWAYS(captureWorker && "Capture handle is empty");
const BaseObject& handle = captureWorker.GetBaseObject();
- return static_cast< const Internal::Adaptor::Capture& >( handle );
+ return static_cast<const Internal::Adaptor::Capture&>(handle);
}
-} // End of namespace Dali
+} // End of namespace Dali
#endif // DALI_INTERNAL_CAPTURE_H
/*
- * 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;
}
#define DALI_INTERNAL_COLOR_CONTROLLER_H
/*
- * 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/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/color-controller.h>
#include <dali/devel-api/adaptor-framework/color-controller-plugin.h>
+#include <dali/devel-api/adaptor-framework/color-controller.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of ColorController
*/
class ColorController : public BaseObject
{
public:
-
/**
* Constructor.
*/
/**
* @copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&)
*/
- bool RetrieveColor( const std::string& colorCode, Vector4& colorValue );
+ bool RetrieveColor(const std::string& colorCode, Vector4& colorValue);
/**
* @copydoc Dali::ColorController::RetrieveColor(const std::string&, Vector4&, Vector4&, Vector4&)
*/
- bool RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor);
+ bool RetrieveColor(const std::string& colorCode, Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor);
private:
-
- /**
+ /**
* @brief Initialize
*/
void Initialize();
~ColorController() override;
private:
-
using CreateColorControllerFunction = Dali::ColorControllerPlugin* (*)();
- void* mLibHandle; ///< Handle for the loaded library
- Dali::ColorControllerPlugin* mPlugin; ///< Plugin handle
-
- CreateColorControllerFunction mCreateColorControllerPtr; ///< Function pointer called in adaptor to create a plugin instance
+ void* mLibHandle; ///< Handle for the loaded library
+ Dali::ColorControllerPlugin* mPlugin; ///< Plugin handle
+ CreateColorControllerFunction mCreateColorControllerPtr; ///< Function pointer called in adaptor to create a plugin instance
};
} // 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
{
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
}
#define DALI_INTERNAL_COMMAND_LINE_OPTIONS_H
/*
- * 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 <string>
#include <cstdint> // int32_t
+#include <string>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Parses the passed command line arguments and sets the values stored within this
* class appropriately.
struct CommandLineOptions
{
public:
-
/**
* Constructor
* @param[in,out] argc The number of arguments
* @param[in,out] argv The argument list
* @note Supported options are stripped from argv, and argc is updated appropriately.
*/
- CommandLineOptions( int32_t *argc, char **argv[] );
+ CommandLineOptions(int32_t* argc, char** argv[]);
/**
* Destructor
*/
~CommandLineOptions();
-public: // Command line parsed values
-
- int32_t stageWidth; ///< The width of the stage required. 0 if not set.
- int32_t stageHeight; ///< The height of the stage required. 0 if not set.
+public: // Command line parsed values
+ int32_t stageWidth; ///< The width of the stage required. 0 if not set.
+ int32_t stageHeight; ///< The height of the stage required. 0 if not set.
std::string stageDPI; ///< DPI stored as hxv, where h is horizontal DPI and v is vertical DPI
};
/*
- * 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/configuration-manager.h>
// EXTERNAL INCLUDES
-#include <fstream>
#include <dali/integration-api/debug.h>
+#include <fstream>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/file-stream.h>
-#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/system/common/environment-options.h>
#include <dali/internal/system/common/environment-variables.h>
#include <dali/internal/system/common/thread-controller.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace
{
-
-const std::string SYSTEM_CACHE_FILE = "gpu-environment.conf";
-const std::string DALI_ENV_MULTIPLE_WINDOW_SUPPORT = "DALI_ENV_MULTIPLE_WINDOW_SUPPORT";
+const std::string SYSTEM_CACHE_FILE = "gpu-environment.conf";
+const std::string DALI_ENV_MULTIPLE_WINDOW_SUPPORT = "DALI_ENV_MULTIPLE_WINDOW_SUPPORT";
const std::string DALI_BLEND_EQUATION_ADVANCED_SUPPORT = "DALI_BLEND_EQUATION_ADVANCED_SUPPORT";
-const std::string DALI_GLSL_VERSION = "DALI_GLSL_VERSION";
-
-bool RetrieveKeyFromConfigFile( std::iostream& stream, const std::string& key, std::string& value )
-{
- bool keyFound = false;
-
- std::string 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 == "" )
- {
- continue;
- }
-
- std::istringstream stream( line );
- std::string name;
- std::getline(stream, name, ' ');
- if( name == key )
- {
- std::getline(stream, value);
- keyFound = true;
- break;
- }
- }
-
- return keyFound;
-}
-
+const std::string DALI_GLSL_VERSION = "DALI_GLSL_VERSION";
} // unnamed namespace
-ConfigurationManager::ConfigurationManager( std::string systemCachePath, EglGraphics* eglGraphics, ThreadController* threadController )
-: mSystemCacheFilePath( systemCachePath + SYSTEM_CACHE_FILE ),
- mEglGraphics( eglGraphics ),
- mThreadController( threadController ),
- mMaxTextureSize( 0u ),
- mGlslVersion( 0u),
- mIsMultipleWindowSupported( true ),
- mIsAdvancedBlendEquationSupported( true ),
- mMaxTextureSizeCached( false ),
- mIsMultipleWindowSupportedCached( false ),
- mIsAdvancedBlendEquationSupportedCached( false ),
- mGlslVersionCached( false )
+ConfigurationManager::ConfigurationManager(std::string systemCachePath, GraphicsInterface* graphics, ThreadController* threadController)
+: mSystemCacheFilePath(systemCachePath + SYSTEM_CACHE_FILE),
+ mGraphics(graphics),
+ mThreadController(threadController),
+ mMaxTextureSize(0u),
+ mShaderLanguageVersion(0u),
+ mIsMultipleWindowSupported(true),
+ mIsAdvancedBlendEquationSupported(true),
+ mMaxTextureSizeCached(false),
+ mIsMultipleWindowSupportedCached(false),
+ mIsAdvancedBlendEquationSupportedCached(false),
+ mShaderLanguageVersionCached(false)
{
}
{
}
-void ConfigurationManager::RetrieveKeysFromConfigFile( const std::string& configFilePath )
+void ConfigurationManager::RetrieveKeysFromConfigFile(const std::string& configFilePath)
{
- Dali::FileStream configFile( configFilePath, Dali::FileStream::READ | Dali::FileStream::TEXT );
- std::iostream& stream = configFile.GetStream();
- if( stream.rdbuf()->in_avail() )
+ Dali::FileStream configFile(configFilePath, Dali::FileStream::READ | Dali::FileStream::TEXT);
+ std::iostream& stream = configFile.GetStream();
+ if(stream.rdbuf()->in_avail())
{
- std::string value;
- if( !mMaxTextureSizeCached &&
- RetrieveKeyFromConfigFile( stream, DALI_ENV_MAX_TEXTURE_SIZE, value ) )
- {
- mMaxTextureSize = std::atoi( value.c_str() );
- mMaxTextureSizeCached = true;
- }
-
- if( !mGlslVersionCached &&
- RetrieveKeyFromConfigFile( stream, DALI_GLSL_VERSION, value ) )
- {
- mGlslVersion = std::atoi( value.c_str() );
- mGlslVersionCached = true;
- }
-
- if( !mIsMultipleWindowSupportedCached &&
- RetrieveKeyFromConfigFile( stream, DALI_ENV_MULTIPLE_WINDOW_SUPPORT, value ) )
+ std::string line;
+ while(std::getline(stream, line))
{
- mIsMultipleWindowSupported = std::atoi( value.c_str() );
- mIsMultipleWindowSupportedCached = true;
- }
+ 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;
+ }
- if( !mIsAdvancedBlendEquationSupportedCached &&
- RetrieveKeyFromConfigFile( stream, DALI_BLEND_EQUATION_ADVANCED_SUPPORT, value ) )
- {
- mIsAdvancedBlendEquationSupported = std::atoi( value.c_str() );
- mIsAdvancedBlendEquationSupportedCached = true;
+ std::istringstream subStream(line);
+ std::string name;
+ std::string value;
+ std::getline(subStream, name, ' ');
+ if(!mMaxTextureSizeCached && name == DALI_ENV_MAX_TEXTURE_SIZE)
+ {
+ std::getline(subStream, value);
+ mMaxTextureSize = std::atoi(value.c_str());
+ mMaxTextureSizeCached = true;
+ }
+ else if(!mIsAdvancedBlendEquationSupportedCached && name == DALI_BLEND_EQUATION_ADVANCED_SUPPORT)
+ {
+ std::getline(subStream, value);
+ mIsAdvancedBlendEquationSupported = std::atoi(value.c_str());
+ mIsAdvancedBlendEquationSupportedCached = true;
+ }
+ else if(!mShaderLanguageVersionCached && name == DALI_GLSL_VERSION)
+ {
+ std::getline(subStream, value);
+ mShaderLanguageVersion = std::atoi(value.c_str());
+ mShaderLanguageVersionCached = true;
+ }
+ else if(!mIsMultipleWindowSupportedCached && name == DALI_ENV_MULTIPLE_WINDOW_SUPPORT)
+ {
+ std::getline(subStream, value);
+ mIsMultipleWindowSupported = std::atoi(value.c_str());
+ mIsMultipleWindowSupportedCached = true;
+ }
}
}
}
uint32_t ConfigurationManager::GetMaxTextureSize()
{
- if( !mMaxTextureSizeCached )
+ if(!mMaxTextureSizeCached)
{
- RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
- if( !mMaxTextureSizeCached )
+ if(!mMaxTextureSizeCached)
{
- GlImplementation& mGLES = mEglGraphics->GetGlesInterface();
- mMaxTextureSize = mGLES.GetMaxTextureSize();
+ mMaxTextureSize = mGraphics->GetMaxTextureSize();
mMaxTextureSizeCached = true;
- Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
- std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
- if( stream.is_open() )
+ Dali::FileStream configFile(mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT);
+ std::fstream& stream = dynamic_cast<std::fstream&>(configFile.GetStream());
+ if(stream.is_open())
{
stream << DALI_ENV_MAX_TEXTURE_SIZE << " " << mMaxTextureSize << std::endl;
}
else
{
- DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
}
}
}
uint32_t ConfigurationManager::GetShadingLanguageVersion()
{
- if ( !mGlslVersionCached )
+ if(!mShaderLanguageVersionCached)
{
- RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
- if ( !mGlslVersionCached )
+ if(!mShaderLanguageVersionCached)
{
- EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
- if ( !eglImpl.IsGlesInitialized() )
+ if(!mGraphics->IsInitialized())
{
- // Wait until GLES is initialised, but this will happen once.
+ // Wait until Graphics Subsystem is initialised, but this will happen once.
// This method blocks until the render thread has initialised the graphics.
mThreadController->WaitForGraphicsInitialization();
}
- // Query from GLES and save the cache
- mGlslVersion = mEglGraphics->GetGlesInterface().GetShadingLanguageVersion();
- DALI_LOG_ERROR("mGlslVersion : %d\n", mGlslVersion);
- mGlslVersionCached = true;
+ // Query from graphics and save the cache
+ mShaderLanguageVersion = mGraphics->GetShaderLanguageVersion();
+ mShaderLanguageVersionCached = true;
- Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
- std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
- if ( stream.is_open() )
+ Dali::FileStream configFile(mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT);
+ std::fstream& stream = dynamic_cast<std::fstream&>(configFile.GetStream());
+ if(stream.is_open())
{
- stream << DALI_GLSL_VERSION << " " << mGlslVersion << std::endl;
+ stream << DALI_GLSL_VERSION << " " << mShaderLanguageVersion << std::endl;
}
else
{
- DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
}
}
}
- return mGlslVersion;
+ return mShaderLanguageVersion;
}
bool ConfigurationManager::IsMultipleWindowSupported()
{
- if ( !mIsMultipleWindowSupportedCached )
+ if(!mIsMultipleWindowSupportedCached)
{
- RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
- if ( !mIsMultipleWindowSupportedCached )
+ if(!mIsMultipleWindowSupportedCached)
{
- EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
- if ( !eglImpl.IsGlesInitialized() )
+ if(!mGraphics->IsInitialized())
{
- // Wait until GLES is initialised, but this will happen once.
+ // Wait until Graphics Subsystem is initialised, but this will happen once.
// This method blocks until the render thread has initialised the graphics.
mThreadController->WaitForGraphicsInitialization();
}
- // Query from GLES and save the cache
- mIsMultipleWindowSupported = eglImpl.IsSurfacelessContextSupported();
+ // Query from Graphics Subsystem and save the cache
+ mIsMultipleWindowSupported = mGraphics->IsResourceContextSupported();
mIsMultipleWindowSupportedCached = true;
- Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
- std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
- if ( stream.is_open() )
+ Dali::FileStream configFile(mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT);
+ std::fstream& stream = dynamic_cast<std::fstream&>(configFile.GetStream());
+ if(stream.is_open())
{
stream << DALI_ENV_MULTIPLE_WINDOW_SUPPORT << " " << mIsMultipleWindowSupported << std::endl;
}
else
{
- DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
}
}
}
bool ConfigurationManager::IsAdvancedBlendEquationSupported()
{
- if ( !mIsAdvancedBlendEquationSupportedCached )
+ if(!mIsAdvancedBlendEquationSupportedCached)
{
- RetrieveKeysFromConfigFile( mSystemCacheFilePath );
+ RetrieveKeysFromConfigFile(mSystemCacheFilePath);
- if ( !mIsAdvancedBlendEquationSupportedCached )
+ if(!mIsAdvancedBlendEquationSupportedCached)
{
- EglImplementation& eglImpl = mEglGraphics->GetEglImplementation();
- if ( !eglImpl.IsGlesInitialized() )
+ if(!mGraphics->IsInitialized())
{
- // Wait until GLES is initialised, but this will happen once.
+ // Wait until graphics subsystem is initialised, but this will happen once per factory reset.
// This method blocks until the render thread has initialised the graphics.
mThreadController->WaitForGraphicsInitialization();
}
- // Query from GLES and save the cache
- mIsAdvancedBlendEquationSupported = mEglGraphics->GetGlesInterface().IsAdvancedBlendEquationSupported();
+ // Query from Graphics Subsystem and save the cache
+ mIsAdvancedBlendEquationSupported = mGraphics->IsAdvancedBlendEquationSupported();
mIsAdvancedBlendEquationSupportedCached = true;
- Dali::FileStream configFile( mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT );
- std::fstream& stream = dynamic_cast<std::fstream&>( configFile.GetStream() );
- if ( stream.is_open() )
+ Dali::FileStream configFile(mSystemCacheFilePath, Dali::FileStream::READ | Dali::FileStream::APPEND | Dali::FileStream::TEXT);
+ std::fstream& stream = dynamic_cast<std::fstream&>(configFile.GetStream());
+ if(stream.is_open())
{
stream << DALI_BLEND_EQUATION_ADVANCED_SUPPORT << " " << mIsAdvancedBlendEquationSupported << std::endl;
}
else
{
- DALI_LOG_ERROR( "Fail to open file : %s\n", mSystemCacheFilePath.c_str() );
+ DALI_LOG_ERROR("Fail to open file : %s\n", mSystemCacheFilePath.c_str());
}
}
}
return mIsAdvancedBlendEquationSupported;
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_ENVIRONMENT_CONFIGURATION_MANAGER_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
{
-
class FileStream;
namespace Internal
{
namespace Adaptor
{
-
-class EglGraphics;
+class GraphicsInterface;
class ThreadController;
/**
class ConfigurationManager
{
public:
-
/**
* @brief Constructor
*/
- ConfigurationManager( std::string systemCachePath, EglGraphics* eglGraphics, ThreadController* threadController );
+ ConfigurationManager(std::string systemCachePath, GraphicsInterface* graphics, ThreadController* threadController);
/**
* @brief Virtual Destructor for interface cleanup
/**
* @brief Retrieve all keys from the config file if the file exists.
*/
- void RetrieveKeysFromConfigFile( const std::string& configFilePath );
+ void RetrieveKeysFromConfigFile(const std::string& configFilePath);
/**
* @brief Get the maximum texture size.
uint32_t GetMaxTextureSize();
/**
- * @brief Get the GLSL version that the system supports
- * @return the GLSL version.
+ * @brief Get the shader language version that the system supports
+ * @return the shader language version.
*/
uint32_t GetShadingLanguageVersion();
bool IsAdvancedBlendEquationSupported();
// Deleted copy constructor.
- ConfigurationManager( const ConfigurationManager& ) = delete;
+ ConfigurationManager(const ConfigurationManager&) = delete;
// Deleted move constructor.
- ConfigurationManager( const ConfigurationManager&& ) = delete;
+ ConfigurationManager(const ConfigurationManager&&) = delete;
// Deleted assignment operator.
- ConfigurationManager& operator=( const ConfigurationManager& ) = delete;
+ ConfigurationManager& operator=(const ConfigurationManager&) = delete;
// Deleted move assignment operator.
- ConfigurationManager& operator=( const ConfigurationManager&& ) = delete;
-
-private: // Data
-
- std::string mSystemCacheFilePath; ///< The path of system cache file
- EglGraphics* mEglGraphics; ///< EGL graphics
- ThreadController* mThreadController; ///< The thread controller
- unsigned int mMaxTextureSize; ///< The largest texture that the GL can handle
- unsigned int mGlslVersion; ///< The GLSL version that the system supports.
- bool mIsMultipleWindowSupported:1; ///< Whether multiple window is supported by the GLES
- bool mIsAdvancedBlendEquationSupported:1; ///< Whether blend equation advanced (extension) is supported by the GLES
- bool mMaxTextureSizeCached:1; ///< Whether we have checked the maximum texture size
- bool mIsMultipleWindowSupportedCached:1; ///< Whether we have checked the support of multiple window
- bool mIsAdvancedBlendEquationSupportedCached:1;///< Whether we have checked the support of blend equation advanced (extension)
- bool mGlslVersionCached:1; ///< Whether we have checked the GLSL version
+ ConfigurationManager& operator=(const ConfigurationManager&&) = delete;
+
+private: // Data
+ std::string mSystemCacheFilePath; ///< The path of system cache file
+ GraphicsInterface* mGraphics; ///< Graphics interface
+ ThreadController* mThreadController; ///< The thread controller
+ unsigned int mMaxTextureSize; ///< The largest texture that the GL can handle
+ unsigned int mShaderLanguageVersion; ///< The shader language version that the system supports.
+ bool mIsMultipleWindowSupported : 1; ///< Whether multiple window is supported by the GLES
+ bool mIsAdvancedBlendEquationSupported : 1; ///< Whether blend equation advanced (extension) is supported by the GLES
+ bool mMaxTextureSizeCached : 1; ///< Whether we have checked the maximum texture size
+ bool mIsMultipleWindowSupportedCached : 1; ///< Whether we have checked the support of multiple window
+ bool mIsAdvancedBlendEquationSupportedCached : 1; ///< Whether we have checked the support of blend equation advanced (extension)
+ bool mShaderLanguageVersionCached : 1; ///< Whether we have checked the shader language version
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ENVIRONMENT_CONFIGURATION_MANAGER_H
#define DALI_INTERNAL_ADAPTOR_CORE_EVENT_INTERFACE_H
/*
- * 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 Integration
{
struct Event;
namespace Internal
{
-
namespace Adaptor
{
-
/**
* This interface should be used by adaptor components to send events to Core.
* This is preferable to using Core directly i.e. so there is a common place for measuring performance.
class CoreEventInterface
{
public:
-
/**
* Queue an event with Core.
* @param[in] event The new event.
virtual void ProcessCoreEvents() = 0;
protected:
-
/**
* Protected virtual destructor
*/
- virtual ~CoreEventInterface() {}
+ virtual ~CoreEventInterface()
+ {
+ }
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_CORE_EVENT_INTERFACE_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.
#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
#define DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H
/*
- * 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 <memory>
#include <dali/integration-api/debug.h>
+#include <memory>
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
class EnvironmentOptions : public Dali::LogFactoryInterface
{
public:
-
/**
* Constructor
*/
* Create a TraceManager which is used for tracing.
* @param PerformanceInterface for using network logging for tracing on Ubuntu
*/
- void CreateTraceManager( PerformanceInterface* performanceInterface );
+ void CreateTraceManager(PerformanceInterface* performanceInterface);
/**
* Initialize TraceManager by installing Trace function.
/**
* @param logFunction logging function
*/
- void SetLogFunction( const Dali::Integration::Log::LogFunction& logFunction );
+ void SetLogFunction(const Dali::Integration::Log::LogFunction& logFunction);
/**
* Install the log function for the current thread.
bool PartialUpdateRequired() const;
/// Deleted copy constructor.
- EnvironmentOptions( const EnvironmentOptions& ) = delete;
+ EnvironmentOptions(const EnvironmentOptions&) = delete;
/// Deleted move constructor.
- EnvironmentOptions( const EnvironmentOptions&& ) = delete;
+ EnvironmentOptions(const EnvironmentOptions&&) = delete;
/// Deleted assignment operator.
- EnvironmentOptions& operator=( const EnvironmentOptions& ) = delete;
+ EnvironmentOptions& operator=(const EnvironmentOptions&) = delete;
/// Deleted move assignment operator.
- EnvironmentOptions& operator=( const EnvironmentOptions&& ) = delete;
+ EnvironmentOptions& operator=(const EnvironmentOptions&&) = delete;
private: // Internal
-
/**
* Parses the environment options.
* Called from the constructor
void ParseEnvironmentOptions();
private: // Data
-
Dali::Integration::Log::LogFunction mLogFunction;
- std::string mWindowName; ///< name of the window
- std::string mWindowClassName; ///< name of the class the window belongs to
- unsigned int mNetworkControl; ///< whether network control is enabled
- unsigned int mFpsFrequency; ///< how often fps is logged out in seconds
- unsigned int mUpdateStatusFrequency; ///< how often update status is logged out in frames
- unsigned int mObjectProfilerInterval; ///< how often object counts are logged out in seconds
- unsigned int mPerformanceStatsLevel; ///< performance statistics logging bitmask
- unsigned int mPerformanceStatsFrequency; ///< performance statistics logging frequency (seconds)
- unsigned int mPerformanceTimeStampOutput; ///< performance time stamp output ( bitmask)
- unsigned int mPanGestureLoggingLevel; ///< pan-gesture log level
- unsigned int mWindowWidth; ///< width of the window
- unsigned int mWindowHeight; ///< height of the window
- unsigned int mRenderRefreshRate; ///< render refresh rate
- unsigned int mMaxTextureSize; ///< The maximum texture size that GL can handle
- unsigned int mRenderToFboInterval; ///< The number of frames that are going to be rendered into the Frame Buffer Object but the last one which is going to be rendered into the Frame Buffer.
- int mPanGesturePredictionMode; ///< prediction mode for pan gestures
- int mPanGesturePredictionAmount; ///< prediction amount for pan gestures
- int mPanGestureMaxPredictionAmount; ///< maximum prediction amount for pan gestures
- int mPanGestureMinPredictionAmount; ///< minimum prediction amount for pan gestures
- int mPanGesturePredictionAmountAdjustment; ///< adjustment of prediction amount for pan gestures
- int mPanGestureSmoothingMode; ///< prediction mode for pan gestures
- float mPanGestureSmoothingAmount; ///< prediction amount for pan gestures
- int mPanGestureUseActualTimes; ///< Disable to optionally override actual times if they make results worse.
- int mPanGestureInterpolationTimeRange; ///< Time into past history (ms) to use points to interpolate the first point.
- int mPanGestureScalarOnlyPredictionEnabled; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
- int mPanGestureTwoPointPredictionEnabled; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
- int mPanGestureTwoPointInterpolatePastTime; ///< The target time in the past to generate the second interpolated point.
- float mPanGestureTwoPointVelocityBias; ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
- float mPanGestureTwoPointAccelerationBias; ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
- int mPanGestureMultitapSmoothingRange; ///< The range in time (ms) of points in the history to smooth the final output against.
- int mPanMinimumDistance; ///< minimum distance required before pan starts
- int mPanMinimumEvents; ///< minimum events required before pan starts
- float mPinchMinimumDistance; ///< minimum number of pixels moved before a pinch starts
- int mPinchMinimumTouchEvents; ///< minimum events required before a pinch starts
- int mPinchMinimumTouchEventsAfterStart; ///< minimum events required after a pinch started
- int mRotationMinimumTouchEvents; ///< minimum events required before a rotation starts
- int mRotationMinimumTouchEventsAfterStart; ///< minimum events required after a rotation started
- int mLongPressMinimumHoldingTime; ///< minimum holding time required to be recognized as a long press gesture (millisecond)
- int mGlesCallTime; ///< time in seconds between status updates
- int mMultiSamplingLevel; ///< The number of samples required in multisample buffers
- ThreadingMode::Type mThreadingMode; ///< threading mode
- bool mGlesCallAccumulate; ///< Whether or not to accumulate gles call statistics
- bool mDepthBufferRequired; ///< Whether the depth buffer is required
- bool mStencilBufferRequired; ///< Whether the stencil buffer is required
- bool mPartialUpdateRequired; ///< Whether the partial update is required
- std::unique_ptr<TraceManager> mTraceManager; ///< TraceManager
+
+ std::string mWindowName; ///< name of the window
+ std::string mWindowClassName; ///< name of the class the window belongs to
+
+ unsigned int mNetworkControl; ///< whether network control is enabled
+ unsigned int mFpsFrequency; ///< how often fps is logged out in seconds
+ unsigned int mUpdateStatusFrequency; ///< how often update status is logged out in frames
+ unsigned int mObjectProfilerInterval; ///< how often object counts are logged out in seconds
+ unsigned int mPerformanceStatsLevel; ///< performance statistics logging bitmask
+ unsigned int mPerformanceStatsFrequency; ///< performance statistics logging frequency (seconds)
+ unsigned int mPerformanceTimeStampOutput; ///< performance time stamp output ( bitmask)
+ unsigned int mPanGestureLoggingLevel; ///< pan-gesture log level
+ unsigned int mWindowWidth; ///< width of the window
+ unsigned int mWindowHeight; ///< height of the window
+ unsigned int mRenderRefreshRate; ///< render refresh rate
+ unsigned int mMaxTextureSize; ///< The maximum texture size that GL can handle
+ unsigned int mRenderToFboInterval; ///< The number of frames that are going to be rendered into the Frame Buffer Object but the last one which is going to be rendered into the Frame Buffer.
+
+ int mPanGesturePredictionMode; ///< prediction mode for pan gestures
+ int mPanGesturePredictionAmount; ///< prediction amount for pan gestures
+ int mPanGestureMaxPredictionAmount; ///< maximum prediction amount for pan gestures
+ int mPanGestureMinPredictionAmount; ///< minimum prediction amount for pan gestures
+ int mPanGesturePredictionAmountAdjustment; ///< adjustment of prediction amount for pan gestures
+ int mPanGestureSmoothingMode; ///< prediction mode for pan gestures
+ float mPanGestureSmoothingAmount; ///< prediction amount for pan gestures
+ int mPanGestureUseActualTimes; ///< Disable to optionally override actual times if they make results worse.
+ int mPanGestureInterpolationTimeRange; ///< Time into past history (ms) to use points to interpolate the first point.
+ int mPanGestureScalarOnlyPredictionEnabled; ///< If enabled, prediction is done using velocity alone (no integration or acceleration).
+ int mPanGestureTwoPointPredictionEnabled; ///< If enabled, a second interpolated point is predicted and combined with the first to get more stable values.
+ int mPanGestureTwoPointInterpolatePastTime; ///< The target time in the past to generate the second interpolated point.
+ float mPanGestureTwoPointVelocityBias; ///< The ratio of first and second interpolated points to use for velocity. 0.0f = 100% of first point. 1.0f = 100% of second point.
+ float mPanGestureTwoPointAccelerationBias; ///< The ratio of first and second interpolated points to use for acceleration. 0.0f = 100% of first point. 1.0f = 100% of second point.
+ int mPanGestureMultitapSmoothingRange; ///< The range in time (ms) of points in the history to smooth the final output against.
+ int mPanMinimumDistance; ///< minimum distance required before pan starts
+ int mPanMinimumEvents; ///< minimum events required before pan starts
+ float mPinchMinimumDistance; ///< minimum number of pixels moved before a pinch starts
+ int mPinchMinimumTouchEvents; ///< minimum events required before a pinch starts
+ int mPinchMinimumTouchEventsAfterStart; ///< minimum events required after a pinch started
+ int mRotationMinimumTouchEvents; ///< minimum events required before a rotation starts
+ int mRotationMinimumTouchEventsAfterStart; ///< minimum events required after a rotation started
+ int mLongPressMinimumHoldingTime; ///< minimum holding time required to be recognized as a long press gesture (millisecond)
+ int mGlesCallTime; ///< time in seconds between status updates
+ int mMultiSamplingLevel; ///< The number of samples required in multisample buffers
+
+ ThreadingMode::Type mThreadingMode; ///< threading mode
+
+ bool mGlesCallAccumulate; ///< Whether or not to accumulate gles call statistics
+ bool mDepthBufferRequired; ///< Whether the depth buffer is required
+ bool mStencilBufferRequired; ///< Whether the stencil buffer is required
+ bool mPartialUpdateRequired; ///< Whether the partial update is required
+
+ std::unique_ptr<TraceManager> mTraceManager; ///< TraceManager
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_ENVIRONMENT_OPTIONS_H
#define DALI_INTERNAL_ADAPTOR_ENVIRONMENT_VARIABLES_H
/*
- * 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
{
-
/**
* What performance statistics are logged out to dlog
* see StatisticsLogOptions in performance-interface.h for values
// Pan-Gesture configuration:
// Prediction Modes 1 & 2:
-#define DALI_ENV_PAN_PREDICTION_MODE "DALI_PAN_PREDICTION_MODE"
-#define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT"
-#define DALI_ENV_PAN_SMOOTHING_MODE "DALI_PAN_SMOOTHING_MODE"
+#define DALI_ENV_PAN_PREDICTION_MODE "DALI_PAN_PREDICTION_MODE"
+#define DALI_ENV_PAN_PREDICTION_AMOUNT "DALI_PAN_PREDICTION_AMOUNT"
+#define DALI_ENV_PAN_SMOOTHING_MODE "DALI_PAN_SMOOTHING_MODE"
// Prediction Mode 1:
-#define DALI_ENV_PAN_MAX_PREDICTION_AMOUNT "DALI_PAN_MAX_PREDICTION_AMOUNT"
-#define DALI_ENV_PAN_MIN_PREDICTION_AMOUNT "DALI_PAN_MIN_PREDICTION_AMOUNT"
-#define DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT "DALI_PAN_PREDICTION_AMOUNT_ADJUSTMENT"
-#define DALI_ENV_PAN_SMOOTHING_AMOUNT "DALI_PAN_SMOOTHING_AMOUNT"
+#define DALI_ENV_PAN_MAX_PREDICTION_AMOUNT "DALI_PAN_MAX_PREDICTION_AMOUNT"
+#define DALI_ENV_PAN_MIN_PREDICTION_AMOUNT "DALI_PAN_MIN_PREDICTION_AMOUNT"
+#define DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT "DALI_PAN_PREDICTION_AMOUNT_ADJUSTMENT"
+#define DALI_ENV_PAN_SMOOTHING_AMOUNT "DALI_PAN_SMOOTHING_AMOUNT"
// Prediction Mode 2:
-#define DALI_ENV_PAN_USE_ACTUAL_TIMES "DALI_PAN_USE_ACTUAL_TIMES"
-#define DALI_ENV_PAN_INTERPOLATION_TIME_RANGE "DALI_PAN_INTERPOLATION_TIME_RANGE"
-#define DALI_ENV_PAN_SCALAR_ONLY_PREDICTION_ENABLED "DALI_PAN_SCALAR_ONLY_PREDICTION_ENABLED"
-#define DALI_ENV_PAN_TWO_POINT_PREDICTION_ENABLED "DALI_PAN_TWO_POINT_PREDICTION_ENABLED"
-#define DALI_ENV_PAN_TWO_POINT_PAST_INTERPOLATE_TIME "DALI_PAN_TWO_POINT_PAST_INTERPOLATE_TIME"
-#define DALI_ENV_PAN_TWO_POINT_VELOCITY_BIAS "DALI_PAN_TWO_POINT_VELOCITY_BIAS"
-#define DALI_ENV_PAN_TWO_POINT_ACCELERATION_BIAS "DALI_PAN_TWO_POINT_ACCELERATION_BIAS"
-#define DALI_ENV_PAN_MULTITAP_SMOOTHING_RANGE "DALI_PAN_MULTITAP_SMOOTHING_RANGE"
+#define DALI_ENV_PAN_USE_ACTUAL_TIMES "DALI_PAN_USE_ACTUAL_TIMES"
+#define DALI_ENV_PAN_INTERPOLATION_TIME_RANGE "DALI_PAN_INTERPOLATION_TIME_RANGE"
+#define DALI_ENV_PAN_SCALAR_ONLY_PREDICTION_ENABLED "DALI_PAN_SCALAR_ONLY_PREDICTION_ENABLED"
+#define DALI_ENV_PAN_TWO_POINT_PREDICTION_ENABLED "DALI_PAN_TWO_POINT_PREDICTION_ENABLED"
+#define DALI_ENV_PAN_TWO_POINT_PAST_INTERPOLATE_TIME "DALI_PAN_TWO_POINT_PAST_INTERPOLATE_TIME"
+#define DALI_ENV_PAN_TWO_POINT_VELOCITY_BIAS "DALI_PAN_TWO_POINT_VELOCITY_BIAS"
+#define DALI_ENV_PAN_TWO_POINT_ACCELERATION_BIAS "DALI_PAN_TWO_POINT_ACCELERATION_BIAS"
+#define DALI_ENV_PAN_MULTITAP_SMOOTHING_RANGE "DALI_PAN_MULTITAP_SMOOTHING_RANGE"
// Pan-Gesture miscellaneous:
-#define DALI_ENV_LOG_PAN_GESTURE "DALI_LOG_PAN_GESTURE"
-#define DALI_ENV_PAN_MINIMUM_DISTANCE "DALI_PAN_MINIMUM_DISTANCE"
-#define DALI_ENV_PAN_MINIMUM_EVENTS "DALI_PAN_MINIMUM_EVENTS"
+#define DALI_ENV_LOG_PAN_GESTURE "DALI_LOG_PAN_GESTURE"
+#define DALI_ENV_PAN_MINIMUM_DISTANCE "DALI_PAN_MINIMUM_DISTANCE"
+#define DALI_ENV_PAN_MINIMUM_EVENTS "DALI_PAN_MINIMUM_EVENTS"
// Pinch-Gesture
-#define DALI_ENV_PINCH_MINIMUM_DISTANCE "DALI_PINCH_MINIMUM_DISTANCE"
-#define DALI_ENV_PINCH_MINIMUM_TOUCH_EVENTS "DALI_PINCH_MINIMUM_TOUCH_EVENTS"
-#define DALI_ENV_PINCH_MINIMUM_TOUCH_EVENTS_AFTER_START "DALI_PINCH_MINIMUM_TOUCH_EVENTS_AFTER_START"
+#define DALI_ENV_PINCH_MINIMUM_DISTANCE "DALI_PINCH_MINIMUM_DISTANCE"
+#define DALI_ENV_PINCH_MINIMUM_TOUCH_EVENTS "DALI_PINCH_MINIMUM_TOUCH_EVENTS"
+#define DALI_ENV_PINCH_MINIMUM_TOUCH_EVENTS_AFTER_START "DALI_PINCH_MINIMUM_TOUCH_EVENTS_AFTER_START"
// Rotation-Gesture
-#define DALI_ENV_ROTATION_MINIMUM_TOUCH_EVENTS "DALI_ROTATION_MINIMUM_TOUCH_EVENTS"
-#define DALI_ENV_ROTATION_MINIMUM_TOUCH_EVENTS_AFTER_START "DALI_ROTATION_MINIMUM_TOUCH_EVENTS_AFTER_START"
+#define DALI_ENV_ROTATION_MINIMUM_TOUCH_EVENTS "DALI_ROTATION_MINIMUM_TOUCH_EVENTS"
+#define DALI_ENV_ROTATION_MINIMUM_TOUCH_EVENTS_AFTER_START "DALI_ROTATION_MINIMUM_TOUCH_EVENTS_AFTER_START"
/**
* The minimum holding time required to be recognized as a long press gesture (milliseconds)
*/
-#define DALI_ENV_LONG_PRESS_MINIMUM_HOLDING_TIME "DALI_LONG_PRESS_MINIMUM_HOLDING_TIME"
+#define DALI_ENV_LONG_PRESS_MINIMUM_HOLDING_TIME "DALI_LONG_PRESS_MINIMUM_HOLDING_TIME"
#define DALI_GLES_CALL_TIME "DALI_GLES_CALL_TIME"
#ifndef DALI_INTERNAL_PLATFORM_FILECLOSER_H
#define DALI_INTERNAL_PLATFORM_FILECLOSER_H
/*
- * 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 Platform
{
-
/**
* Opens files and closes them later even if an exception is thrown.
*/
class FileCloser
{
protected: // prevent this class being directly instantiated
-
/**
* @brief Construct a FileCloser guarding a new FILE* for accessing the path passed in.
*/
- FileCloser( const char* const filename, const char* const mode )
+ FileCloser(const char* const filename, const char* const mode)
{
- DALI_ASSERT_DEBUG( filename != 0 && "Can't open a null filename." );
- DALI_ASSERT_DEBUG( mode != 0 && "Null mode is undefined behaviour in spec." );
+ DALI_ASSERT_DEBUG(filename != 0 && "Can't open a null filename.");
+ DALI_ASSERT_DEBUG(mode != 0 && "Null mode is undefined behaviour in spec.");
Dali::FileLoader::FileType fileType = Dali::FileLoader::FileType::TEXT;
const char* modeStr = mode;
- while( *modeStr )
+ while(*modeStr)
{
- switch ( *modeStr )
+ switch(*modeStr)
{
- case 'r':
- break;
- case 'b':
- fileType = FileLoader::FileType::BINARY;
- break;
- // Still has to use fopen for append and write modes
- case 'a':
- case 'w':
- case '+':
- mFile = fopen( filename, mode );
- return;
- default:
- break;
+ case 'r':
+ break;
+ case 'b':
+ fileType = FileLoader::FileType::BINARY;
+ break;
+ // Still has to use fopen for append and write modes
+ case 'a':
+ case 'w':
+ case '+':
+ mFile = fopen(filename, mode);
+ return;
+ default:
+ break;
}
++modeStr;
}
std::streampos bufferSize = 0;
- if( !Dali::FileLoader::ReadFile( filename, bufferSize, mFileBuffer, fileType ) )
+ if(!Dali::FileLoader::ReadFile(filename, bufferSize, mFileBuffer, fileType))
{
mFile = nullptr;
}
else
{
- mFile = fmemopen( &mFileBuffer[0], bufferSize, mode );
+ mFile = fmemopen(&mFileBuffer[0], bufferSize, mode);
}
}
/**
* @brief Construct a FileCloser guarding a FILE* for reading out of the memory buffer passed in.
*/
- FileCloser( uint8_t* buffer, size_t dataSize, const char* const mode )
- : mFile( fmemopen( buffer, dataSize, mode) )
+ FileCloser(uint8_t* buffer, size_t dataSize, const char* const mode)
+ : mFile(fmemopen(buffer, dataSize, mode))
{
}
- FileCloser( Dali::Vector<uint8_t>& vector, size_t dataSize, const char * const mode )
+ FileCloser(Dali::Vector<uint8_t>& vector, size_t dataSize, const char* const mode)
{
// 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).
size_t bufferSize = dataSize;
++bufferSize;
- vector.Resize( bufferSize );
+ vector.Resize(bufferSize);
- void * const buffer = &vector[0];
- mFile = fmemopen( buffer, bufferSize, mode );
+ void* const buffer = &vector[0];
+ mFile = fmemopen(buffer, bufferSize, mode);
- DALI_ASSERT_DEBUG( buffer != 0 && "Cant open file on null buffer." );
- DALI_ASSERT_DEBUG( dataSize > 0 && "Pointless to open file on empty buffer." );
- DALI_ASSERT_DEBUG( mode != 0 && "Null mode is undefined behaviour in spec." );
+ DALI_ASSERT_DEBUG(buffer != 0 && "Cant open file on null buffer.");
+ DALI_ASSERT_DEBUG(dataSize > 0 && "Pointless to open file on empty buffer.");
+ DALI_ASSERT_DEBUG(mode != 0 && "Null mode is undefined behaviour in spec.");
- if( mFile == 0 )
+ if(mFile == 0)
{
- DALI_LOG_WARNING( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n", static_cast<void*>(buffer), static_cast<unsigned>(dataSize), mode );
+ DALI_LOG_WARNING("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n", static_cast<void*>(buffer), static_cast<unsigned>(dataSize), mode);
}
}
- /**
+ /**
* @brief Destroy the FileCloser and clean up its FILE*.
*/
~FileCloser()
{
- if( mFile != 0 )
+ if(mFile != 0)
{
- const int closeFailed = fclose( mFile );
+ const int closeFailed = fclose(mFile);
- if ( closeFailed )
+ 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 = 0;
}
}
private:
-
// Undefined
- FileCloser( const FileCloser& fileCloser );
+ FileCloser(const FileCloser& fileCloser);
// Undefined
- FileCloser& operator=( const FileCloser& fileCloser );
+ FileCloser& operator=(const FileCloser& fileCloser);
private:
- FILE* mFile;
+ FILE* mFile;
Dali::Vector<char> mFileBuffer;
};
#define DALI_INTERNAL_FILE_DESCRIPTOR_MONITOR_H
/*
- * 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 Integration
{
class Core;
namespace Internal
{
-
namespace Adaptor
{
-
/**
* @brief Monitors the given file descriptor and whenever anything is written to it, the provided
* callback is called
class FileDescriptorMonitor
{
public:
-
/**
* @brief Bitmask of file descriptor event types
*/
* readable or writable even when it isn’t. The developer should check for handle EAGAIN or equivalent
* when reading from or write to the fd.
*/
- FileDescriptorMonitor( int fileDescriptor, CallbackBase* callback, int eventBitmask );
+ FileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask);
/**
* Destructor
~FileDescriptorMonitor();
private:
-
// Undefined
- FileDescriptorMonitor( const FileDescriptorMonitor& fileDescriptorMonitor );
+ FileDescriptorMonitor(const FileDescriptorMonitor& fileDescriptorMonitor);
// Undefined
- FileDescriptorMonitor& operator=( const FileDescriptorMonitor& fileDescriptorMonitor );
+ FileDescriptorMonitor& operator=(const FileDescriptorMonitor& fileDescriptorMonitor);
private:
struct Impl;
#define DALI_INTERNAL_PORTABLE_FILE_READER_H
/*
- * 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 Platform
{
-
class FileReader : public FileStream
{
public:
- FileReader( const std::string& filename )
- : FileStream( filename, FileStream::READ | FileStream::BINARY )
+ FileReader(const std::string& filename)
+ : FileStream(filename, FileStream::READ | FileStream::BINARY)
{
}
- FileReader( Dali::Vector<uint8_t>& vector )
- : FileStream( &vector[0], vector.Size(), FileStream::READ | FileStream::BINARY )
+ FileReader(Dali::Vector<uint8_t>& vector)
+ : FileStream(&vector[0], vector.Size(), FileStream::READ | FileStream::BINARY)
{
}
- FileReader( Dali::Vector<uint8_t>& vector, size_t dataSize )
- : FileStream( &vector[0], dataSize, FileStream::READ | FileStream::BINARY )
+ FileReader(Dali::Vector<uint8_t>& vector, size_t dataSize)
+ : FileStream(&vector[0], dataSize, FileStream::READ | FileStream::BINARY)
{
}
- FileReader( uint8_t* data, size_t dataSize )
- : FileStream( data, dataSize, FileStream::READ | FileStream::BINARY )
+ FileReader(uint8_t* data, size_t dataSize)
+ : FileStream(data, dataSize, FileStream::READ | FileStream::BINARY)
{
}
};
#define DALI_INTERNAL_PORTABLE_FILE_WRITER_H
/*
- * 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 Platform
{
-
class FileWriter : public FileStream
{
public:
* @param[in,out] vector The vector to write to
* @param[in] dataSize the amount of data to be written
*/
- FileWriter( Dali::Vector<uint8_t>& vector, size_t dataSize )
- : FileStream( vector, dataSize, FileStream::WRITE | FileStream::BINARY )
+ FileWriter(Dali::Vector<uint8_t>& vector, size_t dataSize)
+ : FileStream(vector, dataSize, FileStream::WRITE | FileStream::BINARY)
{
}
};
#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);
}
}
#define DALI_INTERNAL_FPS_TRACKER_H
/*
- * 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 EnvironmentOptions;
/**
class FpsTracker
{
public:
-
/**
* Create the FPS Tracker.
* @param[in] environmentOptions environment options
*/
- FpsTracker( const EnvironmentOptions& environmentOptions );
+ FpsTracker(const EnvironmentOptions& environmentOptions);
/**
* Non-virtual destructor; UpdateThread is not suitable as a base class.
bool Enabled() const;
private:
-
/**
* Output the FPS information
* when the FSP tracking is enabled,
*/
void OutputFPSRecord();
-private: // Data
-
- float mFpsTrackingSeconds; ///< fps tracking time length in seconds
- float mFrameCount; ///< how many frames occurred during tracking period
- float mElapsedTime; ///< time elapsed from previous fps tracking output
+private: // Data
+ float mFpsTrackingSeconds; ///< fps tracking time length in seconds
+ float mFrameCount; ///< how many frames occurred during tracking period
+ float mElapsedTime; ///< time elapsed from previous fps tracking output
};
} // namespace Adaptor
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
-
#define DALI_INTERNAL_ADAPTOR_FRAME_TIME_STAMP_H
/*
- * 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
{
-
/**
* Simple structure to hold information about an event in time
* within Dali. For example when rendering started.
*/
struct FrameTimeStamp
{
+ static const unsigned int BUFFER_NOT_USED = 2; ///< no index buffer was used
- static const unsigned int BUFFER_NOT_USED = 2; ///< no index buffer was used
-
- /**
+ /**
* Constructor
*/
- FrameTimeStamp();
+ FrameTimeStamp();
- /**
+ /**
* Constructor
* @param frame the frame number
* @param microseconds the time from a monotonic clock
* @param bufferIndex double buffered index used for performing an update / render
*/
- FrameTimeStamp( unsigned int frame, uint64_t microseconds, unsigned int bufferIndex = BUFFER_NOT_USED );
+ FrameTimeStamp(unsigned int frame, uint64_t microseconds, unsigned int bufferIndex = BUFFER_NOT_USED);
- /**
+ /**
* Constructor
* @param bufferIndex double buffered index used for performing an update / render
*/
- FrameTimeStamp( unsigned int bufferIndex );
+ FrameTimeStamp(unsigned int bufferIndex);
- /**
+ /**
* @param start start time
* @param end end time
* @return difference in microseconds between two time stamps
*/
- static unsigned int MicrosecondDiff( const FrameTimeStamp& start,const FrameTimeStamp& end );
+ static unsigned int MicrosecondDiff(const FrameTimeStamp& start, const FrameTimeStamp& end);
- unsigned int frame; ///< Frame number ( not always available)
- uint64_t microseconds; ///< Microsecond time stamp
- unsigned int bufferIndex; ///< The double buffered index used for performing an update / render
- };
+ unsigned int frame; ///< Frame number ( not always available)
+ uint64_t microseconds; ///< Microsecond time stamp
+ unsigned int bufferIndex; ///< The double buffered index used for performing an update / render
+};
} // namespace Adaptor
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_FRAME_TIME_STAMP_H
-
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
#define DALI_INTERNAL_ADAPTOR_FRAME_TIME_STATS_H
/*
- * 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/frame-time-stamp.h>
#include <dali/public-api/common/dali-vector.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Used to get statistics about time stamps over a period of time.
* E.g. the min, max, total and average time spent inside two markers,
* Timer start time
* @param timeStamp time stamp
*/
- void StartTime( const FrameTimeStamp& timeStamp );
+ void StartTime(const FrameTimeStamp& timeStamp);
- /**
+ /**
* Timer end time
* @param timeStamp time stamp
*/
- void EndTime( const FrameTimeStamp& timeStamp );
+ void EndTime(const FrameTimeStamp& timeStamp);
- /**
+ /**
* Reset all internal counters / state except total time.
*/
- void Reset();
+ void Reset();
- /**
+ /**
* @return maximum time in seconds
*/
- float GetMaxTime() const;
+ float GetMaxTime() const;
- /**
+ /**
* @return minimum time in seconds
*/
- float GetMinTime() const;
+ float GetMinTime() const;
- /**
+ /**
* @return total time in second
*/
- float GetTotalTime() const;
+ float GetTotalTime() const;
- /**
+ /**
* Get how many times the timer has been started /stopped
*/
- unsigned int GetRunCount() const;
+ unsigned int GetRunCount() const;
- /**
+ /**
* Calculate the mean and standard deviation
*
* @param[out] mean The return mean value
* @param[out] standardDeviation The return standard deviation value
*/
- void CalculateMean( float& meanOut, float& standardDeviationOut ) const;
+ void CalculateMean(float& meanOut, float& standardDeviationOut) const;
private:
-
- /**
+ /**
* internal time state.
*/
- enum TimeState
- {
- WAITING_FOR_START_TIME, ///< waiting for start time marker
- WAITING_FOR_END_TIME ///< waiting for end time marker
- };
-
- typedef Dali::Vector< unsigned int > Samples;
- Samples mSamples;
-
- unsigned int mMin; ///< current minimum value in microseconds
- unsigned int mMax; ///< current maximum value in microseconds
- unsigned int mTotal; ///< current total in in microseconds
- unsigned int mRunCount; ///< how many times the timer has been start / stopped
- FrameTimeStamp mStart; ///< start time stamp, to calculate the diff
- TimeState mTimeState:1; ///< time state
- bool mMinMaxTimeSet:1; ///< whether the min-max values have been configured
-
+ enum TimeState
+ {
+ WAITING_FOR_START_TIME, ///< waiting for start time marker
+ WAITING_FOR_END_TIME ///< waiting for end time marker
+ };
+
+ typedef Dali::Vector<unsigned int> Samples;
+ Samples mSamples;
+
+ unsigned int mMin; ///< current minimum value in microseconds
+ unsigned int mMax; ///< current maximum value in microseconds
+ unsigned int mTotal; ///< current total in in microseconds
+ unsigned int mRunCount; ///< how many times the timer has been start / stopped
+ FrameTimeStamp mStart; ///< start time stamp, to calculate the diff
+ TimeState mTimeState : 1; ///< time state
+ bool mMinMaxTimeSet : 1; ///< whether the min-max values have been configured
};
} // namespace Adaptor
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_FRAME_TIME_STATS_H
-
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
#define DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H
/*
- * 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
{
-
/**
* Concrete Kernel Tracing Interface.
* Used to log trace messages to the kernel using ftrace.
class KernelTrace : public TraceInterface
{
public:
-
/**
* Constructor
*/
/**
* @copydoc KernelTracerInterface::KernelTrace()
*/
- void Trace( const PerformanceMarker& marker, const std::string& traceMessage ) override;
+ void Trace(const PerformanceMarker& marker, const std::string& traceMessage) override;
private:
-
- int mFileDescriptor;
- bool mLoggedError:1;
-
+ int mFileDescriptor;
+ bool mLoggedError : 1;
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_KERNEL_TRACE_H
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;
#define DALI_INTERNAL_LOCALE_UTILS_H
/*
- * 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 Locale
{
-
enum Direction
{
LEFT_TO_RIGHT,
RIGHT_TO_LEFT,
};
-Locale::Direction GetDirection( const std::string& locale );
+Locale::Direction GetDirection(const std::string& locale);
} // namespace Locale
#define DALI_TIZEN_LOGGING_H
/*
- * 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>
-
namespace Dali
{
-
namespace TizenPlatform
{
-
/**
* @copydoc Dali::Integration::Log:LogMessage
*/
/*
- * 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
#define DALI_ADAPTOR_OBJECT_PROFILER_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.
*/
// EXTERNAL INCLUDES
-#include <cstdint> // uint32_t
-#include <cstddef> // size_t
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/object-registry.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/signals/connection-tracker.h>
+#include <cstddef> // size_t
+#include <cstdint> // uint32_t
// INTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/timer.h>
{
namespace Adaptor
{
-
/**
* Class to profile the number of instances of Objects in the system
*/
class ObjectProfiler : public ConnectionTracker
{
public:
-
/**
* Constructor
* @param objectRegistry The objectRegistry
* @param timeInterval to specify the frequency of reporting
*/
- ObjectProfiler( Dali::ObjectRegistry objectRegistry, uint32_t timeInterval );
+ ObjectProfiler(Dali::ObjectRegistry objectRegistry, uint32_t timeInterval);
/**
* Destructor
* Callback used when objects are created. Increases instance count for that object type
* @param[in] handle of the created object
*/
- void OnObjectCreated( BaseHandle handle );
+ void OnObjectCreated(BaseHandle handle);
/**
* Callback used when objects are created. Decreases instance count for that object type
* @param[in] object The object being destroyed
*/
- void OnObjectDestroyed( const Dali::RefObject* object );
+ void OnObjectDestroyed(const Dali::RefObject* object);
/**
* Get the memory size of the given object
*/
- std::size_t GetMemorySize( const std::string& name, uint32_t count );
+ std::size_t GetMemorySize(const std::string& name, uint32_t count);
private:
+ using InstanceCountPair = std::pair<const std::string, uint32_t>;
+ using InstanceTypePair = std::pair<BaseObject*, std::string>;
- using InstanceCountPair = std::pair< const std::string, uint32_t >;
- using InstanceTypePair = std::pair< BaseObject*, std::string >;
-
- Dali::ObjectRegistry mObjectRegistry;
- Dali::Timer mTimer;
- std::vector< InstanceCountPair > mInstanceCountContainer;
- std::vector< InstanceTypePair > mInstanceTypes;
+ Dali::ObjectRegistry mObjectRegistry;
+ Dali::Timer mTimer;
+ std::vector<InstanceCountPair> mInstanceCountContainer;
+ std::vector<InstanceTypePair> mInstanceTypes;
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_ADAPTOR_OBJECT_PROFILER_H
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
#define DALI_INTERNAL_BASE_PERFORMANCE_INTERFACE_FACTORY_H
/*
- * 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
{
-
/**
* Performance interface factory class
*
class PerformanceInterfaceFactory
{
public:
-
/**
* Create a new concrete implementation of the performance interface.
* @param adaptorServices adaptor internal services
* @param environmentOptions environment options
* @return pointer to a new performance interface
*/
- static PerformanceInterface* CreateInterface( AdaptorInternalServices& adaptorServices,
- const EnvironmentOptions& environmentOptions );
-
+ static PerformanceInterface* CreateInterface(AdaptorInternalServices& adaptorServices,
+ const EnvironmentOptions& environmentOptions);
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_BASE_PERFORMANCE_INTERFACE_FACTORY_H
#define DALI_INTERNAL_BASE_PERFORMANCE_INTERFACE_H
/*
- * 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
{
-
/**
* Abstract Performance Interface.
* Used by the Adaptor to store performance metrics.
class PerformanceInterface
{
public:
-
- typedef unsigned short ContextId; ///< Type to represent a context ID
+ typedef unsigned short ContextId; ///< Type to represent a context ID
/**
* bitmask of statistics logging options.
*/
enum StatisticsLogOptions
{
- DISABLED = 0,
- LOG_EVERYTHING = 1 << 0, ///< Bit 0 (1), log all statistics to the DALi log
- LOG_UPDATE_RENDER = 1 << 1, ///< Bit 1 (2), log update and render statistics to the DALi log
- LOG_EVENT_PROCESS = 1 << 2, ///< Bit 2 (4), log event task statistics to the DALi log
- LOG_CUSTOM_MARKERS = 1 << 3, ///< Bit 3 (8), log custom marker statistics to the DALi log
+ DISABLED = 0,
+ LOG_EVERYTHING = 1 << 0, ///< Bit 0 (1), log all statistics to the DALi log
+ LOG_UPDATE_RENDER = 1 << 1, ///< Bit 1 (2), log update and render statistics to the DALi log
+ LOG_EVENT_PROCESS = 1 << 2, ///< Bit 2 (4), log event task statistics to the DALi log
+ LOG_CUSTOM_MARKERS = 1 << 3, ///< Bit 3 (8), log custom marker statistics to the DALi log
};
/**
*/
enum TimeStampOutput
{
- NO_TIME_STAMP_OUTPUT = 0,
- OUTPUT_DALI_LOG = 1 << 0, ///< Bit 0 (1), log markers to DALi log
- OUTPUT_KERNEL_TRACE = 1 << 1, ///< Bit 1 (2), log makers to kernel trace
- OUTPUT_SYSTEM_TRACE = 1 << 2, ///< Bit 2 (4), log markers to system trace
- OUTPUT_NETWORK = 1 << 3, ///< Bit 3 (8), log markers to network client
+ NO_TIME_STAMP_OUTPUT = 0,
+ OUTPUT_DALI_LOG = 1 << 0, ///< Bit 0 (1), log markers to DALi log
+ OUTPUT_KERNEL_TRACE = 1 << 1, ///< Bit 1 (2), log makers to kernel trace
+ OUTPUT_SYSTEM_TRACE = 1 << 2, ///< Bit 2 (4), log markers to system trace
+ OUTPUT_NETWORK = 1 << 3, ///< Bit 3 (8), log markers to network client
};
/**
*/
enum MarkerType
{
- VSYNC = 0, ///< V-Sync
- UPDATE_START , ///< Update start
- UPDATE_END , ///< Update end
- RENDER_START , ///< Render start
- RENDER_END , ///< Render end
- SWAP_START , ///< SwapBuffers Start
- SWAP_END , ///< SwapBuffers End
+ VSYNC = 0, ///< V-Sync
+ UPDATE_START, ///< Update start
+ UPDATE_END, ///< Update end
+ RENDER_START, ///< Render start
+ RENDER_END, ///< Render end
+ SWAP_START, ///< SwapBuffers Start
+ SWAP_END, ///< SwapBuffers End
PROCESS_EVENTS_START, ///< Process events start (e.g. touch event)
PROCESS_EVENTS_END, ///< Process events end
- PAUSED , ///< Pause start
- RESUME , ///< Resume start
- START , ///< The start of custom tracking
+ PAUSED, ///< Pause start
+ RESUME, ///< Resume start
+ START, ///< The start of custom tracking
END ///< The end of custom tracking
};
/**
* Constructor.
*/
- PerformanceInterface() {}
+ PerformanceInterface()
+ {
+ }
/**
* Virtual destructor
*/
- virtual ~PerformanceInterface() {};
+ virtual ~PerformanceInterface(){};
/**
* @brief Add a new context with a given name
* @param[in] name The name of the context
* @return Return the unique id for this context
*/
- virtual ContextId AddContext( const char* name ) = 0;
+ virtual ContextId AddContext(const char* name) = 0;
/**
* @brief Remove a context from use
*
* @param[in] contextId The ID of the context to remove
*/
- virtual void RemoveContext( ContextId contextId ) = 0;
+ virtual void RemoveContext(ContextId contextId) = 0;
/**
* @brief Add a performance marker
* The default context 0 Event/Update/Render is assumed.
* @param[in] markerType performance marker type
*/
- virtual void AddMarker( MarkerType markerType ) = 0;
+ virtual void AddMarker(MarkerType markerType) = 0;
/**
* @brief Add a performance marker for a used defined context
* @param[in] markerType performance marker type
* @param[in] contextId The context of the marker. This must be one generated by AddContext.
*/
- virtual void AddMarker( MarkerType markerType, ContextId contextId ) = 0;
+ virtual void AddMarker(MarkerType markerType, ContextId contextId) = 0;
/**
* @brief Set the logging level and frequency
* @param[in] timeStampOutput 0 = disabled, > 0 bitmask of TimeStampOutput options.
* @param[in] logFrequency how often to log out in seconds
*/
- virtual void SetLogging( unsigned int statisticsLogOptions, unsigned int timeStampOutput, unsigned int logFrequency) = 0;
+ virtual void SetLogging(unsigned int statisticsLogOptions, unsigned int timeStampOutput, unsigned int logFrequency) = 0;
/**
* @brief Set the logging frequency for an individual context
*
* @param[in] logFrequency how often to log out in seconds
*/
- virtual void SetLoggingFrequency( unsigned int logFrequency, ContextId contextId ) = 0;
+ virtual void SetLoggingFrequency(unsigned int logFrequency, ContextId contextId) = 0;
/**
* @brief Set logging on or off for a particular context
* @param[in] enable Enable logging or not
* @param[in] contextId The id of the context to log. This must be one generated by AddContext.
*/
- virtual void EnableLogging( bool enable, ContextId contextId ) = 0;
+ virtual void EnableLogging(bool enable, ContextId contextId) = 0;
private:
-
// Undefined copy constructor.
- PerformanceInterface( const PerformanceInterface& );
+ PerformanceInterface(const PerformanceInterface&);
// Undefined assignment operator.
- PerformanceInterface& operator=( const PerformanceInterface& );
-
+ PerformanceInterface& operator=(const PerformanceInterface&);
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif
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);
}
}
#define DALI_INTERNAL_PERFORMANCE_LOGGER_H
/*
- * 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/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/performance-interface.h>
#include <dali/devel-api/adaptor-framework/performance-logger.h>
+#include <dali/internal/system/common/performance-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class PerformanceLogger;
typedef IntrusivePtr<PerformanceLogger> PerformanceLoggerPtr;
class PerformanceLogger : public BaseObject
{
public:
-
/**
* @brief Create a new logger
*
* @param[in] name The name of the logger. This needs to be a compile-time literal and alive for the whole lifetime of the performance logger.
* @return a new logger
*/
- static PerformanceLoggerPtr New( const char* name );
+ static PerformanceLoggerPtr New(const char* name);
/**
* Constructor
* @param[in] name The name to assing to the logger
*/
- PerformanceLogger( const char* name );
+ PerformanceLogger(const char* name);
/**
* Destructor.
*
* @param markerType Performance marker type
*/
- void AddMarker( Dali::PerformanceLogger::Marker markerType );
+ void AddMarker(Dali::PerformanceLogger::Marker markerType);
/**
* Set the logging frequency
*
* @param logFrequency how often to log out in seconds
*/
- void SetLoggingFrequency( unsigned int logFrequency);
+ void SetLoggingFrequency(unsigned int logFrequency);
/**
* Set logging on or off for this logger
*
* @param[in] enable Enable logging or not
*/
- void EnableLogging( bool enable );
+ void EnableLogging(bool enable);
private: // Implementation
-
// not implemented
- PerformanceLogger( const PerformanceLogger& );
- PerformanceLogger& operator=( const PerformanceLogger& );
+ PerformanceLogger(const PerformanceLogger&);
+ PerformanceLogger& operator=(const PerformanceLogger&);
private:
-
- PerformanceInterface::ContextId mContext; ///< Context of this logger
-
+ PerformanceInterface::ContextId mContext; ///< Context of this logger
};
// Helpers for public-api forwarding methods
-inline static Internal::Adaptor::PerformanceLogger& GetImplementation( Dali::PerformanceLogger& logger )
+inline static Internal::Adaptor::PerformanceLogger& GetImplementation(Dali::PerformanceLogger& logger)
{
- DALI_ASSERT_ALWAYS( logger && "PerformanceLogger handle is empty" );
+ DALI_ASSERT_ALWAYS(logger && "PerformanceLogger handle is empty");
BaseObject& handle = logger.GetBaseObject();
- return static_cast< Internal::Adaptor::PerformanceLogger& >( handle );
+ return static_cast<Internal::Adaptor::PerformanceLogger&>(handle);
}
-inline static const Internal::Adaptor::PerformanceLogger& GetImplementation( const Dali::PerformanceLogger& logger )
+inline static const Internal::Adaptor::PerformanceLogger& GetImplementation(const Dali::PerformanceLogger& logger)
{
- DALI_ASSERT_ALWAYS( logger && "PerformanceLogger handle is empty" );
+ DALI_ASSERT_ALWAYS(logger && "PerformanceLogger handle is empty");
const BaseObject& handle = logger.GetBaseObject();
- return static_cast< const Internal::Adaptor::PerformanceLogger& >( handle );
+ return static_cast<const Internal::Adaptor::PerformanceLogger&>(handle);
}
} // namespace Adaptor
// 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
-
#define DALI_INTERNAL_ADAPTOR_PERFORMANCE_MARKER_H
/*
- * 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/internal/system/common/performance-interface.h>
#include <dali/internal/system/common/frame-time-stamp.h>
+#include <dali/internal/system/common/performance-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Marker used to record an event with a time stamp in Dali
*/
class PerformanceMarker
{
public:
-
-
/**
* Bitmask used to filter different types of markers based
* on what group they belong to.
*/
enum MarkerFilter
{
- FILTERING_DISABLED = 0, ///< disabled
- V_SYNC_EVENTS = 1 << 0, ///< v-sync
- UPDATE = 1 << 1, ///< update start / end
- RENDER = 1 << 2, ///< render start / end
- EVENT_PROCESS = 1 << 3, ///< process events start / end
- SWAP_BUFFERS = 1 << 4, ///< swap buffers start / end
- LIFE_CYCLE_EVENTS = 1 << 5, ///< pause / resume
- RESOURCE_EVENTS = 1 << 6, ///< resource events
- CUSTOM_EVENTS = 1 << 7
+ FILTERING_DISABLED = 0, ///< disabled
+ V_SYNC_EVENTS = 1 << 0, ///< v-sync
+ UPDATE = 1 << 1, ///< update start / end
+ RENDER = 1 << 2, ///< render start / end
+ EVENT_PROCESS = 1 << 3, ///< process events start / end
+ SWAP_BUFFERS = 1 << 4, ///< swap buffers start / end
+ LIFE_CYCLE_EVENTS = 1 << 5, ///< pause / resume
+ RESOURCE_EVENTS = 1 << 6, ///< resource events
+ CUSTOM_EVENTS = 1 << 7
};
/**
*/
enum MarkerEventType
{
- SINGLE_EVENT, ///< event is something that has no duration associated with it
- START_TIMED_EVENT, ///< start of a timed event
- END_TIMED_EVENT ///< end of a timed event
+ SINGLE_EVENT, ///< event is something that has no duration associated with it
+ START_TIMED_EVENT, ///< start of a timed event
+ END_TIMED_EVENT ///< end of a timed event
};
-
/**
* @brief Constructor
* @param[in] type marker type
*/
- PerformanceMarker( PerformanceInterface::MarkerType type );
+ PerformanceMarker(PerformanceInterface::MarkerType type);
/**
* @brief Constructor
* @param[in] type marker type
* @param[in] time time stamp
*/
- PerformanceMarker( PerformanceInterface::MarkerType type, FrameTimeStamp time );
+ PerformanceMarker(PerformanceInterface::MarkerType type, FrameTimeStamp time);
/**
* @return the time stamp
*/
MarkerFilter GetFilterType() const;
-
/**
* @return marker name
*/
- const char* GetName( ) const;
+ const char* GetName() const;
/**
* @param start the start marker
* @param end the end marker
* @return difference in microseconds between two markers
*/
- static unsigned int MicrosecondDiff( const PerformanceMarker& start, const PerformanceMarker& end );
+ static unsigned int MicrosecondDiff(const PerformanceMarker& start, const PerformanceMarker& end);
/**
* @return if a marker is enabled as part of a group
*/
- bool IsFilterEnabled( MarkerFilter filter ) const;
-private:
-
- PerformanceInterface::MarkerType mType; ///< marker type
- FrameTimeStamp mTimeStamp; ///< frame time stamp
+ bool IsFilterEnabled(MarkerFilter filter) const;
+private:
+ PerformanceInterface::MarkerType mType; ///< marker type
+ FrameTimeStamp mTimeStamp; ///< frame time stamp
};
} // 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
{
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
#define DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H
/*
- * 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 INCLDUES
-#include <dali/public-api/common/dali-vector.h>
#include <dali/devel-api/threading/mutex.h>
+#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/frame-time-stats.h>
-#include <dali/internal/network/common/network-performance-server.h>
#include <dali/internal/adaptor/common/adaptor-internal-services.h>
+#include <dali/internal/network/common/network-performance-server.h>
+#include <dali/internal/system/common/frame-time-stats.h>
#include <dali/internal/system/common/performance-marker.h>
#include <dali/internal/system/common/stat-context-manager.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class EnvironmentOptions;
class StatContext;
/**
class PerformanceServer : public PerformanceInterface, public StatContextLogInterface
{
public:
-
/**
* @brief Constructor
* @param[in] adaptorServices adaptor internal services
* @param[in] environmentOptions environment options
*/
- PerformanceServer( AdaptorInternalServices& adaptorServices,
- const EnvironmentOptions& environmentOptions );
+ PerformanceServer(AdaptorInternalServices& adaptorServices,
+ const EnvironmentOptions& environmentOptions);
/**
* Destructor
/**
* @copydoc PerformanceLogger::AddContext()
*/
- ContextId AddContext( const char* name ) override;
+ ContextId AddContext(const char* name) override;
/**
* @copydoc PerformanceLogger::RemoveContext()
*/
- void RemoveContext( ContextId contextId ) override;
+ void RemoveContext(ContextId contextId) override;
/**
* @copydoc PerformanceInterface::AddMarker( MarkerType markerType )
*/
- void AddMarker( MarkerType markerType ) override;
+ void AddMarker(MarkerType markerType) override;
/**
* @copydoc PerformanceLogger::AddMarker( MarkerType markerType, ContextId contextId )
*/
- void AddMarker( MarkerType markerType, ContextId contextId ) override;
+ void AddMarker(MarkerType markerType, ContextId contextId) override;
/**
* @copydoc PerformanceInterface::SetLogging()
*/
- virtual void SetLogging( unsigned int statisticsLogOptions,
- unsigned int timeStampOutput,
- unsigned int logFrequency );
+ virtual void SetLogging(unsigned int statisticsLogOptions,
+ unsigned int timeStampOutput,
+ unsigned int logFrequency);
/**
* @copydoc PerformanceLogger::SetLoggingFrequency()
*/
- void SetLoggingFrequency( unsigned int logFrequency, ContextId contextId ) override;
+ void SetLoggingFrequency(unsigned int logFrequency, ContextId contextId) override;
/**
* @copydoc PerformanceLogger::EnableLogging()
*/
- void EnableLogging( bool enable, ContextId contextId ) override;
+ void EnableLogging(bool enable, ContextId contextId) override;
public: //StatLogInterface
-
/**
* @copydoc StatLogInterface::LogContextStatistics()
*/
- void LogContextStatistics( const char* const text ) override;
+ void LogContextStatistics(const char* const text) override;
private:
-
/**
* @brief log the marker out to kernel/ DALi log
* @param[in] marker performance marker
* @param[in] description marker description
*/
- void LogMarker( const PerformanceMarker& marker, const char* const description );
+ void LogMarker(const PerformanceMarker& marker, const char* const description);
private:
-
- const EnvironmentOptions& mEnvironmentOptions; ///< environment options
- TraceInterface& mKernelTrace; ///< kernel trace interface
- TraceInterface& mSystemTrace; ///< system trace interface
- Dali::Mutex mLogMutex; ///< mutex
+ const EnvironmentOptions& mEnvironmentOptions; ///< environment options
+ TraceInterface& mKernelTrace; ///< kernel trace interface
+ TraceInterface& mSystemTrace; ///< system trace interface
+ Dali::Mutex mLogMutex; ///< mutex
#if defined(NETWORK_LOGGING_ENABLED)
- NetworkPerformanceServer mNetworkServer; ///< network server
- bool mNetworkControlEnabled; ///< Whether network control is enabled
+ NetworkPerformanceServer mNetworkServer; ///< network server
+ bool mNetworkControlEnabled; ///< Whether network control is enabled
#endif
- StatContextManager mStatContextManager; ///< Stat context manager
- unsigned int mStatisticsLogBitmask; ///< statistics log level
- unsigned int mPerformanceOutputBitmask; ///< performance marker output
+ StatContextManager mStatContextManager; ///< Stat context manager
+ unsigned int mStatisticsLogBitmask; ///< statistics log level
+ unsigned int mPerformanceOutputBitmask; ///< performance marker output
- bool mLoggingEnabled:1; ///< whether logging update / render to a log is enabled
- bool mLogFunctionInstalled:1; ///< whether the log function is installed
+ bool mLoggingEnabled : 1; ///< whether logging update / render to a log is enabled
+ bool mLogFunctionInstalled : 1; ///< whether the log function is installed
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_PERFORMANCE_SERVER_H
#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
#define DALI_INTERNAL_ADAPTOR_SHARED_FILE_H
/*
- * 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 <string>
#include <sys/types.h>
+#include <string>
namespace Dali
{
{
namespace Adaptor
{
-
class SharedFile
{
public:
* Open an existing shared file for read/write
* @return The shared file, or NULL if a file could not be opened and mapped.
*/
- static SharedFile* New( const char* filename, int size, bool isSystem );
+ static SharedFile* New(const char* filename, int size, bool isSystem);
/**
* Constructor
* Opens a file descriptor to shared memory segment
* @return The file descriptor
*/
- int Open( const char* filename, int size, int oflag, mode_t mode );
+ int Open(const char* filename, int size, int oflag, mode_t mode);
/**
* Opens a file for read/write
* @return true if opened, false on error.
*/
- bool OpenFile( const char* filename, int size, bool isSystem );
+ bool OpenFile(const char* filename, int size, bool isSystem);
/**
* Close the shared file
std::string mFilename;
};
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_SHARED_FILE_H
#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);
}
}
#define DALI_INTERNAL_SOUND_PLAYER_H
/*
- * 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 <string>
#include <dali/public-api/object/base-object.h>
+#include <string>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/sound-player.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Plays haptic effects.
*/
class SoundPlayer : public Dali::BaseObject
{
-
public:
-
typedef Dali::SoundPlayer::SoundPlayFinishedSignalType SoundPlayFinishedSignalType;
/**
* @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.
*/
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
private:
-
/**
* Private Constructor; see also soundPlayer::New()
* @param[in] soundPlayer The public sound player class
SoundPlayer& operator=(SoundPlayer&);
private:
-
- FeedbackPluginProxy mPlugin;
+ FeedbackPluginProxy mPlugin;
SoundPlayFinishedSignalType mSoundPlayFinishedSignal;
};
} // namespace Internal
-
// Helpers for public-api forwarding methods
inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
+ DALI_ASSERT_ALWAYS(player && "SoundPlayer handle is empty");
BaseObject& handle = player.GetBaseObject();
inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
+ DALI_ASSERT_ALWAYS(player && "SoundPlayer handle is empty");
const BaseObject& handle = player.GetBaseObject();
#define DALI_INTERNAL_ADAPTOR_STATISTICS_STAT_CONTEXT_LOG_INTERFACE_H
/*
- * 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
{
-
/**
* @brief Abstract interface used to log statistics data
*/
class StatContextLogInterface
{
public:
-
/**
* @brief Used to log statistics out
* @param[in] text log the text
*/
- virtual void LogContextStatistics( const char* const text) = 0;
-
+ virtual void LogContextStatistics(const char* const text) = 0;
protected:
-
/**
* @brief Constructor
*/
}
private:
-
// Undefined copy constructor.
- StatContextLogInterface( const StatContextLogInterface& );
+ StatContextLogInterface(const StatContextLogInterface&);
// Undefined assignment operator.
- StatContextLogInterface& operator=( const StatContextLogInterface& );
-
+ StatContextLogInterface& operator=(const StatContextLogInterface&);
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_STATISTICS_STAT_CONTEXT_LOG_INTERFACE_H
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
-
-
#define DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_MANAGER_H
/*
- * 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/threading/mutex.h>
// INTERNAL INCLUDES
+#include <dali/internal/system/common/performance-interface.h>
#include <dali/internal/system/common/performance-marker.h>
#include <dali/internal/system/common/stat-context.h>
-#include <dali/internal/system/common/performance-interface.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Class to manage StatContext objects.
*
*/
class StatContextManager
{
-
public:
-
- /**
+ /**
* @brief Constructor
* @param[in] logInterface interface to log statistics to
*/
- StatContextManager( StatContextLogInterface& logInterface );
+ StatContextManager(StatContextLogInterface& logInterface);
- /**
+ /**
* @brief destructor, not intended as a bass class
*/
- ~StatContextManager();
+ ~StatContextManager();
- /**
+ /**
* @brief Add a context
* @param[in] name Name of the context to print in console
* @param[in] type the type of events to filter ( e.g. event, update, render or custom)
* @return The ID to give the context
*/
- PerformanceInterface::ContextId AddContext( const char* const name, PerformanceMarker::MarkerFilter type );
+ PerformanceInterface::ContextId AddContext(const char* const name, PerformanceMarker::MarkerFilter type);
- /**
+ /**
* @brief Remove a context
* @param[in] contextId id of the context to remove
*/
- void RemoveContext(PerformanceInterface::ContextId contextId );
+ void RemoveContext(PerformanceInterface::ContextId contextId);
- /**
+ /**
* @brief Add an internal marker (e.g. v-sync, update, render markers)
* @param[in] marker the marker to add
*/
- void AddInternalMarker( const PerformanceMarker& marker );
+ void AddInternalMarker(const PerformanceMarker& marker);
- /**
+ /**
* @brief Add a custom marker defined by the application
* @param[in] marker the marker to add
* @param[in] contextId the context the custom marker is designed for
*/
- void AddCustomMarker( const PerformanceMarker& marker , PerformanceInterface::ContextId contextId );
+ void AddCustomMarker(const PerformanceMarker& marker, PerformanceInterface::ContextId contextId);
- /**
+ /**
* @brief Get the nane of a context
* @param[in] contextId id of the context to get the name
* @return context name
*/
- const char* GetContextName( PerformanceInterface::ContextId contextId ) const;
+ const char* GetContextName(PerformanceInterface::ContextId contextId) const;
- /**
+ /**
* @brief Get the full description of a marker for this context
* @param[in] type marker type, for a customer marker this will be either START or END
* @param[in] contextId id of the context to get the name
* @return marker description in relation to this context
*/
- const char* GetMarkerDescription( PerformanceInterface::MarkerType type, PerformanceInterface::ContextId contextId ) const;
-
+ const char* GetMarkerDescription(PerformanceInterface::MarkerType type, PerformanceInterface::ContextId contextId) const;
- /**
+ /**
* @brief enable / disable logging for a context
* @param[in] enable whether to enable logging
* @param[in] contextId the context to configure
*/
- void EnableLogging( bool enable, PerformanceInterface::ContextId contextId );
+ void EnableLogging(bool enable, PerformanceInterface::ContextId contextId);
- /**
+ /**
* @brief set global logging level and frequency.
* @param[in] statisticsLogOptions log options
* @param[in] logFrequency frequency in seconds
*/
- void SetLoggingLevel( unsigned int statisticsLogOptions, unsigned int logFrequency);
+ void SetLoggingLevel(unsigned int statisticsLogOptions, unsigned int logFrequency);
- /**
+ /**
* @brief Set the frequency of logging for an individual context
* @param[in] logFrequency log frequency in seconds
* @param[in] contextId the context to configure
*/
- void SetLoggingFrequency( unsigned int logFrequency, PerformanceInterface::ContextId contextId );
+ void SetLoggingFrequency(unsigned int logFrequency, PerformanceInterface::ContextId contextId);
- private:
+private:
+ StatContextManager(const StatContextManager&); ///< Undefined
+ StatContextManager& operator=(const StatContextManager&); ///< Undefined
- StatContextManager( const StatContextManager& ); ///< Undefined
- StatContextManager& operator=( const StatContextManager& ); ///< Undefined
+ typedef Dali::Vector<StatContext*> StatContexts;
- typedef Dali::Vector< StatContext* > StatContexts;
-
- /**
+ /**
* @brief helper
* @param[in] contextId the context to get
* @return context
*/
- StatContext* GetContext( PerformanceInterface::ContextId contextId ) const;
+ StatContext* GetContext(PerformanceInterface::ContextId contextId) const;
- Dali::Mutex mDataMutex; ///< mutex
- StatContexts mStatContexts; ///< The list of stat contexts
- StatContextLogInterface& mLogInterface; ///< Log interface
+ Dali::Mutex mDataMutex; ///< mutex
+ StatContexts mStatContexts; ///< The list of stat contexts
+ StatContextLogInterface& mLogInterface; ///< Log interface
- PerformanceInterface::ContextId mNextContextId; ///< The next valid context ID
+ PerformanceInterface::ContextId mNextContextId; ///< The next valid context ID
- // Some defaults contexts
- PerformanceInterface::ContextId mUpdateStats; ///< update time statistics
- PerformanceInterface::ContextId mRenderStats; ///< render time statistics
- PerformanceInterface::ContextId mEventStats; ///< event time statistics
+ // Some defaults contexts
+ PerformanceInterface::ContextId mUpdateStats; ///< update time statistics
+ PerformanceInterface::ContextId mRenderStats; ///< render time statistics
+ PerformanceInterface::ContextId mEventStats; ///< event time statistics
- unsigned int mStatisticsLogBitmask; ///< statistics log bitmask
- unsigned int mLogFrequency; ///< log frequency
+ unsigned int mStatisticsLogBitmask; ///< statistics log bitmask
+ unsigned int mLogFrequency; ///< log frequency
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_MANAGER_H
-
*
*/
-
// 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
#define DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_H
/*
- * 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 <string>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/performance-marker.h>
#include <dali/internal/system/common/frame-time-stats.h>
#include <dali/internal/system/common/performance-interface.h>
+#include <dali/internal/system/common/performance-marker.h>
#include <dali/internal/system/common/stat-context-log-interface.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Stores and prints statistics for a particular logging context.
*
*/
class StatContext
{
-
public:
-
- /**
+ /**
* @brief Constructor
*
* @param[in] id The ID to give the context
* @param[in] logInterface interface to log out to
*
*/
- StatContext( unsigned int id,
- const char* const contextName,
- PerformanceMarker::MarkerFilter contextType,
- unsigned int logFrequencySeconds,
- StatContextLogInterface& logInterface );
-
+ StatContext(unsigned int id,
+ const char* const contextName,
+ PerformanceMarker::MarkerFilter contextType,
+ unsigned int logFrequencySeconds,
+ StatContextLogInterface& logInterface);
- /**
+ /**
* @brief Non-virtual destructor, not intended as a base class
*/
- ~StatContext();
+ ~StatContext();
- /**
+ /**
* @return Return the context ID
*/
- unsigned int GetId() const;
+ unsigned int GetId() const;
- /**
+ /**
* @return the context name
*/
- const char* GetName() const;
+ const char* GetName() const;
- /**
+ /**
*
* For logging we want to output the name of the context with either
* START / END appended to the end. E.g. MY_MARKER_START
* @param[in] type marker type, for a customer marker this will be either START or END
* @return the full description for a marker
*/
- const char* GetMarkerDescription( PerformanceInterface::MarkerType type ) const;
+ const char* GetMarkerDescription(PerformanceInterface::MarkerType type) const;
- /**
+ /**
* @brief Set the frequency for logging
*
* @param[in] logFrequencySeconds The log frequency to set in seconds
*/
- void SetLogFrequency( unsigned int logFrequencySeconds );
+ void SetLogFrequency(unsigned int logFrequencySeconds);
- /**
+ /**
* @brief enable/disable logging
*
* @param[in] enableLogging Flag to spePerformancecify enabling/disabling
*/
- void EnableLogging( bool enableLogging );
+ void EnableLogging(bool enableLogging);
- /**
+ /**
* @brief Process a custom marker from the application
*
* @param[in] marker The marker to log
*/
- void ProcessCustomMarker( const PerformanceMarker& marker );
+ void ProcessCustomMarker(const PerformanceMarker& marker);
- /**
+ /**
* @brief Process a internal marker from DALi (V_SYNC/ UPDATE /RENDER/ EVENT )
*
* @param[in] marker The marker to log
*/
- void ProcessInternalMarker( const PerformanceMarker& marker );
+ void ProcessInternalMarker(const PerformanceMarker& marker);
- private:
-
- /**
+private:
+ /**
* @brief Record marker
*
* @param[in] marker to record
*/
- void RecordMarker( const PerformanceMarker& marker );
+ void RecordMarker(const PerformanceMarker& marker);
- /**
+ /**
* @brief Called when V-SYNC occurs to indicate a frame tick
* @param[in] marker the marker containing a v-sync
*/
- void FrameTick( const PerformanceMarker& marker );
+ void FrameTick(const PerformanceMarker& marker);
- /**
+ /**
* @brief Helper to print to console
*/
- void LogMarker();
-
-
- private:
-
- StatContext(); ///< undefined default constructor
-
- StatContext( const StatContext& ); ///< undefined copy constructor
-
- StatContext& operator=( const StatContext& ); ///< undefined assignment operator
-
- private:
-
- PerformanceMarker mInitialMarker; ///< Used to store initial time
- FrameTimeStats mStats; ///< Frame time stats to accumulate
- const char* const mName; ///< Name of the context
- char* mTempLogBuffer; ///< Temporary log buffer
- StatContextLogInterface& mLogInterface; ///< Log interface
- const std::string mNamePlusStart; ///< Name of the context + _START
- const std::string mNamePlusEnd; ///< Name of the context + _END
- unsigned int mId; ///< The ID of the context
- unsigned int mLogFrequencyMicroseconds; ///< if logging is enabled, what frequency to log out at in micro-seconds
- PerformanceMarker::MarkerFilter mFilterType; ///< type of events the context is filtering
- bool mLoggingEnabled:1; ///< Whether to print the log for this context or not
- bool mInitialMarkerSet:1; ///< Whether the initial marker has been set
-
+ void LogMarker();
+
+private:
+ StatContext(); ///< undefined default constructor
+
+ StatContext(const StatContext&); ///< undefined copy constructor
+
+ StatContext& operator=(const StatContext&); ///< undefined assignment operator
+
+private:
+ PerformanceMarker mInitialMarker; ///< Used to store initial time
+ FrameTimeStats mStats; ///< Frame time stats to accumulate
+ const char* const mName; ///< Name of the context
+ char* mTempLogBuffer; ///< Temporary log buffer
+ StatContextLogInterface& mLogInterface; ///< Log interface
+ const std::string mNamePlusStart; ///< Name of the context + _START
+ const std::string mNamePlusEnd; ///< Name of the context + _END
+ unsigned int mId; ///< The ID of the context
+ unsigned int mLogFrequencyMicroseconds; ///< if logging is enabled, what frequency to log out at in micro-seconds
+ PerformanceMarker::MarkerFilter mFilterType; ///< type of events the context is filtering
+ bool mLoggingEnabled : 1; ///< Whether to print the log for this context or not
+ bool mInitialMarkerSet : 1; ///< Whether the initial marker has been set
};
+} // namespace Adaptor
} // namespace Internal
-} // namespace Adaptor
-
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_STAT_CONTEXT_H
#define DALI_INTERNAL_SYSTEM_SETTINGS_H
/*
- * 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
{
-
// Get SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY from system setting if available
-int GetLongPressTime( int defaultTime );
+int GetLongPressTime(int defaultTime);
// Get ELM_ACCESS_ACTION_OVER from Elementary if available
int GetElmAccessActionOver();
#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
#define DALI_INTERNAL_ADAPTOR_SYSTEM_TRACE_H
/*
- * 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
{
-
/**
* Concrete System Tracing Interface.
* Used to log trace messages to the system using ttrace
class SystemTrace : public TraceInterface
{
public:
-
/**
* Constructor
*/
/**
* @copydoc KernelTracerInterface::KernelTrace()
*/
- void Trace( const PerformanceMarker& marker, const std::string& traceMessage ) override;
-
+ void Trace(const PerformanceMarker& marker, const std::string& traceMessage) override;
};
-} // namespace Internal
-
} // namespace Adaptor
+} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_SYSTEM_TRACE_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.
#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
#define DALI_INTERNAL_THREAD_CONTROLLER_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
{
-
class RenderSurfaceInterface;
namespace Internal
{
-
namespace Adaptor
{
-
enum class UpdateMode;
enum class ThreadMode;
class ThreadController
{
public:
-
/**
* Constructor
*/
- ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode );
+ ThreadController(AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode);
/**
* Non virtual destructor. Not intended as base class.
*
* @param updateMode The update mode (i.e. either update and render, or update and upload without rendering)
*/
- void RequestUpdateOnce( UpdateMode updateMode );
+ void RequestUpdateOnce(UpdateMode updateMode);
/**
* @brief Replaces the surface.
*
* @param surface new surface
*/
- void ReplaceSurface( Dali::RenderSurfaceInterface* surface );
+ void ReplaceSurface(Dali::RenderSurfaceInterface* surface);
/**
* Deletes the surface.
* @param surface The surface to be deleted
*/
- void DeleteSurface( Dali::RenderSurfaceInterface* surface );
+ void DeleteSurface(Dali::RenderSurfaceInterface* surface);
/**
* Resize the surface.
/**
* @copydoc Dali::Adaptor::SetRenderRefreshRate()
*/
- void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender );
+ void SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender);
/**
* @copydoc Dali::Adaptor::SetPreRenderCallback
*/
- void SetPreRenderCallback( CallbackBase* callback );
+ void SetPreRenderCallback(CallbackBase* callback);
/**
* @brief Adds the new surface.
*
* @param surface new surface
*/
- void AddSurface( Dali::RenderSurfaceInterface* surface );
+ void AddSurface(Dali::RenderSurfaceInterface* surface);
private:
-
// Undefined copy constructor.
- ThreadController( const ThreadController& ) = delete;
+ ThreadController(const ThreadController&) = delete;
// Undefined assignment operator.
- ThreadController& operator=( const ThreadController& ) = delete;
+ ThreadController& operator=(const ThreadController&) = delete;
private:
-
ThreadControllerInterface* mThreadControllerInterface;
};
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);
}
#define DALI_INTERNAL_TIME_SERVICE_H
/*
- * 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 TimeService
{
-
/**
* @brief Get the monotonic time since the clock's epoch.
*
*
* @note The maximum value timeInNanoseconds can hold is 0xFFFFFFFFFFFFFFFF which is 1.844674407e+19. Therefore, this can overflow after approximately 584 years.
*/
-void GetNanoseconds( uint64_t& timeInNanoseconds );
+void GetNanoseconds(uint64_t& timeInNanoseconds);
/**
* @brief Get the monotonic time since the clock's epoch.
*
* @note The maximum value timeInNanoseconds can hold is 0xFFFFFFFFFFFFFFFF which is 1.844674407e+19. Therefore, this can overflow after approximately 584 years.
*/
-void SleepUntil( uint64_t timeInNanoseconds );
+void SleepUntil(uint64_t timeInNanoseconds);
} // namespace TimeService
#define DALI_INTERNAL_TIMER_H
/*
- * 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/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/internal/system/common/timer-interface.h>
#include <dali/public-api/adaptor-framework/timer.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
class Timer;
class Timer : public BaseObject, public TimerInterface
{
public:
- static TimerPtr New( unsigned int milliSec );
+ static TimerPtr New(unsigned int milliSec);
/**
* Constructor
* @param[in] milliSec Interval in milliseconds.
*/
- Timer( unsigned int milliSec );
+ Timer(unsigned int milliSec);
/**
* Destructor.
virtual ~Timer();
public:
-
/**
* @copydoc Dali::Timer::Start()
*/
/**
* @copydoc Dali::Timer::SetInterval()
*/
- void SetInterval( unsigned int interval, bool restart ) override;
+ void SetInterval(unsigned int interval, bool restart) override;
/**
* @copydoc Dali::Timer::GetInterval()
bool Tick();
public: // Signals
-
Dali::Timer::TimerSignalType& TickSignal();
private: // Implementation
-
// not implemented
- Timer( const Timer& );
- Timer& operator=( const Timer& );
+ Timer(const Timer&);
+ Timer& operator=(const Timer&);
/**
* Resets any stored timer data.
void ResetTimerData();
private: // Data
-
Dali::Timer::TimerSignalType mTickSignal;
// To hide away implementation details
#define DALI_INTERNAL_ADAPTOR_BASE_TIMER_INTERFACE_H
/*
- * 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
{
-
/**
* Interface for a timer class
*/
/**
* @copydoc Dali::Timer::SetInterval()
*/
- virtual void SetInterval( unsigned int intervalInMilliseconds, bool restart ) = 0;
+ virtual void SetInterval(unsigned int intervalInMilliseconds, bool restart) = 0;
/**
* @copydoc Dali::Timer::GetInterval()
/**
* Virtual protected destructor, no deletion through this interface
*/
- virtual ~TimerInterface() { }
+ virtual ~TimerInterface()
+ {
+ }
};
-
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_ADAPTOR_BASE_TIMER_INTERFACE_H
/*
- * 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;
}
#define DALI_INTERNAL_TRIGGER_EVENT_H
/*
- * 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/public-api/signals/callback.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/integration-api/adaptor-framework/trigger-event-interface.h>
#include <dali/internal/system/common/file-descriptor-monitor.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-
/**
* The TriggerEvent class is used to send events between threads. For example, this can be used
* to wake up one thread from another thread.
class TriggerEvent : public TriggerEventInterface
{
public:
-
/**
* Constructor
* Creates an event file descriptor and starts a GSource which reads from the file
* @param[in] options Trigger event options.
* @note The ownership of callback is taken by this class.
*/
- TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options );
+ TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options);
/**
* Destructor
~TriggerEvent();
public:
-
/**
* Triggers the event.
*
void Trigger();
private:
-
/**
* @brief Called when our event file descriptor has been written to.
* @param[in] eventBitMask bit mask of events that occured on the file descriptor
* @param[in] fileDescriptor The file descriptor
*/
- void Triggered( FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor );
+ void Triggered(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor);
private:
-
struct Source;
private:
-
- FileDescriptorMonitor* mFileDescriptorMonitor;
- CallbackBase* mCallback;
- int mFileDescriptor;
+ FileDescriptorMonitor* mFileDescriptorMonitor;
+ CallbackBase* mCallback;
+ int mFileDescriptor;
TriggerEventInterface::Options mOptions;
};
#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());
}
}
}
#define DALI_INTERNAL_UPDATE_STATUS_LOGGER_H
/*
- * 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 EnvironmentOptions;
/**
class UpdateStatusLogger
{
public:
-
/**
* Create the update-status-logger.
* @param[in] environmentOptions environment options
*/
- UpdateStatusLogger( const EnvironmentOptions& environmentOptions );
+ UpdateStatusLogger(const EnvironmentOptions& environmentOptions);
/**
* Non-virtual destructor; UpdateThread is not suitable as a base class.
* Optionally output the update thread status.
* @param[in] keepUpdatingStatus Whether the update-thread requested further updates.
*/
- void Log( unsigned int keepUpdatingStatus );
-
-private: // Data
+ void Log(unsigned int keepUpdatingStatus);
- unsigned int mStatusLogInterval; ///< Interval in frames between status debug prints
- unsigned int mStatusLogCount; ///< Used to count frames between status debug prints
+private: // Data
+ unsigned int mStatusLogInterval; ///< Interval in frames between status debug prints
+ unsigned int mStatusLogCount; ///< Used to count frames between status debug prints
};
} // 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.
*/
// 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)
{
}
#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_H
/*
- * 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
{
-
typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
/**
class WidgetApplication : public Application
{
public:
-
- typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction > CreateWidgetFunctionPair;
- typedef std::vector< CreateWidgetFunctionPair > CreateWidgetFunctionContainer;
+ typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
+ typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
/**
* Create a new widget application
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+ static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
public:
-
/**
* @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
*/
- virtual void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction );
+ virtual void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction);
protected:
-
/**
* Private Constructor
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- WidgetApplication( int* argc, char **argv[], const std::string& stylesheet );
+ WidgetApplication(int* argc, char** argv[], const std::string& stylesheet);
/**
* Destructor
#define DALI_WIDGET_CONTROLLER_H
/*
- * 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 Widget::Impl : public Dali::ConnectionTracker
{
public:
-
/**
* Set content information to widget framework
*/
- virtual void SetContentInfo( const std::string& contentInfo ) = 0;
+ virtual void SetContentInfo(const std::string& contentInfo) = 0;
};
} // namespace Adaptor
${adaptor_system_dir}/common/stat-context-manager.cpp
${adaptor_system_dir}/common/system-trace.cpp
${adaptor_system_dir}/common/thread-controller.cpp
- ${adaptor_system_dir}/common/time-service.cpp
${adaptor_system_dir}/common/update-status-logger.cpp
${adaptor_system_dir}/common/widget-application-impl.cpp
)
${adaptor_system_dir}/linux/callback-manager-ecore.cpp
${adaptor_system_dir}/linux/file-descriptor-monitor-ecore.cpp
${adaptor_system_dir}/generic/shared-file-operations-generic.cpp
+ ${adaptor_system_dir}/common/time-service.cpp
${adaptor_system_dir}/linux/timer-impl-ecore.cpp
)
${adaptor_system_dir}/tizen-wayland/logging-tizen.cpp
${adaptor_system_dir}/tizen-wayland/system-settings-tizen.cpp
${adaptor_system_dir}/tizen-wayland/widget-application-impl-tizen.cpp
+ ${adaptor_system_dir}/common/time-service.cpp
${adaptor_system_dir}/tizen-wayland/widget-controller-tizen.cpp
)
${adaptor_system_dir}/ubuntu-x11/logging-x.cpp
${adaptor_system_dir}/ubuntu-x11/system-settings-x.cpp
${adaptor_system_dir}/ubuntu-x11/widget-application-impl-x.cpp
+ ${adaptor_system_dir}/common/time-service.cpp
${adaptor_system_dir}/ubuntu-x11/widget-controller-x.cpp
)
${adaptor_system_dir}/android/shared-file-operations-android.cpp
${adaptor_system_dir}/android/system-settings-android.cpp
${adaptor_system_dir}/android/timer-impl-android.cpp
+ ${adaptor_system_dir}/common/time-service.cpp
${adaptor_system_dir}/android/widget-application-impl-android.cpp
)
${adaptor_system_dir}/windows/trigger-event-factory.cpp
${adaptor_system_dir}/windows/logging-win.cpp
${adaptor_system_dir}/windows/widget-application-impl-win.cpp
+ ${adaptor_system_dir}/common/time-service.cpp
${adaptor_system_dir}/windows/widget-controller-win.cpp
)
+
+# module: system, backend: macOS
+SET( adaptor_system_macos_src_files
+ ${adaptor_system_dir}/ubuntu-x11/logging-x.cpp
+ ${adaptor_system_dir}/macos/file-descriptor-monitor-macos.cpp
+ ${adaptor_system_dir}/macos/timer-impl-mac.cpp
+ ${adaptor_system_dir}/common/shared-file.cpp
+ ${adaptor_system_dir}/common/trigger-event-factory.cpp
+ ${adaptor_system_dir}/generic/shared-file-operations-generic.cpp
+ ${adaptor_system_dir}/common/time-service.cpp
+ ${adaptor_system_dir}/macos/trigger-event.mm
+ ${adaptor_system_dir}/macos/callback-manager-mac.mm
+ ${adaptor_system_dir}/macos/widget-application-impl-mac.cpp
+)
/*
- * 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;
#define DALI_ECORE_CALLBACK_MANAGER_H
/*
- * 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/internal/system/common/callback-manager.h>
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
struct CallbackData;
/**
*/
class EcoreCallbackManager : public CallbackManager
{
-
public:
-
- /**
+ /**
* @brief constructor
*/
- EcoreCallbackManager();
+ EcoreCallbackManager();
- /**
+ /**
* @brief destructor
*/
- ~EcoreCallbackManager()
- {
- }
+ ~EcoreCallbackManager()
+ {
+ }
- /**
+ /**
* @copydoc CallbackManager::AddIdleCallback()
*/
- bool AddIdleCallback( CallbackBase* callback, bool hasReturnValue ) override;
+ bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) override;
- /**
+ /**
* @copydoc CallbackManager::RemoveIdleCallback()
*/
- void RemoveIdleCallback( CallbackBase* callback ) override;
+ void RemoveIdleCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::ProcessIdle()
*/
- bool ProcessIdle() override;
+ bool ProcessIdle() override;
- /**
+ /**
* @copydoc CallbackManager::ProcessIdle()
*/
- void ClearIdleCallbacks() override;
+ void ClearIdleCallbacks() override;
- /**
+ /**
* @copydoc CallbackManager::AddIdleEntererCallback()
*/
- bool AddIdleEntererCallback( CallbackBase* callback ) override;
+ bool AddIdleEntererCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::RemoveIdleEntererCallback()
*/
- void RemoveIdleEntererCallback( CallbackBase* callback ) override;
+ void RemoveIdleEntererCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::Start()
*/
- void Start() override;
+ void Start() override;
- /**
+ /**
* @copydoc CallbackManager::Stop()
*/
- void Stop() override;
+ void Stop() override;
private:
-
- /**
+ /**
* @brief Remove all idle call backs that are pending
* Called by Stop()
* Always called from the main thread
*/
- void RemoveAllCallbacks();
+ void RemoveAllCallbacks();
- /**
+ /**
* @brief Removes a single call back from the container
* Always called from main thread
* @param callbackData callback data
*/
- void RemoveCallbackFromContainer(CallbackData *callbackData);
+ void RemoveCallbackFromContainer(CallbackData* callbackData);
- /**
+ /**
* @brief Remove a standard call back from ecore
* Always called from main thread
* @param callbackData callback data
*/
- void RemoveStandardCallback(CallbackData *callbackData);
-
+ void RemoveStandardCallback(CallbackData* callbackData);
- typedef std::list<CallbackData *> CallbackList;
+ typedef std::list<CallbackData*> CallbackList;
- bool mRunning; ///< flag is set to true if when running
- CallbackList mCallbackContainer; ///< container of live idle callbacks
+ bool mRunning; ///< flag is set to true if when running
+ CallbackList mCallbackContainer; ///< container of live idle callbacks
};
} // namespace Adaptor
#define DALI_INTERNAL_SYSTEM_LINUX_DALI_ECORE_X_H
/*
- * 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.
#pragma GCC system_header
#include <Ecore_X.h>
-
-
#endif /* DALI_INTERNAL_SYSTEM_LINUX_DALI_ECORE_X_H */
#define DALI_INTERNAL_SYSTEM_LINUX_DALI_ECORE_H
/*
- * 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.
#pragma GCC system_header
#include <Ecore.h>
-
-
#endif /* DALI_INTERNAL_SYSTEM_LINUX_DALI_ECORE_H */
#define DALI_INTERNAL_SYSTEM_LINUX_DALI_ELEMENTARY_H
/*
- * 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.
#pragma GCC system_header
#include <Elementary.h>
-
-
#endif /* DALI_INTERNAL_SYSTEM_LINUX_DALI_ELEMENTARY_H */
/*
- * 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;
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/system/common/callback-manager.h>
+#include <memory>
+
+namespace Dali::Internal::Adaptor
+{
+/**
+ * @brief Cocoa Implementation of CallbackManager
+ */
+class CocoaCallbackManager : public CallbackManager
+{
+public:
+ CocoaCallbackManager();
+
+ /**
+ * @copydoc CallbackManager::AddIdleCallback()
+ */
+ bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) override;
+
+ /**
+ * @caopydoc CallbackManager::RemoveIdleCallback
+ */
+ void RemoveIdleCallback(CallbackBase* callback) override;
+
+ /**
+ * @copydoc CallbackManager::ProcessIdle
+ */
+ bool ProcessIdle() override;
+
+ /**
+ * @copydoc CallbackManager::ClearIdleCallbacks
+ */
+ void ClearIdleCallbacks() override;
+
+ /**
+ * @copydoc CallbackManager::AddIdleEntererCallback
+ */
+ bool AddIdleEntererCallback(CallbackBase* callback) override;
+
+ /**
+ * @copydoc CallbackManager::RemoveIdleEntererCallback
+ */
+ void RemoveIdleEntererCallback(CallbackBase* callback) override;
+
+ /**
+ * @copydoc CallbackManager::Start
+ */
+ void Start() override;
+
+ /**
+ * @copydoc CallbackManager::Stop
+ */
+ void Stop() override;
+
+ struct Impl;
+
+private:
+ std::unique_ptr<Impl> mImpl;
+ bool mRunning;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+#include "extern-definitions.h"
+
+#include "callback-manager-mac.h"
+
+#include <unordered_map>
+#include <optional>
+
+namespace
+{
+NSString *EventName = @"Dali::Internal::Adaptor::CallbackManager";
+}
+
+using Dali::Internal::Adaptor::CocoaCallbackManager;
+
+// This is the observer that processes callback events
+@interface CallbackObserver : NSObject
+- (CallbackObserver *) init;
+- (void) ReceiveCallback:(NSNotification *) aNotification;
+@end
+
+// DaliCallback is the Objective-C object holding the information to execute the callback
+@interface DaliCallback : NSObject
+- (DaliCallback *) initWithImpl:(CocoaCallbackManager::Impl*) impl
+ withCallback:(Dali::CallbackBase *) callback;
+- (void) ExecuteCallback;
+@end
+
+namespace Dali::Internal::Adaptor
+{
+
+namespace Detail
+{
+// Helper class to implement the callbacks containers
+// The boolean value corresponds to the hasReturnValue parameter
+struct CallbackContainer final : public std::unordered_map<CallbackBase*, bool>
+{
+ using Parent = std::unordered_map<CallbackBase*, bool>;
+ using iterator = Parent::iterator;
+ using const_iterator = Parent::const_iterator;
+ using value_type = Parent::value_type;
+ using key_type = Parent::key_type;
+ using size_type = Parent::size_type;
+
+ ~CallbackContainer() { Clear(); }
+
+ void RemoveCallback(const_iterator item)
+ {
+ delete item->first;
+ erase(item);
+ }
+
+ bool RemoveCallback(CallbackBase *callback)
+ {
+ if (auto it(find(callback)); it != end())
+ {
+ RemoveCallback(it);
+ return true;
+ }
+
+ return false;
+ }
+
+ void Clear()
+ {
+ for (auto [cb, dummy]: *this)
+ {
+ delete cb;
+ }
+
+ clear();
+ }
+
+ // Execute the callback if it is present. The first item in the
+ // return value tells either the callback was executed or not.
+ // The second item gives the return value of the callback itself,
+ // if any.
+ std::pair<const_iterator, std::optional<bool>>
+ Execute(CallbackBase *callback) const
+ {
+ std::optional<bool> retValue;
+
+ auto it(find(callback));
+ if (it != end())
+ {
+ retValue = Execute(it);
+ }
+
+ return std::make_pair(it, retValue);
+ }
+
+ std::optional<bool> Execute(const_iterator it) const
+ {
+ auto [callback, hasReturnValue] = *it;
+ if (hasReturnValue)
+ {
+ return CallbackBase::ExecuteReturn<bool>(*callback);
+ }
+ else
+ {
+ CallbackBase::Execute(*callback);
+ }
+
+ return std::optional<bool>();
+ }
+};
+}
+
+// Internal implementation of the CallbackManager
+struct CocoaCallbackManager::Impl final
+{
+ CFRunLoopObserverContext mObserverContext;
+
+ Detail::CallbackContainer mCallbacks, mIdleEntererCallbacks;
+ CFRef<CFRunLoopObserverRef> mIdleObserver;
+ CallbackObserver *mObserver;
+
+ Impl();
+ ~Impl();
+
+ Impl(const Impl &) = delete;
+ Impl &operator=(const Impl&) = delete;
+ Impl(const Impl &&) = delete;
+ Impl &operator=(const Impl&&) = delete;
+
+ bool ProcessIdle();
+ void EnqueueNotification(DaliCallback *callback) const;
+ inline bool AddIdleEntererCallback(CallbackBase *callback);
+ bool AddIdleCallback(CallbackBase *callback, bool hasReturnValue);
+
+private:
+ static void IdleEnterObserverCallback(
+ CFRunLoopObserverRef observer,
+ CFRunLoopActivity activity,
+ void *info
+ );
+};
+
+CocoaCallbackManager::Impl::Impl()
+ : mObserverContext{0, this, nullptr, nullptr, 0}
+ // mIdleObserver is configured to receive a notification
+ // when to run loop is about to sleep
+ , mIdleObserver(MakeRef(CFRunLoopObserverCreate(
+ kCFAllocatorDefault,
+ kCFRunLoopBeforeWaiting,
+ true,
+ 0,
+ IdleEnterObserverCallback,
+ &mObserverContext)))
+{
+ CFRunLoopAddObserver(CFRunLoopGetMain(), mIdleObserver.get(), kCFRunLoopCommonModes);
+ mObserver = [[CallbackObserver alloc] init];
+}
+
+CocoaCallbackManager::Impl::~Impl()
+{
+ CFRunLoopRemoveObserver(CFRunLoopGetMain(), mIdleObserver.get(), kCFRunLoopCommonModes);
+ auto *center = [NSNotificationCenter defaultCenter];
+ [center removeObserver:mObserver name:EventName object:nil];
+}
+
+bool CocoaCallbackManager::Impl::ProcessIdle()
+{
+ auto ret = !mCallbacks.empty();
+ for (auto it(cbegin(mCallbacks)), e(cend(mCallbacks)); it != e; ++it)
+ {
+ if (!mCallbacks.Execute(it).value_or(false))
+ {
+ mCallbacks.RemoveCallback(it);
+ }
+ }
+
+ return ret;
+}
+
+void CocoaCallbackManager::Impl::EnqueueNotification(DaliCallback *callback) const
+{
+ auto *notification = [NSNotification notificationWithName:EventName object:callback];
+ auto *queue = [NSNotificationQueue defaultQueue];
+ [queue enqueueNotification:notification postingStyle:NSPostWhenIdle coalesceMask:0 forModes:nil];
+}
+
+bool CocoaCallbackManager::Impl::AddIdleEntererCallback(CallbackBase *callback)
+{
+ return mIdleEntererCallbacks.emplace(callback, true).second;
+}
+
+void CocoaCallbackManager::Impl::IdleEnterObserverCallback(
+ CFRunLoopObserverRef observer,
+ CFRunLoopActivity activity,
+ void *info
+)
+{
+ auto *pImpl = reinterpret_cast<Impl*>(info);
+
+ for (auto it(cbegin(pImpl->mIdleEntererCallbacks)),
+ e(cend(pImpl->mIdleEntererCallbacks)); it != e; ++it)
+ {
+ if (!pImpl->mIdleEntererCallbacks.Execute(it).value_or(false))
+ {
+ pImpl->mIdleEntererCallbacks.RemoveCallback(it);
+ }
+ }
+}
+
+bool CocoaCallbackManager::Impl::AddIdleCallback(
+ CallbackBase *callback, bool hasReturnValue)
+{
+ if (mCallbacks.emplace(callback, hasReturnValue).second)
+ {
+ auto *daliCallback = [[DaliCallback alloc] initWithImpl:this
+ withCallback:callback];
+ EnqueueNotification(daliCallback);
+ return true;
+ }
+
+ return false;
+}
+
+// Creates a concrete interface for CallbackManager
+CallbackManager* CallbackManager::New()
+{
+ return new CocoaCallbackManager;
+}
+
+CocoaCallbackManager::CocoaCallbackManager()
+ : mImpl(std::make_unique<CocoaCallbackManager::Impl>())
+ , mRunning(false)
+{
+}
+
+bool CocoaCallbackManager::AddIdleCallback(CallbackBase *callback, bool hasReturnValue)
+{
+ return mRunning && mImpl->AddIdleCallback(callback, hasReturnValue);
+}
+
+void CocoaCallbackManager::RemoveIdleCallback(CallbackBase *callback)
+{
+ mImpl->mCallbacks.RemoveCallback(callback);
+}
+
+bool CocoaCallbackManager::ProcessIdle()
+{
+ return mImpl->ProcessIdle();
+}
+
+void CocoaCallbackManager::ClearIdleCallbacks()
+{
+ mImpl->mCallbacks.Clear();
+}
+
+bool CocoaCallbackManager::AddIdleEntererCallback(CallbackBase* callback)
+{
+ return mRunning && mImpl->AddIdleEntererCallback(callback);;
+}
+
+void CocoaCallbackManager::RemoveIdleEntererCallback(CallbackBase* callback)
+{
+ mImpl->mIdleEntererCallbacks.RemoveCallback(callback);
+}
+
+void CocoaCallbackManager::Start()
+{
+ DALI_ASSERT_DEBUG( mRunning == false );
+ mRunning = true;
+}
+
+void CocoaCallbackManager::Stop()
+{
+ DALI_ASSERT_DEBUG( mRunning == true );
+ mRunning = false;
+}
+
+}
+
+@implementation DaliCallback
+{
+ CocoaCallbackManager::Impl *mImpl;
+ Dali::CallbackBase *mCallback;
+}
+
+- (DaliCallback *) initWithImpl:(CocoaCallbackManager::Impl *) impl
+ withCallback:(Dali::CallbackBase *) callback
+{
+ self = [super init];
+ if (self)
+ {
+ mImpl = impl;
+ mCallback = callback;
+ }
+ return self;
+}
+
+- (void) ExecuteCallback
+{
+ // Look for the callback inside the list.
+ // If it is not there, then it was either called by ProcessIdle
+ // or was removed by RemoveCallback.
+ if (auto [iter, shouldKeep] = mImpl->mCallbacks.Execute(mCallback);
+ iter != mImpl->mCallbacks.end())
+ {
+ if (!shouldKeep.value_or(false))
+ {
+ mImpl->mCallbacks.RemoveCallback(iter);
+ }
+ else
+ {
+ mImpl->EnqueueNotification(self);
+ }
+ }
+}
+@end
+
+@implementation CallbackObserver
+- (CallbackObserver *) init
+{
+ self = [super init];
+ if (self)
+ {
+ auto *center = [NSNotificationCenter defaultCenter];
+ [center addObserver:self
+ selector:@selector(ReceiveCallback:)
+ name:EventName
+ object:nil];
+ }
+ return self;
+}
+
+- (void) ReceiveCallback:(NSNotification *)aNotification
+{
+ DaliCallback *callback = [aNotification object];
+ [callback ExecuteCallback];
+}
+@end
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/system/common/file-descriptor-monitor.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+namespace Dali::Internal::Adaptor
+{
+FileDescriptorMonitor::FileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask)
+{
+ DALI_LOG_WARNING("Implementation missing for macOS");
+}
+
+FileDescriptorMonitor::~FileDescriptorMonitor()
+{
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/system/common/timer-impl.h>
+#include "extern-definitions.h"
+
+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()
+ {
+ Stop();
+ }
+
+ static void TimerProc(CFRunLoopTimerRef timer, void* info);
+
+ void Start();
+ void Stop();
+ void Reset(Timer* parent, unsigned int milliSec);
+
+ unsigned int GetInterval() const noexcept
+ {
+ return CFRunLoopTimerGetInterval(mTimer.get()) * 1000.0;
+ }
+
+ bool IsRunning() const noexcept
+ {
+ return CFRunLoopTimerIsValid(mTimer.get());
+ }
+
+private:
+ CFRef<CFRunLoopTimerRef> CreateTimer(Timer* parent, unsigned int milliSec);
+
+ CFRef<CFRunLoopTimerRef> mTimer;
+};
+
+void Timer::Impl::TimerProc(CFRunLoopTimerRef timer, void* info)
+{
+ auto* pTimer = static_cast<Timer*>(info);
+ pTimer->Tick();
+}
+
+void Timer::Impl::Start()
+{
+ if(!IsRunning())
+ {
+ auto runLoop = CFRunLoopGetMain();
+ CFRunLoopAddTimer(runLoop, mTimer.get(), kCFRunLoopDefaultMode);
+ }
+}
+
+void Timer::Impl::Stop()
+{
+ if(IsRunning())
+ {
+ CFRunLoopTimerContext context;
+ CFRunLoopTimerGetContext(mTimer.get(), &context);
+ const auto interval = CFRunLoopTimerGetInterval(mTimer.get());
+ CFRunLoopTimerInvalidate(mTimer.get());
+
+ // After we invalidate the timer, we can't reuse it, so we create
+ // a new timer for case the user calls Start again
+ const auto fireDate = CFAbsoluteTimeGetCurrent() + interval;
+ mTimer.reset(CFRunLoopTimerCreate(
+ kCFAllocatorDefault,
+ fireDate,
+ interval,
+ 0,
+ 0,
+ TimerProc,
+ &context));
+ }
+}
+
+void Timer::Impl::Reset(Timer* parent, unsigned int milliSec)
+{
+ Stop();
+ mTimer = CreateTimer(parent, milliSec);
+ Start();
+}
+
+CFRef<CFRunLoopTimerRef>
+Timer::Impl::CreateTimer(Timer* parent, unsigned int milliSec)
+{
+ const auto interval = static_cast<CFAbsoluteTime>(milliSec) / 1000;
+ const auto fireDate = CFAbsoluteTimeGetCurrent() + interval;
+ CFRunLoopTimerContext context =
+ {
+ .version = 0,
+ .info = parent,
+ .retain = nullptr,
+ .release = nullptr,
+ };
+
+ return MakeRef(CFRunLoopTimerCreate(
+ kCFAllocatorDefault,
+ fireDate,
+ interval,
+ 0,
+ 0,
+ TimerProc,
+ &context));
+}
+
+TimerPtr Timer::New(unsigned int milliSec)
+{
+ return new Timer(milliSec);
+}
+
+Timer::Timer(unsigned int milliSec)
+: mImpl(new Impl(this, milliSec))
+{
+}
+
+Timer::~Timer()
+{
+ // stop timers
+ Stop();
+
+ delete mImpl;
+ mImpl = NULL;
+}
+
+void Timer::Start()
+{
+ mImpl->Start();
+}
+
+void Timer::Stop()
+{
+ mImpl->Stop();
+}
+
+void Timer::Pause()
+{
+}
+
+void Timer::Resume()
+{
+}
+
+void Timer::SetInterval(unsigned int interval, bool restart)
+{
+ mImpl->Reset(this, interval);
+}
+
+unsigned int Timer::GetInterval() const
+{
+ return mImpl->GetInterval();
+}
+
+bool Timer::Tick()
+{
+ // Guard against destruction during signal emission
+ Dali::Timer handle(this);
+
+ bool retVal(false);
+
+ // Override with new signal if used
+ if(!mTickSignal.Empty())
+ {
+ retVal = mTickSignal.Emit();
+
+ // Timer stops if return value is false
+ if(retVal == false)
+ {
+ Stop();
+ }
+ else
+ {
+ retVal = true; // continue emission
+ }
+ }
+ else // no callbacks registered
+ {
+ // periodic timer is started but nobody listens, continue
+ retVal = true;
+ }
+
+ return retVal;
+}
+
+Dali::Timer::TimerSignalType& Timer::TickSignal()
+{
+ return mTickSignal;
+}
+
+bool Timer::IsRunning() const
+{
+ return mImpl->IsRunning();
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/signals/callback.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/trigger-event-interface.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+#include <memory>
+
+namespace Dali::Internal::Adaptor
+{
+class TriggerEvent : public TriggerEventInterface
+{
+public:
+ /**
+ * Constructor
+ * Creates an event file descriptor and starts a GSource which reads from the file
+ * descriptor when there is data.
+ *
+ * @param[in] callback The callback to call
+ * @param[in] options Trigger event options.
+ * @note The ownership of callback is taken by this class.
+ */
+ TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options);
+
+ /**
+ * Triggers the event.
+ *
+ * This can be called from one thread in order to wake up another thread.
+ */
+ void Trigger() override;
+
+ struct Impl;
+
+private:
+ /**
+ * @brief Called when our event file descriptor has been written to.
+ * @param[in] eventBitMask bit mask of events that occured on the file descriptor
+ */
+ void Triggered();
+
+ std::unique_ptr<CallbackBase> mCallback;
+ std::unique_ptr<Impl> mImpl;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+#include <atomic>
+#include <string>
+#include <sstream>
+#include <type_traits>
+#include "trigger-event.h"
+
+namespace
+{
+const char *EventName = "Dali::Internal::Adaptor::Triggerevent_";
+}
+
+@interface NotificationObserver : NSObject
+
+-(NotificationObserver *) initTriggerImpl:(Dali::Internal::Adaptor::TriggerEvent::Impl *) impl;
+
+@end
+
+namespace Dali::Internal::Adaptor
+{
+
+struct TriggerEvent::Impl final
+{
+ std::unique_ptr<CallbackBase> mCallback;
+ NotificationObserver *mReceiver;
+ NSString *mName;
+ TriggerEventInterface::Options mOptions;
+
+ Impl(CallbackBase *callback, TriggerEventInterface::Options options)
+ : mCallback(callback), mOptions(options)
+ {
+ const auto myId = mNameId.fetch_add(1, std::memory_order_relaxed);
+
+ std::stringstream ss;
+ ss << EventName << myId;
+ mName = [NSString stringWithUTF8String:ss.str().c_str()];
+
+ mReceiver = [[NotificationObserver alloc] initTriggerImpl:this];
+ }
+
+ Impl(Impl &&) = delete;
+ Impl &operator=(Impl &&) = delete;
+
+ ~Impl()
+ {
+ auto *center = [NSNotificationCenter defaultCenter];
+ [center removeObserver:mReceiver];
+ }
+
+ void Trigged()
+ {
+ CallbackBase::Execute( *mCallback );
+ }
+
+private:
+ // This is incremented each time the class is instatiated to guarantee
+ // an unique notification id
+ static std::atomic_uint64_t mNameId;
+};
+
+std::atomic<uint64_t> TriggerEvent::Impl::mNameId{0};
+
+TriggerEvent::TriggerEvent(CallbackBase *callback, TriggerEventInterface::Options options)
+ : mCallback(callback)
+ , mImpl(std::make_unique<Impl>(MakeCallback(this, &TriggerEvent::Triggered), options))
+{
+}
+
+void TriggerEvent::Trigger()
+{
+ auto center = [NSDistributedNotificationCenter defaultCenter];
+
+ // Post a notification to the notification center
+ // The run loop will pop the queue and call the notification center
+ [center postNotificationName:mImpl->mName object:nil];
+}
+
+void TriggerEvent::Triggered()
+{
+ CallbackBase::Execute(*mCallback);
+
+ if (mImpl->mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER)
+ {
+ delete this;
+ }
+}
+
+}
+
+@implementation NotificationObserver
+{
+ Dali::Internal::Adaptor::TriggerEvent::Impl *mImpl;
+}
+
+-(void) ReceiveNotification: (NSNotification *) aNotification
+{
+ mImpl->Trigged();
+}
+
+-(NotificationObserver *) initTriggerImpl:(Dali::Internal::Adaptor::TriggerEvent::Impl *) impl;
+{
+ self = [super init];
+ if (self)
+ {
+ mImpl = impl;
+ auto center = [NSDistributedNotificationCenter defaultCenter];
+ [center addObserver:self
+ selector:@selector(ReceiveNotification:)
+ name:impl->mName
+ object:nil
+ suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
+ }
+
+ return self;
+}
+
+@end
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/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[],
+ const std::string& stylesheet)
+{
+ return new WidgetApplicationCocoa(argc, argv, stylesheet);
+}
+
+WidgetApplicationCocoa::WidgetApplicationCocoa(
+ int* argc,
+ char** argv[],
+ const std::string& stylesheet)
+: WidgetApplication(argc, argv, stylesheet)
+{
+ DALI_LOG_ERROR("WidgetApplication is not implemented in MACOS profile.\n");
+}
+
+WidgetApplicationCocoa::~WidgetApplicationCocoa()
+{
+}
+
+void WidgetApplicationCocoa::RegisterWidgetCreatingFunction(
+ const std::string& widgetName,
+ Dali::WidgetApplication::CreateWidgetFunction createFunction)
+{
+}
+
+// factory function, must be implemented
+namespace WidgetApplicationFactory
+{
+/**
+ * Create a new widget application
+ * @param[in] argc A pointer to the number of arguments
+ * @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)
+{
+ return WidgetApplicationCocoa::New(argc, argv, stylesheet);
+}
+
+} // namespace WidgetApplicationFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H
+#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/application-impl.h>
+#include <dali/internal/system/common/widget-application-impl.h>
+#include <dali/public-api/adaptor-framework/widget-application.h>
+
+namespace Dali
+{
+class Widget;
+
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Implementation of the WidgetApplicationCocoa class.
+ */
+class WidgetApplicationCocoa : public WidgetApplication
+{
+public:
+ typedef std::pair<
+ const std::string,
+ Dali::WidgetApplication::CreateWidgetFunction>
+ CreateWidgetFunctionPair;
+
+ typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
+
+ /**
+ * Create a new widget application
+ * @param[in] argc A pointer to the number of arguments
+ * @param[in] argv A pointer to the argument list
+ * @param[in] stylesheet The path to user defined theme file
+ */
+ static WidgetApplicationPtr New(
+ int* argc,
+ char** argv[],
+ const std::string& stylesheet);
+
+public:
+ /**
+ * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
+ */
+ void RegisterWidgetCreatingFunction(
+ const std::string& widgetName,
+ Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
+
+protected:
+ /**
+ * Private Constructor
+ * @param[in] argc A pointer to the number of arguments
+ * @param[in] argv A pointer to the argument list
+ * @param[in] stylesheet The path to user defined theme file
+ */
+ WidgetApplicationCocoa(int* argc, char** argv[], const std::string& stylesheet);
+
+ /**
+ * Destructor
+ */
+ virtual ~WidgetApplicationCocoa();
+
+ WidgetApplicationCocoa(const Application&) = delete;
+ WidgetApplicationCocoa& operator=(Application&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WIDGET_APPLICATION_IMPL_UBUNTU_H
/*
- * 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
#define DALI_INTERNAL_WIDGET_APPLICATION_TIZEN_H
/*
- * 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 <widget_base.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/internal/adaptor/common/application-impl.h>
#include <dali/internal/system/common/widget-application-impl.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
class WidgetApplication;
typedef IntrusivePtr<WidgetApplication> WidgetApplicationPtr;
class WidgetApplicationTizen : public WidgetApplication
{
public:
-
- typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction > CreateWidgetFunctionPair;
- typedef std::vector< CreateWidgetFunctionPair > CreateWidgetFunctionContainer;
+ typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
+ typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
/**
* Create a new widget application
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+ static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
public:
/**
/**
* @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
*/
- void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) override;
+ void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
/**
* Add widget name - CreateWidgetFunction pair to container.
*/
- void AddWidgetCreatingFunctionPair( CreateWidgetFunctionPair pair );
+ void AddWidgetCreatingFunctionPair(CreateWidgetFunctionPair pair);
/**
* Find and get CreateWidgetFunctionPair in container by widget name.
*/
- CreateWidgetFunctionPair GetWidgetCreatingFunctionPair( const std::string& widgetName );
+ CreateWidgetFunctionPair GetWidgetCreatingFunctionPair(const std::string& widgetName);
/**
* Add widget_base_instance_h - Widget instance pair to container.
*/
- void AddWidget( widget_base_instance_h widgetBaseInstance, Dali::Widget widget , Dali::Window window );
+ void AddWidget(widget_base_instance_h widgetBaseInstance, Dali::Widget widget, Dali::Window window);
/**
* Find and get Widget instance in container by widget_base_instance_h.
*/
- Dali::Widget GetWidget( widget_base_instance_h widgetBaseInstance ) const;
+ Dali::Widget GetWidget(widget_base_instance_h widgetBaseInstance) const;
/**
* Delete widget_base_instance_h - Widget instance pair in container.
*/
- void DeleteWidget( widget_base_instance_h widgetBaseInstance );
+ void DeleteWidget(widget_base_instance_h widgetBaseInstance);
/**
* Find and get Window instance in container by widget_base_instance_h.
*/
- Dali::Window GetWindowFromWidget( widget_base_instance_h widgetBaseInstance ) const;
+ Dali::Window GetWindowFromWidget(widget_base_instance_h widgetBaseInstance) const;
/**
* Get the number of created widget.
int32_t GetWidgetCount();
protected:
-
/**
* Private Constructor
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- WidgetApplicationTizen( int* argc, char **argv[], const std::string& stylesheet );
+ WidgetApplicationTizen(int* argc, char** argv[], const std::string& stylesheet);
/**
* Destructor
WidgetApplicationTizen& operator=(Application&) = delete;
private:
+ typedef std::pair<widget_base_instance_h, Dali::Widget> WidgetInstancePair;
+ typedef std::vector<WidgetInstancePair> WidgetInstanceContainer;
- typedef std::pair< widget_base_instance_h, Dali::Widget > WidgetInstancePair;
- typedef std::vector< WidgetInstancePair > WidgetInstanceContainer;
-
- CreateWidgetFunctionContainer mCreateWidgetFunctionContainer;
- WidgetInstanceContainer mWidgetInstanceContainer;
+ CreateWidgetFunctionContainer mCreateWidgetFunctionContainer;
+ WidgetInstanceContainer mWidgetInstanceContainer;
- typedef std::pair< widget_base_instance_h, Dali::Window > WindowInstancePair;
- typedef std::vector< WindowInstancePair > WindowInstanceContainer;
- WindowInstanceContainer mWindowInstanceContainer;
+ typedef std::pair<widget_base_instance_h, Dali::Window> WindowInstancePair;
+ typedef std::vector<WindowInstancePair> WindowInstanceContainer;
+ WindowInstanceContainer mWindowInstanceContainer;
};
} // 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
#define DALI_WIDGET_CONTROLLER_TIZEN_H
/*
- * 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 <widget_base.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/widget-impl.h>
#include <dali/internal/system/common/widget-controller.h>
+#include <dali/public-api/adaptor-framework/widget-impl.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* @brief Holds the Implementation for the internal WidgetImpl class
*/
class WidgetImplTizen : public Widget::Impl
{
public:
-
/**
* Constructor
*/
- WidgetImplTizen( widget_base_instance_h instanceHandle );
+ WidgetImplTizen(widget_base_instance_h instanceHandle);
/**
* Destructor
~WidgetImplTizen() override;
public:
-
/**
* Set content information to widget framework
*/
- void SetContentInfo( const std::string& contentInfo ) override;
+ void SetContentInfo(const std::string& contentInfo) override;
private:
-
widget_base_instance_h mInstanceHandle;
};
/*
- * 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
#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_UBUNTU_H
/*
- * 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 Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of the WidgetApplicationUbuntu class.
*/
class WidgetApplicationUbuntu : public WidgetApplication
{
public:
-
- typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction > CreateWidgetFunctionPair;
- typedef std::vector< CreateWidgetFunctionPair > CreateWidgetFunctionContainer;
+ typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
+ typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
/**
* Create a new widget application
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+ static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
public:
-
/**
* @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
*/
- void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) override;
+ void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
protected:
-
/**
* Private Constructor
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- WidgetApplicationUbuntu( int* argc, char **argv[], const std::string& stylesheet );
+ WidgetApplicationUbuntu(int* argc, char** argv[], const std::string& stylesheet);
/**
* Destructor
/*
- * 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)
{
}
#define DALI_WIDGET_CONTROLLER_UBUNTU_H
/*
- * 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 WidgetImplUbuntu : public Widget::Impl
{
public:
-
/**
* Constructor
*/
~WidgetImplUbuntu() override;
public:
-
/**
* Set content information to widget framework
*/
- void SetContentInfo( const std::string& contentInfo ) override;
+ void SetContentInfo(const std::string& contentInfo) override;
};
} // namespace Adaptor
/*\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
#define DALI_WIN_CALLBACK_MANAGER_H
/*
- * 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 WinCallbackManager : public CallbackManager
{
-
public:
-
- /**
+ /**
* @brief constructor
*/
- WinCallbackManager();
+ WinCallbackManager();
- /**
+ /**
* @brief destructor
*/
- ~WinCallbackManager(){}
+ ~WinCallbackManager()
+ {
+ }
- /**
+ /**
* @copydoc CallbackManager::AddIdleCallback()
*/
- bool AddIdleCallback( CallbackBase* callback, bool hasReturnValue ) override;
+ bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) override;
- /**
+ /**
* @copydoc CallbackManager::RemoveIdleCallback()
*/
- void RemoveIdleCallback( CallbackBase* callback ) override;
+ void RemoveIdleCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::ProcessIdle()
*/
- bool ProcessIdle() override;
+ bool ProcessIdle() override;
- /**
+ /**
* @copydoc CallbackManager::ClearIdleCallbacks()
*/
- void ClearIdleCallbacks() override;
+ void ClearIdleCallbacks() override;
- /**
+ /**
* @brief Adds a @p callback to be run when entering an idle state.
* @note Must be called from the main thread only.
*
*
* @return true on success
*/
- bool AddIdleEntererCallback( CallbackBase* callback ) override;
+ bool AddIdleEntererCallback(CallbackBase* callback) override;
- /**
+ /**
* @brief Removes a previously added the idle enterer callback.
* @note Must be called from main thread only.
*
*
* @param[in] callback The callback to be removed.
*/
- void RemoveIdleEntererCallback( CallbackBase* callback ) override;
+ void RemoveIdleEntererCallback(CallbackBase* callback) override;
- /**
+ /**
* @copydoc CallbackManager::Start()
*/
- void Start() override;
+ void Start() override;
- /**
+ /**
* @copydoc CallbackManager::Stop()
*/
- void Stop() override;
+ void Stop() override;
private:
- std::set<CallbackBase*> mCallbacks;
- bool mRunning; ///< flag is set to true if when running
+ std::set<CallbackBase*> mCallbacks;
+ bool mRunning; ///< flag is set to true if when running
};
} // 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
{
-
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
#define DALI_INTERNAL_TRIGGER_EVENT_IMPL_H
/*
-* 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/public-api/signals/callback.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/integration-api/adaptor-framework/trigger-event-interface.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class TriggerEvent : public TriggerEventInterface
{
public:
-
/**
* Constructor
* Creates an event file descriptor and starts a GSource which reads from the file
* @param[in] options Trigger event options.
* @note The ownership of callback is taken by this class.
*/
- TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options );
+ TriggerEvent(CallbackBase* callback, TriggerEventInterface::Options options);
/**
* Destructor
~TriggerEvent();
public:
-
/**
* Triggers the event.
*
void Trigger();
private:
-
/**
* @brief Called when our event file descriptor has been written to.
* @param[in] eventBitMask bit mask of events that occured on the file descriptor
void Triggered();
private:
-
- CallbackBase* mCallback;
- CallbackBase* mSelfCallback;
- int32_t mThreadID;
+ CallbackBase* mCallback;
+ CallbackBase* mSelfCallback;
+ int32_t mThreadID;
TriggerEventInterface::Options mOptions;
};
/*
- * 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
#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H
/*
- * 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 INCLUDES
#include <dali/internal/adaptor/common/application-impl.h>
-#include <dali/internal/system/common//widget-application-impl.h>
+#include <dali/internal/system/common //widget-application-impl.h>
#include <dali/public-api/adaptor-framework/widget-application.h>
namespace Dali
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of the WidgetApplicationWin class.
*/
class WidgetApplicationWin : public WidgetApplication
{
public:
-
- typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction > CreateWidgetFunctionPair;
- typedef std::vector< CreateWidgetFunctionPair > CreateWidgetFunctionContainer;
+ typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction> CreateWidgetFunctionPair;
+ typedef std::vector<CreateWidgetFunctionPair> CreateWidgetFunctionContainer;
/**
* Create a new widget application
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+ static WidgetApplicationPtr New(int* argc, char** argv[], const std::string& stylesheet);
public:
-
/**
* @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
*/
- void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) override;
+ void RegisterWidgetCreatingFunction(const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction) override;
protected:
-
/**
* Private Constructor
* @param[in] argc A pointer to the number of arguments
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
*/
- WidgetApplicationWin( int* argc, char **argv[], const std::string& stylesheet );
+ WidgetApplicationWin(int* argc, char** argv[], const std::string& stylesheet);
/**
* Destructor
/*
- * 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)
{
}
#define DALI_WIDGET_CONTROLLER_WIN_H
/*
- * 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 WidgetImplWin : public Widget::Impl
{
public:
-
/**
* Constructor
*/
~WidgetImplWin() override;
public:
-
/**
* Set content information to widget framework
*/
- void SetContentInfo( const std::string& contentInfo ) override;
+ void SetContentInfo(const std::string& contentInfo) override;
};
} // namespace Adaptor
#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();
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_IMPL_H
/*
- * 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
{
-
/**
* Implementation of the BidirectionalSupport
*/
class BidirectionalSupport : public BaseObject
{
public:
-
/**
* Constructor
*/
/**
* @copydoc Dali::BidirectionalSupport::CreateInfo()
*/
- 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);
/**
* @copydoc Dali::BidirectionalSupport::DestroyInfo()
*/
- void DestroyInfo( BidiInfoIndex bidiInfoIndex );
+ void DestroyInfo(BidiInfoIndex bidiInfoIndex);
/**
* @copydoc Dali::BidirectionalSupport::Reorder()
*/
- void Reorder( BidiInfoIndex bidiInfoIndex,
- CharacterIndex firstCharacterIndex,
- Length numberOfCharacters,
- CharacterIndex* visualToLogicalMap );
+ void Reorder(BidiInfoIndex bidiInfoIndex,
+ CharacterIndex firstCharacterIndex,
+ Length numberOfCharacters,
+ CharacterIndex* visualToLogicalMap);
/**
* @copydoc Dali::BidirectionalSupport::GetMirroredText()
*/
- bool GetMirroredText( Character* text,
- CharacterDirection* directions,
- Length numberOfCharacters );
+ bool GetMirroredText(Character* text,
+ CharacterDirection* directions,
+ Length numberOfCharacters);
/**
* @copydoc Dali::BidirectionalSupport::GetParagraphDirection()
*/
- bool GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const;
+ bool GetParagraphDirection(BidiInfoIndex bidiInfoIndex) const;
/**
* @copydoc Dali::BidirectionalSupport::GetCharactersDirection()
*/
- void GetCharactersDirection( BidiInfoIndex bidiInfoIndex,
- CharacterDirection* directions,
- Length numberOfCharacters );
+ void GetCharactersDirection(BidiInfoIndex bidiInfoIndex,
+ CharacterDirection* directions,
+ Length numberOfCharacters);
private:
-
/**
* Helper for lazy initialization.
*/
void CreatePlugin();
private:
-
// Undefined copy constructor.
- BidirectionalSupport( const BidirectionalSupport& );
+ BidirectionalSupport(const BidirectionalSupport&);
// Undefined assignment constructor.
- BidirectionalSupport& operator=( const BidirectionalSupport& );
+ BidirectionalSupport& operator=(const BidirectionalSupport&);
private:
-
struct Plugin;
Plugin* mPlugin;
} // namespace TextAbstraction
-inline static TextAbstraction::Internal::BidirectionalSupport& GetImplementation( TextAbstraction::BidirectionalSupport& bidirectionalSupport )
+inline static TextAbstraction::Internal::BidirectionalSupport& GetImplementation(TextAbstraction::BidirectionalSupport& bidirectionalSupport)
{
- DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
+ DALI_ASSERT_ALWAYS(bidirectionalSupport && "bidirectional support handle is empty");
BaseObject& handle = bidirectionalSupport.GetBaseObject();
return static_cast<TextAbstraction::Internal::BidirectionalSupport&>(handle);
}
-inline static const TextAbstraction::Internal::BidirectionalSupport& GetImplementation( const TextAbstraction::BidirectionalSupport& bidirectionalSupport )
+inline static const TextAbstraction::Internal::BidirectionalSupport& GetImplementation(const TextAbstraction::BidirectionalSupport& bidirectionalSupport)
{
- DALI_ASSERT_ALWAYS( bidirectionalSupport && "bidirectional support handle is empty" );
+ DALI_ASSERT_ALWAYS(bidirectionalSupport && "bidirectional support handle is empty");
const BaseObject& handle = bidirectionalSupport.GetBaseObject();
return static_cast<const TextAbstraction::Internal::BidirectionalSupport&>(handle);
}
/*
- * 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;
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_CAIRO_RENDERER_H
/*
- * 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
{
/**
*
* @see Dali::TextAbstraction::TextRenderer.
*/
-Devel::PixelBuffer RenderTextCairo( const TextAbstraction::TextRenderer::Parameters& parameters );
+Devel::PixelBuffer RenderTextCairo(const TextAbstraction::TextRenderer::Parameters& parameters);
} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_TEXT_ABSTRACTION_CAIRO_RENDERER_H
-
/*
- * 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;
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_HELPER_H
/*
- * 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 TextAbstraction
{
-
namespace Internal
{
-
/**
* @brief Retrieves a table index for a given value.
*
*
* @return The index to the closest available value
*/
-int ValueToIndex( int value, const int* const table, unsigned int maxIndex );
+int ValueToIndex(int value, const int* const table, unsigned int maxIndex);
-} // Internal
+} // namespace Internal
-} // TextAbstraction
+} // namespace TextAbstraction
-} // Dali
+} // namespace Dali
#endif // DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_HELPER_H
/*
- * 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/text/text-abstraction/font-client-impl.h>
// EXTERNAL INCLUDES
-#if !(defined(DALI_PROFILE_UBUNTU) || defined(ANDROID) || defined(WIN32))
+#if !(defined(DALI_PROFILE_UBUNTU) || defined(ANDROID) || defined(WIN32) || defined(__APPLE__))
#include <vconf.h>
#endif
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))
- vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize );
+#if !(defined(DALI_PROFILE_UBUNTU) || defined(ANDROID) || defined(WIN32) || defined(__APPLE__))
+ 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);
}
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H
/*
- * 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-client.h>
-
struct FT_FaceRec_;
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
/**
* Implementation of the FontClient
*/
class FontClient : public BaseObject
{
public:
-
/**
* Constructor
*/
/**
* @copydoc Dali::TextAbstraction::FontClient::SetDpi()
*/
- void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
+ void SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDpi()
*/
- void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi );
+ void GetDpi(unsigned int& horizontalDpi, unsigned int& verticalDpi);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDefaultFontSize()
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDefaultFonts()
*/
- void GetDefaultFonts( FontList& defaultFonts );
+ void GetDefaultFonts(FontList& defaultFonts);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDefaultPlatformFontDescription()
*/
- void GetDefaultPlatformFontDescription( FontDescription& fontDescription );
+ void GetDefaultPlatformFontDescription(FontDescription& fontDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetSystemFonts()
*/
- void GetSystemFonts( FontList& systemFonts );
+ void GetSystemFonts(FontList& systemFonts);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDescription()
*/
- void GetDescription( FontId id, FontDescription& fontDescription );
+ void GetDescription(FontId id, FontDescription& fontDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetPointSize()
*/
- PointSize26Dot6 GetPointSize( FontId id );
+ PointSize26Dot6 GetPointSize(FontId id);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsCharacterSupportedByFont()
*/
- bool IsCharacterSupportedByFont( FontId fontId, Character character );
+ bool IsCharacterSupportedByFont(FontId fontId, Character character);
/**
* @copydoc Dali::TextAbstraction::FontClient::FindDefaultFont()
*/
- FontId FindDefaultFont( Character charcode,
- PointSize26Dot6 requestedPointSize,
- bool preferColor );
+ FontId FindDefaultFont(Character charcode,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor);
/**
* @copydoc Dali::TextAbstraction::FontClient::FindFallbackFont()
*/
- FontId FindFallbackFont( Character charcode,
- const FontDescription& preferredFontDescription,
- PointSize26Dot6 requestedPointSize,
- bool preferColor );
+ FontId FindFallbackFont(Character charcode,
+ const FontDescription& preferredFontDescription,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*/
- FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex );
+ FontId GetFontId(const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*/
- FontId GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex );
+ FontId GetFontId(const FontDescription& fontDescription,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontId( const BitmapFont& bitmapFont )
*/
- FontId GetFontId( const BitmapFont& bitmapFont );
+ FontId GetFontId(const BitmapFont& bitmapFont);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontPath& path )
*/
- bool IsScalable( const FontPath& path );
+ bool IsScalable(const FontPath& path);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontDescription& fontDescription )
*/
- bool IsScalable( const FontDescription& fontDescription );
+ bool IsScalable(const FontDescription& fontDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
*/
- void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes );
+ void GetFixedSizes(const FontPath& path, Dali::Vector<PointSize26Dot6>& sizes);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes()
*/
- void GetFixedSizes( const FontDescription& fontDescription,
- Dali::Vector< PointSize26Dot6 >& sizes );
+ void GetFixedSizes(const FontDescription& fontDescription,
+ Dali::Vector<PointSize26Dot6>& sizes);
/**
* @copydoc Dali::TextAbstraction::FontClient::HasItalicStyle()
*/
- bool HasItalicStyle( FontId fontId ) const;
+ bool HasItalicStyle(FontId fontId) const;
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontMetrics()
*/
- void GetFontMetrics( FontId fontId, FontMetrics& metrics );
+ void GetFontMetrics(FontId fontId, FontMetrics& metrics);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex()
*/
- GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
+ GlyphIndex GetGlyphIndex(FontId fontId, Character charcode);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetGlyphMetrics()
*/
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal );
+ bool GetGlyphMetrics(GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
*/
- void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth );
+ void CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
*/
- PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth );
+ PixelData CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateVectorBlob()
*/
- void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight );
+ void CreateVectorBlob(FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetEllipsisGlyph()
*/
- const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize );
+ const GlyphInfo& GetEllipsisGlyph(PointSize26Dot6 requestedPointSize);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsColorGlyph()
*/
- bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex );
+ bool IsColorGlyph(FontId fontId, GlyphIndex glyphIndex);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateEmbeddedItem()
*/
- GlyphIndex CreateEmbeddedItem( const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat );
+ GlyphIndex CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat);
/**
* @brief Retrieves the pointer to the FreeType Font Face for the given @p fontId.
*
* @return The pointer to the FreeType Font Face.
*/
- FT_FaceRec_* GetFreetypeFace( FontId fontId );
+ FT_FaceRec_* GetFreetypeFace(FontId fontId);
/**
* @brief Retrieves the type of font.
*
* @return FACE_FONT if the font has been loaded by FreeType, BITMAP_FONT if it's a font that has been loaded from images or INVALID if it's a non valid font.
*/
- FontDescription::Type GetFontType( FontId fontId );
+ FontDescription::Type GetFontType(FontId fontId);
/**
* @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory()
*/
- bool AddCustomFontDirectory( const FontPath& path );
+ bool AddCustomFontDirectory(const FontPath& path);
private:
-
/**
* Helper for lazy initialization.
*/
void CreatePlugin();
// Undefined copy constructor.
- FontClient( const FontClient& );
+ FontClient(const FontClient&);
// Undefined assignment constructor.
- FontClient& operator=( const FontClient& );
+ FontClient& operator=(const FontClient&);
private:
-
struct Plugin;
Plugin* mPlugin;
inline static Internal::FontClient& GetImplementation(FontClient& fontClient)
{
- DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
+ DALI_ASSERT_ALWAYS(fontClient && "fontClient handle is empty");
BaseObject& handle = fontClient.GetBaseObject();
return static_cast<Internal::FontClient&>(handle);
}
inline static const Internal::FontClient& GetImplementation(const FontClient& fontClient)
{
- DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" );
+ DALI_ASSERT_ALWAYS(fontClient && "fontClient handle is empty");
const BaseObject& handle = fontClient.GetBaseObject();
return static_cast<const Internal::FontClient&>(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.
// 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>
+#include <algorithm>
+#include <iterator>
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.weight = fontDescription.weight;
+ 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);
+ *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;
}
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H
/*
- * 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/adaptor-framework/pixel-buffer.h>
#include <dali/devel-api/text-abstraction/bitmap-font.h>
#include <dali/devel-api/text-abstraction/font-metrics.h>
#include <dali/devel-api/text-abstraction/glyph-info.h>
#include <dali/internal/text/text-abstraction/font-client-impl.h>
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
#include <third-party/glyphy/vector-font-cache.h>
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
/**
* @brief Type used for indices addressing the vector with front descriptions of validated fonts.
*/
*/
struct FallbackCacheItem
{
- FallbackCacheItem( FontDescription&& fontDescription, FontList* fallbackFonts, CharacterSetList* characterSets );
+ FallbackCacheItem(FontDescription&& fontDescription, FontList* fallbackFonts, CharacterSetList* characterSets);
- FontDescription fontDescription; ///< The font description.
- FontList* fallbackFonts; ///< The list of fallback fonts for the given font-description.
- CharacterSetList* characterSets; ///< The list of character sets for the given font-description.
+ FontDescription fontDescription; ///< The font description.
+ FontList* fallbackFonts; ///< The list of fallback fonts for the given font-description.
+ CharacterSetList* characterSets; ///< The list of character sets for the given font-description.
};
/**
*/
struct FontDescriptionCacheItem
{
- FontDescriptionCacheItem( const FontDescription& fontDescription,
- FontDescriptionId index );
- FontDescriptionCacheItem( FontDescription&& fontDescription,
- FontDescriptionId index );
+ FontDescriptionCacheItem(const FontDescription& fontDescription,
+ FontDescriptionId index);
+ FontDescriptionCacheItem(FontDescription&& fontDescription,
+ FontDescriptionId index);
- FontDescription fontDescription; ///< The font description.
- FontDescriptionId index; ///< Index to the vector of font descriptions.
+ FontDescription fontDescription; ///< The font description.
+ FontDescriptionId index; ///< Index to the vector of font descriptions.
};
/**
*/
struct FontDescriptionSizeCacheItem
{
- FontDescriptionSizeCacheItem( FontDescriptionId validatedFontId,
- PointSize26Dot6 requestedPointSize,
- FontId fontId );
+ FontDescriptionSizeCacheItem(FontDescriptionId validatedFontId,
+ PointSize26Dot6 requestedPointSize,
+ FontId fontId);
FontDescriptionId validatedFontId; ///< Index to the vector with font descriptions.
PointSize26Dot6 requestedPointSize; ///< The font point size.
*/
struct FontFaceCacheItem
{
- FontFaceCacheItem( FT_Face ftFace,
- const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex face,
- const FontMetrics& metrics );
-
- FontFaceCacheItem( FT_Face ftFace,
- const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex face,
- const FontMetrics& metrics,
- int fixedSizeIndex,
- float fixedWidth,
- float fixedHeight,
- bool hasColorTables );
-
- FT_Face mFreeTypeFace; ///< The FreeType face.
- FontPath mPath; ///< The path to the font file name.
- PointSize26Dot6 mRequestedPointSize; ///< The font point size.
- FaceIndex mFaceIndex; ///< The face index.
- FontMetrics mMetrics; ///< The font metrics.
- _FcCharSet* mCharacterSet; ///< Pointer with the range of characters.
- int mFixedSizeIndex; ///< Index to the fixed size table for the requested size.
- float mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
- float mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
- unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
- FontId mFontId; ///< Index to the vector with the cache of font's ids.
- bool mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps.
- bool mHasColorTables : 1; ///< Whether the font has color tables.
+ FontFaceCacheItem(FT_Face ftFace,
+ const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex face,
+ const FontMetrics& metrics);
+
+ FontFaceCacheItem(FT_Face ftFace,
+ const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex face,
+ const FontMetrics& metrics,
+ int fixedSizeIndex,
+ float fixedWidth,
+ float fixedHeight,
+ bool hasColorTables);
+
+ FT_Face mFreeTypeFace; ///< The FreeType face.
+ FontPath mPath; ///< The path to the font file name.
+ PointSize26Dot6 mRequestedPointSize; ///< The font point size.
+ FaceIndex mFaceIndex; ///< The face index.
+ FontMetrics mMetrics; ///< The font metrics.
+ _FcCharSet* mCharacterSet; ///< Pointer with the range of characters.
+ int mFixedSizeIndex; ///< Index to the fixed size table for the requested size.
+ float mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
+ float mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
+ unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
+ FontId mFontId; ///< Index to the vector with the cache of font's ids.
+ bool mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps.
+ bool mHasColorTables : 1; ///< Whether the font has color tables.
};
struct EllipsisItem
{
PointSize26Dot6 requestedPointSize;
- GlyphInfo glyph;
+ GlyphInfo glyph;
};
/**
struct PixelBufferCacheItem
{
Devel::PixelBuffer pixelBuffer; ///< The pixel buffer loaded from the url.
- std::string url; ///< The url.
+ std::string url; ///< The url.
};
/**
struct EmbeddedItem
{
PixelBufferId pixelBufferId; ///< Index to the vector of pixel buffers
- unsigned int width; ///< The desired width.
- unsigned int height; ///< The desired height.
+ unsigned int width; ///< The desired width.
+ unsigned int height; ///< The desired height.
};
/**
*/
struct BitmapFontCacheItem
{
- BitmapFont font; ///< The bitmap font.
+ BitmapFont font; ///< The bitmap font.
std::vector<Devel::PixelBuffer> pixelBuffers; ///< The pixel buffers of the glyphs.
- FontId id; ///< Index to the vector with the cache of font's ids.
+ FontId id; ///< Index to the vector with the cache of font's ids.
};
/**
* @param[in] horizontalDpi The horizontal dpi.
* @param[in] verticalDpi The vertical dpi.
*/
- Plugin( unsigned int horizontalDpi, unsigned int verticalDpi );
+ Plugin(unsigned int horizontalDpi, unsigned int verticalDpi);
/**
* Default destructor.
/**
* @copydoc Dali::TextAbstraction::FontClient::SetDpi()
*/
- void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
+ void SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi);
/**
* @copydoc Dali::TextAbstraction::FontClient::ResetSystemDefaults()
/**
* @copydoc Dali::TextAbstraction::FontClient::SetDefaultFont()
*/
- void SetDefaultFont( const FontDescription& preferredFontDescription );
+ void SetDefaultFont(const FontDescription& preferredFontDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDefaultPlatformFontDescription()
*/
- void GetDefaultPlatformFontDescription( FontDescription& fontDescription );
+ void GetDefaultPlatformFontDescription(FontDescription& fontDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDefaultFonts()
*/
- void GetDefaultFonts( FontList& defaultFonts );
+ void GetDefaultFonts(FontList& defaultFonts);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetSystemFonts()
*/
- void GetSystemFonts( FontList& systemFonts );
+ void GetSystemFonts(FontList& systemFonts);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetDescription()
*/
- void GetDescription( FontId id, FontDescription& fontDescription ) const;
+ void GetDescription(FontId id, FontDescription& fontDescription) const;
/**
* @copydoc Dali::TextAbstraction::FontClient::GetPointSize()
*/
- PointSize26Dot6 GetPointSize( FontId id );
+ PointSize26Dot6 GetPointSize(FontId id);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsCharacterSupportedByFont()
*/
- bool IsCharacterSupportedByFont( FontId fontId, Character character );
+ bool IsCharacterSupportedByFont(FontId fontId, Character character);
/**
* @brief Finds within the @p fontList a font which support the @p carcode.
*
* @return A valid font identifier, or zero if no font is found.
*/
- FontId FindFontForCharacter( const FontList& fontList,
- const CharacterSetList& characterSetList,
- Character charcode,
- PointSize26Dot6 requestedPointSize,
- bool preferColor );
+ FontId FindFontForCharacter(const FontList& fontList,
+ const CharacterSetList& characterSetList,
+ Character charcode,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor);
/**
* @copydoc Dali::TextAbstraction::FontClient::FindDefaultFont()
*/
- FontId FindDefaultFont( Character charcode,
- PointSize26Dot6 requestedPointSize,
- bool preferColor );
+ FontId FindDefaultFont(Character charcode,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor);
/**
* @copydoc Dali::TextAbstraction::FontClient::FindFallbackFont()
*/
- FontId FindFallbackFont( Character charcode,
- const FontDescription& preferredFontDescription,
- PointSize26Dot6 requestedPointSize,
- bool preferColor );
+ FontId FindFallbackFont(Character charcode,
+ const FontDescription& preferredFontDescription,
+ PointSize26Dot6 requestedPointSize,
+ bool preferColor);
/**
* @see Dali::TextAbstraction::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*
* @param[in] cacheDescription Whether to cache the font description.
*/
- FontId GetFontId( const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex,
- bool cacheDescription );
+ FontId GetFontId(const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex,
+ bool cacheDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& preferredFontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*/
- FontId GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex );
+ FontId GetFontId(const FontDescription& fontDescription,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontId( const BitmapFont& bitmapFont )
*/
- FontId GetFontId( const BitmapFont& bitmapFont );
+ FontId GetFontId(const BitmapFont& bitmapFont);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontPath& path )
*/
- bool IsScalable( const FontPath& path );
+ bool IsScalable(const FontPath& path);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontDescription& fontDescription )
*/
- bool IsScalable( const FontDescription& fontDescription );
+ bool IsScalable(const FontDescription& fontDescription);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes()
*/
- void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes );
+ void GetFixedSizes(const FontPath& path, Dali::Vector<PointSize26Dot6>& sizes);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes()
*/
- void GetFixedSizes( const FontDescription& fontDescription,
- Dali::Vector< PointSize26Dot6 >& sizes );
+ void GetFixedSizes(const FontDescription& fontDescription,
+ Dali::Vector<PointSize26Dot6>& sizes);
/**
* @copydoc Dali::TextAbstraction::FontClient::HasItalicStyle()
*/
- bool HasItalicStyle( FontId fontId ) const;
+ bool HasItalicStyle(FontId fontId) const;
/**
* @copydoc Dali::TextAbstraction::FontClient::GetFontMetrics()
*/
- void GetFontMetrics( FontId fontId, FontMetrics& metrics );
+ void GetFontMetrics(FontId fontId, FontMetrics& metrics);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex()
*/
- GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
+ GlyphIndex GetGlyphIndex(FontId fontId, Character charcode);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetGlyphMetrics()
*/
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal );
+ bool GetGlyphMetrics(GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal);
/**
* Helper for GetGlyphMetrics when using bitmaps
*/
- bool GetBitmapMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
+ bool GetBitmapMetrics(GlyphInfo* array, uint32_t size, bool horizontal);
/**
* Helper for GetGlyphMetrics when using vectors
*/
- bool GetVectorMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
+ bool GetVectorMetrics(GlyphInfo* array, uint32_t size, bool horizontal);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
*/
- void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth );
+ void CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
*/
- PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth );
+ PixelData CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateVectorBlob()
*/
- void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight );
+ void CreateVectorBlob(FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight);
/**
* @copydoc Dali::TextAbstraction::FontClient::GetEllipsisGlyph()
*/
- const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize );
+ const GlyphInfo& GetEllipsisGlyph(PointSize26Dot6 requestedPointSize);
/**
* @copydoc Dali::TextAbstraction::FontClient::IsColorGlyph()
*/
- bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex );
+ bool IsColorGlyph(FontId fontId, GlyphIndex glyphIndex);
/**
* @copydoc Dali::TextAbstraction::FontClient::CreateEmbeddedItem()
*/
- GlyphIndex CreateEmbeddedItem( const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat );
+ GlyphIndex CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat);
/**
* @copydoc Dali::TextAbstraction::Internal::FontClient::GetFreetypeFace()
*/
- FT_FaceRec_* GetFreetypeFace( FontId fontId );
+ FT_FaceRec_* GetFreetypeFace(FontId fontId);
/**
* @copydoc Dali::TextAbstraction::Internal::FontClient::GetFontType()
*/
- FontDescription::Type GetFontType( FontId fontId );
+ FontDescription::Type GetFontType(FontId fontId);
/**
* @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory()
*/
- bool AddCustomFontDirectory( const FontPath& path );
+ bool AddCustomFontDirectory(const FontPath& path);
private:
-
/**
* @brief Caches the fonts present in the platform.
*
* @param[out] characterSet The character set for that pattern.
* @return true if match found.
*/
- bool MatchFontDescriptionToPattern( _FcPattern* pattern, Dali::TextAbstraction::FontDescription& fontDescription, _FcCharSet** characterSet );
+ bool MatchFontDescriptionToPattern(_FcPattern* pattern, Dali::TextAbstraction::FontDescription& fontDescription, _FcCharSet** characterSet);
/**
* @brief Creates a font family pattern used to match fonts.
*
* @return The pattern.
*/
- _FcPattern* CreateFontFamilyPattern( const FontDescription& fontDescription ) const;
+ _FcPattern* CreateFontFamilyPattern(const FontDescription& fontDescription) const;
/**
* @brief Retrieves the fonts present in the platform.
*
* @return @e true if the operation is successful.
*/
- bool GetFcString( const _FcPattern* const pattern, const char* const n, std::string& string );
+ bool GetFcString(const _FcPattern* const pattern, const char* const n, std::string& string);
/**
* @brief Retrieves a font config object's value from a pattern.
*
* @return @e true if the operation is successful.
*/
- bool GetFcInt( const _FcPattern* const pattern, const char* const n, int& intVal );
+ bool GetFcInt(const _FcPattern* const pattern, const char* const n, int& intVal);
/**
* @brief Creates a font.
*
* @return The font identifier.
*/
- FontId CreateFont( const FontPath& path,
- PointSize26Dot6 requestedPointSize,
- FaceIndex faceIndex,
- bool cacheDescription );
+ FontId CreateFont(const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ FaceIndex faceIndex,
+ bool cacheDescription);
/**
* @brief Copy the color bitmap given in @p srcBuffer to @p data.
* @param[in] srcHeight The height of the bitmap.
* @param[in] srcBuffer The buffer of the bitmap.
*/
- void ConvertBitmap( TextAbstraction::FontClient::GlyphBufferData& data, unsigned int srcWidth, unsigned int srcHeight, const unsigned char* const srcBuffer );
+ void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, unsigned int srcWidth, unsigned int srcHeight, const unsigned char* const srcBuffer);
/**
* @brief Copy the FreeType bitmap to the given buffer.
* @param[in] srcBitmap The FreeType bitmap.
* @param[in] isShearRequired Whether the bitmap needs a shear transform (for software italics).
*/
- void ConvertBitmap( TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap srcBitmap, bool isShearRequired );
+ void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap srcBitmap, bool isShearRequired);
/**
* @brief Finds in the cache if there is a triplet with the path to the font file name, the font point size and the face index.
*
* @return @e true if there triplet is found.
*/
- bool FindFont( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex, FontId& fontId ) const;
+ bool FindFont(const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex, FontId& fontId) const;
/**
* @brief Finds in the cache a cluster 'font family, font width, font weight, font slant'
*
* @return @e true if the pair is found.
*/
- bool FindValidatedFont( const FontDescription& fontDescription,
- FontDescriptionId& validatedFontId );
+ bool FindValidatedFont(const FontDescription& fontDescription,
+ FontDescriptionId& validatedFontId);
/**
* @brief Finds a fallback font list from the cache for a given font-description
* @param[out] A valid pointer to a font list, or @e nullptr if not found.
* @param[out] characterSetList A valid pointer to a character set list, or @e nullptr if not found.
*/
- bool FindFallbackFontList( const FontDescription& fontDescription,
- FontList*& fontList,
- CharacterSetList*& characterSetList );
+ bool FindFallbackFontList(const FontDescription& fontDescription,
+ FontList*& fontList,
+ CharacterSetList*& characterSetList);
/**
* @brief Finds in the cache a pair 'validated font identifier and font point size'.
*
* @return @e true if the pair is found.
*/
- bool FindFont( FontDescriptionId validatedFontId,
- PointSize26Dot6 requestedPointSize,
- FontId& fontId );
+ bool FindFont(FontDescriptionId validatedFontId,
+ PointSize26Dot6 requestedPointSize,
+ FontId& fontId);
/**
* @brief Finds in the cache a bitmap font with the @p bitmapFont family name.
*
* @return Whether the font has been found.
*/
- bool FindBitmapFont( const FontFamily& bitmapFont, FontId& fontId ) const;
+ bool FindBitmapFont(const FontFamily& bitmapFont, FontId& fontId) const;
/**
* @brief Validate a font description.
* @param[in] fontDescription The font to validate.
* @param[out] validatedFontId Result of validation
*/
- void ValidateFont( const FontDescription& fontDescription,
- FontDescriptionId& validatedFontId );
+ void ValidateFont(const FontDescription& fontDescription,
+ FontDescriptionId& validatedFontId);
/**
* @brief Helper for GetDefaultFonts etc.
* @param[out] fontList A list of the fonts which are a close match for fontDescription.
* @param[out] characterSetList A list of character sets which are a close match for fontDescription.
*/
- void SetFontList( const FontDescription& fontDescription, FontList& fontList, CharacterSetList& characterSetList );
+ void SetFontList(const FontDescription& fontDescription, FontList& fontList, CharacterSetList& characterSetList);
/**
* Caches a font path.
* @param[in] requestedPointSize The font point size.
* @param[in] path Path to the font file name.
*/
- void CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path );
+ void CacheFontPath(FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path);
/**
* @brief Creates a character set from a given font's @p description.
*
* @return A character set.
*/
- _FcCharSet* CreateCharacterSetFromDescription( const FontDescription& description );
+ _FcCharSet* CreateCharacterSetFromDescription(const FontDescription& description);
/**
* @brief Free the resources allocated in the fallback cache.
*
* @param[in] fallbackCache The fallback cache.
*/
- void ClearFallbackCache( std::vector<FallbackCacheItem>& fallbackCache );
+ void ClearFallbackCache(std::vector<FallbackCacheItem>& fallbackCache);
/**
* @brief Free the resources allocated by the FcCharSet objects.
void ClearCharacterSetFromFontFaceCache();
private:
-
// Declared private and left undefined to avoid copies.
- Plugin( const Plugin& );
+ Plugin(const Plugin&);
// Declared private and left undefined to avoid copies.
- Plugin& operator=( const Plugin& );
+ Plugin& operator=(const Plugin&);
private:
-
FT_Library mFreeTypeLibrary; ///< A handle to a FreeType library instance.
unsigned int mDpiHorizontal; ///< Horizontal dpi.
FontDescription mDefaultFontDescription; ///< The cached default font from the system
- FontList mSystemFonts; ///< Cached system fonts.
- FontList mDefaultFonts; ///< Cached default fonts.
+ FontList mSystemFonts; ///< Cached system fonts.
+ FontList mDefaultFonts; ///< Cached default fonts.
CharacterSetList mDefaultFontCharacterSets;
std::vector<FallbackCacheItem> mFallbackCache; ///< Cached fallback font lists.
VectorFontCache* mVectorFontCache; ///< Separate cache for vector data blobs etc.
- Vector<EllipsisItem> mEllipsisCache; ///< Caches ellipsis glyphs for a particular point size.
- std::vector<PixelBufferCacheItem> mPixelBufferCache; ///< Caches the pixel buffer of a url.
- Vector<EmbeddedItem> mEmbeddedItemCache; ///< Cache embedded items.
- std::vector<BitmapFontCacheItem> mBitmapFontCache; ///< Stores bitmap fonts.
+ Vector<EllipsisItem> mEllipsisCache; ///< Caches ellipsis glyphs for a particular point size.
+ std::vector<PixelBufferCacheItem> mPixelBufferCache; ///< Caches the pixel buffer of a url.
+ Vector<EmbeddedItem> mEmbeddedItemCache; ///< Cache embedded items.
+ std::vector<BitmapFontCacheItem> mBitmapFontCache; ///< Stores bitmap fonts.
bool mDefaultFontDescriptionCached : 1; ///< Whether the default font is cached or not
};
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();
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_SEGMENTATION_IMPL_H
/*
- * 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
{
-
/**
* Implementation of the Segmentation
*/
class Segmentation : public BaseObject
{
public:
-
/**
* Constructor
*/
/**
* @copydoc Dali::Segmentation::GetLineBreakPositions()
*/
- void GetLineBreakPositions( const Character* const text,
- Length numberOfCharacters,
- LineBreakInfo* breakInfo );
-
+ void GetLineBreakPositions(const Character* const text,
+ Length numberOfCharacters,
+ LineBreakInfo* breakInfo);
/**
* @copydoc Dali::Segmentation::GetWordBreakPositions()
*/
- void GetWordBreakPositions( const Character* const text,
- Length numberOfCharacters,
- WordBreakInfo* breakInfo );
+ void GetWordBreakPositions(const Character* const text,
+ Length numberOfCharacters,
+ WordBreakInfo* breakInfo);
private:
-
/**
* Helper for lazy initialization.
*/
void CreatePlugin();
private:
-
// Undefined copy constructor.
- Segmentation( const Segmentation& );
+ Segmentation(const Segmentation&);
// Undefined assignment constructor.
- Segmentation& operator=( Segmentation& );
+ Segmentation& operator=(Segmentation&);
private:
-
struct Plugin;
Plugin* mPlugin;
} // namespace TextAbstraction
-inline static TextAbstraction::Internal::Segmentation& GetImplementation( TextAbstraction::Segmentation& segmentation )
+inline static TextAbstraction::Internal::Segmentation& GetImplementation(TextAbstraction::Segmentation& segmentation)
{
- DALI_ASSERT_ALWAYS( segmentation && "segmentation handle is empty" );
+ DALI_ASSERT_ALWAYS(segmentation && "segmentation handle is empty");
BaseObject& handle = segmentation.GetBaseObject();
- return static_cast<TextAbstraction::Internal::Segmentation&>( handle );
+ return static_cast<TextAbstraction::Internal::Segmentation&>(handle);
}
-inline static const TextAbstraction::Internal::Segmentation& GetImplementation( const TextAbstraction::Segmentation& segmentation )
+inline static const TextAbstraction::Internal::Segmentation& GetImplementation(const TextAbstraction::Segmentation& segmentation)
{
- DALI_ASSERT_ALWAYS( segmentation && "segmentation handle is empty" );
+ DALI_ASSERT_ALWAYS(segmentation && "segmentation handle is empty");
const BaseObject& handle = segmentation.GetBaseObject();
- return static_cast<const TextAbstraction::Internal::Segmentation&>( handle );
+ return static_cast<const TextAbstraction::Internal::Segmentation&>(handle);
}
} // 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 "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();
}
#define DALI_INTERNAL_TEXT_ABSTRACTION_SHAPING_IMPL_H
/*
- * 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/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
#include <dali/devel-api/text-abstraction/shaping.h>
+#include <dali/public-api/common/dali-vector.h>
namespace Dali
{
-
namespace TextAbstraction
{
-
namespace Internal
{
-
/**
* Implementation of the Shaping
*/
class Shaping : public BaseObject
{
public:
-
/**
* Constructor
*/
/**
* @copydoc Dali::Shaping::Shape()
*/
- Length Shape( const Character* const text,
- Length numberOfCharacters,
- FontId fontId,
- Script script );
+ Length Shape(const Character* const text,
+ Length numberOfCharacters,
+ FontId fontId,
+ Script script);
/**
* @copydoc Dali::Shaping::GetGlyphs()
*/
- void GetGlyphs( GlyphInfo* glyphInfo,
- CharacterIndex* glyphToCharacterMap );
+ void GetGlyphs(GlyphInfo* glyphInfo,
+ CharacterIndex* glyphToCharacterMap);
private:
-
/**
* Helper for lazy initialization.
*/
void CreatePlugin();
private:
-
// Undefined copy constructor.
- Shaping( const Shaping& );
+ Shaping(const Shaping&);
// Undefined assignment constructor.
- Shaping& operator=( const Shaping& );
+ Shaping& operator=(const Shaping&);
struct Plugin;
Plugin* mPlugin;
} // namespace TextAbstraction
-inline static TextAbstraction::Internal::Shaping& GetImplementation( TextAbstraction::Shaping& shaping )
+inline static TextAbstraction::Internal::Shaping& GetImplementation(TextAbstraction::Shaping& shaping)
{
- DALI_ASSERT_ALWAYS( shaping && "shaping handle is empty" );
+ DALI_ASSERT_ALWAYS(shaping && "shaping handle is empty");
BaseObject& handle = shaping.GetBaseObject();
- return static_cast<TextAbstraction::Internal::Shaping&>( handle );
+ return static_cast<TextAbstraction::Internal::Shaping&>(handle);
}
-inline static const TextAbstraction::Internal::Shaping& GetImplementation( const TextAbstraction::Shaping& shaping )
+inline static const TextAbstraction::Internal::Shaping& GetImplementation(const TextAbstraction::Shaping& shaping)
{
- DALI_ASSERT_ALWAYS( shaping && "shaping handle is empty" );
+ DALI_ASSERT_ALWAYS(shaping && "shaping handle is empty");
const BaseObject& handle = shaping.GetBaseObject();
- return static_cast<const TextAbstraction::Internal::Shaping&>( handle );
+ return static_cast<const TextAbstraction::Internal::Shaping&>(handle);
}
} // 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 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
{
#define DALI_INTERNAL_TEXT_ABSTRACTION_TEXT_RENDERER_IMPL_H
/*
- * 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
{
-
/**
* Implementation of the TextRenderer
*/
class TextRenderer : public BaseObject
{
public:
-
/**
* Constructor
*/
Devel::PixelBuffer Render(const TextAbstraction::TextRenderer::Parameters& parameters);
private:
-
// Undefined copy constructor.
TextRenderer(const TextRenderer&);
/*
- * 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());
}
}
#define DALI_INTERNAL_THREAD_SETTINGS_H
/*
- * 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 <string>
#include <sys/prctl.h>
+#include <string>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Implementation of the Thread Settings
*/
namespace ThreadSettings
{
-
/**
* @brief Set the thread 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.
*
*/
-#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);
}
}
#define DALI_INTERNAL_TRACE_MANAGER_IMPL_ANDROID_H
/*
- * 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 PerformanceInterface;
/**
* Explicit Constructor
*/
- explicit TraceManagerAndroid( PerformanceInterface* performanceInterface );
+ explicit TraceManagerAndroid(PerformanceInterface* performanceInterface);
protected:
/**
Dali::Integration::Trace::LogContextFunction GetLogContextFunction() final;
private:
-
/**
* LogContext method (Android specific) used for tracing
*/
- static void LogContext( bool start, const char* tag );
+ static void LogContext(bool start, const char* tag);
};
} // 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 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;
#define DALI_INTERNAL_TRACE_FACTORY_H
/*
- * 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
{
-
using TraceManagerUPtr = std::unique_ptr<TraceManager>;
// Factory function creating new TraceFactory
// Symbol exists but may be overriden during linking
-TraceManagerUPtr CreateTraceFactory( PerformanceInterface* performanceInterface );
+TraceManagerUPtr CreateTraceFactory(PerformanceInterface* 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.
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;
}
#define DALI_INTERNAL_TRACE_MANAGER_IMPL_H
/*
- * 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 INCLUDES
-
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
class PerformanceInterface;
class TraceManager
{
public:
-
/**
* Explicit Constructor
*/
- explicit TraceManager( PerformanceInterface* performanceInterface );
+ explicit TraceManager(PerformanceInterface* performanceInterface);
/**
* Constructor
PerformanceInterface* mPerformanceInterface;
protected:
-
/**
* Obtain the platform dependent LogContextFunction method used for tracing
*/
- virtual Dali::Integration::Trace::LogContextFunction GetLogContextFunction() { return nullptr; };
+ virtual Dali::Integration::Trace::LogContextFunction GetLogContextFunction()
+ {
+ return nullptr;
+ };
private:
-
/**
* Set / Install the platform dependent trace function
* @param logContextFunction - Platform dependent trace function
*/
- void SetTraceLogContextFunction( const Dali::Integration::Trace::LogContextFunction& logContextFunction );
+ void SetTraceLogContextFunction(const Dali::Integration::Trace::LogContextFunction& logContextFunction);
- TraceManager( const TraceManager& ) = delete;
- TraceManager& operator=( TraceManager& ) = delete;
+ TraceManager(const TraceManager&) = delete;
+ TraceManager& operator=(TraceManager&) = delete;
};
} // 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 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);
}
}
#define DALI_INTERNAL_TRACE_MANAGER_IMPL_GENERIC_H
/*
- * 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 PerformanceInterface;
/**
* Explicit Constructor
*/
- explicit TraceManagerGeneric( PerformanceInterface* performanceInterface );
+ explicit TraceManagerGeneric(PerformanceInterface* performanceInterface);
protected:
/**
Dali::Integration::Trace::LogContextFunction GetLogContextFunction() final;
private:
-
/**
* LogContext method (Generic specific) used for tracing
*/
- static void LogContext( bool start, const char* tag );
+ static void LogContext(bool start, const char* tag);
};
} // 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 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);
}
}
#define DALI_INTERNAL_TRACE_MANAGER_IMPL_TIZEN_H
/*
- * 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 PerformanceInterface;
/**
* Explicit Constructor
*/
- explicit TraceManagerTizen( PerformanceInterface* performanceInterface );
+ explicit TraceManagerTizen(PerformanceInterface* performanceInterface);
protected:
-
/**
* Destructor
*/
Dali::Integration::Trace::LogContextFunction GetLogContextFunction() final;
private:
-
/**
* LogContext method (Tizen specific) used for tracing
*/
- static void LogContext( bool start, const char* tag );
+ static void LogContext(bool start, const char* tag);
};
} // 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 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::Finalize()
{
- mPlugin.Initialize( url );
+ mPlugin.Finalize();
}
-void VectorAnimationRenderer::Finalize()
+bool VectorAnimationRenderer::Load(const std::string& url)
{
- mPlugin.Finalize();
+ return mPlugin.Load(url);
}
-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
#define DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_IMPL_H
/*
- * 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 VectorAnimationRenderer;
-using VectorAnimationRendererPtr = IntrusivePtr< VectorAnimationRenderer >;
+using VectorAnimationRendererPtr = IntrusivePtr<VectorAnimationRenderer>;
/**
* Dali internal VectorAnimationRenderer.
class VectorAnimationRenderer : public BaseObject, public ConnectionTracker
{
public:
-
/**
* @brief Creates a VectorAnimationRenderer object.
*
static VectorAnimationRendererPtr New();
/**
- * @brief Initializes member data.
+ * @copydoc Dali::VectorAnimationRenderer::Finalize()
*/
- void Initialize( const std::string& url );
+ void Finalize();
/**
- * @copydoc Dali::VectorAnimationRenderer::Finalize()
+ * @copydoc Dali::VectorAnimationRenderer::Load()
*/
- void Finalize();
+ bool Load(const std::string& url);
/**
* @copydoc Dali::VectorAnimationRenderer::SetRenderer()
*/
- void SetRenderer( Dali::Renderer renderer );
+ void SetRenderer(Dali::Renderer renderer);
/**
* @copydoc Dali::VectorAnimationRenderer::SetSize()
*/
- void SetSize( uint32_t width, uint32_t height );
+ void SetSize(uint32_t width, uint32_t height);
/**
* @copydoc Dali::VectorAnimationRenderer::Render()
*/
- bool Render( uint32_t frameNumber );
+ bool Render(uint32_t frameNumber);
/**
* @copydoc Dali::VectorAnimationRenderer::GetTotalFrameNumber()
/**
* @copydoc Dali::VectorAnimationRenderer::GetDefaultSize()
*/
- void GetDefaultSize( uint32_t& width, uint32_t& height ) const;
+ void GetDefaultSize(uint32_t& width, uint32_t& height) const;
/**
* @copydoc Dali::VectorAnimationRenderer::GetLayerInfo()
*/
- void GetLayerInfo( Property::Map& map ) const;
+ void GetLayerInfo(Property::Map& map) const;
/**
* @copydoc Dali::VectorAnimationRenderer::GetMarkerInfo()
*/
- bool GetMarkerInfo( const std::string& marker, uint32_t& startFrame, uint32_t& endFrame ) const;
+ bool GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const;
/**
* @copydoc Dali::VectorAnimationRenderer::IgnoreRenderedFrame()
Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal();
private:
-
/**
* @brief Constructor
*/
~VectorAnimationRenderer();
private:
-
- VectorAnimationRenderer( const VectorAnimationRenderer& ) = delete;
- VectorAnimationRenderer& operator=( VectorAnimationRenderer& ) = delete;
+ VectorAnimationRenderer(const VectorAnimationRenderer&) = delete;
+ VectorAnimationRenderer& operator=(VectorAnimationRenderer&) = delete;
private:
-
VectorAnimationRendererPluginProxy mPlugin;
};
} // namespace Internal
-inline static Internal::Adaptor::VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
+inline static Internal::Adaptor::VectorAnimationRenderer& GetImplementation(Dali::VectorAnimationRenderer& renderer)
{
- DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
+ DALI_ASSERT_ALWAYS(renderer && "VectorAnimationRenderer handle is empty.");
BaseObject& handle = renderer.GetBaseObject();
- return static_cast< Internal::Adaptor::VectorAnimationRenderer& >( handle );
+ return static_cast<Internal::Adaptor::VectorAnimationRenderer&>(handle);
}
-inline static const Internal::Adaptor::VectorAnimationRenderer& GetImplementation( const Dali::VectorAnimationRenderer& renderer )
+inline static const Internal::Adaptor::VectorAnimationRenderer& GetImplementation(const Dali::VectorAnimationRenderer& renderer)
{
- DALI_ASSERT_ALWAYS( renderer && "VectorAnimationRenderer handle is empty." );
+ DALI_ASSERT_ALWAYS(renderer && "VectorAnimationRenderer handle is empty.");
const BaseObject& handle = renderer.GetBaseObject();
- return static_cast< const Internal::Adaptor::VectorAnimationRenderer& >( handle );
+ return static_cast<const Internal::Adaptor::VectorAnimationRenderer&>(handle);
}
} // 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 )
+void VectorAnimationRendererPluginProxy::Finalize()
{
- if( mPlugin )
+ if(mPlugin)
{
- return mPlugin->Initialize( url );
+ mPlugin->Finalize();
}
- return false;
}
-void VectorAnimationRendererPluginProxy::Finalize()
+bool VectorAnimationRendererPluginProxy::Load(const std::string& url)
{
- if( mPlugin )
+ if(mPlugin)
{
- mPlugin->Finalize();
+ return mPlugin->Load(url);
}
+ return false;
}
-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();
}
#define DALI_INTERNAL_VECTOR_ANIMATION_RENDERER_PLUGIN_PROXY_H
/*
- * 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
{
-
/**
* Proxy class to dynamically load, use and unload vector animation renderer plugin.
*/
class VectorAnimationRendererPluginProxy
{
public:
-
/**
* @brief Constructor
*/
- VectorAnimationRendererPluginProxy( const std::string& sharedObjectName );
+ VectorAnimationRendererPluginProxy(const std::string& sharedObjectName);
/**
* @brief Destructor
~VectorAnimationRendererPluginProxy();
/**
- * @copydoc Dali::VectorAnimationRendererPlugin::Initialize()
+ * @copydoc Dali::VectorAnimationRendererPlugin::Finalize()
*/
- bool Initialize( const std::string& url );
+ void Finalize();
/**
- * @copydoc Dali::VectorAnimationRendererPlugin::Finalize()
+ * @copydoc Dali::VectorAnimationRendererPlugin::Load()
*/
- void Finalize();
+ bool Load(const std::string& url);
/**
* @copydoc Dali::VectorAnimationRendererPlugin::SetRenderer()
*/
- void SetRenderer( Dali::Renderer renderer );
+ void SetRenderer(Dali::Renderer renderer);
/**
* @copydoc Dali::VectorAnimationRendererPlugin::SetSize()
*/
- void SetSize( uint32_t width, uint32_t height );
+ void SetSize(uint32_t width, uint32_t height);
/**
* @copydoc Dali::VectorAnimationRendererPlugin::Render()
*/
- bool Render( uint32_t frameNumber );
+ bool Render(uint32_t frameNumber);
/**
* @copydoc Dali::VectorAnimationRendererPlugin::GetTotalFrameNumber()
/**
* @copydoc Dali::VectorAnimationRendererPlugin::GetDefaultSize()
*/
- void GetDefaultSize( uint32_t& width, uint32_t& height ) const;
+ void GetDefaultSize(uint32_t& width, uint32_t& height) const;
/**
* @copydoc Dali::VectorAnimationRendererPlugin::GetLayerInfo()
*/
- void GetLayerInfo( Property::Map& map ) const;
+ void GetLayerInfo(Property::Map& map) const;
/**
* @copydoc Dali::VectorAnimationRendererPlugin::GetMarkerInfo()
*/
- bool GetMarkerInfo( const std::string& marker, uint32_t& startFrame, uint32_t& endFrame ) const;
+ bool GetMarkerInfo(const std::string& marker, uint32_t& startFrame, uint32_t& endFrame) const;
/**
* @copydoc Dali::VectorAnimationRendererPlugin::IgnoreRenderedFrame()
VectorAnimationRendererPlugin::UploadCompletedSignalType& UploadCompletedSignal();
// Not copyable or movable
- VectorAnimationRendererPluginProxy( const VectorAnimationRendererPluginProxy& ) = delete; ///< Deleted copy constructor
- VectorAnimationRendererPluginProxy( VectorAnimationRendererPluginProxy&& ) = delete; ///< Deleted move constructor
- VectorAnimationRendererPluginProxy& operator=( const VectorAnimationRendererPluginProxy& ) = delete; ///< Deleted copy assignment operator
- VectorAnimationRendererPluginProxy& operator=( VectorAnimationRendererPluginProxy&& ) = delete; ///< Deleted move assignment operator
+ VectorAnimationRendererPluginProxy(const VectorAnimationRendererPluginProxy&) = delete; ///< Deleted copy constructor
+ VectorAnimationRendererPluginProxy(VectorAnimationRendererPluginProxy&&) = delete; ///< Deleted move constructor
+ VectorAnimationRendererPluginProxy& operator=(const VectorAnimationRendererPluginProxy&) = delete; ///< Deleted copy assignment operator
+ VectorAnimationRendererPluginProxy& operator=(VectorAnimationRendererPluginProxy&&) = delete; ///< Deleted move assignment operator
private:
-
/**
* Dynamically loads the plugin.
*/
void Initialize();
private:
-
using CreateVectorAnimationRendererFunction = Dali::VectorAnimationRendererPlugin* (*)();
- std::string mSharedObjectName; ///< Shared object name
- void* mLibHandle; ///< Handle for the loaded library
- Dali::VectorAnimationRendererPlugin* mPlugin; ///< Plugin handle
+ std::string mSharedObjectName; ///< Shared object name
+ void* mLibHandle; ///< Handle for the loaded library
+ Dali::VectorAnimationRendererPlugin* mPlugin; ///< Plugin handle
- CreateVectorAnimationRendererFunction mCreateVectorAnimationRendererPtr; ///< Function pointer called in adaptor to create a plugin instance
+ CreateVectorAnimationRendererFunction mCreateVectorAnimationRendererPtr; ///< Function pointer called in adaptor to create a plugin instance
VectorAnimationRendererPlugin::UploadCompletedSignalType mDefaultSignal;
-
};
} // 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
{
-
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())
{
#define DALI_INTERNAL_VECTOR_IMAGE_RENDERER_IMPL_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.
#include <dali/public-api/signals/connection-tracker.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/devel-api/adaptor-framework/vector-image-renderer.h>
#include <dali/internal/vector-image/common/vector-image-renderer-plugin-proxy.h>
-#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
struct NSVGrasterizer;
struct NSVGimage;
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
class VectorImageRenderer;
-using VectorImageRendererPtr = IntrusivePtr< VectorImageRenderer >;
+using VectorImageRendererPtr = IntrusivePtr<VectorImageRenderer>;
/**
* Dali internal VectorImageRenderer.
class VectorImageRenderer : public BaseObject
{
public:
-
/**
* @brief Creates a VectorImageRenderer object.
*
/**
* @copydoc Dali::VectorImageRenderer::GetDefaultSize()
*/
- void GetDefaultSize( uint32_t& width, uint32_t& height ) const;
+ void GetDefaultSize(uint32_t& width, uint32_t& height) const;
- VectorImageRenderer( const VectorImageRenderer& ) = delete;
- VectorImageRenderer& operator=( VectorImageRenderer& ) = delete;
- VectorImageRenderer( VectorImageRenderer&& ) = delete;
- VectorImageRenderer& operator=( VectorImageRenderer&& ) = delete;
+ VectorImageRenderer(const VectorImageRenderer&) = delete;
+ VectorImageRenderer& operator=(VectorImageRenderer&) = delete;
+ VectorImageRenderer(VectorImageRenderer&&) = delete;
+ VectorImageRenderer& operator=(VectorImageRenderer&&) = delete;
private:
-
/**
* @brief Constructor
*/
void Initialize();
private:
-
VectorImageRendererPluginProxy mPlugin;
NSVGimage* mParsedImage;
NSVGrasterizer* mRasterizer;
} // namespace Internal
-inline static Internal::Adaptor::VectorImageRenderer& GetImplementation( Dali::VectorImageRenderer& renderer )
+inline static Internal::Adaptor::VectorImageRenderer& GetImplementation(Dali::VectorImageRenderer& renderer)
{
- DALI_ASSERT_ALWAYS( renderer && "VectorImageRenderer handle is empty." );
+ DALI_ASSERT_ALWAYS(renderer && "VectorImageRenderer handle is empty.");
BaseObject& handle = renderer.GetBaseObject();
- return static_cast< Internal::Adaptor::VectorImageRenderer& >( handle );
+ return static_cast<Internal::Adaptor::VectorImageRenderer&>(handle);
}
-inline static const Internal::Adaptor::VectorImageRenderer& GetImplementation( const Dali::VectorImageRenderer& renderer )
+inline static const Internal::Adaptor::VectorImageRenderer& GetImplementation(const Dali::VectorImageRenderer& renderer)
{
- DALI_ASSERT_ALWAYS( renderer && "VectorImageRenderer handle is empty." );
+ DALI_ASSERT_ALWAYS(renderer && "VectorImageRenderer handle is empty.");
const BaseObject& handle = renderer.GetBaseObject();
- return static_cast< const Internal::Adaptor::VectorImageRenderer& >( handle );
+ return static_cast<const Internal::Adaptor::VectorImageRenderer&>(handle);
}
} // 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/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);
}
}
#define DALI_INTERNAL_VECTOR_IMAGE_RENDERER_PLUGIN_PROXY_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.
*/
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/vector-image-renderer-plugin.h>
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/devel-api/adaptor-framework/vector-image-renderer-plugin.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Proxy class to dynamically load, use and unload vector image renderer plugin.
*/
class VectorImageRendererPluginProxy
{
public:
-
/**
* @brief Constructor
*/
- VectorImageRendererPluginProxy( std::string sharedObjectName );
+ VectorImageRendererPluginProxy(std::string sharedObjectName);
/**
* @brief Destructor
void GetDefaultSize(uint32_t& width, uint32_t& height) const;
// Not copyable or movable
- VectorImageRendererPluginProxy( const VectorImageRendererPluginProxy& ) = delete; ///< Deleted copy constructor
- VectorImageRendererPluginProxy( VectorImageRendererPluginProxy&& ) = delete; ///< Deleted move constructor
- VectorImageRendererPluginProxy& operator=( const VectorImageRendererPluginProxy& ) = delete; ///< Deleted copy assignment operator
- VectorImageRendererPluginProxy& operator=( VectorImageRendererPluginProxy&& ) = delete; ///< Deleted move assignment operator
+ VectorImageRendererPluginProxy(const VectorImageRendererPluginProxy&) = delete; ///< Deleted copy constructor
+ VectorImageRendererPluginProxy(VectorImageRendererPluginProxy&&) = delete; ///< Deleted move constructor
+ VectorImageRendererPluginProxy& operator=(const VectorImageRendererPluginProxy&) = delete; ///< Deleted copy assignment operator
+ VectorImageRendererPluginProxy& operator=(VectorImageRendererPluginProxy&&) = delete; ///< Deleted move assignment operator
private:
-
/**
* Dynamically loads the plugin.
*/
void InitializePlugin();
private:
-
using CreateVectorImageRendererFunction = Dali::VectorImageRendererPlugin* (*)();
- std::string mSharedObjectName; ///< Shared object name
- void* mLibHandle; ///< Handle for the loaded library
- Dali::VectorImageRendererPlugin* mPlugin; ///< Plugin handle
-
- CreateVectorImageRendererFunction mCreateVectorImageRendererPtr; ///< Function pointer called in adaptor to create a plugin instance
+ std::string mSharedObjectName; ///< Shared object name
+ void* mLibHandle; ///< Handle for the loaded library
+ Dali::VectorImageRendererPlugin* mPlugin; ///< Plugin handle
+ CreateVectorImageRendererFunction mCreateVectorImageRendererPtr; ///< Function pointer called in adaptor to create a plugin instance
};
} // namespace Adaptor
/*
- * 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
#define DALI_VIDEO_PLAYER_IMPL_H
/*
- * 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/public-api/object/base-object.h>
#include <dali/devel-api/adaptor-framework/video-sync-mode.h>
+#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/video-player.h>
#include <dali/devel-api/adaptor-framework/video-player-plugin.h>
+#include <dali/devel-api/adaptor-framework/video-player.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
class VideoPlayer;
-typedef IntrusivePtr< VideoPlayer > VideoPlayerPtr;
+typedef IntrusivePtr<VideoPlayer> VideoPlayerPtr;
/**
* @brief VideoPlayer class is used for video playback.
* @SINCE_1_1.24
*/
-class VideoPlayer: public Dali::BaseObject
+class VideoPlayer : public Dali::BaseObject
{
public:
-
/**
* @brief Creates a new VideoPlayer handle
* @SINCE_1_1.24
/**
* @copydoc Dali::VideoPlayer::SetUrl()
*/
- void SetUrl( const std::string& url );
+ void SetUrl(const std::string& url);
/**
* @copydoc Dali::VideoPlayer::GetUrl()
/**
* @copydoc Dali::VideoPlayer::SetMute()
*/
- void SetMute( bool mute );
+ void SetMute(bool mute);
/**
* @copydoc Dali::VideoPlayer::IsMuted()
/**
* @copydoc Dali::VideoPlayer::SetVolume()
*/
- void SetVolume( float left, float right );
+ void SetVolume(float left, float right);
/**
* @copydoc Dali::VideoPlayer::GetVolume()
*/
- void GetVolume( float& left, float& right );
+ void GetVolume(float& left, float& right);
/**
* @copydoc Dali::VideoPlayer::SetRenderingTarget()
*/
- void SetRenderingTarget( Dali::Any target );
+ void SetRenderingTarget(Dali::Any target);
/**
* @copydoc Dali::VideoPlayer::SetPlayPosition()
*/
- void SetPlayPosition( int millisecond );
+ void SetPlayPosition(int millisecond);
/**
* @copydoc Dali::VideoPlayer::GetPlayPosition()
/**
* @copydoc Dali::VideoPlayer::SetDisplayArea()
*/
- void SetDisplayArea( DisplayArea area );
+ void SetDisplayArea(DisplayArea area);
/**
* @copydoc Dali::VideoPlayer::SetSetDisplayRotation()
*/
- void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation );
+ void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
/**
* @copydoc Dali::VideoPlayer::GetDisplayRotation()
/**
* @brief Initializes member data.
*/
- void Initialize( Dali::Actor actor, VideoSyncMode syncMode );
+ void Initialize(Dali::Actor actor, VideoSyncMode syncMode);
/**
* @brief Dali::VideoPlayer::Forward()
*/
- void Forward( int millisecond );
+ void Forward(int millisecond);
/**
* @brief Dali::VideoPlayer::Backward()
*/
- void Backward( int millisecond );
+ void Backward(int millisecond);
/**
* @brief Dali::VideoPlayer::IsVideoTextureSupported()
/**
* @brief Dali::VideoPlayer::SetCodecType()
*/
- void SetCodecType( Dali::VideoPlayerPlugin::CodecType type );
+ void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
/**
* @brief Dali::VideoPlayer::GetCodecType()
/**
* @copydoc Dali::VideoPlayer::SetDisplayMode()
*/
- void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode );
+ void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
/**
* @brief Dali::VideoPlayer::GetDisplayMode()
void FinishSynchronization();
private:
-
/**
* @brief Constructor.
* @SINCE_1_1.24
virtual ~VideoPlayer();
// Undefined copy constructor
- VideoPlayer( const VideoPlayer& player );
+ VideoPlayer(const VideoPlayer& player);
// Undefined assignment operator
- VideoPlayer& operator=( const VideoPlayer& player );
+ VideoPlayer& operator=(const VideoPlayer& player);
private:
-
Dali::VideoPlayerPlugin* mPlugin; ///< Videoplayer plugin handle
- void* mHandle; ///< Handle for the loaded library
+ void* mHandle; ///< Handle for the loaded library
- typedef Dali::VideoPlayerPlugin* (*CreateVideoPlayerFunction)( Dali::Actor actor, Dali::VideoSyncMode syncMode );
- typedef void (*DestroyVideoPlayerFunction)( Dali::VideoPlayerPlugin* plugin );
+ typedef Dali::VideoPlayerPlugin* (*CreateVideoPlayerFunction)(Dali::Actor actor, Dali::VideoSyncMode syncMode);
+ typedef void (*DestroyVideoPlayerFunction)(Dali::VideoPlayerPlugin* plugin);
- CreateVideoPlayerFunction mCreateVideoPlayerPtr;
+ CreateVideoPlayerFunction mCreateVideoPlayerPtr;
DestroyVideoPlayerFunction mDestroyVideoPlayerPtr;
Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
} // namespace Adaptor
} // namespace Internal
-inline static Internal::Adaptor::VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
+inline static Internal::Adaptor::VideoPlayer& GetImplementation(Dali::VideoPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "VideoPlayer handle is empty." );
+ DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty.");
BaseObject& handle = player.GetBaseObject();
- return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
+ return static_cast<Internal::Adaptor::VideoPlayer&>(handle);
}
-inline static const Internal::Adaptor::VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
+inline static const Internal::Adaptor::VideoPlayer& GetImplementation(const Dali::VideoPlayer& player)
{
- DALI_ASSERT_ALWAYS( player && "VideoPlayer handle is empty." );
+ DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty.");
const BaseObject& handle = player.GetBaseObject();
- return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
+ return static_cast<const Internal::Adaptor::VideoPlayer&>(handle);
}
-} // namespace Dali;
+} // namespace Dali
#endif // DALI_VIDEO_PLAYER_IMPL_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.
#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
#include <dali/devel-api/adaptor-framework/environment-variable.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
#include <dali/internal/system/common/environment-variables.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/images/pixel-data.h>
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);
+}
+
+void WebEngine::Create(int width, int height, int argc, char** argv)
{
- mPlugin->Create( width, height, locale, timezoneId );
+ mPlugin->Create(width, height, argc, argv);
}
void WebEngine::Destroy()
return mPlugin->GetNativeImageSource();
}
+Dali::WebEngineSettings& WebEngine::GetSettings() const
+{
+ return mPlugin->GetSettings();
+}
+
+Dali::WebEngineContext& WebEngine::GetContext() const
+{
+ return mPlugin->GetContext();
+}
+
+Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
+{
+ return mPlugin->GetCookieManager();
+}
+
+Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
+{
+ return mPlugin->GetBackForwardList();
+}
+
void WebEngine::LoadUrl( const std::string& url )
{
- mPlugin->LoadUrl( url );
+ mPlugin->LoadUrl(url);
+}
+
+std::string WebEngine::GetTitle() const
+{
+ return mPlugin->GetTitle();
+}
+
+Dali::PixelData WebEngine::GetFavicon() const
+{
+ return mPlugin->GetFavicon();
}
const std::string& WebEngine::GetUrl()
return mPlugin->GetUrl();
}
-void WebEngine::LoadHTMLString( const std::string& htmlString )
+const std::string& WebEngine::GetUserAgent() const
+{
+ return mPlugin->GetUserAgent();
+}
+
+void WebEngine::SetUserAgent(const std::string& userAgent)
{
- mPlugin->LoadHTMLString( htmlString );
+ mPlugin->SetUserAgent(userAgent);
+}
+
+void WebEngine::LoadHtmlString(const std::string& htmlString)
+{
+ mPlugin->LoadHtmlString(htmlString);
}
void WebEngine::Reload()
mPlugin->Resume();
}
-bool WebEngine::CanGoForward()
+void WebEngine::ScrollBy(int deltaX, int deltaY)
{
- return mPlugin->CanGoForward();
+ mPlugin->ScrollBy(deltaX, deltaY);
}
-void WebEngine::GoForward()
+void WebEngine::SetScrollPosition(int x, int y)
{
- mPlugin->GoForward();
+ mPlugin->SetScrollPosition(x, y);
}
-bool WebEngine::CanGoBack()
+Dali::Vector2 WebEngine::GetScrollPosition() const
{
- return mPlugin->CanGoBack();
+ return mPlugin->GetScrollPosition();
}
-void WebEngine::GoBack()
+Dali::Vector2 WebEngine::GetScrollSize() const
{
- mPlugin->GoBack();
+ return mPlugin->GetScrollSize();
}
-void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler )
+Dali::Vector2 WebEngine::GetContentSize() const
{
- mPlugin->EvaluateJavaScript( script, resultHandler );
+ return mPlugin->GetContentSize();
}
-void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler )
+void WebEngine::RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback )
{
- mPlugin->AddJavaScriptMessageHandler( exposedObjectName, handler );
+ mPlugin->RegisterJavaScriptAlertCallback( callback );
}
-void WebEngine::ClearHistory()
+void WebEngine::JavaScriptAlertReply()
{
- mPlugin->ClearHistory();
+ mPlugin->JavaScriptAlertReply();
}
-void WebEngine::ClearCache()
+void WebEngine::RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback )
{
- mPlugin->ClearCache();
+ mPlugin->RegisterJavaScriptAlertCallback( callback );
}
-void WebEngine::ClearCookies()
+void WebEngine::JavaScriptConfirmReply( bool confirmed )
{
- mPlugin->ClearCookies();
+ mPlugin->JavaScriptConfirmReply( confirmed );
}
-Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const
+void WebEngine::RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback )
{
- return mPlugin->GetCacheModel();
+ mPlugin->RegisterJavaScriptPromptCallback( callback );
}
-void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
+void WebEngine::JavaScriptPromptReply( const std::string& result )
{
- mPlugin->SetCacheModel( cacheModel );
+ mPlugin->JavaScriptPromptReply( result );
}
-Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const
+bool WebEngine::CanGoForward()
{
- return mPlugin->GetCookieAcceptPolicy();
+ return mPlugin->CanGoForward();
}
-void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
+void WebEngine::GoForward()
{
- mPlugin->SetCookieAcceptPolicy( policy );
+ mPlugin->GoForward();
}
-const std::string& WebEngine::GetUserAgent() const
+bool WebEngine::CanGoBack()
{
- return mPlugin->GetUserAgent();
+ return mPlugin->CanGoBack();
}
-void WebEngine::SetUserAgent( const std::string& userAgent )
+void WebEngine::GoBack()
{
- mPlugin->SetUserAgent( userAgent );
+ mPlugin->GoBack();
}
-bool WebEngine::IsJavaScriptEnabled() const
+void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
{
- return mPlugin->IsJavaScriptEnabled();
+ mPlugin->EvaluateJavaScript(script, resultHandler);
}
-void WebEngine::EnableJavaScript( bool enabled )
+void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
{
- mPlugin->EnableJavaScript( enabled );
+ mPlugin->AddJavaScriptMessageHandler(exposedObjectName, handler);
}
-bool WebEngine::AreImagesAutomaticallyLoaded() const
+void WebEngine::ClearAllTilesResources()
{
- return mPlugin->AreImagesAutomaticallyLoaded();
+ mPlugin->ClearAllTilesResources();
}
-void WebEngine::LoadImagesAutomatically( bool automatic )
+void WebEngine::ClearHistory()
{
- mPlugin->LoadImagesAutomatically( automatic );
+ mPlugin->ClearHistory();
}
-const std::string& WebEngine::GetDefaultTextEncodingName() const
+void WebEngine::SetSize(int width, int height)
{
- return mPlugin->GetDefaultTextEncodingName();
+ mPlugin->SetSize(width, height);
}
-void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+bool WebEngine::SendTouchEvent(const Dali::TouchEvent& touch)
{
- mPlugin->SetDefaultTextEncodingName( defaultTextEncodingName );
+ return mPlugin->SendTouchEvent(touch);
}
-int WebEngine::GetDefaultFontSize() const
+bool WebEngine::SendKeyEvent(const Dali::KeyEvent& event)
{
- return mPlugin->GetDefaultFontSize();
+ return mPlugin->SendKeyEvent(event);
}
-void WebEngine::SetDefaultFontSize( int defaultFontSize )
+void WebEngine::SetFocus(bool focused)
{
- mPlugin->SetDefaultFontSize( defaultFontSize );
+ mPlugin->SetFocus(focused);
}
-void WebEngine::SetSize( int width, int height )
+void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
{
- mPlugin->SetSize( width, height );
+ mPlugin->UpdateDisplayArea(displayArea);
}
-bool WebEngine::SendTouchEvent( const Dali::TouchEvent& touch )
+void WebEngine::EnableVideoHole(bool enabled)
{
- return mPlugin->SendTouchEvent( touch );
+ mPlugin->EnableVideoHole(enabled);
}
-bool WebEngine::SendKeyEvent( const Dali::KeyEvent& event )
+Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
{
- return mPlugin->SendKeyEvent( event );
+ return mPlugin->PageLoadStartedSignal();
}
-Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
+Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
{
- return mPlugin->PageLoadStartedSignal();
+ return mPlugin->PageLoadInProgressSignal();
}
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
return mPlugin->PageLoadErrorSignal();
}
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+ return mPlugin->ScrollEdgeReachedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
+{
+ return mPlugin->UrlChangedSignal();
+}
+
} // namespace Adaptor;
} // namespace Internal;
} // namespace Dali;
#define DALI_WEB_ENGINE_IMPL_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.
#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/web-engine.h>
#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
+#include <dali/devel-api/adaptor-framework/web-engine.h>
namespace Dali
{
+// forward declaration
+class WebEngineBackForwardList;
+class WebEngineContext;
+class WebEngineCookieManager;
+class WebEngineSettings;
namespace Internal
{
-
namespace Adaptor
{
-
class WebEngine;
-typedef IntrusivePtr< WebEngine > WebEnginePtr;
+typedef IntrusivePtr<WebEngine> WebEnginePtr;
/**
* @brief WebEngine class is used for Web.
class WebEngine : public Dali::BaseObject
{
public:
-
/**
* @brief Creates a new WebEngine handle
*
/**
* @copydoc Dali::WebEngine::Create()
*/
- void Create( int width, int height, const std::string& locale, const std::string& timezoneId );
+ void Create(int width, int height, const std::string& locale, const std::string& timezoneId);
+
+ /**
+ * @copydoc Dali::WebEngine::Create()
+ */
+ void Create(int width, int height, int argc, char** argv);
/**
* @copydoc Dali::WebEngine::Destroy()
Dali::NativeImageInterfacePtr GetNativeImageSource();
/**
+ * @copydoc Dali::WebEngine::GetSettings()
+ */
+ Dali::WebEngineSettings& GetSettings() const;
+
+ /**
+ * @copydoc Dali::WebEngine::GetContext()
+ */
+ Dali::WebEngineContext& GetContext() const;
+
+ /**
+ * @copydoc Dali::WebEngine::GetCookieManager()
+ */
+ Dali::WebEngineCookieManager& GetCookieManager() const;
+
+ /**
+ * @copydoc Dali::WebEngine::GetBackForwardList()
+ */
+ Dali::WebEngineBackForwardList& GetBackForwardList() const;
+
+ /**
* @copydoc Dali::WebEngine::LoadUrl()
*/
- void LoadUrl( const std::string& url );
+ void LoadUrl(const std::string& url);
+
+ /**
+ * @copydoc Dali::WebEngine::GetTitle()
+ */
+ std::string GetTitle() const;
+
+ /**
+ * @copydoc Dali::WebEngine::GetFavicon()
+ */
+ Dali::PixelData GetFavicon() const;
/**
* @copydoc Dali::WebEngine::GetUrl()
const std::string& GetUrl();
/**
- * @copydoc Dali::WebEngine::LoadHTMLString()
+ * @copydoc Dali::WebEngine::GetUserAgent()
*/
- void LoadHTMLString( const std::string& htmlString );
+ const std::string& GetUserAgent() const;
+
+ /**
+ * @copydoc Dali::WebEngine::SetUserAgent()
+ */
+ void SetUserAgent(const std::string& userAgent);
+
+ /**
+ * @copydoc Dali::WebEngine::LoadHtmlString()
+ */
+ void LoadHtmlString(const std::string& htmlString);
/**
* @copydoc Dali::WebEngine::Reload()
void Resume();
/**
- * @copydoc Dali::WebEngine::CanGoForward()
+ * @copydoc Dali::WebEngine::ScrollBy()
*/
- bool CanGoForward();
+ void ScrollBy(int deltaX, int deltaY);
/**
- * @copydoc Dali::WebEngine::GoForward()
+ * @copydoc Dali::WebEngine::SetScrollPosition()
*/
- void GoForward();
+ void SetScrollPosition(int x, int y);
/**
- * @copydoc Dali::WebEngine::CanGoBack()
+ * @copydoc Dali::WebEngine::GetScrollPosition()
*/
- bool CanGoBack();
+ Dali::Vector2 GetScrollPosition() const;
/**
- * @copydoc Dali::WebEngine::GoBack()
+ * @copydoc Dali::WebEngine::GetScrollSize()
*/
- void GoBack();
+ Dali::Vector2 GetScrollSize() const;
/**
- * @copydoc Dali::WebEngine::EvaluateJavaScript()
+ * @copydoc Dali::WebEngine::GetContentSize()
*/
- void EvaluateJavaScript( const std::string& script, std::function< void(const std::string&) > resultHandler );
+ Dali::Vector2 GetContentSize() const;
/**
- * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler()
- */
- void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler );
+ * @copydoc Dali::WebEngine::RegisterJavaScriptAlertCallback()
+ */
+ void RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback );
/**
- * @copydoc Dali::WebEngine::ClearHistory()
+ * @copydoc Dali::WebEngine::JavaScriptAlertReply()
*/
- void ClearHistory();
+ void JavaScriptAlertReply();
/**
- * @copydoc Dali::WebEngine::ClearCache()
+ * @copydoc Dali::WebEngine::RegisterJavaScriptConfirmCallback()
*/
- void ClearCache();
+ void RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback );
/**
- * @copydoc Dali::WebEngine::ClearCookies()
+ * @copydoc Dali::WebEngine::JavaScriptConfirmReply()
*/
- void ClearCookies();
+ void JavaScriptConfirmReply( bool confirmed );
/**
- * @copydoc Dali::WebEngine::GetCacheModel()
+ * @copydoc Dali::WebEngine::RegisterJavaScriptPromptCallback()
*/
- Dali::WebEnginePlugin::CacheModel GetCacheModel() const;
+ void RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback );
/**
- * @copydoc Dali::WebEngine::SetCacheModel()
+ * @copydoc Dali::WebEngine::JavaScriptPromptReply()
*/
- void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel );
+ void JavaScriptPromptReply( const std::string& result );
/**
- * @copydoc Dali::WebEngine::GetCookieAcceptPolicy()
+ * @copydoc Dali::WebEngine::CanGoForward()
*/
- Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const;
+ bool CanGoForward();
/**
- * @copydoc Dali::WebEngine::SetCookieAcceptPolicy()
+ * @copydoc Dali::WebEngine::GoForward()
*/
- void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy );
+ void GoForward();
/**
- * @copydoc Dali::WebEngine::GetUserAgent()
+ * @copydoc Dali::WebEngine::CanGoBack()
*/
- const std::string& GetUserAgent() const;
+ bool CanGoBack();
/**
- * @copydoc Dali::WebEngine::SetUserAgent()
+ * @copydoc Dali::WebEngine::GoBack()
*/
- void SetUserAgent( const std::string& userAgent );
+ void GoBack();
/**
- * @copydoc Dali::WebEngine::IsJavaScriptEnabled()
+ * @copydoc Dali::WebEngine::EvaluateJavaScript()
*/
- bool IsJavaScriptEnabled() const;
+ void EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler);
/**
- * @copydoc Dali::WebEngine::EnableJavaScript()
+ * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler()
*/
- void EnableJavaScript( bool enabled );
+ void AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler);
/**
- * @copydoc Dali::WebEngine::AreImagesAutomaticallyLoaded()
+ * @copydoc Dali::WebEngine::ClearAllTilesResources()
*/
- bool AreImagesAutomaticallyLoaded() const;
+ void ClearAllTilesResources();
/**
- * @copydoc Dali::WebEngine::LoadImagesAutomatically()
+ * @copydoc Dali::WebEngine::ClearHistory()
*/
- void LoadImagesAutomatically( bool automatic );
+ void ClearHistory();
/**
- * @copydoc Dali::WebEngine::GetDefaultTextEncodingName()
+ * @copydoc Dali::WebEngine::SetSize()
*/
- const std::string& GetDefaultTextEncodingName() const;
+ void SetSize(int width, int height);
/**
- * @copydoc Dali::WebEngine::SetDefaultTextEncodingName()
+ * @copydoc Dali::WebEngine::SendTouchEvent()
*/
- void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+ bool SendTouchEvent(const Dali::TouchEvent& touch);
/**
- * @copydoc Dali::WebEngine::GetDefaultFontSize()
+ * @copydoc Dali::WebEngine::SendKeyEvent()
*/
- int GetDefaultFontSize() const;
+ bool SendKeyEvent(const Dali::KeyEvent& event);
/**
- * @copydoc Dali::WebEngine::SetDefaultFontSize()
+ * @copydoc Dali::WebEngine::SetFocus()
*/
- void SetDefaultFontSize( int defaultFontSize );
+ void SetFocus(bool focused);
/**
- * @copydoc Dali::WebEngine::SetSize()
+ * @copydoc Dali::WebEngine::UpdateDisplayArea()
*/
- void SetSize( int width, int height );
+ void UpdateDisplayArea(Dali::Rect<int> displayArea);
/**
- * @copydoc Dali::WebEngine::SendTouchEvent()
+ * @copydoc Dali::WebEngine::EnableVideoHole()
*/
- bool SendTouchEvent( const Dali::TouchEvent& touch );
+ void EnableVideoHole(bool enabled);
/**
- * @copydoc Dali::WebEngine::SendKeyEvent()
+ * @copydoc Dali::WebEngine::PageLoadStartedSignal()
*/
- bool SendKeyEvent( const Dali::KeyEvent& event );
+ Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
/**
- * @copydoc Dali::WebEngine::PageLoadStartedSignal()
+ * @copydoc Dali::WebEngine::PageLoadProgressSignal()
*/
- Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal();
+ Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadInProgressSignal();
/**
* @copydoc Dali::WebEngine::PageLoadFinishedSignal()
*/
Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal();
-private:
+ /**
+ * @copydoc Dali::WebEngine::ScrollEdgeReachedSignal()
+ */
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
+ /**
+ * @copydoc Dali::WebEngine::UrlChangedSignal()
+ */
+ Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& UrlChangedSignal();
+private:
/**
* @brief Constructor.
*/
virtual ~WebEngine();
// Undefined copy constructor
- WebEngine( const WebEngine& WebEngine );
+ WebEngine(const WebEngine& WebEngine);
// Undefined assignment operator
- WebEngine& operator=( const WebEngine& WebEngine );
+ WebEngine& operator=(const WebEngine& WebEngine);
/**
* @brief Initializes member data.
bool InitializePluginHandle();
private:
-
typedef Dali::WebEnginePlugin* (*CreateWebEngineFunction)();
- typedef void (*DestroyWebEngineFunction)( Dali::WebEnginePlugin* plugin );
+ typedef void (*DestroyWebEngineFunction)(Dali::WebEnginePlugin* plugin);
- Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance
- void* mHandle; ///< Handle for the loaded library
- CreateWebEngineFunction mCreateWebEnginePtr; ///< Function to create plugin instance
- DestroyWebEngineFunction mDestroyWebEnginePtr; ///< Function to destroy plugin instance
+ Dali::WebEnginePlugin* mPlugin; ///< WebEnginePlugin instance
+ void* mHandle; ///< Handle for the loaded library
+ CreateWebEngineFunction mCreateWebEnginePtr; ///< Function to create plugin instance
+ DestroyWebEngineFunction mDestroyWebEnginePtr; ///< Function to destroy plugin instance
};
} // namespace Adaptor
} // namespace Internal
-inline static Internal::Adaptor::WebEngine& GetImplementation( Dali::WebEngine& webEngine )
+inline static Internal::Adaptor::WebEngine& GetImplementation(Dali::WebEngine& webEngine)
{
- DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+ DALI_ASSERT_ALWAYS(webEngine && "WebEngine handle is empty.");
BaseObject& handle = webEngine.GetBaseObject();
- return static_cast< Internal::Adaptor::WebEngine& >( handle );
+ return static_cast<Internal::Adaptor::WebEngine&>(handle);
}
-inline static const Internal::Adaptor::WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
+inline static const Internal::Adaptor::WebEngine& GetImplementation(const Dali::WebEngine& webEngine)
{
- DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+ DALI_ASSERT_ALWAYS(webEngine && "WebEngine handle is empty.");
const BaseObject& handle = webEngine.GetBaseObject();
- return static_cast< const Internal::Adaptor::WebEngine& >( handle );
+ return static_cast<const Internal::Adaptor::WebEngine&>(handle);
}
-} // namespace Dali;
+} // namespace Dali
#endif
-
/*
- * 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
#define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_DISPLAY_CONNECTION_FACTORY_ANDROID_H
/*
- * 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 DisplayConnectionFactoryAndroid : public DisplayConnectionFactory
{
public:
} // namespace Dali
-
#endif // DALI_INTERNAL_WINDOWSYSTEM_ANDROID_DISPLAY_CONNECTION_FACTORY_ANDROID_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.
*/
// 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;
}
#define DALI_INTERNAL_WINDOWSYSTEM_DISPLAY_CONNECTION_IMPL_ANDROID_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
{
-
class DisplayConnection;
namespace Internal
{
-
namespace Adaptor
{
-
/**
* DisplayConnection implementation
*/
class DisplayConnectionAndroid : public Dali::Internal::Adaptor::DisplayConnection
{
public:
-
/**
* @brief Default constructor
*/
static DisplayConnection* New();
public:
-
/**
* @copydoc Dali::DisplayConnection::GetDisplay
*/
* @brief Sets the surface type
* @param[in] type The surface type
*/
- void SetSurfaceType( Dali::RenderSurfaceInterface::Type type );
+ void SetSurfaceType(Dali::RenderSurfaceInterface::Type type);
/**
* @brief Sets the graphics interface
* @param[in] graphics The graphics interface
*/
- void SetGraphicsInterface( GraphicsInterface& graphics );
+ void SetGraphicsInterface(GraphicsInterface& graphics);
public:
-
/**
* Destructor
*/
virtual ~DisplayConnectionAndroid();
protected:
-
// Undefined
DisplayConnectionAndroid(const DisplayConnectionAndroid&);
DisplayConnectionAndroid& operator=(const DisplayConnectionAndroid& rhs);
private:
- EGLNativeDisplayType mDisplay; ///< EGL display for rendering
- Dali::RenderSurfaceInterface::Type mSurfaceType; ///< The surface type
- GraphicsInterface* mGraphics; ///< The graphics interface
+ EGLNativeDisplayType mDisplay; ///< EGL display for rendering
+ Dali::RenderSurfaceInterface::Type mSurfaceType; ///< The surface type
+ GraphicsInterface* mGraphics; ///< The graphics interface
};
} // 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.
#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
#define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_RENDER_SURFACE_FACTORY_ANDROID_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 Adaptor
{
-
class RenderSurfaceFactoryAndroid : public RenderSurfaceFactory
{
public:
- std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) override;
};
} // 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
-
#define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_BASE_ANDROID_H
/*
- * 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
{
-
/**
* WindowBaseAndroid class provides an WindowBase Android implementation.
*/
class WindowBaseAndroid : public WindowBase
{
public:
-
/**
* @brief Constructor
*/
- WindowBaseAndroid( PositionSize positionSize, Any surface, bool isTransparent );
+ WindowBaseAndroid(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Destructor
virtual ~WindowBaseAndroid();
public:
-
/**
* @brief Called when the window property is changed.
*/
- bool OnWindowPropertyChanged( void* data, int type, void* event );
+ bool OnWindowPropertyChanged(void* data, int type, void* event);
/**
* @brief Called when the window receives a delete request
/**
* @brief Called when the window gains focus.
*/
- void OnFocusIn( void* data, int type, void* event );
+ void OnFocusIn(void* data, int type, void* event);
/**
* @brief Called when the window loses focus.
*/
- void OnFocusOut( void* data, int type, void* event );
+ void OnFocusOut(void* data, int type, void* event);
/**
* @brief Called when the window is damaged.
*/
- void OnWindowDamaged( void* data, int type, void* event );
+ void OnWindowDamaged(void* data, int type, void* event);
/**
* @brief Called when a touch down is received.
*/
- void OnMouseButtonDown( void* data, int type, void* event );
+ void OnMouseButtonDown(void* data, int type, void* event);
/**
* @brief Called when a touch up is received.
*/
- void OnMouseButtonUp( void* data, int type, void* event );
+ void OnMouseButtonUp(void* data, int type, void* event);
/**
* @brief Called when a touch motion is received.
*/
- void OnMouseButtonMove( void* data, int type, void* event );
+ void OnMouseButtonMove(void* data, int type, void* event);
/**
* @brief Called when a mouse wheel is received.
*/
- void OnMouseWheel( void* data, int type, void* event );
+ void OnMouseWheel(void* data, int type, void* event);
/**
* @brief Called when a key down is received.
*/
- void OnKeyDown( void* data, int type, void* event );
+ void OnKeyDown(void* data, int type, void* event);
/**
* @brief Called when a key up is received.
*/
- void OnKeyUp( void* data, int type, void* event );
+ void OnKeyUp(void* data, int type, void* event);
/**
* @brief Called when the source window notifies us the content in clipboard is selected.
*/
- void OnSelectionClear( void* data, int type, void* event );
+ void OnSelectionClear(void* data, int type, void* event);
/**
* @brief Called when the source window sends us about the selected content.
*/
- void OnSelectionNotify( void* data, int type, void* event );
+ void OnSelectionNotify(void* data, int type, void* event);
public:
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
*/
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
*/
- EGLNativeWindowType CreateEglWindow( int width, int height ) override;
+ EGLNativeWindowType CreateEglWindow(int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
*/
- void SetEglWindowRotation( int angle ) override;
+ void SetEglWindowRotation(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
*/
- void SetEglWindowBufferTransform( int angle ) override;
+ void SetEglWindowBufferTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
*/
- void SetEglWindowTransform( int angle ) override;
+ void SetEglWindowTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
*/
- void ResizeEglWindow( PositionSize positionSize ) override;
+ void ResizeEglWindow(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Move()
*/
- void Move( PositionSize positionSize ) override;
+ void Move(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
*/
- void Resize( PositionSize positionSize ) override;
+ void Resize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
*/
- void MoveResize( PositionSize positionSize ) override;
+ void MoveResize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
*/
- void SetClass( const std::string& name, const std::string& className ) override;
+ void SetClass(const std::string& name, const std::string& className) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
*/
- void SetAvailableAnlges( const std::vector< int >& angles ) override;
+ void SetAvailableAnlges(const std::vector<int>& angles) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
*/
- void SetPreferredAngle( int angle ) override;
+ void SetPreferredAngle(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
*/
- void SetAcceptFocus( bool accept ) override;
+ void SetAcceptFocus(bool accept) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Show()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id ) override;
+ bool RemoveAuxiliaryHint(unsigned int id) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+ std::string GetAuxiliaryHintValue(unsigned int id) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion ) override;
+ void SetInputRegion(const Rect<int>& inputRegion) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
*/
- void SetType( Dali::WindowType type ) override;
+ void SetType(Dali::WindowType type) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
*/
- bool SetNotificationLevel( Dali::WindowNotificationLevel level ) override;
+ bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque ) override;
+ void SetOpaqueState(bool opaque) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
*/
- bool SetBrightness( int brightness ) override;
+ bool SetBrightness(int brightness) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
*/
- bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
*/
- bool UngrabKey( Dali::KEY key ) override;
+ bool UngrabKey(Dali::KEY key) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
*/
- bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+ bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
*/
- bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+ bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
*/
- void SetWindowRotationAngle( int degree ) override;
+ void SetWindowRotationAngle(int degree) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
*/
- void WindowRotationCompleted( int degree, int width, int height ) override;
+ void WindowRotationCompleted(int degree, int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
*/
- void SetTransparency( bool transparent ) override;
+ void SetTransparency(bool transparent) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
*/
- void SetParent( WindowBase* parentWinBase ) override;
+ void SetParent(WindowBase* parentWinBase) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
int GetOrientation() const override;
private:
-
/**
* Second stage initialization
*/
- void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+ void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Get the surface id if the surface parameter is not empty
* @param surface Any containing a surface id, or can be empty
* @return surface id, or zero if surface is empty
*/
- unsigned int GetSurfaceId( Any surface ) const;
+ unsigned int GetSurfaceId(Any surface) const;
protected:
-
// Undefined
WindowBaseAndroid(const WindowBaseAndroid&) = delete;
WindowBaseAndroid& operator=(const WindowBaseAndroid& rhs) = delete;
private:
-
- ANativeWindow* mWindow; ///< Native window handle
- bool mOwnSurface:1; ///< Whether we own the surface (responsible for deleting it)
- bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
- bool mRotationAppSet:1;
+ ANativeWindow* mWindow; ///< Native window handle
+ bool mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
+ bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
+ bool mRotationAppSet : 1;
};
} // 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< 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
#define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_FACTORY_ANDROID_H
/*
- * 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
{
-
class WindowFactoryAndroid : public WindowFactory
{
public:
- std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override;
+ std::unique_ptr<WindowBase> CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent) override;
};
} // 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
-
#define DALI_INTERNAL_DAMAGE_OBSERVER_H
/*
- * 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
{
-
typedef Rect<int> DamageArea;
/**
class DamageObserver
{
public:
-
/**
* Deriving classes should override this to be notified when we receive a damage event.
* @param[in] area The area that has been damaged.
*/
- virtual void OnDamaged( const DamageArea& area ) = 0;
+ virtual void OnDamaged(const DamageArea& area) = 0;
protected:
-
/**
* Protected Constructor.
*/
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_DISPLAY_CONNECTION_FACTORY_H
/*
- * 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
{
-
class DisplayConnection;
class DisplayConnectionFactory
{
public:
-
- DisplayConnectionFactory() = default;
+ DisplayConnectionFactory() = default;
virtual ~DisplayConnectionFactory() = default;
virtual std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> CreateDisplayConnection() = 0;
-
};
extern std::unique_ptr<DisplayConnectionFactory> GetDisplayConnectionFactory();
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_DISPLAY_CONNECTION_IMPL_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.
*/
// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/window-system/common/display-connection.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
-
namespace Dali
{
-
class DisplayConnection;
namespace Internal
{
namespace Adaptor
{
-
/**
* DisplayConnection implementation
*/
class DisplayConnection : public Dali::BaseObject
{
public:
-
/**
* @brief Default constructor
*/
static DisplayConnection* New();
public:
-
/**
* @copydoc Dali::DisplayConnection::GetDisplay
*/
* Sets the render surface type
* @param[in] type The render surface type
*/
- virtual void SetSurfaceType( Dali::RenderSurfaceInterface::Type type ) = 0;
+ virtual void SetSurfaceType(Dali::RenderSurfaceInterface::Type type) = 0;
/**
* Sets the graphics interface
* @param[in] graphics The graphics interface
*/
- virtual void SetGraphicsInterface( GraphicsInterface& graphics ) = 0;
+ virtual void SetGraphicsInterface(GraphicsInterface& graphics) = 0;
public:
-
/**
* Destructor
*/
~DisplayConnection() override = default;
protected:
-
// Undefined
DisplayConnection(const DisplayConnection&) = delete;
// Undefined
DisplayConnection& operator=(const DisplayConnection& rhs) = delete;
-
};
} // 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.
*/
// 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
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_DISPLAY_CONNECTION_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.
#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
#include <dali/internal/graphics/common/graphics-interface.h>
-
namespace Dali
{
namespace Internal
{
class DisplayConnection;
}
-}
+} // namespace Internal
class DisplayConnection
{
public:
-
/**
* @brief Create an initialized DisplayConnection.
*
* @param[in] graphics The abstracted graphics interface
* @return A handle to a newly allocated DisplayConnection resource.
*/
- static DisplayConnection* New( Dali::Internal::Adaptor::GraphicsInterface& graphics );
+ static DisplayConnection* New(Dali::Internal::Adaptor::GraphicsInterface& graphics);
/**
* @brief Create an initialized DisplayConnection.
* @param[in] type Render surface type
* @return A handle to a newly allocated DisplayConnection resource.
*/
- static DisplayConnection* New( Dali::Internal::Adaptor::GraphicsInterface& graphics, Dali::RenderSurfaceInterface::Type type );
+ static DisplayConnection* New(Dali::Internal::Adaptor::GraphicsInterface& graphics, Dali::RenderSurfaceInterface::Type type);
/**
* @brief Create a DisplayConnection handle; this can be initialised with DisplayConnection::New().
bool Initialize();
public:
-
/**
* @brief This constructor is used by DisplayConnection New() methods.
*
explicit DALI_INTERNAL DisplayConnection(Internal::Adaptor::DisplayConnection* impl);
private:
-
std::unique_ptr<Internal::Adaptor::DisplayConnection> mImpl;
};
-}
+} // namespace Dali
#endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_DISPLAY_CONNECTION_H
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_DISPLAY_UTILs_H
/*
- * 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 Utils
{
-
template<typename T, typename... Args>
std::unique_ptr<T> MakeUnique(Args&&... args)
{
/*
- * 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);
}
}
#define DALI_INTERNAL_EVENT_HANDLER_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.
*/
// EXTERNAL INCLUDES
-#include <cstdint> // uint32_t
#include <dali/public-api/common/intrusive-ptr.h>
+#include <cstdint> // uint32_t
#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/devel-api/adaptor-framework/style-monitor.h>
namespace Dali
{
-
namespace Integration
{
-
struct Point;
struct KeyEvent;
struct WheelEvent;
-}
+} // namespace Integration
namespace Internal
{
-
namespace Adaptor
{
-
class StyleMonitor;
class WindowRenderSurface;
class EventHandler : public ConnectionTracker, public Dali::RefObject
{
public:
-
/**
* The observer can be overridden in order to listen to the events.
*/
class Observer
{
public:
-
/**
* Deriving classes should override this to be notified when we receive a touch point event.
* @param[in] point The touch point
* @param[in] timeStamp The time stamp
*/
- virtual void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) = 0;
+ virtual void OnTouchPoint(Dali::Integration::Point& point, int timeStamp) = 0;
/**
* Deriving classes should override this to be notified when we receive a wheel event.
* @param[in] wheelEvent The wheel event
*/
- virtual void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) = 0;
+ virtual void OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent) = 0;
/**
* Deriving classes should override this to be notified when we receive a key event.
* @param[in] keyEvent The key event holding the key information.
*/
- virtual void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) = 0;
+ virtual void OnKeyEvent(Dali::Integration::KeyEvent& keyEvent) = 0;
/**
* Deriving classes should override this to be notified when the window is rotated.
* @param[in] rotation The rotation event.
*/
- virtual void OnRotation( const RotationEvent& rotation ) = 0;
+ virtual void OnRotation(const RotationEvent& rotation) = 0;
protected:
-
/**
* Protected Constructor.
*/
- Observer() {}
+ Observer()
+ {
+ }
/**
* Protected virtual destructor.
*/
- virtual ~Observer() {}
+ virtual ~Observer()
+ {
+ }
};
public:
-
/**
* Constructor.
* @param[in] windowBase The window base to be handled
* @param[in] damageObserver The damage observer (to pass damage events to).
*/
- EventHandler( WindowBase* windowBase, DamageObserver& damageObserver );
+ EventHandler(WindowBase* windowBase, DamageObserver& damageObserver);
/**
* Destructor.
* Adds an observer so that we can observe the events.
* @param[in] observer The observer.
*/
- void AddObserver( Observer& observer );
+ void AddObserver(Observer& observer);
/**
* Removes the observer from the EventHandler.
* @param[in] observer The observer to remove.
* @note Observers should remove themselves when they are destroyed.
*/
- void RemoveObserver( Observer& observer );
+ void RemoveObserver(Observer& observer);
private:
-
/**
* Send a style change event to the style monitor.
* @param[in] styleChange The style that has changed.
*/
- void SendEvent( StyleChange::Type styleChange );
+ void SendEvent(StyleChange::Type styleChange);
/**
* Send a window damage event to the observer.
* @param[in] area Damaged area.
*/
- void SendEvent( const DamageArea& area );
+ void SendEvent(const DamageArea& area);
/**
* Called when a touch event is received.
*/
- void OnTouchEvent( Integration::Point& point, uint32_t timeStamp );
+ void OnTouchEvent(Integration::Point& point, uint32_t timeStamp);
/**
* Called when a mouse wheel is received.
*/
- void OnWheelEvent( Integration::WheelEvent& wheelEvent );
+ void OnWheelEvent(Integration::WheelEvent& wheelEvent);
/**
* Called when a key event is received.
*/
- void OnKeyEvent( Integration::KeyEvent& keyEvent );
+ void OnKeyEvent(Integration::KeyEvent& keyEvent);
/**
* Called when the window focus is changed.
*/
- void OnFocusChanged( bool focusIn );
+ void OnFocusChanged(bool focusIn);
/**
* Called when the window is rotated.
* @param[in] event The rotation event
*/
- void OnRotation( const RotationEvent& event );
+ void OnRotation(const RotationEvent& event);
/**
* Called when the window is damaged.
*/
- void OnWindowDamaged( const DamageArea& area );
+ void OnWindowDamaged(const DamageArea& area);
/**
* Called when the source window notifies us the content in clipboard is selected.
*/
- void OnSelectionDataSend( void* event );
+ void OnSelectionDataSend(void* event);
/**
* Called when the source window sends us about the selected content.
*/
- void OnSelectionDataReceived( void* event );
+ void OnSelectionDataReceived(void* event);
/**
* Called when the style is changed.
*/
- void OnStyleChanged( StyleChange::Type styleChange );
+ void OnStyleChanged(StyleChange::Type styleChange);
private:
-
// Undefined
- EventHandler( const EventHandler& eventHandler );
+ EventHandler(const EventHandler& eventHandler);
// Undefined
- EventHandler& operator=( const EventHandler& eventHandler );
+ EventHandler& operator=(const EventHandler& eventHandler);
private:
-
- Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
- DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
+ Dali::StyleMonitor mStyleMonitor; ///< Handle to the style monitor, set on construction, to send font size and font change events to.
+ DamageObserver& mDamageObserver; ///< Reference to the DamageObserver, set on construction, to sent damage events to.
Dali::ClipboardEventNotifier mClipboardEventNotifier; ///< Pointer to the clipboard event notifier
- Dali::Clipboard mClipboard;///< Pointer to the clipboard
+ Dali::Clipboard mClipboard; ///< Pointer to the clipboard
using ObserverContainer = std::vector<Observer*>;
- ObserverContainer mObservers; ///< A list of event observer pointers
+ ObserverContainer mObservers; ///< A list of event observer pointers
bool mPaused; ///< The paused state of the 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/common/gl-window-impl.h>
// EXTERNAL HEADERS
-#include <dali/integration-api/core.h>
-#include <dali/devel-api/adaptor-framework/orientation.h>
#include <dali/devel-api/adaptor-framework/gl-window.h>
-#include <dali/integration-api/events/touch-integ.h>
-#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/devel-api/adaptor-framework/orientation.h>
#include <dali/devel-api/events/key-event-devel.h>
+#include <dali/integration-api/core.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-integ.h>
// INTERNAL HEADERS
+#include <dali/internal/graphics/gles/egl-graphics-factory.h>
+#include <dali/internal/window-system/common/display-utils.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/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-impl.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/internal/graphics/gles/egl-graphics-factory.h>
-#include <dali/internal/window-system/common/display-utils.h>
namespace Dali
{
{
namespace Adaptor
{
-
namespace
{
-const int MINIMUM_DIMENSION_CHANGE( 1 );
+const int MINIMUM_DIMENSION_CHANGE(1);
#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
-GlWindow* GlWindow::New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent )
+GlWindow* GlWindow::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
{
- GlWindow* window = new GlWindow();
+ GlWindow* window = new GlWindow();
window->mIsTransparent = isTransparent;
- window->Initialize( positionSize, name, className );
+ window->Initialize(positionSize, name, className);
return window;
}
GlWindow::GlWindow()
: mWindowBase(),
mGraphics(),
- mDisplayConnection( nullptr ),
- mEventHandler( nullptr ),
+ mDisplayConnection(nullptr),
+ mGlWindowRenderThread(nullptr),
+ mEventHandler(nullptr),
+ mIsTransparent(false),
+ mIsFocusAcceptable(false),
+ mIconified(false),
+ mOpaqueState(false),
+ mResizeEnabled(false),
+ mVisible(false),
+ mIsRotated(false),
+ mIsWindowRotated(false),
+ mIsTouched(false),
+ mIsEGLInitialized(false),
+ mDepth(false),
+ mStencil(false),
mPositionSize(),
- mColorDepth( COLOR_DEPTH_24 ),
- mIsTransparent( false ),
- mIsFocusAcceptable( false ),
- mIconified( false ),
- mOpaqueState( false ),
- mResizeEnabled( false ),
- mVisible( false ),
- mIsRotated( false ),
- mIsWindowRotated( false ),
- mIsTouched( false ),
mAvailableAngles(),
- mPreferredAngle( 0 ),
- mTotalRotationAngle( 0 ),
- mWindowRotationAngle( 0 ),
- mScreenRotationAngle( 0 ),
- mOrientationMode( 0 ),
- mWindowWidth( 0 ),
- mWindowHeight( 0 ),
- mNativeWindowId( -1 ),
+ mColorDepth(COLOR_DEPTH_24),
+ mRenderingMode(Dali::GlWindow::RenderingMode::CONTINUOUS),
+ mPreferredAngle(0),
+ mTotalRotationAngle(0),
+ mWindowRotationAngle(0),
+ mScreenRotationAngle(0),
+ mOrientationMode(0),
+ mWindowWidth(0),
+ mWindowHeight(0),
+ mNativeWindowId(-1),
+ mMSAA(0),
mKeyEventSignal(),
mTouchedSignal(),
mFocusChangeSignal(),
mResizeSignal(),
- mVisibilityChangedSignal(),
- mGLInitCallback(),
- mGLRenderFrameCallback(),
- mGLTerminateCallback(),
- mGLRenderCallback( nullptr ),
- mEGLSurface( nullptr ),
- mEGLContext( nullptr ),
- mGLESVersion( Dali::GlWindow::GlesVersion::VERSION_3_0 ),
- mInitCallback( false ),
- mDepth( false ),
- mStencil( false ),
- mIsEGLInitialize( false ),
- mMSAA( 0 )
+ mVisibilityChangedSignal()
{
}
GlWindow::~GlWindow()
{
- if( mEventHandler )
+ if(mEventHandler)
{
- mEventHandler->RemoveObserver( *this );
+ mEventHandler->RemoveObserver(*this);
}
- if( mGLTerminateCallback )
+ if(mGlWindowRenderThread)
{
- CallbackBase::Execute(*mGLTerminateCallback);
+ mGlWindowRenderThread->Stop();
+ mGlWindowRenderThread->Join();
}
- if( mIsEGLInitialize )
+ if(mIsEGLInitialized)
{
- GraphicsInterface* graphics = mGraphics.get();
- EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-
- if( mEGLSurface )
- {
- eglImpl.DestroySurface( mEGLSurface );
- mEGLSurface = nullptr;
- }
-
- if( mEGLContext )
- {
- eglImpl.DestroyContext( mEGLContext );
- mEGLContext = nullptr;
- }
-
- eglImpl.TerminateGles();
-
mGraphics->Destroy();
}
}
-void GlWindow::Initialize( const PositionSize& positionSize, const std::string& name, const std::string& className )
+void GlWindow::Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className)
{
int screenWidth, screenHeight;
mPositionSize = positionSize;
- WindowSystem::GetScreenSize( screenWidth, screenHeight );
- if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) )
+ WindowSystem::GetScreenSize(screenWidth, screenHeight);
+ if((mPositionSize.width == 0) || (mPositionSize.height == 0))
{
- mPositionSize.x = 0;
- mPositionSize.y = 0;
- mPositionSize.width = screenWidth;
+ mPositionSize.x = 0;
+ mPositionSize.y = 0;
+ mPositionSize.width = screenWidth;
mPositionSize.height = screenHeight;
}
- if( screenWidth > screenHeight )
+ if(screenWidth > screenHeight)
{
mOrientationMode = 1; // Default mode is landscape
}
// Create a window base
auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory();
- Any surface;
- mWindowBase = windowFactory->CreateWindowBase( mPositionSize, surface, ( mIsTransparent ? true : false ) );
- mWindowBase->IconifyChangedSignal().Connect( this, &GlWindow::OnIconifyChanged );
- mWindowBase->FocusChangedSignal().Connect( this, &GlWindow::OnFocusChanged );
+ Any surface;
+ mWindowBase = windowFactory->CreateWindowBase(mPositionSize, surface, (mIsTransparent ? true : false));
+ mWindowBase->IconifyChangedSignal().Connect(this, &GlWindow::OnIconifyChanged);
+ mWindowBase->FocusChangedSignal().Connect(this, &GlWindow::OnFocusChanged);
- if( Dali::Adaptor::IsAvailable() )
+ if(Dali::Adaptor::IsAvailable())
{
SetEventHandler();
}
- if( !mPositionSize.IsEmpty() )
+ if(!mPositionSize.IsEmpty())
{
- AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
mResizeEnabled = true;
}
mWindowBase->Show();
- if( mIsTransparent )
+ if(mIsTransparent)
{
mColorDepth = COLOR_DEPTH_32;
}
mColorDepth = COLOR_DEPTH_24;
}
- SetClass( name, className );
+ SetClass(name, className);
// For Debugging
mNativeWindowId = mWindowBase->GetNativeWindowId();
void GlWindow::SetEventHandler()
{
- mEventHandler = EventHandlerPtr( new EventHandler( mWindowBase.get(), *this ) );
- mEventHandler->AddObserver( *this );
+ mEventHandler = EventHandlerPtr(new EventHandler(mWindowBase.get(), *this));
+ mEventHandler->AddObserver(*this);
}
-void GlWindow::SetClass( const std::string& name, const std::string className )
+void GlWindow::SetClass(const std::string& name, const std::string className)
{
- mName = name;
+ mName = name;
mClassName = className;
- mWindowBase->SetClass( name, className );
+ mWindowBase->SetClass(name, className);
}
-void GlWindow::SetEglConfig( bool depth, bool stencil, int msaa, Dali::GlWindow::GlesVersion version )
+void GlWindow::SetEglConfig(bool depth, bool stencil, int msaa, Dali::GlWindow::GlesVersion version)
{
// Init Graphics
- mDepth = depth;
+ mDepth = depth;
mStencil = stencil;
- mMSAA = msaa;
- mGLESVersion = version;
+ mMSAA = msaa;
InitializeGraphics();
+
+ int rVersion = 30;
+
+ if(version == Dali::GlWindow::GlesVersion::VERSION_2_0)
+ {
+ rVersion = 20;
+ }
+ else if(version == Dali::GlWindow::GlesVersion::VERSION_3_0)
+ {
+ rVersion = 30;
+ }
+
+ mGlWindowRenderThread->SetEglConfig(depth, stencil, msaa, rVersion);
}
void GlWindow::Raise()
{
mWindowBase->Raise();
- 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 GlWindow::Lower()
{
mWindowBase->Lower();
- 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 GlWindow::Activate()
{
mWindowBase->Activate();
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Activate() \n", this, mNativeWindowId);
}
void GlWindow::Show()
mWindowBase->Show();
- if( !mIconified )
+ if(!mIconified)
{
- Dali::GlWindow handle( this );
- mVisibilityChangedSignal.Emit( handle, true );
+ Dali::GlWindow handle(this);
+ mVisibilityChangedSignal.Emit(handle, true);
}
- if( mEventHandler )
+ if(mEventHandler)
{
mEventHandler->Resume();
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
+ if(mGlWindowRenderThread)
+ {
+ mGlWindowRenderThread->Resume();
+ }
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Show(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
}
void GlWindow::Hide()
mWindowBase->Hide();
- if( !mIconified )
+ if(!mIconified)
{
- Dali::GlWindow handle( this );
- mVisibilityChangedSignal.Emit( handle, false );
+ Dali::GlWindow handle(this);
+ mVisibilityChangedSignal.Emit(handle, false);
}
- if( mEventHandler )
+ if(mEventHandler)
{
mEventHandler->Pause();
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible );
+ if(mGlWindowRenderThread)
+ {
+ mGlWindowRenderThread->Pause();
+ }
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Hide(): iconified = %d, visible = %d\n", this, mNativeWindowId, mIconified, mVisible);
}
unsigned int GlWindow::GetSupportedAuxiliaryHintCount() const
return mWindowBase->GetSupportedAuxiliaryHintCount();
}
-std::string GlWindow::GetSupportedAuxiliaryHint( unsigned int index ) const
+std::string GlWindow::GetSupportedAuxiliaryHint(unsigned int index) const
{
- return mWindowBase->GetSupportedAuxiliaryHint( index );
+ return mWindowBase->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 mWindowBase->AddAuxiliaryHint( hint, value );
+ return mWindowBase->AddAuxiliaryHint(hint, value);
}
-bool GlWindow::RemoveAuxiliaryHint( unsigned int id )
+bool GlWindow::RemoveAuxiliaryHint(unsigned int id)
{
- return mWindowBase->RemoveAuxiliaryHint( id );
+ return mWindowBase->RemoveAuxiliaryHint(id);
}
-bool GlWindow::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+bool GlWindow::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
{
- return mWindowBase->SetAuxiliaryHintValue( id, value );
+ return mWindowBase->SetAuxiliaryHintValue(id, value);
}
-std::string GlWindow::GetAuxiliaryHintValue( unsigned int id ) const
+std::string GlWindow::GetAuxiliaryHintValue(unsigned int id) const
{
- return mWindowBase->GetAuxiliaryHintValue( id );
+ return mWindowBase->GetAuxiliaryHintValue(id);
}
-unsigned int GlWindow::GetAuxiliaryHintId( const std::string& hint ) const
+unsigned int GlWindow::GetAuxiliaryHintId(const std::string& hint) const
{
- return mWindowBase->GetAuxiliaryHintId( hint );
+ return mWindowBase->GetAuxiliaryHintId(hint);
}
-void GlWindow::SetInputRegion( const Rect< int >& inputRegion )
+void GlWindow::SetInputRegion(const Rect<int>& inputRegion)
{
- mWindowBase->SetInputRegion( inputRegion );
+ mWindowBase->SetInputRegion(inputRegion);
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "GlWindow::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "GlWindow::SetInputRegion: x = %d, y = %d, w = %d, h = %d\n", inputRegion.x, inputRegion.y, inputRegion.width, inputRegion.height);
}
-void GlWindow::SetOpaqueState( bool opaque )
+void GlWindow::SetOpaqueState(bool opaque)
{
mOpaqueState = opaque;
- mWindowBase->SetOpaqueState( opaque );
+ mWindowBase->SetOpaqueState(opaque);
- DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "GlWindow::SetOpaqueState: opaque = %d\n", opaque );
+ DALI_LOG_INFO(gWindowLogFilter, Debug::Verbose, "GlWindow::SetOpaqueState: opaque = %d\n", opaque);
}
bool GlWindow::IsOpaqueState() const
return mOpaqueState;
}
-void GlWindow::SetPositionSize( PositionSize positionSize )
+void GlWindow::SetPositionSize(PositionSize positionSize)
{
- if( !mResizeEnabled )
+ if(!mResizeEnabled)
{
- AddAuxiliaryHint( "wm.policy.win.user.geometry", "1" );
+ AddAuxiliaryHint("wm.policy.win.user.geometry", "1");
mResizeEnabled = true;
}
- 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);
}
mPositionSize = positionSize;
}
else
{
- if( needToMove )
+ if(needToMove)
{
- mWindowBase->Move( positionSize );
+ mWindowBase->Move(positionSize);
mPositionSize = positionSize;
}
}
// If window's size or position is changed, the signal will be emitted to user.
- if( ( needToMove ) || ( needToResize ) )
+ if((needToMove) || (needToResize))
{
- Uint16Pair newSize( mPositionSize.width, mPositionSize.height );
- Dali::GlWindow handle( this );
- mResizeSignal.Emit( newSize );
+ Uint16Pair newSize(mPositionSize.width, mPositionSize.height);
+ Dali::GlWindow handle(this);
+ mResizeSignal.Emit(newSize);
}
}
PositionSize GlWindow::GetPositionSize() const
{
- PositionSize positionSize( mPositionSize );
- if( mTotalRotationAngle == 90 || mTotalRotationAngle == 270 )
+ PositionSize positionSize(mPositionSize);
+ if(mTotalRotationAngle == 90 || mTotalRotationAngle == 270)
{
positionSize.height = mPositionSize.width;
- positionSize.width = mPositionSize.height;
+ positionSize.width = mPositionSize.height;
}
return positionSize;
}
-void GlWindow::OnIconifyChanged( bool iconified )
+void GlWindow::OnIconifyChanged(bool iconified)
{
- if( iconified )
+ if(iconified)
{
mIconified = true;
- if( mVisible )
+ if(mVisible)
{
- Dali::GlWindow handle( this );
- mVisibilityChangedSignal.Emit( handle, false );
+ Dali::GlWindow handle(this);
+ mVisibilityChangedSignal.Emit(handle, false);
}
- if( mEventHandler )
+ if(mEventHandler)
{
mEventHandler->Pause();
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible );
+ if(mGlWindowRenderThread)
+ {
+ mGlWindowRenderThread->Pause();
+ }
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Iconified: visible = %d\n", this, mNativeWindowId, mVisible);
}
else
{
mIconified = false;
- if( mVisible )
+ if(mVisible)
{
- Dali::GlWindow handle( this );
- mVisibilityChangedSignal.Emit( handle, true );
+ Dali::GlWindow handle(this);
+ mVisibilityChangedSignal.Emit(handle, true);
}
- if( mEventHandler )
+ if(mEventHandler)
{
mEventHandler->Resume();
}
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible );
+ if(mGlWindowRenderThread)
+ {
+ mGlWindowRenderThread->Resume();
+ }
+
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), Deiconified: visible = %d\n", this, mNativeWindowId, mVisible);
}
}
-void GlWindow::OnFocusChanged( bool focusIn )
+void GlWindow::OnFocusChanged(bool focusIn)
{
- Dali::GlWindow handle( this );
- mFocusChangeSignal.Emit( handle, focusIn );
+ Dali::GlWindow handle(this);
+ mFocusChangeSignal.Emit(handle, focusIn);
}
void GlWindow::OnOutputTransformed()
{
int screenRotationAngle = mWindowBase->GetScreenRotationAngle();
- if( screenRotationAngle != mScreenRotationAngle )
+ if(screenRotationAngle != mScreenRotationAngle)
{
mScreenRotationAngle = screenRotationAngle;
- mTotalRotationAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
+ mTotalRotationAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
- if( mTotalRotationAngle == 90 || mTotalRotationAngle == 270 )
+ if(mTotalRotationAngle == 90 || mTotalRotationAngle == 270)
{
- mWindowWidth = mPositionSize.height;
+ mWindowWidth = mPositionSize.height;
mWindowHeight = mPositionSize.width;
}
else
{
- mWindowWidth = mPositionSize.width;
+ mWindowWidth = mPositionSize.width;
mWindowHeight = mPositionSize.height;
}
// Emit Resize signal
- Dali::GlWindow handle( this );
- mResizeSignal.Emit( Dali::Uint16Pair( mWindowWidth, mWindowHeight ) );
+ Dali::GlWindow handle(this);
+ mResizeSignal.Emit(Dali::Uint16Pair(mWindowWidth, mWindowHeight));
}
}
-void GlWindow::OnTouchPoint( Dali::Integration::Point& point, int timeStamp )
+void GlWindow::OnTouchPoint(Dali::Integration::Point& point, int timeStamp)
{
PointState::Type state = point.GetState();
- if( state == PointState::DOWN )
+ if(state == PointState::DOWN)
{
mIsTouched = true;
}
- if( state == PointState::UP )
+ if(state == PointState::UP)
{
mIsTouched = false;
}
- if( !mIsTouched && state == PointState::MOTION )
+ if(!mIsTouched && state == PointState::MOTION)
{
return;
}
- RecalculateTouchPosition( point );
- Dali::TouchEvent touchEvent = Dali::Integration::NewTouchEvent( timeStamp, point );
- Dali::GlWindow handle( this );
- mTouchedSignal.Emit( touchEvent );
+ RecalculateTouchPosition(point);
+ Dali::TouchEvent touchEvent = Dali::Integration::NewTouchEvent(timeStamp, point);
+ Dali::GlWindow handle(this);
+ mTouchedSignal.Emit(touchEvent);
}
-void GlWindow::OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent )
+void GlWindow::OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent)
{
// TODO:
//FeedWheelEvent( wheelEvent );
}
-void GlWindow::OnKeyEvent( Dali::Integration::KeyEvent& keyEvent )
+void GlWindow::OnKeyEvent(Dali::Integration::KeyEvent& keyEvent)
{
- Dali::KeyEvent event = Dali::DevelKeyEvent::New( keyEvent.keyName, keyEvent.logicalKey, keyEvent.keyString, keyEvent.keyCode,
- keyEvent.keyModifier, keyEvent.time, static_cast<Dali::KeyEvent::State>(keyEvent.state),
- keyEvent.compose, keyEvent.deviceName, keyEvent.deviceClass, keyEvent.deviceSubclass );
- Dali::GlWindow handle( this );
- mKeyEventSignal.Emit( event );
+ Dali::KeyEvent event = Dali::DevelKeyEvent::New(keyEvent.keyName, keyEvent.logicalKey, keyEvent.keyString, keyEvent.keyCode, keyEvent.keyModifier, keyEvent.time, static_cast<Dali::KeyEvent::State>(keyEvent.state), keyEvent.compose, keyEvent.deviceName, keyEvent.deviceClass, keyEvent.deviceSubclass);
+ Dali::GlWindow handle(this);
+ mKeyEventSignal.Emit(event);
}
-void GlWindow::OnRotation( const RotationEvent& rotation )
+void GlWindow::OnRotation(const RotationEvent& rotation)
{
mWindowRotationAngle = rotation.angle;
- mTotalRotationAngle = ( mWindowRotationAngle + mScreenRotationAngle ) % 360;
- if( mTotalRotationAngle == 90 || mTotalRotationAngle == 270 )
+ mTotalRotationAngle = (mWindowRotationAngle + mScreenRotationAngle) % 360;
+ if(mTotalRotationAngle == 90 || mTotalRotationAngle == 270)
{
- mWindowWidth = mPositionSize.height;
+ mWindowWidth = mPositionSize.height;
mWindowHeight = mPositionSize.width;
}
else
{
- mWindowWidth = mPositionSize.width;
+ mWindowWidth = mPositionSize.width;
mWindowHeight = mPositionSize.height;
}
- mIsRotated = true;
+ mIsRotated = true;
mIsWindowRotated = true;
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), OnRotation(): resize signal emit [%d x %d]\n", this, mNativeWindowId, mWindowWidth, mWindowHeight);
// Emit Resize signal
- Dali::GlWindow handle( this );
- mResizeSignal.Emit( Dali::Uint16Pair( mWindowWidth, mWindowHeight ) );
+ Dali::GlWindow handle(this);
+ mResizeSignal.Emit(Dali::Uint16Pair(mWindowWidth, mWindowHeight));
}
-void GlWindow::RecalculateTouchPosition( Integration::Point& point )
+void GlWindow::RecalculateTouchPosition(Integration::Point& point)
{
Vector2 position = point.GetScreenPosition();
Vector2 convertedPosition;
- switch( mTotalRotationAngle )
+ switch(mTotalRotationAngle)
{
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);
}
-void GlWindow::SetAvailableAnlges( const std::vector< int >& angles )
+void GlWindow::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);
}
-bool GlWindow::IsOrientationAvailable( WindowOrientation orientation ) const
+bool GlWindow::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;
}
-int GlWindow::ConvertToAngle( WindowOrientation orientation )
+int GlWindow::ConvertToAngle(WindowOrientation orientation)
{
int convertAngle = 0;
- if ( mOrientationMode == 0 )
+ if(mOrientationMode == 0)
{
- convertAngle = static_cast< int >( orientation );
+ convertAngle = static_cast<int>(orientation);
}
- else if( mOrientationMode == 1)
+ else if(mOrientationMode == 1)
{
- switch( orientation )
+ switch(orientation)
{
case WindowOrientation::LANDSCAPE:
{
return convertAngle;
}
-WindowOrientation GlWindow::ConvertToOrientation( int angle ) const
+WindowOrientation GlWindow::ConvertToOrientation(int angle) const
{
WindowOrientation orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
- if ( mOrientationMode == 0 ) // Portrate mode
+ if(mOrientationMode == 0) // Portrate mode
{
- orientation = static_cast< WindowOrientation >( angle );
+ orientation = static_cast<WindowOrientation>(angle);
}
- else if( mOrientationMode == 1 ) // Landscape mode
+ else if(mOrientationMode == 1) // Landscape mode
{
- switch( angle )
+ switch(angle)
{
case 0:
{
WindowOrientation GlWindow::GetCurrentOrientation() const
{
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mTotalRotationAngle );
- return ConvertToOrientation( mTotalRotationAngle );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mTotalRotationAngle);
+ return ConvertToOrientation(mTotalRotationAngle);
}
-void GlWindow::SetAvailableOrientations( const Dali::Vector< WindowOrientation >& orientations )
+void GlWindow::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::SetAvailableRotationAngles, invalid angle: %d\n", orientations[index]);
continue;
}
bool found = false;
- int angle = ConvertToAngle( orientations[index] );
+ int angle = 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] == angle )
+ if(mAvailableAngles[i] == angle)
{
found = true;
break;
}
}
- if( !found )
+ if(!found)
{
- DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, angle );
- mAvailableAngles.push_back( angle );
+ DALI_LOG_RELEASE_INFO("Window (%p), WinId (%d), SetAvailableOrientations: %d\n", this, mNativeWindowId, angle);
+ mAvailableAngles.push_back(angle);
}
}
- SetAvailableAnlges( mAvailableAngles );
+ SetAvailableAnlges(mAvailableAngles);
}
-void GlWindow::SetPreferredOrientation( WindowOrientation orientation )
+void GlWindow::SetPreferredOrientation(WindowOrientation orientation)
{
- if( IsOrientationAvailable( orientation ) == false )
+ if(IsOrientationAvailable(orientation) == false)
{
- DALI_LOG_ERROR( "Window::SetPreferredOrientation, invalid orientation: %d\n", orientation );
+ DALI_LOG_ERROR("Window::SetPreferredOrientation, invalid 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);
}
-void GlWindow::SetChild( Dali::Window& child )
+void GlWindow::SetChild(Dali::Window& child)
{
- if( DALI_UNLIKELY( child ) )
+ if(DALI_UNLIKELY(child))
{
- mChildWindow = child;
- Internal::Adaptor::Window& windowImpl = Dali::GetImplementation( mChildWindow );
- WindowRenderSurface* renderSurface = static_cast<WindowRenderSurface*>( windowImpl.GetSurface() );
- if( renderSurface )
+ mChildWindow = child;
+ Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(mChildWindow);
+ WindowRenderSurface* renderSurface = static_cast<WindowRenderSurface*>(windowImpl.GetSurface());
+ if(renderSurface)
{
WindowBase* childWindowBase = renderSurface->GetWindowBase();
- if( childWindowBase )
+ if(childWindowBase)
{
- childWindowBase->SetParent( mWindowBase.get() );
+ childWindowBase->SetParent(mWindowBase.get());
}
}
}
}
-void GlWindow::RegisterGlCallback( CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback )
+void GlWindow::RegisterGlCallback(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback)
{
- if( mIsEGLInitialize == false )
+ if(mIsEGLInitialized == false)
{
InitializeGraphics();
}
- mGLInitCallback = std::unique_ptr< CallbackBase >(initCallback);
- mGLRenderFrameCallback = std::unique_ptr< CallbackBase >( renderFrameCallback );
- mGLTerminateCallback = std::unique_ptr< CallbackBase >( terminateCallback );
-
- mInitCallback = false;
-
- if( !mGLRenderCallback )
- {
- mGLRenderCallback = MakeCallback( this, &GlWindow::RunCallback );
-
- if( Dali::Adaptor::IsAvailable() )
- {
- Dali::Adaptor::Get().AddIdle( mGLRenderCallback, true );
- }
- else
- {
- DALI_LOG_RELEASE_INFO( "RegisterGlCallback: Adaptor is not avaiable\n" );
- }
-
- }
+ mGlWindowRenderThread->RegisterGlCallback(initCallback, renderFrameCallback, terminateCallback);
+ mGlWindowRenderThread->Start();
}
-bool GlWindow::RunCallback()
+void GlWindow::RenderOnce()
{
- GraphicsInterface* graphics = mGraphics.get();
- EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-
- eglImpl.MakeContextCurrent( mEGLSurface, mEGLContext );
-
- int renderFrameResult = 0;
-
- if( mIsRotated )
+ if(mGlWindowRenderThread)
{
- mWindowBase->SetEglWindowBufferTransform( mTotalRotationAngle );
- if( mIsWindowRotated )
- {
- mWindowBase->SetEglWindowTransform( mWindowRotationAngle );
- }
- mIsRotated = false;
+ mGlWindowRenderThread->RenderOnce();
}
+}
- if( !mInitCallback )
+void GlWindow::SetRenderingMode(Dali::GlWindow::RenderingMode mode)
+{
+ mRenderingMode = mode;
+ if(mGlWindowRenderThread)
{
- if( mGLInitCallback )
+ bool onDemand = false;
+ if(mRenderingMode == Dali::GlWindow::RenderingMode::ON_DEMAND)
{
- CallbackBase::Execute(*mGLInitCallback);
+ onDemand = true;
}
- mInitCallback = true;
+ mGlWindowRenderThread->SetOnDemandRenderMode(onDemand);
}
-
- if( mGLRenderFrameCallback )
- {
- renderFrameResult = CallbackBase::ExecuteReturn<int>(*mGLRenderFrameCallback);
- }
-
- if( mIsWindowRotated )
- {
- mWindowBase->WindowRotationCompleted( mWindowRotationAngle, mPositionSize.width, mPositionSize.height );
- mIsWindowRotated = false;
- }
-
- if(renderFrameResult)
- {
- eglImpl.SwapBuffers( mEGLSurface );
- }
-
- return true;
}
-void GlWindow::RenderOnce()
+Dali::GlWindow::RenderingMode GlWindow::GetRenderingMode() const
{
- RunCallback();
+ return mRenderingMode;
}
void GlWindow::InitializeGraphics()
{
- if( !mIsEGLInitialize )
+ if(!mIsEGLInitialized)
{
// Init Graphics
- std::unique_ptr< GraphicsFactory > graphicsFactoryPtr = Utils::MakeUnique< GraphicsFactory >();
- auto graphicsFactory = *graphicsFactoryPtr.get();
+ std::unique_ptr<GraphicsFactory> graphicsFactoryPtr = Utils::MakeUnique<GraphicsFactory>(mEnvironmentOptions);
+ auto graphicsFactory = *graphicsFactoryPtr.get();
- mGraphics = std::unique_ptr< GraphicsInterface >( &graphicsFactory.Create() );
- GraphicsInterface* graphics = mGraphics.get();
- EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
- eglGraphics->Initialize( mDepth, mStencil, mMSAA );
- eglGraphics->Create();
+ mGraphics = std::unique_ptr<GraphicsInterface>(&graphicsFactory.Create());
+ GraphicsInterface* graphics = mGraphics.get();
+ EglGraphics* eglGraphics = static_cast<EglGraphics*>(graphics);
+ eglGraphics->Initialize(mDepth, mStencil, false, mMSAA);
- mDisplayConnection = std::unique_ptr< Dali::DisplayConnection >( Dali::DisplayConnection::New( *graphics, Dali::RenderSurfaceInterface::Type::WINDOW_RENDER_SURFACE ) );
+ mDisplayConnection = std::unique_ptr<Dali::DisplayConnection>(Dali::DisplayConnection::New(*graphics, Dali::RenderSurfaceInterface::Type::WINDOW_RENDER_SURFACE));
mDisplayConnection->Initialize();
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_2_0 )
+ // Create Render Thread
+ mGlWindowRenderThread = std::unique_ptr<Dali::Internal::Adaptor::GlWindowRenderThread>(new GlWindowRenderThread(mPositionSize, mColorDepth));
+ if(!mGlWindowRenderThread)
{
- eglImpl.SetGlesVersion( 20 );
- }
- else if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_3_0 )
- {
- eglImpl.SetGlesVersion( 30 );
+ DALI_LOG_ERROR("Fail to create GlWindow Render Thread!!!!\n");
+ return;
}
- if( eglImpl.ChooseConfig(true, mColorDepth) == false )
+ mGlWindowRenderThread->SetGraphicsInterface(graphics);
+ mGlWindowRenderThread->SetWindowBase(mWindowBase.get());
+ bool onDemand = false;
+ if(mRenderingMode == Dali::GlWindow::RenderingMode::ON_DEMAND)
{
- if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_3_0 )
- {
- DALI_LOG_RELEASE_INFO( "InitializeGraphics: Fail to choose config with GLES30, retry with GLES20\n" );
- eglImpl.SetGlesVersion( 20 );
- mGLESVersion = Dali::GlWindow::GlesVersion::VERSION_2_0;
- if( eglImpl.ChooseConfig(true, mColorDepth) == false )
- {
- DALI_LOG_ERROR("InitializeGraphics: Fail to choose config with GLES20");
- return;
- }
- }
- else
- {
- DALI_LOG_ERROR("InitializeGraphics: Fail to choose config with GLES20");
- return;
- }
+ onDemand = true;
}
- eglImpl.CreateWindowContext( mEGLContext );
+ mGlWindowRenderThread->SetOnDemandRenderMode(onDemand);
- // Create the EGL window
- EGLNativeWindowType window = mWindowBase->CreateEglWindow( mPositionSize.width, mPositionSize.height );
- mEGLSurface = eglImpl.CreateSurfaceWindow( window, mColorDepth );
-
- mIsEGLInitialize = true;
+ mIsEGLInitialized = true;
}
}
-void GlWindow::OnDamaged( const DamageArea& area )
+void GlWindow::OnDamaged(const DamageArea& area)
{
-
}
-} // Adaptor
+} // namespace Adaptor
-} // Internal
+} // namespace Internal
-} // Dali
+} // namespace Dali
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_IMPL_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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
#include <dali/public-api/adaptor-framework/window.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
// INTERNAL INCLUDES
-#include <dali/internal/graphics/gles/egl-graphics.h>
-#include <dali/public-api/adaptor-framework/key-grab.h>
#include <dali/devel-api/adaptor-framework/gl-window.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
#include <dali/internal/window-system/common/event-handler.h>
+#include <dali/internal/window-system/common/gl-window-render-thread.h>
namespace Dali
{
class WindowBase;
class GlWindow;
-using GlWindowPtr = IntrusivePtr< GlWindow >;
-using EventHandlerPtr = IntrusivePtr< EventHandler >;
+using GlWindowPtr = IntrusivePtr<GlWindow>;
+using EventHandlerPtr = IntrusivePtr<EventHandler>;
/**
* Window provides a surface to render onto with orientation.
class GlWindow : public BaseObject, public EventHandler::Observer, public DamageObserver, public ConnectionTracker
{
public:
-
- using KeyEventSignalType = Dali::GlWindow::KeyEventSignalType;
- using TouchEventSignalType = Dali::GlWindow::TouchEventSignalType;
- using FocusChangeSignalType = Dali::GlWindow::FocusChangeSignalType;
- using ResizeSignalType = Dali::GlWindow::ResizeSignalType;
+ using KeyEventSignalType = Dali::GlWindow::KeyEventSignalType;
+ using TouchEventSignalType = Dali::GlWindow::TouchEventSignalType;
+ using FocusChangeSignalType = Dali::GlWindow::FocusChangeSignalType;
+ using ResizeSignalType = Dali::GlWindow::ResizeSignalType;
using VisibilityChangedSignalType = Dali::GlWindow::VisibilityChangedSignalType;
- using SignalType = Signal< void () >;
+ using SignalType = Signal<void()>;
/**
* @brief Create a new GlWindow. This should only be called once by the Application class
* @param[in] isTransparent Whether window is transparent
* @return A newly allocated Window
*/
- static GlWindow* New( const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false );
+ static GlWindow* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
/**
* @copydoc Dali::GlWindow::SetEglConfig()
*/
- void SetEglConfig( bool depth, bool stencil, int msaa, Dali::GlWindow::GlesVersion version );
+ void SetEglConfig(bool depth, bool stencil, int msaa, Dali::GlWindow::GlesVersion version);
/**
* @copydoc Dali::GlWindow::Raise()
/**
* @copydoc Dali::GlWindow::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const;
/**
* @copydoc Dali::GlWindow::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value);
/**
* @copydoc Dali::GlWindow::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id );
+ bool RemoveAuxiliaryHint(unsigned int id);
/**
* @copydoc Dali::GlWindow::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value);
/**
* @copydoc Dali::GlWindow::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const;
+ std::string GetAuxiliaryHintValue(unsigned int id) const;
/**
* @copydoc Dali::GlWindow::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const;
/**
* @copydoc Dali::GlWindow::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion );
+ void SetInputRegion(const Rect<int>& inputRegion);
/**
* @copydoc Dali::GlWindow::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque );
+ void SetOpaqueState(bool opaque);
/**
* @copydoc Dali::GlWindow::IsOpaqueState()
/**
* @copydoc Dali::GlWindow::SetPositionSize()
*/
- void SetPositionSize( PositionSize positionSize );
+ void SetPositionSize(PositionSize positionSize);
/**
* @copydoc Dali::GlWindow::GetPositionSize()
/**
* @copydoc Dali::GlWindow::SetAvailableOrientations()
*/
- void SetAvailableOrientations( const Dali::Vector< WindowOrientation >& orientations );
+ void SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations);
/**
* @copydoc Dali::GlWindow::SetPreferredOrientation()
*/
- void SetPreferredOrientation( WindowOrientation orientation );
+ void SetPreferredOrientation(WindowOrientation orientation);
/**
* @copydoc Dali::GlWindow::RegisterGlCallback()
*/
- void RegisterGlCallback( CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback );
+ void RegisterGlCallback(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback);
/**
* @copydoc Dali::GlWindow::RenderOnce()
*/
void RenderOnce();
+ /**
+ * @copydoc Dali::GlWindow::SetRenderingMode()
+ */
+ void SetRenderingMode(Dali::GlWindow::RenderingMode mode);
+
+ /**
+ * @copydoc Dali::GlWindow::GetRenderingMode()
+ */
+ Dali::GlWindow::RenderingMode GetRenderingMode() const;
+
public: // For implementation
/**
* @brief Sets child window with Dali::Window
*
* Currently the child window is default window.
*/
- void SetChild( Dali::Window& child );
+ void SetChild(Dali::Window& child);
private:
-
/**
* Private constructor.
* @sa Window::New()
* @param[in] name The window title
* @param[in] className The window class name
*/
- void Initialize( const PositionSize& positionSize, const std::string& name, const std::string& className );
+ void Initialize(const PositionSize& positionSize, const std::string& name, const std::string& className);
/**
* Called when the window becomes iconified or deiconified.
*
* @param[in] iconified The flag whether window is iconifed or deiconfied.
*/
- void OnIconifyChanged( bool iconified );
+ void OnIconifyChanged(bool iconified);
/**
* Called when the window focus is changed.
* @param[in] focusIn The flag whether window is focused or not.
*/
- void OnFocusChanged( bool focusIn );
+ void OnFocusChanged(bool focusIn);
/**
* Called when the output is transformed.
*
* @param[in] angles The list of the avaiabled rotation angle.
*/
- void SetAvailableAnlges( const std::vector< int >& angles );
+ void SetAvailableAnlges(const std::vector<int>& angles);
/**
* @brief Check available window orientation for Available angle.
*
* @return true is available window orientation. false is not available.
*/
- bool IsOrientationAvailable( WindowOrientation orientation ) const;
+ bool IsOrientationAvailable(WindowOrientation orientation) const;
/**
* @brief Convert from window orientation to angle using orientation mode value.
*
* @return The coverted angle value is returned.
*/
- int ConvertToAngle( WindowOrientation orientation );
+ int ConvertToAngle(WindowOrientation orientation);
/**
* @brief Convert from angle to window orientation using orientation mode value.
*
* @return The converted window orientation value is returned.
*/
- WindowOrientation ConvertToOrientation( int angle ) const;
-
- /**
- * @brief Run Ui GL callback function.
- *
- * @return true is the callback function works continuos.
- */
- bool RunCallback();
+ WindowOrientation ConvertToOrientation(int angle) const;
/**
* @brief Initialize and create EGL resource
/**
* @brief Sets event handler for window's events.
*/
- void SetEventHandler() ;
+ void SetEventHandler();
/**
* @brief calculate touch position for rotation.
*/
- void RecalculateTouchPosition( Integration::Point& point ) ;
+ void RecalculateTouchPosition(Integration::Point& point);
/**
* @brief Sets window and class name.
* @param[in] name The name of the window
* @param[in] className The class of the window
*/
- void SetClass( const std::string& name, const std::string className );
+ void SetClass(const std::string& name, const std::string className);
private:
-
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
*/
- void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
+ void OnTouchPoint(Dali::Integration::Point& point, int timeStamp) override;
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
*/
- void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
+ void OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent) override;
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
*/
- void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
+ void OnKeyEvent(Dali::Integration::KeyEvent& keyEvent) override;
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
*/
- void OnRotation( const RotationEvent& rotation ) override;
+ void OnRotation(const RotationEvent& rotation) override;
private: // From Dali::Internal::Adaptor::DamageObserver
-
/**
* @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged()
*/
- void OnDamaged( const DamageArea& area );
+ void OnDamaged(const DamageArea& area);
public: // Signals
-
/**
* @copydoc Dali::GlWindow::FocusChangeSignal()
*/
- FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
+ FocusChangeSignalType& FocusChangeSignal()
+ {
+ return mFocusChangeSignal;
+ }
/**
* @copydoc Dali::GlWindow::ResizeSignal()
*/
- ResizeSignalType& ResizeSignal() { return mResizeSignal; }
+ ResizeSignalType& ResizeSignal()
+ {
+ return mResizeSignal;
+ }
/**
* @copydoc Dali::GlWindow::KeyEventSignal()
*/
- KeyEventSignalType& KeyEventSignal() { return mKeyEventSignal; }
+ KeyEventSignalType& KeyEventSignal()
+ {
+ return mKeyEventSignal;
+ }
/**
* @copydoc Dali::GlWindow::TouchSignal()
*/
- TouchEventSignalType& TouchedSignal() { return mTouchedSignal; }
+ TouchEventSignalType& TouchedSignal()
+ {
+ return mTouchedSignal;
+ }
/**
* @copydoc Dali::GlWindow::VisibilityChangedSignal()
*/
- VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
+ VisibilityChangedSignalType& VisibilityChangedSignal()
+ {
+ return mVisibilityChangedSignal;
+ }
private:
-
- std::unique_ptr< WindowBase > mWindowBase;
- std::unique_ptr< GraphicsInterface > mGraphics; ///< Graphics interface
- std::unique_ptr< Dali::DisplayConnection > mDisplayConnection;
- std::string mName;
- std::string mClassName;
- EventHandlerPtr mEventHandler; ///< The window events handler
- PositionSize mPositionSize;
- ColorDepth mColorDepth;
- Dali::Window mChildWindow;
- bool mIsTransparent:1;
- bool mIsFocusAcceptable:1;
- bool mIconified:1;
- bool mOpaqueState:1;
- bool mResizeEnabled:1;
- bool mVisible:1;
- bool mIsRotated:1;
- bool mIsWindowRotated:1;
- bool mIsTouched:1;
-
- std::vector< int > mAvailableAngles;
- int mPreferredAngle;
- int mTotalRotationAngle; ///< The angle of window + screen rotation angle % 360
- int mWindowRotationAngle; ///< The angle of window rotation angle
- int mScreenRotationAngle; ///< The angle of screen rotation angle
- int mOrientationMode; ///< 0: Default portrati, 1:Default landscape
- int mWindowWidth; ///< The width of the window
- int mWindowHeight; ///< The height of the window
- int mNativeWindowId; ///< The Native Window Id
+ std::unique_ptr<WindowBase> mWindowBase;
+ std::unique_ptr<GraphicsInterface> mGraphics; ///< Graphics interface
+ std::unique_ptr<Dali::DisplayConnection> mDisplayConnection; ///< The native display connection
+ std::unique_ptr<GlWindowRenderThread> mGlWindowRenderThread; ///< The render thread
+ EventHandlerPtr mEventHandler; ///< The window events handler
+ Dali::Window mChildWindow; ///< The default child UI Window
+ std::string mName;
+ std::string mClassName;
+ bool mIsTransparent : 1;
+ bool mIsFocusAcceptable : 1;
+ bool mIconified : 1;
+ bool mOpaqueState : 1;
+ bool mResizeEnabled : 1;
+ bool mVisible : 1;
+ bool mIsRotated : 1;
+ bool mIsWindowRotated : 1;
+ bool mIsTouched : 1;
+ bool mIsEGLInitialized : 1;
+ bool mDepth : 1;
+ bool mStencil : 1;
+
+ PositionSize mPositionSize; ///< The window position and size
+ EnvironmentOptions mEnvironmentOptions;
+ std::vector<int> mAvailableAngles; ///< The list of available angle
+ ColorDepth mColorDepth; ///< The color depth of window
+ Dali::GlWindow::RenderingMode mRenderingMode; ///< The rendering mode
+
+ int mPreferredAngle; ///< The angle of preferred angle
+ int mTotalRotationAngle; ///< The angle of window + screen rotation angle % 360
+ int mWindowRotationAngle; ///< The angle of window rotation angle
+ int mScreenRotationAngle; ///< The angle of screen rotation angle
+ int mOrientationMode; ///< 0: Default portrati, 1:Default landscape
+ int mWindowWidth; ///< The width of the window
+ int mWindowHeight; ///< The height of the window
+ int mNativeWindowId; ///< The Native Window Id
+ int mMSAA; ///< The multisample anti-aliasing for EGL Configuration
// Signals
- KeyEventSignalType mKeyEventSignal;
- TouchEventSignalType mTouchedSignal;
- FocusChangeSignalType mFocusChangeSignal;
- ResizeSignalType mResizeSignal;
- VisibilityChangedSignalType mVisibilityChangedSignal;
-
- // EGL, GL Resource
- std::unique_ptr< CallbackBase > mGLInitCallback;
- std::unique_ptr< CallbackBase > mGLRenderFrameCallback;
- std::unique_ptr< CallbackBase > mGLTerminateCallback;
- CallbackBase* mGLRenderCallback;
- EGLSurface mEGLSurface;
- EGLContext mEGLContext;
- Dali::GlWindow::GlesVersion mGLESVersion;
- bool mInitCallback:1;
- bool mDepth:1;
- bool mStencil:1;
- bool mIsEGLInitialize:1;
- int mMSAA;
+ KeyEventSignalType mKeyEventSignal;
+ TouchEventSignalType mTouchedSignal;
+ FocusChangeSignalType mFocusChangeSignal;
+ ResizeSignalType mResizeSignal;
+ VisibilityChangedSignalType mVisibilityChangedSignal;
};
} // namespace Adaptor
-} // namepsace Internal
+} // namespace Internal
// Helpers for public-api forwarding methods
inline Internal::Adaptor::GlWindow& GetImplementation(Dali::GlWindow& window)
{
- DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+ DALI_ASSERT_ALWAYS(window && "Window handle is empty");
BaseObject& object = window.GetBaseObject();
return static_cast<Internal::Adaptor::GlWindow&>(object);
}
inline const Internal::Adaptor::GlWindow& GetImplementation(const Dali::GlWindow& window)
{
- DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+ DALI_ASSERT_ALWAYS(window && "Window handle is empty");
const BaseObject& object = window.GetBaseObject();
return static_cast<const Internal::Adaptor::GlWindow&>(object);
}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/devel-api/adaptor-framework/thread-settings.h>
+
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/system/common/time-service.h>
+#include <dali/internal/window-system/common/gl-window-render-thread.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace
+{
+const unsigned int NANOSECONDS_PER_SECOND(1e+9);
+
+// The following values will get calculated at compile time
+const float DEFAULT_FRAME_DURATION_IN_SECONDS(1.0f / 60.0f);
+const uint64_t DEFAULT_FRAME_DURATION_IN_NANOSECONDS(DEFAULT_FRAME_DURATION_IN_SECONDS* NANOSECONDS_PER_SECOND);
+
+} // namespace
+
+GlWindowRenderThread::GlWindowRenderThread(PositionSize positionSize, ColorDepth colorDepth)
+: mGraphics(nullptr),
+ mWindowBase(nullptr),
+ mLogFactory(Dali::Adaptor::Get().GetLogFactory()),
+ mPositionSize(positionSize),
+ mColorDepth(colorDepth),
+ mGLInitCallback(),
+ mGLRenderFrameCallback(),
+ mGLTerminateCallback(),
+ mEGLSurface(nullptr),
+ mEGLContext(nullptr),
+ mDepth(false),
+ mStencil(false),
+ mIsEGLInitialize(false),
+ mGLESVersion(30), //Default GLES version 30
+ mMSAA(0),
+ mRenderThreadWaitCondition(),
+ mDestroyRenderThread(0),
+ mPauseRenderThread(0),
+ mRenderingMode(0),
+ mRequestRenderOnce(0)
+{
+ unsigned int refrashRate = 1u;
+ mDefaultFrameDurationNanoseconds = uint64_t(refrashRate) * DEFAULT_FRAME_DURATION_IN_NANOSECONDS;
+}
+
+GlWindowRenderThread::~GlWindowRenderThread()
+{
+}
+
+void GlWindowRenderThread::SetGraphicsInterface(GraphicsInterface* graphics)
+{
+ mGraphics = graphics;
+}
+
+void GlWindowRenderThread::SetWindowBase(WindowBase* windowBase)
+{
+ mWindowBase = windowBase;
+}
+
+void GlWindowRenderThread::SetEglConfig(bool depth, bool stencil, int msaa, int version)
+{
+ mDepth = depth;
+ mStencil = stencil;
+ mMSAA = msaa;
+ mGLESVersion = version;
+}
+
+void GlWindowRenderThread::Pause()
+{
+ ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
+ mPauseRenderThread = 1;
+ DALI_LOG_RELEASE_INFO("GlWindowRenderThread::Pause()\n");
+}
+
+void GlWindowRenderThread::Resume()
+{
+ ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
+ mPauseRenderThread = 0;
+ DALI_LOG_RELEASE_INFO("GlWindowRenderThread::Resume()\n");
+ mRenderThreadWaitCondition.Notify(lock);
+}
+
+void GlWindowRenderThread::Stop()
+{
+ ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
+ mDestroyRenderThread = 1;
+ DALI_LOG_RELEASE_INFO("GlWindowRenderThread::Stop()\n");
+ mRenderThreadWaitCondition.Notify(lock);
+}
+
+void GlWindowRenderThread::RegisterGlCallback(CallbackBase* initCallback,
+ CallbackBase* renderFrameCallback,
+ CallbackBase* terminateCallback)
+{
+ mGLInitCallback = std::unique_ptr<CallbackBase>(initCallback);
+ mGLRenderFrameCallback = std::unique_ptr<CallbackBase>(renderFrameCallback);
+ mGLTerminateCallback = std::unique_ptr<CallbackBase>(terminateCallback);
+}
+
+void GlWindowRenderThread::SetOnDemandRenderMode(bool onDemand)
+{
+ ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
+ mRenderingMode = static_cast<unsigned int>(onDemand);
+ DALI_LOG_RELEASE_INFO("GlWindowRenderThread::SetOnDemandRenderMode(): mRenderingMode: %d\n", mRenderingMode);
+ if(!onDemand)
+ {
+ mRenderThreadWaitCondition.Notify(lock);
+ }
+}
+
+void GlWindowRenderThread::RenderOnce()
+{
+ ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
+ mRequestRenderOnce = 1;
+ mRenderThreadWaitCondition.Notify(lock);
+}
+
+void GlWindowRenderThread::Run()
+{
+ Dali::SetThreadName("GlWindowRenderThread");
+ mLogFactory.InstallLogFunction();
+
+ int renderFrameResult = 0;
+ EglGraphics* eglGraphics = static_cast<EglGraphics*>(mGraphics);
+
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+
+ InitializeGraphics(eglGraphics);
+
+ eglImpl.MakeContextCurrent(mEGLSurface, mEGLContext);
+
+ if(mGLInitCallback)
+ {
+ CallbackBase::Execute(*mGLInitCallback);
+ }
+
+ uint64_t timeToSleepUntil = 0;
+
+ while(RenderReady(timeToSleepUntil))
+ {
+ uint64_t currentFrameStartTime = 0;
+ TimeService::GetNanoseconds(currentFrameStartTime);
+
+ if(mGLRenderFrameCallback)
+ {
+ renderFrameResult = CallbackBase::ExecuteReturn<int>(*mGLRenderFrameCallback);
+
+ if(renderFrameResult)
+ {
+ eglImpl.SwapBuffers(mEGLSurface);
+ }
+ }
+ renderFrameResult = 0;
+
+ if(timeToSleepUntil == 0)
+ {
+ timeToSleepUntil = currentFrameStartTime + mDefaultFrameDurationNanoseconds;
+ }
+ else
+ {
+ timeToSleepUntil += mDefaultFrameDurationNanoseconds;
+ uint64_t currentFrameEndTime = 0;
+ TimeService::GetNanoseconds(currentFrameEndTime);
+ while(currentFrameEndTime > timeToSleepUntil + mDefaultFrameDurationNanoseconds)
+ {
+ timeToSleepUntil += mDefaultFrameDurationNanoseconds;
+ }
+ }
+
+ TimeService::SleepUntil(timeToSleepUntil);
+
+ if(mRequestRenderOnce)
+ {
+ mRequestRenderOnce = 0;
+ }
+ }
+
+ if(mGLTerminateCallback)
+ {
+ CallbackBase::Execute(*mGLTerminateCallback);
+ }
+
+ if(mIsEGLInitialize)
+ {
+ EglGraphics* eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+
+ if(mEGLSurface)
+ {
+ eglImpl.DestroySurface(mEGLSurface);
+ mEGLSurface = nullptr;
+ }
+
+ if(mEGLContext)
+ {
+ eglImpl.DestroyContext(mEGLContext);
+ mEGLContext = nullptr;
+ }
+
+ eglImpl.TerminateGles();
+ }
+}
+
+void GlWindowRenderThread::InitializeGraphics(EglGraphics* eglGraphics)
+{
+ mIsEGLInitialize = true;
+
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ eglImpl.SetGlesVersion(mGLESVersion);
+
+ if(eglImpl.ChooseConfig(true, mColorDepth) == false)
+ {
+ if(mGLESVersion == 30)
+ {
+ DALI_LOG_RELEASE_INFO("InitializeGraphics: Fail to choose config with GLES30, retry with GLES20\n");
+ eglImpl.SetGlesVersion(20);
+ mGLESVersion = 20;
+ if(eglImpl.ChooseConfig(true, mColorDepth) == false)
+ {
+ DALI_LOG_ERROR("InitializeGraphics: Fail to choose config with GLES20");
+ return;
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR("InitializeGraphics: Fail to choose config with GLES20");
+ return;
+ }
+ }
+ eglImpl.CreateWindowContext(mEGLContext);
+
+ // Create the EGL window
+ EGLNativeWindowType window = mWindowBase->CreateEglWindow(mPositionSize.width, mPositionSize.height);
+ mEGLSurface = eglImpl.CreateSurfaceWindow(window, mColorDepth);
+}
+
+bool GlWindowRenderThread::RenderReady(uint64_t& timeToSleepUntil)
+{
+ ConditionalWait::ScopedLock updateLock(mRenderThreadWaitCondition);
+ while((!mDestroyRenderThread && mRenderingMode && !mRequestRenderOnce) || mPauseRenderThread)
+ {
+ timeToSleepUntil = 0;
+ mRenderThreadWaitCondition.Wait(updateLock);
+ }
+
+ // Keep the update-render thread alive if this thread is NOT to be destroyed
+ return !mDestroyRenderThread;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_RENDER_THREAD_H
+#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_GL_WINDOW_RENDER_THREAD_H
+
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/devel-api/threading/thread.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/window-system/common/window-base.h>
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+namespace Adaptor
+{
+class WindowBase;
+class GlWindow;
+
+/**
+ * @brief It is for render thread for GlWindow.
+ * User callbacks works in the thread.
+ *
+ * Key Points:
+ * 1. Two Threads:
+ * a. Main/Event Thread.
+ * b. Render Thread.
+ * 2. There is NO VSync thread:
+ * a. We calculate the difference between these two times and if:
+ * i. The difference is less than the default frame time, we sleep.
+ * ii. If it’s more or the same, we continue.
+ * 3. Support Rendering mode
+ * a. CONTINUOUS mode
+ * i. The rendering loop works continuously.
+ * b. ON_DEMAND mode
+ * i. The rendering works by user's request.
+ * ii. User's request is the renderOnce()'s function calling.
+ */
+
+class GlWindowRenderThread : public Dali::Thread
+{
+public:
+ /**
+ * Constructor
+ *
+ * @param[in] positionSize The position and size of the physical window
+ * @param[in] depth color depth of the physical window
+ */
+ GlWindowRenderThread(PositionSize positionSize, ColorDepth colorDepth);
+
+ /**
+ * destructor.
+ */
+ virtual ~GlWindowRenderThread();
+
+ /**
+ * Sets the GraphicsInterface instance.
+ * This graphics instance is used to create and initialize graphics resource
+ *
+ * @param[in] graphics The graphice instance
+ */
+ void SetGraphicsInterface(GraphicsInterface* graphics);
+
+ /**
+ * Sets the WindowBase instance
+ * This WindowBase instance is used to call wl egl window APIs.
+ *
+ * @param[in] windowBase The WindowBase instance
+ */
+ void SetWindowBase(WindowBase* windowBase);
+
+ /**
+ * @brief Sets egl configuration for GlWindow
+ *
+ * @param[in] depth the flag of depth buffer. If true is set, 24bit depth buffer is enabled.
+ * @param[in] stencil the flag of stencil. it true is set, 8bit stencil buffer is enabled.
+ * @param[in] msaa the bit of msaa.
+ * @param[in] version the GLES version.
+ *
+ */
+ void SetEglConfig(bool depth, bool stencil, int msaa, int version);
+
+ /**
+ * Pauses the Render Thread.
+ * It is called when GlWindow is iconified or hidden.
+ *
+ * This will lock the mutex in mRenderThreadWaitCondition.
+ */
+ void Pause();
+
+ /**
+ * Resumes the Render Thread.
+ * It is called when GlWindow is de-iconified or shown.
+ *
+ * This will lock the mutex in mRenderThreadWaitCondition.
+ */
+ void Resume();
+
+ /**
+ * Stops the Render Thread.
+ * This will lock the mutex in mRenderThreadWaitCondition.
+ *
+ * @note Should only be called in Stop as calling this will kill the render thread.
+ */
+ void Stop();
+
+ /**
+ * @copydoc Dali::GlWindow::RegisterGlCallback()
+ */
+ void RegisterGlCallback(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback);
+
+ /**
+ * Enable OnDemand Rendering Mode
+ *
+ * @param[in] onDemand the flag of OnDemand Rendering Mode. If the flag is true, rendering mode is OnDemand, otherwise the flag is false, rendering mode is continuous mode.
+ */
+ void SetOnDemandRenderMode(bool onDemand);
+
+ /**
+ * @copydoc Dali::GlWindow::RenderOnce()
+ */
+ void RenderOnce();
+
+protected:
+ /**
+ * The Render thread loop. This thread will be destroyed on exit from this function.
+ */
+ virtual void Run();
+
+private:
+ /**
+ * @brief Initialize and create EGL resource
+ */
+ void InitializeGraphics(EglGraphics* eglGraphics);
+
+ /**
+ * Called by the Render Thread which ensures a wait if required.
+ *
+ * @param[out] timeToSleepUntil The time remaining in nanoseconds to keep the thread sleeping before resuming.
+ * @return false, if the thread should stop.
+ */
+ bool RenderReady(uint64_t& timeToSleepUntil);
+
+private:
+ GraphicsInterface* mGraphics; ///< Graphics interface
+ WindowBase* mWindowBase;
+
+ const Dali::LogFactoryInterface& mLogFactory;
+
+ PositionSize mPositionSize; ///< Position
+ ColorDepth mColorDepth;
+
+ // EGL, GL Resource
+ std::unique_ptr<CallbackBase> mGLInitCallback;
+ std::unique_ptr<CallbackBase> mGLRenderFrameCallback;
+ std::unique_ptr<CallbackBase> mGLTerminateCallback;
+ EGLSurface mEGLSurface;
+ EGLContext mEGLContext;
+ bool mDepth : 1;
+ bool mStencil : 1;
+ bool mIsEGLInitialize : 1;
+ int mGLESVersion;
+ int mMSAA;
+
+ // To manage the render/main thread
+ ConditionalWait mRenderThreadWaitCondition; ///< The wait condition for the update-render-thread.
+ volatile unsigned int mDestroyRenderThread; ///< Stop render thread. It means this rendter thread will be destoried.
+ volatile unsigned int mPauseRenderThread; ///< Sleep render thread by pause.
+ volatile unsigned int mRenderingMode; ///< Rendering Mode, 0: continuous, 1:OnDemad
+ volatile unsigned int mRequestRenderOnce; ///< Request rendering once
+
+ uint64_t mDefaultFrameDurationNanoseconds; ///< Default duration of a frame (used for sleeping if not enough time elapsed). Not protected by lock, but written to rarely so not worth adding a lock when reading.
+
+}; // GlWindowRenderThread
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#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.
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);
}
}
#define DALI_INTERNAL_ORIENTATION_H
/*
- * 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 <cmath>
#include <dali/public-api/common/constants.h>
#include <dali/public-api/object/base-object.h>
+#include <cmath>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/orientation.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
class Window;
class Orientation : public BaseObject
{
public:
-
typedef Dali::Orientation::OrientationSignalType OrientationSignalType;
static Orientation* New(Window* window);
~Orientation() override;
public:
-
/**
* Returns the actual orientation in degrees
* @return The device's orientation
* Called by the Window when orientation is changed
* @param[in] rotation The rotation event
*/
- void OnOrientationChange( const RotationEvent& rotation );
+ void OnOrientationChange(const RotationEvent& rotation);
public: // Signals
-
/**
* @copydoc Dali::Orientation::ChangedSignal()
*/
OrientationSignalType& ChangedSignal();
private:
-
// Undefined
Orientation(const Orientation&);
Orientation& operator=(Orientation&);
private:
-
- Window* mWindow;
+ Window* mWindow;
OrientationSignalType mChangedSignal;
- int mOrientation;
- int mWindowWidth;
- int mWindowHeight;
+ int mOrientation;
+ int mWindowWidth;
+ int mWindowHeight;
};
-inline Orientation& GetImplementation (Dali::Orientation& orientation)
+inline Orientation& GetImplementation(Dali::Orientation& orientation)
{
DALI_ASSERT_ALWAYS(orientation && "Orientation handle is empty");
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_PIXMAP_RENDER_SURFACE_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
{
-
class TriggerEventInterface;
namespace Internal
{
namespace Adaptor
{
-
/**
* Pixmap interface of render surface.
*/
class PixmapRenderSurface : public Dali::RenderSurfaceInterface
{
public:
-
/**
* @brief Default constructor
*/
virtual ~PixmapRenderSurface() = default;
public: // API
-
/**
* @brief Get the render surface the adaptor is using to render to.
* @return reference to current render surface
* @brief Sets the render notification trigger to call when render thread is completed a frame
* @param renderNotification to use
*/
- virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) = 0;
+ virtual void SetRenderNotification(TriggerEventInterface* renderNotification) = 0;
/**
* @copydoc Dali::RenderSurfaceInterface::GetDepthBufferRequired()
}
private:
-
/**
* Second stage construction
*/
- virtual void Initialize( Any surface ) = 0;
+ virtual void Initialize(Any surface) = 0;
/**
* @brief Create a renderable
* @brief Use an existing render surface
* @param surfaceId the id of the surface
*/
- virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
+ virtual void UseExistingRenderable(unsigned int surfaceId) = 0;
protected:
-
// Undefined
PixmapRenderSurface(const PixmapRenderSurface&) = delete;
// Undefined
PixmapRenderSurface& operator=(const PixmapRenderSurface& rhs) = delete;
-
};
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_RENDER_SURFACE_FACTORY_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
{
-
class NativeRenderSurface;
namespace Internal
{
namespace Adaptor
{
-
class WindowRenderSurface;
class PixmapRenderSurface;
class RenderSurfaceFactory
{
public:
-
- RenderSurfaceFactory() = default;
+ RenderSurfaceFactory() = default;
virtual ~RenderSurfaceFactory() = default;
- virtual std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) = 0;
+ virtual std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) = 0;
- virtual std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) = 0;
+ virtual std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) = 0;
- virtual std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) = 0;
+ virtual std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) = 0;
};
-extern std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory();
+extern std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory();
} // namespace Adaptor
} // namespace Internal
#define DALI_INTERNAL_ROTATION_EVENT_H
/*
- * 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 RotationEvent
{
int angle; ///< one of 0, 90, 180, 270
/*
- * 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(),
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_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.
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/point.h>
#include <dali/integration-api/events/wheel-event-integ.h>
+#include <cstdint>
#include <string>
#include <vector>
-#include <cstdint>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/window.h>
-#include <dali/public-api/adaptor-framework/key-grab.h>
-#include <dali/public-api/adaptor-framework/style-change.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/window-system/common/damage-observer.h>
#include <dali/internal/window-system/common/rotation-event.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/public-api/adaptor-framework/key-grab.h>
+#include <dali/public-api/adaptor-framework/style-change.h>
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
+#include <dali/public-api/adaptor-framework/window.h>
namespace Dali
{
{
namespace Adaptor
{
-
/**
* WindowBase interface
*/
class WindowBase
{
public:
-
/**
* @brief Struct used to retrieve accessibility information
*/
};
// Window
- typedef Signal< void ( bool ) > IconifySignalType;
- typedef Signal< void ( bool ) > FocusSignalType;
- typedef Signal< void ( ) > OutputSignalType;
- typedef Signal< void ( ) > DeleteSignalType;
- typedef Signal< void ( const DamageArea& ) > DamageSignalType;
- typedef Signal< void ( const RotationEvent& ) > RotationSignalType;
- typedef Signal< void ( WindowEffectState, WindowEffectType ) > TransitionEffectEventSignalType;
- typedef Signal< void ( ) > KeyboardRepeatSettingsChangedSignalType;
- typedef Signal< void ( ) > WindowRedrawRequestSignalType;
+ typedef Signal<void(bool)> IconifySignalType;
+ typedef Signal<void(bool)> FocusSignalType;
+ typedef Signal<void()> OutputSignalType;
+ typedef Signal<void()> DeleteSignalType;
+ typedef Signal<void(const DamageArea&)> DamageSignalType;
+ typedef Signal<void(const RotationEvent&)> RotationSignalType;
+ typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
+ typedef Signal<void()> KeyboardRepeatSettingsChangedSignalType;
+ typedef Signal<void()> WindowRedrawRequestSignalType;
// Input events
- typedef Signal< void ( Integration::Point&, uint32_t ) > TouchEventSignalType;
- typedef Signal< void ( Integration::WheelEvent& ) > WheelEventSignalType;
- typedef Signal< void( Integration::KeyEvent& ) > KeyEventSignalType;
+ typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
+ typedef Signal<void(Integration::WheelEvent&)> WheelEventSignalType;
+ typedef Signal<void(Integration::KeyEvent&)> KeyEventSignalType;
// Clipboard
- typedef Signal< void ( void* ) > SelectionSignalType;
+ typedef Signal<void(void*)> SelectionSignalType;
// Accessibility
- typedef Signal< void ( StyleChange::Type ) > StyleSignalType;
- typedef Signal< void ( const AccessibilityInfo& ) > AccessibilitySignalType;
+ typedef Signal<void(StyleChange::Type)> StyleSignalType;
+ typedef Signal<void(const AccessibilityInfo&)> AccessibilitySignalType;
/**
* @brief Default constructor
virtual ~WindowBase();
public:
-
/**
* @brief Get the native window handle
* @return The native window handle
/**
* @brief Create the egl window
*/
- virtual EGLNativeWindowType CreateEglWindow( int width, int height ) = 0;
+ virtual EGLNativeWindowType CreateEglWindow(int width, int height) = 0;
/**
* @brief Destroy the egl window
/**
* @brief Set the egl window rotation
*/
- virtual void SetEglWindowRotation( int angle ) = 0;
+ virtual void SetEglWindowRotation(int angle) = 0;
/**
* @brief Set the egl window buffer transform
*/
- virtual void SetEglWindowBufferTransform( int angle ) = 0;
+ virtual void SetEglWindowBufferTransform(int angle) = 0;
/**
* @brief Set the egl window transform
*/
- virtual void SetEglWindowTransform( int angle ) = 0;
+ virtual void SetEglWindowTransform(int angle) = 0;
/**
* @brief Resize the egl window
*/
- virtual void ResizeEglWindow( Dali::PositionSize positionSize ) = 0;
+ virtual void ResizeEglWindow(Dali::PositionSize positionSize) = 0;
/**
* @brief Returns whether the egl window support rotation or not
/**
* @brief Move the window
*/
- virtual void Move( Dali::PositionSize positionSize ) = 0;
+ virtual void Move(Dali::PositionSize positionSize) = 0;
/**
* @brief Resize the window
*/
- virtual void Resize( Dali::PositionSize positionSize ) = 0;
+ virtual void Resize(Dali::PositionSize positionSize) = 0;
/**
* @brief Move and resize the window
*/
- virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
+ virtual void MoveResize(Dali::PositionSize positionSize) = 0;
/**
* @copydoc Dali::Window::SetClass()
*/
- virtual void SetClass( const std::string& name, const std::string& className ) = 0;
+ virtual void SetClass(const std::string& name, const std::string& className) = 0;
/**
* @copydoc Dali::Window::Raise()
/**
* @copydoc Dali::Window::SetAvailableOrientations()
*/
- virtual void SetAvailableAnlges( const std::vector< int >& angles ) = 0;
+ virtual void SetAvailableAnlges(const std::vector<int>& angles) = 0;
/**
* @copydoc Dali::Window::SetPreferredOrientation()
*/
- virtual void SetPreferredAngle( int angle ) = 0;
+ virtual void SetPreferredAngle(int angle) = 0;
/**
* @copydoc Dali::Window::SetAcceptFocus()
*/
- virtual void SetAcceptFocus( bool accept ) = 0;
+ virtual void SetAcceptFocus(bool accept) = 0;
/**
* @copydoc Dali::Window::Show()
/**
* @copydoc Dali::Window::GetSupportedAuxiliaryHint()
*/
- virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const = 0;
+ virtual std::string GetSupportedAuxiliaryHint(unsigned int index) const = 0;
/**
* @copydoc Dali::Window::AddAuxiliaryHint()
*/
- virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) = 0;
+ virtual unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) = 0;
/**
* @copydoc Dali::Window::RemoveAuxiliaryHint()
*/
- virtual bool RemoveAuxiliaryHint( unsigned int id ) = 0;
+ virtual bool RemoveAuxiliaryHint(unsigned int id) = 0;
/**
* @copydoc Dali::Window::SetAuxiliaryHintValue()
*/
- virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) = 0;
+ virtual bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) = 0;
/**
* @copydoc Dali::Window::GetAuxiliaryHintValue()
*/
- virtual std::string GetAuxiliaryHintValue( unsigned int id ) const = 0;
+ virtual std::string GetAuxiliaryHintValue(unsigned int id) const = 0;
/**
* @copydoc Dali::Window::GetAuxiliaryHintId()
*/
- virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const = 0;
+ virtual unsigned int GetAuxiliaryHintId(const std::string& hint) const = 0;
/**
* @copydoc Dali::Window::SetInputRegion()
*/
- virtual void SetInputRegion( const Rect< int >& inputRegion ) = 0;
+ virtual void SetInputRegion(const Rect<int>& inputRegion) = 0;
/**
* @copydoc Dali::Window::SetType()
*/
- virtual void SetType( Dali::WindowType type ) = 0;
+ virtual void SetType(Dali::WindowType type) = 0;
/**
* @copydoc Dali::Window::SetNotificationLevel()
*/
- virtual bool SetNotificationLevel( Dali::WindowNotificationLevel level ) = 0;
+ virtual bool SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
/**
* @copydoc Dali::Window::GetNotificationLevel()
/**
* @copydoc Dali::Window::SetOpaqueState()
*/
- virtual void SetOpaqueState( bool opaque ) = 0;
+ virtual void SetOpaqueState(bool opaque) = 0;
/**
* @copydoc Dali::Window::SetScreenOffMode()
/**
* @copydoc Dali::Window::SetBrightness()
*/
- virtual bool SetBrightness( int brightness ) = 0;
+ virtual bool SetBrightness(int brightness) = 0;
/**
* @copydoc Dali::Window::GetBrightness()
/**
* @copydoc Dali::KeyGrab::GrabKey()
*/
- virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) = 0;
+ virtual bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) = 0;
/**
* @copydoc Dali::KeyGrab::UngrabKey()
*/
- virtual bool UngrabKey( Dali::KEY key ) = 0;
+ virtual bool UngrabKey(Dali::KEY key) = 0;
/**
* @copydoc Dali::KeyGrab::GrabKeyList()
*/
- virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) = 0;
+ virtual bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) = 0;
/**
* @copydoc Dali::KeyGrab::UngrabKeyList()
*/
- virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) = 0;
+ virtual bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) = 0;
/**
* @brief Get DPI
* @param[out] dpiHorizontal set to the horizontal dpi
* @param[out] dpiVertical set to the vertical dpi
*/
- virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
+ virtual void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) = 0;
/**
* @brief Return the orientation of the surface.
/**
* @brief Set the rotation angle of the window
*/
- virtual void SetWindowRotationAngle( int degree ) = 0;
+ virtual void SetWindowRotationAngle(int degree) = 0;
/**
* @brief Inform the window rotation is completed
*/
- virtual void WindowRotationCompleted( int degree, int width, int height ) = 0;
+ virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
/**
* @copydoc Dali::Window::SetTransparency()
*/
- virtual void SetTransparency( bool transparent ) = 0;
+ virtual void SetTransparency(bool transparent) = 0;
/**
* @copydoc Dali::Window::SetParent()
*/
- virtual void SetParent( WindowBase* parentWinBase ) = 0;
+ virtual void SetParent(WindowBase* parentWinBase) = 0;
/**
* @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
/**
* @brief This signal is emitted when the window becomes iconified or deiconified.
*/
- IconifySignalType& IconifyChangedSignal();
+ IconifySignalType& IconifyChangedSignal();
/**
* @brief This signal is emitted when the window focus is changed.
WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
protected:
-
// Undefined
WindowBase(const WindowBase&) = delete;
WindowBase& operator=(const WindowBase& rhs) = delete;
protected:
-
IconifySignalType mIconifyChangedSignal;
FocusSignalType mFocusChangedSignal;
OutputSignalType mOutputTransformedSignal;
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_BASE_WINDOW_EVENT_INTERFACE_H
/*
- * 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/public-api/events/key-event.h>
-#include <dali/public-api/events/wheel-event.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/point.h>
+#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/events/wheel-event.h>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
/**
* @brief Abstract interface for handling DALi events received from the native window system
*
*/
class WindowEventInterface
{
-
public:
-
/**
* @brief Touch Event callback
* @param[in] point touch point
* @param[in] timeStamp time stamp
*/
- virtual void TouchEvent( Dali::Integration::Point& point, unsigned long timeStamp ) = 0;
+ virtual void TouchEvent(Dali::Integration::Point& point, unsigned long timeStamp) = 0;
/**
* @brief Key Event callback
* @param[in] keyEvent key event
*/
- virtual void KeyEvent( Dali::Integration::KeyEvent& keyEvent ) = 0;
+ virtual void KeyEvent(Dali::Integration::KeyEvent& keyEvent) = 0;
/**
* @brief Wheel Event callback
* @param[in] wheelEvent wheel event
*/
- virtual void WheelEvent( Dali::WheelEvent& wheelEvent ) = 0;
+ virtual void WheelEvent(Dali::WheelEvent& wheelEvent) = 0;
/**
* @brief Window damage callback
* @param[in] damageArea Window damage area
*/
- virtual void DamageEvent( Dali::Rect<int>& damageArea ) = 0;
+ virtual void DamageEvent(Dali::Rect<int>& damageArea) = 0;
/**
* @brief Window Focused
virtual void WindowFocusOut() = 0;
protected:
-
/**
* @brief Constructor
*/
}
// Undefined copy constructor.
- WindowEventInterface( const WindowEventInterface& );
+ WindowEventInterface(const WindowEventInterface&);
// Undefined assignment operator.
- WindowEventInterface& operator=( const WindowEventInterface& );
-
+ WindowEventInterface& operator=(const WindowEventInterface&);
};
} // namespace Adaptor
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_FACTORY_H
/*
- * 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
{
-
class Adaptor;
class WindowBase;
class WindowFactory
{
public:
-
- WindowFactory() = default;
+ WindowFactory() = default;
virtual ~WindowFactory() = default;
- virtual std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) = 0;
+ virtual std::unique_ptr<WindowBase> CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent) = 0;
};
-extern std::unique_ptr< WindowFactory > GetWindowFactory();
+extern std::unique_ptr<WindowFactory> GetWindowFactory();
} // namespace Adaptor
} // 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.
#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
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_IMPL_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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/object/base-object.h>
#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/object/property-array.h>
#include <dali/public-api/adaptor-framework/window-enumerations.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
// INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/window.h>
-#include <dali/public-api/adaptor-framework/key-grab.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
#include <dali/internal/window-system/common/event-handler.h>
+#include <dali/public-api/adaptor-framework/key-grab.h>
+#include <dali/public-api/adaptor-framework/window.h>
namespace Dali
{
class WindowBase;
class Window;
-using WindowPtr = IntrusivePtr< Window >;
-using OrientationPtr = IntrusivePtr< Orientation >;
-using EventHandlerPtr = IntrusivePtr< EventHandler >;
+using WindowPtr = IntrusivePtr<Window>;
+using OrientationPtr = IntrusivePtr<Orientation>;
+using EventHandlerPtr = IntrusivePtr<EventHandler>;
/**
* Window provides a surface to render onto with orientation & indicator properties.
class Window : public Dali::Internal::Adaptor::SceneHolder, public EventHandler::Observer, public ConnectionTracker
{
public:
- typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
- typedef Dali::Window::ResizeSignalType ResizeSignalType;
- typedef Dali::DevelWindow::VisibilityChangedSignalType VisibilityChangedSignalType;
- typedef Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
+ typedef Dali::Window::FocusChangeSignalType FocusChangeSignalType;
+ typedef Dali::Window::ResizeSignalType ResizeSignalType;
+ typedef Dali::DevelWindow::VisibilityChangedSignalType VisibilityChangedSignalType;
+ typedef Dali::DevelWindow::TransitionEffectEventSignalType TransitionEffectEventSignalType;
typedef Dali::DevelWindow::KeyboardRepeatSettingsChangedSignalType KeyboardRepeatSettingsChangedSignalType;
- typedef Signal< void () > SignalType;
+ typedef Signal<void()> SignalType;
/**
* @brief Create a new Window. This should only be called once by the Application class
/**
* @copydoc Dali::Window::SetClass()
*/
- void SetClass( std::string name, std::string className );
+ void SetClass(std::string name, std::string className);
/**
* @brief Gets the window class name.
/**
* @copydoc Dali::Window::GetLayer()
*/
- Dali::Layer GetLayer( uint32_t depth ) const;
+ Dali::Layer GetLayer(uint32_t depth) const;
/**
* @copydoc Dali::DevelWindow::GetRenderTaskList()
/**
* @copydoc Dali::Window::SetAcceptFocus()
*/
- void SetAcceptFocus( bool accept );
+ void SetAcceptFocus(bool accept);
/**
* @copydoc Dali::Window::IsFocusAcceptable()
/**
* @copydoc Dali::Window::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const;
/**
* @copydoc Dali::Window::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value );
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value);
/**
* @copydoc Dali::Window::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id );
+ bool RemoveAuxiliaryHint(unsigned int id);
/**
* @copydoc Dali::Window::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value );
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value);
/**
* @copydoc Dali::Window::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const;
+ std::string GetAuxiliaryHintValue(unsigned int id) const;
/**
* @copydoc Dali::Window::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const;
/**
* @copydoc Dali::Window::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion );
+ void SetInputRegion(const Rect<int>& inputRegion);
/**
* @copydoc Dali::Window::SetType()
*/
- void SetType( WindowType type );
+ void SetType(WindowType type);
/**
* @copydoc Dali::Window::GetType() const
/**
* @copydoc Dali::Window::SetNotificationLevel()
*/
- bool SetNotificationLevel( WindowNotificationLevel level );
+ bool SetNotificationLevel(WindowNotificationLevel level);
/**
* @copydoc Dali::Window::GetNotificationLevel()
/**
* @copydoc Dali::Window::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque );
+ void SetOpaqueState(bool opaque);
/**
* @copydoc Dali::Window::IsOpaqueState()
/**
* @copydoc Dali::Window::SetBrightness()
*/
- bool SetBrightness( int brightness );
+ bool SetBrightness(int brightness);
/**
* @copydoc Dali::Window::GetBrightness()
/**
* @copydoc Dali::Window::SetSize()
*/
- void SetSize( Dali::Window::WindowSize size );
+ void SetSize(Dali::Window::WindowSize size);
/**
* @copydoc Dali::Window::GetSize()
/**
* @copydoc Dali::Window::SetPosition()
*/
- void SetPosition( Dali::Window::WindowPosition position );
+ void SetPosition(Dali::Window::WindowPosition position);
/**
* @copydoc Dali::Window::GetPosition()
/**
* @copydoc Dali::DevelWindow::SetPositionSize()
*/
- void SetPositionSize( PositionSize positionSize );
+ void SetPositionSize(PositionSize positionSize);
/**
* @copydoc Dali::Window::GetRootLayer()
/**
* @copydoc Dali::Window::SetTransparency()
*/
- void SetTransparency( bool transparent );
+ void SetTransparency(bool transparent);
/**
* @copydoc Dali::KeyGrab::GrabKey()
*/
- bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode );
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode);
/**
* @copydoc Dali::KeyGrab::UngrabKey()
*/
- bool UngrabKey( Dali::KEY key );
+ bool UngrabKey(Dali::KEY key);
/**
* @copydoc Dali::KeyGrab::GrabKeyList()
*/
- bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result );
+ bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result);
/**
* @copydoc Dali::KeyGrab::UngrabKeyList()
*/
- bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result );
+ bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result);
/**
* @copydoc Dali::DevelWindow::Get()
*/
- static Dali::Window Get( Dali::Actor actor );
+ static Dali::Window Get(Dali::Actor actor);
/**
* @copydoc Dali::DevelWindow::SetParent()
*/
- void SetParent( Dali::Window& parent );
+ void SetParent(Dali::Window& parent);
/**
* @copydoc Dali::DevelWindow::Unparent()
/**
* @copydoc Dali::DevelWindow::SetAvailableOrientations()
*/
- void SetAvailableOrientations( const Dali::Vector<WindowOrientation>& orientations );
+ void SetAvailableOrientations(const Dali::Vector<WindowOrientation>& orientations);
public: // Dali::Internal::Adaptor::SceneHolder
-
/**
* @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
*/
int32_t GetNativeId() const;
private:
-
/**
* @brief Enumeration for orietation mode.
* The Orientation Mode is related to screen size.
/**
* Called when the window becomes iconified or deiconified.
*/
- void OnIconifyChanged( bool iconified );
+ void OnIconifyChanged(bool iconified);
/**
* Called when the window focus is changed.
*/
- void OnFocusChanged( bool focusIn );
+ void OnFocusChanged(bool focusIn);
/**
* Called when the output is transformed.
/**
* Called when the window receives a Transition effect-start/end event.
*/
- void OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type );
+ void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
/**
* @brief Called when window receives a keyboard repeat event.
/**
* @brief Set available orientation to window base.
*/
- void SetAvailableAnlges( const std::vector< int >& angles );
+ void SetAvailableAnlges(const std::vector<int>& angles);
/**
* @brief Convert from window orientation to angle using OrientationMode.
*/
- int ConvertToAngle( WindowOrientation orientation );
+ int ConvertToAngle(WindowOrientation orientation);
/**
* @brief Convert from angle to window orientation using OrientationMode.
*/
- WindowOrientation ConvertToOrientation( int angle ) const;
+ WindowOrientation ConvertToOrientation(int angle) const;
/**
* @brief Check available window orientation for Available orientation.
*/
- bool IsOrientationAvailable( WindowOrientation orientation ) const;
+ bool IsOrientationAvailable(WindowOrientation orientation) const;
private: // Dali::Internal::Adaptor::SceneHolder
-
/**
* @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
*/
- void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
+ void OnAdaptorSet(Dali::Adaptor& adaptor) override;
/**
* @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
*/
- void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
+ void OnSurfaceSet(Dali::RenderSurfaceInterface* surface) override;
/**
* @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
/**
* @copydoc Dali::Internal::Adaptor::SceneHolder::RecalculateTouchPosition
*/
- void RecalculateTouchPosition( Integration::Point& point ) override;
+ void RecalculateTouchPosition(Integration::Point& point) override;
private: // Dali::Internal::Adaptor::EventHandler::Observer
-
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnTouchPoint
*/
- void OnTouchPoint( Dali::Integration::Point& point, int timeStamp ) override;
+ void OnTouchPoint(Dali::Integration::Point& point, int timeStamp) override;
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnWheelEvent
*/
- void OnWheelEvent( Dali::Integration::WheelEvent& wheelEvent ) override;
+ void OnWheelEvent(Dali::Integration::WheelEvent& wheelEvent) override;
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnKeyEvent
*/
- void OnKeyEvent( Dali::Integration::KeyEvent& keyEvent ) override;
+ void OnKeyEvent(Dali::Integration::KeyEvent& keyEvent) override;
/**
* @copydoc Dali::Internal::Adaptor::EventHandler::Observer::OnRotation
*/
- void OnRotation( const RotationEvent& rotation ) override;
+ void OnRotation(const RotationEvent& rotation) override;
public: // Signals
-
/**
* @copydoc Dali::Window::FocusChangeSignal()
*/
- FocusChangeSignalType& FocusChangeSignal() { return mFocusChangeSignal; }
+ FocusChangeSignalType& FocusChangeSignal()
+ {
+ return mFocusChangeSignal;
+ }
/**
* @copydoc Dali::Window::ResizedSignal()
*/
- ResizeSignalType& ResizeSignal() { return mResizeSignal; }
+ ResizeSignalType& ResizeSignal()
+ {
+ return mResizeSignal;
+ }
/**
* This signal is emitted when the window is requesting to be deleted
*/
- SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
+ SignalType& DeleteRequestSignal()
+ {
+ return mDeleteRequestSignal;
+ }
/**
* @copydoc Dali::DevelWindow::VisibilityChangedSignal()
*/
- VisibilityChangedSignalType& VisibilityChangedSignal() { return mVisibilityChangedSignal; }
+ VisibilityChangedSignalType& VisibilityChangedSignal()
+ {
+ return mVisibilityChangedSignal;
+ }
/**
* @copydoc Dali::Window::SignalEventProcessingFinished()
*/
- Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal() { return mScene.EventProcessingFinishedSignal(); }
+ Dali::DevelWindow::EventProcessingFinishedSignalType& EventProcessingFinishedSignal()
+ {
+ return mScene.EventProcessingFinishedSignal();
+ }
/**
* @copydoc Dali::DevelWindow::TransitionEffectEventSignal()
*/
- TransitionEffectEventSignalType& TransitionEffectEventSignal() { return mTransitionEffectEventSignal; }
+ TransitionEffectEventSignalType& TransitionEffectEventSignal()
+ {
+ return mTransitionEffectEventSignal;
+ }
/**
* @copydoc Dali::DevelWindow::KeyboardRepeatSettingsChangedSignal()
*/
- KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal() { return mKeyboardRepeatSettingsChangedSignal; }
+ KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal()
+ {
+ return mKeyboardRepeatSettingsChangedSignal;
+ }
private:
+ WindowRenderSurface* mWindowSurface; ///< The window rendering surface
+ WindowBase* mWindowBase;
+ std::string mName;
+ std::string mClassName;
+ bool mIsTransparent : 1;
+ bool mIsFocusAcceptable : 1;
+ bool mIconified : 1;
+ bool mOpaqueState : 1;
+ bool mResizeEnabled : 1;
+ WindowType mType;
+ Dali::Window mParentWindow;
- WindowRenderSurface* mWindowSurface; ///< The window rendering surface
- WindowBase* mWindowBase;
- std::string mName;
- std::string mClassName;
- bool mIsTransparent:1;
- bool mIsFocusAcceptable:1;
- bool mIconified:1;
- bool mOpaqueState:1;
- bool mResizeEnabled:1;
- WindowType mType;
- Dali::Window mParentWindow;
-
- OrientationPtr mOrientation;
- std::vector< int > mAvailableAngles;
- int mPreferredAngle;
+ OrientationPtr mOrientation;
+ std::vector<int> mAvailableAngles;
+ int mPreferredAngle;
- int mRotationAngle; ///< The angle of the rotation
- int mWindowWidth; ///< The width of the window
- int mWindowHeight; ///< The height of the window
+ int mRotationAngle; ///< The angle of the rotation
+ int mWindowWidth; ///< The width of the window
+ int mWindowHeight; ///< The height of the window
- EventHandlerPtr mEventHandler; ///< The window events handler
+ EventHandlerPtr mEventHandler; ///< The window events handler
- OrientationMode mOrientationMode;
+ OrientationMode mOrientationMode;
- int mNativeWindowId; ///< The Native Window Id
+ int mNativeWindowId; ///< The Native Window Id
// Signals
SignalType mDeleteRequestSignal;
};
} // namespace Adaptor
-} // namepsace Internal
+} // namespace Internal
// Helpers for public-api forwarding methods
inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
{
- DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+ DALI_ASSERT_ALWAYS(window && "Window handle is empty");
BaseObject& object = window.GetBaseObject();
return static_cast<Internal::Adaptor::Window&>(object);
}
inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
{
- DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+ DALI_ASSERT_ALWAYS(window && "Window handle is empty");
const BaseObject& object = window.GetBaseObject();
return static_cast<const Internal::Adaptor::Window&>(object);
}
/*
- * 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
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_RENDER_SURFACE_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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/signals/connection-tracker.h>
-#include <dali/public-api/signals/dali-signal.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/integration-api/scene.h>
+#include <dali/public-api/signals/connection-tracker.h>
+#include <dali/public-api/signals/dali-signal.h>
#include <unistd.h>
// INTERNAL INCLUDES
namespace Dali
{
-
class TriggerEventInterface;
namespace Internal
{
namespace Adaptor
{
-
class WindowBase;
class AdaptorInternalServices;
class WindowRenderSurface : public Dali::RenderSurfaceInterface, public ConnectionTracker
{
public:
-
- using OutputSignalType = Signal< void ( ) >;
- using DamagedRectsContainer = std::list< std::vector< Rect< int > > >;
+ using OutputSignalType = Signal<void()>;
+ using DamagedRectsContainer = std::list<std::vector<Rect<int>>>;
/**
* Uses an window surface to render to.
* @param [in] surface can be a window or pixmap.
* @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
*/
- WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
+ WindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false);
/**
* @brief Destructor
virtual ~WindowRenderSurface();
public: // API
-
/**
* @brief Get the native window handle
* @return The native window handle
* @brief Sets the render notification trigger to call when render thread is completed a frame
* @param renderNotification to use
*/
- void SetRenderNotification( TriggerEventInterface* renderNotification );
+ void SetRenderNotification(TriggerEventInterface* renderNotification);
/**
* @brief Sets whether the surface is transparent or not.
* @param[in] transparent Whether the surface is transparent
*/
- void SetTransparency( bool transparent );
+ void SetTransparency(bool transparent);
/**
* Request surface rotation
* @param[in] width A new width of the surface
* @param[in] height A new height of the surface
*/
- void RequestRotation( int angle, int width, int height );
+ void RequestRotation(int angle, int width, int height);
/**
* @brief Gets the window base object
OutputSignalType& OutputTransformedSignal();
public: // from Dali::RenderSurfaceInterface
-
/**
* @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
*/
/**
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetOrientation()
/**
* @copydoc Dali::RenderSurfaceInterface::MoveResize()
*/
- void MoveResize( Dali::PositionSize positionSize) override;
+ void MoveResize(Dali::PositionSize positionSize) override;
/**
* @copydoc Dali::RenderSurfaceInterface::StartRender()
/**
* @copydoc Dali::RenderSurfaceInterface::PreRender()
*/
- bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
+ bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
/**
* @copydoc Dali::RenderSurfaceInterface::PostRender()
*/
- void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
+ void PostRender(bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects) override;
/**
* @copydoc Dali::RenderSurfaceInterface::StopRender()
/**
* @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
*/
- void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
+ void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
/**
* @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
Integration::StencilBufferAvailable GetStencilBufferRequired() override;
private:
-
/**
* @brief Second stage construction
*/
- void Initialize( Any surface );
+ void Initialize(Any surface);
/**
* Notify output is transformed.
* @param[in] eventBitMask bit mask of events that occured on the file descriptor
* @param[in] fileDescriptor The file descriptor
*/
- void OnFileDescriptorEventDispatched( FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor );
+ void OnFileDescriptorEventDispatched(FileDescriptorMonitor::EventType eventBitMask, int fileDescriptor);
/**
* @brief Set the buffer damage rects.
* @param[in] damagedRects List of damaged rects
* @param[in] clippingRect The rect to clip rendered scene
*/
- void SetBufferDamagedRects( const std::vector< Rect< int > >& damagedRects, Rect< int >& clippingRect );
+ void SetBufferDamagedRects(const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect);
/**
* @brief Swap buffers.
* @param[in] damagedRects List of damaged rects
*/
- void SwapBuffers( const std::vector<Rect<int>>& damagedRects );
+ void SwapBuffers(const std::vector<Rect<int>>& damagedRects);
protected:
-
// Undefined
WindowRenderSurface(const WindowRenderSurface&) = delete;
WindowRenderSurface& operator=(const WindowRenderSurface& rhs) = delete;
private:
-
struct FrameCallbackInfo
{
- FrameCallbackInfo( Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd )
+ FrameCallbackInfo(Dali::Integration::Scene::FrameCallbackContainer& callbackList, int fd)
: callbacks(),
fileDescriptorMonitor(),
- fileDescriptor( fd )
+ fileDescriptor(fd)
{
// Transfer owership of the CallbackBase
- for( auto&& iter : callbackList )
+ for(auto&& iter : callbackList)
{
- callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
+ callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
}
}
{
// Delete FileDescriptorMonitor before close fd.
fileDescriptorMonitor.release();
- close( fileDescriptor );
+ close(fileDescriptor);
}
Dali::Integration::Scene::FrameCallbackContainer callbacks;
- std::unique_ptr< FileDescriptorMonitor > fileDescriptorMonitor;
- int fileDescriptor;
+ std::unique_ptr<FileDescriptorMonitor> fileDescriptorMonitor;
+ int fileDescriptor;
};
- using FrameCallbackInfoContainer = std::vector< std::unique_ptr< FrameCallbackInfo > >;
+ using FrameCallbackInfoContainer = std::vector<std::unique_ptr<FrameCallbackInfo>>;
private: // Data
-
- EglInterface* mEGL;
- Dali::DisplayConnection* mDisplayConnection;
- PositionSize mPositionSize; ///< Position
- std::unique_ptr< WindowBase > mWindowBase;
- ThreadSynchronizationInterface* mThreadSynchronization;
- TriggerEventInterface* mRenderNotification; ///< Render notification trigger
- TriggerEventInterface* mRotationTrigger;
- std::unique_ptr< TriggerEventInterface > mFrameRenderedTrigger;
- GraphicsInterface* mGraphics; ///< Graphics interface
- EGLSurface mEGLSurface;
- EGLContext mEGLContext;
- ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
- OutputSignalType mOutputTransformedSignal;
- FrameCallbackInfoContainer mFrameCallbackInfoContainer;
- DamagedRectsContainer mBufferDamagedRects;
- Dali::Mutex mMutex;
- int mWindowRotationAngle;
- int mScreenRotationAngle;
- uint32_t mDpiHorizontal;
- uint32_t mDpiVertical;
- bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
- bool mWindowRotationFinished;
- bool mScreenRotationFinished;
- bool mResizeFinished;
- bool mDefaultScreenRotationAvailable;
+ EglInterface* mEGL;
+ Dali::DisplayConnection* mDisplayConnection;
+ PositionSize mPositionSize; ///< Position
+ std::unique_ptr<WindowBase> mWindowBase;
+ ThreadSynchronizationInterface* mThreadSynchronization;
+ TriggerEventInterface* mRenderNotification; ///< Render notification trigger
+ TriggerEventInterface* mRotationTrigger;
+ std::unique_ptr<TriggerEventInterface> mFrameRenderedTrigger;
+ GraphicsInterface* mGraphics; ///< Graphics interface
+ EGLSurface mEGLSurface;
+ EGLContext mEGLContext;
+ ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
+ OutputSignalType mOutputTransformedSignal;
+ FrameCallbackInfoContainer mFrameCallbackInfoContainer;
+ DamagedRectsContainer mBufferDamagedRects;
+ Dali::Mutex mMutex;
+ int mWindowRotationAngle;
+ int mScreenRotationAngle;
+ uint32_t mDpiHorizontal;
+ uint32_t mDpiVertical;
+ bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
+ bool mWindowRotationFinished;
+ bool mScreenRotationFinished;
+ bool mResizeFinished;
+ bool mDefaultScreenRotationAvailable;
}; // class WindowRenderSurface
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_SYSTEM_H
/*
- * 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
{
-
namespace WindowSystem
{
-
/**
* @brief Initialize a window system
*/
/**
* @brief Get the screen size
*/
-void GetScreenSize( int& width, int& height );
+void GetScreenSize(int& width, int& height);
/**
* @copydoc Dali::Keyboard::SetRepeatInfo()
*/
-bool SetKeyboardRepeatInfo( float rate, float delay );
+bool SetKeyboardRepeatInfo(float rate, float delay);
/**
* @copydoc Dali::Keyboard::GetRepeatInfo()
*/
-bool GetKeyboardRepeatInfo( float& rate, float& delay );
+bool GetKeyboardRepeatInfo(float& rate, float& delay);
} // namespace WindowSystem
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
#endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_SYSTEM_H
#define DALI_INTERNAL_WINDOW_VISIBILITY_OBSERVER_H
/*
- * 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
{
-
/**
* An interface used to observe when the application's window is shown/hidden.
*/
class WindowVisibilityObserver
{
public:
-
/**
* Called when the window becomes fully or partially visible.
*/
virtual void OnWindowHidden() = 0;
protected:
-
/**
* Protected Constructor.
*/
${adaptor_window_system_dir}/common/window-impl.cpp
${adaptor_window_system_dir}/common/window-render-surface.cpp
${adaptor_window_system_dir}/common/gl-window-impl.cpp
+ ${adaptor_window_system_dir}/common/gl-window-render-thread.cpp
)
# module: window-system, backend: tizen-wayland
${adaptor_window_system_dir}/windows/window-factory-win.cpp
${adaptor_window_system_dir}/windows/window-system-win.cpp
)
+
+# module: window-system, backend: macos
+SET( adaptor_window_system_macos_src_files
+ ${adaptor_window_system_dir}/macos/display-connection-factory-mac.cpp
+ ${adaptor_window_system_dir}/macos/display-connection-impl-mac.cpp
+ ${adaptor_window_system_dir}/macos/window-render-surface-cocoa.cpp
+ ${adaptor_window_system_dir}/macos/window-system-mac.mm
+ ${adaptor_window_system_dir}/macos/window-base-mac.mm
+ ${adaptor_window_system_dir}/macos/window-factory-mac.cpp
+ ${adaptor_window_system_dir}/macos/render-surface-factory-mac.cpp
+)
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/macos/display-connection-factory-mac.h>
+#include <dali/internal/window-system/macos/display-connection-impl-mac.h>
+
+namespace Dali::Internal::Adaptor
+{
+std::unique_ptr<DisplayConnection>
+DisplayConnectionFactoryCocoa::CreateDisplayConnection()
+{
+ return Utils::MakeUnique<DisplayConnectionCocoa>();
+}
+
+std::unique_ptr<DisplayConnectionFactory>
+GetDisplayConnectionFactory()
+{
+ return Utils::MakeUnique<DisplayConnectionFactoryCocoa>();
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/window-system/common/display-connection-factory.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali::Internal::Adaptor
+{
+class DisplayConnectionFactoryCocoa : public DisplayConnectionFactory
+{
+public:
+ std::unique_ptr<DisplayConnection> CreateDisplayConnection() override;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <EGL/egl.h>
+#include <dali/internal/window-system/macos/display-connection-impl-mac.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-graphics.h>
+
+namespace Dali::Internal::Adaptor
+{
+DisplayConnection* DisplayConnectionCocoa::New()
+{
+ return new DisplayConnectionCocoa();
+}
+
+DisplayConnectionCocoa::DisplayConnectionCocoa()
+: mGraphics(nullptr)
+{
+}
+
+DisplayConnectionCocoa::~DisplayConnectionCocoa()
+{
+}
+
+Any DisplayConnectionCocoa::GetDisplay()
+{
+ return EGL_DEFAULT_DISPLAY;
+}
+
+void DisplayConnectionCocoa::ConsumeEvents()
+{
+}
+
+bool DisplayConnectionCocoa::InitializeEgl(EglInterface& egl)
+{
+ EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
+
+ if(!eglImpl.InitializeGles(EGL_DEFAULT_DISPLAY))
+ {
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");
+ return false;
+ }
+
+ return true;
+}
+
+bool DisplayConnectionCocoa::InitializeGraphics()
+{
+ auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
+ EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+
+ if(!eglImpl.InitializeGles(EGL_DEFAULT_DISPLAY))
+ {
+ DALI_LOG_ERROR("Failed to initialize GLES.\n");
+ return false;
+ }
+
+ return true;
+}
+
+void DisplayConnectionCocoa::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)
+{
+}
+
+void DisplayConnectionCocoa::SetGraphicsInterface(GraphicsInterface& graphics)
+{
+ mGraphics = &graphics;
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/internal/window-system/common/display-connection-impl.h>
+#include <dali/public-api/object/base-object.h>
+
+namespace Dali::Internal::Adaptor
+{
+/**
+ * DisplayConnection implementation
+ */
+class DisplayConnectionCocoa : public Dali::Internal::Adaptor::DisplayConnection
+{
+public:
+ /**
+ * @brief Default constructor
+ */
+ DisplayConnectionCocoa();
+
+ /**
+ * @brief Create an initialized DisplayConnection.
+ *
+ * @return A handle to a newly allocated DisplayConnection resource.
+ */
+ static DisplayConnection* New();
+
+public:
+ /**
+ * @copydoc Dali::DisplayConnection::GetDisplay
+ */
+ Any GetDisplay();
+
+ /**
+ * @copydoc Dali::DisplayConnection::ConsumeEvents
+ */
+ void ConsumeEvents();
+
+ /**
+ * @copydoc Dali::DisplayConnection::InitializeEgl
+ */
+ bool InitializeEgl(EglInterface& egl);
+
+ /**
+ * @copydoc Dali::DisplayConnection::InitializeGraphics
+ */
+ bool InitializeGraphics();
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::DisplayConnection::SetSurfaceType
+ */
+ void SetSurfaceType(Dali::RenderSurfaceInterface::Type type);
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::DisplayConnection::SetGraphicsInterface
+ */
+ void SetGraphicsInterface(GraphicsInterface& graphics);
+
+public:
+ /**
+ * Destructor
+ */
+ virtual ~DisplayConnectionCocoa();
+
+private:
+ // Undefined
+ DisplayConnectionCocoa(const DisplayConnectionCocoa&) = delete;
+
+ // Undefined
+ DisplayConnectionCocoa& operator=(const DisplayConnectionCocoa& rhs) = delete;
+
+private:
+ GraphicsInterface* mGraphics; ///< The graphics interface
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/macos/render-surface-factory-mac.h>
+
+// EXTERNAL HEADERS
+#include <dali/integration-api/debug.h>
+
+// INTERNAL HEADERS
+#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 "window-render-surface-cocoa.h"
+
+namespace Dali::Internal::Adaptor
+{
+std::unique_ptr<WindowRenderSurface>
+RenderSurfaceFactoryCocoa::CreateWindowRenderSurface(
+ Dali::PositionSize positionSize,
+ Any surface,
+ bool isTransparent)
+{
+ return Utils::MakeUnique<WindowRenderSurfaceCocoa>(positionSize, surface, isTransparent);
+}
+
+std::unique_ptr<PixmapRenderSurface>
+RenderSurfaceFactoryCocoa::CreatePixmapRenderSurface(
+ Dali::PositionSize positionSize,
+ Any surface,
+ bool isTransparent)
+{
+ DALI_LOG_ERROR("Pixmap isn't been supported in Windows");
+ return nullptr;
+}
+
+std::unique_ptr<NativeRenderSurface>
+RenderSurfaceFactoryCocoa::CreateNativeRenderSurface(
+ SurfaceSize surfaceSize,
+ Any surface,
+ bool isTransparent)
+{
+ return std::unique_ptr<NativeRenderSurface>(nullptr);
+}
+
+// this should be created from somewhere
+std::unique_ptr<RenderSurfaceFactory> GetRenderSurfaceFactory()
+{
+ // returns Window factory
+ return Utils::MakeUnique<RenderSurfaceFactoryCocoa>();
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/window-system/common/render-surface-factory.h>
+
+namespace Dali::Internal::Adaptor
+{
+class RenderSurfaceFactoryCocoa : public RenderSurfaceFactory
+{
+public:
+ std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(
+ Dali::PositionSize positionSize,
+ Any surface,
+ bool isTransparent = false) override;
+
+ std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(
+ Dali::PositionSize positionSize,
+ Any surface,
+ bool isTransparent = false) override;
+
+ std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(
+ SurfaceSize surfaceSize,
+ Any surface,
+ bool isTransparent = false) override;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/window-base.h>
+#include <memory>
+
+namespace Dali::Internal::Adaptor
+{
+/**
+ * WindowBaseCocoa class provides an WindowBase Win32 implementation.
+ */
+class WindowBaseCocoa : public WindowBase
+{
+public:
+ struct Impl;
+
+ /**
+ * @brief Constructor
+ */
+ WindowBaseCocoa(PositionSize positionSize, Any surface, bool isTransparent);
+
+ /**
+ * @brief Destructor
+ */
+ ~WindowBaseCocoa();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
+ */
+ Any GetNativeWindow() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
+ */
+ int GetNativeWindowId() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
+ */
+ EGLNativeWindowType CreateEglWindow(int width, int height) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
+ */
+ void DestroyEglWindow() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
+ */
+ void SetEglWindowRotation(int angle) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
+ */
+ void SetEglWindowBufferTransform(int angle) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
+ */
+ void SetEglWindowTransform(int angle) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
+ */
+ void ResizeEglWindow(PositionSize positionSize) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
+ */
+ bool IsEglWindowRotationSupported() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
+ */
+ void Move(PositionSize positionSize) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
+ */
+ void Resize(PositionSize positionSize) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
+ */
+ void MoveResize(PositionSize positionSize) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
+ */
+ void SetClass(const std::string& name, const std::string& className) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
+ */
+ void Raise() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
+ */
+ void Lower() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
+ */
+ void Activate() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
+ */
+ void SetAvailableAnlges(const std::vector<int>& angles) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
+ */
+ void SetPreferredAngle(int angle) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
+ */
+ void SetAcceptFocus(bool accept) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
+ */
+ void Show() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
+ */
+ void Hide() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
+ */
+ unsigned int GetSupportedAuxiliaryHintCount() const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
+ */
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
+ */
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
+ */
+ bool RemoveAuxiliaryHint(unsigned int id) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
+ */
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
+ */
+ std::string GetAuxiliaryHintValue(unsigned int id) const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
+ */
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
+ */
+ void SetInputRegion(const Rect<int>& inputRegion) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
+ */
+ void SetType(Dali::WindowType type) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
+ */
+ bool SetNotificationLevel(WindowNotificationLevel level) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
+ */
+ WindowNotificationLevel GetNotificationLevel() const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
+ */
+ void SetOpaqueState(bool opaque) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
+ */
+ bool SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
+ */
+ WindowScreenOffMode GetScreenOffMode() const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
+ */
+ bool SetBrightness(int brightness) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
+ */
+ int GetBrightness() const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
+ */
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
+ */
+ bool UngrabKey(Dali::KEY key) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
+ */
+ bool GrabKeyList(
+ const Dali::Vector<Dali::KEY>& key,
+ const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode,
+ Dali::Vector<bool>& result) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
+ */
+ bool UngrabKeyList(
+ const Dali::Vector<Dali::KEY>& key,
+ Dali::Vector<bool>& result) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
+ */
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
+ */
+ int GetOrientation() const override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
+ */
+ int GetScreenRotationAngle() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
+ */
+ void SetWindowRotationAngle(int degree) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
+ */
+ void WindowRotationCompleted(int degree, int width, int height) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
+ */
+ void SetTransparency(bool transparent) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
+ */
+ void SetParent(WindowBase* parentWinBase) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
+ */
+ int CreateFrameRenderedSyncFence() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
+ */
+ int CreateFramePresentedSyncFence() override;
+
+private:
+ // Undefined
+ WindowBaseCocoa(const WindowBaseCocoa&) = delete;
+
+ // Undefined
+ WindowBaseCocoa& operator=(const WindowBaseCocoa& rhs) = delete;
+
+private:
+ std::unique_ptr<Impl> mImpl;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "dali/public-api/adaptor-framework/window.h"
+#include "dali/public-api/events/wheel-event.h"
+#include <Carbon/Carbon.h>
+#import <Cocoa/Cocoa.h>
+
+// CLASS HEADER
+#include <dali/internal/window-system/macos/window-base-mac.h>
+
+// EXTERNAL_HEADERS
+#include <dali/public-api/object/any.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/window-system/common/window-impl.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
+
+#include <cmath>
+
+using Dali::Internal::Adaptor::WindowBaseCocoa;
+
+// Angle is default selecting CGL as its backend and because
+// of that we are using NSOpenGLView. Ideally we should use
+// Metal as the backend. When this happends, we must change
+// the parent class to MTKView.
+@interface CocoaView : NSOpenGLView
+- (CocoaView *) initWithFrame:(NSRect) rect withImpl:(WindowBaseCocoa::Impl *) impl;
+- (BOOL) isFlipped;
+- (BOOL) wantsUpdateLayer;
+- (BOOL) acceptsFirstResponder;
+- (void) mouseDown:(NSEvent *) event;
+- (void) mouseUp:(NSEvent *) event;
+- (void) mouseDragged:(NSEvent *) event;
+- (void) keyDown:(NSEvent *) event;
+- (void) keyUp:(NSEvent *) event;
+- (void) drawRect:(NSRect) dirtyRect;
+- (void) prepareOpenGL;
+@end
+
+@interface WindowDelegate : NSObject <NSWindowDelegate>
+- (WindowDelegate *) init:(WindowBaseCocoa::Impl *) impl;
+- (void) windowDidBecomeKey:(NSNotification *) notification;
+- (void) windowDidResignKey:(NSNotification *) notification;
+- (void) windowWillClose:(NSNotification *) notification;
+@end
+
+namespace Dali::Internal::Adaptor
+{
+
+namespace
+{
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+#endif
+
+// Converts a y coordinate from top to bottom coordinate
+CGFloat BottomYCoordinate(CGFloat topYCoordinate, CGFloat windowHeight) noexcept
+{
+ const auto screen = [NSScreen.mainScreen frame];
+ return screen.size.height - windowHeight - topYCoordinate;
+}
+
+NSRect PositionSizeToRect(const PositionSize &positionSize, bool flipped = false) noexcept
+{
+ // positionSize assumes top-left coordinate system
+ // Cocoa assumes bottom-left coordinate system
+ // If NSView isFlipped method returns YES, then it uses top-left coordinate system
+ const auto windowHeight = static_cast<CGFloat>(positionSize.height);
+ const auto yGiven = static_cast<CGFloat>(positionSize.y);
+
+ CGFloat yWindow;
+ if (flipped)
+ {
+ yWindow = yGiven;
+ }
+ else
+ {
+ yWindow = BottomYCoordinate(yGiven, windowHeight);
+ }
+
+ return
+ {
+ .origin =
+ {
+ .x = static_cast<CGFloat>(positionSize.x),
+ .y = yWindow
+ },
+ .size =
+ {
+ .width = static_cast<CGFloat>(positionSize.width),
+ .height = windowHeight,
+ },
+ };
+}
+
+} // unnamed namespace
+
+struct WindowBaseCocoa::Impl final
+{
+ NSWindow *mWindow;
+ NSWindowController *mWinController;
+ WindowBaseCocoa *mThis;
+
+ Impl(const Impl &rhs) = delete;
+ Impl &operator<(const Impl &rhs) = delete;
+ Impl(const Impl &&rhs) = delete;
+ Impl &operator<(const Impl &&rhs) = delete;
+
+ Impl(
+ WindowBaseCocoa *pThis,
+ PositionSize positionSize,
+ Any surface,
+ bool isTransparent
+ );
+
+ ~Impl();
+
+ void OnFocus(bool focus)
+ {
+ mThis->mFocusChangedSignal.Emit(focus);
+ }
+
+ // Handle mouse events
+ void OnMouse(NSEvent *event, PointState::Type state);
+ void OnMouseWheel(NSEvent *event);
+ void OnKey(NSEvent *event, Integration::KeyEvent::State keyState);
+ void OnWindowDamaged(const NSRect &rect);
+
+ void OnRedraw(void)
+ {
+ mThis->mWindowRedrawRequestSignal.Emit();
+ }
+
+private:
+ uint32_t GetKeyModifiers(NSEvent *event) const noexcept;
+ std::string GetKeyName(NSEvent *event) const;
+};
+
+WindowBaseCocoa::Impl::Impl(
+ WindowBaseCocoa *pThis,
+ PositionSize positionSize,
+ Any surface,
+ bool isTransparent
+) : mThis(pThis)
+{
+ constexpr NSUInteger style =
+ NSWindowStyleMaskTitled
+ | NSWindowStyleMaskClosable
+ | NSWindowStyleMaskMiniaturizable
+ | NSWindowStyleMaskResizable;
+
+ mWindow = [[NSWindow alloc] initWithContentRect:PositionSizeToRect(positionSize)
+ styleMask:style
+ backing:NSBackingStoreBuffered
+ defer:NO];
+
+ mWindow.alphaValue = static_cast<CGFloat>(!isTransparent);
+ mWinController = [[NSWindowController alloc] initWithWindow:mWindow];
+
+ mWindow.delegate = [[WindowDelegate alloc] init:this];
+
+ NSView *view = [[CocoaView alloc] initWithFrame:PositionSizeToRect(positionSize, true)
+ withImpl:this];
+ NSPoint origin{0, 0};
+ [view setFrameOrigin:origin];
+
+ mWindow.contentView = view;
+
+ [mWindow makeKeyAndOrderFront:nil];
+}
+
+WindowBaseCocoa::Impl::~Impl()
+{
+ [mWinController close];
+ [NSApp stop:nil];
+}
+
+void WindowBaseCocoa::Impl::OnMouse(NSEvent *event, PointState::Type state)
+{
+ Integration::Point point;
+ point.SetDeviceId(event.deviceID);
+ point.SetState(state);
+ auto p = [event locationInWindow];
+ auto [x, y] = [mWindow.contentView convertPoint:p fromView:nil];
+ point.SetScreenPosition(Vector2(x, y));
+ point.SetRadius(std::sqrt(x*x + y*y));
+ point.SetPressure(event.pressure);
+
+ if (x == 0.0)
+ {
+ point.SetAngle(Degree(0.0));
+ }
+ else
+ {
+ point.SetAngle(Radian(std::atan(y/x)));
+ }
+
+ DALI_LOG_INFO(
+ gWindowBaseLogFilter,
+ Debug::Verbose,
+ "WindowBaseCocoa::Impl::OnMouse(%.1f, %.1f)\n",
+ x,
+ y
+ );
+
+ // timestamp is given in seconds, the signal expects it in milliseconds
+ mThis->mTouchEventSignal.Emit(point, event.timestamp * 1000);
+}
+
+void WindowBaseCocoa::Impl::OnMouseWheel(NSEvent *event)
+{
+ auto p = [event locationInWindow];
+ auto [x, y] = [mWindow.contentView convertPoint:p fromView:nil];
+
+ const auto modifiers = GetKeyModifiers(event);
+ const Vector2 vec(x, y);
+ const auto timestamp = event.timestamp * 1000;
+
+ if (event.scrollingDeltaY)
+ {
+ Integration::WheelEvent wheelEvent(
+ Integration::WheelEvent::MOUSE_WHEEL,
+ 0,
+ modifiers,
+ vec,
+ event.scrollingDeltaY < 0 ? -1 : 1,
+ timestamp
+ );
+
+ mThis->mWheelEventSignal.Emit(wheelEvent);
+ }
+
+ if (event.scrollingDeltaX)
+ {
+ Integration::WheelEvent wheelEvent(
+ Integration::WheelEvent::MOUSE_WHEEL,
+ 0,
+ modifiers,
+ vec,
+ event.scrollingDeltaX < 0 ? -1 : 1,
+ timestamp
+ );
+
+ mThis->mWheelEventSignal.Emit(wheelEvent);
+ }
+}
+
+void WindowBaseCocoa::Impl::OnKey(NSEvent *event, Integration::KeyEvent::State keyState)
+{
+ const std::string empty;
+
+ Integration::KeyEvent keyEvent(
+ GetKeyName(event),
+ empty,
+ [event.characters UTF8String],
+ event.keyCode,
+ GetKeyModifiers(event),
+ event.timestamp * 1000,
+ keyState,
+ empty,
+ empty,
+ Device::Class::NONE,
+ Device::Subclass::NONE
+ );
+
+ DALI_LOG_INFO(
+ gWindowBaseLogFilter,
+ Debug::Verbose,
+ "WindowBaseCocoa::Impl::OnKey(%s)\n",
+ [event.characters UTF8String]
+ );
+
+ mThis->mKeyEventSignal.Emit(keyEvent);
+}
+
+void WindowBaseCocoa::Impl::OnWindowDamaged(const NSRect &rect)
+{
+ const DamageArea area(
+ rect.origin.x,
+ rect.origin.y,
+ rect.size.width,
+ rect.size.height
+ );
+
+ mThis->mWindowDamagedSignal.Emit(area);
+}
+
+uint32_t WindowBaseCocoa::Impl::GetKeyModifiers(NSEvent *event) const noexcept
+{
+ uint32_t modifiers = 0;
+
+ if (event.modifierFlags & NSEventModifierFlagShift)
+ {
+ modifiers |= 1;
+ }
+
+ if (event.modifierFlags & NSEventModifierFlagControl)
+ {
+ modifiers |= 2;
+ }
+
+ if (event.modifierFlags & NSEventModifierFlagCommand)
+ {
+ modifiers |= 4;
+ }
+
+ return modifiers;
+}
+
+std::string WindowBaseCocoa::Impl::GetKeyName(NSEvent *event) const
+{
+ switch (event.keyCode)
+ {
+ case kVK_Control: return "Control";
+ case kVK_Shift: return "Shift";
+ case kVK_Delete: return "Backspace";
+ case kVK_Command: return "Command";
+ case kVK_Tab: return "Tab";
+ case kVK_Return: return "Return";
+ case kVK_Escape: return "Escape";
+ case kVK_Space: return "Space";
+ case kVK_LeftArrow: return "Left";
+ case kVK_UpArrow: return "Up";
+ case kVK_RightArrow: return "Right";
+ case kVK_DownArrow: return "Down";
+ case kVK_ANSI_0: return "0";
+ case kVK_ANSI_1: return "1";
+ case kVK_ANSI_2: return "2";
+ case kVK_ANSI_3: return "3";
+ case kVK_ANSI_4: return "4";
+ case kVK_ANSI_5: return "5";
+ case kVK_ANSI_6: return "6";
+ case kVK_ANSI_7: return "7";
+ case kVK_ANSI_8: return "8";
+ case kVK_ANSI_9: return "9";
+ default: return [event.characters UTF8String];
+ }
+
+ return "";
+}
+
+WindowBaseCocoa::WindowBaseCocoa(PositionSize positionSize, Any surface, bool isTransparent)
+ : mImpl(std::make_unique<Impl>(this, positionSize, surface, isTransparent))
+{
+}
+
+WindowBaseCocoa::~WindowBaseCocoa()
+{
+}
+
+Any WindowBaseCocoa::GetNativeWindow()
+{
+ return mImpl->mWindow;
+}
+
+int WindowBaseCocoa::GetNativeWindowId()
+{
+ return mImpl->mWindow.windowNumber;
+}
+
+EGLNativeWindowType WindowBaseCocoa::CreateEglWindow(int width, int height)
+{
+ // XXX: this method is called from a secondary thread, but
+ // we can only resize the window from the main thread
+ //PositionSize size(0, 0, width, height);
+ //Resize(size);
+ return mImpl->mWindow.contentView.layer;
+}
+
+void WindowBaseCocoa::DestroyEglWindow()
+{
+}
+
+void WindowBaseCocoa::SetEglWindowRotation( int angle )
+{
+}
+
+void WindowBaseCocoa::SetEglWindowBufferTransform( int angle )
+{
+}
+
+void WindowBaseCocoa::SetEglWindowTransform( int angle )
+{
+}
+
+void WindowBaseCocoa::ResizeEglWindow( PositionSize positionSize )
+{
+ Resize(positionSize);
+}
+
+bool WindowBaseCocoa::IsEglWindowRotationSupported()
+{
+ return false;
+}
+
+void WindowBaseCocoa::Move( PositionSize positionSize )
+{
+ const NSPoint p = {
+ .x = static_cast<CGFloat>(positionSize.x),
+ .y = static_cast<CGFloat>(positionSize.y),
+ };
+
+ [mImpl->mWindow setFrameTopLeftPoint:p];
+}
+
+void WindowBaseCocoa::Resize( PositionSize positionSize )
+{
+ auto r = mImpl->mWindow.frame;
+ r.size.width = static_cast<CGFloat>(positionSize.width);
+ r.size.height = static_cast<CGFloat>(positionSize.height);
+ [mImpl->mWindow setFrame:r display:YES];
+
+ NSSize size =
+ {
+ .width = r.size.width,
+ .height = r.size.height,
+ };
+
+ [mImpl->mWindow.contentView setFrameSize:size];
+
+}
+
+void WindowBaseCocoa::MoveResize( PositionSize positionSize )
+{
+ [mImpl->mWindow setFrame: PositionSizeToRect(positionSize) display:YES];
+
+ NSSize size =
+ {
+ .width = static_cast<CGFloat>(positionSize.width),
+ .height = static_cast<CGFloat>(positionSize.height),
+ };
+
+ [mImpl->mWindow.contentView setFrameSize:size];
+}
+
+void WindowBaseCocoa::SetClass( const std::string& name, const std::string& className )
+{
+}
+
+void WindowBaseCocoa::Raise()
+{
+ [mImpl->mWindow orderFront:nil];
+}
+
+void WindowBaseCocoa::Lower()
+{
+ [mImpl->mWindow orderBack:nil];
+}
+
+void WindowBaseCocoa::Activate()
+{
+ [mImpl->mWinController showWindow:nil];
+}
+
+void WindowBaseCocoa::SetAvailableAnlges( const std::vector< int >& angles )
+{
+}
+
+void WindowBaseCocoa::SetPreferredAngle( int angle )
+{
+}
+
+void WindowBaseCocoa::SetAcceptFocus( bool accept )
+{
+}
+
+void WindowBaseCocoa::Show()
+{
+ [mImpl->mWinController showWindow:nil];
+}
+
+void WindowBaseCocoa::Hide()
+{
+ [mImpl->mWindow orderOut:nil];
+}
+
+unsigned int WindowBaseCocoa::GetSupportedAuxiliaryHintCount() const
+{
+ return 0;
+}
+
+std::string WindowBaseCocoa::GetSupportedAuxiliaryHint( unsigned int index ) const
+{
+ return std::string();
+}
+
+unsigned int WindowBaseCocoa::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+{
+ return 0;
+}
+
+bool WindowBaseCocoa::RemoveAuxiliaryHint( unsigned int id )
+{
+ return false;
+}
+
+bool WindowBaseCocoa::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+{
+ return false;
+}
+
+std::string WindowBaseCocoa::GetAuxiliaryHintValue( unsigned int id ) const
+{
+ return std::string();
+}
+
+unsigned int WindowBaseCocoa::GetAuxiliaryHintId( const std::string& hint ) const
+{
+ return 0;
+}
+
+void WindowBaseCocoa::SetInputRegion( const Rect< int >& inputRegion )
+{
+}
+
+void WindowBaseCocoa::SetType( Dali::WindowType type )
+{
+}
+
+bool WindowBaseCocoa::SetNotificationLevel( WindowNotificationLevel level )
+{
+ return false;
+}
+
+WindowNotificationLevel WindowBaseCocoa::GetNotificationLevel() const
+{
+ return WindowNotificationLevel::NONE;
+}
+
+void WindowBaseCocoa::SetOpaqueState( bool opaque )
+{
+}
+
+bool WindowBaseCocoa::SetScreenOffMode(WindowScreenOffMode screenOffMode)
+{
+ return false;
+}
+
+WindowScreenOffMode WindowBaseCocoa::GetScreenOffMode() const
+{
+ return WindowScreenOffMode::TIMEOUT;
+}
+
+bool WindowBaseCocoa::SetBrightness( int brightness )
+{
+ return false;
+}
+
+int WindowBaseCocoa::GetBrightness() const
+{
+ return 0;
+}
+
+bool WindowBaseCocoa::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+{
+ return false;
+}
+
+bool WindowBaseCocoa::UngrabKey( Dali::KEY key )
+{
+ return false;
+}
+
+bool WindowBaseCocoa::GrabKeyList(
+ const Dali::Vector< Dali::KEY >& key,
+ const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode,
+ Dali::Vector< bool >& result
+)
+{
+ return false;
+}
+
+bool WindowBaseCocoa::UngrabKeyList(
+ const Dali::Vector< Dali::KEY >& key,
+ Dali::Vector< bool >& result
+)
+{
+ return false;
+}
+
+void WindowBaseCocoa::GetDpi(
+ unsigned int& dpiHorizontal,
+ unsigned int& dpiVertical
+)
+{
+ auto *screen = [NSScreen mainScreen];
+ NSSize res = [screen.deviceDescription[NSDeviceResolution] sizeValue];
+ dpiHorizontal = res.width;
+ dpiVertical = res.height;
+}
+
+int WindowBaseCocoa::GetOrientation() const
+{
+ return 0;
+}
+
+int WindowBaseCocoa::GetScreenRotationAngle()
+{
+ return 0;
+}
+
+void WindowBaseCocoa::SetWindowRotationAngle( int degree )
+{
+}
+
+void WindowBaseCocoa::WindowRotationCompleted( int degree, int width, int height )
+{
+}
+
+void WindowBaseCocoa::SetTransparency( bool transparent )
+{
+ mImpl->mWindow.alphaValue = static_cast<CGFloat>(!transparent);
+}
+
+void WindowBaseCocoa::SetParent( WindowBase* parentWinBase )
+{
+ auto &parent = dynamic_cast<WindowBaseCocoa&>(*parentWinBase);
+ [mImpl->mWindow setParentWindow:parent.mImpl->mWindow];
+}
+
+int WindowBaseCocoa::CreateFrameRenderedSyncFence()
+{
+ return -1;
+}
+
+int WindowBaseCocoa::CreateFramePresentedSyncFence()
+{
+ return -1;
+}
+
+} // namespace Dali::Internal::Adaptor
+
+@implementation CocoaView
+{
+ WindowBaseCocoa::Impl *mImpl;
+}
+
+- (CocoaView *) initWithFrame:(NSRect) rect withImpl:(WindowBaseCocoa::Impl *) impl
+{
+ self = [super initWithFrame:rect];
+ if (self)
+ {
+ mImpl = impl;
+ self.wantsLayer = YES;
+ self.wantsBestResolutionOpenGLSurface = NO;
+ }
+
+ return self;
+}
+
+- (BOOL) isFlipped
+{
+ return YES;
+}
+
+- (BOOL) wantsUpdateLayer
+{
+ return YES;
+}
+
+- (BOOL) acceptsFirstResponder
+{
+ return YES;
+}
+
+- (void) mouseDown:(NSEvent *) event
+{
+ mImpl->OnMouse(event, Dali::PointState::DOWN);
+}
+
+- (void) mouseUp:(NSEvent *) event
+{
+ mImpl->OnMouse(event, Dali::PointState::UP);
+}
+
+- (void) mouseDragged:(NSEvent *) event
+{
+ mImpl->OnMouse(event, Dali::PointState::MOTION);
+}
+
+- (void) keyDown:(NSEvent *) event
+{
+ mImpl->OnKey(event, Dali::Integration::KeyEvent::DOWN);
+}
+
+- (void) keyUp:(NSEvent *) event
+{
+ mImpl->OnKey(event, Dali::Integration::KeyEvent::UP);
+}
+
+- (void) drawRect:(NSRect) dirtyRect
+{
+ DALI_LOG_INFO(
+ Dali::Internal::Adaptor::gWindowBaseLogFilter,
+ Debug::Verbose,
+ "-[CocoaView drawRect:(%.1f, %.1f, %.1f, %.1f)]\n",
+ dirtyRect.origin.x,
+ dirtyRect.origin.y,
+ dirtyRect.size.width,
+ dirtyRect.size.height
+ );
+
+ mImpl->OnWindowDamaged(dirtyRect);
+}
+
+- (void) prepareOpenGL
+{
+ auto ctx = CGLGetCurrentContext();
+ DALI_ASSERT_ALWAYS(ctx);
+
+ // Enable multithreading
+ if (auto err = CGLEnable(ctx, kCGLCEMPEngine); err != kCGLNoError)
+ {
+ DALI_LOG_ERROR("%s - %s", __PRETTY_FUNCTION__, CGLErrorString(err));
+ }
+}
+@end
+
+@implementation WindowDelegate
+{
+ WindowBaseCocoa::Impl *mImpl;
+}
+
+- (WindowDelegate *) init:(Dali::Internal::Adaptor::WindowBaseCocoa::Impl *) impl
+{
+ self = [super init];
+ if (self)
+ {
+ mImpl = impl;
+ }
+ return self;
+}
+
+- (void) windowDidBecomeKey:(NSNotification *) notification
+{
+ mImpl->OnFocus(true);
+}
+
+- (void) windowDidResignKey:(NSNotification *) notification
+{
+ mImpl->OnFocus(false);
+}
+
+- (void) windowWillClose:(NSNotification *) notification
+{
+ [NSApp stop:nil];
+}
+@end
+
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/macos/window-factory-mac.h>
+
+// INTERNAL HEADERS
+#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)
+{
+ return Utils::MakeUnique<WindowBaseCocoa>(positionSize, surface, isTransparent);
+}
+
+// this should be created from Window impl
+std::unique_ptr<WindowFactory> GetWindowFactory()
+{
+ // returns Window factory
+ return Utils::MakeUnique<WindowFactoryCocoa>();
+}
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/window-system/common/window-factory.h>
+
+namespace Dali::Internal::Adaptor
+{
+class WindowFactoryCocoa : public WindowFactory
+{
+public:
+ std::unique_ptr<WindowBase> CreateWindowBase(
+ Dali::PositionSize positionSize,
+ Any surface,
+ bool isTransparent) override;
+};
+
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "window-render-surface-cocoa.h"
+
+namespace Dali::Internal::Adaptor
+{
+WindowRenderSurfaceCocoa::WindowRenderSurfaceCocoa(Dali::PositionSize positionSize, Any surface, bool isTransparent)
+: WindowRenderSurface(positionSize, surface, isTransparent),
+ mReady(false)
+{
+}
+
+void WindowRenderSurfaceCocoa::StartRender()
+{
+ std::unique_lock<std::mutex> lock(mCondMutex);
+ WindowRenderSurface::StartRender();
+ while(!mReady)
+ {
+ mRenderWait.wait(lock);
+ }
+}
+
+void WindowRenderSurfaceCocoa::CreateSurface()
+{
+ std::lock_guard<std::mutex> lock(mCondMutex);
+ WindowRenderSurface::CreateSurface();
+ mReady = true;
+ mRenderWait.notify_all();
+}
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <condition_variable>
+#include <mutex>
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/window-render-surface.h>
+
+namespace Dali::Internal::Adaptor
+{
+/**
+ * We must create the EGL Window before we enter the run loop.
+ * This specialization ensures this condition is respected.
+ */
+class WindowRenderSurfaceCocoa : public WindowRenderSurface
+{
+public:
+ /**
+ * @copydoc Dali::WindowRenderSurface()
+ */
+ WindowRenderSurfaceCocoa(Dali::PositionSize positionSize, Any surface, bool isTransparent = true);
+
+ /**
+ * @copydoc Dali::RenderSurfaceInterface::StartRender()
+ */
+ void StartRender() override;
+
+ /**
+ * @copydoc Dali::RenderSurfaceInterface::CreateSurface()
+ */
+ void CreateSurface() override;
+
+private:
+ std::mutex mCondMutex;
+ std::condition_variable mRenderWait;
+ bool mReady;
+};
+} // namespace Dali::Internal::Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/window-system/common/window-system.h>
+
+namespace Dali::Internal::Adaptor::WindowSystem
+{
+
+void Initialize()
+{
+}
+
+void GetScreenSize( int& width, int& height )
+{
+ NSRect r = [[NSScreen mainScreen] frame];
+ width = static_cast<int>(r.size.width);
+ height = static_cast<int>(r.size.height);
+}
+
+bool SetKeyboardRepeatInfo( float rate, float delay )
+{
+ return false;
+}
+
+bool GetKeyboardRepeatInfo( float& rate, float& delay )
+{
+ return false;
+}
+
+} // namespace Dali::Internal::Adaptor::WindowSystem
+
/*
- * 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
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREWL_DISPLAY_CONNECTION_FACTORY_ECORE_WL_H
/*
- * 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.
std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> CreateDisplayConnection() override;
};
-} // Adaptor
+} // namespace Adaptor
-} // Internal
-
-} // Dali
+} // namespace Internal
+} // namespace Dali
#endif // DALI_INTERNAL_WINDOWSYSTEM_ECOREWL_DISPLAY_CONNECTION_FACTORY_ECORE_WL_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.
*/
// 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));
}
}
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREWL_DISPLAY_CONNECTION_IMPL_ECORE_WL_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
{
-
class DisplayConnection;
namespace Internal
{
-
namespace Adaptor
{
-
/**
* DisplayConnection implementation
*/
class DisplayConnectionEcoreWl : public Dali::Internal::Adaptor::DisplayConnection
{
public:
-
/**
* @brief Default constructor
*/
static DisplayConnection* New();
public:
-
/**
* @copydoc Dali::DisplayConnection::GetDisplay
*/
* @brief Sets the surface type
* @param[in] type The surface type
*/
- void SetSurfaceType( Dali::RenderSurfaceInterface::Type type );
+ void SetSurfaceType(Dali::RenderSurfaceInterface::Type type);
/**
* @brief Sets the graphics interface
* @param[in] graphics The graphics interface
*/
- void SetGraphicsInterface( GraphicsInterface& graphics );
+ void SetGraphicsInterface(GraphicsInterface& graphics);
public:
-
/**
* Destructor
*/
virtual ~DisplayConnectionEcoreWl();
protected:
-
/**
* @brief Gets display connection for native surface
*/
DisplayConnectionEcoreWl& operator=(const DisplayConnectionEcoreWl& rhs);
private:
- EGLNativeDisplayType mDisplay; ///< Wayland-display for rendering
- Dali::RenderSurfaceInterface::Type mSurfaceType; ///< The surface type
- GraphicsInterface* mGraphics; ///< The graphics interface
+ EGLNativeDisplayType mDisplay; ///< Wayland-display for rendering
+ Dali::RenderSurfaceInterface::Type mSurfaceType; ///< The surface type
+ GraphicsInterface* mGraphics; ///< The graphics interface
};
} // 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.
#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
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL_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 Adaptor
{
-
class RenderSurfaceFactoryEcoreWl : public RenderSurfaceFactory
{
public:
- std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) override;
};
} // 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()
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H
/*
- * 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
{
-
class WindowRenderSurface;
class WindowRenderSurfaceEcoreWl;
class WindowBaseEcoreWl : public WindowBase
{
public:
-
/**
* @brief Constructor
*/
- WindowBaseEcoreWl( PositionSize positionSize, Any surface, bool isTransparent );
+ WindowBaseEcoreWl(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Destructor
virtual ~WindowBaseEcoreWl();
public:
-
/**
* @brief Called when the window iconify state is changed.
*/
- Eina_Bool OnIconifyStateChanged( void* data, int type, void* event );
+ Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
/**
* @brief Called when the window gains focus.
*/
- Eina_Bool OnFocusIn( void* data, int type, void* event );
+ Eina_Bool OnFocusIn(void* data, int type, void* event);
/**
* @brief Called when the window loses focus.
*/
- Eina_Bool OnFocusOut( void* data, int type, void* event );
+ Eina_Bool OnFocusOut(void* data, int type, void* event);
/**
* @brief Called when the output is transformed.
*/
- Eina_Bool OnOutputTransform( void* data, int type, void* event );
+ Eina_Bool OnOutputTransform(void* data, int type, void* event);
/**
* @brief Called when the output transform should be ignored.
*/
- Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event );
+ Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
/**
* @brief Called when a rotation event is recevied.
*/
- void OnRotation( void* data, int type, void* event );
+ void OnRotation(void* data, int type, void* event);
/**
* @brief Called when a touch down is received.
*/
- void OnMouseButtonDown( void* data, int type, void* event );
+ void OnMouseButtonDown(void* data, int type, void* event);
/**
* @brief Called when a touch up is received.
*/
- void OnMouseButtonUp( void* data, int type, void* event );
+ void OnMouseButtonUp(void* data, int type, void* event);
/**
* @brief Called when a touch motion is received.
*/
- void OnMouseButtonMove( void* data, int type, void* event );
+ void OnMouseButtonMove(void* data, int type, void* event);
/**
* @brief Called when a touch is canceled.
*/
- void OnMouseButtonCancel( void* data, int type, void* event );
+ void OnMouseButtonCancel(void* data, int type, void* event);
/**
* @brief Called when a mouse wheel is received.
*/
- void OnMouseWheel( void* data, int type, void* event );
+ void OnMouseWheel(void* data, int type, void* event);
/**
* @brief Called when a detent rotation event is recevied.
*/
- void OnDetentRotation( void* data, int type, void* event );
+ void OnDetentRotation(void* data, int type, void* event);
/**
* @brief Called when a key down is received.
*/
- void OnKeyDown( void* data, int type, void* event );
+ void OnKeyDown(void* data, int type, void* event);
/**
* @brief Called when a key up is received.
*/
- void OnKeyUp( void* data, int type, void* event );
+ void OnKeyUp(void* data, int type, void* event);
/**
* @brief Called when the source window notifies us the content in clipboard is selected.
*/
- void OnDataSend( void* data, int type, void* event );
+ void OnDataSend(void* data, int type, void* event);
/**
* @brief Called when the source window sends us about the selected content.
*/
- void OnDataReceive( void* data, int type, void* event );
+ void OnDataReceive(void* data, int type, void* event);
/**
* @brief Called when a font name is changed.
/**
* @brief Called when Ecore ElDBus accessibility event is received.
*/
- void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
+ void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
#endif
/**
* @brief RegistryGlobalCallback
*/
- void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
+ void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
/**
* @brief RegistryGlobalCallbackRemove
*/
- void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
+ void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
/**
* @brief TizenPolicyNotificationChangeDone
*/
- void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
+ void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
/**
* @brief TizenPolicyScreenModeChangeDone
*/
- void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
+ void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
/**
* @brief DisplayPolicyBrightnessChangeDone
*/
- void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
+ void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
public:
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
*/
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
*/
- EGLNativeWindowType CreateEglWindow( int width, int height ) override;
+ EGLNativeWindowType CreateEglWindow(int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
*/
- void SetEglWindowRotation( int angle ) override;
+ void SetEglWindowRotation(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
*/
- void SetEglWindowBufferTransform( int angle ) override;
+ void SetEglWindowBufferTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
*/
- void SetEglWindowTransform( int angle ) override;
+ void SetEglWindowTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
*/
- void ResizeEglWindow( PositionSize positionSize ) override;
+ void ResizeEglWindow(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Move()
*/
- void Move( PositionSize positionSize ) override;
+ void Move(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
*/
- void Resize( PositionSize positionSize ) override;
+ void Resize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
*/
- void MoveResize( PositionSize positionSize ) override;
+ void MoveResize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
*/
- void SetClass( const std::string& name, const std::string& className ) override;
+ void SetClass(const std::string& name, const std::string& className) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
*/
- void SetAvailableAnlges( const std::vector< int >& angles ) override;
+ void SetAvailableAnlges(const std::vector<int>& angles) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
*/
- void SetPreferredAngle( int angle ) override;
+ void SetPreferredAngle(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
*/
- void SetAcceptFocus( bool accept ) override;
+ void SetAcceptFocus(bool accept) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Show()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id ) override;
+ bool RemoveAuxiliaryHint(unsigned int id) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+ std::string GetAuxiliaryHintValue(unsigned int id) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion ) override;
+ void SetInputRegion(const Rect<int>& inputRegion) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
*/
- void SetType( Dali::WindowType type ) override;
+ void SetType(Dali::WindowType type) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
*/
- bool SetNotificationLevel( Dali::WindowNotificationLevel level ) override;
+ bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque ) override;
+ void SetOpaqueState(bool opaque) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
*/
- bool SetBrightness( int brightness ) override;
+ bool SetBrightness(int brightness) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
*/
- bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
*/
- bool UngrabKey( Dali::KEY key ) override;
+ bool UngrabKey(Dali::KEY key) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
*/
- bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+ bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
*/
- bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+ bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
*/
- void SetWindowRotationAngle( int degree ) override;
+ void SetWindowRotationAngle(int degree) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
*/
- void WindowRotationCompleted( int degree, int width, int height ) override;
+ void WindowRotationCompleted(int degree, int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
*/
- void SetTransparency( bool transparent ) override;
+ void SetTransparency(bool transparent) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
*/
- void SetParent( WindowBase* parentWinBase ) override;
+ void SetParent(WindowBase* parentWinBase) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
int CreateFramePresentedSyncFence() override;
private:
-
/**
* Second stage initialization
*/
- void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+ void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
/**
* Initialize Ecore ElDBus
/**
* @brief Create window
*/
- void CreateWindow( PositionSize positionSize );
+ void CreateWindow(PositionSize positionSize);
protected:
-
// Undefined
WindowBaseEcoreWl(const WindowBaseEcoreWl&) = delete;
WindowBaseEcoreWl& operator=(const WindowBaseEcoreWl& rhs) = delete;
private:
+ typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
- typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
+ Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
- Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
+ Ecore_Wl_Window* mEcoreWindow;
+ wl_surface* mWlSurface;
+ wl_egl_window* mEglWindow;
+ wl_display* mDisplay;
+ wl_event_queue* mEventQueue;
+ tizen_policy* mTizenPolicy;
+ tizen_display_policy* mTizenDisplayPolicy;
- Ecore_Wl_Window* mEcoreWindow;
- wl_surface* mWlSurface;
- wl_egl_window* mEglWindow;
- wl_display* mDisplay;
- wl_event_queue* mEventQueue;
- tizen_policy* mTizenPolicy;
- tizen_display_policy* mTizenDisplayPolicy;
+ std::vector<std::string> mSupportedAuxiliaryHints;
+ AuxiliaryHints mAuxiliaryHints;
- std::vector< std::string > mSupportedAuxiliaryHints;
- AuxiliaryHints mAuxiliaryHints;
+ int mNotificationLevel;
+ uint32_t mNotificationChangeState;
+ bool mNotificationLevelChangeDone;
- int mNotificationLevel;
- uint32_t mNotificationChangeState;
- bool mNotificationLevelChangeDone;
+ int mScreenOffMode;
+ uint32_t mScreenOffModeChangeState;
+ bool mScreenOffModeChangeDone;
- int mScreenOffMode;
- uint32_t mScreenOffModeChangeState;
- bool mScreenOffModeChangeDone;
+ int mBrightness;
+ uint32_t mBrightnessChangeState;
+ bool mBrightnessChangeDone;
- int mBrightness;
- uint32_t mBrightnessChangeState;
- bool mBrightnessChangeDone;
+ bool mOwnSurface;
- bool mOwnSurface;
-
- int mWindowRotationAngle;
- int mScreenRotationAngle;
- int mSupportedPreProtation;
+ int mWindowRotationAngle;
+ int mScreenRotationAngle;
+ int mSupportedPreProtation;
#ifdef DALI_ELDBUS_AVAILABLE
- Eldbus_Connection* mSystemConnection;
+ Eldbus_Connection* mSystemConnection;
#endif // DALI_ELDBUS_AVAILABLE
-
};
} // 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/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
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_FACTORY_ECORE_WL_H
/*
- * 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
{
-
class WindowFactoryEcoreWl : public WindowFactory
{
public:
- std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override;
+ std::unique_ptr<WindowBase> CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent) override;
};
} // 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
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL2_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 Adaptor
{
-
class RenderSurfaceFactoryEcoreWl2 : public RenderSurfaceFactory
{
public:
- std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) override;
};
} // 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
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
/*
- * 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
{
-
class WindowRenderSurface;
class WindowRenderSurfaceEcoreWl2;
class WindowBaseEcoreWl2 : public WindowBase
{
public:
-
/**
* @brief Constructor
*/
- WindowBaseEcoreWl2( PositionSize positionSize, Any surface, bool isTransparent );
+ WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Destructor
virtual ~WindowBaseEcoreWl2();
public:
-
/**
* @brief Called when the window iconify state is changed.
*/
- Eina_Bool OnIconifyStateChanged( void* data, int type, void* event );
+ Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
/**
* @brief Called when the window gains focus.
*/
- Eina_Bool OnFocusIn( void* data, int type, void* event );
+ Eina_Bool OnFocusIn(void* data, int type, void* event);
/**
* @brief Called when the window loses focus.
*/
- Eina_Bool OnFocusOut( void* data, int type, void* event );
+ Eina_Bool OnFocusOut(void* data, int type, void* event);
/**
* @brief Called when the output is transformed.
*/
- Eina_Bool OnOutputTransform( void* data, int type, void* event );
+ Eina_Bool OnOutputTransform(void* data, int type, void* event);
/**
* @brief Called when the output transform should be ignored.
*/
- Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event );
+ Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
/**
* @brief Called when a rotation event is recevied.
*/
- void OnRotation( void* data, int type, void* event );
+ void OnRotation(void* data, int type, void* event);
/**
* @brief Called when a configure event is recevied.
*/
- void OnConfiguration( void* data, int type, void* event );
+ void OnConfiguration(void* data, int type, void* event);
/**
* @brief Called when a touch down is received.
*/
- void OnMouseButtonDown( void* data, int type, void* event );
+ void OnMouseButtonDown(void* data, int type, void* event);
/**
* @brief Called when a touch up is received.
*/
- void OnMouseButtonUp( void* data, int type, void* event );
+ void OnMouseButtonUp(void* data, int type, void* event);
/**
* @brief Called when a touch motion is received.
*/
- void OnMouseButtonMove( void* data, int type, void* event );
+ void OnMouseButtonMove(void* data, int type, void* event);
/**
* @brief Called when a touch is canceled.
*/
- void OnMouseButtonCancel( void* data, int type, void* event );
+ void OnMouseButtonCancel(void* data, int type, void* event);
/**
* @brief Called when a mouse wheel is received.
*/
- void OnMouseWheel( void* data, int type, void* event );
+ void OnMouseWheel(void* data, int type, void* event);
/**
* @brief Called when a detent rotation event is recevied.
*/
- void OnDetentRotation( void* data, int type, void* event );
+ void OnDetentRotation(void* data, int type, void* event);
/**
* @brief Called when a key down is received.
*/
- void OnKeyDown( void* data, int type, void* event );
+ void OnKeyDown(void* data, int type, void* event);
/**
* @brief Called when a key up is received.
*/
- void OnKeyUp( void* data, int type, void* event );
+ void OnKeyUp(void* data, int type, void* event);
/**
* @brief Called when the source window notifies us the content in clipboard is selected.
*/
- void OnDataSend( void* data, int type, void* event );
+ void OnDataSend(void* data, int type, void* event);
/**
* @brief Called when the source window sends us about the selected content.
*/
- void OnDataReceive( void* data, int type, void* event );
+ void OnDataReceive(void* data, int type, void* event);
/**
* @brief Called when a font name is changed.
/**
* @brief Called when a transition effect-start/end event is received.
*/
- void OnTransitionEffectEvent( WindowEffectState state, WindowEffectType type );
+ void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
/**
* @brief Called when a keyboard repeat event is changed.
/**
* @brief Called when Ecore ElDBus accessibility event is received.
*/
- void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
+ void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
#endif
/**
* @brief Called when a keymap is changed.
*/
- void KeymapChanged(void *data, int type, void *event);
+ void KeymapChanged(void* data, int type, void* event);
/**
* @brief RegistryGlobalCallback
*/
- void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
+ void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
/**
* @brief RegistryGlobalCallbackRemove
*/
- void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
+ void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
/**
* @brief TizenPolicyNotificationChangeDone
*/
- void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
+ void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
/**
* @brief TizenPolicyScreenModeChangeDone
*/
- void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
+ void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
/**
* @brief DisplayPolicyBrightnessChangeDone
*/
- void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
-
+ void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
/**
* @brief Gets the key code by keyName.
*/
- void GetKeyCode( std::string keyName, int32_t& keyCode );
+ void GetKeyCode(std::string keyName, int32_t& keyCode);
public:
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
*/
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
*/
- EGLNativeWindowType CreateEglWindow( int width, int height ) override;
+ EGLNativeWindowType CreateEglWindow(int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
*/
- void SetEglWindowRotation( int angle ) override;
+ void SetEglWindowRotation(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
*/
- void SetEglWindowBufferTransform( int angle ) override;
+ void SetEglWindowBufferTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
*/
- void SetEglWindowTransform( int angle ) override;
+ void SetEglWindowTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
*/
- void ResizeEglWindow( PositionSize positionSize ) override;
+ void ResizeEglWindow(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Move()
*/
- void Move( PositionSize positionSize ) override;
+ void Move(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
*/
- void Resize( PositionSize positionSize ) override;
+ void Resize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
*/
- void MoveResize( PositionSize positionSize ) override;
+ void MoveResize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
*/
- void SetClass( const std::string& name, const std::string& className ) override;
+ void SetClass(const std::string& name, const std::string& className) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
*/
- void SetAvailableAnlges( const std::vector< int >& angles ) override;
+ void SetAvailableAnlges(const std::vector<int>& angles) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
*/
- void SetPreferredAngle( int angle ) override;
+ void SetPreferredAngle(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
*/
- void SetAcceptFocus( bool accept ) override;
+ void SetAcceptFocus(bool accept) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Show()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id ) override;
+ bool RemoveAuxiliaryHint(unsigned int id) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+ std::string GetAuxiliaryHintValue(unsigned int id) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion ) override;
+ void SetInputRegion(const Rect<int>& inputRegion) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
*/
- void SetType( Dali::WindowType type ) override;
+ void SetType(Dali::WindowType type) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
*/
- bool SetNotificationLevel( Dali::WindowNotificationLevel level ) override;
+ bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque ) override;
+ void SetOpaqueState(bool opaque) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
*/
- bool SetBrightness( int brightness ) override;
+ bool SetBrightness(int brightness) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
*/
- bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
*/
- bool UngrabKey( Dali::KEY key ) override;
+ bool UngrabKey(Dali::KEY key) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
*/
- bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+ bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
*/
- bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+ bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
*/
- void SetWindowRotationAngle( int degree ) override;
+ void SetWindowRotationAngle(int degree) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
*/
- void WindowRotationCompleted( int degree, int width, int height ) override;
+ void WindowRotationCompleted(int degree, int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
*/
- void SetTransparency( bool transparent ) override;
+ void SetTransparency(bool transparent) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
*/
- void SetParent( WindowBase* parentWinBase ) override;
+ void SetParent(WindowBase* parentWinBase) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
int CreateFramePresentedSyncFence() override;
private:
-
/**
* Second stage initialization
*/
- void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+ void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
/**
* Initialize Ecore ElDBus
/**
* @brief Create window
*/
- void CreateWindow( PositionSize positionSize );
+ void CreateWindow(PositionSize positionSize);
protected:
-
// Undefined
WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
private:
+ typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
- typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
-
- Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
+ Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
- Ecore_Wl2_Window* mEcoreWindow;
- wl_surface* mWlSurface;
- wl_egl_window* mEglWindow;
- wl_display* mDisplay;
- wl_event_queue* mEventQueue;
- tizen_policy* mTizenPolicy;
- tizen_display_policy* mTizenDisplayPolicy;
- xkb_keymap* mKeyMap;
+ Ecore_Wl2_Window* mEcoreWindow;
+ wl_surface* mWlSurface;
+ wl_egl_window* mEglWindow;
+ wl_display* mDisplay;
+ wl_event_queue* mEventQueue;
+ tizen_policy* mTizenPolicy;
+ tizen_display_policy* mTizenDisplayPolicy;
+ xkb_keymap* mKeyMap;
- std::vector< std::string > mSupportedAuxiliaryHints;
- AuxiliaryHints mAuxiliaryHints;
+ std::vector<std::string> mSupportedAuxiliaryHints;
+ AuxiliaryHints mAuxiliaryHints;
- int mNotificationLevel;
- uint32_t mNotificationChangeState;
- bool mNotificationLevelChangeDone;
+ int mNotificationLevel;
+ uint32_t mNotificationChangeState;
+ bool mNotificationLevelChangeDone;
- int mScreenOffMode;
- uint32_t mScreenOffModeChangeState;
- bool mScreenOffModeChangeDone;
+ int mScreenOffMode;
+ uint32_t mScreenOffModeChangeState;
+ bool mScreenOffModeChangeDone;
- int mBrightness;
- uint32_t mBrightnessChangeState;
- bool mBrightnessChangeDone;
+ int mBrightness;
+ uint32_t mBrightnessChangeState;
+ bool mBrightnessChangeDone;
- bool mVisible:1;
- Dali::PositionSize mWindowPositionSize;
+ bool mVisible : 1;
+ Dali::PositionSize mWindowPositionSize;
- bool mOwnSurface;
+ bool mOwnSurface;
- volatile uint32_t mMoveResizeSerial;
- uint32_t mLastSubmittedMoveResizeSerial;
+ volatile uint32_t mMoveResizeSerial;
+ uint32_t mLastSubmittedMoveResizeSerial;
- int mWindowRotationAngle;
- int mScreenRotationAngle;
- int mSupportedPreProtation;
+ int mWindowRotationAngle;
+ int mScreenRotationAngle;
+ int mSupportedPreProtation;
#ifdef DALI_ELDBUS_AVAILABLE
- Eldbus_Connection* mSystemConnection;
+ Eldbus_Connection* mSystemConnection;
#endif // DALI_ELDBUS_AVAILABLE
};
} // 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/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
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_FACTORY_ECORE_WL2_H
/*
- * 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
{
-
class WindowFactoryEcoreWl2 : public WindowFactory
{
public:
- std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override;
+ std::unique_ptr<WindowBase> CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent) override;
};
} // 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
+ MakeContextCurrent();
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;
}
#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_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.
*/
// EXTERNAL INCLUDES
+#include <dali/devel-api/threading/conditional-wait.h>
#include <tbm_surface.h>
#include <tbm_surface_queue.h>
-#include <dali/devel-api/threading/conditional-wait.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/integration-api/adaptor-framework/egl-interface.h>
#include <dali/integration-api/adaptor-framework/native-render-surface.h>
#include <dali/internal/graphics/common/graphics-interface.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
-
class DisplayConnection;
class EglInterface;
class NativeRenderSurfaceEcoreWl : public Dali::NativeRenderSurface
{
public:
-
/**
* Uses an Wayland surface to render to.
* @param [in] surfaceSize the size of the surface
* @param [in] surface the native surface handle
* @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
*/
- NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent = false );
+ NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, Any surface, bool isTransparent = false);
/**
* @brief Destructor
virtual ~NativeRenderSurfaceEcoreWl();
public: // from WindowRenderSurface
-
/**
* @copydoc Dali::NativeRenderSurface::GetSurface()
*/
/**
* @copydoc Dali::NativeRenderSurface::SetRenderNotification()
*/
- void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
+ void SetRenderNotification(TriggerEventInterface* renderNotification) override;
/**
* @copydoc Dali::NativeRenderSurface::WaitUntilSurfaceReplaced()
virtual Any GetNativeRenderable() override;
public: // from Dali::RenderSurfaceInterface
-
/**
* @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
*/
/**
* @copydoc Dali::RenderSurfaceInterface::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetOrientation()
/**
* @copydoc Dali::RenderSurfaceInterface::MoveResize()
*/
- void MoveResize( Dali::PositionSize positionSize) override;
+ void MoveResize(Dali::PositionSize positionSize) override;
/**
* @copydoc Dali::RenderSurfaceInterface::StartRender()
/**
* @copydoc Dali::RenderSurfaceInterface::PreRender()
*/
- bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
+ bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
/**
* @copydoc Dali::RenderSurfaceInterface::PostRender()
*/
- void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
+ void PostRender(bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects) override;
/**
* @copydoc Dali::RenderSurfaceInterface::StopRender()
/**
* @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
*/
- void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )override;
+ void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
Integration::StencilBufferAvailable GetStencilBufferRequired() override;
private:
-
/**
* @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
*/
void ReleaseDrawable() override;
private: // Data
-
- SurfaceSize mSurfaceSize;
- TriggerEventInterface* mRenderNotification;
- Internal::Adaptor::GraphicsInterface* mGraphics; ///< The graphics interface
- EglInterface* mEGL;
- EGLSurface mEGLSurface;
- EGLContext mEGLContext;
- ColorDepth mColorDepth;
- tbm_format mTbmFormat;
- bool mOwnSurface;
- bool mDrawableCompleted;
-
- tbm_surface_queue_h mTbmQueue;
- tbm_surface_h mConsumeSurface;
- ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
- ConditionalWait mTbmSurfaceCondition;
-
+ SurfaceSize mSurfaceSize;
+ TriggerEventInterface* mRenderNotification;
+ Internal::Adaptor::GraphicsInterface* mGraphics; ///< The graphics interface
+ EglInterface* mEGL;
+ EGLSurface mEGLSurface;
+ EGLContext mEGLContext;
+ ColorDepth mColorDepth;
+ tbm_format mTbmFormat;
+ bool mOwnSurface;
+ bool mDrawableCompleted;
+
+ tbm_surface_queue_h mTbmQueue;
+ tbm_surface_h mConsumeSurface;
+ ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
+ ConditionalWait mTbmSurfaceCondition;
};
} // 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 Adaptor
{
-
std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> DisplayConnectionFactoryX::CreateDisplayConnection()
{
return Utils::MakeUnique<DisplayConnectionX11>();
return Utils::MakeUnique<DisplayConnectionFactoryX>();
}
-}
-}
-}
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_DISPLAY_CONNECTION_FACTORY_ECORE_X_H
/*
- * 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 DisplayConnectionFactoryX : public DisplayConnectionFactory
{
public:
} // namespace Dali
-
#endif // DALI_INTERNAL_WINDOWSYSTEM_ECOREX_DISPLAY_CONNECTION_FACTORY_ECORE_X_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.
#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;
}
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_DISPLAY_CONNECTION_IMPL_ECORE_X_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
{
-
class DisplayConnection;
namespace Internal
{
-
namespace Adaptor
{
-
-
class Impl
{
public:
-
- XDisplay* mDisplay; ///< X-display for rendering
+ XDisplay* mDisplay; ///< X-display for rendering
};
-
/**
* DisplayConnection implementation
*/
class DisplayConnectionX11 : public Dali::Internal::Adaptor::DisplayConnection
{
public:
-
/**
* @brief Default constructor
*/
static DisplayConnection* New();
public:
-
/**
* @copydoc Dali::DisplayConnection::GetDisplay
*/
/**
* @copydoc Dali::Internal::Adaptor::DisplayConnection::SetSurfaceType
*/
- void SetSurfaceType( Dali::RenderSurfaceInterface::Type type );
+ void SetSurfaceType(Dali::RenderSurfaceInterface::Type type);
/**
* @copydoc Dali::Internal::Adaptor::DisplayConnection::SetGraphicsInterface
*/
- void SetGraphicsInterface( GraphicsInterface& graphics );
+ void SetGraphicsInterface(GraphicsInterface& graphics);
public:
-
/**
* Destructor
*/
virtual ~DisplayConnectionX11();
protected:
-
// Undefined
DisplayConnectionX11(const DisplayConnectionX11&) = delete;
DisplayConnectionX11& operator=(const DisplayConnectionX11& rhs) = delete;
private:
-
GraphicsInterface* mGraphics; ///< The graphics interface
public:
-
- XDisplay* mDisplay; ///< X-display for rendering
-
+ XDisplay* mDisplay; ///< X-display for rendering
};
} // namespace Adaptor
-} // namespace internal
+} // namespace Internal
} // namespace Dali
#define DALI_X11_TYPES_H
/*
- * 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
{
-
-typedef ::Pixmap XPixmap;
-typedef ::Window XWindow;
+typedef ::Pixmap XPixmap;
+typedef ::Window XWindow;
typedef ::Display XDisplay;
-typedef ::Screen XScreen;
+typedef ::Screen XScreen;
} // 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 <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
#define DALI_ECORE_X_PIXMAP_RENDER_SURFACE_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.
#include <dali/devel-api/threading/conditional-wait.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/integration-api/adaptor-framework/egl-interface.h>
#include <dali/internal/graphics/common/graphics-interface.h>
#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/system/linux/dali-ecore-x.h>
#include <dali/internal/window-system/common/pixmap-render-surface.h>
#include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
{
namespace Adaptor
{
-
/**
* Ecore X11 Pixmap implementation of render surface.
*/
class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
{
public:
-
/**
* Uses an X11 surface to render to.
* @param [in] positionSize the position and size of the surface
* @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
* @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
*/
- PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
+ PixmapRenderSurfaceEcoreX(Dali::PositionSize positionSize, Any surface, bool isTransparent = false);
/**
* @brief Destructor
virtual ~PixmapRenderSurfaceEcoreX();
public: // from WindowRenderSurface
-
/**
* @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
*/
/**
* @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
*/
- void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
+ void SetRenderNotification(TriggerEventInterface* renderNotification) override;
public: // from Dali::RenderSurfaceInterface
-
/**
* @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
*/
/**
* @copydoc Dali::RenderSurfaceInterface::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
/**
* @copydoc Dali::RenderSurfaceInterface::MoveResize()
*/
- virtual void MoveResize( Dali::PositionSize positionSize) override {}
+ virtual void MoveResize(Dali::PositionSize positionSize) override
+ {
+ }
/**
* @copydoc Dali::RenderSurfaceInterface::StartRender()
/**
* @copydoc Dali::RenderSurfaceInterface::PreRender()
*/
- bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
+ bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
/**
* @copydoc Dali::RenderSurfaceInterface::PostRender()
*/
- void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
+ void PostRender(bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects) override;
/**
* @copydoc Dali::RenderSurfaceInterface::StopRender()
/**
* @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
*/
- void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
+ void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
/**
* @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
void MakeContextCurrent() override;
private: // from PixmapRenderSurface
-
/**
* @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
*/
/**
* @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
*/
- void Initialize( Any surface ) override;
+ void Initialize(Any surface) override;
/**
* @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
/**
* @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
*/
- void UseExistingRenderable( unsigned int surfaceId ) override;
+ void UseExistingRenderable(unsigned int surfaceId) override;
private:
-
/**
* Get the surface id if the surface parameter is not empty
* @param surface Any containing a surface id, or can be empty
* @return surface id, or zero if surface is empty
*/
- unsigned int GetSurfaceId( Any surface ) const;
+ unsigned int GetSurfaceId(Any surface) const;
private: // Data
-
- static const int BUFFER_COUNT = 2;
- GraphicsInterface* mGraphics; ///< Graphics interface
- Dali::DisplayConnection* mDisplayConnection; ///< Display connection
- PositionSize mPosition; ///< Position
- TriggerEventInterface* mRenderNotification; ///< Render notification trigger
- ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
- bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
+ static const int BUFFER_COUNT = 2;
+ GraphicsInterface* mGraphics; ///< Graphics interface
+ Dali::DisplayConnection* mDisplayConnection; ///< Display connection
+ PositionSize mPosition; ///< Position
+ TriggerEventInterface* mRenderNotification; ///< Render notification trigger
+ ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
+ bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
int mProduceBufferIndex;
int mConsumeBufferIndex;
- XPixmap mX11Pixmaps[BUFFER_COUNT]; ///< X-Pixmap
+ XPixmap mX11Pixmaps[BUFFER_COUNT]; ///< X-Pixmap
EGLSurface mEglSurfaces[BUFFER_COUNT];
- ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
- ConditionalWait mPixmapCondition; ///< condition to share pixmap
+ ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
+ ConditionalWait mPixmapCondition; ///< condition to share pixmap
};
} // 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
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_RENDER_SURFACE_FACTORY_ECORE_X_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 Adaptor
{
-
class RenderSurfaceFactoryEcoreX : public RenderSurfaceFactory
{
public:
- std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) override;
};
} // 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);
}
}
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_WINDOW_BASE_ECORE_X_H
/*
- * 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-base.h>
// EXTERNAL HEADERS
-#include <dali/internal/system/linux/dali-ecore.h>
#include <dali/internal/system/linux/dali-ecore-x.h>
+#include <dali/internal/system/linux/dali-ecore.h>
namespace Dali
{
{
namespace Adaptor
{
-
/**
* WindowBaseEcoreX class provides an WindowBase EcoreX implementation.
*/
class WindowBaseEcoreX : public WindowBase
{
public:
-
/**
* @brief Constructor
*/
- WindowBaseEcoreX( PositionSize positionSize, Any surface, bool isTransparent );
+ WindowBaseEcoreX(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Destructor
virtual ~WindowBaseEcoreX();
public:
-
/**
* @brief Called when the window property is changed.
*/
- Eina_Bool OnWindowPropertyChanged( void* data, int type, void* event );
+ Eina_Bool OnWindowPropertyChanged(void* data, int type, void* event);
/**
* @brief Called when the window receives a delete request
/**
* @brief Called when the window gains focus.
*/
- void OnFocusIn( void* data, int type, void* event );
+ void OnFocusIn(void* data, int type, void* event);
/**
* @brief Called when the window loses focus.
*/
- void OnFocusOut( void* data, int type, void* event );
+ void OnFocusOut(void* data, int type, void* event);
/**
* @brief Called when the window is damaged.
*/
- void OnWindowDamaged( void* data, int type, void* event );
+ void OnWindowDamaged(void* data, int type, void* event);
/**
* @brief Called when a touch down is received.
*/
- void OnMouseButtonDown( void* data, int type, void* event );
+ void OnMouseButtonDown(void* data, int type, void* event);
/**
* @brief Called when a touch up is received.
*/
- void OnMouseButtonUp( void* data, int type, void* event );
+ void OnMouseButtonUp(void* data, int type, void* event);
/**
* @brief Called when a touch motion is received.
*/
- void OnMouseButtonMove( void* data, int type, void* event );
+ void OnMouseButtonMove(void* data, int type, void* event);
/**
* @brief Called when a mouse wheel is received.
*/
- void OnMouseWheel( void* data, int type, void* event );
+ void OnMouseWheel(void* data, int type, void* event);
/**
* @brief Called when a key down is received.
*/
- void OnKeyDown( void* data, int type, void* event );
+ void OnKeyDown(void* data, int type, void* event);
/**
* @brief Called when a key up is received.
*/
- void OnKeyUp( void* data, int type, void* event );
+ void OnKeyUp(void* data, int type, void* event);
/**
* @brief Called when the source window notifies us the content in clipboard is selected.
*/
- void OnSelectionClear( void* data, int type, void* event );
+ void OnSelectionClear(void* data, int type, void* event);
/**
* @brief Called when the source window sends us about the selected content.
*/
- void OnSelectionNotify( void* data, int type, void* event );
+ void OnSelectionNotify(void* data, int type, void* event);
public:
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
*/
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
*/
- EGLNativeWindowType CreateEglWindow( int width, int height ) override;
+ EGLNativeWindowType CreateEglWindow(int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
*/
- void SetEglWindowRotation( int angle ) override;
+ void SetEglWindowRotation(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
*/
- void SetEglWindowBufferTransform( int angle ) override;
+ void SetEglWindowBufferTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
*/
- void SetEglWindowTransform( int angle ) override;
+ void SetEglWindowTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
*/
- void ResizeEglWindow( PositionSize positionSize ) override;
+ void ResizeEglWindow(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Move()
*/
- void Move( PositionSize positionSize ) override;
+ void Move(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
*/
- void Resize( PositionSize positionSize ) override;
+ void Resize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
*/
- void MoveResize( PositionSize positionSize ) override;
+ void MoveResize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
*/
- void SetClass( const std::string& name, const std::string& className ) override;
+ void SetClass(const std::string& name, const std::string& className) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
*/
- void SetAvailableAnlges( const std::vector< int >& angles ) override;
+ void SetAvailableAnlges(const std::vector<int>& angles) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
*/
- void SetPreferredAngle( int angle ) override;
+ void SetPreferredAngle(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
*/
- void SetAcceptFocus( bool accept ) override;
+ void SetAcceptFocus(bool accept) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Show()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id ) override;
+ bool RemoveAuxiliaryHint(unsigned int id) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+ std::string GetAuxiliaryHintValue(unsigned int id) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion ) override;
+ void SetInputRegion(const Rect<int>& inputRegion) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
*/
- void SetType( Dali::WindowType type ) override;
+ void SetType(Dali::WindowType type) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
*/
- bool SetNotificationLevel( Dali::WindowNotificationLevel level ) override;
+ bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque ) override;
+ void SetOpaqueState(bool opaque) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
*/
- bool SetBrightness( int brightness ) override;
+ bool SetBrightness(int brightness) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
*/
- bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
*/
- bool UngrabKey( Dali::KEY key ) override;
+ bool UngrabKey(Dali::KEY key) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
*/
- bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+ bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
*/
- bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+ bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
*/
- void SetWindowRotationAngle( int degree ) override;
+ void SetWindowRotationAngle(int degree) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
*/
- void WindowRotationCompleted( int degree, int width, int height ) override;
+ void WindowRotationCompleted(int degree, int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
*/
- void SetTransparency( bool transparent ) override;
+ void SetTransparency(bool transparent) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
*/
- void SetParent( WindowBase* parentWinBase ) override;
+ void SetParent(WindowBase* parentWinBase) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
int CreateFramePresentedSyncFence() override;
private:
-
/**
* Second stage initialization
*/
- void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+ void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Get the surface id if the surface parameter is not empty
* @param surface Any containing a surface id, or can be empty
* @return surface id, or zero if surface is empty
*/
- unsigned int GetSurfaceId( Any surface ) const;
+ unsigned int GetSurfaceId(Any surface) const;
/**
* @brief Create window
*/
- void CreateWindow( PositionSize positionSize, bool isTransparent );
+ void CreateWindow(PositionSize positionSize, bool isTransparent);
protected:
-
// Undefined
WindowBaseEcoreX(const WindowBaseEcoreX&) = delete;
WindowBaseEcoreX& operator=(const WindowBaseEcoreX& rhs) = delete;
private:
-
- Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
- Ecore_X_Window mEcoreWindow; ///< Native window handle
- bool mOwnSurface:1; ///< Whether we own the surface (responsible for deleting it)
- bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
- bool mRotationAppSet:1;
- int mWindowRotationAngle;
+ Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
+ Ecore_X_Window mEcoreWindow; ///< Native window handle
+ bool mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
+ bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
+ bool mRotationAppSet : 1;
+ int mWindowRotationAngle;
};
} // 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/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
#define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_WINDOW_FACTORY_ECORE_X_H
/*
- * 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
{
-
class WindowFactoryEcoreX : public WindowFactory
{
public:
- std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override;
+ std::unique_ptr<WindowBase> CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent) override;
};
} // 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
#define DALI_INTERNAL_ECORE_X_RENDER_SURFACE_H
/*
- * 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 <string>
-#include <dali/internal/system/linux/dali-ecore-x.h>
#include <X11/Xlib.h>
+#include <dali/internal/system/linux/dali-ecore-x.h>
// INTERNAL INCLUDES
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
namespace ECore
{
-
namespace WindowInterface
{
/**
* Gets the Ecore X Window
* @return window
*/
- Ecore_X_Window GetWindow();
+Ecore_X_Window GetWindow();
- /**
+/**
* Gets a specified X window property
* @param[in] property the required property id
* @param[in] xDataType the type
* @param[in] num the offset / index of the property
* @return string the property value
*/
- 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);
- /**
+/**
* Send an X Event
* @param[in] display target display
* @param[in] window target window
* @param[in] messageFormat format of message
* @param[in] msg message to send
*/
- void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate,
- long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char *msg );
+void SendXEvent(Ecore_X_Display* display, Ecore_X_Window window, bool propagate, long int eventMask, Ecore_X_Atom messageType, int messageFormat, const char* msg);
} // namespace WindowInterface
-
} // namespace ECore
} // 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.
*/
// 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
#define DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H
/*
- * 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 DisplayConnectionFactoryWin : public DisplayConnectionFactory
{
public:
} // namespace Dali
-
#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H
/*\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
#define DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H\r
\r
/*\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
// INTERNAL INCLUDES\r
+#include <dali/internal/graphics/gles/egl-implementation.h>\r
#include <dali/internal/window-system/common/display-connection-impl.h>\r
#include <dali/public-api/object/base-object.h>\r
-#include <dali/internal/graphics/gles/egl-implementation.h>\r
\r
namespace Dali\r
{\r
-\r
class RenderSurface;\r
class DisplayConnection;\r
\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
/**\r
* DisplayConnection implementation\r
*/\r
class DisplayConnectionWin : public Dali::Internal::Adaptor::DisplayConnection\r
{\r
public:\r
-\r
/**\r
* @brief Default constructor\r
*/\r
static DisplayConnection* New();\r
\r
public:\r
-\r
/**\r
* @copydoc Dali::DisplayConnection::GetDisplay\r
*/\r
/**\r
* @copydoc Dali::Internal::Adaptor::DisplayConnection::SetSurfaceType\r
*/\r
- void SetSurfaceType( Dali::RenderSurfaceInterface::Type type );\r
+ void SetSurfaceType(Dali::RenderSurfaceInterface::Type type);\r
\r
/**\r
* @copydoc Dali::Internal::Adaptor::DisplayConnection::SetGraphicsInterface\r
*/\r
- void SetGraphicsInterface( GraphicsInterface& graphics );\r
+ void SetGraphicsInterface(GraphicsInterface& graphics);\r
\r
public:\r
-\r
/**\r
* Destructor\r
*/\r
virtual ~DisplayConnectionWin();\r
\r
private:\r
-\r
// Undefined\r
DisplayConnectionWin(const DisplayConnectionWin&) = delete;\r
\r
DisplayConnectionWin& operator=(const DisplayConnectionWin& rhs) = delete;\r
\r
private:\r
-\r
- GraphicsInterface *mGraphics; ///< The graphics interface\r
- HDC mDisplay;\r
+ GraphicsInterface* mGraphics; ///< The graphics interface\r
+ HDC mDisplay;\r
};\r
\r
} // namespace Adaptor\r
\r
-} // namespace internal\r
+} // namespace Internal\r
\r
} // namespace Dali\r
\r
#define _WINDOWEVENTSYSTEM_H_\r
\r
/*\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
* limitations under the License.\r
*\r
*/\r
-#define DEVICE_MOUSE 0\r
+#define DEVICE_MOUSE 0\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
struct _Event_Mouse_Button\r
{\r
- WinWindowHandle window; /**< The main window where event happened */\r
+ WinWindowHandle window; /**< The main window where event happened */\r
\r
- uint32_t timestamp; /**< Time when the event occurred */\r
+ uint32_t timestamp; /**< Time when the event occurred */\r
\r
- int32_t x; /**< x coordinate relative to window where event happened */\r
- int32_t y; /**< y coordinate relative to window where event happened */\r
+ int32_t x; /**< x coordinate relative to window where event happened */\r
+ int32_t y; /**< y coordinate relative to window where event happened */\r
\r
struct\r
{\r
- int32_t device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */\r
- double radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */\r
- double pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */\r
- double angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */\r
- double x, y; /**< same as x, y, but with sub-pixel precision, if available */\r
+ int32_t device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */\r
+ double radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */\r
+ double pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */\r
+ double angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */\r
+ double x, y; /**< same as x, y, but with sub-pixel precision, if available */\r
struct\r
{\r
- double x, y;\r
+ double x, y;\r
} root; /**< same as root.x, root.y, but with sub-pixel precision, if available */\r
} multi;\r
};\r
*/\r
struct _Event_Mouse_Wheel\r
{\r
- WinWindowHandle window; /**< The main window where event happened */\r
- WinWindowHandle root_window; /**< The root window where event happened */\r
- WinWindowHandle event_window; /**< The child window where event happened */\r
+ WinWindowHandle window; /**< The main window where event happened */\r
+ WinWindowHandle root_window; /**< The root window where event happened */\r
+ WinWindowHandle event_window; /**< The child window where event happened */\r
\r
- uint32_t timestamp; /**< Time when the event occurred */\r
- uint32_t modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/\r
+ uint32_t timestamp; /**< Time when the event occurred */\r
+ uint32_t modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/\r
\r
- int32_t direction; /**< Orientation of the wheel (horizontal/vertical) */\r
- int32_t z; /**< Value of the wheel event (+1/-1) */\r
+ int32_t direction; /**< Orientation of the wheel (horizontal/vertical) */\r
+ int32_t z; /**< Value of the wheel event (+1/-1) */\r
\r
- int32_t x; /**< x coordinate relative to window where event happened */\r
- int32_t y; /**< y coordinate relative to window where event happened */\r
+ int32_t x; /**< x coordinate relative to window where event happened */\r
+ int32_t y; /**< y coordinate relative to window where event happened */\r
struct\r
{\r
- int32_t x;\r
- int32_t y;\r
+ int32_t x;\r
+ int32_t y;\r
} root; /**< Coordinates relative to root window */\r
};\r
\r
\r
struct TWinEventInfo\r
{\r
- TWinEventInfo( uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam)\r
+ TWinEventInfo(uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam)\r
{\r
this->mWindow = (WinWindowHandle)hWnd;\r
- this->uMsg = uMsg;\r
- this->wParam = wParam;\r
- this->lParam = lParam;\r
+ this->uMsg = uMsg;\r
+ this->wParam = wParam;\r
+ this->lParam = lParam;\r
}\r
\r
WinWindowHandle mWindow;\r
- uint32_t uMsg;\r
- uint64_t wParam;\r
- uint64_t lParam;\r
+ uint32_t uMsg;\r
+ uint64_t wParam;\r
+ uint64_t lParam;\r
};\r
-
-} // namespace Adaptor
-
-} // namespace internal
-
+\r
+} // namespace Adaptor\r
+\r
+} // namespace Internal\r
+\r
} // namespace Dali\r
\r
#endif\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)
{
- TTimerCallbackInfo *callbackInfo = new TTimerCallbackInfo;
- callbackInfo->data = data;
- callbackInfo->callback = callback;
- callbackInfo->hWnd = ::GetActiveWindow();
+ HWND hwnd = GetActiveWindow();
+ if(!hwnd)
+ {
+ hwnd = FindWindow(DALI_WINDOW_CLASS_NAME.c_str(), nullptr);
+ }
+
+ if(!hwnd)
+ {
+ return -1;
+ }
+
+ TTimerCallbackInfo* callbackInfo = new TTimerCallbackInfo;
+ callbackInfo->data = data;
+ callbackInfo->callback = callback;
+ callbackInfo->hWnd = hwnd;
INT_PTR timerID = (INT_PTR)callbackInfo;
- ::SetTimer( callbackInfo->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
#define PLATFORM_IMPLEMENT_WIN_INCLUDE\r
\r
/*\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_HEADERS\r
+#include <dali/public-api/signals/callback.h>\r
#include <stdint.h>\r
#include <string>\r
-#include <dali/public-api/signals/callback.h>\r
\r
-typedef uintptr_t WinWindowHandle;\r
-typedef uint64_t WinPixmap;\r
+typedef uintptr_t WinWindowHandle;\r
+typedef uint64_t WinPixmap;\r
\r
namespace Dali\r
{\r
-\r
namespace Internal\r
{\r
-\r
namespace Adaptor\r
{\r
-\r
namespace WindowsPlatform\r
{\r
-\r
bool PostWinThreadMessage(\r
- _In_ uint32_t Msg,\r
- _In_ uint64_t wParam,\r
- _In_ uint64_t lParam,\r
- _In_ uint64_t threadID = -1 );\r
+ _In_ uint32_t Msg,\r
+ _In_ uint64_t wParam,\r
+ _In_ uint64_t lParam,\r
+ _In_ uint64_t threadID = -1);\r
\r
-using timerCallback = bool(*)(void *data);\r
+using timerCallback = bool (*)(void* data);\r
\r
-intptr_t SetTimer(int interval, timerCallback callback, void *data);\r
+intptr_t SetTimer(int interval, timerCallback callback, void* data);\r
\r
void KillTimer(intptr_t id);\r
\r
-std::string GetKeyName( int keyCode );\r
+std::string GetKeyName(int keyCode);\r
\r
uint64_t GetCurrentThreadId();\r
\r
-void GetNanoseconds( uint64_t& timeInNanoseconds );\r
+void GetNanoseconds(uint64_t& timeInNanoseconds);\r
\r
-unsigned int GetCurrentMilliSeconds( void );\r
+unsigned int GetCurrentMilliSeconds(void);\r
\r
class WindowImpl\r
{\r
public:\r
static const uint32_t STYLE;\r
- static const int32_t EDGE_WIDTH;\r
- static const int32_t EDGE_HEIGHT;\r
+ static const int32_t EDGE_WIDTH;\r
+ static const int32_t EDGE_HEIGHT;\r
\r
WindowImpl();\r
\r
virtual ~WindowImpl();\r
\r
- static void ProcWinMessage( uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam );\r
+ static void ProcWinMessage(uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam);\r
\r
static uint64_t CreateHwnd(\r
- _In_opt_ const char *lpWindowName,\r
- _In_ int X,\r
- _In_ int Y,\r
- _In_ int nWidth,\r
- _In_ int nHeight,\r
- _In_opt_ uint64_t parent );\r
+ _In_opt_ const char* lpWindowName,\r
+ _In_ int X,\r
+ _In_ int Y,\r
+ _In_ int nWidth,\r
+ _In_ int nHeight,\r
+ _In_opt_ uint64_t parent);\r
\r
static void DestroyHWnd(uint64_t hWnd);\r
\r
- void GetDPI( float &xDpi, float &yDpi );\r
+ void GetDPI(float& xDpi, float& yDpi);\r
\r
int GetColorDepth();\r
\r
- void SetListener( CallbackBase *callback );\r
+ void SetListener(CallbackBase* callback);\r
\r
bool PostWinMessage(\r
_In_ uint32_t Msg,\r
_In_ uint64_t wParam,\r
- _In_ uint64_t lParam );\r
+ _In_ uint64_t lParam);\r
\r
void SetHWND(uint64_t inHWnd);\r
void SetWinProc();\r
\r
-protected:\r
-\r
private:\r
- int colorDepth;\r
+ int colorDepth;\r
uint64_t mHWnd; // no ownership, managed outside\r
uint64_t mHdc;\r
\r
- CallbackBase *listener;\r
+ CallbackBase* listener;\r
};\r
\r
-} // namespace WindowsPlatformImplement\r
+} // namespace WindowsPlatform\r
\r
} // namespace Adaptor\r
\r
-} // namespace internal\r
+} // namespace Internal\r
\r
} // namespace Dali\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.
{
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
#define DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_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 Adaptor
{
-
class RenderSurfaceFactoryWin : public RenderSurfaceFactory
{
public:
- std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<WindowRenderSurface> CreateWindowRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+ std::unique_ptr<PixmapRenderSurface> CreatePixmapRenderSurface(Dali::PositionSize positionSize, Any surface, bool isTransparent = false) override;
- std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) override;
+ std::unique_ptr<NativeRenderSurface> CreateNativeRenderSurface(SurfaceSize surfaceSize, Any surface, bool isTransparent = false) override;
};
} // 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
-
#define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
/*
- * 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 INCLUDES
#include <dali/internal/window-system/common/window-base.h>
-#include <dali/internal/window-system/windows/platform-implement-win.h>
#include <dali/internal/window-system/windows/event-system-win.h>
+#include <dali/internal/window-system/windows/platform-implement-win.h>
namespace Dali
{
{
namespace Adaptor
{
-
class Window;
class WindowRenderSurface;
class WindowRenderSurfaceWin;
class WindowBaseWin : public WindowBase
{
public:
-
/**
* @brief Constructor
*/
- WindowBaseWin( PositionSize positionSize, Any surface, bool isTransparent );
+ WindowBaseWin(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Destructor
virtual ~WindowBaseWin();
public:
-
/**
* Called when the window receives a delete request
*/
/**
* @brief Called when the window gains focus.
*/
- void OnFocusIn( int type, TWinEventInfo *event );
+ void OnFocusIn(int type, TWinEventInfo* event);
/**
* @brief Called when the window loses focus.
*/
- void OnFocusOut( int type, TWinEventInfo *event );
+ void OnFocusOut(int type, TWinEventInfo* event);
/**
* @brief Called when the window is damaged.
*/
- void OnWindowDamaged( int type, TWinEventInfo *event );
+ void OnWindowDamaged(int type, TWinEventInfo* event);
/**
* @brief Called when a touch down is received.
*/
- void OnMouseButtonDown( int type, TWinEventInfo *event );
+ void OnMouseButtonDown(int type, TWinEventInfo* event);
/**
* @brief Called when a touch up is received.
*/
- void OnMouseButtonUp( int type, TWinEventInfo *event );
+ void OnMouseButtonUp(int type, TWinEventInfo* event);
/**
* @brief Called when a touch motion is received.
*/
- void OnMouseButtonMove( int type, TWinEventInfo *event );
+ void OnMouseButtonMove(int type, TWinEventInfo* event);
/**
* @brief Called when a mouse wheel is received.
*/
- void OnMouseWheel( int type, TWinEventInfo *event );
+ void OnMouseWheel(int type, TWinEventInfo* event);
/**
* @brief Called when a key down is received.
*/
- void OnKeyDown( int type, TWinEventInfo *event );
+ void OnKeyDown(int type, TWinEventInfo* event);
/**
* @brief Called when a key up is received.
*/
- void OnKeyUp( int type, TWinEventInfo *event );
-
+ void OnKeyUp(int type, TWinEventInfo* event);
public:
-
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
*/
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
*/
- EGLNativeWindowType CreateEglWindow( int width, int height ) override;
+ EGLNativeWindowType CreateEglWindow(int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
*/
- void SetEglWindowRotation( int angle ) override;
+ void SetEglWindowRotation(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
*/
- void SetEglWindowBufferTransform( int angle ) override;
+ void SetEglWindowBufferTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
*/
- void SetEglWindowTransform( int angle ) override;
+ void SetEglWindowTransform(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
*/
- void ResizeEglWindow( PositionSize positionSize ) override;
+ void ResizeEglWindow(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Move()
*/
- void Move( PositionSize positionSize ) override;
+ void Move(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
*/
- void Resize( PositionSize positionSize ) override;
+ void Resize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
*/
- void MoveResize( PositionSize positionSize ) override;
+ void MoveResize(PositionSize positionSize) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
*/
- void SetClass( const std::string& name, const std::string& className ) override;
+ void SetClass(const std::string& name, const std::string& className) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
*/
- void SetAvailableAnlges( const std::vector< int >& angles ) override;
+ void SetAvailableAnlges(const std::vector<int>& angles) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
*/
- void SetPreferredAngle( int angle ) override;
+ void SetPreferredAngle(int angle) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
*/
- void SetAcceptFocus( bool accept ) override;
+ void SetAcceptFocus(bool accept) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::Show()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
*/
- std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+ std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
*/
- unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+ unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
*/
- bool RemoveAuxiliaryHint( unsigned int id ) override;
+ bool RemoveAuxiliaryHint(unsigned int id) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
*/
- bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+ bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
*/
- std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+ std::string GetAuxiliaryHintValue(unsigned int id) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
*/
- unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+ unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
*/
- void SetInputRegion( const Rect< int >& inputRegion ) override;
+ void SetInputRegion(const Rect<int>& inputRegion) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
*/
- void SetType( Dali::WindowType type ) override;
+ void SetType(Dali::WindowType type) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
*/
- bool SetNotificationLevel( Dali::WindowNotificationLevel level ) override;
+ bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
*/
- void SetOpaqueState( bool opaque ) override;
+ void SetOpaqueState(bool opaque) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
*/
- bool SetBrightness( int brightness ) override;
+ bool SetBrightness(int brightness) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
*/
- bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+ bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
*/
- bool UngrabKey( Dali::KEY key ) override;
+ bool UngrabKey(Dali::KEY key) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
*/
- bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+ bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
*/
- bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+ bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
*/
- void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+ void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
*/
- void SetWindowRotationAngle( int degree ) override;
+ void SetWindowRotationAngle(int degree) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
*/
- void WindowRotationCompleted( int degree, int width, int height ) override;
+ void WindowRotationCompleted(int degree, int width, int height) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
*/
- void SetTransparency( bool transparent ) override;
+ void SetTransparency(bool transparent) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
*/
- void SetParent( WindowBase* parentWinBase ) override;
+ void SetParent(WindowBase* parentWinBase) override;
/**
* @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
int CreateFramePresentedSyncFence() override;
private:
-
/**
* Second stage initialization
*/
- void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+ void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
/**
* @brief Get the surface id if the surface parameter is not empty
* @param surface Any containing a surface id, or can be empty
* @return surface id, or zero if surface is empty
*/
- uintptr_t GetSurfaceId( Any surface ) const;
+ uintptr_t GetSurfaceId(Any surface) const;
/**
* @brief Create window
*/
- void CreateWinWindow( PositionSize positionSize, bool isTransparent );
+ void CreateWinWindow(PositionSize positionSize, bool isTransparent);
/**
* @brief Sets up an already created window.
*/
- void SetWinWindow( uintptr_t surfaceId );
+ void SetWinWindow(uintptr_t surfaceId);
private:
-
// Undefined
WindowBaseWin(const WindowBaseWin&) = delete;
WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete;
private:
- void EventEntry( TWinEventInfo *event );
+ void EventEntry(TWinEventInfo* event);
private:
- WinWindowHandle mWin32Window; ///< Native window handle
- bool mOwnSurface:1; ///< Whether we own the surface (responsible for deleting it)
- bool mIsTransparent:1; ///< Whether the window is transparent (32 bit or 24 bit)
- bool mRotationAppSet:1;
+ WinWindowHandle mWin32Window; ///< Native window handle
+ bool mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
+ bool mIsTransparent : 1; ///< Whether the window is transparent (32 bit or 24 bit)
+ bool mRotationAppSet : 1;
WindowsPlatform::WindowImpl mWindowImpl;
};
} // 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/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
#define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H
/*
- * 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
{
-
class WindowFactoryWin : public WindowFactory
{
public:
- std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override;
+ std::unique_ptr<WindowBase> CreateWindowBase(Dali::PositionSize positionSize, Any surface, bool isTransparent) override;
};
} // 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
-
#define DALI_INPUT_MEHTOD_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.
*/
enum Type
{
- DEFAULT, ///< Default action @SINCE_1_3.20
- DONE, ///< Done @SINCE_1_3.20
- GO, ///< Go action @SINCE_1_3.20
- JOIN, ///< Join action @SINCE_1_3.20
- LOGIN, ///< Login action @SINCE_1_3.20
- NEXT, ///< Next action @SINCE_1_3.20
- SEARCH, ///< Search action @SINCE_1_3.20
- SEND, ///< Send action @SINCE_1_3.20
- SIGNIN ///< Sign in action @SINCE_1_3.20
+ DEFAULT, ///< Default action @SINCE_1_3.20
+ DONE, ///< Done @SINCE_1_3.20
+ GO, ///< Go action @SINCE_1_3.20
+ JOIN, ///< Join action @SINCE_1_3.20
+ LOGIN, ///< Login action @SINCE_1_3.20
+ NEXT, ///< Next action @SINCE_1_3.20
+ SEARCH, ///< Search action @SINCE_1_3.20
+ SEND, ///< Send action @SINCE_1_3.20
+ SIGNIN ///< Sign in action @SINCE_1_3.20
};
} // namespace ButtonAction
#define DALI_WINDOW_ENUMERATIONS_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.
HIDE, ///< Window hide effect. @SINCE_2_0.0
};
-}
+} // namespace Dali
#endif // DALI_WINDOW_ENUMERATIONS_H
#define DALI_WINDOW_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.
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/uint-16-pair.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/signals/dali-signal.h>
-#include <dali/public-api/adaptor-framework/window-enumerations.h>
#include <string>
// INTERNAL INCLUDES
using TouchEventSignalType = Signal<void(const TouchEvent&)>; ///< Touch signal type @SINCE_1_9.28
public:
-
// Methods
/**
/*
- * 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.
{
const unsigned int ADAPTOR_MAJOR_VERSION = 2;
const unsigned int ADAPTOR_MINOR_VERSION = 0;
-const unsigned int ADAPTOR_MICRO_VERSION = 6;
+const unsigned int ADAPTOR_MICRO_VERSION = 15;
const char* const ADAPTOR_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
#define DALI_ADAPTOR_DOC_H
/*
- * 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.
* @}
*/
-#endif /* DALI_ADAPTOR_DOC_H */
+#endif /* DALI_ADAPTOR_DOC_H */
Name: dali2-adaptor
Summary: The DALi Tizen Adaptor
-Version: 2.0.6
+Version: 2.0.15
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT
/*
- * 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
-
#define FEEDBACK_PLUGIN_H
/*
- * 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 Plugin
{
-
/**
* Plays feedback effects for Dali-Toolkit UI Controls.
*/
class DaliFeedback : public Dali::FeedbackPlugin
{
-
public: // Construction & Destruction
-
/**
* Constructor
*/
virtual ~DaliFeedback();
public: // FeedbackPlugin overrides
-
/**
* @copydoc Dali::Integration::FeedbackPlugin::PlayHaptic()
*/
- void PlayHaptic( const std::string& filePath );
+ void PlayHaptic(const std::string& filePath);
/**
* @copydoc Dali::FeedbackPlugin::PlayHapticMonotone()
*/
- void PlayHapticMonotone( unsigned int duration );
+ void PlayHapticMonotone(unsigned int duration);
/**
* @copydoc Dali::FeedbackPlugin::StopHaptic()
/**
* @copydoc Dali::FeedbackPlugin::PlaySound()
*/
- int PlaySound( const std::string& fileName );
+ int PlaySound(const std::string& fileName);
/**
* @copydoc Dali::FeedbackPlugin::StopSound()
*/
- void StopSound( int handle );
+ void StopSound(int handle);
/**
* @copydoc Dali::FeedbackPlugin::PlayFeedbackPattern()
*/
- void PlayFeedbackPattern( int type, int pattern );
+ void PlayFeedbackPattern(int type, int pattern);
};
-} // namespace Plugin
+} // namespace Plugin
-} // namespace Dali
+} // namespace Dali
#endif // FEEDBACK_PLUGIN_H
${adaptor_thirdparty_dir}/nanosvg/nanosvgrast.cc
)
+SET( adaptor_macos_platform_src_files
+ ${adaptor_thirdparty_dir}/macos-platform/environment.cpp
+ ${adaptor_thirdparty_dir}/macos-platform/thread.cpp
+)
--- /dev/null
+#include <cstdlib>
+#include <string>
+
+const char* app_get_data_path()
+{
+ static std::string envValue;
+
+ if( envValue.empty() )
+ {
+ envValue = std::getenv( "DemoData" );
+ envValue += "/";
+ }
+
+ return envValue.c_str();
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#pragma once
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <memory>
+#include <type_traits>
+
+const char* app_get_data_path();
+
+// Specialiation of std::unique_ptr for Foundation Objects
+template<typename T>
+using CFRef = std::unique_ptr<
+ std::remove_pointer_t<T>,
+ std::add_pointer_t<decltype(CFRelease)>
+>;
+
+template<typename T>
+inline CFRef<T> MakeRef(T p)
+{
+ return CFRef<T>(p, CFRelease);
+}
--- /dev/null
+#pragma once
+
+#define PR_SET_NAME 0
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int prctl(int type, const char *str);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+#include <sys/prctl.h>
+#include <pthread.h>
+
+extern "C" int prctl( int type, const char *str )
+{
+ if (PR_SET_NAME == type)
+ {
+ pthread_setname_np(str);
+ }
+ return 0;
+}