/packaging/home*
.vscode/
core
+.clangd/
+compile_commands.json
+dali-toolkit/internal/graphics/generated/*
+dali-toolkit/internal/graphics/builtin-shader-extern-gen.h
+dali-scene-loader/internal/graphics/generated/*
+dali-scene-loader/internal/graphics/builtin-shader-extern-gen.h
* [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)
+ * [DALi Scene Loader](#dali-scene-loader)
# Build Instructions
- INSTALL_CMAKE_MODULES ---> Whether to install the CMake modules (Used by the CMake command find_package() to find previously installed libraries).
- ENABLE_DEBUG ---> Whether to build with debug enabled.
- USE_DEFAULT_RESOURCE_DIR ---> Whether to use the default resource folders. Otherwise set environment variables for DALI_IMAGE_DIR, DALI_SOUND_DIR, DALI_STYLE_DIR, DALI_STYLE_IMAGE_DIR and DALI_DATA_READ_ONLY_DIR
+
+## 4. Building for MacOS
+
+It is assumed that the DALi environment has been set up & both DALi Core & Adaptor have been built accordingly.
+
+To build the repository enter the 'build/tizen' folder:
+```zsh
+% cd dali-toolkit/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
+```
+If a Debug build is required, then add `-DCMAKE_BUILD_TYPE=Debug -DENABLE_DEBUG=ON`
+
+To build, run:
+```zsh
+% make install -j8
+```
+
+# DALi Scene Loader
+
+For information about the DALi Scene Loader library, refer to dali-scene-loader/README.md.
#!/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
do
echo -e "$ASCII_BOLD"
echo -e "Executing $mod$ASCII_RESET"
- dbus-launch 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;
- dbus-launch 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
"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 <string.h>
-#include <getopt.h>
-#include <stdlib.h>
#include <test-harness.h>
#include "tct-dali-scene-loader-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);
}
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
#include <test-harness.h>
#include "tct-dali-scene-loader-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);
}
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
#include <test-harness.h>
#include "tct-dali-toolkit-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);
}
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
#include <test-harness.h>
#include "tct-dali-toolkit-styling-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);
}
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
#include <test-harness.h>
#include "tct-dali-toolkit-third-party-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);
}
#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
+#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 "toolkit-timer.h"
#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.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/public-api/images/pixel-data.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
}
}
+class MockWebEngineContext : public Dali::WebEngineContext
+{
+public:
+ MockWebEngineContext()
+ : mockModel( Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER )
+ {
+ }
+
+ Dali::WebEngineContext::CacheModel GetCacheModel() const override
+ {
+ return mockModel;
+ }
+
+ void SetCacheModel( Dali::WebEngineContext::CacheModel cacheModel ) override
+ {
+ mockModel = cacheModel;
+ }
+
+ void SetProxyUri( const std::string& uri ) override
+ {
+ }
+
+ void SetDefaultProxyAuth( const std::string& username, const std::string& password ) override
+ {
+ }
+
+ void SetCertificateFilePath( const std::string& certificatePath ) override
+ {
+ }
+
+ void DeleteWebDatabase() override
+ {
+ }
+
+ void DeleteWebStorage() override
+ {
+ }
+
+ void DeleteLocalFileSystem() override
+ {
+ }
+
+ void DisableCache( bool cacheDisabled ) override
+ {
+ }
+
+ void ClearCache() override
+ {
+ }
+
+private:
+ Dali::WebEngineContext::CacheModel mockModel;
+};
+
+class MockWebEngineCookieManager : public Dali::WebEngineCookieManager
+{
+public:
+ MockWebEngineCookieManager()
+ : mockCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY )
+ {
+ }
+
+ void SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy policy ) override
+ {
+ mockCookieAcceptPolicy = policy;
+ }
+
+ Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const override
+ {
+ return mockCookieAcceptPolicy;
+ }
+
+ void ClearCookies() override
+ {
+ }
+
+ void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ) override
+ {
+ }
+
+private:
+ Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy;
+};
+
+class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem
+{
+public:
+ MockWebEngineBackForwardListItem()
+ : mockUrl( "http://url" ),
+ mockTitle( "title" ),
+ mockOriginalUrl( "http://originalurl" )
+ {
+ }
+
+ std::string GetUrl() const override
+ {
+ return mockUrl;
+ }
+
+ std::string GetTitle() const override
+ {
+ return mockTitle;
+ }
+
+ std::string GetOriginalUrl() const override
+ {
+ return mockOriginalUrl;
+ }
+
+private:
+ std::string mockUrl;
+ std::string mockTitle;
+ std::string mockOriginalUrl;
+};
+
+class MockWebEngineBackForwardList : public Dali::WebEngineBackForwardList
+{
+public:
+ MockWebEngineBackForwardList( )
+ : mockItem(),
+ pMockItem( &mockItem )
+ {
+ }
+
+ Dali::WebEngineBackForwardListItem& GetCurrentItem() const override
+ {
+ return *pMockItem;
+ }
+
+ Dali::WebEngineBackForwardListItem& GetItemAtIndex( uint32_t index ) const override
+ {
+ return *pMockItem;
+ }
+
+ uint32_t GetItemCount() const override
+ {
+ return 1;
+ }
+
+private:
+ MockWebEngineBackForwardListItem mockItem;
+ WebEngineBackForwardListItem* pMockItem;
+};
+
+class MockWebEngineSettings : public WebEngineSettings
+{
+public:
+ MockWebEngineSettings()
+ : mockDefaultFontSize( 16 ),
+ mockJavaScriptEnabled( true ),
+ mockImageLoadedAutomatically( true ),
+ mockDefaultTextEncodingName()
+ {
+ }
+
+ uint32_t GetDefaultFontSize() const override
+ {
+ return mockDefaultFontSize;
+ }
+
+ void SetDefaultFontSize( uint32_t size ) override
+ {
+ mockDefaultFontSize = size;
+ }
+
+ bool IsJavaScriptEnabled() const override
+ {
+ return mockJavaScriptEnabled;
+ }
+
+ void EnableJavaScript( bool enabled ) override
+ {
+ mockJavaScriptEnabled = enabled;
+ }
+
+ bool AreImagesLoadedAutomatically() const override
+ {
+ return mockImageLoadedAutomatically;
+ }
+
+ void AllowImagesLoadAutomatically( bool automatic ) override
+ {
+ mockImageLoadedAutomatically = automatic;
+ }
+
+ std::string GetDefaultTextEncodingName() const override
+ {
+ return mockDefaultTextEncodingName;
+ }
+
+ void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) override
+ {
+ mockDefaultTextEncodingName = defaultTextEncodingName;
+ }
+
+ void AllowMixedContents( bool allowed ) override
+ {
+ }
+
+ void EnableSpatialNavigation( bool enabled ) override
+ {
+ }
+
+ void EnableWebSecurity( bool enabled ) override
+ {
+ }
+
+ void AllowFileAccessFromExternalUrl( bool allowed ) override
+ {
+ }
+
+ void AllowScriptsOpenWindows( bool allowed ) override
+ {
+ }
+
+private:
+ int mockDefaultFontSize;
+ bool mockJavaScriptEnabled;
+ bool mockImageLoadedAutomatically;
+ std::string mockDefaultTextEncodingName;
+};
+
class WebEngine: public Dali::BaseObject
{
public:
WebEngine()
: mUrl()
, mCurrentPlusOnePos( 0 )
- , mCacheModel( Dali::WebEnginePlugin::CacheModel::DOCUMENT_VIEWER )
- , mCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy::NO_THIRD_PARTY )
, mUserAgent()
- , mEnableJavaScript( true )
- , mLoadImagesAutomatically( true )
- , mDefaultTextEncodingName()
- , mDefaultFontSize( 16 )
, mEvaluating( false )
+ , mScrollPosition( 0, 0 )
+ , mScrollSize( 500, 500 )
+ , mContentSize( 500, 500 )
{
gInstanceCount++;
gInstance = this;
+
+ mockWebEngineSettings = new MockWebEngineSettings();
+ mockWebEngineContext = new MockWebEngineContext();
+ mockWebEngineCookieManager = new MockWebEngineCookieManager();
+ mockWebEngineBackForwardList = new MockWebEngineBackForwardList();
}
virtual ~WebEngine()
{
gInstance = NULL;
}
+
+ delete mockWebEngineSettings;
+ delete mockWebEngineContext;
+ delete mockWebEngineCookieManager;
+ delete mockWebEngineBackForwardList;
+ }
+
+ Dali::WebEngineSettings& GetSettings() const
+ {
+ return *mockWebEngineSettings;
+ }
+
+ Dali::WebEngineContext& GetContext() const
+ {
+ return *mockWebEngineContext;
+ }
+
+ Dali::WebEngineCookieManager& GetCookieManager() const
+ {
+ return *mockWebEngineCookieManager;
+ }
+
+ Dali::WebEngineBackForwardList& GetBackForwardList() const
+ {
+ return *mockWebEngineBackForwardList;
}
void LoadUrl( const std::string& url )
return mUrl;
}
+ std::string GetTitle() const
+ {
+ return std::string("title");
+ }
+
+ Dali::PixelData GetFavicon() const
+ {
+ uint8_t* faviconData = new uint8_t[ 16 ];
+
+ faviconData[ 0 ] = 0xff;
+ faviconData[ 1 ] = 0x00;
+ faviconData[ 2 ] = 0x00;
+ faviconData[ 3 ] = 0xff;
+ faviconData[ 4 ] = 0xff;
+ faviconData[ 5 ] = 0x00;
+ faviconData[ 6 ] = 0x00;
+ faviconData[ 7 ] = 0xff;
+ faviconData[ 8 ] = 0xff;
+ faviconData[ 9 ] = 0x00;
+ faviconData[ 10 ] = 0x00;
+ faviconData[ 11 ] = 0xff;
+ faviconData[ 12 ] = 0xff;
+ faviconData[ 13 ] = 0x00;
+ faviconData[ 14 ] = 0x00;
+ faviconData[ 15 ] = 0xff;
+
+ return Dali::PixelData::New( faviconData, 16, 2, 2,
+ Dali::Pixel::Format::RGBA8888,
+ Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+ }
+
bool CanGoForward() const
{
return mHistory.size() > mCurrentPlusOnePos;
ConnectToGlobalSignal( &OnClearHistory );
}
- Dali::WebEnginePlugin::CacheModel GetCacheModel() const
- {
- return mCacheModel;
- }
-
- void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
- {
- mCacheModel = cacheModel;
- }
-
- Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const
- {
- return mCookieAcceptPolicy;
- }
-
- void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
- {
- mCookieAcceptPolicy = policy;
- }
-
const std::string& GetUserAgent() const
{
return mUserAgent;
mUserAgent = userAgent;
}
- bool IsJavaScriptEnabled() const
- {
- return mEnableJavaScript;
- }
-
- void EnableJavaScript( bool enabled )
- {
- mEnableJavaScript = enabled;
- }
-
- bool AreImagesAutomaticallyLoaded() const
+ void ScrollBy( int dx, int dy )
{
- return mLoadImagesAutomatically;
- }
-
- void LoadImagesAutomatically( bool automatic )
- {
- mLoadImagesAutomatically = automatic;
+ mScrollPosition += Dali::Vector2( dx, dy );
+ if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
+ {
+ gInstance->mScrollEdgeReachedSignal.Emit( Dali::WebEnginePlugin::ScrollEdge::BOTTOM );
+ }
}
- const std::string& GetDefaultTextEncodingName() const
+ void SetScrollPosition( int x, int y )
{
- return mDefaultTextEncodingName;
+ mScrollPosition.x = x;
+ mScrollPosition.y = y;
}
- void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+ Dali::Vector2 GetScrollPosition() const
{
- mDefaultTextEncodingName = defaultTextEncodingName;
+ return mScrollPosition;
}
- int GetDefaultFontSize() const
+ Dali::Vector2 GetScrollSize() const
{
- return mDefaultFontSize;
+ return mScrollSize;
}
- void SetDefaultFontSize( int defaultFontSize )
+ Dali::Vector2 GetContentSize() const
{
- mDefaultFontSize = defaultFontSize;
+ return mContentSize;
}
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
return mPageLoadErrorSignal;
}
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
+ {
+ return mScrollEdgeReachedSignal;
+ }
+
std::string mUrl;
std::vector< std::string > mHistory;
size_t mCurrentPlusOnePos;
- Dali::WebEnginePlugin::CacheModel mCacheModel;
- Dali::WebEnginePlugin::CookieAcceptPolicy mCookieAcceptPolicy;
std::string mUserAgent;
- bool mEnableJavaScript;
- bool mLoadImagesAutomatically;
- std::string mDefaultTextEncodingName;
- int mDefaultFontSize;
Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadStartedSignal;
Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadFinishedSignal;
Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal;
std::vector< std::function< void( const std::string& ) > > mResultCallbacks;
bool mEvaluating;
+
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+ Dali::Vector2 mScrollPosition;
+ Dali::Vector2 mScrollSize;
+ Dali::Vector2 mContentSize;
+ WebEngineBackForwardList* mockWebEngineBackForwardList;
+ WebEngineContext* mockWebEngineContext;
+ WebEngineCookieManager* mockWebEngineCookieManager;
+ WebEngineSettings* mockWebEngineSettings;
};
inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
{
}
+void WebEngine::Create( int width, int height, int argc, char** argv )
+{
+}
+
void WebEngine::Destroy()
{
}
+WebEngineSettings& WebEngine::GetSettings() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetSettings();
+}
+
+WebEngineContext& WebEngine::GetContext() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetContext();
+}
+
+WebEngineCookieManager& WebEngine::GetCookieManager() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetCookieManager();
+}
+
+WebEngineBackForwardList& WebEngine::GetBackForwardList() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetBackForwardList();
+}
+
void WebEngine::LoadUrl( const std::string& url )
{
return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
}
+std::string WebEngine::GetTitle() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetTitle();
+}
+
+Dali::PixelData WebEngine::GetFavicon() const
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetFavicon();
+}
+
const std::string& WebEngine::GetUrl()
{
return Internal::Adaptor::GetImplementation( *this ).GetUrl();
return sourcePtr;
}
-void WebEngine::LoadHTMLString( const std::string& htmlString )
+void WebEngine::LoadHtmlString( const std::string& htmlString )
{
}
{
}
-void WebEngine::ClearHistory()
-{
- Internal::Adaptor::GetImplementation( *this ).ClearHistory();
-}
-
-void WebEngine::ClearCache()
+void WebEngine::ClearAllTilesResources()
{
}
-void WebEngine::ClearCookies()
-{
-}
-
-Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetCacheModel();
-}
-
-void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel )
-{
- Internal::Adaptor::GetImplementation( *this ).SetCacheModel( cacheModel );
-}
-
-Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetCookieAcceptPolicy();
-}
-
-void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy )
+void WebEngine::ClearHistory()
{
- Internal::Adaptor::GetImplementation( *this ).SetCookieAcceptPolicy( policy );
+ Internal::Adaptor::GetImplementation( *this ).ClearHistory();
}
const std::string& WebEngine::GetUserAgent() const
Internal::Adaptor::GetImplementation( *this ).SetUserAgent( userAgent );
}
-bool WebEngine::IsJavaScriptEnabled() const
+void WebEngine::ScrollBy( int dx, int dy )
{
- return Internal::Adaptor::GetImplementation( *this ).IsJavaScriptEnabled();
+ Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
}
-void WebEngine::EnableJavaScript( bool enabled )
+void WebEngine::SetScrollPosition( int x, int y )
{
- Internal::Adaptor::GetImplementation( *this ).EnableJavaScript( enabled );
+ Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
}
-bool WebEngine::AreImagesAutomaticallyLoaded() const
+Dali::Vector2 WebEngine::GetScrollPosition() const
{
- return Internal::Adaptor::GetImplementation( *this ).AreImagesAutomaticallyLoaded();
+ return Internal::Adaptor::GetImplementation( *this ).GetScrollPosition();
}
-void WebEngine::LoadImagesAutomatically( bool automatic )
+Dali::Vector2 WebEngine::GetScrollSize() const
{
- Internal::Adaptor::GetImplementation( *this ).LoadImagesAutomatically( automatic );
+ return Internal::Adaptor::GetImplementation( *this ).GetScrollSize();
}
-const std::string& WebEngine::GetDefaultTextEncodingName() const
+Dali::Vector2 WebEngine::GetContentSize() const
{
- return Internal::Adaptor::GetImplementation( *this ).GetDefaultTextEncodingName();
-}
-
-void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
-{
- Internal::Adaptor::GetImplementation( *this ).SetDefaultTextEncodingName( defaultTextEncodingName );
-}
-
-int WebEngine::GetDefaultFontSize() const
-{
- return Internal::Adaptor::GetImplementation( *this ).GetDefaultFontSize();
-}
-
-void WebEngine::SetDefaultFontSize( int defaultFontSize )
-{
- Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize );
+ return Internal::Adaptor::GetImplementation( *this ).GetContentSize();
}
void WebEngine::SetSize( int width, int height )
return true;
}
+void WebEngine::SetFocus( bool focused )
+{
+}
+
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
{
return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal();
}
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeReachedSignal();
+}
+
} // namespace Dali;
-#include <string.h>
-#include <getopt.h>
-#include <stdlib.h>
#include <test-harness.h>
#include "tct-dali-toolkit-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);
}
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
#include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
#include "dummy-control.h"
.Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
.Add( ImageVisual::Property::PIXEL_AREA, Vector4() )
.Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::REPEAT )
- .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT ));
+ .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT )
+ .Add( DevelVisual::Property::CORNER_RADIUS, 22.2f )
+ .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE ));
Property::Map resultMap;
animatedImageVisual.CreatePropertyMap( resultMap );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<std::string>() == TEST_GIF_FILE_NAME );
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 22.2f, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::Transform::Policy::ABSOLUTE );
+
// request AnimatedImageVisual with an URL
Visual::Base animatedImageVisual2 = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
resultMap.Clear();
int UtcDaliAnimatedImageVisualGetPropertyMap02(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image" );
+ tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image with fixed cache" );
+
+ // request AnimatedImageVisual with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Property::Array urls;
+ CopyUrlsIntoArray( urls );
+
+ Visual::Base animatedImageVisual = factory.CreateVisual(
+ Property::Map()
+ .Add( Toolkit::Visual::Property::TYPE, Visual::ANIMATED_IMAGE )
+ .Add( "url", urls )
+ .Add( "batchSize", 4 )
+ .Add( "cacheSize", 20 )
+ .Add( "loopCount", 10 )
+ .Add( "frameDelay", 200 )
+ .Add( "pixelArea", Vector4() )
+ .Add( "wrapModeU", WrapMode::REPEAT )
+ .Add( "wrapModeV", WrapMode::DEFAULT )
+ .Add( "cornerRadius", 50.0f )
+ .Add( "cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE ));
+
+ Property::Map resultMap;
+ animatedImageVisual.CreatePropertyMap( resultMap );
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find( Toolkit::Visual::Property::TYPE, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::ANIMATED_IMAGE );
+
+ value = resultMap.Find( ImageVisual::Property::URL, "url" );
+ DALI_TEST_CHECK( value );
+ Property::Array* resultUrls = value->GetArray();
+ DALI_TEST_CHECK( resultUrls );
+ DALI_TEST_EQUALS( resultUrls->Count(), urls.Count(), TEST_LOCATION );
+
+ value = resultMap.Find( ImageVisual::Property::BATCH_SIZE, "batchSize" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
+
+ value = resultMap.Find( ImageVisual::Property::CACHE_SIZE, "cacheSize" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 20, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelImageVisual::Property::LOOP_COUNT, "loopCount" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 10, TEST_LOCATION );
+
+ value = resultMap.Find( ImageVisual::Property::FRAME_DELAY, "frameDelay" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 11, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 50.0f, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::Transform::Policy::RELATIVE );
+
+ END_TEST;
+}
+
+
+int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap for multi image rolling cache" );
// request AnimatedImageVisual with a property map
VisualFactory factory = VisualFactory::Get();
.Add( "frameDelay", 200 )
.Add( "pixelArea", Vector4() )
.Add( "wrapModeU", WrapMode::REPEAT )
- .Add( "wrapModeV", WrapMode::DEFAULT ));
+ .Add( "wrapModeV", WrapMode::DEFAULT )
+ .Add( "cornerRadius", 50.5f ));
Property::Map resultMap;
animatedImageVisual.CreatePropertyMap( resultMap );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( value->Get<int>(), 200, TEST_LOCATION );
+ value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 11, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS, "cornerRadius" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<float>(), 50.5f, TEST_LOCATION );
+
+ value = resultMap.Find( Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get<int>() == Visual::Transform::Policy::ABSOLUTE );
+
END_TEST;
}
-int UtcDaliAnimatedImageVisualGetPropertyMap03(void)
+int UtcDaliAnimatedImageVisualGetPropertyMap04(void)
{
ToolkitTestApplication application;
tet_infoline( "UtcDaliAnimatedImageVisualGetPropertyMap" );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get<int>() == 2 );
+ value = resultMap.Find( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get<int>(), 4, TEST_LOCATION );
+
END_TEST;
}
{
Property::Map propertyMap;
- propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
- propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
- propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2);
- propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2);
- propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20);
- propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert( Visual::Property::TYPE, Visual::ANIMATED_IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_GIF_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::BATCH_SIZE, 2 );
+ propertyMap.Insert( ImageVisual::Property::CACHE_SIZE, 2 );
+ propertyMap.Insert( ImageVisual::Property::FRAME_DELAY, 20 );
+ propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
+ propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 0.23f );
+ propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE );
VisualFactory factory = VisualFactory::Get();
Visual::Base visual = factory.CreateVisual( propertyMap );
}
END_TEST;
-}
\ No newline at end of file
+}
propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
.Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
.Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
- .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
+ .Add( DevelImageVisual::Property::PLAY_RANGE, playRange )
+ .Add( DevelVisual::Property::CORNER_RADIUS, 50.0f );
Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" );
int startFrame = 1, endFrame = 3;
+ float cornerRadius = 50.0f;
Property::Array playRange;
playRange.PushBack( startFrame );
playRange.PushBack( endFrame );
.Add( "playRange", playRange )
.Add( "stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME )
.Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE )
- .Add( "redrawInScalingDown", false );
+ .Add( "redrawInScalingDown", false )
+ .Add( "cornerRadius", cornerRadius );
Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get< bool >() == false );
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION );
+
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::ABSOLUTE );
+
actor.Unparent( );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" );
int startFrame = 1, endFrame = 3;
+ float cornerRadius = 50.0f;
Property::Array playRange;
playRange.PushBack( startFrame );
playRange.PushBack( endFrame );
propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
.Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
.Add( DevelImageVisual::Property::LOOP_COUNT, 3 )
- .Add( DevelImageVisual::Property::PLAY_RANGE, playRange );
+ .Add( DevelImageVisual::Property::PLAY_RANGE, playRange )
+ .Add( DevelVisual::Property::CORNER_RADIUS, cornerRadius )
+ .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE);
// request AnimatedVectorImageVisual with a property map
VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK( value );
DALI_TEST_CHECK( value->Get< bool >() == true ); // Check default value
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get< float >(), cornerRadius, TEST_LOCATION );
+
+ value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::RELATIVE );
+
// request AnimatedVectorImageVisual with an URL
Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() );
END_TEST;
}
+int UtcDaliArcVisualGetPropertyMap02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliArcVisualGetPropertyMap02" );
+
+ float thickness = 20.0f;
+ float startAngle = 0.0f, sweepAngle = 90.0f;
+
+ Property::Map propertyMap;
+ propertyMap.Add(Visual::Property::TYPE, DevelVisual::ARC)
+ .Add(Visual::Property::MIX_COLOR, Color::RED)
+ .Add(DevelArcVisual::Property::THICKNESS, thickness )
+ .Add(DevelArcVisual::Property::START_ANGLE, startAngle )
+ .Add(DevelArcVisual::Property::SWEEP_ANGLE, sweepAngle )
+ .Add(DevelArcVisual::Property::CAP, DevelArcVisual::Cap::ROUND );
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ Property::Map resultMap;
+ visual.CreatePropertyMap( resultMap );
+
+ // check the property values from the returned map from a visual
+ Property::Value* value = resultMap.Find( Visual::Property::MIX_COLOR, Property::VECTOR4 );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get< Vector4 >(), Color::RED, TEST_LOCATION );
+
+ value = resultMap.Find( DevelArcVisual::Property::THICKNESS, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get< float >(), thickness, TEST_LOCATION );
+
+ value = resultMap.Find( DevelArcVisual::Property::START_ANGLE, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get< float >(), startAngle, TEST_LOCATION );
+
+ value = resultMap.Find( DevelArcVisual::Property::SWEEP_ANGLE, Property::FLOAT );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_EQUALS( value->Get< float >(), sweepAngle, TEST_LOCATION );
+
+ value = resultMap.Find( DevelArcVisual::Property::CAP, Property::INTEGER );
+ DALI_TEST_CHECK( value );
+ DALI_TEST_CHECK( value->Get< int >() == DevelArcVisual::Cap::ROUND );
+
+ END_TEST;
+}
+
int UtcDaliArcVisualUpdateProperty(void)
{
ToolkitTestApplication application;
application.SendNotification();
application.Render();
+ // Check resource status
+ Visual::ResourceStatus status = actor.GetVisualResourceStatus(Control::CONTROL_PROPERTY_END_INDEX + 1);
+ DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // The broken image should be shown.
DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
application.Render();
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
// color visual 1
application.Render();
DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+ }
+
+ // animated image visual
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ float cornerRadius = 24.0f;
+
+ properties[Visual::Property::TYPE] = Visual::ANIMATED_IMAGE;
+ properties[ImageVisual::Property::URL] = TEST_GIF_FILE_NAME;
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius + 10.0f; // Dummy Input
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+ properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE;
+
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
}
+ // vector image visual
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ float cornerRadius = 27.0f;
+
+ properties[Visual::Property::TYPE] = Visual::SVG;
+ properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
+ properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ // Default corner radius policy is absolute.
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+ }
+
+ // animated vector image visual
+ {
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ float cornerRadius = 1.3f;
+
+ properties[Visual::Property::TYPE] = DevelVisual::ANIMATED_VECTOR_IMAGE;
+ properties[ImageVisual::Property::URL] = TEST_VECTOR_IMAGE_FILE_NAME;
+ properties["cornerRadius"] = cornerRadius;
+ properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE;
+
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+ dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ application.GetScene().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
+ }
+
+
END_TEST;
}
application.Render();
Vector3 targetColor(1.0f, 1.0f, 1.0f);
+ Vector2 targetOffset(0.05f, 0.05f);
+ Vector2 targetSize(1.1f, 1.1f);
float targetOpacity = 0.5f;
float targetCornerRadius = 20.0f;
float targetBlurRadius = 10.0f;
Animation animation = Animation::New(1.0f);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), targetColor);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::OFFSET), targetOffset);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::SIZE), targetSize);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelColorVisual::Property::BLUR_RADIUS), targetBlurRadius);
animation.Play();
DALI_TEST_CHECK(colorValue);
DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
+ Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+ Dali::Property::Map* transformMap = transformValue->GetMap();
+ DALI_TEST_CHECK(transformMap);
+
+ Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+ DALI_TEST_CHECK(offsetValue);
+ DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+ Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+ DALI_TEST_CHECK(sizeValue);
+ DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
// Test uniform values
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
application.Render();
Vector3 targetColor(1.0f, 1.0f, 1.0f);
+ Vector2 targetOffset(0.05f, 0.05f);
+ Vector2 targetSize(1.1f, 1.1f);
float targetOpacity = 0.5f;
float targetCornerRadius = 20.0f;
float targetBlurRadius = 10.0f;
Animation animation = Animation::New(1.0f);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "mixColor"), targetColor);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "opacity"), targetOpacity);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "offset"), targetOffset);
+ animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "size"), targetSize);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "cornerRadius"), targetCornerRadius);
animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "blurRadius"), targetBlurRadius);
animation.Play();
DALI_TEST_CHECK(colorValue);
DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
+ Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+ Dali::Property::Map* transformMap = transformValue->GetMap();
+ DALI_TEST_CHECK(transformMap);
+
+ Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+ DALI_TEST_CHECK(offsetValue);
+ DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+ Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+ DALI_TEST_CHECK(sizeValue);
+ DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
// Test uniform values
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
#include <dali.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/public-api/images/pixel-data.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
-
using namespace Dali;
using namespace Toolkit;
static int gPageLoadStartedCallbackCalled = 0;
static int gPageLoadFinishedCallbackCalled = 0;
+static int gScrollEdgeReachedCallbackCalled = 0;
static int gEvaluateJavaScriptCallbackCalled = 0;
static bool gTouched = false;
gPageLoadFinishedCallbackCalled++;
}
+static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
+{
+ gScrollEdgeReachedCallbackCalled++;
+}
+
static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode )
{
}
view.Reload();
view.StopLoading();
view.ClearHistory();
- view.ClearCache();
- view.ClearCookies();
Test::EmitGlobalTimerSignal();
DALI_TEST_CHECK( !view.CanGoBack() );
DALI_TEST_CHECK( !view.CanGoForward() );
END_TEST;
}
-int UtcDaliWebViewProperty1(void)
+int UtcDaliWebViewFocusGainedAndLost(void)
{
- // URL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- std::string local;
- view.SetProperty( WebView::Property::URL, TEST_URL1 );
- Property::Value val = view.GetProperty( WebView::Property::URL );
- DALI_TEST_CHECK( val.Get( local ) );
- DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
+ view.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ view.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ view.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
+ view.SetProperty( Actor::Property::SIZE, Vector2( 800, 600 ) );
+
+ application.GetScene().Add( view );
+ application.SendNotification();
+ application.Render();
+
+ view.SetKeyInputFocus();
+ DALI_TEST_CHECK( view.HasKeyInputFocus() );
+
+ // reset
+ view.ClearKeyInputFocus();
+ DALI_TEST_CHECK( !view.HasKeyInputFocus() );
END_TEST;
}
-int UtcDaliWebViewProperty2(void)
+int UtcDaliWebViewGetWebBackForwardList(void)
{
- // CACHE_MODEL
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue = "DOCUMENT_VIEWER";
- const WebView::CacheModel::Type kTestEnum = WebView::CacheModel::PRIMARY_WEB_BROWSER;
- const std::string kTestValue = "PRIMARY_WEB_BROWSER";
+ Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+ DALI_TEST_CHECK( bfList != 0 );
- // Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ END_TEST;
+}
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::CACHE_MODEL, kTestEnum );
- value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+int UtcDaliWebViewGetWebContext(void)
+{
+ ToolkitTestApplication application;
- view.SetProperty( WebView::Property::CACHE_MODEL, kTestValue );
- value = view.GetProperty( WebView::Property::CACHE_MODEL );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebContext* context = view.GetContext();
+ DALI_TEST_CHECK( context != 0 );
END_TEST;
}
-int UtcDaliWebViewProperty3(void)
+int UtcDaliWebViewGetWebCookieManager(void)
{
- // COOKIE_ACCEPT_POLICY
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const std::string kDefaultValue = "NO_THIRD_PARTY";
- const WebView::CookieAcceptPolicy::Type kTestEnum = WebView::CookieAcceptPolicy::NEVER;
- const std::string kTestValue = "NEVER";
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 );
- // Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ END_TEST;
+}
- // Check Set/GetProperty
- view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestEnum );
- value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+int UtcDaliWebViewGetWebSettings(void)
+{
+ ToolkitTestApplication application;
- view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestValue );
- value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewProperty1(void)
+{
+ // URL
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ std::string local;
+ view.SetProperty( WebView::Property::URL, TEST_URL1 );
+ Property::Value val = view.GetProperty( WebView::Property::URL );
+ DALI_TEST_CHECK( val.Get( local ) );
+ DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
-int UtcDaliWebViewProperty5(void)
+int UtcDaliWebViewProperty9(void)
{
- // ENABLE_JAVASCRIPT
+ // SCROLL_POSITION
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const bool kDefaultValue = true;
- const bool kTestValue = false;
-
// Check default value
- bool output;
- Property::Value value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ Dali::Vector2 output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::ENABLE_JAVASCRIPT, kTestValue );
- value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+ view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // Check default value of scroll size
+ output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
+ DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+ // Check default value of content size
+ output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
+ DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewPropertyTitleFavicon(void)
+{
+ // SCROLL_POSITION
+ ToolkitTestApplication application;
+
+ char argv[] = "--test";
+ WebView view = WebView::New( 1, (char**)&argv );
+ DALI_TEST_CHECK( view );
+
+ // reset something
+ view.ClearAllTilesResources();
+
+ // Check default value of title
+ std::string testValue("title");
+ std::string output;
+ view.GetProperty( WebView::Property::TITLE ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // Check default value of favicon
+ Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
+ DALI_TEST_CHECK( favicon );
+ Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
+ DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
END_TEST;
}
-int UtcDaliWebViewProperty6(void)
+int UtcDaliWebViewScrollBy(void)
{
- // LOAD_IMAGES_AUTOMATICALLY
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const bool kDefaultValue = true;
- const bool kTestValue = false;
+ // load url.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
+ bool signal1 = false;
+ view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
+ DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
+
+ view.LoadUrl( TEST_URL1 );
+ Test::EmitGlobalTimerSignal();
+
+ // set scroll position.
+ Dali::Vector2 output = Dali::Vector2::ONE;
+ Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+ view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // scroll by and trigger scrollEdgeReached event.
+ view.ScrollBy( 50, 50 );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
+ DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_CHECK( signal1 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewEvaluteJavaScript(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+ view.LoadHtmlString( "<body>Hello World!</body>" );
+ view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
+ view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
+ Test::EmitGlobalTimerSignal();
+
+ DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewMethodsForCoverage(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+ view.LoadHtmlString( "<body>Hello World!</body>" );
+ view.AddJavaScriptMessageHandler( "jsObject",
+ []( const std::string& arg ) {
+ }
+ );
+
+ DALI_TEST_CHECK( view );
+
+ END_TEST;
+}
+
+// test cases for web backforward list.
+
+int UtcDaliWebBackForwardListCheckItem(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebBackForwardList* bfList = view.GetBackForwardList();
+ DALI_TEST_CHECK( bfList != 0 )
+
+ unsigned int itemCount = bfList->GetItemCount();
+ DALI_TEST_CHECK( itemCount == 1 )
+
+ Dali::Toolkit::WebBackForwardListItem* citem = bfList->GetCurrentItem();
+ DALI_TEST_CHECK( citem != 0 );
+
+ const std::string kDefaultUrl( "http://url" );
+ std::string testValue = citem->GetUrl();
+ DALI_TEST_EQUALS( testValue, kDefaultUrl, TEST_LOCATION );
+
+ const std::string kDefaultTitle( "title" );
+ testValue = citem->GetTitle();
+ DALI_TEST_EQUALS( testValue, kDefaultTitle, TEST_LOCATION );
+
+ const std::string kDefaultOriginalUrl( "http://originalurl" );
+ testValue = citem->GetOriginalUrl();
+ DALI_TEST_EQUALS( testValue, kDefaultOriginalUrl, TEST_LOCATION );
+
+ Dali::Toolkit::WebBackForwardListItem* item = bfList->GetItemAtIndex( 0 );
+ DALI_TEST_CHECK( item != 0 );
+
+ END_TEST;
+}
+
+// test cases for web context.
+
+int UtcDaliWebContextGetSetCacheModel(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ Dali::Toolkit::WebContext* context = view.GetContext();
+ DALI_TEST_CHECK( context != 0 )
+
+ std::string kDefaultValue;
+
+ // Reset something
+ context->SetProxyUri( kDefaultValue );
+ context->SetCertificateFilePath( kDefaultValue );
+ context->DisableCache( false );
+ context->SetDefaultProxyAuth( kDefaultValue, kDefaultValue );
+ context->DeleteWebDatabase();
+ context->DeleteWebStorage();
+ context->DeleteLocalFileSystem();
+ context->ClearCache();
// Check default value
- bool output;
- Property::Value value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ Dali::WebEngineContext::CacheModel value = context->GetCacheModel();
+ DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY, kTestValue );
- value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ context->SetCacheModel( Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
+ value = context->GetCacheModel();
+ DALI_TEST_CHECK( value == Dali::WebEngineContext::CacheModel::DOCUMENT_BROWSER );
END_TEST;
}
-int UtcDaliWebViewProperty7(void)
+// test cases for web cookie manager.
+
+int UtcDaliWebCookieManagerGetSetCookieAcceptPolicy(void)
{
- // DEFAULT_TEXT_ENCODING_NAME
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
+ Dali::Toolkit::WebCookieManager* cookieManager = view.GetCookieManager();
+ DALI_TEST_CHECK( cookieManager != 0 )
+
const std::string kDefaultValue;
- const std::string kTestValue = "UTF-8";
+
+ // Reset something
+ cookieManager->SetPersistentStorage( kDefaultValue, Dali::WebEngineCookieManager::CookiePersistentStorage::SQLITE );
+ cookieManager->ClearCookies();
// Check default value
- std::string output;
- Property::Value value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ Dali::WebEngineCookieManager::CookieAcceptPolicy value = cookieManager->GetCookieAcceptPolicy();
+ DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME, kTestValue );
- value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ cookieManager->SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
+ value = cookieManager->GetCookieAcceptPolicy();
+ DALI_TEST_CHECK( value == Dali::WebEngineCookieManager::CookieAcceptPolicy::ALWAYS );
END_TEST;
}
-int UtcDaliWebViewProperty8(void)
+// test cases for web settings.
+
+int UtcDaliWebSettingsGetSetDefaultFontSize(void)
{
- // DEFAULT_FONT_SIZE
ToolkitTestApplication application;
WebView view = WebView::New();
DALI_TEST_CHECK( view );
- const int kDefaultValue = 16;
- const int kTestValue = 26;
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
// Check default value
- int output;
- Property::Value value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION );
+ int value = settings->GetDefaultFontSize();
+ DALI_TEST_CHECK( value == 16 );
// Check Set/GetProperty
- view.SetProperty( WebView::Property::DEFAULT_FONT_SIZE, kTestValue );
- value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE );
- DALI_TEST_CHECK( value.Get( output ) );
- DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION );
+ settings->SetDefaultFontSize( 20 );
+ value = settings->GetDefaultFontSize();
+ DALI_TEST_CHECK( value == 20 );
END_TEST;
}
-int UtcDaliWebViewEvaluteJavaScript(void)
+int UtcDaliWebSettingsCheckEnableJavaScript(void)
{
ToolkitTestApplication application;
- WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
- view.LoadHTMLString( "<body>Hello World!</body>" );
- view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
- view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript );
- Test::EmitGlobalTimerSignal();
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
- DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION );
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value is true or not
+ bool value = settings->IsJavaScriptEnabled();
+ DALI_TEST_CHECK( value );
+
+ // Check Set/GetProperty
+ settings->EnableJavaScript( false );
+ value = settings->IsJavaScriptEnabled();
+ DALI_TEST_CHECK( !value );
END_TEST;
}
-
-int UtcDaliWebViewMethodsForCoverage(void)
+int UtcDaliWebSettingsCheckAllowImagesLoadAutomatically(void)
{
ToolkitTestApplication application;
- WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
- view.LoadHTMLString( "<body>Hello World!</body>" );
- view.AddJavaScriptMessageHandler( "jsObject",
- []( const std::string& arg ) {
- }
- );
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+ // Check default value is true or not
+ bool value = settings->AreImagesLoadedAutomatically();
+ DALI_TEST_CHECK( value );
+
+ // Check Set/GetProperty
+ settings->AllowImagesLoadAutomatically( false );
+ value = settings->AreImagesLoadedAutomatically();
+ DALI_TEST_CHECK( !value );
+
+ END_TEST;
+}
+
+int UtcDaliWebSettingsGetSetDefaultTextEncodingName(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
DALI_TEST_CHECK( view );
+ Dali::Toolkit::WebSettings* settings = view.GetSettings();
+ DALI_TEST_CHECK( settings != 0 )
+
+ const std::string kDefaultValue;
+ const std::string kTestValue = "UTF-8";
+
+ // Reset something
+ settings->AllowMixedContents( false );
+ settings->EnableSpatialNavigation( false );
+ settings->EnableWebSecurity( false );
+ settings->AllowFileAccessFromExternalUrl( false );
+ settings->AllowScriptsOpenWindows( false );
+
+ // Check default value
+ std::string value = settings->GetDefaultTextEncodingName();
+ DALI_TEST_EQUALS( value, kDefaultValue, TEST_LOCATION );
+
+ // Check Set/GetProperty
+ settings->SetDefaultTextEncodingName( kTestValue );
+ value = settings->GetDefaultTextEncodingName();
+ DALI_TEST_EQUALS( value, kTestValue, TEST_LOCATION );
+
END_TEST;
}
+
+++ /dev/null
-scripts/tcbuild.sh
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+#---------- DEBUG_BEGIN ----------
+#ARG="-d" # debug-on flag, might be set as $1
+# keyprompt "introductory message" -- wait until any key pressed
+function keyprompt { echo -ne "\n\e[1;31m$1 -- " && read -n 1 && echo -e "\n\e[0m"; }
+# d_bp -- breakpoint at which user need to press any key to proceed
+function d_bp { if [[ "$ARG" == "-d" ]]; then keyprompt "d >> Press any key"; fi }
+# d_showVar VARNAME -- print bash variable name
+function d_showVar { if [ "$ARG" == "-d" -a -n "$1" ]; then echo "d >> ${1} = ${!1}"; fi }
+# d_print "message" -- print a debug message
+function d_print { if [ "$ARG" == "-d" -a -n "$1" ]; then echo -e "d >> $1"; fi }
+#---------- DEBUG_END ----------
+
+PROJECT_DIR="$(cd "$(dirname $0)" && pwd)"
+d_showVar PROJECT_DIR
+
+function gbs_profile {
+perl -e "
+use Config::Tiny;
+my \$Config = Config::Tiny->read( \"\$ENV{HOME}/.gbs.conf\" );
+my \$profile = \$Config->{general}->{profile};
+\$profile =~ s/profile.//;
+print \$profile;"
+}
+
+PROFILE=`gbs_profile`
+RPM_DIR="$HOME/GBS-ROOT/local/repos/$PROFILE/armv7l/RPMS"
+d_showVar RPM_DIR
+
+function add_module {
+ # argument check
+ if [ -z "$1" ]; then echo "Usage: `basename $0` addmod <module_name> [module_lib_name]"; exit 1; fi
+
+ MODULE_NAME=$1
+ d_showVar MODULE_NAME
+ MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/')
+ d_showVar MODULE_NAME_C
+ MODULE_NAME_U=$(echo $MODULE_NAME | sed -e 's/-/_/')
+ d_showVar MODULE_NAME_U
+# MODULE_LIBNAME=${2:-capi-$MODULE_NAME}
+ MODULE_LIBNAME=$1
+ d_showVar MODULE_LIBNAME
+
+ echo "Adding $MODULE_NAME module to project..."
+ d_bp
+ cd $PROJECT_DIR
+ # prepare .spec file
+ echo "-- Generating packaging/core-$MODULE_NAME-tests.spec file"
+ if [ ! -d packaging ]; then mkdir packaging; fi
+ sed -e "s:\[MODULE_NAME\]:$MODULE_NAME:g" -e "s:\[MODULE_LIBNAME\]:$MODULE_LIBNAME:g" \
+ templates/core-\[module_name\]-tests.spec > packaging/core-$MODULE_NAME-tests.spec
+ # prepare src directory
+ mkdir src/$MODULE_NAME
+ echo "-- Generating src/$MODULE_NAME/CMakeLists.txt file"
+ sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" -e "s:%{MODULE_LIBNAME}:$MODULE_LIBNAME:g" \
+ templates/src-directory/CMakeLists.txt > src/$MODULE_NAME/CMakeLists.txt
+ echo "-- Generating src/$MODULE_NAME/tct-$MODULE_NAME-core.c file"
+ sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" \
+ templates/src-directory/tct-\[module_name\]-core.c > src/$MODULE_NAME/tct-$MODULE_NAME-core.c
+ echo "-- Generating src/$MODULE_NAME/utc-$MODULE_NAME.c file"
+ sed -e "s:%{MODULE_NAME_U}:$MODULE_NAME_U:g" -e "s:%{MODULE_NAME_C}:$MODULE_NAME_C:g" \
+ templates/src-directory/utc-\[module_name\].c > src/$MODULE_NAME/utc-$MODULE_NAME.c
+ echo "Task finished successfully"
+}
+
+function rm_module {
+ # argument check
+ if [ -z "$1" ]; then echo "Usage: `basename $0` rmmod <module_name>"; exit 1; fi
+
+ MODULE_NAME=$1
+ d_showVar MODULE_NAME
+
+ echo "Removing $MODULE_NAME module from project..."
+ d_bp
+ echo "---- Updating /opt/tct/packages/package_list.xml"
+ scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/packages/package_list.xml 1
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # echo "---- Updating test plans"
+ # scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/manager/plan/*.xml 1
+ # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+
+ cd $PROJECT_DIR
+ echo "-- Removing packaging/core-$MODULE_NAME-tests.spec file"
+ rm packaging/core-$MODULE_NAME-tests.spec
+ echo "-- Removing src/$MODULE_NAME directory"
+ rm -r src/$MODULE_NAME
+ echo "Task finished successfully"
+}
+
+function build {
+ if [ -n "$1" ]; then
+ (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ cp packaging/core-$1-tests.spec ../packaging
+ cp .gitignore-without-autogenerated-files .gitignore
+ gbs build -A armv7l --spec core-$1-tests.spec --include-all --keep-packs | \
+ tee build.log | stdbuf -o0 sed -e 's/error:/\x1b[1;91m&\x1b[0m/' \
+ -e 's/warning:/\x1b[93m&\x1b[0m/'
+ rm ../packaging/core-$1-tests.spec
+ cp .gitignore-with-autogenerated-files .gitignore
+ else
+ echo "Build requires a module name"
+ exit 1
+ fi
+}
+
+function inst {
+ if [ -z "$1" ]
+ then
+ for mod in `ls -1 src/ | grep -v CMakeLists`
+ do
+
+ if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
+
+ PKG_NAME="core-$mod-tests"
+ d_showVar PKG_NAME
+ VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
+ d_showVar VER
+ PKG_VNAME="$PKG_NAME-$VER"
+ d_showVar PKG_VNAME
+ PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
+ d_showVar PKG_FNAME
+
+ if [ -f "$RPM_DIR/$PKG_FNAME" ]
+ then
+ inst $mod
+ echo ""
+ fi
+ fi
+ done
+ else
+ cd $PROJECT_DIR
+ # setting variables
+ MOD_NAME="$1"
+ d_showVar MOD_NAME
+ PKG_NAME="core-$MOD_NAME-tests"
+ d_showVar PKG_NAME
+ VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
+ d_showVar VER
+ PKG_VNAME="$PKG_NAME-$VER"
+ d_showVar PKG_VNAME
+ PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
+ d_showVar PKG_FNAME
+ TCT_DIR="opt/tct-$MOD_NAME-core-tests"
+ d_showVar TCT_DIR
+
+ echo "Deploying $MOD_NAME suite to tct-mgr..."
+ d_bp
+ # prepare tct directory and files
+ echo "-- Preparing suite .zip file..."
+ echo "---- Creating /tmp/$TCT_DIR directory"
+ rm -r /tmp/opt > /dev/null 2>&1
+ mkdir -p /tmp/$TCT_DIR
+ # README
+ echo "---- Copying /tmp/$TCT_DIR"
+ cp templates/tct-package/README /tmp/$TCT_DIR
+ # rpm
+ echo "---- Copying /tmp/$TCT_DIR package"
+ cp $RPM_DIR/$PKG_FNAME /tmp/$TCT_DIR
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # inst.sh
+ echo "---- Generating /tmp/$TCT_DIR/inst.sh file"
+ sed -e "s:%{PKG_NAME}:\"$PKG_NAME\":g" -e "s:%{PKG_FULLNAME}:\"$PKG_FNAME\":g" \
+ -e "s:%{PKG_DIR}:\"/opt/usr/media/tct/$TCT_DIR\":g" \
+ templates/tct-package/inst.sh > /tmp/$TCT_DIR/inst.sh
+ chmod a+x /tmp/$TCT_DIR/inst.sh
+ # tests.xml
+ echo "---- Generating /tmp/$TCT_DIR"
+ scripts/tctestsgen.sh $MOD_NAME /tmp/$TCT_DIR target
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # zip
+ echo "---- Preparing /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip file"
+ # clear old zips
+ rm -r /tmp/tct/packages > /dev/null 2>&1
+ mkdir -p /tmp/tct/packages
+ # create new zip
+ ( cd /tmp; zip -r /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip opt > /dev/null 2>&1; )
+ # deployment
+ echo "-- Suite deployment..."
+ echo "---- Copying /opt/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip"
+ cp /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip /opt/tct/packages/
+ echo "---- Updating /opt/tct/packages/package_list.xml"
+ scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/packages/package_list.xml 0
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # echo "---- Updating test plans"
+ # for file in `grep -r tct-$MOD_NAME-core-tests /opt/tct/manager/plan/ | cut -d: -f1 | uniq`
+ # do
+ # scripts/tcpackageslistsgen.sh $MOD_NAME $file
+ # done
+ # scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/manager/plan/Full_test.xml
+ # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ echo "Task finished successfully"
+ fi
+}
+
+if [ -z "$1" ]; then
+ # usage note
+ echo "Usage: `basename $0` <addmod|rmmod|build|install> <module_name> [module_lib_name]"
+ exit 1
+elif [ "addmod" == "$1" ]; then
+ # add new module
+ add_module $2 $3
+elif [ "rmmod" == "$1" ]; then
+ # remove module
+ rm_module $2
+elif [ "build" == "$1" ]; then
+ # build the binary
+ build $2
+elif [ "install" == "$1" ]; then
+ # install
+ inst $2
+else
+ echo "Invalid subcommand: $1"
+fi
build
dali.info
+*.dylib
+dali2-*-config.cmake
+libdali2-scene-loader.so*
\ No newline at end of file
FIND_PACKAGE( dali2-adaptor REQUIRED)
ENDIF()
+IF ( APPLE )
+ FIND_PACKAGE( dali2-core REQUIRED)
+ FIND_PACKAGE( dali2-adaptor REQUIRED)
+ENDIF()
+
SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
# Define non-boolean options to CMake
ADD_COMPILE_OPTIONS( /vmg ) # Avoids a 'reinterpret_cast' compile error while compiling signals and callbacks.
ADD_COMPILE_OPTIONS( /wd4251 ) # Ignores warning C4251: "'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'"
ELSE()
+ INCLUDE(CheckCXXCompilerFlag)
+
# Set up compiler flags and warnings
ADD_COMPILE_OPTIONS( -Wno-ignored-qualifiers )
# TODO: Clang is a lot more strict with warnings, we should address
# those issues at some point.
- IF( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
+ # Matches "Clang" or "AppleClang"
+ IF( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
ADD_COMPILE_OPTIONS( -Werror )
ENDIF()
- ADD_COMPILE_OPTIONS( -Wall -Wno-unused-parameter -Wno-float-equal -Wno-class-memaccess )
+ ADD_COMPILE_OPTIONS( -Wall -Wno-unused-parameter -Wno-float-equal )
+ ADD_COMPILE_OPTIONS( -Wall -Wno-unused-parameter -Wno-float-equal )
+ CHECK_CXX_COMPILER_FLAG(-Wno-class-memaccess HAVE_NO_CLASS_MEMACCESS)
+ IF (HAVE_NO_CLASS_MEMACCESS)
+ ADD_COMPILE_OPTIONS( -Wno-class-memaccess )
+ ENDIF()
IF( ENABLE_COVERAGE OR "$ENV{CXXFLAGS}" MATCHES --coverage )
ADD_COMPILE_OPTIONS( --coverage )
SET(LIBTYPE STATIC)
ENDIF()
-IF( WIN32 )
+# Generate source files for shaders
+SET(SHADER_SOURCE_DIR "${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/shaders/")
+SET(SHADER_GENERATED_DIR "${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/generated")
+EXECUTE_PROCESS( COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/shader-generator.sh ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}" )
+
+SET(GENERATED_SHADER_DIR ${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/)
+SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+ "${GENERATED_SHADER_DIR}/generated/"
+ "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
+
+IF( WIN32 OR APPLE )
SET( DALICORE_LDFLAGS
"${DALICORE_LDFLAGS}"
dali2-core::dali2-core )
- FIND_PACKAGE( pthreads REQUIRED )
FIND_PACKAGE( curl REQUIRED )
FIND_LIBRARY( GETOPT_LIBRARY NAMES getopt )
FIND_LIBRARY( EXIF_LIBRARY NAMES libexif )
FIND_PACKAGE( jpeg REQUIRED )
FIND_LIBRARY( TURBO_JPEG_LIBRARY NAMES turbojpeg )
- FIND_PACKAGE( unofficial-fontconfig REQUIRED )
FIND_PACKAGE( freetype REQUIRED )
FIND_PACKAGE( harfbuzz REQUIRED )
FIND_LIBRARY( FRIBIDI_LIBRARY NAMES fribidi )
FIND_PACKAGE( unofficial-angle REQUIRED )
- FIND_PACKAGE( unofficial-cairo REQUIRED )
+ IF(WIN32)
+ FIND_PACKAGE( unofficial-fontconfig REQUIRED )
+ ENDIF()
+
+ FIND_PACKAGE( unofficial-cairo REQUIRED )
FIND_PACKAGE( WebP REQUIRED )
SET( DALIADAPTOR_LDFLAGS
dali2-adaptor::dali2-adaptor )
ENDIF()
+IF ( WIN32 )
+ FIND_PACKAGE( pthreads REQUIRED )
+ENDIF()
ADD_LIBRARY( ${name} ${LIBTYPE} ${SOURCES} )
TARGET_LINK_LIBRARIES( ${name}
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()
INSTALL( FILES ${ROOT_SRC_DIR}/dali-toolkit/dali-toolkit.h DESTINATION ${INCLUDE_DIR}/dali-toolkit )
# package doxygen file (contains doxygen grouping information)
-INSTALL( FILES ${package_doxy_files} DESTINATION ${DEV_INCLUDE_PATH}/dali-toolkit/doc )
+INSTALL( FILES ${package_doxy_files} DESTINATION ${INCLUDE_DIR}/dali-toolkit/doc )
# On some platforms we want to install the data files to different location compare to
# the data location used runtime. For example, on Android we want the toolkit library to load
-cmake_minimum_required(VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.8.2)
set(name "dali2-scene-loader")
project(${name} CXX)
target_link_libraries(${name} log)
endif()
-install(TARGETS ${name} DESTINATION ${prefix}/lib)
+# Generate source files for shaders
+SET(SHADER_SOURCE_DIR "${scene_loader_dir}/internal/graphics/shaders/")
+SET(SHADER_GENERATED_DIR "${scene_loader_dir}/internal/graphics/generated")
+EXECUTE_PROCESS( COMMAND bash -c "${repo_root_dir}/build/tizen/shader-generator.sh ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}" )
+
+SET(GENERATED_SHADER_DIR ${scene_loader_dir}/internal/graphics/)
+SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+ "${GENERATED_SHADER_DIR}/generated/"
+ "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
+
+IF( INSTALL_CMAKE_MODULES )
+ SET_TARGET_PROPERTIES( ${name}
+ PROPERTIES
+ VERSION ${DALI_SCENE_LOADER_VERSION}
+ SOVERSION ${${name}_VERSION_MAJOR}
+ CLEAN_DIRECT_OUPUT 1
+ )
+
+ IF( ENABLE_DEBUG )
+ SET( BIN_DIR "${BIN_DIR}/debug" )
+ SET( LIB_DIR "${LIB_DIR}/debug" )
+ ENDIF()
+
+ # Install the library files.
+ INSTALL( TARGETS ${name}
+ EXPORT ${name}-targets
+ LIBRARY DESTINATION ${LIB_DIR}
+ ARCHIVE DESTINATION ${LIB_DIR}
+ RUNTIME DESTINATION ${BIN_DIR}
+ )
+
+ # Install the cmake modules.
+ INSTALL(
+ EXPORT ${name}-targets
+ NAMESPACE ${name}::
+ FILE ${name}-targets.cmake
+ DESTINATION share/${name}
+ )
+
+ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake "
+ include(CMakeFindDependencyMacro)
+ include(\${CMAKE_CURRENT_LIST_DIR}/${name}-targets.cmake)
+ ")
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake DESTINATION share/${name})
+
+ # Install the pdb file.
+ IF( ENABLE_DEBUG AND WIN32 )
+ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/${name}.pdb DESTINATION ${BIN_DIR} )
+ ENDIF()
+ELSE()
+ # Install the library so file and symlinks
+ INSTALL( TARGETS ${name} DESTINATION ${LIB_DIR} )
+ENDIF()
file(GLOB scene_loader_include_files ${scene_loader_public_api_dir})
install(DIRECTORY ${scene_loader_include_files}
@prefix@/include/dali/devel-api \
../../../dali-toolkit/public-api \
../../../dali-toolkit/devel-api \
+ ../../../dali-scene-loader/public-api \
../../../automated-tests/README.md
# This tag can be used to specify the character encoding of the source files
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
-PREDEFINED = DALI_TOOLKIT_API \
+PREDEFINED = DALI_CORE_API \
+ DALI_ADAPTOR_API \
+ DALI_TOOLKIT_API \
+ DALI_SCENE_LOADER_API \
DALI_INTERNAL \
__attribute__ \
((visibility \
--- /dev/null
+#!/bin/bash
+
+indir=$1
+outdir=$2
+
+mkdir -p $outdir
+
+if [ ! -e $indir ] ; then
+ echo "Error! "$indir" not found!"
+ exit 0
+fi
+
+cd $indir
+all_shaders=$(ls -1 *.{vert,frag,def})
+cd $OLDPWD
+
+# Generate one header file per shader which is defined as a const std::string_view
+for name in $all_shaders ; do
+ echo "Generating header files for $name..."
+ varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
+
+ newname=$(echo ${name} | sed -e 's/\./-/;')".h"
+ echo Writing $newname
+
+ shader_fullpath=$(echo ${indir})$name
+
+ header_name="${varname}_GEN_H"
+ echo "const std::string_view" "$varname""{" > $outdir/$newname
+ cat $shader_fullpath | sed -e 's/^..*$/"&\\n"/' >> $outdir/$newname
+ echo "};" >> $outdir/$newname
+done
+
+# Generate one cpp file that includes all the previously generated string_views for shaders
+echo "Generating cpp file..."
+echo -e "#include \"../builtin-shader-extern-gen.h\"\n" > $outdir/builtin-shader-gen.cpp
+
+varnames=
+for name in $all_shaders ; do
+ varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
+ newname=$(echo ${name} | sed -e 's/\./-/;')".h"
+ varnames="${varnames} $varname"
+ echo "#include \"$newname\"" >> $outdir/builtin-shader-gen.cpp
+done
+
+# Generate one header file that defines all the shader string_views as extern variables
+echo "Generating extern header file ( for external use )..."
+echo "#ifndef GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H" > $outdir/../builtin-shader-extern-gen.h
+echo -e "#define GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H\n" >> $outdir/../builtin-shader-extern-gen.h
+
+echo "#include <string_view>" >> $outdir/../builtin-shader-extern-gen.h
+echo "" >> $outdir/../builtin-shader-extern-gen.h
+
+for name in $all_shaders ; do
+ varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
+ newname=$(echo ${name} | sed -e 's/\./-/;')".h"
+ echo "extern const std::string_view $varname;" >> $outdir/../builtin-shader-extern-gen.h
+done
+cat >> $outdir/../builtin-shader-extern-gen.h << EOF
+
+#endif // GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H
+EOF
+
-# dali-sceen-loader
+# Table of contents
+ * [Overview](#overview)
+ * [`scenes`](#scenes)
+ * [`nodes`](#nodes)
+ * [Transformations](#transformations)
+ * [Size](#size)
+ * [Visibility](#visibility)
+ * [`children`](#children)
+ * [`customization`](#customization)
+ * [Renderables](#renderables)
+ * [`model`](#model)
+ * [`arc`](#arc)
+ * [`inverseBindPoseMatrix`](#inversebindposematrix)
+ * [`materials`](#materials)
+ * [`meshes`](#meshes)
+ * [`shaders`](#shaders)
+ * [`rendererState`](#rendererState)
+ * [`defines`](#defines)
+ * [`hints`](#hints)
+ * [Uniforms](#uniforms)
+ * [`skeletons`](#skeletons)
+ * [`cameras`](#cameras)
+ * [Perspective cameras](#perspective-cameras)
+ * [Orthographic cameras](#orthographic-cameras)
+ * [`lights`](#lights)
+ * [`animations`](#animations)
+ * [`properties`](#properties)
+ * [`keyFramesBin`](#keyframesbin)
+ * [`keyFrames`](#keyFrames)
+ * [`value`](#value)
+ * [`animationGroups`](#animationGroups)
-Provides functionality for loading scenes created in the JSON-based DLI format. DLI is most similar to glTF, but less verbose / granular, and it has a few extra features:
+# Overview
+DLI is a JSON based format for representing 3D scenes.
+ * Like glTF, the DLI document defines a set of scenes, which in turn define a hierarchical structure of nodes, and the additional data required to render them - meshes, geometry.
+ * Unlike glTF, it allows definitions of shaders, environment maps, and lighting parameters as well;
+ * Unlike glTF, DLI does not concern itself with buffers, buffer views and accessors;
+ * It supports customizations, which allow replacing parts of the scene based on customization tags and options, without reloading the whole scene.
+ * It supports the processing of custom categories, which can be scheduled to take place prior to or after the processing of the scene data, as well as custom node and animation processors.
-- customizations: switch between alternative definitions of parts of the scene;
-- environment maps;
-- text, arc, and image elements;
-- etc. (TODO)
+# `scenes`
+The "scenes" element is an array of JSON objects, each of which must define a `nodes` array with the index of the definition of the root node.
-Please refer to [dli-exporter](http://github.com/dalihub/dli-exporter) for converting 3D models to DLI.
+:warning: The array must not be empty. Only the first element is used.
+An optional `scene` element with an integer value may be defined to specify the index of the first scene to be created.
+The rest of the scenes are created in the order of their definition (from index 0 to the highest, skipping the default - already created - scene).
+```js
+{
+ "scene": 0,
+ "scenes": [ { "nodes": [ 0 ] } ],
+ "nodes": [ {
+ "name": "some_unique_name"
+ } ]
+}
+```
-## Prequisites
+# `nodes`
+The 3D scene is built using a hierarchy of nodes, which are used to position the objects to render.
-- Windows:
+:warning: Each node must have a `name` string that 1, is not an empty string and 2, is unique within the DLI document. The use of alpha-numeric characters and underscore only is highly recommeneded.
- - Microsoft Visual Studio 2017 (or later, with 2017 build tools);
- - [windows-dependencies](https://github.com/dalihub/windows-dependencies ) - please follow the steps in its README.md *as well as* its vcpkg-script/ReadMe.md, to install VCPKG and all dependencies;
-
-- Linux:
+## Transformations
+There are two ways to define the local transform of each nodes. Both are optional, defaulting to a position at the origin, a scale of one and no rotation.
+ * A `matrix` array of 16 numerical values defining a column-major 4x4 matrix;
+ * A `position` array of 3 numerical values defining a 3D vector and an `angle` array of 3 numerical values defining euler angles of rotation along the 3 axes.
- - GCC v9.3+;
- - CMake v3.14+;
- - [dali-core](https://github.com/dalihub/dali-core );
- - [dali-adaptor](https://github.com/dalihub/dali-adaptor );
- - [dali-toolkit](https://github.com/dalihub/dali-toolkit );
- - configure DALi environment by following the instructions in README.md, in dali-core;
+## Size
+The size of the bounding box of a node may be specified using either of the optional `size` or `bounds` properties, as arrays of 2 or 3 numerical values. Its default value is the unit vector.
-## Build instructions
+## Visibility
+The `visible` optional boolean property defines whether a node and its children are rendered (`true`) or not (`false`).
-1, build the DALi libraries;
+## `children`
+An array of 0 or more indices into the top level `nodes` array, which shall inherit the transform and visibility of their parent node.
-2,
+:warning: Nodes are processed in the order they are encountered during the depth-first traversal of the hierarchy.
+```js
+ "nodes": [ {
+ "name": "hip",
+ "children": [ 3, 1, 2 ]
+ }, {
+ "name": "spine"
+ }, {
+ "name": "left leg"
+ }, {
+ "name": "right leg"
+ } ]
+```
- - Windows: refer to the VS2017 solution in the windows-dependencies repository;
- - Linux: run the ../build/tizen/dali-scene-loader/build.sh;
- - Tizen:
+## `customization`
+Customizations may allow creating a different sub-tree of each node that define them, based on application specific configuration settings known at the time of creating the scene.
+The definition of a `customization` is a single string tag:
+```js
+ "nodes": [ {
+ "name": "Soup du jour",
+ "customization": "flavor", // this one
+ "children": [ 1, 2, 3 ]
+ }, {
+ "name": "Broccoli and Stilton",
+ }, {
+ "name": "Butternut Squash",
+ }, {
+ "name": "Strawberry and Cream",
+ } ]
+```
+:warning: Customizations and renderables are mutually exclusive on the same node.
- $ gbs build -A ${target_arch}
+## Renderables
+There is support for two types of nodes that define renderable content.
+The definition of these renderables come in sub-objects.
+All of them support a `color` property, which is an array of 3 or 4 numerical values for RGB or RGBA components. For the alpha value to take effect, alpha blending must be enabled; this is controlled by the [material](#materiaL).
- - for debug, add: --define "%enable_debug 1"
- - for SMACK-enabled targets, add: --define "%enable_dali_smack_rules 1"
+:warning: Customizations and renderables are mutually exclusive on the same node.
+
+### `model`
+Provides definition for a 3D object, which requires a `mesh`, `shader` and `material`.
+Each of these are provided in form of an integer index into the related top-level array of the DLI document.
+
+:warning: `mesh` must be provided; the rest are optional and default to 0.
+```js
+ "nodes": [ {
+ "name": "Sphere",
+ "model": {
+ "mesh": 0, // required
+ "shader": 0, // optional, defaults to 0
+ "material": 1 // optional, defaults to 0
+ }
+ } ]
+```
+
+### `arc`
+Arc is a specialisation of a model that allows the rendering of circular progress bars. As such, it also must provide a `mesh` ID.
+```js
+ "nodes": [ {
+ "name": "Any Name",
+ "arc": {
+ "mesh": 0, // required
+ "shader": 0, // optional, defaults to 0
+ "material": 1 // optional, defaults to 0
+ "antiAliasing": true,
+ "radius": -0.928,
+ "startAngle": -81.0,
+ "endAngle": 261
+ }
+ } ]
+```
+ * `startAngle` and `endAngle` are the angular positions where the arc starts and ends, in degrees.
+ * `radius` is the inner radius of the arc, the outer radius being defined by the [`size`](#size) of the node.
+ * `antiAliasing` defines whether the edges of the arc should be smoothed.
+
+## `inverseBindPoseMatrix`
+Nodes that serve as joints of a [skeleton](#skeleton) must define this property as an array of 16 numerical values for a column major 4x4 matrix.
+```js
+ "nodes": [ {
+ "name" : "l_shoulder_JNT",
+ "inverseBindPoseMatrix" : [ 0.996081, -0.0407448, 0.0785079, 0.0, 0.0273643, 0.985992, 0.164531, 0.0, -0.0841121, -0.161738, 0.983242, 0.0, -0.0637747, -1.16091, -0.161038, 1.0 ]
+ } ]
+```
+
+# `environment`
+An array of environment map definitions, which have the following format:
+```js
+ "environment": [{
+ "cubeSpecular": "Studio_001/Radiance.ktx",
+ "cubeDiffuse": "Studio_001/Irradiance.ktx",
+ "cubeInitialOrientation": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ]
+ } ]
+```
+`cubeSpecular` and `cubeDiffuse` are the names of the respective cube map files that will be attempted to be located from the _environment_ path, which is up to the application. A 1x1x1 white RGB888 cubemap is created in place of either that was omitted.
+`cubeInitialOrientation` may be used to inform the (PBR) shader of a matrix which describes the initial orientation of the cube map. Defaults to the identity matrix.
+
+# `materials`
+Defines configurations of textures (and their samplers) that form materials. These can be created from single values or image files (in the formats that DALi supports).
+```js
+ "materials": [ {
+ "environment": 0,
+ "albedoMap": "A.png",
+ "normal": "N.png",
+ "metallicRoughnessMap": "MR.png",
+ "color": [ 1.0, 0.8, 0.7, 0.5 ]
+ } ]
+```
+ * `environment`: The index of the [environment map](#environments) to use. Single integer, defaults to `0`.
+ * `mipmap`: A boolean to speficy if the creation and sampling of mipmaps should be enabled. Off by default.
+ * `color`: Base color, which the color of the node gets multiplied by. Defaults to white.
+ * `metallic` and `roughness`: Properties for PBR materials; both are expected to be a single numerical value and default to `1.0`.
+
+## Texture maps
+`albedoMap` / `albedoMetallicMap` / `normalMap` / `normalRoughnessMap` / `metallicRoughnessMap` / `subsurfaceMap`: define various texture semantics, i.e. the role of the texture, which shall be loaded from an image _inside the materials path_, which is up to the application. All of them are optional.
+
+:warning: Semantics shall not overlap within the same material, e.g. multiple albedo definitions, or albedo and albedoMetallic.
+
+# `meshes`
+Defines an array of meshes which are used to access geometry data stored in a binary file. The `uri` property is used to locate each file _inside the mesh path_, which is up to the application; alternatively it can be set to `"quad"`, resulting in the creation of a unit quad.
+Those models loaded from a file may provide an accessor, and flag its presence in the `attributes` bitmask property. The following are supported:
+|Attribute Name|Bit|Decimal value|Type|Remarks|
+|-|-|-|-|-|
+|`indices` |0| 1|unsigned short||
+|`positions`|1| 2|Vector3||
+|`normals` |2| 4|Vector3||
+|`textures` |3| 8|Vector2|UVs|
+|`tangents` |4| 16|Vector3||
+| |5| 32||Ignored, but reserved for bitangents|
+|`joints0` |6| 64|Vector4|Joint IDs for skinned meshes|
+|`weights0` |7|128|Vector4|Joint weights for skinned meshes|
+
+E.g. if positions, normals and tangents are provided, the `attributes` property must have a value of 2 + 4 + 16 = 22.
+Each attribute must provide a `byteOffset` and `byteLength` property, which must be correctly sized for the type of the given attribute.
+Finally, to specify what primitives should the geometry be rendered as, a `primitive` property may be provided with one of the following values: `TRIANGLES` (default), `LINES`, `POINTS`.
+
+## Skinned meshes
+DLI supports meshes that allow deformation by skeletal animation. These must define a few additional properties:
+ * `joints0` and `weights0` attributes, as above.
+ * A [`skeleton`](#skeletons) ID, to specify which (joint) nodes' transformations affect the mesh.
+
+:warning: The maximum number of bones supported by DALi Scene Loader is `64`.
+
+## Blend shapes
+Blend shapes provide alternate configurations of vertex `positions`, `normals` and/or `tangents` that may be blended with the same attributes of the base mesh, controlled by an animatable `weight`.
+```js
+ "meshes": [ {
+ "uri": "example.bin",
+ "attributes": 2,
+ "positions": {
+ "byteOffset": 0,
+ "byteLength": 12000
+ },
+ "blendShapesHeader": {
+ "version": "2.0",
+ "byteOffset": 12000,
+ "byteLEngth": 4
+ },
+ "blendShapes": [ {
+ "weight": 0.0,
+ "positions": {
+ byteOffset: 12004,
+ byteLength: 12000
+ }
+ } ]
+ } ]
+```
+A `blendShapesHeader`, if present, must define:
+ * the `version` of the blend shapes; supported values are `1.0` and `2.0`. The difference between the versions is that v1.0 requires a per-blend shape definition of an un-normalization factor.
+ * the `byteOffset` and `byteLength` of a buffer in the binary which defines the width (2 bytes) and height (2 bytes) of the texture that dali-scene-loader creates for blend shape data.
+
+The `blendShapes` array then defines the shapes that are available to blend between, comprising of:
+ * An initial `weight` numerical, the default is 0;
+ * `position` / `normals` / `tangents` attributes, which must be also present in the base mesh and are the same format (`byteOffset` / `byteLength`);
+
+:warning: The size of the attributes of the blend shape must match that of the base mesh (and each other) - i.e. they must define the same number of vertices.
+
+# `shaders`
+Provides an array of shader programs that renderables may use for rendering.
+For each shader, `vertex` and `fragment` are required string properties pointing to the shader files _inside the shader path_, which is up to the application.
+ * `rendererState`: This string defines the options for configuring the settings of the renderer. Refer to public-api/renderer-state.h for details.
+ * `defines`: An optional array of strings which will be used to create #defines into the vertex and fragment shaders.
+ * `hints`: An optional array of strings that map to `Dali::Shader::Hint` values. Therefore two values are supported - `MODIFIES_GEOMETRY` and `OUTPUT_IS_TRANSPARENT`.
+
+## Uniforms
+Every property that is not one of the reserved keys above, will be attempted to be registered as a uniform of the same name.
+
+:warning: Boolean values will be converted to floating point 1.0 (for `true`) or 0.0 (for `false`).
+
+:warning: Integer values will be converted to floating point.
+
+:warning: Arrays of numerical values will be treated as one of the vec2 / vec3 / vec4 / mat3 / mat4 types, depending on what do they define sufficient components for.
+```js
+ "shaders": [ {
+ "vertex": "dli_pbr.vsh",
+ "fragment": "dli_pbr.fsh",
+ "defines": [ "HIGHP", SKINNING" ],
+ "rendererState": "DEPTH_WRITE|DEPTH_TEST|CULL_BACK",
+ "hints":
+ "uMaxLOD": 6
+ } ]
+```
+
+# `skeletons`
+Skeletons in DLI simply define the name of a `node` that shall serve as the _root joint_ of the given skeleton.
+```js
+ "skeletons": [ {
+ "node": "hipJoint"
+ } ]
+```
+The Joint IDs in skinned mesh data relate to the descendants of the [node](#nodes) identified as the root joint that are joints, i.e. define [`inverseBindPoseMatrix`](#inversebindposematrix), in depth-first traversal order.
+
+# `cameras`
+Define the transformation of viewers and the projection used by them.
+All cameras may define:
+ * `matrix`: an array of 16 numerical values for the transform matrix
+ * `near` and `far` values for the position of the respective clipping planes. These default to `0.1` and `1000.0`, respectively.
+
+## Perspective cameras
+This projection type - and a vertical field of view of `60` degrees - is the default.
+The (V)FOV can be specified in the `fov` property, as a single numerical value.
+
+## Orthographic cameras
+If the `orthographic` is defined with an array of four numerical values for the left, right, bottom and top clipping planes (in this order), then orthographic projection is used, and `fov` is ignored.
+
+# `lights`
+Define parameters for a single light source - the implementation is up to the application. The following properties are supported.
+ * `transform`: matrix of 16 numerical values for the positioning / directing of the light;
+ * `color`: array of 3 components for RGB;
+ * `intensity`: single float;
+ * `shadowIntensity`: single float;
+ * `shadowMapSize`: unsigned integer size (same width & height) of shadow map.
+ * `orthographicSize`: single float to define the size (same width & height) of orthographic position.
+
+# `animations`
+Animations provide a way to change properties of nodes (and those of their renderables) over time.
+```js
+ "animations": [ {
+ "name": "Idle",
+ "loopCount": 0,
+ "duration": 4.0,
+ "endAction": "DISCARD",
+ "disconnectAction": "DISCARD",
+ "properties": []
+ } ]
+```
+ * `name`: the identifier to look the animation up by;
+ * `loopCount`: the number of times that the animation should be played. The default is `1`; `0` signifies infinity repetitions.
+ * `duration`: the duration of the animation in seconds. If not provided, it will be calculated from the properties.
+ * `endAction` and `disconnectAction`: the supported values, defaults and their meaning are described in the `Dali::Animation::EndAction` enum;
+
+## `properties`
+An array of animation property definitions.
+ * `node`: the name of the node whose property shall be animated;
+ * `property`: the name that the property was registered under.
+ * `alphaFunction`: the name of an alpha function which shall be used in animating a value, or between key frames;
+ * `timePeriod`: `delay` (defaults to `0.0`) and `duration` (defaults to the `duration` of the animation) of the property animation, in sceonds;
+
+The property may be animated using one of the following methods. They are listed in priority order; if e.g. a property defines `keyFramesBin` and `keyFrames`, then only `keyFramesBin` is used.
+
+### `keyFramesBin`
+JSON object that defines a keyframe animation in a binary buffer, with the following properties:
+ * `url` the path to the file containing the buffer;
+ * `numKeys`: the number of keys.
+ * `byteOffset`: offset to the start of the buffer
+
+The size of the buffer depends on the property being animated, where the property value for each frame follows a 4 byte floating point value determining progress (between 0 and 1).
+
+:warning: Only `position` (3D vector of floats, 12 bytes), `rotation` (Quaternion, 12 bytes), and `scale` (3D vector, 12 bytes) properties are supported.
+
+### `keyFrames`
+JSON array of keyframe objects defined with the following properties:
+ * `progress`: a scalar between `0` and `1` to apply to the duration to get the time stamp of the frame;
+ * `value`: array of 3 or 4 numerical values depending on which property is being animated;
+
+:warning: Only `position`, `rotation`, and `scale` properties are supported.
+
+### `value`
+Value animations animate a property using a single value that may be absolute or relative.
+The properties it supports are the following:
+ * `value`: the value to animate to (if absolute) or by (if `relative`);
+ * `relative`: whether `value` is a target, or an offset;
+
+# `animationGroups`
+Animation groups simply group animations together by name, under another name, which may be used to trigger them at the same time.
+```js
+ "animationGroups": [ {
+ "name": "Idle",
+ "animations": [ "IdleBody", "IdleFace" ]
+ } ]
+```
--- /dev/null
+#version 300 es
+
+precision mediump float;
+flat in float vColor;
+out vec4 FragColor;
+
+void main()
+{
+ vec3 rgb = vec3(fract(vColor), fract(vColor * 0.00390625), fract(vColor * 0.00390625 * 0.00390625));
+ FragColor = vec4(rgb, 1.);
+}
\ No newline at end of file
--- /dev/null
+#version 300 es
+
+precision mediump float;
+uniform mat4 uMvpMatrix;
+in vec3 aPosition;
+in float aColor;
+flat out float vColor;
+
+void main()
+{
+ vColor = aColor;
+ gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
+}
\ No newline at end of file
return endAction;
}
-AnimationDefinition::AnimationDefinition()
-{}
+AnimationDefinition::AnimationDefinition() = default;
AnimationDefinition::AnimationDefinition(AnimationDefinition&& other)
-: mName(std::move(other.mName)),
+: mName(std::move(other.mName)),
mDuration(other.mDuration),
mLoopCount(other.mLoopCount),
mDisconnectAction(other.mDisconnectAction),
* on the given @a shader and @a actor.
*/
static void ConfigureProperties(const std::pair<MeshDefinition, MeshGeometry>& mesh, Shader shader, Actor actor);
+
+ BlendShapes() = delete;
};
}
struct DALI_SCENE_LOADER_API CameraParameters
{
- CameraParameters()
- : matrix(Matrix::IDENTITY),
- orthographicSize(-1.f, 1.f, 1.f, -1.f),
- yFov(60.f),
- zNear(0.1f),
- zFar(1000.f),
- isPerspective(true)
- {}
-
- ~CameraParameters() = default;
-
- Matrix matrix;
- Vector4 orthographicSize;
- float yFov;
- float zNear;
- float zFar;
- bool isPerspective;
+ Matrix matrix = Matrix::IDENTITY;
+ Vector4 orthographicSize = Vector4{ -1.f, 1.f, 1.f, -1.f };
+ float yFov = 60.f;
+ float zNear = 0.1f;
+ float zFar = 1000.f;
+ bool isPerspective = true;
/**
* @return The view-projection matrix of the camera.
ReadFloat(eArc->GetChild("endAngle"), arc.mEndAngleDegrees);
}
-const TreeNode *Tidx(const TreeNode *node, int index)
+const TreeNode *GetNthChild(const TreeNode *node, uint32_t index)
{
- int i = 0;
+ uint32_t i = 0;
for (TreeNode::ConstIterator it = (*node).CBegin(); it != (*node).CEnd(); ++it, ++i)
{
if (i == index)
void DliLoader::Impl::ParseSceneInternal(Index iScene, const Toolkit::TreeNode* tnScenes,
const Toolkit::TreeNode* tnNodes, LoadParams& params)
{
- auto getSceneRootIdx = [&](Index iScene) {
- auto tn = Tidx(tnScenes, iScene); // now a "scene" object
+ auto getSceneRootIdx = [tnScenes, tnNodes](Index iScene) {
+ auto tn = GetNthChild(tnScenes, iScene); // now a "scene" object
if (!tn)
{
ExceptionFlinger(ASSERT_LOCATION) << iScene << " is out of bounds access into " << SCENES << ".";
" must define a node id.";
}
- tn = Tidx(tn, 0); // now the first element of the array
+ tn = GetNthChild(tn, 0); // now the first element of the array
Index iRootNode;
if (!ReadIndex(tn, iRootNode))
{
ExceptionFlinger(ASSERT_LOCATION) << "Root node index << " << iRootNode << " of scene " << iScene << " is out of bounds.";
}
- tn = Tidx(tnNodes, iRootNode); // now a "node" object
+ tn = GetNthChild(tnNodes, iRootNode); // now a "node" object
if (tn->GetType() != TreeNode::OBJECT)
{
ExceptionFlinger(ASSERT_LOCATION) << "Root node of scene " << iScene << " is of invalid JSON type; object required";
std::vector<IndexProperty> resourceIds;
resourceIds.reserve(4);
- if (auto node = Tidx(nodes, index))
+ if (auto node = GetNthChild(nodes, index))
{
NodeDefinition nodeDef;
nodeDef.mParentIdx = inOutParentStack.empty() ? INVALID_INDEX : inOutParentStack.back();
const float duration = LoadDataFromAccessors<float>(path, input, output, inputDataBuffer, outputDataBuffer);
char weightNameBuffer[32];
- char* const pWeightName = weightNameBuffer + sprintf(weightNameBuffer, "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str());
+ auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str());
+ char* const pWeightName = weightNameBuffer + prefixSize;
+ const auto remainingSize = sizeof(weightNameBuffer) - prefixSize;
for (uint32_t weightIndex = 0u, endWeightIndex = channel.mSampler->mOutput->mCount / channel.mSampler->mInput->mCount; weightIndex < endWeightIndex; ++weightIndex)
{
AnimatedProperty& animatedProperty = properties[propertyIndex++];
animatedProperty.mNodeName = nodeName;
- sprintf(pWeightName, "%d]", weightIndex);
+ snprintf(pWeightName, remainingSize, "%d]", weightIndex);
animatedProperty.mPropertyName = std::string(weightNameBuffer);
animatedProperty.mKeyFrames = KeyFrames::New();
return sampler;
}
+TextureDefinition::TextureDefinition(const std::string& imageUri, SamplerFlags::Type samplerFlags)
+: mImageUri(imageUri),
+ mSamplerFlags(samplerFlags)
+{}
+
MaterialDefinition::RawData
MaterialDefinition::LoadRaw(const std::string& imagesPath) const
{
std::string mImageUri;
SamplerFlags::Type mSamplerFlags;
- TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT)
- : mImageUri(imageUri),
- mSamplerFlags(samplerFlags)
- {}
+ TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT);
};
/**
};
-const std::string QUAD_STRING("quad");
+const std::string QUAD("quad");
///@brief Reads a blob from the given stream @a source into @a target, which must have
/// at least @a descriptor.length bytes.
{
DALI_ASSERT_DEBUG(0u != totalTextureSize && "totalTextureSize is zero.")
- // Calculate the dimensions of the texture.
- // The total size of the texture is the length of the blend shapes blob.
+ // Calculate the dimensions of the texture.
+ // The total size of the texture is the length of the blend shapes blob.
- textureWidth = 0u;
+ textureWidth = 0u;
textureHeight = 0u;
if (0u == totalTextureSize)
}
MeshDefinition::SparseBlob::SparseBlob(const Blob& indices, const Blob& values, uint32_t count)
-: mIndices{indices},
+: mIndices{indices},
mValues{values},
mCount{count}
{}
MeshDefinition::Accessor::Accessor(const MeshDefinition::Blob& blob,
const MeshDefinition::SparseBlob& sparse)
-: mBlob{blob},
+: mBlob{blob},
mSparse{(sparse.mIndices.IsDefined() && sparse.mValues.IsDefined()) ? new SparseBlob{sparse} : nullptr}
{}
void MeshDefinition::Blob::ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max,
uint32_t count, float* values)
{
- DALI_ASSERT_DEBUG(max.empty() || max.size() == min.size());
+ DALI_ASSERT_DEBUG(max.size() == min.size() || max.size() * min.size() == 0);
const auto numComponents = std::max(min.size(), max.size());
using ClampFn = void(*)(const float*, const float*, uint32_t, float&);
}
}
+MeshDefinition::Blob::Blob(uint32_t offset, uint32_t length, uint16_t stride, uint16_t elementSizeHint, const std::vector<float>& min, const std::vector<float>& max)
+: mOffset(offset),
+ mLength(length),
+ mStride(stride),
+ mElementSizeHint(elementSizeHint),
+ mMin(min),
+ mMax(max)
+{}
+
uint32_t MeshDefinition::Blob::GetBufferSize() const
{
return IsConsecutive() ? mLength : (mLength * mElementSizeHint / mStride);
bool MeshDefinition::IsQuad() const
{
- return CaseInsensitiveStringCompare("quad", mUri);
+ return CaseInsensitiveStringCompare(QUAD, mUri);
}
bool MeshDefinition::IsSkinned() const
Blob() = default;
Blob(uint32_t offset, uint32_t length, uint16_t stride = 0, uint16_t elementSizeHint = 0,
- const std::vector<float>& min = {}, const std::vector<float>& max = {})
- : mOffset(offset),
- mLength(length),
- mStride(stride),
- mElementSizeHint(elementSizeHint),
- mMin(min),
- mMax(max)
- {}
+ const std::vector<float>& min = {}, const std::vector<float>& max = {});
/**
* @brief Calculates the size of a tightly-packed buffer for the elements from the blob.
class DALI_SCENE_LOADER_API IResourceReceiver
{
public:
- virtual ~IResourceReceiver()
- {}
+ virtual ~IResourceReceiver() = default;
virtual void Register(ResourceType::Value type, Index id) = 0;
};
class DALI_SCENE_LOADER_API IResourceReflector
{
public:
- virtual ~IResourceReflector()
- {}
+ virtual ~IResourceReflector() = default;
virtual void Reflect(ResourceType::Value type, Index& id) = 0;
};
Index mShaderIdx = INVALID_INDEX;
public: // METHODS
- virtual ~Renderable() {}
+ virtual ~Renderable() = default;
virtual void RegisterResources(IResourceReceiver& receiver) const;
virtual void ReflectResources(IResourceReflector& reflector);
virtual void Finish(NodeDefinition& n) = 0;
protected:
- ~IVisitor() {}
+ ~IVisitor() = default; // deliberately non-virtual these are transient objects and we don't want to pay for the vtable.
};
class IConstVisitor
virtual void Finish(const NodeDefinition& n) = 0;
protected:
- ~IConstVisitor() {}
+ ~IConstVisitor() = default; // deliberately non-virtual these are transient objects and we don't want to pay for the vtable.
};
struct Extra
/*
- * 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-scene-loader/public-api/blend-shape-details.h"
#include "dali-scene-loader/public-api/utils.h"
#include "dali-scene-loader/public-api/skinning-details.h"
+#include "dali-scene-loader/internal/graphics/builtin-shader-extern-gen.h"
//#define DEBUG_SCENE_DEFINITION
//#define DEBUG_JOINTS
#ifdef DEBUG_JOINTS
-const char* JOINT_DEBUG_VSH = "#version 300 es\n"
-DALI_COMPOSE_SHADER(
- precision mediump float;
- uniform mat4 uMvpMatrix;
- in vec3 aPosition;
- in float aColor;
- flat out float vColor;
- void main() {
- vColor = aColor;
- gl_Position = uMvpMatrix * vec4(aPosition, 1.0);
- });
-
-const char* JOINT_DEBUG_FSH = "#version 300 es\n"
-DALI_COMPOSE_SHADER(
- precision mediump float;
- flat in float vColor;
- out vec4 FragColor;
- void main() {
- vec3 rgb = vec3(fract(vColor), fract(vColor * 0.00390625), fract(vColor * 0.00390625 * 0.00390625));
- FragColor = vec4(rgb, 1.);
- });
Shader sJointDebugShader;
int sNumScenes = 0;
{
if (0 == sNumScenes)
{
- sJointDebugShader = Shader::New(JOINT_DEBUG_VSH, JOINT_DEBUG_FSH);
+ sJointDebugShader = Shader::New(SHADER_SCENE_LOADER_JOINT_DEBUG_VERT, SHADER_SCENE_LOADER_JOINT_DEBUG_FRAG);
}
++sNumScenes;
}
{
public:
ActorCreatorVisitor(NodeDefinition::CreateParams& params)
- : mCreationContext(params)
+ : mCreationContext(params)
{}
void Start(const NodeDefinition& n)
}
SceneDefinition::SceneDefinition(SceneDefinition&& other)
-: mNodes(std::move(other.mNodes)),
+: mNodes(std::move(other.mNodes)),
mRootNodeIds(std::move(other.mRootNodeIds))
{
#ifdef DEBUG_JOINTS
* @brief Name of bone matrix uniform (array).
*/
static const std::string BONE_UNIFORM_NAME;
+
+ Skinning() = delete;
};
}
thread_local char sExceptionFlingerMessageBuffer[ExceptionFlinger::MESSAGE_BUFFER_SIZE]{};
}
-char* ExceptionFlinger::GetMessageBuffer()
+StreamBuffer::StreamBuffer(char* buffer, size_t size) noexcept(true)
+{
+ setp(buffer, buffer + size);
+}
+
+ExceptionFlinger::Impl::~Impl() noexcept(false)
+{
+ throw DaliException(mLocation, GetMessageBuffer());
+}
+
+ExceptionFlinger::ExceptionFlinger(const char* location) noexcept(true)
+: mImpl{ location },
+ mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1),
+ mStream(&mStreamBuffer)
+{}
+
+ExceptionFlinger::~ExceptionFlinger() noexcept(false)
+{
+ operator<<('\0');
+}
+
+char* ExceptionFlinger::GetMessageBuffer() noexcept(true)
{
return sExceptionFlingerMessageBuffer;
}
class DALI_SCENE_LOADER_API StreamBuffer : public std::basic_streambuf<char>
{
public:
- StreamBuffer(char* buffer, size_t size)
- {
- setp(buffer, buffer + size);
- }
+ StreamBuffer(char* buffer, size_t size) noexcept(true);
};
/*
public:
enum { MESSAGE_BUFFER_SIZE = 512 };
- ExceptionFlinger(const char* location)
- : mLocation(location),
- mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1),
- mStream(&mStreamBuffer)
- {}
+ ExceptionFlinger(const char* location) noexcept(true);
- ~ExceptionFlinger() noexcept(false)
- {
- operator<<('\0');
- throw DaliException(mLocation, GetMessageBuffer());
- }
+ [[noreturn]]
+ ~ExceptionFlinger() noexcept(false);
template <typename T>
- ExceptionFlinger& operator<<(const T& rhs)
+ ExceptionFlinger& operator<<(const T& rhs) noexcept(true)
{
mStream << rhs;
return *this;
}
private:
- static char* GetMessageBuffer();
+ struct Impl
+ {
+ const char* mLocation;
+
+ [[noreturn]]
+ ~Impl() noexcept(false);
+ };
+
+ static char* GetMessageBuffer() noexcept(true);
- const char* mLocation;
+ Impl mImpl;
StreamBuffer mStreamBuffer;
std::ostream mStream;
};
#define DALI_TOOLKIT_UIBUILDER_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 Adds user defined constants to all future style template or animation expansions
*
* e.g.
- * Property::Map map;
- * map["IMAGE_DIRECTORY"] = "/usr/share/images";
- * builder.AddConstants( map );
+ * @code
+ * Property::Map map;
+ * map["IMAGE_DIRECTORY"] = "/usr/share/images";
+ * builder.AddConstants( map );
+ * @endcode
+ *
+ * The following shows a list of constants available by default:
+ *
+ * Constant | Description
+ * ----------------------------- | ----------------------------------------------------------------------------------------------------
+ * DALI_IMAGE_DIR | The Image Directory used by Toolkit.
+ * DALI_SOUND_DIR | The Sound Directory used by Toolkit.
+ * DALI_STYLE_DIR | The Style directory that the Toolkit uses.
+ * DALI_STYLE_IMAGE_DIR | The directory that stores all the images used by Toolkit's style.
+ * DALI_SHADER_VERSION_PREFIX | For use in custom shaders to prepend the shader version in use. @ref Shader::GetShaderVersionPrefix
+ * DALI_VERTEX_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetVertexShaderPrefix
+ * DALI_FRAGMENT_SHADER_PREFIX | For use in custom vertex shaders to preprocessor prefix used. @ref Shader::GetFragmentShaderPrefix()
*
* @pre The Builder has been initialized.
* @param map The user defined constants used in template expansions.
* builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
* @endcode
*
+ * @see AddConstants(const Property::Map&) for builder pre-defined default constants.
+ *
* @pre The Builder has been initialized.
* @param key The constant name to add or update
* @param value The new value for the constant.
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+const std::string EMPTY_STRING;
+
+WebBackForwardListItem::WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item )
+: mWebEngineBackForwardListItem( item )
+{
+}
+
+WebBackForwardListItem::~WebBackForwardListItem()
+{
+}
+
+std::string WebBackForwardListItem::GetUrl() const
+{
+ return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetUrl() : EMPTY_STRING;
+}
+
+std::string WebBackForwardListItem::GetTitle() const
+{
+ return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetTitle() : EMPTY_STRING;
+}
+
+std::string WebBackForwardListItem::GetOriginalUrl() const
+{
+ return mWebEngineBackForwardListItem ? mWebEngineBackForwardListItem->GetOriginalUrl() : EMPTY_STRING;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
+#define DALI_TOOLKIT_WEB_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>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+class WebEngineBackForwardListItem;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebBackForwardListItem is a class for back-forward list item of WebView.
+ *
+ *
+ * For working WebBackForwardListItem, a Dali::WebBackForwardListItem should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebBackForwardListItem
+{
+public:
+ /**
+ * @brief Creates a WebBackForwardListItem.
+ */
+ WebBackForwardListItem( const Dali::WebEngineBackForwardListItem* item );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebBackForwardListItem() final;
+
+ /**
+ * @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 @a item, otherwise "" in case of an error
+ */
+ std::string GetUrl() const;
+
+ /**
+ * @brief Returns the title of the item.
+ *
+ * @return The title of the @a item, otherwise "" in case of an error
+ */
+ std::string GetTitle() const;
+
+ /**
+ * @brief Returns the original URL of the item.
+ *
+ * @return The original URL of the @a item, otherwise "" in case of an error
+ */
+ std::string GetOriginalUrl() const;
+
+private:
+
+ const Dali::WebEngineBackForwardListItem* mWebEngineBackForwardListItem;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_ITEM_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.h>
+#include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebBackForwardList::WebBackForwardList( const Dali::WebEngineBackForwardList& list )
+: mWebEngineBackForwardList( list )
+, mWebBackForwardListItem( 0 )
+{
+}
+
+WebBackForwardList::~WebBackForwardList()
+{
+}
+
+WebBackForwardListItem* WebBackForwardList::GetCurrentItem()
+{
+ mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetCurrentItem() );
+ return &mWebBackForwardListItem;
+}
+
+WebBackForwardListItem* WebBackForwardList::GetItemAtIndex( uint32_t index )
+{
+ mWebBackForwardListItem = WebBackForwardListItem( &mWebEngineBackForwardList.GetItemAtIndex( index ) );
+ return &mWebBackForwardListItem;
+}
+
+uint32_t WebBackForwardList::GetItemCount() const
+{
+ return mWebEngineBackForwardList.GetItemCount();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
+#define DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list-item.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+class WebEngineBackForwardList;
+
+namespace Toolkit
+{
+class WebBackForwardListItem;
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebBackForwardList is a class for back-forward list item of WebView.
+ *
+ *
+ * For working WebBackForwardList, a Dali::WebBackForwardList should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebBackForwardList
+{
+public:
+ /**
+ * @brief Creates a WebBackForwardList.
+ */
+ WebBackForwardList( const Dali::WebEngineBackForwardList& list );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebBackForwardList() final;
+
+ /**
+ * @brief Returns the current item in the @a list.
+ * @return The current item in list.
+ */
+ WebBackForwardListItem* GetCurrentItem();
+
+ /**
+ * @brief Returns the item at a given @a index relative to the current item.
+ * @param[in] index The index of the item
+ * @return The current item in list.
+ */
+ WebBackForwardListItem* GetItemAtIndex(uint32_t index);
+
+ /**
+ * @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 0 in case of an error
+ */
+ uint32_t GetItemCount() const;
+
+private:
+ const Dali::WebEngineBackForwardList& mWebEngineBackForwardList;
+ Dali::Toolkit::WebBackForwardListItem mWebBackForwardListItem;
+
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_BACK_FORWARD_LIST_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebContext::WebContext( Dali::WebEngineContext& context)
+: mWebEngineContext( context )
+{
+}
+
+WebContext::~WebContext()
+{
+}
+
+Dali::WebEngineContext::CacheModel WebContext::GetCacheModel() const
+{
+ return mWebEngineContext.GetCacheModel();
+}
+
+void WebContext::SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel )
+{
+ mWebEngineContext.SetCacheModel( cacheModel );
+}
+
+void WebContext::SetProxyUri( const std::string& uri )
+{
+ mWebEngineContext.SetProxyUri( uri );
+}
+
+void WebContext::SetCertificateFilePath( const std::string& certificatePath )
+{
+ mWebEngineContext.SetCertificateFilePath( certificatePath );
+}
+
+void WebContext::DisableCache( bool cacheDisabled )
+{
+ mWebEngineContext.DisableCache( cacheDisabled );
+}
+
+void WebContext::SetDefaultProxyAuth( const std::string& username, const std::string& password )
+{
+ mWebEngineContext.SetDefaultProxyAuth( username, password );
+}
+
+void WebContext::DeleteWebDatabase()
+{
+ mWebEngineContext.DeleteWebDatabase();
+}
+
+void WebContext::DeleteWebStorage()
+{
+ mWebEngineContext.DeleteWebStorage();
+}
+
+void WebContext::DeleteLocalFileSystem()
+{
+ mWebEngineContext.DeleteLocalFileSystem();
+}
+
+void WebContext::ClearCache()
+{
+ mWebEngineContext.ClearCache();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_CONTEXT_H
+#define DALI_TOOLKIT_WEB_CONTEXT_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 <string>
+#include <dali/devel-api/adaptor-framework/web-engine-context.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebContext is a control for settings of WebView.
+ *
+ * For working WebContext, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebContext
+{
+public:
+
+ /**
+ * @brief Creates a WebContext.
+ *
+ * @param[in] context The context of web engine.
+ */
+ WebContext( Dali::WebEngineContext& context );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebContext() final;
+
+ /**
+ * @brief Returns the cache model type.
+ *
+ * @return #Dali::WebEngineContext::CacheModel
+ */
+ Dali::WebEngineContext::CacheModel GetCacheModel() const;
+
+ /**
+ * @brief Requests to set the cache model.
+ *
+ * @param[in] cacheModel The cache model
+ */
+ void SetCacheModel(Dali::WebEngineContext::CacheModel cacheModel );
+
+ /**
+ * @brief Sets the given proxy URI to network backend of specific context.
+ *
+ * @param[in] uri The proxy URI to set
+ */
+ void SetProxyUri( const std::string& uri );
+
+ /**
+ * 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
+ */
+ void SetCertificateFilePath( const std::string& certificatePath );
+
+ /**
+ * 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
+ */
+ void DisableCache( bool cacheDisabled );
+
+ /**
+ * @brief Sets a proxy auth credential to network backend of specific context.
+ *
+ * @param[in] username username to set
+ * @param[in] password password to set
+ */
+ void SetDefaultProxyAuth( const std::string& username, const std::string& password );
+
+ /**
+ * Requests for deleting all web databases.
+ */
+ void DeleteWebDatabase();
+
+ /**
+ * @brief Deletes web storage.
+ *
+ * @details This function does not ensure that all data will be removed.
+ * Should be used to extend free physical memory.
+ */
+ void DeleteWebStorage();
+
+ /**
+ * @brief Requests for deleting all local file systems.
+ */
+ void DeleteLocalFileSystem();
+
+ /**
+ * @brief Requests to clear cache
+ */
+ void ClearCache();
+
+private:
+
+ Dali::WebEngineContext& mWebEngineContext;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_CONTEXT_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebCookieManager::WebCookieManager( Dali::WebEngineCookieManager& manager )
+: mWebEngineCookieManager( manager )
+{
+}
+
+WebCookieManager::~WebCookieManager()
+{
+}
+
+void WebCookieManager::SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy cookieAcceptPolicy )
+{
+ mWebEngineCookieManager.SetCookieAcceptPolicy( cookieAcceptPolicy );
+}
+
+Dali::WebEngineCookieManager::CookieAcceptPolicy WebCookieManager::GetCookieAcceptPolicy() const
+{
+ return mWebEngineCookieManager.GetCookieAcceptPolicy();
+}
+
+void WebCookieManager::ClearCookies()
+{
+ mWebEngineCookieManager.ClearCookies();
+}
+
+void WebCookieManager::SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage )
+{
+ mWebEngineCookieManager.SetPersistentStorage( path, storage );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
+#define DALI_TOOLKIT_WEB_COOKIE_MANAGER_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 <string>
+#include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineCookieManager;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebCookieManager is a control for settings of WebView.
+ *
+ *
+ * For working WebCookieManager, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebCookieManager
+{
+public:
+
+ /**
+ * @brief Creates a WebCookieManager.
+ * @param[in] manager A #Dali::WebEngineCookieManager
+ */
+ WebCookieManager( Dali::WebEngineCookieManager& manager );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebCookieManager() final;
+
+ /**
+ * @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
+ */
+ void SetCookieAcceptPolicy(Dali::WebEngineCookieManager::CookieAcceptPolicy policy );
+
+ /**
+ * @brief Gets the cookie acceptance policy. The default is Toolkit::WebCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY.
+ * @see Dali::WebEngineCookieManager::CookieAcceptPolicy
+ */
+ Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const;
+
+ /**
+ * @brief Deletes all the cookies of @a manager.
+ */
+ void ClearCookies();
+
+ /**
+ * @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
+ */
+ void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage );
+
+private:
+
+ Dali::WebEngineCookieManager& mWebEngineCookieManager;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_COOKIE_MANAGER_H
--- /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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-settings.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+WebSettings::WebSettings( Dali::WebEngineSettings& settings )
+: mWebEngineSettings( settings )
+{
+}
+
+WebSettings::~WebSettings()
+{
+}
+
+void WebSettings::AllowMixedContents( bool allowed )
+{
+ mWebEngineSettings.AllowMixedContents( allowed );
+}
+
+void WebSettings::EnableSpatialNavigation( bool enabled )
+{
+ mWebEngineSettings.AllowMixedContents( enabled );
+}
+
+int WebSettings::GetDefaultFontSize() const
+{
+ return mWebEngineSettings.GetDefaultFontSize();
+}
+
+void WebSettings::SetDefaultFontSize( int defaultFontSize )
+{
+ mWebEngineSettings.SetDefaultFontSize( defaultFontSize );
+}
+
+void WebSettings::EnableWebSecurity( bool enabled )
+{
+ mWebEngineSettings.EnableWebSecurity( enabled );
+}
+
+void WebSettings::AllowFileAccessFromExternalUrl( bool allowed )
+{
+ mWebEngineSettings.AllowFileAccessFromExternalUrl( allowed );
+}
+
+bool WebSettings::IsJavaScriptEnabled() const
+{
+ return mWebEngineSettings.IsJavaScriptEnabled();
+}
+
+void WebSettings::EnableJavaScript( bool enabled )
+{
+ mWebEngineSettings.EnableJavaScript( enabled );
+}
+
+void WebSettings::AllowScriptsOpenWindows( bool allowed )
+{
+ mWebEngineSettings.AllowScriptsOpenWindows( allowed );
+}
+
+bool WebSettings::AreImagesLoadedAutomatically() const
+{
+ return mWebEngineSettings.AreImagesLoadedAutomatically();
+}
+
+void WebSettings::AllowImagesLoadAutomatically( bool automatic )
+{
+ mWebEngineSettings.AllowImagesLoadAutomatically( automatic );
+}
+
+std::string WebSettings::GetDefaultTextEncodingName() const
+{
+ return mWebEngineSettings.GetDefaultTextEncodingName();
+}
+
+void WebSettings::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
+{
+ mWebEngineSettings.SetDefaultTextEncodingName( defaultTextEncodingName );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_SETTINGS_H
+#define DALI_TOOLKIT_WEB_SETTINGS_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 <string>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+class WebEngineSettings;
+
+namespace Toolkit
+{
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebEngineSettings is a control for settings of WebView.
+ *
+ *
+ * For working WebEngineSettings, a WebView should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebSettings
+{
+public:
+ /**
+ * @brief Creates a WebEngineSettings.
+ *
+ * @param[in] settings A settings of web engine.
+ */
+ WebSettings( Dali::WebEngineSettings& settings );
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~WebSettings() final;
+
+ /**
+ *@brief Allow running mixed contents or not.
+ *
+ * @param[in] allowed if true, allow to run mixed contents,
+ * otherwise not allow
+ */
+ void AllowMixedContents( bool allowed );
+
+ /**
+ * @brief Enable the spatial navigation or not.
+ *
+ * @param[in] enabled if true, use spatial navigation,
+ * otherwise to disable
+ */
+ void EnableSpatialNavigation( bool enabled );
+
+ /**
+ * @brief Returns the default font size in pixel. The default value is 16.
+ *
+ * @return The default font size
+ */
+ int GetDefaultFontSize() const;
+
+ /**
+ * @brief Sets the default font size in pixel. The default value is 16.
+ *
+ * @param[in] defaultFontSize A new default font size to set
+ */
+ void SetDefaultFontSize( int defaultFontSize );
+
+ /**
+ * @brief Enables/disables web security.
+ *
+ * @param[in] enabled if true, to enable the web security
+ * otherwise to disable
+ */
+ void EnableWebSecurity( bool enabled );
+
+ /**
+ * @brief Allow/Disallow file access from external url
+ *
+ * @param[in] allowed if true, to allow file access from external url
+ * otherwise to disallow
+ */
+ void AllowFileAccessFromExternalUrl( bool allowed );
+
+ /**
+ * @brief Returns whether JavaScript can be executable. The default is true.
+ *
+ * @return true if JavaScript executing is enabled, false otherwise
+ */
+ bool IsJavaScriptEnabled() const;
+
+ /**
+ * @brief Enables/disables JavaScript executing. The default is enabled.
+ *
+ * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+ */
+ void EnableJavaScript( bool enabled );
+
+ /**
+ * @brief Allow if the scripts can open new windows.
+ *
+ * @param[in] allowed if true, the scripts can open new windows,
+ * otherwise not
+ */
+ void AllowScriptsOpenWindows( bool allowed );
+
+ /**
+ * @brief Returns whether images can be loaded automatically. The default is true.
+ *
+ * @return true if images are loaded automatically, false otherwise
+ */
+ bool AreImagesLoadedAutomatically() const;
+
+ /**
+ * @brief Enables/disables auto loading of images. The default is enabled.
+ *
+ * @param[in] automatic True if images are loaded automatically, false otherwise
+ */
+ void AllowImagesLoadAutomatically( bool automatic );
+
+ /**
+ * @brief Gets the default text encoding name (e.g. UTF-8).
+ *
+ * @return The default text encoding name
+ */
+ std::string GetDefaultTextEncodingName() const;
+
+ /**
+ * @brief Sets the default text encoding name (e.g. UTF-8).
+ *
+ * @param[in] defaultTextEncodingName The default text encoding name
+ */
+ void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+
+private:
+ Dali::WebEngineSettings& mWebEngineSettings;
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_SETTINGS_H
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/web-view/web-view-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace Dali
{
return Internal::WebView::New(locale, timezoneId);
}
+WebView WebView::New( int argc, char** argv )
+{
+ return Internal::WebView::New( argc, argv );
+}
+
WebView WebView::DownCast(BaseHandle handle)
{
return Control::DownCast<WebView, Internal::WebView>(handle);
}
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetSettings();
+}
+
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetContext();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetCookieManager();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+ return Dali::Toolkit::GetImpl( *this ).GetBackForwardList();
+}
+
+Dali::Toolkit::ImageView& WebView::GetFavicon()
+{
+ return Dali::Toolkit::GetImpl( *this ).GetFavicon();
+}
+
void WebView::LoadUrl(const std::string& url)
{
Dali::Toolkit::GetImpl(*this).LoadUrl(url);
}
-void WebView::LoadHTMLString(const std::string& htmlString)
+void WebView::LoadHtmlString(const std::string& htmlString)
{
- Dali::Toolkit::GetImpl(*this).LoadHTMLString(htmlString);
+ Dali::Toolkit::GetImpl(*this).LoadHtmlString(htmlString);
}
void WebView::Reload()
Dali::Toolkit::GetImpl(*this).Resume();
}
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+ Dali::Toolkit::GetImpl( *this ).ScrollBy( deltaX, deltaY );
+}
+
bool WebView::CanGoForward()
{
return Dali::Toolkit::GetImpl(*this).CanGoForward();
Dali::Toolkit::GetImpl(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
}
-void WebView::ClearHistory()
+void WebView::ClearAllTilesResources()
{
- Dali::Toolkit::GetImpl(*this).ClearHistory();
+ Dali::Toolkit::GetImpl( *this ).ClearAllTilesResources();
}
-void WebView::ClearCache()
-{
- Dali::Toolkit::GetImpl(*this).ClearCache();
-}
-
-void WebView::ClearCookies()
+void WebView::ClearHistory()
{
- Dali::Toolkit::GetImpl(*this).ClearCookies();
+ Dali::Toolkit::GetImpl(*this).ClearHistory();
}
WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
return Dali::Toolkit::GetImpl(*this).PageLoadErrorSignal();
}
+WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+ return Dali::Toolkit::GetImpl( *this ).ScrollEdgeReachedSignal();
+}
+
WebView::WebView(Internal::WebView& implementation)
: Control(implementation)
{
#include <functional>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
#include <dali-toolkit/public-api/controls/control.h>
namespace Dali
{
namespace Toolkit
{
+class ImageView;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
+
namespace Internal DALI_INTERNAL
{
class WebView;
class DALI_TOOLKIT_API WebView : public Control
{
public:
- /**
- * @brief A structure used to contain the cache model enumeration.
- */
- struct CacheModel
- {
- /**
- * @brief Enumeration for cache model options.
- */
- enum Type
- {
- /**
- * @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
- };
- };
-
- /**
- * @brief A structure used to contain the cookie acceptance policy enumeration.
- */
- struct CookieAcceptPolicy
- {
- /**
- * @brief Enumeration for the cookies accept policies.
- */
- enum Type
- {
- /**
- * @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
- };
- };
/**
* @brief Enumeration for the start and end property ranges for this control.
URL = PROPERTY_START_INDEX,
/**
- * @brief The cache model.
- * @details Name "cacheModel", type WebView::CacheModel::Type (Property::INTEGER) or Property::STRING.
- * @note Default is WebView::CacheModel::DOCUMENT_VIEWER.
- * @see WebView::CacheModel::Type
- */
- CACHE_MODEL,
-
- /**
- * @brief The cookie acceptance policy.
- * @details Name "cookieAcceptPolicy", type WebView::CookieAcceptPolicy::Type (Property::INTEGER) or Property::STRING.
- * @note Default is WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
- * @see WebView::CookieAcceptPolicy::Type
- */
- COOKIE_ACCEPT_POLICY,
-
- /**
* @brief The user agent string.
* @details Name "userAgent", type Property::STRING.
*/
USER_AGENT,
/**
- * @brief Whether JavaScript is enabled.
- * @details Name "enableJavaScript", type Property::BOOLEAN.
- * @note Default is true.
+ * @brief The current position of scroll.
+ * @details Name "scrollPosition", type Property::VECTOR2.
*/
- ENABLE_JAVASCRIPT,
+ SCROLL_POSITION,
/**
- * @brief Whether images can be loaded automatically.
- * @details Name "loadImagesAutomatically", type Property::BOOLEAN.
- * @note Default is true.
+ * @brief The current position of scroll.
+ * @details Name "scrollSize", type Property::VECTOR2. Read-only.
*/
- LOAD_IMAGES_AUTOMATICALLY,
+ SCROLL_SIZE,
/**
- * @brief The default text encoding name.
- * @details Name "defaultTextEncodingName", type Property::STRING.
- * @note If the value is not set, the web engine detects web page's text encoding.
+ * @brief The current position of scroll.
+ * @details Name "contentSize", type Property::VECTOR2. Read-only.
*/
- DEFAULT_TEXT_ENCODING_NAME,
+ CONTENT_SIZE,
/**
- * @brief The default font size in pixel.
- * @details Name "defaultFontSize", type Property::INT.
- * @note Default is 16.
+ * @brief The title of web page.
+ * @details Name "title", type Property::STRING.
+ * @note The value is read-only.
*/
- DEFAULT_FONT_SIZE
+ TITLE,
};
};
/**
* @brief WebView signal type related with page loading.
*/
- typedef Signal<void(WebView, const std::string&)> WebViewPageLoadSignalType;
+ using WebViewPageLoadSignalType = Signal< void( WebView, const std::string& ) >;
/**
* @brief WebView signal type related with page loading error.
*/
- typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
+ using WebViewPageLoadErrorSignalType = Signal< void( WebView, const std::string&, LoadErrorCode ) >;
+
+ /**
+ * @brief WebView signal type related with scroll edge reached.
+ */
+ using WebViewScrollEdgeReachedSignalType = Signal< void( WebView, Dali::WebEnginePlugin::ScrollEdge ) >;
public:
/**
static WebView New(const std::string& locale, const std::string& timezoneId);
/**
+ * @brief Creates an initialized WebView.
+ *
+ * @param [in] argc The count of arguments of Applications
+ * @param [in] argv The string array of arguments of Applications
+ */
+ static WebView New( int argc, char** argv );
+
+ /**
* @brief Creates an uninitialized WebView.
*/
WebView();
static WebView DownCast(BaseHandle handle);
/**
+ * @brief Get WebSettings of WebEngine.
+ */
+ Dali::Toolkit::WebSettings* GetSettings() const;
+
+ /**
+ * @brief Get WebContext of WebEngine.
+ */
+ Dali::Toolkit::WebContext* GetContext() const;
+
+ /**
+ * @brief Get CookieManager of WebEngine.
+ */
+ Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+ /**
+ * @brief Get WebBackForwardList of WebEngine.
+ */
+ Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+ /**
+ * @brief Get Favicon of web page.
+ *
+ * @return Handle to a fav icon
+ */
+ Dali::Toolkit::ImageView& GetFavicon();
+
+ /**
* @brief Loads a web page based on a given URL.
*
* @param [in] url The URL of the resource to load
*
* @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.
+ * @param[in] deltaX The delta x of scroll
+ * @param[in] deltaY The delta y of scroll
+ */
+ void ScrollBy( int deltaX, int deltaY );
+
+ /**
* @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 Clears all tiles resources of Web.
*/
- void ClearHistory();
+ void ClearAllTilesResources();
/**
- * @brief Clears the cache of Web.
- */
- void ClearCache();
-
- /**
- * @brief Clears all the cookies of Web.
+ * @brief Clears the history of Web.
*/
- void ClearCookies();
+ void ClearHistory();
/**
* @brief Connects to this signal to be notified when page loading is started.
*/
WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+ /**
+ * @brief Connects to this signal to be notified when scroll edge is reached.
+ *
+ * @return A signal object to connect with.
+ */
+ WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
public: // Not intended for application developers
/// @cond internal
/**
${devel_api_src_dir}/controls/text-controls/text-selection-toolbar.cpp
${devel_api_src_dir}/controls/tool-bar/tool-bar.cpp
${devel_api_src_dir}/controls/video-view/video-view-devel.cpp
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list.cpp
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.cpp
+ ${devel_api_src_dir}/controls/web-view/web-context.cpp
+ ${devel_api_src_dir}/controls/web-view/web-cookie-manager.cpp
+ ${devel_api_src_dir}/controls/web-view/web-settings.cpp
${devel_api_src_dir}/controls/web-view/web-view.cpp
${devel_api_src_dir}/focus-manager/keyinput-focus-manager.cpp
${devel_api_src_dir}/focus-manager/keyboard-focus-manager-devel.cpp
${devel_api_src_dir}/image-loader/image-atlas.cpp
${devel_api_src_dir}/image-loader/texture-manager.cpp
${devel_api_src_dir}/layouting/flex-node.cpp
+ ${devel_api_src_dir}/shader-effects/alpha-discard-effect.cpp
+ ${devel_api_src_dir}/shader-effects/dissolve-effect.cpp
+ ${devel_api_src_dir}/shader-effects/distance-field-effect.cpp
+ ${devel_api_src_dir}/shader-effects/image-region-effect.cpp
+ ${devel_api_src_dir}/shader-effects/motion-blur-effect.cpp
+ ${devel_api_src_dir}/shader-effects/motion-stretch-effect.cpp
${devel_api_src_dir}/styling/style-manager-devel.cpp
${devel_api_src_dir}/text/bitmap-font.cpp
${devel_api_src_dir}/text/text-utils-devel.cpp
)
SET( devel_api_web_view_header_files
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list.h
+ ${devel_api_src_dir}/controls/web-view/web-back-forward-list-item.h
+ ${devel_api_src_dir}/controls/web-view/web-context.h
+ ${devel_api_src_dir}/controls/web-view/web-cookie-manager.h
+ ${devel_api_src_dir}/controls/web-view/web-settings.h
${devel_api_src_dir}/controls/web-view/web-view.h
)
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+Property::Map CreateAlphaDiscardEffect()
+{
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_ALPHA_DISCARD_EFFECT_FRAG.data();
+
+ map[Toolkit::Visual::Property::SHADER] = customShader;
+ return map;
+}
+
+} // namespace Toolkit
+} // namespace Dali
#define DALI_TOOLKIT_ALPHA_DISCARD_EFFECT_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/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
namespace Dali
{
*
* @return A property map of the required shaders.
*/
-inline Property::Map CreateAlphaDiscardEffect()
-{
- const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE =
- "varying mediump vec2 vTexCoord; \n"
- " \n"
- "uniform sampler2D sTexture; \n"
- "uniform lowp vec4 uColor; \n"
- "void main() \n"
- "{ \n"
- " mediump vec4 color = texture2D( sTexture, vTexCoord ); \n"
- " if(color.a <= 0.0001) \n"
- " { \n"
- " discard; \n"
- " } \n"
- " gl_FragColor = color * uColor; \n"
- "} \n";
-
- Property::Map map;
-
- Property::Map customShader;
- customShader[Visual::Shader::Property::FRAGMENT_SHADER] = ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE;
-
- map[Toolkit::Visual::Property::SHADER] = customShader;
- return map;
-}
+DALI_TOOLKIT_API Property::Map CreateAlphaDiscardEffect();
} // namespace Toolkit
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/dissolve-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+void DissolveEffectSetCentralLine( Actor& actor, const Vector2& position, const Vector2& displacement, float initialProgress )
+{
+ // the line passes through 'position' and has the direction of 'displacement'
+ float coefA, coefB, coefC; //line equation: Ax+By+C=0;
+ coefA = displacement.y;
+ coefB = -displacement.x;
+ coefC = -displacement.y * position.x + displacement.x * position.y;
+
+ float inversedAABB = 1.f / (coefA * coefA + coefB * coefB);
+ float inversedSqrtAABB = sqrtf(inversedAABB);
+ float saddleA;
+
+ //saddle surface(Hyperbolic paraboloid)function, used to calculate the dissolve starting time
+ //z = y*y/a/a - x*x/b/b
+ //with our selection of parameters(a and b), this value for any texture coordinate is between -1.0 and 1.0
+
+ Vector3 saddleParam; // [0]: a*a, [1]: b*b, [2] b
+ Vector2 translation;
+ Vector2 rotation;
+ float toNext = -1.f;
+ if(displacement.x > 0.f || (EqualsZero(displacement.x) && displacement.y > 0.f))
+ {
+ toNext = 1.f;
+ }
+
+ if((displacement.y * displacement.x < 0.0f))
+ {
+ //distance from (0,0) to the line
+ float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
+ //distance from (1, 1 ) to the line
+ float distanceBottomRight = fabsf(coefA + coefB + coefC) * inversedSqrtAABB;
+ saddleA = std::max(distanceTopLeft, distanceBottomRight);
+
+ //foot of a perpendicular: (1,0) to the line
+ float footX1 = (coefB * coefB - coefA * coefC) * inversedAABB;
+ float footY1 = (-coefA * coefB - coefB * coefC) * inversedAABB;
+ //foot of a perpendicular: (0,1) to the line
+ float footX2 = (-coefA * coefB - coefA * coefC) * inversedAABB;
+ float footY2 = (coefA * coefA - coefB * coefC) * inversedAABB;
+ saddleParam[1] = (footX1 - footX2) * (footX1 - footX2) + (footY1 - footY2) * (footY1 - footY2);
+ translation = Vector2(-footX2, -footY2);
+ }
+ else
+ {
+ //distance from(1,0) to the line
+ float distanceTopRight = fabsf(coefA + coefC) * inversedSqrtAABB;
+ //distance from(0,1) to the line
+ float distanceBottomLeft = fabsf(coefB + coefC) * inversedSqrtAABB;
+ saddleA = std::max(distanceTopRight, distanceBottomLeft);
+ //foot of a perpendicular: (0,0) to the line
+ float footX3 = (-coefA * coefC) * inversedAABB;
+ float footY3 = (-coefB * coefC) * inversedAABB;
+ //foot of a perpendicular: (1.0,1.0) to the line
+ float footX4 = (coefB * coefB - coefA * coefB - coefA * coefC) * inversedAABB;
+ float footY4 = (-coefA * coefB + coefA * coefA - coefB * coefC) * inversedAABB;
+ saddleParam[1] = (footX3 - footX4) * (footX3 - footX4) + (footY3 - footY4) * (footY3 - footY4);
+ translation = Vector2(-footX3, -footY3);
+ }
+
+ saddleParam[2] = sqrtf(saddleParam[1]);
+ saddleParam[0] = saddleA * saddleA;
+ rotation = Vector2(-displacement.x, displacement.y);
+ rotation.Normalize();
+
+ actor.RegisterProperty("uSaddleParam", saddleParam);
+ actor.RegisterProperty("uTranslation", translation);
+ actor.RegisterProperty("uRotation", rotation);
+ actor.RegisterProperty("uToNext", toNext);
+ actor.RegisterProperty("uPercentage", initialProgress, Dali::Property::ANIMATABLE);
+}
+
+Property::Map CreateDissolveEffect( bool useHighPrecision )
+{
+ const char* prefixHighPrecision("precision highp float;\n");
+ const char* prefixMediumPrecision("precision mediump float;\n");
+
+ const char* vertexShader = SHADER_DISSOLVE_EFFECT_VERT.data();
+ const char* fragmentShader = SHADER_DISSOLVE_EFFECT_FRAG.data();
+
+ Property::Map map;
+
+ Property::Map customShader;
+
+ std::string vertexShaderString;
+ std::string fragmentShaderString;
+ if(useHighPrecision)
+ {
+ vertexShaderString.reserve(strlen(prefixHighPrecision) + strlen(vertexShader));
+ vertexShaderString.append(prefixHighPrecision);
+
+ fragmentShaderString.reserve(strlen(prefixHighPrecision) + strlen(fragmentShader));
+ fragmentShaderString.append(prefixHighPrecision);
+ }
+ else
+ {
+ vertexShaderString.reserve(strlen(prefixMediumPrecision) + strlen(vertexShader));
+ vertexShaderString.append(prefixMediumPrecision);
+
+ fragmentShaderString.reserve(strlen(prefixMediumPrecision) + strlen(fragmentShader));
+ fragmentShaderString.append(prefixMediumPrecision);
+ }
+
+ vertexShaderString.append(vertexShader);
+ fragmentShaderString.append(fragmentShader);
+
+ customShader[Visual::Shader::Property::VERTEX_SHADER] = vertexShaderString;
+ customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
+
+ customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 20;
+ customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 20;
+
+ customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+ map[Toolkit::Visual::Property::SHADER] = customShader;
+ return map;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
#define DALI_TOOLKIT_SHADER_EFFECT_DISSOLVE_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/rendering/shader.h>
#include <string.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/object/property-map.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
* @param[in] displacement The direction of the central line
* @param[in] initialProgress The normalised initial progress of the shader
*/
-inline void DissolveEffectSetCentralLine(Actor& actor, const Vector2& position, const Vector2& displacement, float initialProgress)
-{
- // the line passes through 'position' and has the direction of 'displacement'
- float coefA, coefB, coefC; //line equation: Ax+By+C=0;
- coefA = displacement.y;
- coefB = -displacement.x;
- coefC = -displacement.y * position.x + displacement.x * position.y;
-
- float inversedAABB = 1.f / (coefA * coefA + coefB * coefB);
- float inversedSqrtAABB = sqrtf(inversedAABB);
- float saddleA;
-
- //saddle surface(Hyperbolic paraboloid)function, used to calculate the dissolve starting time
- //z = y*y/a/a - x*x/b/b
- //with our selection of parameters(a and b), this value for any texture coordinate is between -1.0 and 1.0
-
- Vector3 saddleParam; // [0]: a*a, [1]: b*b, [2] b
- Vector2 translation;
- Vector2 rotation;
- float toNext = -1.f;
- if(displacement.x > 0.f || (EqualsZero(displacement.x) && displacement.y > 0.f))
- {
- toNext = 1.f;
- }
-
- if((displacement.y * displacement.x < 0.0f))
- {
- //distance from (0,0) to the line
- float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
- //distance from (1, 1 ) to the line
- float distanceBottomRight = fabsf(coefA + coefB + coefC) * inversedSqrtAABB;
- saddleA = std::max(distanceTopLeft, distanceBottomRight);
+DALI_TOOLKIT_API void DissolveEffectSetCentralLine( Actor& actor, const Vector2& position, const Vector2& displacement, float initialProgress );
- //foot of a perpendicular: (1,0) to the line
- float footX1 = (coefB * coefB - coefA * coefC) * inversedAABB;
- float footY1 = (-coefA * coefB - coefB * coefC) * inversedAABB;
- //foot of a perpendicular: (0,1) to the line
- float footX2 = (-coefA * coefB - coefA * coefC) * inversedAABB;
- float footY2 = (coefA * coefA - coefB * coefC) * inversedAABB;
- saddleParam[1] = (footX1 - footX2) * (footX1 - footX2) + (footY1 - footY2) * (footY1 - footY2);
- translation = Vector2(-footX2, -footY2);
- }
- else
- {
- //distance from(1,0) to the line
- float distanceTopRight = fabsf(coefA + coefC) * inversedSqrtAABB;
- //distance from(0,1) to the line
- float distanceBottomLeft = fabsf(coefB + coefC) * inversedSqrtAABB;
- saddleA = std::max(distanceTopRight, distanceBottomLeft);
- //foot of a perpendicular: (0,0) to the line
- float footX3 = (-coefA * coefC) * inversedAABB;
- float footY3 = (-coefB * coefC) * inversedAABB;
- //foot of a perpendicular: (1.0,1.0) to the line
- float footX4 = (coefB * coefB - coefA * coefB - coefA * coefC) * inversedAABB;
- float footY4 = (-coefA * coefB + coefA * coefA - coefB * coefC) * inversedAABB;
- saddleParam[1] = (footX3 - footX4) * (footX3 - footX4) + (footY3 - footY4) * (footY3 - footY4);
- translation = Vector2(-footX3, -footY3);
- }
-
- saddleParam[2] = sqrtf(saddleParam[1]);
- saddleParam[0] = saddleA * saddleA;
- rotation = Vector2(-displacement.x, displacement.y);
- rotation.Normalize();
-
- actor.RegisterProperty("uSaddleParam", saddleParam);
- actor.RegisterProperty("uTranslation", translation);
- actor.RegisterProperty("uRotation", rotation);
- actor.RegisterProperty("uToNext", toNext);
- actor.RegisterProperty("uPercentage", initialProgress, Dali::Property::ANIMATABLE);
-}
/**
* @brief Create a new Dissolve effect
*
* @return The newly created Property::Map with the dissolve effect
*/
-inline Property::Map CreateDissolveEffect(bool useHighPrecision = true)
-{
- const char* prefixHighPrecision("precision highp float;\n");
- const char* prefixMediumPrecision("precision mediump float;\n");
-
- const char* vertexShader(
- "attribute mediump vec2 aPosition;\n"
- "\n"
- "uniform mediump mat4 uMvpMatrix;\n"
- "uniform vec3 uSize;\n"
- "uniform vec4 uTextureRect;"
- "\n"
- "uniform float uPercentage;\n"
- "uniform vec3 uSaddleParam;\n"
- "uniform vec2 uTranslation;\n"
- "uniform vec2 uRotation; \n"
- "uniform float uToNext;\n"
- "\n"
- "varying float vPercentage;\n"
- "varying vec2 vTexCoord;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
- " vertexPosition.xyz *= uSize;\n"
- " vertexPosition = uMvpMatrix * vertexPosition;\n"
- " gl_Position = vertexPosition;\n"
- "\n"
- " vec2 texCoord = aPosition + vec2(0.5);\n"
- " vTexCoord = texCoord;\n"
- "\n"
- " //Calculate the distortion value given the dissolve central line\n"
- " vec2 value = texCoord + uTranslation;\n"
- " mat2 rotateMatrix = mat2(uRotation.s, uRotation.t, -uRotation.t, uRotation.s);\n"
- " value = rotateMatrix * value;\n"
- " if(uToNext == 1.0)\n"
- " value.s = uSaddleParam[2] + value.s;\n"
- " float delay = value.t * value.t / uSaddleParam[0] - value.s * value.s / uSaddleParam[1];\n"
- " vPercentage = clamp(uPercentage * 2.0 - 0.5 * sin(delay * 1.571) - 0.5, 0.0, 1.0);\n"
- "}\n");
-
- const char* fragmentShader(
- "varying float vPercentage;\n"
- "varying mediump vec2 vTexCoord;\n"
- "\n"
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform vec4 uTextureRect;\n"
- "float rand(vec2 co)\n"
- "{\n"
- " return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n"
- "}\n"
- "void main()\n"
- "{\n"
- " //Calculate the randomness\n"
- " float offsetS = rand(vTexCoord * vPercentage) - vTexCoord.s;\n"
- " float offsetT = rand(vec2(vTexCoord.t * vPercentage, vTexCoord.s * vPercentage)) - vTexCoord.t;\n"
- " vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage;\n"
- " gl_FragColor = texture2D(sTexture, lookupCoord) * uColor;\n"
- " gl_FragColor.a *= 1.0 - vPercentage;\n"
- "}\n");
-
- Property::Map map;
-
- Property::Map customShader;
-
- std::string vertexShaderString;
- std::string fragmentShaderString;
- if(useHighPrecision)
- {
- vertexShaderString.reserve(strlen(prefixHighPrecision) + strlen(vertexShader));
- vertexShaderString.append(prefixHighPrecision);
-
- fragmentShaderString.reserve(strlen(prefixHighPrecision) + strlen(fragmentShader));
- fragmentShaderString.append(prefixHighPrecision);
- }
- else
- {
- vertexShaderString.reserve(strlen(prefixMediumPrecision) + strlen(vertexShader));
- vertexShaderString.append(prefixMediumPrecision);
-
- fragmentShaderString.reserve(strlen(prefixMediumPrecision) + strlen(fragmentShader));
- fragmentShaderString.append(prefixMediumPrecision);
- }
-
- vertexShaderString.append(vertexShader);
- fragmentShaderString.append(fragmentShader);
-
- customShader[Visual::Shader::Property::VERTEX_SHADER] = vertexShaderString;
- customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
-
- customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 20;
- customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 20;
-
- customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
- map[Toolkit::Visual::Property::SHADER] = customShader;
- return map;
-}
+DALI_TOOLKIT_API Property::Map CreateDissolveEffect( bool useHighPrecision = true);
} // namespace Toolkit
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
+
+// EXTERNAL INCLUDES
+#include <string.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+Dali::Property::Map CreateDistanceFieldEffect()
+{
+ const char* fragmentShaderPrefix("#extension GL_OES_standard_derivatives : enable\n");
+
+ const char* fragmentShader = SHADER_DISTANCE_FIELD_EFFECT_FRAG.data();
+
+ Property::Map map;
+
+ Property::Map customShader;
+
+ std::string fragmentShaderString;
+ fragmentShaderString.reserve(strlen(fragmentShaderPrefix) + strlen(fragmentShader));
+ fragmentShaderString.append(fragmentShaderPrefix);
+ fragmentShaderString.append(fragmentShader);
+
+ customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
+ customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+ map[Toolkit::Visual::Property::SHADER] = customShader;
+ return map;
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
#define DALI_TOOLKIT_SHADER_EFFECT_DISTANCEFIELD_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-toolkit/public-api/dali-toolkit-common.h>
+
// EXTERNAL INCLUDES
#include <dali/public-api/object/property-map.h>
-#include <string.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
*
* @return The newly created Property::Map with the distance field effect
*/
-inline Dali::Property::Map CreateDistanceFieldEffect()
-{
- const char* fragmentShaderPrefix("#extension GL_OES_standard_derivatives : enable\n");
-
- const char* fragmentShader(
- "varying mediump vec2 vTexCoord;\n"
- "\n"
- "uniform mediump float uGlowBoundary;\n"
- "uniform mediump vec2 uOutlineParams;\n"
- "uniform lowp vec4 uOutlineColor;\n"
- "uniform lowp vec4 uShadowColor;\n"
- "uniform mediump vec2 uShadowOffset;\n"
- "uniform lowp vec4 uGlowColor;\n"
- "uniform lowp float uDoOutline;\n"
- "uniform lowp float uDoShadow;\n"
- "uniform lowp float uDoGlow;\n"
- "\n"
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "\n"
- "void main()\n"
- "{\n"
- " // sample distance field\n"
- " mediump float smoothing = 0.5;\n"
- " \n"
- " mediump float distance = texture2D(sTexture, vTexCoord).a;\n"
- " mediump float smoothWidth = fwidth(distance);\n"
- " mediump float alphaFactor = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);\n"
- " lowp vec4 color;\n"
- " if (uDoShadow == 0.0)\n"
- " {\n"
- " mediump float alpha = uColor.a * alphaFactor;\n"
- " lowp vec4 rgb = uColor;\n"
- "\n"
- " if (uDoOutline > 0.0)\n"
- " {\n"
- " mediump float outlineWidth = uOutlineParams[1] + smoothWidth;\n"
- " mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);\n"
- " alpha = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);\n"
- " rgb = mix(uOutlineColor, uColor, outlineBlend);\n"
- " }\n"
- "\n"
- " if (uDoGlow > 0.0)\n"
- " {\n"
- " rgb = mix(uGlowColor, rgb, alphaFactor);\n"
- " alpha = smoothstep(uGlowBoundary, smoothing, distance);\n"
- " }\n"
- "\n"
- " // set fragment color\n"
- " color = vec4(rgb.rgb, alpha);\n"
- " }\n"
- "\n"
- " else // (uDoShadow > 0.0)\n"
- " {\n"
- " mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
- " mediump float inText = alphaFactor;\n"
- " mediump float inShadow = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, shadowDistance);\n"
- "\n"
- " // inside object, outside shadow\n"
- " if (inText == 1.0)\n"
- " {\n"
- " color = uColor;\n"
- " }\n"
- " // inside object, outside shadow\n"
- " else if ((inText != 0.0) && (inShadow == 0.0))\n"
- " {\n"
- " color = uColor;\n"
- " color.a *= inText;\n"
- " }\n"
- " // outside object, completely inside shadow\n"
- " else if ((inText == 0.0) && (inShadow == 1.0))\n"
- " {\n"
- " color = uShadowColor;\n"
- " }\n"
- " // inside object, completely inside shadow\n"
- " else if ((inText != 0.0) && (inShadow == 1.0))\n"
- " {\n"
- " color = mix(uShadowColor, uColor, inText);\n"
- " color.a = uShadowColor.a;\n"
- " }\n"
- " // inside object, inside shadow's border\n"
- " else if ((inText != 0.0) && (inShadow != 0.0))\n"
- " {\n"
- " color = mix(uShadowColor, uColor, inText);\n"
- " color.a *= max(inText, inShadow);\n"
- " }\n"
- " // inside shadow's border\n"
- " else if (inShadow != 0.0)\n"
- " {\n"
- " color = uShadowColor;\n"
- " color.a *= inShadow;\n"
- " }\n"
- " // outside shadow and object\n"
- " else \n"
- " {\n"
- " color.a = 0.0;\n"
- " }\n"
- "\n"
- " }\n"
- "\n"
- " gl_FragColor = color;\n"
- "\n"
- "}\n");
-
- Property::Map map;
-
- Property::Map customShader;
-
- std::string fragmentShaderString;
- fragmentShaderString.reserve(strlen(fragmentShaderPrefix) + strlen(fragmentShader));
- fragmentShaderString.append(fragmentShaderPrefix);
- fragmentShaderString.append(fragmentShader);
-
- customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShaderString;
- customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
- map[Toolkit::Visual::Property::SHADER] = customShader;
- return map;
-}
+DALI_TOOLKIT_API Dali::Property::Map CreateDistanceFieldEffect();
} // namespace Toolkit
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+Property::Map CreateImageRegionEffect()
+{
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[Visual::Shader::Property::VERTEX_SHADER] = SHADER_IMAGE_REGION_EFFECT_VERT.data();
+
+ map[Toolkit::Visual::Property::SHADER] = customShader;
+ return map;
+}
+
+} // Toolkit
+
+} // Dali
#define DALI_TOOLKIT_IMAGE_REGION_EFFECT_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/property-map.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
namespace Dali
{
*
* @return A property map of the required shader
*/
-inline Property::Map CreateImageRegionEffect()
-{
- std::string vertexShader(
- "attribute mediump vec2 aPosition;\n"
- "\n"
- "uniform mediump mat4 uMvpMatrix;\n"
- "uniform vec3 uSize;\n"
- "uniform vec4 uTextureRect;"
- "\n"
- "varying vec2 vTexCoord;\n"
-
- "uniform mediump vec2 uTopLeft;\n"
- "uniform mediump vec2 uBottomRight;\n"
- "void main()\n"
- "{\n"
- " mediump vec4 position = vec4(aPosition, 0.0, 1.0);\n"
- " position.xyz *= uSize;\n"
- " gl_Position = uMvpMatrix * position;\n"
- // The line below is doing the same as the following commented lines:
- //" vec2 imageSize = uTextureRect.zw - uTextureRect.xy;\n"
- //" vec2 topLeft = uTextureRect.xy + uTopLeft * imageSize;\n"
- //" vec2 bottomRight = uTextureRect.xy + uBottomRight * imageSize;\n"
- //" vec2 texCoord = (aTexCoord - uTextureRect.xy) / imageSize;\n"
- //" vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );\n"
-
- " vec2 texCoord = aPosition + vec2(0.5);\n"
- " vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );\n"
- "}\n");
-
- Property::Map map;
-
- Property::Map customShader;
- customShader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
-
- map[Toolkit::Visual::Property::SHADER] = customShader;
- return map;
-}
+DALI_TOOLKIT_API Property::Map CreateImageRegionEffect();
} // namespace Toolkit
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/motion-blur-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+void SetMotionBlurProperties( Actor& actor, unsigned int numBlurSamples )
+{
+ actor.RegisterProperty("uBlurTexCoordScale", 0.125f);
+ actor.RegisterProperty("uGeometryStretchFactor", 0.05f);
+ actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
+ actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
+ actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
+ actor.RegisterProperty("uAlphaScale", 0.75f);
+ actor.RegisterProperty("uNumSamples", static_cast<float>(numBlurSamples));
+ actor.RegisterProperty("uRecipNumSamples", 1.0f / static_cast<float>(numBlurSamples));
+ actor.RegisterProperty("uRecipNumSamplesMinusOne", 1.0f / static_cast<float>(numBlurSamples - 1.0f));
+ Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
+
+ Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
+ constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
+ constraint.Apply();
+}
+
+
+Property::Map CreateMotionBlurEffect()
+{
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[Visual::Shader::Property::VERTEX_SHADER] = SHADER_MOTION_BLUR_EFFECT_VERT.data();
+ customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_MOTION_BLUR_EFFECT_FRAG.data();
+
+ customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
+ customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
+
+ customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+ map[Toolkit::Visual::Property::SHADER] = customShader;
+ return map;
+}
+
+} // Toolkit
+} // Dali
#define DALI_TOOLKIT_SHADER_EFFECT_MOTION_BLUR_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/actors/actor.h>
-#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-map.h>
-#include <dali/public-api/rendering/shader.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
namespace Dali
{
* @param[in] actor The actor that registers the uniform properties
* @param[in] numBlurSamples Number of samples used by the shader
*/
-inline void SetMotionBlurProperties(Actor& actor, unsigned int numBlurSamples = 8)
-{
- actor.RegisterProperty("uBlurTexCoordScale", 0.125f);
- actor.RegisterProperty("uGeometryStretchFactor", 0.05f);
- actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
- actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
- actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
- actor.RegisterProperty("uAlphaScale", 0.75f);
- actor.RegisterProperty("uNumSamples", static_cast<float>(numBlurSamples));
- actor.RegisterProperty("uRecipNumSamples", 1.0f / static_cast<float>(numBlurSamples));
- actor.RegisterProperty("uRecipNumSamplesMinusOne", 1.0f / static_cast<float>(numBlurSamples - 1.0f));
- Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
-
- Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
- constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
- constraint.Apply();
-}
+DALI_TOOLKIT_API void SetMotionBlurProperties( Actor& actor, unsigned int numBlurSamples = 8 );
/**
* @brief Create a new MotionBlurEffect
*
* @return The newly created Property::Map with the motion blur effect
*/
-inline Property::Map CreateMotionBlurEffect()
-{
- std::string vertexSource;
- vertexSource =
- "precision mediump float;\n"
-
- "attribute vec2 aPosition;\n"
-
- "uniform mat4 uMvpMatrix;\n"
- "uniform mat4 uModelView;\n"
- "uniform mat4 uViewMatrix;\n"
- "uniform mat4 uProjection;\n"
- "uniform vec3 uSize;\n"
-
- "uniform mat4 uModelLastFrame;\n"
- "float timeDelta = 0.0167;\n"
-
- "uniform float uGeometryStretchFactor;\n"
- "uniform float uSpeedScalingFactor;\n"
-
- // outputs
- "varying vec2 vModelSpaceCenterToPos;\n"
- "varying vec2 vScreenSpaceVelocityVector;\n"
- "varying float vSpeed;\n"
- "varying vec2 vTexCoord;\n"
-
- "void main()\n"
- "{\n"
- // get view space position of vertex this frame and last frame
- " vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
- " vertexPosition.xyz *= uSize;\n"
-
- " vec4 viewSpaceVertex = uModelView * vertexPosition;\n"
- " vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertexPosition;\n"
- " float reciprocalTimeDelta = 1.0 / timeDelta;\n"
-
- // work out vertex's last movement in view space
- " vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
-
- // get clip space position of vertex this frame and last frame
- " vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;\n"
- " vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;\n"
-
- // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
- // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
- " float t = 0.0;\n"
- " float posDeltaLength = length(viewSpacePosDelta);\n"
- " if(posDeltaLength > 0.001)\n" // avoid div by 0 if object has barely moved
- " {\n"
- " vec4 viewSpaceCenterToPos = uModelView * vec4(vertexPosition.xy, 0.0, 0.0);\n"
- " float centerToVertexDist = length(viewSpaceCenterToPos);\n"
- " if(centerToVertexDist > 0.001)\n" // avoid div by 0 if object has vertex at model space origin
- " {\n"
- " vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;\n"
- " vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;\n"
- " t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5;\n" // scale and bias from [-1..1] to [0..1]
- " }\n"
- " }\n"
- // output vertex position lerped with its last position, based on how much it is trailing,
- // this stretches the geom back along where it has just been, giving a warping effect
- // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
- " gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * uGeometryStretchFactor * reciprocalTimeDelta);\n"
-
- // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
- " vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;\n"
- " vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;\n"
- // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
- " vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);\n"
- " vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y;\n" // TODO negated due to y being inverted in our coordinate system?
- // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
- " vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;\n"
- " vSpeed = clamp(vSpeed, 0.0, 1.0);\n"
-
- // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
- " vModelSpaceCenterToPos = viewSpaceVertex.xy;\n"
-
- " vec2 texCoord = aPosition + vec2(0.5);"
- " vTexCoord = texCoord;\n"
- "}\n";
-
- std::string fragmentSource;
- fragmentSource =
- "precision mediump float;\n"
-
- "uniform sampler2D sTexture;\n"
- "uniform vec4 uColor;\n"
-
- "uniform vec2 uObjectFadeStart;\n"
- "uniform vec2 uObjectFadeEnd;\n"
- "uniform float uAlphaScale;\n"
- "uniform float uBlurTexCoordScale;\n"
- "uniform float uNumSamples;\n"
- "uniform float uRecipNumSamples;\n"
- "uniform float uRecipNumSamplesMinusOne;\n"
- // inputs
- "varying vec2 vModelSpaceCenterToPos;\n"
- "varying vec2 vScreenSpaceVelocityVector;\n"
- "varying float vSpeed;\n"
- "varying vec2 vTexCoord;\n"
-
- "void main()\n"
- "{\n"
- // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
- // the blurred object and the unblurred background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
- " vec2 centerToPixel = abs(vModelSpaceCenterToPos);\n"
- " vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));\n"
- " float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale;\n" // apply global scaler
- " fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);\n" // fade proportional to speed, so opaque when at rest
-
- // scale velocity vector by user requirements
- " vec2 velocity = vScreenSpaceVelocityVector * uBlurTexCoordScale;\n"
-
- // standard actor texel
- " vec4 colActor = texture2D(sTexture, vTexCoord);\n"
-
- // blurred actor - gather texture samples from the actor texture in the direction of motion
- " vec4 col = colActor * uRecipNumSamples;\n"
- " for(float i = 1.0; i < uNumSamples; i += 1.0)\n"
- " {\n"
- " float t = i * uRecipNumSamplesMinusOne;\n"
- " col += texture2D(sTexture, vTexCoord + (velocity * t)) * uRecipNumSamples;\n"
- " }\n"
- " gl_FragColor = mix(colActor, col, vSpeed);\n" // lerp blurred and non-blurred actor based on speed of motion
- " gl_FragColor.a = fadeToEdgesScale;//colActor.a * fadeToEdgesScale;\n" // fade blurred actor to its edges based on speed of motion
- " gl_FragColor *= uColor;\n"
- "}\n";
-
- Property::Map map;
-
- Property::Map customShader;
- customShader[Visual::Shader::Property::VERTEX_SHADER] = vertexSource;
- customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentSource;
-
- customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
- customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
-
- customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
- map[Toolkit::Visual::Property::SHADER] = customShader;
- return map;
-}
+DALI_TOOLKIT_API Property::Map CreateMotionBlurEffect();
} // namespace Toolkit
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/shader-effects/motion-stretch-effect.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/rendering/shader.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+void SetMotionStretchProperties( Actor& actor )
+{
+ actor.RegisterProperty("uGeometryStretchFactor", 0.5f);
+ actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
+ actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
+ actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
+ actor.RegisterProperty("uAlphaScale", 0.75f);
+ Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
+
+ Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
+ constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
+ constraint.Apply();
+}
+
+Property::Map CreateMotionStretchEffect()
+{
+ Property::Map map;
+
+ Property::Map customShader;
+ customShader[Visual::Shader::Property::VERTEX_SHADER] = SHADER_MOTION_STRETCH_EFFECT_VERT.data();
+ customShader[Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_MOTION_STRETCH_EFFECT_FRAG.data();
+
+ customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
+ customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
+
+ customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
+
+ map[Toolkit::Visual::Property::SHADER] = customShader;
+ return map;
+}
+
+
+} // Toolkit
+} // Dali
#define DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_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/actors/actor.h>
-#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-map.h>
-#include <dali/public-api/rendering/shader.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
namespace Dali
{
/**
* @brief Set the properties for the motion stretch
*/
-inline void SetMotionStretchProperties(Actor& actor)
-{
- actor.RegisterProperty("uGeometryStretchFactor", 0.5f);
- actor.RegisterProperty("uSpeedScalingFactor", 0.5f);
- actor.RegisterProperty("uObjectFadeStart", Vector2(0.25f, 0.25f));
- actor.RegisterProperty("uObjectFadeEnd", Vector2(0.5f, 0.5f));
- actor.RegisterProperty("uAlphaScale", 0.75f);
- Property::Index uModelProperty = actor.RegisterProperty("uModelLastFrame", Matrix::IDENTITY);
-
- Constraint constraint = Constraint::New<Matrix>(actor, uModelProperty, EqualToConstraint());
- constraint.AddSource(Source(actor, Actor::Property::WORLD_MATRIX));
- constraint.Apply();
-}
+DALI_TOOLKIT_API void SetMotionStretchProperties( Actor& actor );
/**
* @brief Creates a new MotionStretchEffect
*
* @return The newly created Property::Map with the motion stretch effect
*/
-inline Property::Map CreateMotionStretchEffect()
-{
- std::string vertexSource;
- vertexSource =
- "precision mediump float;\n"
-
- "attribute vec2 aPosition;\n"
-
- "uniform mat4 uMvpMatrix;\n"
- "uniform mat4 uModelView;\n"
- "uniform mat4 uViewMatrix;\n"
- "uniform mat4 uProjection;\n"
- "uniform vec3 uSize;\n"
-
- "uniform mat4 uModelLastFrame;\n"
- "float timeDelta = 0.0167;\n"
-
- "uniform float uGeometryStretchFactor;\n"
- "uniform float uSpeedScalingFactor;\n"
-
- // outputs
- "varying vec2 vModelSpaceCenterToPos;\n"
- "varying vec2 vScreenSpaceVelocityVector;\n"
- "varying float vSpeed;\n"
- "varying vec2 vTexCoord;\n"
-
- "void main()\n"
- "{\n"
- // get view space position of vertex this frame and last frame
- " vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
- " vertexPosition.xyz *= uSize;\n"
-
- " vec4 viewSpaceVertex = uModelView * vertexPosition;\n"
- " vec4 viewSpaceVertexLastFrame = uViewMatrix * uModelLastFrame * vertexPosition;\n"
-
- // work out vertex's last movement in view space
- " vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;\n"
- " float reciprocalTimeDelta = 1.0 / timeDelta;\n"
-
- // get clip space position of vertex this frame and last frame
- " vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;\n"
- " vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;\n"
-
- // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
- // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
- " float t = 0.0;\n"
- " float posDeltaLength = length(viewSpacePosDelta);\n"
- " if(posDeltaLength > 0.001)\n" // avoid div by 0 if object has barely moved
- " {\n"
- " vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0, 0.0);\n"
- " float centerToVertexDist = length(viewSpaceCenterToPos);\n"
- " if(centerToVertexDist > 0.001)\n" // avoid div by 0 if object has vertex at model space origin
- " {\n"
- " vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;\n"
- " vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;\n"
- " t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5;\n" // scale and bias from [-1..1] to [0..1]
- " }\n"
- " }\n"
- // output vertex position lerped with its last position, based on how much it is trailing,
- // this stretches the geom back along where it has just been, giving a warping effect
- // We raise t to a power in order that non-trailing vertices are effected much more than trailing ones
- // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
- " gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * t * t * uGeometryStretchFactor * reciprocalTimeDelta);\n"
-
- // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
- " vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;\n"
- " vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;\n"
- // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
- " vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);\n"
- " vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y;\n" // TODO negated due to y being inverted in our coordinate system?
- // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
- " vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;\n"
- " vSpeed = clamp(vSpeed, 0.0, 1.0);\n"
-
- // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
- " vModelSpaceCenterToPos = viewSpaceVertex.xy;\n"
-
- " vec2 texCoord = aPosition + vec2(0.5);"
- " vTexCoord = texCoord;\n"
- "}\n";
-
- std::string fragmentSource;
- fragmentSource =
- "precision mediump float;\n"
-
- "uniform sampler2D sTexture;\n"
- "uniform vec4 uColor;\n"
-
- "uniform vec2 uObjectFadeStart;\n"
- "uniform vec2 uObjectFadeEnd;\n"
- "uniform float uAlphaScale;\n"
-
- // inputs
- "varying vec2 vModelSpaceCenterToPos;\n"
- "varying vec2 vScreenSpaceVelocityVector;\n"
- "varying float vSpeed;\n"
- "varying vec2 vTexCoord;\n"
-
- "void main()\n"
- "{\n"
- // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
- // the stretched object and the background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
- " vec2 centerToPixel = abs( vModelSpaceCenterToPos );\n"
- " vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));\n"
- " float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale;\n" // apply global scaler
- " fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);\n" // fade proportional to speed, so opaque when at rest
-
- // standard actor texel
- " vec4 colActor = texture2D(sTexture, vTexCoord);\n"
- " gl_FragColor = colActor;\n"
- " gl_FragColor.a *= fadeToEdgesScale;\n" // fade actor to its edges based on speed of motion
- " gl_FragColor *= uColor;\n"
- "}";
-
- Property::Map map;
-
- Property::Map customShader;
- customShader[Visual::Shader::Property::VERTEX_SHADER] = vertexSource;
- customShader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentSource;
-
- customShader[Visual::Shader::Property::SUBDIVIDE_GRID_X] = 10;
- customShader[Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 10;
-
- customShader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
-
- map[Toolkit::Visual::Property::SHADER] = customShader;
- return map;
-}
+DALI_TOOLKIT_API Property::Map CreateMotionStretchEffect();
} // namespace Toolkit
{
/**
* @brief The thickness of the arc.
- * @details Name "thickness", type Property::FLOAT.
+ * @details Name "thickness", type Property::FLOAT, animatable.
* @note Mandatory.
*/
THICKNESS = VISUAL_PROPERTY_START_INDEX,
/**
* @brief The start angle where the arc begins in degrees.
- * @details Name "startAngle", type Property::FLOAT.
+ * @details Name "startAngle", type Property::FLOAT, animatable.
* @note Optional. If not specified, the default is 0.
*/
START_ANGLE,
/**
* @brief The sweep angle of the arc in degrees.
- * @details Name "sweepAngle", type Property::FLOAT.
+ * @details Name "sweepAngle", type Property::FLOAT, animatable.
* The arc starts at a specified start angle and sweeps clockwise, drawing slices of pie.
* @note Optional. If not specified, the default is 360.
*/
PLAY_STATE = ORIENTATION_CORRECTION + 5,
/**
- * @brief The current frame number the AnimatedVectorImageVisual will use.
+ * @brief The current frame number the AnimatedImageVisual and AnimatedVectorImageVisual will use.
* @details Name "currentFrameNumber", Type Property::INTEGER, between [0, the maximum frame number] or between the play range if specified
* @note This property is read-only.
*/
CURRENT_FRAME_NUMBER = ORIENTATION_CORRECTION + 6,
/**
- * @brief The total frame number the AnimatedVectorImageVisual will use.
+ * @brief The total frame number the AnimatedImageVisual and AnimatedVectorImageVisual will use.
* @details Name "totalFrameNumber", Type Property::INTEGER.
* @note This property is read-only.
*/
/*
- * 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-info.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/rendering/shader.h>
#include <dali/public-api/signals/functor-delegate.h>
#include <dali/devel-api/common/stage.h>
#include <dali/devel-api/scripting/scripting.h>
{
mParser = Dali::Toolkit::JsonParser::New();
- Property::Map defaultDirs;
- defaultDirs[TOKEN_STRING(DALI_IMAGE_DIR)] = AssetManager::GetDaliImagePath();
- defaultDirs[TOKEN_STRING(DALI_SOUND_DIR)] = AssetManager::GetDaliSoundPath();
- defaultDirs[TOKEN_STRING(DALI_STYLE_DIR)] = AssetManager::GetDaliStylePath();
- defaultDirs[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath();
+ Property::Map defaultConstants;
+ defaultConstants[TOKEN_STRING(DALI_IMAGE_DIR)] = AssetManager::GetDaliImagePath();
+ defaultConstants[TOKEN_STRING(DALI_SOUND_DIR)] = AssetManager::GetDaliSoundPath();
+ defaultConstants[TOKEN_STRING(DALI_STYLE_DIR)] = AssetManager::GetDaliStylePath();
+ defaultConstants[TOKEN_STRING(DALI_STYLE_IMAGE_DIR)] = AssetManager::GetDaliStyleImagePath();
+ defaultConstants[TOKEN_STRING(DALI_SHADER_VERSION_PREFIX)] = Shader::GetShaderVersionPrefix();
+ defaultConstants[TOKEN_STRING(DALI_VERTEX_SHADER_PREFIX)] = Shader::GetVertexShaderPrefix();
+ defaultConstants[TOKEN_STRING(DALI_FRAGMENT_SHADER_PREFIX)] = Shader::GetFragmentShaderPrefix();
- AddConstants( defaultDirs );
+ AddConstants(defaultConstants);
}
void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
#include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h>
#include <dali-toolkit/internal/controls/control/control-renderers.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
-///////////////////////////////////////////////////////
-//
-// Bloom shaders
-//
-
-const char* const BLOOM_EXTRACT_FRAGMENT_SOURCE =
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform mediump float uBloomThreshold;\n"
- "uniform mediump float uRecipOneMinusBloomThreshold;\n"
- "void main()\n"
- "{\n"
- " mediump vec4 col;\n"
- " col = texture2D(sTexture, vTexCoord);\n"
- " col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold;\n" // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
- " gl_FragColor = clamp(col, 0.0, 1.0);\n"
- "}\n";
-
-const char* const COMPOSITE_FRAGMENT_SOURCE =
- "precision mediump float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform sampler2D sEffect;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform float uBloomIntensity;\n"
- "uniform float uImageIntensity;\n"
- "uniform float uBloomSaturation;\n"
- "uniform float uImageSaturation;\n"
-
- "vec4 ChangeSaturation(vec4 col, float sat)\n"
- "{\n"
- " float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));\n"
- " return mix(vec4(grey, grey, grey, 1.0), col, sat);\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " mediump vec4 image;\n"
- " mediump vec4 bloom;\n"
- " image = texture2D(sTexture, vTexCoord);\n"
- " bloom = texture2D(sEffect, vTexCoord);\n"
- " image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;\n"
- " bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;\n"
- " image *= 1.0 - clamp(bloom, 0.0, 1.0);\n" // darken base where bloom is strong, to prevent excessive burn-out of result
- " gl_FragColor = image + bloom;\n"
- "}\n";
-
} // namespace
//////////////////////////////////////////////////////
// Point actors and render tasks at new render targets
- Renderer bloomRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, BLOOM_EXTRACT_FRAGMENT_SOURCE );
+ Renderer bloomRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLOOM_VIEW_EXTRACT_SHADER_FRAG );
SetRendererTexture( bloomRenderer, mRenderTargetForRenderingChildren );
mBloomExtractActor.AddRenderer( bloomRenderer );
mBloomExtractActor.SetProperty( Actor::Property::SIZE, Vector2( mDownsampledWidth, mDownsampledHeight ) ); // size needs to match render target
mGaussianBlurView.SetUserImageAndOutputRenderTarget( mBloomExtractTarget.GetColorTexture(), blurExtractTarget );
// use the completed blur in the first buffer and composite with the original child actors render
- Renderer compositeRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, COMPOSITE_FRAGMENT_SOURCE );
+ Renderer compositeRenderer = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLOOM_VIEW_COMPOSITE_SHADER_FRAG );
SetRendererTexture( compositeRenderer, mRenderTargetForRenderingChildren );
TextureSet textureSet = compositeRenderer.GetTextures();
textureSet.SetTexture( 0u, mRenderTargetForRenderingChildren.GetColorTexture() );
// EXTERNAL INCLUDES
#include <sstream>
#include <dali/public-api/rendering/shader.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
*/
inline Shader CreateBubbleShader( unsigned int numBubble )
{
- const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump float aIndex;\n
- attribute mediump vec2 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- varying mediump vec2 vTexCoord;\n
- uniform mediump mat4 uMvpMatrix;\n
- // the gravity applied to the y direction
- uniform mediump float uGravity;\n
- // xy: the emit position of the bubble; zw: the destination of the bubble.
- // The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
- uniform vec4 uStartEndPosition[NUMBER_OF_BUBBLE];\n
- // The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
- uniform float uPercentage[NUMBER_OF_BUBBLE];\n
- uniform vec2 uInvertedMovementArea;\n
- // The bubble number is restricted by the available uniform num.
- // To increase the displayed bubble, every uStartEndPosition and uPercentage uniform is applied to a small bunch of bubbles (9 here)
- // The offset defines the random offset between bubbles within the bunch.
- uniform vec2 uOffset[9];\n
- // This uniform is used to change the bubble size during running time
- uniform float uDynamicScale;\n
- varying float vPercentage;\n
- varying vec2 vEffectTexCoord;\n
- void main()\n
- {\n
- vec4 position = vec4( aPosition, 0.0, 1.0 );\n
- // The Z coordinate is used to record the bubble index within current mesh actor
- int index = int(aIndex); \n
- //for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
- int groupIdx = index / NUMBER_OF_BUBBLE;\n
- // The bubbles within the same bunch applies the same uniforms uStartEndPosition[idx] & uPercentage[idx]
- int idx = index - groupIdx*NUMBER_OF_BUBBLE;\n
- float percentage = uPercentage[idx];
- // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
- if( percentage <= 0.0 || percentage >= 1.0 )\n
- {\n
- gl_Position = vec4(0.0);\n
- return;\n
- }\n
- vec4 startAndEnd = uStartEndPosition[idx];\n
- // The final position is added up different offset for bubbles
- startAndEnd.zw += uOffset[groupIdx];\n
- \n
- // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
- // the new xy value containes both the new scale and new bubble position
- position.xy *= uDynamicScale*min(percentage*5.0, 1.0);\n
- position.xy += mix(startAndEnd.xy, startAndEnd.zw, percentage);\n
- // The gravity is g*t*t on the y direction
- position.y += uGravity * pow(percentage, 2.0);\n
- gl_Position = uMvpMatrix * position;\n
- \n
- // Add multiple bubble shapes in the effect
- vTexCoord = aTexCoord;\n
- vPercentage = percentage;\n
- // Use the emit position color for the bubble
- vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea + vec2(0.5);\n
- }\n
- );
-
- const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform lowp vec4 uColor;\n
- uniform sampler2D sBackground;\n
- uniform sampler2D sBubbleShape;\n
- varying mediump float vPercentage;\n
- varying mediump vec2 vEffectTexCoord;\n
- \n
- void main()\n
- {\n
- // Get the emit pisition color, and Mix with the actor color
- mediump vec4 fragColor = texture2D(sBackground, vEffectTexCoord)*uColor;\n
- // Apply the shape defined by the texture contained sBubbleShape
- // And make the opacity being 0.7, and animate from 0.7 to 0 during the last 1/3 of movement
- fragColor.a *= texture2D(sBubbleShape, vTexCoord).a * ( 2.1 - max( vPercentage*2.1, 1.4 ) );\n
- gl_FragColor = fragColor;\n
- }\n
- );
-
std::ostringstream vertexShaderStringStream;
vertexShaderStringStream << "#define NUMBER_OF_BUBBLE "<< numBubble << "\n"
- << VERTEX_SHADER;
- Shader shader = Shader::New( vertexShaderStringStream.str(), FRAGMENT_SHADER );
+ << SHADER_BUBBLE_EFFECT_VERT;
+ Shader shader = Shader::New( vertexShaderStringStream.str(), SHADER_BUBBLE_EFFECT_FRAG );
return shader;
}
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/bubble-effect/bubble-effect.h>
#include <dali-toolkit/internal/controls/bubble-effect/bubble-renderer.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace
{
return f0 + (rand_r( &seed ) & 0xfff) * (f1-f0) * (1.0f/4095.0f);
}
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aTexCoord;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- varying mediump vec2 vTexCoord;\n
- \n
-
- void main()\n
- {\n
- gl_Position = uMvpMatrix * vec4(aPosition*uSize.xy,0.0,1.0);
- vTexCoord = aTexCoord;\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- precision highp float;\n
- uniform vec3 uHSVDelta;\n
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- float rand(vec2 co) \n
- {\n
- return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
- \n
- vec3 rgb2hsv(vec3 c)\n
- {\n
- vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
- vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n
- vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n
- \n
- float d = q.x - min(q.w, q.y);\n
- float e = 1.0e-10;\n
- return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n
- }\n
- vec3 hsv2rgb(vec3 c)\n
- {\n
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n
- return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n
- }\n
- void main() {\n
- vec4 color = texture2D(sTexture, vTexCoord); \n
- vec3 hsvColor = rgb2hsv( color.rgb );\n
- // modify the hsv Value
- hsvColor += uHSVDelta * rand(vTexCoord); \n
- // if the new vale exceeds one, then decrease it
- hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n
- // if the new vale drops below zero, then increase it
- hsvColor -= min(hsvColor*2.0, 0.0);\n
- color = vec4( hsv2rgb( hsvColor ), 1.0 ); \n
- gl_FragColor = color; \n
- }\n
- );
-
Dali::Geometry CreateTexturedQuad()
{
struct Vertex
//Create renderer
Dali::Geometry geometry = CreateTexturedQuad();
- Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ Shader shader = Shader::New( SHADER_BUBBLE_EMITTER_VERT, SHADER_BUBBLE_EMITTER_FRAG );
Renderer renderer = Renderer::New( geometry, shader );
TextureSet textureSet = TextureSet::New();
textureSet.SetTexture(0u, bgTexture );
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/visual-properties.h>
-
-#define DALI_COMPOSE_SHADER(STR) #STR
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
*/
inline Property::Map CreateColorAdjuster()
{
- std::string fragmentShader = DALI_COMPOSE_SHADER(
- precision highp float;\n
- uniform vec3 uHSVDelta;\n
- uniform float uIgnoreAlpha;\n
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- float rand(vec2 co) \n
- {\n
- return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
- \n
- vec3 rgb2hsv(vec3 c)\n
- {\n
- vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
- vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n
- vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n
- \n
- float d = q.x - min(q.w, q.y);\n
- float e = 1.0e-10;\n
- return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n
- }\n
- vec3 hsv2rgb(vec3 c)\n
- {\n
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n
- return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n
- }\n
- void main() {\n
- vec4 color = texture2D(sTexture, vTexCoord); \n
- vec3 hsvColor = rgb2hsv( color.rgb );\n
- // modify the hsv Value
- hsvColor += uHSVDelta * rand(vTexCoord); \n
- // if the new vale exceeds one, then decrease it
- hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n
- // if the new vale drops below zero, then increase it
- hsvColor -= min(hsvColor*2.0, 0.0);\n
- color.rgb = hsv2rgb( hsvColor ); \n
- // uIgnoreAlpha decide the result alpha will be 1.0 or source's alpha
- color.a += uIgnoreAlpha;\n
- gl_FragColor = color; \n
- }\n
- );
-
Property::Map customShader;
- customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_BUBBLE_EFFECT_COLOR_ADJUSTER_FRAG.data();
Property::Map map;
map[ Toolkit::Visual::Property::SHADER ] = customShader;
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
namespace
{
return Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( self );
}
-const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png";
-
static Dali::Actor CreateHighlightIndicatorActor()
{
+ std::string focusBorderImagePath(AssetManager::GetDaliImagePath());
+ focusBorderImagePath += "/keyboard_focus.9.png";
// Create the default if it hasn't been set and one that's shared by all the
- // keyboard focusable actors const char* const FOCUS_BORDER_IMAGE_PATH =
- // DALI_IMAGE_DIR "keyboard_focus.9.png";
- auto actor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH );
+ // keyboard focusable actors
+ auto actor = Toolkit::ImageView::New( focusBorderImagePath );
actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
DevelControl::AppendAccessibilityAttribute( actor, "highlight", "" );
actor.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_ANIMATED, true);
namespace Internal
{
-#define DALI_COMPOSE_SHADER(STR) #STR
-
-const char * const BASIC_VERTEX_SOURCE = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- attribute mediump vec2 aPosition;\n
- varying mediump vec2 vTexCoord;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- \n
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition * uSize.xy, 0.0, 1.0);\n
- vTexCoord = aPosition + vec2(0.5);
- gl_Position = uMvpMatrix * vertexPosition;\n
- }\n
-);
-
-const char * const BASIC_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform vec4 uColor;\n
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D(sTexture, vTexCoord);\n
- gl_FragColor *= uColor;
- }\n
-);
-
Geometry CreateGridGeometry( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
return geometry;
}
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc )
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc )
{
Dali::Shader shader = Dali::Shader::New( vertexSrc, fragmentSrc );
return renderer;
}
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc, Dali::Shader::Hint::Value hints, Uint16Pair gridSize )
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc, Dali::Shader::Hint::Value hints, Uint16Pair gridSize )
{
Dali::Shader shader = Dali::Shader::New( vertexSrc, fragmentSrc, hints );
*/
#include <dali/dali.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
namespace Internal
{
-extern const char* const BASIC_VERTEX_SOURCE;
-
-extern const char* const BASIC_FRAGMENT_SOURCE;
+#define BASIC_VERTEX_SOURCE SHADER_CONTROL_RENDERERS_VERT
+#define BASIC_FRAGMENT_SOURCE SHADER_CONTROL_RENDERERS_FRAG
/**
* Helper method for rendering an image with custom shader.
* @param[in] fragmentSrc The custom fragment shader.
* @return A newly created renderer.
*/
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc );
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc );
/**
* Helper method for rendering an image with custom shader.
* @param[in] gridSize The number of grid sub-divisions required.
* @return A newly created renderer.
*/
-Dali::Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc, Dali::Shader::Hint::Value hints, Dali::Uint16Pair gridSize );
+Dali::Renderer CreateRenderer( std::string_view vertexSrc, std::string_view fragmentSrc, Dali::Shader::Hint::Value hints, Dali::Uint16Pair gridSize );
/**
* Helper method for setting the first texture passed to a renderer.
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
#include <dali-toolkit/internal/filters/emboss-filter.h>
#include <dali-toolkit/internal/filters/spread-filter.h>
const Vector4 EFFECTS_VIEW_DEFAULT_BACKGROUND_COLOR( 0.0f, 0.0f, 0.0f, 0.0 );
const bool EFFECTS_VIEW_REFRESH_ON_DEMAND(false);
-#define DALI_COMPOSE_SHADER(STR) #STR
-
-const char* EFFECTS_VIEW_VERTEX_SOURCE = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- varying mediump vec2 vTexCoord;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- uniform mediump vec3 effectOffset;\n
- \n
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vertexPosition.xyz *= uSize;\n
- vertexPosition.xyz += effectOffset;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
- \n
- vTexCoord = aPosition + vec2(0.5);\n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* EFFECTS_VIEW_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 effectColor;\n
- \n
- void main()\n
- {\n
- gl_FragColor = effectColor;\n
- gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;\n
- }\n
-);
-
const float BLUR_KERNEL0[] = { 12.0f/16.0f,
2.0f/16.0f, 2.0f/16.0f };
Actor self( Self() );
// Create renderers
- mRendererPostFilter = CreateRenderer( EFFECTS_VIEW_VERTEX_SOURCE, EFFECTS_VIEW_FRAGMENT_SOURCE );
+ mRendererPostFilter = CreateRenderer( SHADER_EFFECTS_VIEW_VERT,
+ SHADER_EFFECTS_VIEW_FRAG );
mRendererPostFilter.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT );
self.AddRenderer( mRendererPostFilter );
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/controls/control/control-renderers.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
// TODO:
// pixel format / size - set from JSON
const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
-const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform mediump vec2 uSampleOffsets[NUM_SAMPLES];\n
- uniform mediump float uSampleWeights[NUM_SAMPLES];\n
-
- void main()\n
- {\n
- mediump vec4 col = texture2D(sTexture, vTexCoord + uSampleOffsets[0]) * uSampleWeights[0];\n
- for (int i=1; i<NUM_SAMPLES; ++i)\n
- {\n
- col += texture2D(sTexture, vTexCoord + uSampleOffsets[i]) * uSampleWeights[i];\n
- }\n
- gl_FragColor = col;\n
- }\n
-);
-
} // namespace
std::ostringstream fragmentStringStream;
fragmentStringStream << "#define NUM_SAMPLES " << mNumSamples << "\n";
- fragmentStringStream << GAUSSIAN_BLUR_FRAGMENT_SOURCE;
+ fragmentStringStream << SHADER_GAUSSIAN_BLUR_VIEW_FRAG;
std::string fragmentSource(fragmentStringStream.str());
//////////////////////////////////////////////////////
// Create an actor for performing a horizontal blur on the texture
mHorizBlurActor = Actor::New();
mHorizBlurActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER );
+
Renderer renderer = CreateRenderer( BASIC_VERTEX_SOURCE, fragmentSource.c_str() );
mHorizBlurActor.AddRenderer( renderer );
#include <dali/devel-api/adaptor-framework/image-loading.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/controls/model3d-view/obj-loader.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
DALI_TYPE_REGISTRATION_END()
-
-#define MAKE_SHADER(A)#A
-
-// Diffuse illumination shader
-
-const char* SIMPLE_VERTEX_SHADER = MAKE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- attribute highp vec3 aNormal;\n
- varying mediump vec3 vIllumination;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;\n
- uniform mediump mat3 uNormalMatrix;
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
-
- void main()\n
- {\n
- vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
- vertexPosition = uObjectMatrix * vertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- //Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
- vec3 normal = uNormalMatrix * aNormal;\n
- vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
- vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
-
- float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );\n
- vIllumination = vec3(lightDiffuse * 0.5 + 0.5);\n
-
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* SIMPLE_FRAGMENT_SHADER = MAKE_SHADER(
- precision mediump float;\n
- varying mediump vec3 vIllumination;\n
- uniform lowp vec4 uColor;\n
-
- void main()\n
- {\n
- gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a);\n
- }\n
-);
-
-// Diffuse and specular illumination shader with albedo texture
-
-const char* VERTEX_SHADER = MAKE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- attribute highp vec3 aNormal;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vIllumination;\n
- varying mediump float vSpecular;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;
- uniform mediump mat3 uNormalMatrix;
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
-
- void main()
- {\n
- vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
- vertexPosition = uObjectMatrix * vertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- //Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
- vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
- vec3 normal = normalize(uNormalMatrix * aNormal);\n
-
- vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
- vec3 viewDir = normalize(-vertPos.xyz);
-
- vec3 halfVector = normalize(viewDir + vecToLight);
-
- float lightDiffuse = dot( vecToLight, normal );\n
- lightDiffuse = max(0.0,lightDiffuse);\n
- vIllumination = vec3(lightDiffuse * 0.5 + 0.5);\n
-
- vec3 reflectDir = reflect(-vecToLight, normal);
- vSpecular = pow( max(dot(reflectDir, viewDir), 0.0), 4.0 );
-
- vTexCoord = aTexCoord;\n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vIllumination;\n
- varying mediump float vSpecular;\n
- uniform sampler2D sDiffuse;\n
- uniform lowp vec4 uColor;\n
-
- void main()\n
- {\n
- vec4 texture = texture2D( sDiffuse, vTexCoord );\n
- gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb + vSpecular * 0.3, texture.a * uColor.a);\n
- }\n
-);
-
-// Diffuse and specular illumination shader with albedo texture, normal map and gloss map shader
-
-const char* NRMMAP_VERTEX_SHADER = MAKE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- attribute highp vec3 aNormal;\n
- attribute highp vec3 aTangent;\n
- attribute highp vec3 aBiNormal;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vLightDirection;\n
- varying mediump vec3 vHalfVector;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;
- uniform mediump mat3 uNormalMatrix;
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 uLightPosition;\n
-
- void main()
- {\n
- vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);\n
- vertexPosition = uObjectMatrix * vertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
- vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
-
- vec3 tangent = normalize(uNormalMatrix * aTangent);
- vec3 binormal = normalize(uNormalMatrix * aBiNormal);
- vec3 normal = normalize(uNormalMatrix * aNormal);
-
- vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
- vLightDirection.x = dot(vecToLight, tangent);
- vLightDirection.y = dot(vecToLight, binormal);
- vLightDirection.z = dot(vecToLight, normal);
-
- vec3 viewDir = normalize(-vertPos.xyz);
- vec3 halfVector = normalize(viewDir + vecToLight);
- vHalfVector.x = dot(halfVector, tangent);
- vHalfVector.y = dot(halfVector, binormal);
- vHalfVector.z = dot(halfVector, normal);
-
- vTexCoord = aTexCoord;\n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* NRMMAP_FRAGMENT_SHADER = MAKE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vLightDirection;\n
- varying mediump vec3 vHalfVector;\n
- uniform sampler2D sDiffuse;\n
- uniform sampler2D sNormal;\n
- uniform sampler2D sGloss;\n
- uniform lowp vec4 uColor;\n
-
- void main()\n
- {\n
- vec4 texture = texture2D( sDiffuse, vTexCoord );\n
- vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n
- vec4 glossMap = texture2D( sGloss, vTexCoord );\n
-
- float lightDiffuse = max( 0.0, dot( normal, normalize(vLightDirection) ) );\n
- lightDiffuse = lightDiffuse * 0.5 + 0.5;\n
-
- float shininess = pow (max (dot (normalize( vHalfVector ), normal), 0.0), 16.0) ;
-
- gl_FragColor = vec4( texture.rgb * uColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a);\n
- }\n
-);
-
-
} // anonymous namespace
using namespace Dali;
{
//Create empty versions of the geometry and material so we always have a Renderer
Geometry mesh = Geometry::New();
- Shader shader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ Shader shader = Shader::New( SHADER_MODEL3D_VIEW_SIMPLE_SHADER_VERT, SHADER_MODEL3D_VIEW_SIMPLE_SHADER_FRAG );
mRenderer = Renderer::New( mesh, shader );
DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
{
if( (mTexture2Url != "") && (mTexture1Url != "") && (mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP) )
{
- mShader = Shader::New( NRMMAP_VERTEX_SHADER, NRMMAP_FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MODEL3D_VIEW_NRMMAP_SHADER_VERT, SHADER_MODEL3D_VIEW_NRMMAP_SHADER_FRAG );
}
else if( mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_TEXTURE ||
mIlluminationType == Toolkit::Model3dView::DIFFUSE_WITH_NORMAL_MAP )
{
- mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MODEL3D_VIEW_SHADER_VERT, SHADER_MODEL3D_VIEW_SHADER_FRAG );
}
else
{
- mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MODEL3D_VIEW_SIMPLE_SHADER_VERT, SHADER_MODEL3D_VIEW_SIMPLE_SHADER_FRAG );
}
}
else
{
- mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MODEL3D_VIEW_SIMPLE_SHADER_VERT, SHADER_MODEL3D_VIEW_SIMPLE_SHADER_FRAG );
}
mTextureSet = TextureSet::New();
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/visual-properties.h>
-
-#define DALI_COMPOSE_SHADER(STR) #STR
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
**/
inline Property::Map CreatePageTurnBookSpineEffect()
{
- const char* vertexSource = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- attribute mediump vec2 aPosition;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform vec3 uSize;\n
- uniform float uTextureWidth;\n
- varying vec2 vTexCoord;\n
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition*uSize.xy, 0.0, 1.0);\n
- gl_Position = uMvpMatrix * vertexPosition;\n
- vTexCoord = aPosition + vec2(0.5);\n
- vTexCoord.x /= uTextureWidth;
- }\n);
-
- // the simplified version of the fragment shader of page turn effect
- const char* fragmentSource = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- uniform vec3 uSize;\n
- uniform vec2 uSpineShadowParameter;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
-
- void main()\n
- {\n
- if( gl_FrontFacing )\n // display front side
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
- }\n
- else\n // display back side, flip the image horizontally by changing the x component of the texture coordinate
- {\n
- gl_FragColor = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) ) * uColor;\n
- }\n
- // display book spine, a stripe of shadowed texture
- float pixelPos = vTexCoord.x * uSize.x;\n
- if( pixelPos < uSpineShadowParameter.x )\n
- {\n
- float x = pixelPos - uSpineShadowParameter.x;\n
- float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );\n
- vec2 spineNormal = normalize(vec2(uSpineShadowParameter.y*x/uSpineShadowParameter.x, y));\n
- gl_FragColor.rgb *= spineNormal.y; \n
- }\n
- } );
-
Property::Map map;
Property::Map customShader;
- customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexSource;
- customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource;
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = SHADER_PAGE_TURN_BOOK_SPINE_EFFECT_VERT.data();
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_PAGE_TURN_BOOK_SPINE_EFFECT_FRAG.data();
map[ Toolkit::Visual::Property::SHADER ] = customShader;
return map;
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
using namespace Dali;
using namespace Dali::Toolkit;
namespace
{
-#define DALI_COMPOSE_SHADER(STR) #STR
const char * const PROPERTY_COMMON_PARAMETERS( "uCommonParameters" );
const char * const PROPERTY_ORIGINAL_CENTER( "originalCenter" );
const char * const PROPERTY_CURRENT_CENTER( "currentCenter" );
Property::Map Dali::Toolkit::Internal::CreatePageTurnEffect()
{
- const char* vertexShader = DALI_COMPOSE_SHADER(
- /*
- * The common parameters for all the vertices, calculate in CPU then pass into the shader as uniforms
- *
- * first part of the page, (outside the the line passing through original center and vertical to curve direction)
- * no Z change, only 2D rotation and translation
- * ([0][0],[0][1],[1][0],[1][1]) mat2 rotateMatrix
- * ([2][0],[2][1]) vec2 translationVector
- *
- * ([0][2],[0][3]) vec2 originalCenter: Typically the press down position of the Pan Gesture
- * ([1][2],[1][3]) vec2 currentCenter: Typically the current position of the Pan Gesture
- * ([3][0],[3][1]) vec2 curveDirection: The normalized vector pointing from original center to current center
- * ([2][2]) float vanishingPointY: The Y coordinate of the intersection of the spine
- * and the line which goes through the original center and is vertical to the curveDirection
- * ([2][3]) float curveEndY: The Y coordinate of intersection of the spine and the line through both original and current center
- * ([3][2]) float curveHeight: The height of the interpolated hermite curve.
- * ([3][3]) float currentLength: The length from the current center to the curveEnd.
- */
- precision mediump float;\n
- \n
- attribute mediump vec2 aPosition;\n
- \n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat3 uNormalMatrix;\n
- uniform mediump mat4 uModelView;\n
- \n
- uniform mat4 uCommonParameters;\n
- \n
- uniform vec3 uSize;\n
- uniform float uIsTurningBack;\n
- uniform float uTextureWidth;\n
- varying vec3 vNormal;\n
- varying vec4 vPosition;\n
- varying mediump vec2 vTexCoord;\n
- \n
- void main()\n
- {\n
- vec4 position = vec4( aPosition*uSize.xy, 0.0, 1.0);\n
- vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);\n
- vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);\n
- vec3 normal = vec3(0.0,0.0,1.0);\n
- \n
- if(currentCenter.x < originalCenter.x)\n
- {\n
- // change the coordinate origin from the center of the page to its top-left
- position.xy += uSize.xy * 0.5;\n
- vec2 curveDirection = vec2( uCommonParameters[3]);\n
- vec3 vanishingPoint = vec3(0.0, uCommonParameters[2][2], 0.0);\n
- // first part of the page, (outside the the line passing through original center and vertical to curve direction)
- //no Z change, only 2D rotation and translation
- if( dot(curveDirection, position.xy - originalCenter) < 0.0 )
- {\n
- position.y -= vanishingPoint.y;\n
- position.xy = mat2(uCommonParameters)*position.xy + vec2( uCommonParameters[2]);\n
- }\n
- // second part of the page, bent as a ruled surface
- else\n
- {\n
- // calculate on the flat plane, between
- // the first line passing through current vertex and vanishing point
- // the second line passing through original center and current center
- vec2 curveEnd = vec2( 0.0, uCommonParameters[2][3] );\n
- vec2 curFlatDirection = vec2(0.0,1.0);\n
- float lengthFromCurve = position.y - originalCenter.y;\n
- float lengthOnCurve = position.x;\n
- if(currentCenter.y != originalCenter.y)\n
- {\n
- curFlatDirection = normalize(position.xy - vanishingPoint.xy);\n
- lengthFromCurve = (curveEnd.x*curveDirection.y-curveEnd.y*curveDirection.x-position.x*curveDirection.y+position.y*curveDirection.x)
- / (curFlatDirection.x*curveDirection.y-curFlatDirection.y*curveDirection.x);\n
- lengthOnCurve = length(position.xy+lengthFromCurve*curFlatDirection-curveEnd);\n
- }\n
- \n
- // define the control points of hermite curve, composed with two segments
- // calculation is carried out on the 2D plane which is passing through both current and original center and vertical to the image plane
- float currentLength = uCommonParameters[3][3];\n
- float originalLength = abs(originalCenter.x/curveDirection.x);\n
- float height = uCommonParameters[3][2];\n
- float percentage = currentLength/originalLength;\n
- //vec2 SegmentOneControlPoint0 = vec2(0.0, 0.0);
- vec2 SegmentOneControlPoint1 = vec2((0.65*percentage - 0.15)*originalLength, (0.8 + 0.2 * percentage)*height); \n
- vec2 SegmentTwoControlPoint0 = SegmentOneControlPoint1;\n
- vec2 SegmentTwoControlPoint1 = vec2(currentLength, 0.0); \n
- vec2 SegmentOneTangentVector0 = SegmentOneControlPoint1;\n
- vec2 SegmentOneTangentVector1 = vec2(0.5*originalLength,0.0);\n
- vec2 SegmentTwoTangentVector0 = SegmentOneTangentVector1;\n
- vec2 SegmentTwoTangentVector1 = SegmentOneTangentVector1;\n
- \n
- // calculate the corresponding curve point position and its tangent vector
- // it is a linear mapping onto nonlinear curves, might cause some unwanted deformation
- // but as there are no analytical method to calculate the curve length on arbitrary segment
- // no efficient way to solve this nonlinear mapping, Numerical approximation would cost too much computation in shader
- vec2 curvePoint2D;\n
- vec2 tangent;\n
- float t0 = lengthOnCurve / originalLength;\n
- if(t0<=0.5)\n
- {\n
- float t = 2.0*t0;\n
- float t_2 = t*t;\n
- float t_3 = t*t_2;\n
- curvePoint2D = (-2.0*t_3+3.0*t_2)*SegmentOneControlPoint1
- + (t_3-2.0*t_2+t)*SegmentOneTangentVector0 + (t_3-t_2)*SegmentOneTangentVector1;\n
- tangent = (-6.0*t_2+6.0*t)*SegmentOneControlPoint1
- + (3.0*t_2-4.0*t+1.0)*SegmentOneTangentVector0 + (3.0*t_2-2.0*t)*SegmentOneTangentVector1;\n
- }\n
- else\n
- {\n
- float t = 2.0*t0-1.0;\n
- float t_2 = t*t;\n
- float t_3 = t*t_2;\n
- curvePoint2D = (2.0*t_3-3.0*t_2+1.0)*SegmentTwoControlPoint0 + (-2.0*t_3+3.0*t_2)*SegmentTwoControlPoint1
- + (t_3-2.0*t_2+t)*SegmentTwoTangentVector0 + (t_3-t_2)*SegmentTwoTangentVector1;\n
- tangent = (6.0*t_2-6.0*t)*SegmentTwoControlPoint0 + (-6.0*t_2+6.0*t)*SegmentTwoControlPoint1
- + (3.0*t_2-4.0*t+1.0)*SegmentTwoTangentVector0 + (3.0*t_2-2.0*t)*SegmentTwoTangentVector1;\n
- // a trick to eliminate some optical illusion caused by the gradient matter of normal in per-fragment shading
- // which is caused by linear interpolation of normal vs. nonlinear lighting
- // will notice some artifact in the areas with dramatically normal changes, so compress the normal differences here
- tangent.y *= min(1.0, length(position.xyz - vanishingPoint) / uSize.y ); \n
- }\n
- vec3 curvePoint = vec3(curveEnd - curvePoint2D.x*curveDirection,max(0.0,curvePoint2D.y));\n
- vec3 tangentVector = vec3(-tangent.x*curveDirection,tangent.y);\n
- \n
- // locate the new vertex position on the line passing through both vanishing point and the calculated curve point position
- vec3 curLiftDirection = vec3(0.0,-1.0,0.0);\n
- if(currentCenter.y != originalCenter.y)\n
- {\n
- curLiftDirection = normalize(curvePoint - vanishingPoint);\n
- tangentVector *= (curveDirection.y > 0.0) ? -1.0 : 1.0;\n
- // an heuristic adjustment here, to compensate the linear parameter mapping onto the nonlinear curve
- float Y0 = position.y - curveDirection.y * (position.x/curveDirection.x); \n
- float proportion;
- float refLength;\n
- if(abs(Y0-vanishingPoint.y) > abs(curveEnd.y-vanishingPoint.y)) \n
- {\n
- proportion = abs(curveEnd.y - Y0) / (abs(curveEnd.y-Y0)+abs(curveEnd.y - vanishingPoint.y)); \n
- refLength = proportion*length(originalCenter-vanishingPoint.xy) / (proportion-1.0); \n
- }\n
- else\n
- {\n
- proportion = abs(curveEnd.y - Y0) / abs(curveEnd.y - vanishingPoint.y);\n
- refLength = proportion*length(originalCenter-vanishingPoint.xy); \n
- }\n
- float Y1 = currentCenter.y - (normalize(currentCenter-vanishingPoint.xy)).y * refLength; \n
- position.y = mix(Y0, Y1, t0); \n
- }\n
- position.xz = curvePoint.xz - lengthFromCurve*curLiftDirection.xz;\n
- // calculate the normal vector, will be used for lighting
- normal = cross(curLiftDirection, normalize(tangentVector));\n
- // the signature of Z is decided by the page turning direction:
- // from left to right(negative); from right to left (positive)
- position.z *= -uIsTurningBack;\n
- normal.xy *= -uIsTurningBack;\n
- }\n
- // change the coordinate origin from the top-left of the page to its center
- position.xy -= uSize.xy * 0.5; \n
- }\n
- vNormal = uNormalMatrix * normal;\n
- gl_Position = uMvpMatrix * position;
- // varying parameters for fragment shader
- vTexCoord = aPosition + vec2(0.5);\n
- vTexCoord.x /= uTextureWidth;
- vPosition = uModelView * position;\n
- }\n
- );
-
- const char* fragmentShader = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- \n
- varying mediump vec2 vTexCoord;\n
- \n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform vec3 uSize;\n
- uniform vec2 uSpineShadowParameter;\n
- varying vec3 vNormal;\n
- varying vec4 vPosition;\n
- \n
- void main()\n
- {\n
- // need to re-normalize the interpolated normal
- vec3 normal = normalize( vNormal );\n
- // display page content
- vec4 texel;
- // display back image of the page, flip the texture
- if( dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) );\n
- // display front image of the page
- else texel = texture2D( sTexture, vTexCoord );\n
-
- // display book spine, a stripe of shadowed texture
- float pixelPos = vTexCoord.x * uSize.x; \n
- float spineShadowCoef = 1.0; \n
- if( pixelPos < uSpineShadowParameter.x ) \n
- {\n
- float x = pixelPos - uSpineShadowParameter.x;\n
- float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );\n
- spineShadowCoef = normalize( vec2( uSpineShadowParameter.y*x/uSpineShadowParameter.x, y ) ).y;\n
- }\n
- // calculate the lighting
- // set the ambient color as vec3(0.4);
- float lightColor = abs( normal.z ) * 0.6 + 0.4;\n
- gl_FragColor = vec4( ( spineShadowCoef * lightColor ) * texel.rgb , texel.a ) * uColor;\n
- }
- );
-
Property::Map map;
Property::Map customShader;
- customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexShader;
- customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentShader;
+ customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = SHADER_PAGE_TURN_EFFECT_VERT.data();
+ customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_PAGE_TURN_EFFECT_FRAG.data();
customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
// CLASS HEADER
#include <dali-toolkit/internal/controls/scene3d-view/gltf-loader.h>
-#include <dali-toolkit/internal/controls/scene3d-view/gltf-shader.h>
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/adaptor-framework/file-stream.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
bool isEmissiveTexture = false;
std::string VERTEX_SHADER, FRAGMENT_SHADER;
- VERTEX_SHADER = GLES_VERSION_300;
- VERTEX_SHADER += PHYSICALLY_BASED_VERTEX_SHADER;
- FRAGMENT_SHADER = GLES_VERSION_300;
+ VERTEX_SHADER = SHADER_GLTF_GLES_VERSION_300_DEF.data();
+ VERTEX_SHADER += SHADER_GLTF_PHYSICALLY_BASED_SHADER_VERT.data();
+ FRAGMENT_SHADER = SHADER_GLTF_GLES_VERSION_300_DEF.data();
bool useIBL = ( scene3dView.GetLightType() >= Toolkit::Scene3dView::LightType::IMAGE_BASED_LIGHT );
if( isMaterial )
{
MaterialInfo materialInfo = mMaterialArray[meshInfo.materialsIdx];
- if( SetTextureAndSampler( textureSet, materialInfo.baseColorTexture.index, FRAGMENT_SHADER, DEFINE_BASECOLOR_TEXTURE, addIdx ) )
+ if( SetTextureAndSampler( textureSet, materialInfo.baseColorTexture.index, FRAGMENT_SHADER, SHADER_GLTF_BASECOLOR_TEXTURE_DEF.data(), addIdx ) )
{
shaderTypeIndex += static_cast<int32_t>( ShaderType::BASECOLOR_SHADER );
isBaseColorTexture = true;
}
- if( SetTextureAndSampler( textureSet, materialInfo.metallicRoughnessTexture.index, FRAGMENT_SHADER, DEFINE_METALLICROUGHNESS_TEXTURE, addIdx ) )
+ if( SetTextureAndSampler( textureSet, materialInfo.metallicRoughnessTexture.index, FRAGMENT_SHADER, SHADER_GLTF_METALLICROUGHNESS_TEXTURE_DEF.data(), addIdx ) )
{
shaderTypeIndex += static_cast<int32_t>( ShaderType::METALLICROUGHNESS_SHADER );
isMetallicRoughnessTexture = true;
}
- if( SetTextureAndSampler( textureSet, materialInfo.normalTexture.index, FRAGMENT_SHADER, DEFINE_NORMAL_TEXTURE, addIdx ) )
+ if( SetTextureAndSampler( textureSet, materialInfo.normalTexture.index, FRAGMENT_SHADER, SHADER_GLTF_NORMAL_TEXTURE_DEF.data(), addIdx ) )
{
shaderTypeIndex += static_cast<int32_t>( ShaderType::NORMAL_SHADER );
isNormalTexture = true;
}
- if( SetTextureAndSampler( textureSet, materialInfo.occlusionTexture.index, FRAGMENT_SHADER, DEFINE_OCCLUSION_TEXTURE, addIdx ) )
+ if( SetTextureAndSampler( textureSet, materialInfo.occlusionTexture.index, FRAGMENT_SHADER, SHADER_GLTF_OCCULUSION_TEXTURE_DEF.data(), addIdx ) )
{
shaderTypeIndex += static_cast<int32_t>( ShaderType::OCCLUSION_SHADER );
isOcclusionTexture = true;
}
- if( SetTextureAndSampler( textureSet, materialInfo.emissiveTexture.index, FRAGMENT_SHADER, DEFINE_EMIT_TEXTURE, addIdx ) )
+ if( SetTextureAndSampler( textureSet, materialInfo.emissiveTexture.index, FRAGMENT_SHADER, SHADER_GLTF_EMIT_TEXTURE_DEF.data(), addIdx ) )
{
shaderTypeIndex += static_cast<int32_t>( ShaderType::EMIT_SHADER );
isEmissiveTexture = true;
if( useIBL )
{
shaderTypeIndex += static_cast<int32_t>( ShaderType::IBL_SHADER );
- FRAGMENT_SHADER += DEFINE_IBL_TEXTURE;
+ FRAGMENT_SHADER += SHADER_GLTF_IBL_TEXTURE_DEF.data();
Sampler sampler = Sampler::New();
sampler.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
}
}
- FRAGMENT_SHADER += PHYSICALLY_BASED_FRAGMENT_SHADER;
+ FRAGMENT_SHADER += SHADER_GLTF_PHYSICALLY_BASED_SHADER_FRAG.data();
if( !mShaderCache[shaderTypeIndex] )
{
mShaderCache[shaderTypeIndex] = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+++ /dev/null
-#ifndef DALI_TOOLKIT_INTERNAL_GLTF_SHADER_H
-#define DALI_TOOLKIT_INTERNAL_GLTF_SHADER_H
-
-/*
- * Belows Vertex Shader and Fragment Shader code are based off glTF WebGL PBR.
- * https://github.com/KhronosGroup/glTF-WebGL-PBR/
- *
- * Copyright (c) 2016-2017 Mohamad Moneimne and Contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-const char* GLES_VERSION_300 = {
- "#version 300 es\n\n"
- "precision highp float;\n\n"
-};
-
-const char* DEFINE_BASECOLOR_TEXTURE = {
- "#define TEXTURE_BASECOLOR\n\n"
- "uniform sampler2D uBaseColorSampler;\n"
- "uniform int uBaseColorTexCoordIndex;\n\n"
-};
-
-const char* DEFINE_METALLICROUGHNESS_TEXTURE = {
- "#define TEXTURE_METALLICROUGHNESS\n\n"
- "uniform sampler2D uMetallicRoughnessSampler;\n"
- "uniform int uMetallicRoughnessTexCoordIndex;\n\n"
-};
-
-const char* DEFINE_NORMAL_TEXTURE = {
- "#define TEXTURE_NORMAL\n\n"
- "uniform sampler2D uNormalSampler;\n"
- "uniform float uNormalScale;\n"
- "uniform int uNormalTexCoordIndex;\n\n"
-};
-
-const char* DEFINE_OCCLUSION_TEXTURE = {
- "#define TEXTURE_OCCLUSION\n\n"
- "uniform sampler2D uOcclusionSampler;\n"
- "uniform int uOcclusionTexCoordIndex;\n"
- "uniform float uOcclusionStrength;\n\n"
-};
-
-const char* DEFINE_EMIT_TEXTURE = {
- "#define TEXTURE_EMIT\n\n"
- "uniform sampler2D uEmissiveSampler;\n"
- "uniform int uEmissiveTexCoordIndex;\n"
- "uniform vec3 uEmissiveFactor;\n\n"
-};
-
-const char* DEFINE_IBL_TEXTURE = {
- "#define TEXTURE_IBL\n\n"
- "uniform sampler2D ubrdfLUT;\n"
- "uniform samplerCube uDiffuseEnvSampler;\n"
- "uniform samplerCube uSpecularEnvSampler;\n"
- "uniform vec4 uScaleIBLAmbient;\n"
- "uniform highp float uMipmapLevel;\n"
-};
-
-const char* PHYSICALLY_BASED_VERTEX_SHADER = {
- "in highp vec3 aPosition;\n"
- "in mediump vec2 aTexCoord0;\n"
- "in mediump vec2 aTexCoord1;\n"
- "in lowp vec3 aNormal;\n"
- "in lowp vec4 aTangent;\n"
- "in lowp vec4 aVertexColor;\n"
-
- "uniform mediump vec3 uSize;\n"
- "uniform mediump mat4 uModelMatrix;\n"
- "uniform mediump mat4 uViewMatrix;\n"
- "uniform mediump mat4 uProjection;\n"
- "uniform lowp int uLightType;\n"
- "uniform mediump vec3 uLightVector;\n"
- "uniform lowp int uIsColor;\n"
-
- "out lowp vec2 vUV[2];\n"
- "out lowp mat3 vTBN;\n"
- "out lowp vec4 vColor;\n"
- "flat out int visLight;\n"
- "out highp vec3 vLightDirection;\n"
- "out highp vec3 vPositionToCamera;\n"
-
- "void main()\n"
- "{\n"
- " highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);\n"
- " highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 );\n"
- " highp vec4 positionV = uViewMatrix * ( invY * positionW );\n"
-
- " vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) );\n"
- " vPositionToCamera *= invY.xyz;\n"
-
- " lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;\n"
- " vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal);\n"
-
- " vUV[0] = aTexCoord0;\n"
- " vUV[1] = aTexCoord1;\n"
-
- " visLight = 1;\n"
- " if( uLightType == 1 )\n"
- " {\n"
- " vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w );\n"
- " }\n"
- " else if( uLightType == 2 )\n"
- " {\n"
- " vLightDirection = -( invY.xyz * uLightVector );\n"
- " }\n"
- " else\n"
- " {\n"
- " visLight = 0;\n"
- " }\n"
-
- " vColor = vec4( 1.0 );\n"
- " if( uIsColor == 1 )\n"
- " {\n"
- " vColor = aVertexColor;\n"
- " }\n"
-
- " gl_Position = uProjection * positionV;\n" // needs w for proper perspective correction
- " gl_Position = gl_Position/gl_Position.w;\n"
- "}\n"
-};
-
-const char* PHYSICALLY_BASED_FRAGMENT_SHADER = {
- "uniform lowp vec3 uLightColor;\n"
- "uniform lowp vec4 uBaseColorFactor;\n"
- "uniform lowp vec2 uMetallicRoughnessFactors;\n"
- "uniform lowp int alphaMode;\n"
- "uniform lowp float alphaCutoff;\n"
-
- "in lowp vec2 vUV[2];\n"
- "in lowp mat3 vTBN;\n"
- "in lowp vec4 vColor;\n"
- "flat in int visLight;\n"
- "in highp vec3 vLightDirection;\n"
- "in highp vec3 vPositionToCamera;\n"
-
- "out vec4 FragColor;"
-
- "struct PBRInfo\n"
- "{\n"
- " mediump float NdotL;\n" // cos angle between normal and light direction
- " mediump float NdotV;\n" // cos angle between normal and view direction
- " mediump float NdotH;\n" // cos angle between normal and half vector
- " mediump float VdotH;\n" // cos angle between view direction and half vector
- " mediump vec3 reflectance0;\n" // full reflectance color (normal incidence angle)
- " mediump vec3 reflectance90;\n" // reflectance color at grazing angle
- " lowp float alphaRoughness;\n" // roughness mapped to a more linear change in the roughness (proposed by [2])
- "};\n"
-
- "const float M_PI = 3.141592653589793;\n"
- "const float c_MinRoughness = 0.04;\n"
-
- "vec3 getNormal()\n"
- "{\n"
- "#ifdef TEXTURE_NORMAL\n"
- " lowp vec3 n = texture( uNormalSampler, vUV[uNormalTexCoordIndex] ).rgb;\n"
- " n = normalize( vTBN * ( ( 2.0 * n - 1.0 ) * vec3( uNormalScale, uNormalScale, 1.0 ) ) );\n"
- "#else\n"
- " lowp vec3 n = normalize( vTBN[2].xyz );\n"
- "#endif\n"
- " return n;\n"
- "}\n"
-
- "vec3 specularReflection( PBRInfo pbrInputs )\n"
- "{\n"
- " return pbrInputs.reflectance0 + ( pbrInputs.reflectance90 - pbrInputs.reflectance0 ) * pow( clamp( 1.0 - pbrInputs.VdotH, 0.0, 1.0 ), 5.0 );\n"
- "}\n"
-
- "float geometricOcclusion( PBRInfo pbrInputs )\n"
- "{\n"
- " mediump float NdotL = pbrInputs.NdotL;\n"
- " mediump float NdotV = pbrInputs.NdotV;\n"
- " lowp float r = pbrInputs.alphaRoughness;\n"
-
- " lowp float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n"
- " lowp float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n"
- " return attenuationL * attenuationV;\n"
- "}\n"
-
- "float microfacetDistribution(PBRInfo pbrInputs)\n"
- "{\n"
- " mediump float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n"
- " lowp float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n"
- " return roughnessSq / (M_PI * f * f);\n"
- "}\n"
-
- "vec3 linear( vec3 color )\n"
- "{\n"
- " return pow(color,vec3(2.2));\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- // Metallic and Roughness material properties are packed together
- // In glTF, these factors can be specified by fixed scalar values
- // or from a metallic-roughness map
- " lowp float metallic = uMetallicRoughnessFactors.x;\n"
- " lowp float perceptualRoughness = uMetallicRoughnessFactors.y;\n"
-
- // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
- // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
- "#ifdef TEXTURE_METALLICROUGHNESS\n"
- " lowp vec4 metrou = texture(uMetallicRoughnessSampler, vUV[uMetallicRoughnessTexCoordIndex]);\n"
- " metallic = metrou.b * metallic;\n"
- " perceptualRoughness = metrou.g * perceptualRoughness;\n"
- "#endif\n"
-
- " metallic = clamp(metallic, 0.0, 1.0);\n"
- " perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n"
- // Roughness is authored as perceptual roughness; as is convention,
- // convert to material roughness by squaring the perceptual roughness [2].
- " lowp float alphaRoughness = perceptualRoughness * perceptualRoughness;\n"
-
- "#ifdef TEXTURE_BASECOLOR\n"
- // The albedo may be defined from a base texture or a flat color
- " lowp vec4 baseColor = texture(uBaseColorSampler, vUV[uBaseColorTexCoordIndex]) * uBaseColorFactor;\n"
- " baseColor = vec4(linear(baseColor.rgb), baseColor.w);\n"
- "#else\n"
- " lowp vec4 baseColor = vColor * uBaseColorFactor;\n"
- "#endif\n"
-
- " if( alphaMode == 0 )\n"
- " {\n"
- " baseColor.w = 1.0;\n"
- " }\n"
- " else if( alphaMode == 1 )\n"
- " {\n"
- " if( baseColor.w >= alphaCutoff )"
- " {\n"
- " baseColor.w = 1.0;\n"
- " }\n"
- " else\n"
- " {\n"
- " baseColor.w = 0.0;\n"
- " }\n"
- " }\n"
-
- " lowp vec3 f0 = vec3(0.04);\n"
- " lowp vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n"
- " diffuseColor *= ( 1.0 - metallic );\n"
- " lowp vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n"
-
- // Compute reflectance.
- " lowp float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n"
-
- // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect.
- // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%.
- " lowp float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n"
- " lowp vec3 specularEnvironmentR0 = specularColor.rgb;\n"
- " lowp vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n"
-
- " mediump vec3 n = getNormal();\n" // normal at surface point
- " mediump vec3 v = normalize(vPositionToCamera);\n" // Vector from surface point to camera
- " mediump vec3 l = normalize(vLightDirection);\n" // Vector from light to surface point
- " mediump vec3 h = normalize(l+v);\n" // Half vector between both l and v
- " mediump vec3 reflection = -normalize(reflect(v, n));\n"
-
- " mediump float NdotL = clamp(dot(n, l), 0.001, 1.0);\n"
- " mediump float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n"
- " mediump float NdotH = dot(n, h);\n"
- " mediump float LdotH = dot(l, h);\n"
- " mediump float VdotH = dot(v, h);\n"
-
- " PBRInfo pbrInputs = PBRInfo(\n"
- " NdotL,\n"
- " NdotV,\n"
- " NdotH,\n"
- " VdotH,\n"
- " specularEnvironmentR0,\n"
- " specularEnvironmentR90,\n"
- " alphaRoughness\n"
- " );\n"
-
- // Calculate the shading terms for the microfacet specular shading model
- " lowp vec3 color = vec3(0.0);\n"
- " if( visLight == 1 )\n"
- " {\n"
- " lowp vec3 F = specularReflection( pbrInputs );\n"
- " lowp float G = geometricOcclusion( pbrInputs );\n"
- " lowp float D = microfacetDistribution( pbrInputs );\n"
-
- // Calculation of analytical lighting contribution
- " lowp vec3 diffuseContrib = ( 1.0 - F ) * ( diffuseColor / M_PI );\n"
- " lowp vec3 specContrib = F * G * D / ( 4.0 * NdotL * NdotV );\n"
- // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
- " color = NdotL * uLightColor * (diffuseContrib + specContrib);\n"
- " }\n"
-
- "#ifdef TEXTURE_IBL\n"
- " lowp float lod = ( perceptualRoughness * uMipmapLevel );\n"
- // retrieve a scale and bias to F0. See [1], Figure 3
- " lowp vec3 brdf = linear( texture( ubrdfLUT, vec2( NdotV, 1.0 - perceptualRoughness ) ).rgb );\n"
- " lowp vec3 diffuseLight = linear( texture( uDiffuseEnvSampler, n ).rgb );\n"
- " lowp vec3 specularLight = linear( textureLod( uSpecularEnvSampler, reflection, lod ).rgb );\n"
-
- " lowp vec3 diffuse = diffuseLight * diffuseColor * uScaleIBLAmbient.x;\n"
- " lowp vec3 specular = specularLight * ( specularColor * brdf.x + brdf.y ) * uScaleIBLAmbient.y;\n"
- " color += ( diffuse + specular );\n"
- "#endif\n"
-
- "#ifdef TEXTURE_OCCLUSION\n"
- " lowp float ao = texture( uOcclusionSampler, vUV[uOcclusionTexCoordIndex] ).r;\n"
- " color = mix( color, color * ao, uOcclusionStrength );\n"
- "#endif\n"
-
- "#ifdef TEXTURE_EMIT\n"
- " lowp vec3 emissive = linear( texture( uEmissiveSampler, vUV[uEmissiveTexCoordIndex] ).rgb ) * uEmissiveFactor;\n"
- " color += emissive;\n"
- "#endif\n"
-
- " FragColor = vec4( pow( color,vec3( 1.0 / 2.2 ) ), baseColor.a );\n"
- "}\n"
-};
-
-} // namespace internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_INTERNAL_GLTF_SHADER_H
\ No newline at end of file
#include <dali/public-api/rendering/shader.h>
#include <dali/public-api/rendering/texture-set.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+
namespace Dali
{
26.f / 130.f
};
-#define MAKE_SHADER(A)#A
-
-// Modify the vertex position according to the bounce coefficient;
-const char* MESH_VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec3 aPosition1;\n
-attribute mediump vec3 aPosition2;\n
-uniform mediump mat4 uMvpMatrix;\n
-uniform mediump vec3 uSize;
-uniform mediump float uBounceCoefficient;\n
-\n
-void main()\n
-{\n
- gl_Position = uMvpMatrix * vec4(mix( aPosition1, aPosition2, abs(uBounceCoefficient) )*uSize, 1.0);\n
-}
-);
-
-// use the actor color to paint every layer
-const char* MESH_FRAGMENT_SHADER = MAKE_SHADER(
-uniform lowp vec4 uColor;\n
-void main()\n
-{\n
- gl_FragColor = uColor;\n
-}\n
-);
-
} // namespace Anon
Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
meshGeometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
// Create the shader
- Shader shader = Shader::New( MESH_VERTEX_SHADER, MESH_FRAGMENT_SHADER );
+ Shader shader = Shader::New( SHADER_BOUNCING_EFFECT_MESH_SHADER_VERT, SHADER_BOUNCING_EFFECT_MESH_SHADER_FRAG );
// Create renderer
Renderer renderer = Renderer::New( meshGeometry, shader );
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/controls/control/control-renderers.h>
#include <dali-toolkit/internal/controls/shadow-view/shadow-view-impl.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
const char* const BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty";
const char* const SHADOW_COLOR_PROPERTY_NAME = "ShadowColorProperty";
-const char* const RENDER_SHADOW_VERTEX_SOURCE =
-
- " attribute mediump vec2 aPosition;\n"
- " uniform mediump mat4 uMvpMatrix;\n"
- " uniform mediump mat4 uModelMatrix;\n"
- " uniform vec3 uSize;\n"
- " varying vec2 vTexCoord;\n"
-
- " uniform mediump mat4 uLightCameraProjectionMatrix;\n"
- " uniform mediump mat4 uLightCameraViewMatrix;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n"
- " vertexPosition.xyz *= uSize;\n"
- " gl_Position = uMvpMatrix * vertexPosition;\n"
- " vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vertexPosition;\n"
- " vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);\n"
- "}\n";
-
-const char* const RENDER_SHADOW_FRAGMENT_SOURCE =
- "varying mediump vec2 vTexCoord;\n"
- "uniform lowp vec4 uShadowColor;\n"
- "uniform sampler2D sTexture;\n"
-
- "void main()\n"
- "{\n"
- " lowp float alpha;\n"
- " alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;\n"
- " gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
- "}\n";
-
} // namespace
ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale )
mShadowPlane.SetProperty( Actor::Property::NAME, "SHADOW_PLANE" );
mShadowPlane.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
mShadowPlane.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
- Renderer shadowRenderer = CreateRenderer( RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE, Shader::Hint::OUTPUT_IS_TRANSPARENT, Uint16Pair(20,20) );
+ Renderer shadowRenderer = CreateRenderer( SHADER_SHADOW_VIEW_RENDER_SHADER_VERT, SHADER_SHADOW_VIEW_RENDER_SHADER_FRAG,
+ Shader::Hint::OUTPUT_IS_TRANSPARENT,
+ Uint16Pair(20,20) );
TextureSet textureSet = shadowRenderer.GetTextures();
textureSet.SetTexture( 0u, mOutputFrameBuffer.GetColorTexture() );
mShadowPlane.AddRenderer( shadowRenderer );
// INTERNAL_INCLUDES
#include <dali-toolkit/public-api/image-loader/sync-image-loader.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/controls/control/control-renderers.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
const float GAUSSIAN_BLUR_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
const char* ALPHA_UNIFORM_NAME( "uAlpha" );
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp float uAlpha;\n
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
- gl_FragColor.a *= uAlpha;
- }\n
-);
/**
* The constraint is used to blend the group of blurred images continuously with a unified blur strength property value which ranges from zero to one.
for(unsigned int i=0; i<mBlurLevels+1;i++)
{
- mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, FRAGMENT_SHADER );
+ mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SUPER_BLUR_VIEW_FRAG );
mRenderers[i].SetProperty( Dali::Renderer::Property::DEPTH_INDEX, (int)i );
self.AddRenderer( mRenderers[i] );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() );
if ( mInputMethodContext && IsEditable() )
{
+ // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
+ mInputMethodContext.NotifyTextInputMultiLine( true );
+
mInputMethodContext.StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged );
mInputMethodContext.EventReceivedSignal().Connect( this, &TextEditor::OnInputMethodContextEvent );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
if ( mInputMethodContext && IsEditable() )
{
+ // All input panel properties, such as layout, return key type, and input hint, should be set before input panel activates (or shows).
mInputMethodContext.ApplyOptions( mInputMethodOptions );
+ mInputMethodContext.NotifyTextInputMultiLine( false );
mInputMethodContext.StatusChangedSignal().Connect( this, &TextField::KeyboardStatusChanged );
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
const char* const DEFAULT_SAMPLER_TYPE_NAME( "sampler2D" );
const char* const CUSTOM_SAMPLER_TYPE_NAME( "samplerExternalOES" );
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- \n
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vertexPosition.xyz *= uSize;\n
- gl_Position = uMvpMatrix * vertexPosition;\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- \n
- void main()\n
- {\n
- gl_FragColor = vec4(0.0);\n
- }\n
-);
-
-const char* VERTEX_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- varying mediump vec2 vTexCoord;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- varying mediump vec2 sTexCoordRect;\n
- void main()\n
- {\n
- gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);\n
- vTexCoord = aPosition + vec2(0.5);\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
- uniform lowp vec4 uColor;\n
- varying mediump vec2 vTexCoord;\n
- uniform samplerExternalOES sTexture;\n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
- }\n
-);
-
} // anonymous namepsace
VideoView::VideoView( Dali::VideoSyncMode syncMode )
{
// For underlay rendering mode, video display area have to be transparent.
Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ Shader shader = Shader::New( SHADER_VIDEO_VIEW_VERT, SHADER_VIDEO_VIEW_FRAG );
mOverlayRenderer = Renderer::New( geometry, shader );
mOverlayRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
}
if( !vertexShaderValue || !checkShader )
{
- vertexShader = VERTEX_SHADER_TEXTURE;
+ vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
}
Property::Value* fragmentShaderValue = mEffectPropertyMap.Find( CUSTOM_FRAGMENT_SHADER );
if( !fragmentShaderValue || !checkShader )
{
- fragmentShader += FRAGMENT_SHADER_TEXTURE;
+ fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
}
}
else
{
- vertexShader = VERTEX_SHADER_TEXTURE;
- fragmentShader += FRAGMENT_SHADER_TEXTURE;
+ vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
+ fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
}
return Dali::Shader::New( vertexShader, fragmentShader );
// EXTERNAL INCLUDES
#include <cstring>
+#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/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/devel-api/common/stage.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-context.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/public-api/image-loader/image.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
namespace Dali
return Toolkit::WebView::New();
}
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER )
-DALI_ENUM_TO_STRING_TABLE_END( CacheModel )
-
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY )
-DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy )
-
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel", STRING, CACHE_MODEL )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy", STRING, COOKIE_ACCEPT_POLICY )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent", STRING, USER_AGENT )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript", BOOLEAN, ENABLE_JAVASCRIPT )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING, DEFAULT_TEXT_ENCODING_NAME )
-DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize", INTEGER, DEFAULT_FONT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize", VECTOR2, SCROLL_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize", VECTOR2, CONTENT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "title", STRING, TITLE )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadError", PAGE_LOAD_ERROR_SIGNAL )
+DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "scrollEdgeReached", SCROLL_EDGE_REACHED_SIGNAL )
DALI_TYPE_REGISTRATION_END()
}
}
+WebView::WebView( int argc, char** argv )
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+ mUrl(),
+ mVisual(),
+ mWebViewSize( Stage::GetCurrent().GetSize() ),
+ mWebEngine(),
+ mPageLoadStartedSignal(),
+ mPageLoadFinishedSignal(),
+ mPageLoadErrorSignal()
+{
+ mWebEngine = Dali::WebEngine::New();
+
+ // WebEngine is empty when it is not properly initialized.
+ if ( mWebEngine )
+ {
+ mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, argc, argv );
+ }
+}
+
WebView::WebView()
: WebView( "", "" )
{
return handle;
}
+Toolkit::WebView WebView::New( int argc, char** argv )
+{
+ WebView* impl = new WebView( argc, argv );
+ Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+ impl->Initialize();
+ return handle;
+}
+
void WebView::OnInitialize()
{
Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
+ mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
+
+ mWebContext = std::unique_ptr<Dali::Toolkit::WebContext>( new WebContext( mWebEngine.GetContext() ) );
+ mWebCookieManager = std::unique_ptr<Dali::Toolkit::WebCookieManager>( new WebCookieManager( mWebEngine.GetCookieManager() ) );
+ mWebSettings = std::unique_ptr<Dali::Toolkit::WebSettings>( new WebSettings( mWebEngine.GetSettings() ) );
+ mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>( new WebBackForwardList( mWebEngine.GetBackForwardList() ) );
+ }
+}
+
+Dali::Toolkit::WebSettings* WebView::GetSettings() const
+{
+ return mWebSettings.get();
+}
+
+Dali::Toolkit::WebContext* WebView::GetContext() const
+{
+ return mWebContext.get();
+}
+
+Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
+{
+ return mWebCookieManager.get();
+}
+
+Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
+{
+ return mWebBackForwardList.get();
+}
+
+Dali::Toolkit::ImageView& WebView::GetFavicon()
+{
+ if ( mWebEngine )
+ {
+ Dali::PixelData pixelData = mWebEngine.GetFavicon();
+ std::string url = Dali::Toolkit::Image::GenerateUrl( pixelData );
+ mFaviconView = Dali::Toolkit::ImageView::New( url );
+ mFaviconView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ mFaviconView.SetProperty( Dali::Actor::Property::SIZE, Vector2( pixelData.GetWidth(), pixelData.GetHeight() ) );
}
+ return mFaviconView;
}
void WebView::LoadUrl( const std::string& url )
}
}
-void WebView::LoadHTMLString( const std::string& htmlString )
+void WebView::LoadHtmlString( const std::string& htmlString )
{
if( mWebEngine )
{
if( mVisual )
{
DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
- mWebEngine.LoadHTMLString( htmlString );
+ mWebEngine.LoadHtmlString( htmlString );
}
}
}
}
}
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.ScrollBy( deltaX, deltaY );
+ }
+}
+
bool WebView::CanGoForward()
{
return mWebEngine ? mWebEngine.CanGoForward() : false;
}
}
-void WebView::ClearHistory()
+void WebView::ClearAllTilesResources()
{
if( mWebEngine )
{
- mWebEngine.ClearHistory();
+ mWebEngine.ClearAllTilesResources();
}
}
-void WebView::ClearCache()
-{
- if( mWebEngine )
- {
- mWebEngine.ClearCache();
- }
-}
-
-void WebView::ClearCookies()
+void WebView::ClearHistory()
{
if( mWebEngine )
{
- mWebEngine.ClearCookies();
+ mWebEngine.ClearHistory();
}
}
return mPageLoadErrorSignal;
}
+Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+ return mScrollEdgeReachedSignal;
+}
+
void WebView::OnPageLoadStarted( const std::string& url )
{
if( !mPageLoadStartedSignal.Empty() )
}
}
+void WebView::OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge )
+{
+ if( !mScrollEdgeReachedSignal.Empty() )
+ {
+ Dali::Toolkit::WebView handle( GetOwner() );
+ mScrollEdgeReachedSignal.Emit( handle, edge );
+ }
+}
+
bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
Dali::BaseHandle handle( object );
webView.PageLoadErrorSignal().Connect( tracker, functor );
connected = true;
}
+ else if( 0 == strcmp( signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL ) )
+ {
+ webView.ScrollEdgeReachedSignal().Connect( tracker, functor );
+ connected = true;
+ }
return connected;
}
}
break;
}
- case Toolkit::WebView::Property::CACHE_MODEL:
- {
- Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel();
- GET_ENUM_VALUE( CacheModel, value, output );
- impl.SetCacheModel( output );
- break;
- }
- case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
- {
- Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy();
- GET_ENUM_VALUE( CookieAcceptPolicy, value, output );
- impl.SetCookieAcceptPolicy( output );
- break;
- }
case Toolkit::WebView::Property::USER_AGENT:
{
std::string input;
}
break;
}
- case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
- {
- bool input;
- if( value.Get( input ) )
- {
- impl.EnableJavaScript( input );
- }
- break;
- }
- case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
+ case Toolkit::WebView::Property::SCROLL_POSITION:
{
- bool input;
- if( value.Get( input ) )
+ Vector2 input;
+ if ( value.Get( input ) )
{
- impl.LoadImagesAutomatically( input );
- }
- break;
- }
- case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
- {
- std::string input;
- if( value.Get( input ) )
- {
- impl.SetDefaultTextEncodingName( input );
- }
- break;
- }
- case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
- {
- int input;
- if( value.Get( input ) )
- {
- impl.SetDefaultFontSize( input );
+ impl.SetScrollPosition( input.x, input.y );
}
break;
}
value = impl.mUrl;
break;
}
- case Toolkit::WebView::Property::CACHE_MODEL:
- {
- value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() );
- break;
- }
- case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
- {
- value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() );
- break;
- }
case Toolkit::WebView::Property::USER_AGENT:
{
value = impl.GetUserAgent();
break;
}
- case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
+ case Toolkit::WebView::Property::SCROLL_POSITION:
{
- value = impl.IsJavaScriptEnabled();
+ value = impl.GetScrollPosition();
break;
}
- case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
+ case Toolkit::WebView::Property::SCROLL_SIZE:
{
- value = impl.AreImagesAutomaticallyLoaded();
+ value = impl.GetScrollSize();
break;
}
- case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
+ case Toolkit::WebView::Property::CONTENT_SIZE:
{
- value = impl.GetDefaultTextEncodingName();
+ value = impl.GetContentSize();
break;
}
- case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
+ case Toolkit::WebView::Property::TITLE:
{
- value = impl.GetDefaultFontSize();
+ value = impl.GetTitle();
break;
}
default:
return result;
}
-Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
-{
- return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
-}
-
-void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel )
+void WebView::OnKeyInputFocusGained()
{
if( mWebEngine )
{
- mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) );
+ mWebEngine.SetFocus( true );
}
-}
-Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const
-{
- return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY;
+ EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
}
-void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy )
+void WebView::OnKeyInputFocusLost()
{
if( mWebEngine )
{
- mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) );
+ mWebEngine.SetFocus( false );
}
-}
-const std::string& WebView::GetUserAgent() const
-{
- return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
+ EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
}
-void WebView::SetUserAgent( const std::string& userAgent )
+void WebView::SetScrollPosition( int x, int y )
{
if( mWebEngine )
{
- mWebEngine.SetUserAgent( userAgent );
+ mWebEngine.SetScrollPosition( x, y );
}
}
-bool WebView::IsJavaScriptEnabled() const
+Dali::Vector2 WebView::GetScrollPosition() const
{
- return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true;
+ return mWebEngine ? mWebEngine.GetScrollPosition() : Dali::Vector2::ZERO;
}
-void WebView::EnableJavaScript( bool enabled )
+Dali::Vector2 WebView::GetScrollSize() const
{
- if( mWebEngine )
- {
- mWebEngine.EnableJavaScript( enabled );
- }
+ return mWebEngine ? mWebEngine.GetScrollSize() : Dali::Vector2::ZERO;
}
-bool WebView::AreImagesAutomaticallyLoaded() const
+Dali::Vector2 WebView::GetContentSize() const
{
- return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true;
+ return mWebEngine ? mWebEngine.GetContentSize() : Dali::Vector2::ZERO;
}
-void WebView::LoadImagesAutomatically( bool automatic )
+std::string WebView::GetTitle() const
{
- if( mWebEngine )
- {
- mWebEngine.LoadImagesAutomatically( automatic );
- }
-}
-
-const std::string& WebView::GetDefaultTextEncodingName() const
-{
- return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString;
-}
-
-void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
-{
- if( mWebEngine )
- {
- mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName );
- }
+ return mWebEngine ? mWebEngine.GetTitle() : kEmptyString;
}
-int WebView::GetDefaultFontSize() const
+const std::string& WebView::GetUserAgent() const
{
- return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0;
+ return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
}
-void WebView::SetDefaultFontSize( int defaultFontSize )
+void WebView::SetUserAgent( const std::string& userAgent )
{
if( mWebEngine )
{
- mWebEngine.SetDefaultFontSize( defaultFontSize );
+ mWebEngine.SetUserAgent( userAgent );
}
}
*/
// EXTERNAL INCLUDES
+#include <memory>
#include <dali/devel-api/adaptor-framework/web-engine.h>
#include <dali/public-api/images/image-operations.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
namespace Dali
{
class KeyEvent;
class TouchEvent;
+class WebBackForwardList;
+class WebContext;
+class WebCookieManager;
+class WebSettings;
class WebView;
namespace Internal
WebView( const std::string& locale, const std::string& timezoneId );
+ WebView( int argc, char** argv );
+
virtual ~WebView();
public:
static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
/**
+ * @brief Get settings of WebEngine.
+ */
+ Dali::Toolkit::WebSettings* GetSettings() const;
+
+ /**
+ * @brief Get context of WebEngine.
+ */
+ Dali::Toolkit::WebContext* GetContext() const;
+
+ /**
+ * @brief Get cookie manager of WebEngine.
+ */
+ Dali::Toolkit::WebCookieManager* GetCookieManager() const;
+
+ /**
+ * @brief Get WebBackForwardList of WebEngine.
+ */
+ Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::New( int, char** )
+ */
+ static Toolkit::WebView New( int argc, char** argv );
+
+ /**
+ * @brief Get Favicon of web page.
+ *
+ * @return Handle to a fav icon
+ */
+ Dali::Toolkit::ImageView& GetFavicon();
+
+ /**
* @copydoc Dali::Toolkit::WebView::LoadUrl()
*/
void LoadUrl( const std::string& url );
/**
* @copydoc Dali::WebEngine::LoadHTMLString()
*/
- void LoadHTMLString( const std::string& htmlString );
+ void LoadHtmlString( const std::string& htmlString );
/**
* @copydoc Dali::Toolkit::WebView::Reload()
void Resume();
/**
+ * @copydoc Dali::Toolkit::WebView::ScrollBy()
+ */
+ void ScrollBy( int deltaX, int deltaY );
+
+ /**
* @copydoc Dali::Toolkit::WebView::CanGoForward()
*/
bool CanGoForward();
void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler );
/**
- * @copydoc Dali::Toolkit::WebView::ClearHistory()
- */
- void ClearHistory();
-
- /**
- * @copydoc Dali::Toolkit::WebView::ClearCache()
+ * @brief Clears all tiles resources of Web.
*/
- void ClearCache();
+ void ClearAllTilesResources();
/**
- * @copydoc Dali::Toolkit::WebView::ClearCookies()
+ * @copydoc Dali::Toolkit::WebView::ClearHistory()
*/
- void ClearCookies();
+ void ClearHistory();
/**
* @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
*/
Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+ /**
+ * @copydoc Dali::Toolkit::WebView::ScrollEdgeReachedSignal()
+ */
+ Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
public: // Properties
/**
*/
bool OnKeyEvent( const Dali::KeyEvent& event ) override;
-private:
-
- // Undefined
- WebView( const WebView& webView );
-
- WebView& operator=( const WebView& webView );
-
- /**
- * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
- * @see Toolkit::WebView::CacheModel::Type
- */
- Toolkit::WebView::CacheModel::Type GetCacheModel() const;
-
- /**
- * @brief Set cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
- * @param[in] cacheModel The cache model option
- * @see Toolkit::WebView::CacheModel::Type
- */
- void SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel );
-
/**
- * @brief Gets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
- * @see Toolkit::WebView::CookieAcceptPolicy::Type
+ * @copydoc Toolkit::Control::OnKeyInputFocusGained()
*/
- Toolkit::WebView::CookieAcceptPolicy::Type GetCookieAcceptPolicy() const;
+ void OnKeyInputFocusGained() override;
/**
- * @brief Sets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY.
- * @param[in] policy The cookie acceptance policy
- * @see Toolkit::WebView::CookieAcceptPolicy::Type
+ * @copydoc Toolkit::Control::OnKeyInputFocusLost()
*/
- void SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy );
+ void OnKeyInputFocusLost() override;
- /**
- * @brief Get user agent string.
- * @return The string value of user agent
- */
- const std::string& GetUserAgent() const;
+private:
- /**
- * @brief Set user agent string.
- * @param[in] userAgent The string value of user agent
- */
- void SetUserAgent( const std::string& userAgent );
+ // Undefined
+ WebView( const WebView& webView );
- /**
- * @brief Returns whether JavaScript can be executable. The default is true.
- *
- * @return true if JavaScript executing is enabled, false otherwise
- */
- bool IsJavaScriptEnabled() const;
+ WebView& operator=( const WebView& webView );
/**
- * @brief Enables/disables JavaScript executing. The default is enabled.
- *
- * @param[in] enabled True if JavaScript executing is enabled, false otherwise
+ * @brief Sets an absolute scroll of the given view.
+ * @param[in] x The coordinate x of scroll
+ * @param[in] y The coordinate y of scroll
*/
- void EnableJavaScript( bool enabled );
+ void SetScrollPosition( int x, int y );
/**
- * @brief Returns whether images can be loaded automatically. The default is true.
- *
- * @return true if images are loaded automatically, false otherwise
+ * @brief Gets the current scroll position of the given view.
+ * @param[out] x The coordinate x of scroll
+ * @param[out] y The coordinate y of scroll
*/
- bool AreImagesAutomaticallyLoaded() const;
+ Dali::Vector2 GetScrollPosition() const;
/**
- * @brief Enables/disables auto loading of images. The default is enabled.
- *
- * @param[in] automatic True if images are loaded automatically, false otherwise
+ * @brief Gets the possible scroll size of the given view.
+ * @param[out] width The width of scroll size
+ * @param[out] height The height of scroll size
*/
- void LoadImagesAutomatically( bool automatic );
+ Dali::Vector2 GetScrollSize() const;
/**
- * @brief Gets the default text encoding name (e.g. UTF-8).
- *
- * @return The default text encoding name
+ * @brief Gets the last known content's size.
+ * @param[out] width The width of content's size
+ * @param[out] height The height of content's size
*/
- const std::string& GetDefaultTextEncodingName() const;
+ Dali::Vector2 GetContentSize() const;
/**
- * @brief Sets the default text encoding name (e.g. UTF-8).
+ * @brief Returns the title of the Web.
*
- * @param[in] defaultTextEncodingName The default text encoding name
+ * @return The title of web page
*/
- void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName );
+ std::string GetTitle() const;
/**
- * @brief Returns the default font size in pixel. The default value is 16.
- *
- * @return The default font size
+ * @brief Get user agent string.
+ * @return The string value of user agent
*/
- int GetDefaultFontSize() const;
+ const std::string& GetUserAgent() const;
/**
- * @brief Sets the default font size in pixel. The default value is 16.
- *
- * @param[in] defaultFontSize A new default font size to set
+ * @brief Set user agent string.
+ * @param[in] userAgent The string value of user agent
*/
- void SetDefaultFontSize( int defaultFontSize );
+ void SetUserAgent( const std::string& userAgent );
/**
* @brief Callback function to be called when page load started.
*/
void OnPageLoadError( const std::string& url, int errorCode );
+ /**
+ * @brief Callback function to be called when scroll edge is reached.
+ * @param[in] e The scroll edge reached.
+ */
+ void OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge );
+
private:
std::string mUrl;
Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadStartedSignal;
Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal;
Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal;
+ Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+
+ std::unique_ptr<Dali::Toolkit::WebContext> mWebContext;
+ std::unique_ptr<Dali::Toolkit::WebCookieManager> mWebCookieManager;
+ std::unique_ptr<Dali::Toolkit::WebSettings> mWebSettings;
+ std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
+ Dali::Toolkit::ImageView mFaviconView;
};
} // namespace Internal
${toolkit_src_dir}/transition-effects/cube-transition-wave-effect-impl.cpp
${toolkit_src_dir}/text/xhtml-entities.cpp
${toolkit_src_dir}/drag-drop-detector/drag-and-drop-detector-impl.cpp
+ ${toolkit_src_dir}/graphics/generated/builtin-shader-gen.cpp
)
SET( SOURCES ${SOURCES}
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/control/control-renderers.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
1.0f/16.0f, 1.0f/16.0f, 1.0f/16.0f, 0.5f/16.0f,
0.5f/16.0f, 0.5f/16.0f, 0.5f/16.0f };
-const char* BLUR_TWO_PASS_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform vec2 uSampleOffsets[NUM_SAMPLES];\n"
- "uniform float uSampleWeights[NUM_SAMPLES];\n"
- "void main()\n"
- "{\n"
- " vec4 color = vec4(0.0);\n"
- " for( int i = 0; i < NUM_SAMPLES; ++i )\n"
- " {\n"
- " color += texture2D( sTexture, vTexCoord + uSampleOffsets[i] ) * uSampleWeights[i];\n"
- " }\n"
- " gl_FragColor = color;\n"
- "}\n"
-};
-
std::string GetOffsetUniformName( int index )
{
std::ostringstream oss;
return oss.str();
}
-const char* BLEND_TWO_IMAGES_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "uniform float uBlurStrength;\n "
- "uniform sampler2D sTexture;\n"
- "uniform sampler2D sEffect;\n"
- "varying mediump vec2 vTexCoord;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D( sTexture, vTexCoord ) * uBlurStrength"
- " + texture2D( sEffect, vTexCoord )*(1.0-uBlurStrength); \n"
- "}\n"
-};
-
const char* const BLUR_STRENGTH_UNIFORM_NAME( "uBlurStrength" );
const char* const EFFECT_IMAGE_NAME( "sEffect" );
// Set up blur-two-pass custom shader
std::ostringstream sstream;
sstream << "#define NUM_SAMPLES " << kernelSize << "\n";
- sstream << BLUR_TWO_PASS_FRAGMENT_SOURCE;
+ sstream << SHADER_BLUR_TWO_PASS_SHADER_FRAG;
std::string fragmentSource( sstream.str() );
// create actor to render input with applied emboss effect
mBlurredFrameBuffer.AttachColorTexture( blurredTexture );
// create an actor to blend the blurred image and the input image with the given blur strength
- Renderer rendererForBlending = CreateRenderer( BASIC_VERTEX_SOURCE, BLEND_TWO_IMAGES_FRAGMENT_SOURCE );
+ Renderer rendererForBlending = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_BLUR_TWO_IMAGES_SHADER_FRAG );
TextureSet textureSetForBlending = rendererForBlending.GetTextures();
textureSetForBlending.SetTexture( 0u, blurredTexture );
textureSetForBlending.SetTexture( 1u, mInputTexture );
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/control/control-renderers.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
namespace
{
-const char* EMBOSS_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform vec2 uTexScale;\n"
- "uniform vec3 uCoefficient;\n"
- "\n"
- "void main()\n"
- "{\n"
- " vec4 color = uCoefficient.x * texture2D( sTexture, vTexCoord + vec2(0.0, -uTexScale.y) );\n"
- " color += uCoefficient.y * texture2D( sTexture, vTexCoord );\n"
- " color += uCoefficient.z * texture2D( sTexture, vTexCoord + vec2(0.0, uTexScale.y) );\n"
- " gl_FragColor = color;\n"
- "}\n"
-};
-
-const char* const COMPOSITE_FRAGMENT_SOURCE =
-{
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uEffectColor;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = uEffectColor;\n"
- " gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;\n"
- "}\n"
-};
-
const char* const TEX_SCALE_UNIFORM_NAME( "uTexScale" );
const char* const COEFFICIENT_UNIFORM_NAME( "uCoefficient" );
const char* const COLOR_UNIFORM_NAME( "uEffectColor" );
mActorForInput1.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
mActorForInput1.RegisterProperty( COEFFICIENT_UNIFORM_NAME, Vector3( 2.f, -1.f, -1.f ) );
// set EMBOSS custom shader
- Renderer renderer1 = CreateRenderer( BASIC_VERTEX_SOURCE, EMBOSS_FRAGMENT_SOURCE );
+ Renderer renderer1 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_SHADER_FRAG );
SetRendererTexture( renderer1, mInputTexture );
mActorForInput1.AddRenderer( renderer1 );
mRootActor.Add( mActorForInput1 );
mActorForInput2.RegisterProperty( TEX_SCALE_UNIFORM_NAME, textureScale );
mActorForInput2.RegisterProperty( COEFFICIENT_UNIFORM_NAME, Vector3( -1.f, -1.f, 2.f ) );
// set EMBOSS custom shader
- Renderer renderer2 = CreateRenderer( BASIC_VERTEX_SOURCE, EMBOSS_FRAGMENT_SOURCE );
+ Renderer renderer2 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_SHADER_FRAG );
SetRendererTexture( renderer2, mInputTexture );
mActorForInput2.AddRenderer( renderer2 );
mRootActor.Add( mActorForInput2 );
mRootActor.Add( mActorForComposite );
- mRendererForEmboss1 = CreateRenderer( BASIC_VERTEX_SOURCE, COMPOSITE_FRAGMENT_SOURCE );
+ mRendererForEmboss1 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_COMPOSITE_SHADER_FRAG );
SetRendererTexture( mRendererForEmboss1, mFrameBufferForEmboss1 );
mRendererForEmboss1.RegisterProperty( COLOR_UNIFORM_NAME, Color::BLACK );
mActorForComposite.AddRenderer( mRendererForEmboss1 );
- mRendererForEmboss2 = CreateRenderer( BASIC_VERTEX_SOURCE, COMPOSITE_FRAGMENT_SOURCE );
+ mRendererForEmboss2 = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_EMBOSS_FILTER_COMPOSITE_SHADER_FRAG );
SetRendererTexture( mRendererForEmboss2, mFrameBufferForEmboss2 );
mRendererForEmboss2.RegisterProperty( COLOR_UNIFORM_NAME, Color::WHITE );
mActorForComposite.AddRenderer( mRendererForEmboss2 );
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/control/control-renderers.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
namespace
{
-const char* const SPREAD_FRAGMENT_SOURCE =
-{
- "precision highp float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform int uSpread;\n"
- "uniform vec2 uTexScale;\n"
- "void main()\n"
- "{\n"
- " vec4 color = texture2D( sTexture, vTexCoord);\n"
- " for( int i = 1; i <= uSpread; ++i )\n"
- " {\n"
- " vec2 offset = uTexScale * float(i);\n"
- " color = max( texture2D( sTexture, vTexCoord + offset), color );\n"
- " color = max( texture2D( sTexture, vTexCoord - offset), color );\n"
- " }\n"
- " gl_FragColor = color;\n"
- "}\n"
-};
-
const char* const SPREAD_UNIFORM_NAME( "uSpread" );
const char* const TEX_SCALE_UNIFORM_NAME( "uTexScale" );
mActorForInput.RegisterProperty( SPREAD_UNIFORM_NAME, mSpread );
mActorForInput.RegisterProperty( TEX_SCALE_UNIFORM_NAME, Vector2( 1.0f / mTargetSize.width, 0.0f ) );
- Renderer rendererForInput = CreateRenderer( BASIC_VERTEX_SOURCE, SPREAD_FRAGMENT_SOURCE );
+ Renderer rendererForInput = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SPREAD_FILTER_SHADER_FRAG );
SetRendererTexture( rendererForInput, mInputTexture );
mActorForInput.AddRenderer( rendererForInput );
// register properties as shader uniforms
mActorForHorz.RegisterProperty( SPREAD_UNIFORM_NAME, mSpread );
mActorForHorz.RegisterProperty( TEX_SCALE_UNIFORM_NAME, Vector2( 0.0f, 1.0f / mTargetSize.height ) );
- Renderer rendererForHorz = CreateRenderer( BASIC_VERTEX_SOURCE, SPREAD_FRAGMENT_SOURCE );
+ Renderer rendererForHorz = CreateRenderer( BASIC_VERTEX_SOURCE, SHADER_SPREAD_FILTER_SHADER_FRAG );
SetRendererTexture( rendererForHorz, textureForHorz );
mActorForHorz.AddRenderer( rendererForHorz );
--- /dev/null
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ mediump vec4 color = texture2D( sTexture, vTexCoord );
+ if(color.a <= 0.0001)
+ {
+ discard;
+ }
+ gl_FragColor = color * uColor;
+}
--- /dev/null
+precision mediump float;
+
+uniform mediump vec4 start_color;
+uniform mediump vec4 end_color;
+uniform mediump float gradient_offset;
+
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vStart;
+varying mediump vec2 vEnd;
+
+float get_position(vec2 x, vec2 s, vec2 e)
+{
+ vec2 df = e - s;
+ vec2 dx = x - s;
+
+#ifdef GRADIENT_TYPE_LINEAR
+ return dot(dx,df)/dot(df,df);
+#endif
+/* GradientType::LINEAR */
+
+#ifdef GRADIENT_TYPE_RADIAL
+ return sqrt(dot(dx,dx)/dot(df,df));
+#endif
+/* GradientType::RADIAL */
+}
+
+float recalculate(float r)
+{
+#ifdef SPREAD_TYPE_REFLECT
+ return 1.0 - abs(mod(r, 2.0) - 1.0);
+#endif
+/* SpreadType::REFLECT */
+
+#ifdef SPREAD_TYPE_REPEAT
+ return fract(r);
+#endif
+/* SpreadType::REPEAT*/
+
+#ifdef SPREAD_TYPE_CLAMP
+ return clamp(r, 0.0, 1.0);
+#endif
+/* SpreadType::CLAMP */
+}
+
+void main()
+{
+ float r = get_position( vTexCoord, vStart, vEnd );
+ r = recalculate( r + gradient_offset );
+ vec4 color = mix( start_color, end_color, r );
+ gl_FragColor = color;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+uniform mediump vec2 start_point;
+uniform mediump vec2 end_point;
+uniform mediump vec2 rotate_center;
+uniform mediump float rotate_angle;
+
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vStart;
+varying mediump vec2 vEnd;
+
+vec2 rotate(vec2 x, vec2 c, float a)
+{
+ vec2 d = x - c;
+ vec2 r = vec2(d.x * cos(a) - d.y * sin(a), d.x * sin(a) + d.y * cos(a));
+
+#ifdef UNIT_TYPE_BOUNDING_BOX
+ return r + c;
+#endif
+
+ /* UnitType::OBJECT_BOUNDING_BOX */
+#ifdef UNIT_TYPE_USER
+ return (r + c) / uSize.x;
+#endif
+ /* UnitType::USER_SPACE*/
+}
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix( uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ vStart = rotate( start_point, rotate_center, rotate_angle );
+ vEnd = rotate( end_point, rotate_center, rotate_angle );
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+#ifdef UNIT_TYPE_BOUNDING_BOX
+ vTexCoord = vec2(aPosition.x, -aPosition.y);
+#endif
+/* UnitType::OBJECT_BOUNDING_BOX */
+
+#ifdef UNIT_TYPE_USER
+ vTexCoord = vec2(aPosition.x, -aPosition.y * uSize.y / uSize.x);
+#endif
+/* UnitType::USER_SPACE*/
+}
--- /dev/null
+INPUT mediump vec2 vPosition;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform mediump float thickness;
+uniform mediump float radius;
+uniform mediump float startAngle;
+uniform mediump float sweepAngle;
+
+const mediump float M_PI_OVER_2 = 1.57079632679;
+const mediump float M_PI = 3.14159265359;
+const mediump float M_PI_2 = 6.28318530718;
+
+mediump float GetOpacity()
+{
+ mediump float start = radians( mod( startAngle, 360.0 ) );
+ mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );
+ mediump float dist = length( vPosition );
+ if( angle <= radians( sweepAngle ) )
+ {
+ return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );
+ }
+ mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );
+ mediump vec2 q0 = vec2( dist * cos( start - M_PI_OVER_2 ), dist * sin( start - M_PI_OVER_2 ) );
+ mediump vec2 q1 = vec2( dist * cos( end - M_PI_OVER_2 ), dist * sin( end - M_PI_OVER_2 ) );
+ mediump float opacity = 1.0 - smoothstep( 0.0, 2.0, min( length( vPosition - q0 ), length( vPosition - q1 ) ) );
+ opacity *= step( 0.0, thickness / 2.0 - abs( dist - radius ) );
+ return opacity;
+}
+
+void main()
+{
+ OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;
+ OUT_COLOR.a *= GetOpacity();
+}
--- /dev/null
+INPUT mediump vec2 vPosition;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform mediump float thickness;
+uniform mediump float radius;
+uniform mediump float startAngle;
+uniform mediump float sweepAngle;
+
+const mediump float M_PI_OVER_2 = 1.57079632679;
+const mediump float M_PI_2 = 6.28318530718;
+
+mediump float GetOpacity()
+{
+ mediump float start = radians( mod( startAngle, 360.0 ) );
+ mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );
+ mediump float dist = length( vPosition );
+ if( angle <= radians( sweepAngle ) )
+ {
+ return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );
+ }
+ mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );
+ mediump vec2 q0 = vec2( radius * cos( start - M_PI_OVER_2 ), radius * sin( start - M_PI_OVER_2 ) );
+ mediump vec2 q1 = vec2( radius * cos( end - M_PI_OVER_2 ), radius * sin( end - M_PI_OVER_2 ) );
+ return smoothstep( -1.0, 1.0, thickness / 2.0 - min( length( vPosition - q0 ), length( vPosition - q1 ) ) );
+}
+
+void main()
+{
+ OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;
+ OUT_COLOR.a *= GetOpacity();
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vPosition;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vPosition = aPosition* visualSize;
+ return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sEffect;
+uniform lowp vec4 uColor;
+uniform float uBloomIntensity;
+uniform float uImageIntensity;
+uniform float uBloomSaturation;
+uniform float uImageSaturation;
+
+vec4 ChangeSaturation(vec4 col, float sat)
+{
+ float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));
+ return mix(vec4(grey, grey, grey, 1.0), col, sat);
+}
+
+void main()
+{
+ mediump vec4 image;
+ mediump vec4 bloom;
+ image = texture2D(sTexture, vTexCoord);
+ bloom = texture2D(sEffect, vTexCoord);
+ image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;
+ bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;
+ image *= 1.0 - clamp(bloom, 0.0, 1.0); // darken base where bloom is strong, to prevent excessive burn-out of result
+ gl_FragColor = image + bloom;
+}
\ No newline at end of file
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform mediump float uBloomThreshold;
+uniform mediump float uRecipOneMinusBloomThreshold;
+
+void main()
+{
+ mediump vec4 col;
+ col = texture2D(sTexture, vTexCoord);
+ col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold; // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
+ gl_FragColor = clamp(col, 0.0, 1.0);
+}
\ No newline at end of file
--- /dev/null
+precision highp float;
+uniform float uBlurStrength;
+uniform sampler2D sTexture;
+uniform sampler2D sEffect;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uBlurStrength
+ + texture2D( sEffect, vTexCoord )*(1.0-uBlurStrength);
+}
\ No newline at end of file
--- /dev/null
+precision highp float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform vec2 uSampleOffsets[NUM_SAMPLES];
+uniform float uSampleWeights[NUM_SAMPLES];
+
+void main()
+{
+ vec4 color = vec4(0.0);
+ for( int i = 0; i < NUM_SAMPLES; ++i )
+ {
+ color += texture2D( sTexture, vTexCoord + uSampleOffsets[i] ) * uSampleWeights[i];
+ }
+ gl_FragColor = color;
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump float vAlpha;
+
+uniform lowp vec4 uColor;
+uniform lowp vec4 borderColor;
+uniform lowp vec3 mixColor;
+uniform mediump float borderSize;
+
+void main()
+{
+ OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;
+ OUT_COLOR.a *= smoothstep(0.0, 1.5, vAlpha) * smoothstep( borderSize + 1.5, borderSize, vAlpha );
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 aPosition;
+INPUT mediump vec2 aDrift;
+OUTPUT mediump float vAlpha;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump float borderSize;
+
+void main()
+{
+ vec2 position = aPosition*(uSize.xy+vec2(0.75)) + aDrift*(borderSize+1.5);
+ gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);
+ vAlpha = min( abs(aDrift.x), abs(aDrift.y) )*(borderSize+1.5);
+}
\ No newline at end of file
--- /dev/null
+uniform lowp vec4 uColor;
+uniform lowp vec4 borderColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 aPosition;
+INPUT mediump vec2 aDrift;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump float borderSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec2 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy;
+}
+
+void main()
+{
+ vec2 position = ComputeVertexPosition() + aDrift*borderSize;
+ gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);
+}
\ No newline at end of file
--- /dev/null
+// Use the actor color to paint every layer
+uniform lowp vec4 uColor;
+
+void main()
+{
+ gl_FragColor = uColor;
+}
--- /dev/null
+// Modify the vertex position according to the bounce coefficient
+attribute mediump vec3 aPosition1;
+attribute mediump vec3 aPosition2;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+uniform mediump float uBounceCoefficient;
+
+void main()
+{
+ gl_Position = uMvpMatrix * vec4(mix( aPosition1, aPosition2, abs(uBounceCoefficient) )*uSize, 1.0);
+}
--- /dev/null
+precision highp float;
+uniform vec3 uHSVDelta;
+uniform float uIgnoreAlpha;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+
+float rand(vec2 co)
+{
+ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
+}
+
+vec3 rgb2hsv(vec3 c)
+{
+ vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+ vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
+ vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
+
+ float d = q.x - min(q.w, q.y);
+ float e = 1.0e-10;
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+
+vec3 hsv2rgb(vec3 c)
+{
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+
+void main()
+{
+ vec4 color = texture2D(sTexture, vTexCoord);
+ vec3 hsvColor = rgb2hsv( color.rgb );
+ // modify the hsv Value
+ hsvColor += uHSVDelta * rand(vTexCoord);
+ // if the new vale exceeds one, then decrease it
+ hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);
+ // if the new vale drops below zero, then increase it
+ hsvColor -= min(hsvColor*2.0, 0.0);
+ color.rgb = hsv2rgb( hsvColor );
+ // uIgnoreAlpha decide the result alpha will be 1.0 or source's alpha
+ color.a += uIgnoreAlpha;
+ gl_FragColor = color;
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform lowp vec4 uColor;
+uniform sampler2D sBackground;
+uniform sampler2D sBubbleShape;
+varying mediump float vPercentage;
+varying mediump vec2 vEffectTexCoord;
+
+void main()
+{
+ // Get the emit pisition color, and Mix with the actor color
+ mediump vec4 fragColor = texture2D(sBackground, vEffectTexCoord)*uColor;
+
+ // Apply the shape defined by the texture contained sBubbleShape
+ // And make the opacity being 0.7, and animate from 0.7 to 0 during the last 1/3 of movement
+ fragColor.a*= texture2D(sBubbleShape, vTexCoord).a * ( 2.1 - max( vPercentage*2.1, 1.4 ) );
+
+ gl_FragColor = fragColor;
+}
\ No newline at end of file
--- /dev/null
+attribute mediump float aIndex;
+attribute mediump vec2 aPosition;
+attribute highp vec2 aTexCoord;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+// the gravity applied to the y direction
+uniform mediump float uGravity;
+// xy: the emit position of the bubble; zw: the destination of the bubble.
+// The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
+uniform vec4 uStartEndPosition[NUMBER_OF_BUBBLE];
+// The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
+uniform float uPercentage[NUMBER_OF_BUBBLE];
+uniform vec2 uInvertedMovementArea;
+// The bubble number is restricted by the available uniform num.
+// To increase the displayed bubble, every uStartEndPosition and uPercentage uniform is applied to a small bunch of bubbles (9 here)
+// The offset defines the random offset between bubbles within the bunch.
+uniform vec2 uOffset[9];
+// This uniform is used to change the bubble size during running time
+uniform float uDynamicScale;
+varying float vPercentage;
+varying vec2 vEffectTexCoord;
+
+void main()
+{
+ vec4 position = vec4( aPosition, 0.0, 1.0 );
+ // The Z coordinate is used to record the bubble index within current mesh actor
+ int index = int(aIndex);
+ //for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
+ int groupIdx = index / NUMBER_OF_BUBBLE;
+ // The bubbles within the same bunch applies the same uniforms uStartEndPosition[idx] & uPercentage[idx]
+ int idx = index - groupIdx*NUMBER_OF_BUBBLE;
+ float percentage = uPercentage[idx];
+ // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
+ if( percentage <= 0.0 || percentage >= 1.0 )
+ {
+ gl_Position = vec4(0.0);
+ return;
+ }
+ vec4 startAndEnd = uStartEndPosition[idx];
+ // The final position is added up different offset for bubbles
+ startAndEnd.zw += uOffset[groupIdx];
+
+ // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
+ // the new xy value containes both the new scale and new bubble position
+ position.xy *= uDynamicScale*min(percentage*5.0, 1.0);
+ position.xy += mix(startAndEnd.xy, startAndEnd.zw, percentage);
+ // The gravity is g*t*t on the y direction
+ position.y += uGravity * pow(percentage, 2.0);
+ gl_Position = uMvpMatrix * position;
+
+ // Add multiple bubble shapes in the effect
+ vTexCoord = aTexCoord;
+ vPercentage = percentage;
+ // Use the emit position color for the bubble
+ vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea + vec2(0.5);
+}
\ No newline at end of file
--- /dev/null
+precision highp float;
+uniform vec3 uHSVDelta;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+
+float rand(vec2 co)
+{
+ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
+}
+
+vec3 rgb2hsv(vec3 c)
+{
+ vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+ vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
+ vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
+
+ float d = q.x - min(q.w, q.y);
+ float e = 1.0e-10;
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+
+vec3 hsv2rgb(vec3 c)
+{
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+
+void main()
+{
+ vec4 color = texture2D(sTexture, vTexCoord);
+ vec3 hsvColor = rgb2hsv( color.rgb );
+ // modify the hsv Value
+ hsvColor += uHSVDelta * rand(vTexCoord);
+ // if the new vale exceeds one, then decrease it
+ hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);
+ // if the new vale drops below zero, then increase it
+ hsvColor -= min(hsvColor*2.0, 0.0);
+ color = vec4( hsv2rgb( hsvColor ), 1.0 );
+ gl_FragColor = color;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+attribute mediump vec2 aTexCoord;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+ gl_Position = uMvpMatrix * vec4(aPosition*uSize.xy,0.0,1.0);
+ vTexCoord = aTexCoord;
+}
--- /dev/null
+INPUT mediump vec2 vPosition;
+INPUT mediump vec2 vRectSize;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform mediump float blurRadius;
+
+void main()
+{
+ mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );
+ OUT_COLOR = vec4(mixColor, 1.0) * uColor;
+ OUT_COLOR.a *= blur.x * blur.y;
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vPosition;
+OUTPUT mediump vec2 vRectSize;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec2 extraSize;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float blurRadius;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize + blurRadius * 2.0;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vRectSize = visualSize / 2.0;
+ vPosition = aPosition* visualSize;
+ return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 vPosition;
+INPUT mediump vec2 vRectSize;
+INPUT mediump float vCornerRadius;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ OUT_COLOR = vec4(mixColor, 1.0) * uColor;
+ mediump vec2 diff = abs( vPosition ) - vRectSize;
+ mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+ if( dist > 1.0 )
+ {
+ OUT_COLOR.a = 0.0;
+ }
+ else if( dist > -1.0 )
+ {
+ if( min( diff.x, diff.y ) < 0.0)
+ {
+ dist += min( diff.x, diff.y ) / vCornerRadius;
+ }
+ OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist );
+ }
+}
--- /dev/null
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vPosition;
+OUTPUT mediump vec2 vRectSize;
+OUTPUT mediump float vCornerRadius;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec2 extraSize;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min( visualSize.x, visualSize.y );
+ vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+ vRectSize = visualSize / 2.0 - vCornerRadius;
+ vCornerRadius = max( vCornerRadius, 1.0 );
+ vPosition = aPosition* visualSize;
+ return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
--- /dev/null
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ OUT_COLOR = vec4(mixColor, 1.0) * uColor;
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 aPosition;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform vec4 uColor;
+
+void main()
+{
+ gl_FragColor = texture2D(sTexture, vTexCoord);
+ gl_FragColor *= uColor;
+}
--- /dev/null
+precision mediump float;
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition * uSize.xy, 0.0, 1.0);
+ vTexCoord = aPosition + vec2(0.5);
+ gl_Position = uMvpMatrix * vertexPosition;
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec4 uSamplerRect;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+uniform mediump vec4 uTextureRect;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ vTexCoord = aPosition + vec2(0.5);
+ vTexCoord = mix(uTextureRect.xy, uTextureRect.zw, vTexCoord);
+
+ gl_Position = vertexPosition;
+}
\ No newline at end of file
--- /dev/null
+varying float vPercentage;
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform vec4 uTextureRect;
+
+float rand(vec2 co)
+{
+ return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
+}
+
+void main()
+{
+ //Calculate the randomness
+ float offsetS = rand(vTexCoord * vPercentage) - vTexCoord.s;
+ float offsetT = rand(vec2(vTexCoord.t * vPercentage, vTexCoord.s * vPercentage)) - vTexCoord.t;
+ vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage;
+ gl_FragColor = texture2D(sTexture, lookupCoord) * uColor;
+ gl_FragColor.a *= 1.0 - vPercentage;
+}
\ No newline at end of file
--- /dev/null
+attribute mediump vec2 aPosition;
+
+uniform mediump mat4 uMvpMatrix;
+uniform vec3 uSize;
+uniform vec4 uTextureRect;
+
+uniform float uPercentage;
+uniform vec3 uSaddleParam;
+uniform vec2 uTranslation;
+uniform vec2 uRotation;
+uniform float uToNext;
+
+varying float vPercentage;
+varying vec2 vTexCoord;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ vertexPosition = uMvpMatrix * vertexPosition;
+ gl_Position = vertexPosition;
+
+ vec2 texCoord = aPosition + vec2(0.5);
+ vTexCoord = texCoord;
+
+ //Calculate the distortion value given the dissolve central line
+ vec2 value = texCoord + uTranslation;
+ mat2 rotateMatrix = mat2(uRotation.s, uRotation.t, -uRotation.t, uRotation.s);
+ value = rotateMatrix * value;
+ if(uToNext == 1.0)
+ value.s = uSaddleParam[2] + value.s;
+ float delay = value.t * value.t / uSaddleParam[0] - value.s * value.s / uSaddleParam[1];
+ vPercentage = clamp(uPercentage * 2.0 - 0.5 * sin(delay * 1.571) - 0.5, 0.0, 1.0);
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+
+uniform mediump float uGlowBoundary;
+uniform mediump vec2 uOutlineParams;
+uniform lowp vec4 uOutlineColor;
+uniform lowp vec4 uShadowColor;
+uniform mediump vec2 uShadowOffset;
+uniform lowp vec4 uGlowColor;
+uniform lowp float uDoOutline;
+uniform lowp float uDoShadow;
+uniform lowp float uDoGlow;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ // sample distance field
+ mediump float smoothing = 0.5;
+
+ mediump float distance = texture2D(sTexture, vTexCoord).a;
+ mediump float smoothWidth = fwidth(distance);
+ mediump float alphaFactor = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);
+ lowp vec4 color;
+
+ if (uDoShadow == 0.0)
+ {
+ mediump float alpha = uColor.a * alphaFactor;
+ lowp vec4 rgb = uColor;
+
+ if (uDoOutline > 0.0)
+ {
+ mediump float outlineWidth = uOutlineParams[1] + smoothWidth;
+ mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);
+ alpha = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, distance);
+ rgb = mix(uOutlineColor, uColor, outlineBlend);
+ }
+
+ if (uDoGlow > 0.0)
+ {
+ rgb = mix(uGlowColor, rgb, alphaFactor);
+ alpha = smoothstep(uGlowBoundary, smoothing, distance);
+ }
+
+ // set fragment color
+ color = vec4(rgb.rgb, alpha);
+ }
+
+ else // (uDoShadow > 0.0)
+ {
+ mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;
+ mediump float inText = alphaFactor;
+ mediump float inShadow = smoothstep(smoothing - smoothWidth, smoothing + smoothWidth, shadowDistance);
+
+ // inside object, outside shadow
+ if (inText == 1.0)
+ {
+ color = uColor;
+ }
+ // inside object, outside shadow
+ else if ((inText != 0.0) && (inShadow == 0.0))
+ {
+ color = uColor;
+ color.a *= inText;
+ }
+ // outside object, completely inside shadow
+ else if ((inText == 0.0) && (inShadow == 1.0))
+ {
+ color = uShadowColor;
+ }
+ // inside object, completely inside shadow
+ else if ((inText != 0.0) && (inShadow == 1.0))
+ {
+ color = mix(uShadowColor, uColor, inText);
+ color.a = uShadowColor.a;
+ }
+ // inside object, inside shadow's border
+ else if ((inText != 0.0) && (inShadow != 0.0))
+ {
+ color = mix(uShadowColor, uColor, inText);
+ color.a *= max(inText, inShadow);
+ }
+ // inside shadow's border
+ else if (inShadow != 0.0)
+ {
+ color = uShadowColor;
+ color.a *= inShadow;
+ }
+ // outside shadow and object
+ else
+ {
+ color.a = 0.0;
+ }
+ }
+
+ gl_FragColor = color;
+}
\ No newline at end of file
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 effectColor;
+
+void main()
+{
+ gl_FragColor = effectColor;
+ gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump vec3 uSize;
+uniform mediump vec3 effectOffset;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ vertexPosition.xyz += effectOffset;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ vTexCoord = aPosition + vec2(0.5);
+ gl_Position = vertexPosition;
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uEffectColor;
+
+void main()
+{
+ gl_FragColor = uEffectColor;
+ gl_FragColor.a *= texture2D( sTexture, vTexCoord).a;
+}
\ No newline at end of file
--- /dev/null
+precision highp float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform vec2 uTexScale;
+uniform vec3 uCoefficient;
+
+void main()
+{
+ vec4 color = uCoefficient.x * texture2D( sTexture, vTexCoord + vec2(0.0, -uTexScale.y) );
+ color += uCoefficient.y * texture2D( sTexture, vTexCoord );
+ color += uCoefficient.z * texture2D( sTexture, vTexCoord + vec2(0.0, uTexScale.y) );
+ gl_FragColor = color;
+}
\ No newline at end of file
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform mediump vec2 uSampleOffsets[NUM_SAMPLES];
+uniform mediump float uSampleWeights[NUM_SAMPLES];
+
+void main()
+{
+ mediump vec4 col = texture2D(sTexture, vTexCoord + uSampleOffsets[0]) * uSampleWeights[0];
+ for (int i=1; i<NUM_SAMPLES; ++i)
+ {
+ col += texture2D(sTexture, vTexCoord + uSampleOffsets[i]) * uSampleWeights[i];
+ }
+ gl_FragColor = col;
+}
--- /dev/null
+#define TEXTURE_BASECOLOR
+
+uniform sampler2D uBaseColorSampler;
+uniform int uBaseColorTexCoordIndex;
--- /dev/null
+#define TEXTURE_EMIT
+
+uniform sampler2D uEmissiveSampler;
+uniform int uEmissiveTexCoordIndex;
+uniform vec3 uEmissiveFactor;
--- /dev/null
+#version 300 es
+precision highp float;
--- /dev/null
+#define TEXTURE_IBL
+
+uniform sampler2D ubrdfLUT;
+uniform samplerCube uDiffuseEnvSampler;
+uniform samplerCube uSpecularEnvSampler;
+uniform vec4 uScaleIBLAmbient;
+uniform highp float uMipmapLevel;
--- /dev/null
+#define TEXTURE_METALLICROUGHNESS
+
+uniform sampler2D uMetallicRoughnessSampler;
+uniform int uMetallicRoughnessTexCoordIndex;
--- /dev/null
+#define TEXTURE_NORMAL
+
+uniform sampler2D uNormalSampler;
+uniform float uNormalScale;
+uniform int uNormalTexCoordIndex;
--- /dev/null
+#define TEXTURE_OCCLUSION
+
+uniform sampler2D uOcclusionSampler;
+uniform int uOcclusionTexCoordIndex;
+uniform float uOcclusionStrength;
--- /dev/null
+uniform lowp vec3 uLightColor;
+uniform lowp vec4 uBaseColorFactor;
+uniform lowp vec2 uMetallicRoughnessFactors;
+uniform lowp int alphaMode;
+uniform lowp float alphaCutoff;
+
+in lowp vec2 vUV[2];
+in lowp mat3 vTBN;
+in lowp vec4 vColor;
+flat in int visLight;
+in highp vec3 vLightDirection;
+in highp vec3 vPositionToCamera;
+
+out vec4 FragColor;
+
+struct PBRInfo
+{
+ mediump float NdotL; // cos angle between normal and light direction
+ mediump float NdotV; // cos angle between normal and view direction
+ mediump float NdotH; // cos angle between normal and half vector
+ mediump float VdotH; // cos angle between view direction and half vector
+ mediump vec3 reflectance0; // full reflectance color (normal incidence angle)
+ mediump vec3 reflectance90; // reflectance color at grazing angle
+ lowp float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])
+};
+
+const float M_PI = 3.141592653589793;
+const float c_MinRoughness = 0.04;
+
+vec3 getNormal()
+{
+#ifdef TEXTURE_NORMAL
+ lowp vec3 n = texture( uNormalSampler, vUV[uNormalTexCoordIndex] ).rgb;
+ n = normalize( vTBN * ( ( 2.0 * n - 1.0 ) * vec3( uNormalScale, uNormalScale, 1.0 ) ) );
+#else
+ lowp vec3 n = normalize( vTBN[2].xyz );
+#endif
+ return n;
+}
+
+vec3 specularReflection( PBRInfo pbrInputs )
+{
+ return pbrInputs.reflectance0 + ( pbrInputs.reflectance90 - pbrInputs.reflectance0 ) * pow( clamp( 1.0 - pbrInputs.VdotH, 0.0, 1.0 ), 5.0 );
+}
+
+float geometricOcclusion( PBRInfo pbrInputs )
+{
+ mediump float NdotL = pbrInputs.NdotL;
+ mediump float NdotV = pbrInputs.NdotV;
+ lowp float r = pbrInputs.alphaRoughness;
+
+ lowp float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
+ lowp float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
+ return attenuationL * attenuationV;
+}
+
+float microfacetDistribution(PBRInfo pbrInputs)
+{
+ mediump float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
+ lowp float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;
+ return roughnessSq / (M_PI * f * f);
+}
+
+vec3 linear( vec3 color )
+{
+ return pow(color,vec3(2.2));
+}
+
+void main()
+{
+ // Metallic and Roughness material properties are packed together
+ // In glTF, these factors can be specified by fixed scalar values
+ // or from a metallic-roughness map
+ lowp float metallic = uMetallicRoughnessFactors.x;
+ lowp float perceptualRoughness = uMetallicRoughnessFactors.y;
+
+ // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
+ // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
+#ifdef TEXTURE_METALLICROUGHNESS
+ lowp vec4 metrou = texture(uMetallicRoughnessSampler, vUV[uMetallicRoughnessTexCoordIndex]);
+ metallic = metrou.b * metallic;
+ perceptualRoughness = metrou.g * perceptualRoughness;
+#endif
+
+ metallic = clamp(metallic, 0.0, 1.0);
+ perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
+ // Roughness is authored as perceptual roughness; as is convention,
+ // convert to material roughness by squaring the perceptual roughness [2].
+ lowp float alphaRoughness = perceptualRoughness * perceptualRoughness;
+
+#ifdef TEXTURE_BASECOLOR
+ // The albedo may be defined from a base texture or a flat color
+ lowp vec4 baseColor = texture(uBaseColorSampler, vUV[uBaseColorTexCoordIndex]) * uBaseColorFactor;
+ baseColor = vec4(linear(baseColor.rgb), baseColor.w);
+#else
+ lowp vec4 baseColor = vColor * uBaseColorFactor;
+#endif
+
+ if( alphaMode == 0 )
+ {
+ baseColor.w = 1.0;
+ }
+ else if( alphaMode == 1 )
+ {
+ if( baseColor.w >= alphaCutoff )
+ {
+ baseColor.w = 1.0;
+ }
+ else
+ {
+ baseColor.w = 0.0;
+ }
+ }
+
+ lowp vec3 f0 = vec3(0.04);
+ lowp vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
+ diffuseColor *= ( 1.0 - metallic );
+ lowp vec3 specularColor = mix(f0, baseColor.rgb, metallic);
+
+ // Compute reflectance.
+ lowp float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
+
+ // For typical incident reflectance range (between 4% to 100%) set the grazing reflectance to 100% for typical fresnel effect.
+ // For very low reflectance range on highly diffuse objects (below 4%), incrementally reduce grazing reflecance to 0%.
+ lowp float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
+ lowp vec3 specularEnvironmentR0 = specularColor.rgb;
+ lowp vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
+
+ mediump vec3 n = getNormal(); // normal at surface point
+ mediump vec3 v = normalize(vPositionToCamera); // Vector from surface point to camera
+ mediump vec3 l = normalize(vLightDirection); // Vector from light to surface point
+ mediump vec3 h = normalize(l+v); // Half vector between both l and v
+ mediump vec3 reflection = -normalize(reflect(v, n));
+
+ mediump float NdotL = clamp(dot(n, l), 0.001, 1.0);
+ mediump float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
+ mediump float NdotH = dot(n, h);
+ mediump float LdotH = dot(l, h);
+ mediump float VdotH = dot(v, h);
+
+ PBRInfo pbrInputs = PBRInfo(
+ NdotL,
+ NdotV,
+ NdotH,
+ VdotH,
+ specularEnvironmentR0,
+ specularEnvironmentR90,
+ alphaRoughness
+ );
+
+ // Calculate the shading terms for the microfacet specular shading model
+ lowp vec3 color = vec3(0.0);
+ if( visLight == 1 )
+ {
+ lowp vec3 F = specularReflection( pbrInputs );
+ lowp float G = geometricOcclusion( pbrInputs );
+ lowp float D = microfacetDistribution( pbrInputs );
+
+ // Calculation of analytical lighting contribution
+ lowp vec3 diffuseContrib = ( 1.0 - F ) * ( diffuseColor / M_PI );
+ lowp vec3 specContrib = F * G * D / ( 4.0 * NdotL * NdotV );
+ // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
+ color = NdotL * uLightColor * (diffuseContrib + specContrib);
+ }
+
+#ifdef TEXTURE_IBL
+ lowp float lod = ( perceptualRoughness * uMipmapLevel );
+ // retrieve a scale and bias to F0. See [1], Figure 3
+ lowp vec3 brdf = linear( texture( ubrdfLUT, vec2( NdotV, 1.0 - perceptualRoughness ) ).rgb );
+ lowp vec3 diffuseLight = linear( texture( uDiffuseEnvSampler, n ).rgb );
+ lowp vec3 specularLight = linear( textureLod( uSpecularEnvSampler, reflection, lod ).rgb );
+
+ lowp vec3 diffuse = diffuseLight * diffuseColor * uScaleIBLAmbient.x;
+ lowp vec3 specular = specularLight * ( specularColor * brdf.x + brdf.y ) * uScaleIBLAmbient.y;
+ color += ( diffuse + specular );
+#endif
+
+#ifdef TEXTURE_OCCLUSION
+ lowp float ao = texture( uOcclusionSampler, vUV[uOcclusionTexCoordIndex] ).r;
+ color = mix( color, color * ao, uOcclusionStrength );
+#endif
+
+#ifdef TEXTURE_EMIT
+ lowp vec3 emissive = linear( texture( uEmissiveSampler, vUV[uEmissiveTexCoordIndex] ).rgb ) * uEmissiveFactor;
+ color += emissive;
+#endif
+
+ FragColor = vec4( pow( color,vec3( 1.0 / 2.2 ) ), baseColor.a );
+}
--- /dev/null
+in highp vec3 aPosition;
+in mediump vec2 aTexCoord0;
+in mediump vec2 aTexCoord1;
+in lowp vec3 aNormal;
+in lowp vec4 aTangent;
+in lowp vec4 aVertexColor;
+
+uniform mediump vec3 uSize;
+uniform mediump mat4 uModelMatrix;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat4 uProjection;
+uniform lowp int uLightType;
+uniform mediump vec3 uLightVector;
+uniform lowp int uIsColor;
+
+out lowp vec2 vUV[2];
+out lowp mat3 vTBN;
+out lowp vec4 vColor;
+flat out int visLight;
+out highp vec3 vLightDirection;
+out highp vec3 vPositionToCamera;
+
+void main()
+{
+ highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);
+ highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 );
+ highp vec4 positionV = uViewMatrix * ( invY * positionW );
+
+ vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) );
+ vPositionToCamera *= invY.xyz;
+
+ lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;
+ vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal);
+
+ vUV[0] = aTexCoord0;
+ vUV[1] = aTexCoord1;
+
+ visLight = 1;
+ if( uLightType == 1 )
+ {
+ vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w );
+ }
+ else if( uLightType == 2 )
+ {
+ vLightDirection = -( invY.xyz * uLightVector );
+ }
+ else
+ {
+ visLight = 0;
+ }
+
+ vColor = vec4( 1.0 );
+ if( uIsColor == 1 )
+ {
+ vColor = aVertexColor;
+ }
+
+ gl_Position = uProjection * positionV; // needs w for proper perspective correction
+ gl_Position = gl_Position/gl_Position.w;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min( visualSize.x, visualSize.y );
+ vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+ vRectSize = visualSize * 0.5 - vCornerRadius;
+ vCornerRadius = max( vCornerRadius, 1.0 );
+ vPosition = aPosition * visualSize;
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
\ No newline at end of file
--- /dev/null
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+ mediump vec2 diff = abs( vPosition ) - vRectSize;
+ mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+ if( dist > 1.0 )
+ {
+ gl_FragColor = vec4( 0.0 );
+ }
+ else if( dist > -1.0 )
+ {
+ if( min( diff.x, diff.y ) < 0.0 )
+ {
+ dist += min( diff.x, diff.y ) / vCornerRadius;
+ }
+ gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );
+ }
+}
--- /dev/null
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+}
--- /dev/null
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+ mediump vec2 diff = abs( vPosition ) - vRectSize;
+ mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+ if( dist > 1.0 )
+ {
+ gl_FragColor = vec4( 0.0 );
+ }
+ else if( dist > -1.0 )
+ {
+ if( min( diff.x, diff.y ) < 0.0)
+ {
+ dist += min( diff.x, diff.y ) / vCornerRadius;
+ }
+ gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );
+ }
+}
--- /dev/null
+uniform sampler2D sTexture; // sampler1D?
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vPosition;
+varying mediump vec2 vRectSize;
+varying mediump float vCornerRadius;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min( visualSize.x, visualSize.y );
+ vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+ vRectSize = visualSize * 0.5 - vCornerRadius;
+ vCornerRadius = max( vCornerRadius, 1.0 );
+ vPosition = aPosition * visualSize;
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+ vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump mat3 uAlignmentMatrix;
+varying mediump vec2 vTexCoord;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+ vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+
+uniform mediump mat4 uMvpMatrix;
+uniform vec3 uSize;
+uniform vec4 uTextureRect;
+
+varying vec2 vTexCoord;
+
+uniform mediump vec2 uTopLeft;
+uniform mediump vec2 uBottomRight;
+
+void main()
+{
+ mediump vec4 position = vec4(aPosition, 0.0, 1.0);
+ position.xyz *= uSize;
+ gl_Position = uMvpMatrix * position;
+
+ // The line below is doing the same as the following commented lines:
+ //
+ // vec2 imageSize = uTextureRect.zw - uTextureRect.xy;
+ // vec2 topLeft = uTextureRect.xy + uTopLeft * imageSize;
+ // vec2 bottomRight = uTextureRect.xy + uBottomRight * imageSize;
+ // vec2 texCoord = (aTexCoord - uTextureRect.xy) / imageSize;
+ // vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );
+
+ vec2 texCoord = aPosition + vec2(0.5);
+ vTexCoord = uTextureRect.xy + uTopLeft * ( uTextureRect.zw - uTextureRect.xy ) + ( texCoord - uTextureRect.xy ) * ( uBottomRight - uTopLeft );
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform mediump vec4 uAtlasRect;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );
+ OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform mediump vec4 uAtlasRect;
+
+// WrapMode -- 0: CLAMP; 1: REPEAT; 2: REFLECT;
+uniform lowp vec2 wrapMode;
+
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )
+
+{
+ mediump float coord;
+ if( wrap > 1.5 )\n // REFLECT
+ coord = 1.0-abs(fract(coordinate*0.5)*2.0 - 1.0);
+ else \n// warp == 0 or 1
+ coord = mix(coordinate, fract( coordinate ), wrap);
+ return clamp( mix(range.x, range.y, coord), range.x, range.y );
+}
+
+void main()
+{
+ mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),
+ wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );
+ OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );
+}
\ No newline at end of file
--- /dev/null
+INPUT mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+INPUT mediump vec2 vTexCoord;
+INPUT mediump vec2 vPosition;
+INPUT mediump vec2 vRectSize;
+INPUT mediump float vCornerRadius;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ mediump vec2 diff = abs( vPosition ) - vRectSize;
+ mediump float dist = length( max( diff, vec2( 0.0 ) ) ) - vCornerRadius;
+ mediump float opacity = 1.0;
+ if( dist > 1.0 )
+ {
+ opacity = 0.0;
+ }
+ else if( dist > -1.0 )
+ {
+ if( min( diff.x, diff.y ) < 0.0 )
+ {
+ dist += min( diff.x, diff.y ) / vCornerRadius;
+ }
+ opacity = 1.0 - smoothstep( -1.0, 1.0, dist );
+ }
+
+ OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+ OUT_COLOR.a *= opacity;
+ OUT_COLOR.rgb *= mix( 1.0, opacity, preMultipliedAlpha );
+}
--- /dev/null
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vTexCoord;
+OUTPUT mediump vec2 vPosition;
+OUTPUT mediump vec2 vRectSize;
+OUTPUT mediump float vCornerRadius;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec4 pixelArea;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump float cornerRadius;
+uniform mediump float cornerRadiusPolicy;
+uniform mediump vec2 extraSize;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ mediump float minSize = min( visualSize.x, visualSize.y );
+ vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);
+ vCornerRadius = min( vCornerRadius, minSize * 0.5 );
+ vRectSize = visualSize * 0.5 - vCornerRadius;
+ vCornerRadius = max( vCornerRadius, 1.0 );
+ vPosition = aPosition* visualSize;
+ return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+ vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+}
--- /dev/null
+INPUT mediump vec2 aPosition;
+OUTPUT mediump vec2 vTexCoord;
+
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec4 pixelArea;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+ vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+}
\ No newline at end of file
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform sampler2D sDiffuse;
+uniform sampler2D sNormal;
+uniform sampler2D sGloss;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ vec4 texture = texture2D( sDiffuse, vTexCoord );
+ vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );
+ vec4 glossMap = texture2D( sGloss, vTexCoord );
+ vec4 visualMixColor = vec4( mixColor, 1.0 );
+
+ float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );
+ lightDiffuse = lightDiffuse * 0.5 + 0.5;
+
+ float shininess = pow ( max ( dot ( normalize( vHalfVector ), normal ), 0.0 ), 16.0 );
+
+ gl_FragColor = vec4( texture.rgb * uColor.rgb * visualMixColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a * visualMixColor.a );
+}
--- /dev/null
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+attribute highp vec3 aTangent;
+attribute highp vec3 aBiNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ float scaleFactor = min( visualSize.x, visualSize.y );
+ vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+ vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+ vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+ vec4 normalisedVertexPosition = ComputeVertexPosition();
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+
+ vec3 tangent = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aTangent );
+ vec3 binormal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aBiNormal );
+ vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
+
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+ mvLightPosition = uViewMatrix * mvLightPosition;
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+ vLightDirection.x = dot( vectorToLight, tangent );
+ vLightDirection.y = dot( vectorToLight, binormal );
+ vLightDirection.z = dot( vectorToLight, normal );
+
+ vec3 viewDirection = normalize( -mvVertexPosition.xyz );
+ vec3 halfVector = normalize( viewDirection + vectorToLight );
+ vHalfVector.x = dot( halfVector, tangent );
+ vHalfVector.y = dot( halfVector, binormal );
+ vHalfVector.z = dot( halfVector, normal );
+
+ vTexCoord = aTexCoord;
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform sampler2D sDiffuse;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ vec4 texture = texture2D( sDiffuse, vTexCoord );
+ vec4 visualMixColor = vec4( mixColor, 1.0 );
+ gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb * visualMixColor.rgb + vSpecular * 0.3, texture.a * uColor.a * visualMixColor.a );
+}
--- /dev/null
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ float scaleFactor = min( visualSize.x, visualSize.y );
+ vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+ vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+ vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+ vec4 normalisedVertexPosition = ComputeVertexPosition();
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ //Illumination in Model-View space - Transform attributes and uniforms
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+ vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
+
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+ mvLightPosition = uViewMatrix * mvLightPosition;
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+
+ vec3 viewDirection = normalize( -mvVertexPosition.xyz );
+
+ float lightDiffuse = dot( vectorToLight, normal );
+ lightDiffuse = max( 0.0,lightDiffuse );
+ vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
+
+ vec3 reflectDirection = reflect( -vectorToLight, normal );
+ vSpecular = pow( max( dot( reflectDirection, viewDirection ), 0.0 ), 4.0 );
+
+ vTexCoord = aTexCoord;
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+varying mediump vec3 vIllumination;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a ) * vec4( mixColor, 1.0 );
+}
--- /dev/null
+attribute highp vec3 aPosition;
+attribute highp vec3 aNormal;
+varying mediump vec3 vIllumination;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ float scaleFactor = min( visualSize.x, visualSize.y );
+ vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+ vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+ vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+ vec4 normalisedVertexPosition = ComputeVertexPosition();
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ //Illumination in Model-View space - Transform attributes and uniforms
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+ vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;
+
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+ mvLightPosition = uViewMatrix * mvLightPosition;
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+
+ float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );
+ vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
+
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform sampler2D sDiffuse;
+uniform sampler2D sNormal;
+uniform sampler2D sGloss;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ vec4 texture = texture2D( sDiffuse, vTexCoord );
+ vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );
+ vec4 glossMap = texture2D( sGloss, vTexCoord );
+
+ float lightDiffuse = max( 0.0, dot( normal, normalize(vLightDirection) ) );
+ lightDiffuse = lightDiffuse * 0.5 + 0.5;
+
+ float shininess = pow (max (dot (normalize( vHalfVector ), normal), 0.0), 16.0);
+
+ gl_FragColor = vec4( texture.rgb * uColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a);
+}
--- /dev/null
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+attribute highp vec3 aTangent;
+attribute highp vec3 aBiNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vLightDirection;
+varying mediump vec3 vHalfVector;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 uLightPosition;
+
+void main()
+{
+ vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);
+ vertexPosition = uObjectMatrix * vertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);
+ vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);
+
+ vec3 tangent = normalize(uNormalMatrix * aTangent);
+ vec3 binormal = normalize(uNormalMatrix * aBiNormal);
+ vec3 normal = normalize(uNormalMatrix * aNormal);
+
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );
+ vLightDirection.x = dot(vecToLight, tangent);
+ vLightDirection.y = dot(vecToLight, binormal);
+ vLightDirection.z = dot(vecToLight, normal);
+
+ vec3 viewDir = normalize(-vertPos.xyz);
+ vec3 halfVector = normalize(viewDir + vecToLight);
+ vHalfVector.x = dot(halfVector, tangent);
+ vHalfVector.y = dot(halfVector, binormal);
+ vHalfVector.z = dot(halfVector, normal);
+
+ vTexCoord = aTexCoord;
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform sampler2D sDiffuse;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ vec4 texture = texture2D( sDiffuse, vTexCoord );
+ gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb + vSpecular * 0.3, texture.a * uColor.a);
+}
--- /dev/null
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec2 vTexCoord;
+varying mediump vec3 vIllumination;
+varying mediump float vSpecular;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 uLightPosition;
+
+void main()
+{
+ vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);
+ vertexPosition = uObjectMatrix * vertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ //Illumination in Model-View space - Transform attributes and uniforms
+ vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);
+ vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);
+ vec3 normal = normalize(uNormalMatrix * aNormal);
+
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );
+ vec3 viewDir = normalize(-vertPos.xyz);
+
+ vec3 halfVector = normalize(viewDir + vecToLight);
+
+ float lightDiffuse = dot( vecToLight, normal );
+ lightDiffuse = max(0.0,lightDiffuse);
+ vIllumination = vec3(lightDiffuse * 0.5 + 0.5);
+
+ vec3 reflectDir = reflect(-vecToLight, normal);
+ vSpecular = pow( max(dot(reflectDir, viewDir), 0.0), 4.0 );
+
+ vTexCoord = aTexCoord;
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+varying mediump vec3 vIllumination;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a);
+}
--- /dev/null
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec3 vIllumination;
+uniform mediump vec3 uSize;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 uLightPosition;
+
+void main()
+{
+ vec4 vertexPosition = vec4(aPosition*min(uSize.x, uSize.y), 1.0);
+ vertexPosition = uObjectMatrix * vertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ //Illumination in Model-View space - Transform attributes and uniforms
+ vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);
+ vec3 normal = uNormalMatrix * aNormal;
+ vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );
+
+ float lightDiffuse = max( dot( vecToLight, normal ), 0.0 );
+ vIllumination = vec3(lightDiffuse * 0.5 + 0.5);
+
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+
+uniform sampler2D sTexture;
+uniform vec4 uColor;
+
+uniform vec2 uObjectFadeStart;
+uniform vec2 uObjectFadeEnd;
+uniform float uAlphaScale;
+uniform float uBlurTexCoordScale;
+uniform float uNumSamples;
+uniform float uRecipNumSamples;
+uniform float uRecipNumSamplesMinusOne;
+
+// inputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+ // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
+ // the blurred object and the unblurred background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
+ vec2 centerToPixel = abs(vModelSpaceCenterToPos);
+ vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));
+ float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale; // apply global scaler
+ fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed);// fade proportional to speed, so opaque when at rest
+
+ // scale velocity vector by user requirements
+ vec2 velocity = vScreenSpaceVelocityVector * uBlurTexCoordScale;
+
+ // standard actor texel
+ vec4 colActor = texture2D(sTexture, vTexCoord);
+
+ // blurred actor - gather texture samples from the actor texture in the direction of motion
+ vec4 col = colActor * uRecipNumSamples;
+ for(float i = 1.0; i < uNumSamples; i += 1.0)
+ {
+ float t = i * uRecipNumSamplesMinusOne;
+ col += texture2D(sTexture, vTexCoord + (velocity * t)) * uRecipNumSamples;
+ }
+ gl_FragColor = mix(colActor, col, vSpeed); // lerp blurred and non-blurred actor based on speed of motion
+ gl_FragColor.a = fadeToEdgesScale;//colActor.a * fadeToEdgesScale; // fade blurred actor to its edges based on speed of motion
+ gl_FragColor *= uColor;
+}
--- /dev/null
+precision mediump float;
+
+attribute vec2 aPosition;
+
+uniform mat4 uMvpMatrix;
+uniform mat4 uModelView;
+uniform mat4 uViewMatrix;
+uniform mat4 uProjection;
+uniform vec3 uSize;
+
+uniform mat4 uModelLastFrame;
+float timeDelta = 0.0167;
+
+uniform float uGeometryStretchFactor;
+uniform float uSpeedScalingFactor;
+
+// outputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+ // get view space position of vertex this frame and last frame
+ vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+
+ vec4 viewSpaceVertex = uModelView * vertexPosition;
+ vec4 viewSpaceVertexLastFrame = (uViewMatrix * uModelLastFrame) * vertexPosition;
+ float reciprocalTimeDelta = 1.0 / timeDelta;
+
+ // work out vertex's last movement in view space
+ vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;
+
+ // get clip space position of vertex this frame and last frame
+ vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;
+ vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;
+
+ // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
+ // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
+ float t = 0.0;
+ float posDeltaLength = length(viewSpacePosDelta);
+ if(posDeltaLength > 0.001) // avoid div by 0 if object has barely moved
+ {
+ vec4 viewSpaceCenterToPos = uModelView * vec4(vertexPosition.xy, 0.0, 0.0);
+ float centerToVertexDist = length(viewSpaceCenterToPos);
+ if(centerToVertexDist > 0.001) // avoid div by 0 if object has vertex at model space origin
+ {
+ vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;
+ vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;
+ t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5; // scale and bias from [-1..1] to [0..1]
+ }
+ }
+ // output vertex position lerped with its last position, based on how much it is trailing,
+ // this stretches the geom back along where it has just been, giving a warping effect
+ // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
+ gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * uGeometryStretchFactor * reciprocalTimeDelta);
+
+ // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
+ vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;
+ vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;
+ // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
+ vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);
+ vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y; // TODO negated due to y being inverted in our coordinate system?
+ // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
+ vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;
+ vSpeed = clamp(vSpeed, 0.0, 1.0);
+
+ // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
+ vModelSpaceCenterToPos = viewSpaceVertex.xy;
+
+ vec2 texCoord = aPosition + vec2(0.5);
+ vTexCoord = texCoord;
+}
\ No newline at end of file
--- /dev/null
+precision mediump float;
+
+uniform sampler2D sTexture;
+uniform vec4 uColor;
+
+uniform vec2 uObjectFadeStart;
+uniform vec2 uObjectFadeEnd;
+uniform float uAlphaScale;
+
+// inputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+ // calculate an alpha value that will fade the object towards its extremities, we need this to avoid an unsightly hard edge between color values of
+ // the stretched object and the background. Use smoothstep also to hide any hard edges (discontinuities) in rate of change of this alpha gradient
+ vec2 centerToPixel = abs( vModelSpaceCenterToPos );
+ vec2 fadeToEdges = smoothstep(0.0, 1.0, 1.0 - ((centerToPixel - uObjectFadeStart) / (uObjectFadeEnd - uObjectFadeStart)));
+ float fadeToEdgesScale = fadeToEdges.x * fadeToEdges.y * uAlphaScale; // apply global scaler
+ fadeToEdgesScale = mix(1.0, fadeToEdgesScale, vSpeed); // fade proportional to speed, so opaque when at rest
+
+ // standard actor texel
+ vec4 colActor = texture2D(sTexture, vTexCoord);
+ gl_FragColor = colActor;
+ gl_FragColor.a *= fadeToEdgesScale; // fade actor to its edges based on speed of motion
+ gl_FragColor *= uColor;
+}
\ No newline at end of file
--- /dev/null
+precision mediump float;
+
+attribute vec2 aPosition;
+
+uniform mat4 uMvpMatrix;
+uniform mat4 uModelView;
+uniform mat4 uViewMatrix;
+uniform mat4 uProjection;
+uniform vec3 uSize;
+
+uniform mat4 uModelLastFrame;
+float timeDelta = 0.0167;
+
+uniform float uGeometryStretchFactor;
+uniform float uSpeedScalingFactor;
+
+// outputs
+varying vec2 vModelSpaceCenterToPos;
+varying vec2 vScreenSpaceVelocityVector;
+varying float vSpeed;
+varying vec2 vTexCoord;
+
+void main()
+{
+ // get view space position of vertex this frame and last frame
+ vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+
+ vec4 viewSpaceVertex = uModelView * vertexPosition;
+ vec4 viewSpaceVertexLastFrame = uViewMatrix * uModelLastFrame * vertexPosition;
+
+ // work out vertex's last movement in view space
+ vec3 viewSpacePosDelta = viewSpaceVertex.xyz - viewSpaceVertexLastFrame.xyz;
+ float reciprocalTimeDelta = 1.0 / timeDelta;
+
+ // get clip space position of vertex this frame and last frame
+ vec4 clipSpaceVertex = uMvpMatrix * vertexPosition;
+ vec4 clipSpaceVertexLastFrame = uProjection * viewSpaceVertexLastFrame;
+
+ // decide how much this vertex is 'trailing', i.e. at the back of the object relative to its direction of motion. We do this
+ // by assuming the objects model space origin is at its center and taking the dot product of the vector from center to vertex with the motion direction
+ float t = 0.0;
+ float posDeltaLength = length(viewSpacePosDelta);
+ if(posDeltaLength > 0.001) // avoid div by 0 if object has barely moved
+ {
+ vec4 viewSpaceCenterToPos = uModelView * vec4(aPosition, 0.0, 0.0);
+ float centerToVertexDist = length(viewSpaceCenterToPos);
+ if(centerToVertexDist > 0.001) // avoid div by 0 if object has vertex at model space origin
+ {
+ vec3 viewSpacePosDeltaNormalised = viewSpacePosDelta / posDeltaLength;
+ vec3 viewSpaceCenterToPosNormalised = viewSpaceCenterToPos.xyz / centerToVertexDist;
+ t = (dot(viewSpacePosDeltaNormalised, viewSpaceCenterToPosNormalised) * 0.5 ) + 0.5; // scale and bias from [-1..1] to [0..1]
+ }
+ }
+
+ // output vertex position lerped with its last position, based on how much it is trailing,
+ // this stretches the geom back along where it has just been, giving a warping effect
+ // We raise t to a power in order that non-trailing vertices are effected much more than trailing ones
+ // Note: we must take account of time delta to convert position delta into a velocity, so changes are smooth (take into account frame time correctly)
+ gl_Position = mix(clipSpaceVertexLastFrame, clipSpaceVertex, t * t * t * uGeometryStretchFactor * reciprocalTimeDelta);
+
+ // work out vertex's last movement in normalised device coordinates [-1..1] space, i.e. perspective divide
+ vec2 ndcVertex = clipSpaceVertex.xy / clipSpaceVertex.w;
+ vec2 ndcVertexLastFrame = clipSpaceVertexLastFrame.xy / clipSpaceVertexLastFrame.w;
+ // scale and bias so that a value of 1.0 corresponds to screen size (NDC is [-1..1] = 2)
+ vScreenSpaceVelocityVector = ((ndcVertex - ndcVertexLastFrame) * 0.5 * reciprocalTimeDelta);
+ vScreenSpaceVelocityVector.y = -vScreenSpaceVelocityVector.y; // TODO negated due to y being inverted in our coordinate system?
+ // calculate a scaling factor proportional to velocity, which we can use to tweak how things look
+ vSpeed = length(vScreenSpaceVelocityVector) * uSpeedScalingFactor;
+ vSpeed = clamp(vSpeed, 0.0, 1.0);
+
+ // provide fragment shader with vector from center of object to pixel (assumes the objects model space origin is at its center and verts have same z)
+ vModelSpaceCenterToPos = viewSpaceVertex.xy;
+
+ vec2 texCoord = aPosition + vec2(0.5);
+ vTexCoord = texCoord;
+}
\ No newline at end of file
--- /dev/null
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vMaskTexCoord;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec2 uFixed[ 3 ];
+uniform mediump vec2 uStretchTotal;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+void main()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+
+ mediump vec2 size = visualSize.xy;
+
+ mediump vec2 fixedFactor = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].y );
+ mediump vec2 stretch = floor( aPosition * 0.5 );
+ mediump vec2 fixedTotal = uFixed[ 2 ];
+
+ mediump vec4 gridPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );
+ mediump vec4 vertexPosition = gridPosition;
+ vertexPosition.xy -= size * vec2( 0.5, 0.5 );
+ vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;
+
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ vTexCoord = ( fixedFactor + stretch * uStretchTotal ) / ( fixedTotal + uStretchTotal );
+
+ vMaskTexCoord = gridPosition.xy / size;
+ gl_Position = vertexPosition;
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vMaskTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sMask;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+uniform mediump float auxiliaryImageAlpha;
+
+void main()
+{
+ // Where mask image is transparent, all of background image must show through.
+ // where mask image is opaque, only mask should be shown
+ // where mask is translucent, less of background should be shown.
+ // auxiliaryImageAlpha controls how much of mask is visible
+
+ mediump vec4 color = texture2D( sTexture, vTexCoord );
+ mediump vec4 mask= texture2D( sMask, vMaskTexCoord );
+
+ mediump vec3 mixedColor = color.rgb * mix( 1.0-mask.a, 1.0, 1.0-auxiliaryImageAlpha)
+ + mask.rgb*mask.a * auxiliaryImageAlpha;
+ gl_FragColor = vec4(mixedColor,1.0) * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+uniform lowp float preMultipliedAlpha;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vMaskTexCoord;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];
+uniform mediump vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];
+
+// Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+uniform mediump vec2 extraSize;
+
+void main()
+{
+ mediump vec2 fixedFactor= vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );
+ mediump vec2 stretch= vec2( uNinePatchFactorsX[ int( ( aPosition.x ) * 0.5 ) ].y, uNinePatchFactorsY[ int( ( aPosition.y ) * 0.5 ) ].y );
+
+ mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );
+ mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );
+
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+
+ mediump vec4 gridPosition = vec4( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal, 0.0, 1.0 );
+ mediump vec4 vertexPosition = gridPosition;
+ vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
+ vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );
+ vMaskTexCoord = gridPosition.xy / visualSize;
+
+ gl_Position = vertexPosition;
+}
--- /dev/null
+precision mediump float;
+varying mediump vec2 vTexCoord;
+uniform vec3 uSize;
+uniform vec2 uSpineShadowParameter;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ if( gl_FrontFacing ) // display front side
+ {
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+ }
+ else // display back side, flip the image horizontally by changing the x component of the texture coordinate
+ {
+ gl_FragColor = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) ) * uColor;
+ }
+ // display book spine, a stripe of shadowed texture
+ float pixelPos = vTexCoord.x * uSize.x;
+ if( pixelPos < uSpineShadowParameter.x )
+ {
+ float x = pixelPos - uSpineShadowParameter.x;
+ float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );
+ vec2 spineNormal = normalize(vec2(uSpineShadowParameter.y*x/uSpineShadowParameter.x, y));
+ gl_FragColor.rgb *= spineNormal.y;
+ }
+}
\ No newline at end of file
--- /dev/null
+precision mediump float;
+attribute mediump vec2 aPosition;
+uniform mediump mat4 uMvpMatrix;
+uniform vec3 uSize;
+uniform float uTextureWidth;
+varying vec2 vTexCoord;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition*uSize.xy, 0.0, 1.0);
+ gl_Position = uMvpMatrix * vertexPosition;
+ vTexCoord = aPosition + vec2(0.5);
+ vTexCoord.x /= uTextureWidth;
+}
--- /dev/null
+precision mediump float;
+
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform vec3 uSize;
+uniform vec2 uSpineShadowParameter;
+varying vec3 vNormal;
+varying vec4 vPosition;
+
+void main()
+{
+ // need to re-normalize the interpolated normal
+ vec3 normal = normalize( vNormal );
+ // display page content
+ vec4 texel;
+ // display back image of the page, flip the texture
+ if( dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) );
+ // display front image of the page
+ else texel = texture2D( sTexture, vTexCoord );
+
+ // display book spine, a stripe of shadowed texture
+ float pixelPos = vTexCoord.x * uSize.x;
+ float spineShadowCoef = 1.0;
+ if( pixelPos < uSpineShadowParameter.x )
+ {
+ float x = pixelPos - uSpineShadowParameter.x;
+ float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );
+ spineShadowCoef = normalize( vec2( uSpineShadowParameter.y*x/uSpineShadowParameter.x, y ) ).y;
+ }
+ // calculate the lighting
+ // set the ambient color as vec3(0.4);
+ float lightColor = abs( normal.z ) * 0.6 + 0.4;
+ gl_FragColor = vec4( ( spineShadowCoef * lightColor ) * texel.rgb , texel.a ) * uColor;
+}
--- /dev/null
+/*
+ * The common parameters for all the vertices, calculate in CPU then pass into the shader as uniforms
+ *
+ * first part of the page, (outside the the line passing through original center and vertical to curve direction)
+ * no Z change, only 2D rotation and translation
+ * ([0][0],[0][1],[1][0],[1][1]) mat2 rotateMatrix
+ * ([2][0],[2][1]) vec2 translationVector
+ *
+ * ([0][2],[0][3]) vec2 originalCenter: Typically the press down position of the Pan Gesture
+ * ([1][2],[1][3]) vec2 currentCenter: Typically the current position of the Pan Gesture
+ * ([3][0],[3][1]) vec2 curveDirection: The normalized vector pointing from original center to current center
+ * ([2][2]) float vanishingPointY: The Y coordinate of the intersection of the spine
+ * and the line which goes through the original center and is vertical to the curveDirection
+ * ([2][3]) float curveEndY: The Y coordinate of intersection of the spine and the line through both original and current center
+ * ([3][2]) float curveHeight: The height of the interpolated hermite curve.
+ * ([3][3]) float currentLength: The length from the current center to the curveEnd.
+ */
+
+precision mediump float;
+
+attribute mediump vec2 aPosition;
+
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uModelView;
+
+uniform mat4 uCommonParameters;
+
+uniform vec3 uSize;
+uniform float uIsTurningBack;
+uniform float uTextureWidth;
+varying vec3 vNormal;
+varying vec4 vPosition;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+ vec4 position = vec4( aPosition*uSize.xy, 0.0, 1.0);
+ vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);
+ vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);
+ vec3 normal = vec3(0.0,0.0,1.0);
+
+ if(currentCenter.x < originalCenter.x)
+ {
+ // change the coordinate origin from the center of the page to its top-left
+ position.xy += uSize.xy * 0.5;
+ vec2 curveDirection = vec2( uCommonParameters[3]);
+ vec3 vanishingPoint = vec3(0.0, uCommonParameters[2][2], 0.0);
+ // first part of the page, (outside the the line passing through original center and vertical to curve direction)
+ //no Z change, only 2D rotation and translation
+ if( dot(curveDirection, position.xy - originalCenter) < 0.0 )
+ {
+ position.y -= vanishingPoint.y;
+ position.xy = mat2(uCommonParameters)*position.xy + vec2( uCommonParameters[2]);
+ }
+ // second part of the page, bent as a ruled surface
+ else
+ {
+ // calculate on the flat plane, between
+ // the first line passing through current vertex and vanishing point
+ // the second line passing through original center and current center
+ vec2 curveEnd = vec2( 0.0, uCommonParameters[2][3] );
+ vec2 curFlatDirection = vec2(0.0,1.0);
+ float lengthFromCurve = position.y - originalCenter.y;
+ float lengthOnCurve = position.x;
+ if(currentCenter.y != originalCenter.y)
+ {
+ curFlatDirection = normalize(position.xy - vanishingPoint.xy);
+ lengthFromCurve = (curveEnd.x*curveDirection.y-curveEnd.y*curveDirection.x-position.x*curveDirection.y+position.y*curveDirection.x)
+ / (curFlatDirection.x*curveDirection.y-curFlatDirection.y*curveDirection.x);
+ lengthOnCurve = length(position.xy+lengthFromCurve*curFlatDirection-curveEnd);
+ }
+
+ // define the control points of hermite curve, composed with two segments
+ // calculation is carried out on the 2D plane which is passing through both current and original center and vertical to the image plane
+ float currentLength = uCommonParameters[3][3];
+ float originalLength = abs(originalCenter.x/curveDirection.x);
+ float height = uCommonParameters[3][2];
+ float percentage = currentLength/originalLength;
+ //vec2 SegmentOneControlPoint0 = vec2(0.0, 0.0);
+ vec2 SegmentOneControlPoint1 = vec2((0.65*percentage - 0.15)*originalLength, (0.8 + 0.2 * percentage)*height);
+ vec2 SegmentTwoControlPoint0 = SegmentOneControlPoint1;
+ vec2 SegmentTwoControlPoint1 = vec2(currentLength, 0.0);
+ vec2 SegmentOneTangentVector0 = SegmentOneControlPoint1;
+ vec2 SegmentOneTangentVector1 = vec2(0.5*originalLength,0.0);
+ vec2 SegmentTwoTangentVector0 = SegmentOneTangentVector1;
+ vec2 SegmentTwoTangentVector1 = SegmentOneTangentVector1;
+
+ // calculate the corresponding curve point position and its tangent vector
+ // it is a linear mapping onto nonlinear curves, might cause some unwanted deformation
+ // but as there are no analytical method to calculate the curve length on arbitrary segment
+ // no efficient way to solve this nonlinear mapping, Numerical approximation would cost too much computation in shader
+ vec2 curvePoint2D;
+ vec2 tangent;
+ float t0 = lengthOnCurve / originalLength;
+ if(t0<=0.5)
+ {
+ float t = 2.0*t0;
+ float t_2 = t*t;
+ float t_3 = t*t_2;
+ curvePoint2D = (-2.0*t_3+3.0*t_2)*SegmentOneControlPoint1
+ + (t_3-2.0*t_2+t)*SegmentOneTangentVector0 + (t_3-t_2)*SegmentOneTangentVector1;
+ tangent = (-6.0*t_2+6.0*t)*SegmentOneControlPoint1
+ + (3.0*t_2-4.0*t+1.0)*SegmentOneTangentVector0 + (3.0*t_2-2.0*t)*SegmentOneTangentVector1;
+ }
+ else
+ {
+ float t = 2.0*t0-1.0;
+ float t_2 = t*t;
+ float t_3 = t*t_2;
+ curvePoint2D = (2.0*t_3-3.0*t_2+1.0)*SegmentTwoControlPoint0 + (-2.0*t_3+3.0*t_2)*SegmentTwoControlPoint1
+ + (t_3-2.0*t_2+t)*SegmentTwoTangentVector0 + (t_3-t_2)*SegmentTwoTangentVector1;
+ tangent = (6.0*t_2-6.0*t)*SegmentTwoControlPoint0 + (-6.0*t_2+6.0*t)*SegmentTwoControlPoint1
+ + (3.0*t_2-4.0*t+1.0)*SegmentTwoTangentVector0 + (3.0*t_2-2.0*t)*SegmentTwoTangentVector1;
+ // a trick to eliminate some optical illusion caused by the gradient matter of normal in per-fragment shading
+ // which is caused by linear interpolation of normal vs. nonlinear lighting
+ // will notice some artifact in the areas with dramatically normal changes, so compress the normal differences here
+ tangent.y *= min(1.0, length(position.xyz - vanishingPoint) / uSize.y );
+ }
+ vec3 curvePoint = vec3(curveEnd - curvePoint2D.x*curveDirection,max(0.0,curvePoint2D.y));
+ vec3 tangentVector = vec3(-tangent.x*curveDirection,tangent.y);
+
+ // locate the new vertex position on the line passing through both vanishing point and the calculated curve point position
+ vec3 curLiftDirection = vec3(0.0,-1.0,0.0);
+ if(currentCenter.y != originalCenter.y)
+ {
+ curLiftDirection = normalize(curvePoint - vanishingPoint);
+ tangentVector *= (curveDirection.y > 0.0) ? -1.0 : 1.0;
+ // an heuristic adjustment here, to compensate the linear parameter mapping onto the nonlinear curve
+ float Y0 = position.y - curveDirection.y * (position.x/curveDirection.x);
+ float proportion;
+ float refLength;
+ if(abs(Y0-vanishingPoint.y) > abs(curveEnd.y-vanishingPoint.y))
+ {
+ proportion = abs(curveEnd.y - Y0) / (abs(curveEnd.y-Y0)+abs(curveEnd.y - vanishingPoint.y));
+ refLength = proportion*length(originalCenter-vanishingPoint.xy) / (proportion-1.0);
+ }
+ else
+ {
+ proportion = abs(curveEnd.y - Y0) / abs(curveEnd.y - vanishingPoint.y);
+ refLength = proportion*length(originalCenter-vanishingPoint.xy);
+ }
+ float Y1 = currentCenter.y - (normalize(currentCenter-vanishingPoint.xy)).y * refLength;
+ position.y = mix(Y0, Y1, t0);
+ }
+ position.xz = curvePoint.xz - lengthFromCurve*curLiftDirection.xz;
+ // calculate the normal vector, will be used for lighting
+ normal = cross(curLiftDirection, normalize(tangentVector));
+ // the signature of Z is decided by the page turning direction:
+ // from left to right(negative); from right to left (positive)
+ position.z *= -uIsTurningBack;
+ normal.xy *= -uIsTurningBack;
+ }
+ // change the coordinate origin from the top-left of the page to its center
+ position.xy -= uSize.xy * 0.5;
+ }
+ vNormal = uNormalMatrix * normal;
+ gl_Position = uMvpMatrix * position;
+ // varying parameters for fragment shader
+ vTexCoord = aPosition + vec2(0.5);
+ vTexCoord.x /= uTextureWidth;
+ vPosition = uModelView * position;
+}
--- /dev/null
+//Very simple fragment shader that merely applies the vertex shading to the color at each fragment.
+
+precision mediump float;
+varying mediump vec3 vIllumination;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ vec4 baseColor = vec4(mixColor, 1.0) * uColor;
+ gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );
+}
--- /dev/null
+//A simple shader that applies diffuse lighting to a mono-coloured object.
+
+attribute highp vec3 aPosition;
+attribute highp vec2 aTexCoord;
+attribute highp vec3 aNormal;
+varying mediump vec3 vIllumination;
+uniform mediump vec3 uSize;
+uniform mediump vec3 uObjectDimensions;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelView;
+uniform mediump mat4 uViewMatrix;
+uniform mediump mat3 uNormalMatrix;
+uniform mediump mat4 uObjectMatrix;
+uniform mediump vec3 lightPosition;
+uniform mediump vec2 uStageOffset;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform mediump vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ float scaleFactor = min( visualSize.x / uObjectDimensions.x, visualSize.y / uObjectDimensions.y );
+ vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
+ vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
+ vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+}
+
+void main()
+{
+ vec4 normalisedVertexPosition = ComputeVertexPosition();
+ vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;
+ vertexPosition = uMvpMatrix * vertexPosition;
+
+ //Illumination in Model-View space - Transform attributes and uniforms
+ vec4 mvVertexPosition = uModelView * normalisedVertexPosition;
+ vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;
+
+ vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );
+ mvLightPosition = uViewMatrix * mvLightPosition;
+ vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );
+
+ float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );
+ vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
+
+ gl_Position = vertexPosition;
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform lowp vec4 uShadowColor;
+uniform sampler2D sTexture;
+
+void main()
+{
+ lowp float alpha;
+ alpha = texture2D(sTexture, vec2(vTexCoord.x, vTexCoord.y)).a;
+ gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);
+}
\ No newline at end of file
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform mediump mat4 uMvpMatrix;
+uniform mediump mat4 uModelMatrix;
+uniform vec3 uSize;
+varying vec2 vTexCoord;
+
+uniform mediump mat4 uLightCameraProjectionMatrix;
+uniform mediump mat4 uLightCameraViewMatrix;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ gl_Position = uMvpMatrix * vertexPosition;
+ vec4 textureCoords = uLightCameraProjectionMatrix * uLightCameraViewMatrix * uModelMatrix * vertexPosition;
+ vTexCoord = 0.5 + 0.5 * (textureCoords.xy/textureCoords.w);
+}
\ No newline at end of file
--- /dev/null
+precision highp float;
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform int uSpread;
+uniform vec2 uTexScale;
+
+void main()
+{
+ vec4 color = texture2D( sTexture, vTexCoord);
+ for( int i = 1; i <= uSpread; ++i )
+ {
+ vec2 offset = uTexScale * float(i);
+ color = max( texture2D( sTexture, vTexCoord + offset), color );
+ color = max( texture2D( sTexture, vTexCoord - offset), color );
+ }
+ gl_FragColor = color;
+}
\ No newline at end of file
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp float uAlpha;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+ gl_FragColor.a *= uAlpha;
+}
--- /dev/null
+uniform lowp vec4 uColor;
+uniform lowp vec4 textColorAnimatable;
+uniform sampler2D sTexture;
+varying mediump vec2 vTexCoord;
+varying mediump vec4 vColor;
+
+void main()
+{
+ mediump vec4 color = texture2D( sTexture, vTexCoord );
+ gl_FragColor = vec4( vColor.rgb * uColor.rgb * textColorAnimatable.rgb, uColor.a * vColor.a * textColorAnimatable.a * color.r );
+}
--- /dev/null
+uniform lowp vec4 uColor;
+uniform lowp vec4 textColorAnimatable;
+uniform sampler2D sTexture;
+varying mediump vec2 vTexCoord;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+attribute mediump vec2 aTexCoord;
+attribute mediump vec4 aColor;
+uniform mediump vec2 uOffset;
+uniform highp mat4 uMvpMatrix;
+varying mediump vec2 vTexCoord;
+varying mediump vec4 vColor;
+
+void main()
+{
+ mediump vec4 position = vec4( aPosition.xy + uOffset, 0.0, 1.0 );
+ gl_Position = uMvpMatrix * position;
+ vTexCoord = aTexCoord;
+ vColor = aColor;
+}
--- /dev/null
+varying mediump vec4 vColor;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ gl_FragColor = vColor * uColor;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+attribute mediump vec4 aColor;
+varying mediump vec4 vColor;
+uniform highp mat4 uMvpMatrix;
+
+void main()
+{
+ mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
+ gl_Position = uMvpMatrix * position;
+ vColor = aColor;
+}
--- /dev/null
+uniform lowp vec4 uColor;
+
+void main()
+{
+ gl_FragColor = uColor;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+
+void main()
+{
+ mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
+ gl_Position = uMvpMatrix * position;
+}
--- /dev/null
+varying highp vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ if ( vTexCoord.y > 1.0 )
+ discard;
+
+ mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+
+ gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+varying highp vec2 vTexCoord;
+uniform highp vec3 uSize;
+uniform mediump float uDelta;
+uniform mediump vec2 uTextureSize;
+uniform mediump float uGap;
+uniform mediump float uHorizontalAlign;
+uniform mediump float uVerticalAlign;
+
+uniform highp mat4 uMvpMatrix;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+void main()
+{
+ mediump vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
+ mediump vec2 visualSize = mix( uSize.xy * size, size, offsetSizeMode.zw );
+
+ vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + floor( aPosition.x * visualSize.x ) + 0.5 - uGap * 0.5 ) / uTextureSize.x + 0.5;
+ vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + floor( aPosition.y * visualSize.y ) + 0.5 ) / ( uTextureSize.y ) + 0.5;
+
+ mediump vec4 vertexPosition = vec4( floor( ( aPosition + anchorPoint ) * visualSize + ( visualOffset + origin ) * uSize.xy ), 0.0, 1.0 );
+
+ gl_Position = uMvpMatrix * vertexPosition;
+}
\ No newline at end of file
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+
+ gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sStyle;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+ mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );
+
+ // Draw the text as overlay above the style
+ gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+uniform mediump vec4 pixelArea;
+
+varying mediump vec2 vTexCoord;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+ vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ mediump float textTexture = texture2D( sTexture, vTexCoord ).r;
+
+ // Set the color of the text to what it is animated to.
+ gl_FragColor = uTextColorAnimatable * textTexture * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sMask;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+ mediump float maskTexture = texture2D( sMask, vTexCoord ).r;
+
+ // Set the color of non-transparent pixel in text to what it is animated to.
+ // Markup text with multiple text colors are not animated (but can be supported later on if required).
+ // Emoji color are not animated.
+ mediump float vstep = step( 0.0001, textTexture.a );
+ textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture );
+
+ // Draw the text as overlay above the style
+ gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sStyle;
+uniform sampler2D sMask;
+uniform lowp float uHasMultipleTextColors;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ mediump vec4 textTexture = texture2D( sTexture, vTexCoord );
+ mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );
+ mediump float maskTexture = texture2D( sMask, vTexCoord ).r;
+
+ // Set the color of non-transparent pixel in text to what it is animated to.
+ // Markup text with multiple text colors are not animated (but can be supported later on if required).
+ // Emoji color are not animated.
+ mediump float vstep = step( 0.0001, textTexture.a );
+ textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) );
+
+ // Draw the text as overlay above the style
+ gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+varying mediump vec2 vTexCoord;
+uniform sampler2D sTexture;
+uniform sampler2D sStyle;
+uniform lowp vec4 uTextColorAnimatable;
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ mediump float textTexture = texture2D( sTexture, vTexCoord ).r;
+ mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );
+
+ // Draw the text as overlay above the style
+ gl_FragColor = ( uTextColorAnimatable * textTexture + styleTexture * ( 1.0 - uTextColorAnimatable.a * textTexture ) ) * uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+uniform lowp vec4 uColor;
+varying mediump vec2 vTexCoord;
+uniform samplerExternalOES sTexture;
+
+void main()
+{
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+varying mediump vec2 vTexCoord;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+varying mediump vec2 sTexCoordRect;
+
+void main()
+{
+ gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0);
+ vTexCoord = aPosition + vec2(0.5);
+}
--- /dev/null
+void main()
+{
+ gl_FragColor = vec4(0.0);
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+void main()
+{
+ mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+ vertexPosition.xyz *= uSize;
+ gl_Position = uMvpMatrix * vertexPosition;
+}
--- /dev/null
+uniform lowp vec4 uColor;
+uniform lowp vec3 mixColor;
+
+void main()
+{
+ gl_FragColor = uColor * vec4( mixColor, 1.0 );
+}
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+}
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#ifdef DEBUG_ENABLED
#define DECORATOR_DEBUG
#endif
-#define MAKE_SHADER(A)#A
-
-namespace
-{
-const char* VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec2 aPosition;
-uniform highp mat4 uMvpMatrix;
-
-void main()
-{
- mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
- gl_Position = uMvpMatrix * position;
-}
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
-uniform lowp vec4 uColor;
-
-void main()
-{
- gl_FragColor = uColor;
-}
-);
-}
-
namespace Dali
{
namespace Internal
mHidePrimaryCursorAndGrabHandle( false )
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
- mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ mHighlightShader = Shader::New( SHADER_TEXT_DECORATOR_SHADER_VERT, SHADER_TEXT_DECORATOR_SHADER_FRAG );
SetupGestures();
}
#include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
#include <dali-toolkit/internal/text/rendering/atlas/atlas-mesh-factory.h>
#include <dali-toolkit/internal/text/text-view.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
using namespace Dali;
using namespace Dali::Toolkit;
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_RENDERING");
#endif
-#define MAKE_SHADER(A)#A
-
-const char* VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec2 aPosition;
-attribute mediump vec2 aTexCoord;
-attribute mediump vec4 aColor;
-uniform mediump vec2 uOffset;
-uniform highp mat4 uMvpMatrix;
-varying mediump vec2 vTexCoord;
-varying mediump vec4 vColor;
-
-void main()
-{
- mediump vec4 position = vec4( aPosition.xy + uOffset, 0.0, 1.0 );
- gl_Position = uMvpMatrix * position;
- vTexCoord = aTexCoord;
- vColor = aColor;
-}
-);
-
-const char* FRAGMENT_SHADER_L8 = MAKE_SHADER(
-uniform lowp vec4 uColor;
-uniform lowp vec4 textColorAnimatable;
-uniform sampler2D sTexture;
-varying mediump vec2 vTexCoord;
-varying mediump vec4 vColor;
-
-void main()
-{
- mediump vec4 color = texture2D( sTexture, vTexCoord );
- gl_FragColor = vec4( vColor.rgb * uColor.rgb * textColorAnimatable.rgb, uColor.a * vColor.a * textColorAnimatable.a * color.r );
-}
-);
-
-const char* FRAGMENT_SHADER_RGBA = MAKE_SHADER(
-uniform lowp vec4 uColor;
-uniform lowp vec4 textColorAnimatable;
-uniform sampler2D sTexture;
-varying mediump vec2 vTexCoord;
-
-void main()
-{
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable;
-}
-);
-
const float ZERO( 0.0f );
const float HALF( 0.5f );
const float ONE( 1.0f );
// The glyph is an emoji and is not a shadow.
if( !mShaderRgba )
{
- mShaderRgba = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_RGBA );
+ mShaderRgba = Shader::New( SHADER_TEXT_ATLAS_SHADER_VERT, SHADER_TEXT_ATLAS_RGBA_SHADER_FRAG );
}
shader = mShaderRgba;
}
// The glyph is text or a shadow.
if( !mShaderL8 )
{
- mShaderL8 = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_L8 );
+ mShaderL8 = Shader::New( SHADER_TEXT_ATLAS_SHADER_VERT, SHADER_TEXT_ATLAS_L8_SHADER_FRAG );
}
shader = mShaderL8;
}
#include <dali-toolkit/internal/text/text-controller-impl-event-handler.h>
#include <dali-toolkit/internal/text/text-run-container.h>
#include <dali-toolkit/internal/text/text-selection-handle-controller.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
using namespace Dali;
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
#endif
-#define MAKE_SHADER(A)#A
-
-const char* VERTEX_SHADER_BACKGROUND = MAKE_SHADER(
-attribute mediump vec2 aPosition;
-attribute mediump vec4 aColor;
-varying mediump vec4 vColor;
-uniform highp mat4 uMvpMatrix;
-
-void main()
-{
- mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
- gl_Position = uMvpMatrix * position;
- vColor = aColor;
-}
-);
-
-const char* FRAGMENT_SHADER_BACKGROUND = MAKE_SHADER(
-varying mediump vec4 vColor;
-uniform lowp vec4 uColor;
-
-void main()
-{
- gl_FragColor = vColor * uColor;
-}
-);
-
struct BackgroundVertex
{
Vector2 mPosition; ///< Vertex posiiton
if( !mShaderBackground )
{
- mShaderBackground = Shader::New( VERTEX_SHADER_BACKGROUND, FRAGMENT_SHADER_BACKGROUND );
+ mShaderBackground = Shader::New( SHADER_TEXT_CONTROLLER_BACKGROUND_SHADER_VERT, SHADER_TEXT_CONTROLLER_BACKGROUND_SHADER_FRAG );
}
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, mShaderBackground );
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/text-scroller-interface.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
const int MINIMUM_SCROLL_SPEED = 1; // Speed should be set by Property system.
-const char* VERTEX_SHADER_SCROLL = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- varying highp vec2 vTexCoord;\n
- uniform highp vec3 uSize;\n
- uniform mediump float uDelta;\n
- uniform mediump vec2 uTextureSize;\n
- uniform mediump float uGap;\n
- uniform mediump float uHorizontalAlign;\n
- uniform mediump float uVerticalAlign;\n
- \n
- uniform highp mat4 uMvpMatrix;\n
- \n
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- void main()\n
- {\n
- mediump vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );\n
- mediump vec2 visualSize = mix( uSize.xy * size, size, offsetSizeMode.zw );\n
- \n
- vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + floor( aPosition.x * visualSize.x ) + 0.5 - uGap * 0.5 ) / uTextureSize.x + 0.5;\n
- vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + floor( aPosition.y * visualSize.y ) + 0.5 ) / ( uTextureSize.y ) + 0.5;\n
- \n
- mediump vec4 vertexPosition = vec4( floor( ( aPosition + anchorPoint ) * visualSize + ( visualOffset + origin ) * uSize.xy ), 0.0, 1.0 );\n
- \n
- gl_Position = uMvpMatrix * vertexPosition;\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying highp vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- if ( vTexCoord.y > 1.0 )\n
- discard;\n
- \n
- mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
- \n
- gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
- }\n
-);
-
/**
* @brief How the text should be aligned horizontally when scrolling the text.
*
mTextureSet = mRenderer.GetTextures();
// Set the shader and texture for scrolling
- Shader shader = Shader::New( VERTEX_SHADER_SCROLL, FRAGMENT_SHADER, Shader::Hint::NONE );
+ Shader shader = Shader::New( SHADER_TEXT_SCROLLER_SHADER_VERT, SHADER_TEXT_SCROLLER_SHADER_FRAG, Shader::Hint::NONE );
mRenderer.SetShader( shader );
mRenderer.SetTextures( textureSet );
#include <cstring> // for strcmp
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
namespace Dali
DALI_TYPE_REGISTRATION_END()
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- varying mediump vec2 vTexCoord;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- uniform mediump vec4 uTextureRect;\n
- \n
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vertexPosition.xyz *= uSize;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
- \n
- vTexCoord = aPosition + vec2(0.5);\n
- vTexCoord = mix(uTextureRect.xy, uTextureRect.zw, vTexCoord);\n
-
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec4 uSamplerRect;
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
- }\n
-);
-
Actor CreateTile( const Vector4& samplerRect )
{
Actor tile = Actor::New();
void CubeTransitionEffect::OnSceneConnection( int depth )
{
Geometry geometry = VisualFactoryCache::CreateQuadGeometry();
- Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ Shader shader = Shader::New( SHADER_CUBE_TRANSITION_EFFECT_VERT, SHADER_CUBE_TRANSITION_EFFECT_FRAG );
TextureSet textureSet = TextureSet::New();
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
const Toolkit::DevelAnimatedGradientVisual::AnimationParameter::MotionType::Type DEFAULT_ANIMATION_MOTION_TYPE = Toolkit::DevelAnimatedGradientVisual::AnimationParameter::MotionType::LOOP;
const Toolkit::DevelAnimatedGradientVisual::AnimationParameter::EasingType::Type DEFAULT_ANIMATION_EASING_TYPE = Toolkit::DevelAnimatedGradientVisual::AnimationParameter::EasingType::LINEAR;
-const char* const BASIC_VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;
- uniform highp mat4 uMvpMatrix;
- uniform highp vec3 uSize;
-
- uniform mediump vec2 start_point;
- uniform mediump vec2 end_point;
- uniform mediump vec2 rotate_center;
- uniform mediump float rotate_angle;
-
- varying mediump vec2 vTexCoord;
- varying mediump vec2 vStart;
- varying mediump vec2 vEnd;
-
- vec2 rotate(vec2 x, vec2 c, float a)
- {
- vec2 d = x - c;
- vec2 r = vec2(d.x * cos(a) - d.y * sin(a), d.x * sin(a) + d.y * cos(a));
-
-\n #ifdef UNIT_TYPE_BOUNDING_BOX \n return r + c; \n #endif \n /* UnitType::OBJECT_BOUNDING_BOX */
-\n #ifdef UNIT_TYPE_USER \n return (r + c) / uSize.x; \n #endif \n /* UnitType::USER_SPACE */
- }
-
- //Visual size and offset
- uniform mediump vec2 offset;
- uniform highp vec2 size;
- uniform mediump vec4 offsetSizeMode;
- uniform mediump vec2 origin;
- uniform mediump vec2 anchorPoint;
-
- vec4 ComputeVertexPosition()
- {
- vec2 visualSize = mix( uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
- }
-
- void main()
- {
- vStart = rotate( start_point, rotate_center, rotate_angle );
- vEnd = rotate( end_point, rotate_center, rotate_angle );
- gl_Position = uMvpMatrix * ComputeVertexPosition();
-
-\n #ifdef UNIT_TYPE_BOUNDING_BOX \n vTexCoord = vec2(aPosition.x, -aPosition.y); \n #endif \n /* UnitType::OBJECT_BOUNDING_BOX */
-\n #ifdef UNIT_TYPE_USER \n vTexCoord = vec2(aPosition.x, -aPosition.y * uSize.y / uSize.x); \n #endif \n /* UnitType::USER_SPACE */
- }
-);
-
-const char* const BASIC_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- precision mediump float;
-
- uniform mediump vec4 start_color;
- uniform mediump vec4 end_color;
- uniform mediump float gradient_offset;
-
- varying mediump vec2 vTexCoord;
- varying mediump vec2 vStart;
- varying mediump vec2 vEnd;
-
- float get_position(vec2 x, vec2 s, vec2 e)
- {
- vec2 df = e - s;
- vec2 dx = x - s;
-
-\n #ifdef GRADIENT_TYPE_LINEAR \n return dot(dx,df)/dot(df,df); \n #endif \n /* GradientType::LINEAR */
-\n #ifdef GRADIENT_TYPE_RADIAL \n return sqrt(dot(dx,dx)/dot(df,df)); \n #endif \n /* GradientType::RADIAL */
- }
- float recalculate(float r)
- {
-\n #ifdef SPREAD_TYPE_REFLECT \n return 1.0 - abs(mod(r, 2.0) - 1.0); \n #endif \n /* SpreadType::REFLECT */
-\n #ifdef SPREAD_TYPE_REPEAT \n return fract(r); \n #endif \n /* SpreadType::REPEAT */
-\n #ifdef SPREAD_TYPE_CLAMP \n return clamp(r, 0.0, 1.0); \n #endif \n /* SpreadType::CLAMP */
- }
-
- void main()
- {
- float r = get_position( vTexCoord, vStart, vEnd );
- r = recalculate( r + gradient_offset );
- vec4 color = mix( start_color, end_color, r );
- gl_FragColor = color;
- }
-);
-
Property::Value GetStartValue( const Property::Map& map, Property::Index index, const char* const name )
{
// Get start value of animation parameter
std::string frag;
vert = "#define " + tagUnit + "\n"
- + BASIC_VERTEX_SHADER;
+ + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_VERT.data();
frag = "#define " + tagGrad + "\n"
+ "#define " + tagSpread + "\n"
- + BASIC_FRAGMENT_SHADER;
+ + SHADER_ANIMATED_GRADIENT_VISUAL_SHADER_FRAG.data();
shader = Shader::New( vert, frag );
return shader;
map.Insert( Toolkit::ImageVisual::Property::CACHE_SIZE, static_cast<int>(mCacheSize) );
map.Insert( Toolkit::ImageVisual::Property::FRAME_DELAY, static_cast<int>(mFrameDelay) );
map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, static_cast<int>(mLoopCount) );
+ map.Insert( Toolkit::DevelImageVisual::Property::CURRENT_FRAME_NUMBER, (mImageCache) ? static_cast<int32_t>(mImageCache->GetCurrentFrameIndex()) : -1 );
+ map.Insert( Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, (mImageCache) ? static_cast<int32_t>(mImageCache->GetTotalFrameCount()) : -1 );
map.Insert( Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR, mStopBehavior );
}
return static_cast<int32_t>(mFront);
}
+int32_t FixedImageCache::GetTotalFrameCount() const
+{
+ return mImageUrls.size();
+}
+
bool FixedImageCache::IsFrontReady() const
{
return ( mReadyFlags.size() > 0 && mReadyFlags[mFront] == true );
*/
int32_t GetCurrentFrameIndex() const override;
+ /**
+ * Get total frame count of the animated image file.
+ */
+ int32_t GetTotalFrameCount() const override;
+
private:
/**
* @return true if the front frame is ready
*/
virtual int32_t GetCurrentFrameIndex() const = 0;
+ /**
+ * Get total frame count of the animated image file.
+ */
+ virtual int32_t GetTotalFrameCount() const = 0;
+
private:
/**
return mQueue.Front().mFrameNumber;
}
+int32_t RollingAnimatedImageCache::GetTotalFrameCount() const
+{
+ return mFrameCount;
+}
+
bool RollingAnimatedImageCache::IsFrontReady() const
{
return ( !mQueue.IsEmpty() && mQueue.Front().mReady );
*/
int32_t GetCurrentFrameIndex() const override;
+ /**
+ * Get total frame count of the animated image file.
+ */
+ int32_t GetTotalFrameCount() const override;
+
private:
/**
* @return true if the front frame is ready
return mQueue.Front().mUrlIndex;
}
+int32_t RollingImageCache::GetTotalFrameCount() const
+{
+ return mImageUrls.size();
+}
+
bool RollingImageCache::IsFrontReady() const
{
return ( !mQueue.IsEmpty() && mQueue.Front().mReady );
*/
int32_t GetCurrentFrameIndex() const override;
+ /**
+ * Get total frame count of the animated image file.
+ */
+ int32_t GetTotalFrameCount() const override;
+
private:
/**
* @return true if the front frame is ready
}
else
{
- shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, false );
+ shader = mImageVisualShaderFactory.GetShader( mFactoryCache, false, true, IsRoundedCornerRequired() );
}
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
DALI_ENUM_TO_STRING_WITH_SCOPE( DevelArcVisual::Cap, ROUND )
DALI_ENUM_TO_STRING_TABLE_END( CAP )
-const char* VERTEX_SHADER =
- "INPUT mediump vec2 aPosition;\n"
- "OUTPUT mediump vec2 vPosition;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
-
- "//Visual size and offset\n"
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
-
- "vec4 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " vPosition = aPosition* visualSize;\n"
- " return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
- "}\n";
-
-const char* FRAGMENT_SHADER_BUTT_CAP =
- "INPUT mediump vec2 vPosition;\n"
-
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform mediump float thickness;\n"
- "uniform mediump float radius;\n"
- "uniform mediump float startAngle;\n"
- "uniform mediump float sweepAngle;\n"
-
- "const mediump float M_PI_OVER_2 = 1.57079632679;\n"
- "const mediump float M_PI = 3.14159265359;\n"
- "const mediump float M_PI_2 = 6.28318530718;\n"
-
- "mediump float GetOpacity()\n"
- "{\n"
- " mediump float start = radians( mod( startAngle, 360.0 ) );\n"
- " mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );\n"
- " mediump float dist = length( vPosition );\n"
- " if( angle <= radians( sweepAngle ) )\n"
- " {\n"
- " return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );\n"
- " }\n"
- " mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );\n"
- " mediump vec2 q0 = vec2( dist * cos( start - M_PI_OVER_2 ), dist * sin( start - M_PI_OVER_2 ) );\n"
- " mediump vec2 q1 = vec2( dist * cos( end - M_PI_OVER_2 ), dist * sin( end - M_PI_OVER_2 ) );\n"
- " mediump float opacity = 1.0 - smoothstep( 0.0, 2.0, min( length( vPosition - q0 ), length( vPosition - q1 ) ) );\n"
- " opacity *= step( 0.0, thickness / 2.0 - abs( dist - radius ) );\n"
- " return opacity;\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;\n"
- " OUT_COLOR.a *= GetOpacity();\n"
- "}\n";
-
-const char* FRAGMENT_SHADER_ROUND_CAP =
- "INPUT mediump vec2 vPosition;\n"
-
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform mediump float thickness;\n"
- "uniform mediump float radius;\n"
- "uniform mediump float startAngle;\n"
- "uniform mediump float sweepAngle;\n"
-
- "const mediump float M_PI_OVER_2 = 1.57079632679;\n"
- "const mediump float M_PI_2 = 6.28318530718;\n"
-
- "mediump float GetOpacity()\n"
- "{\n"
- " mediump float start = radians( mod( startAngle, 360.0 ) );\n"
- " mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );\n"
- " mediump float dist = length( vPosition );\n"
- " if( angle <= radians( sweepAngle ) )\n"
- " {\n"
- " return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );\n"
- " }\n"
- " mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );\n"
- " mediump vec2 q0 = vec2( radius * cos( start - M_PI_OVER_2 ), radius * sin( start - M_PI_OVER_2 ) );\n"
- " mediump vec2 q1 = vec2( radius * cos( end - M_PI_OVER_2 ), radius * sin( end - M_PI_OVER_2 ) );\n"
- " return smoothstep( -1.0, 1.0, thickness / 2.0 - min( length( vPosition - q0 ), length( vPosition - q1 ) ) );\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;\n"
- " OUT_COLOR.a *= GetOpacity();\n"
- "}\n";
-
}
ArcVisualPtr ArcVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
ResourceReady( Toolkit::Visual::ResourceStatus::READY );
}
+void ArcVisual::DoSetOffScene(Actor& actor)
+{
+ if(mImpl->mRenderer)
+ {
+ // Update values from Renderer
+ mThickness = mImpl->mRenderer.GetProperty<float>(mThicknessIndex);
+ mStartAngle = mImpl->mRenderer.GetProperty<float>(mStartAngleIndex);
+ mSweepAngle = mImpl->mRenderer.GetProperty<float>(mSweepAngleIndex);
+ }
+
+ actor.RemoveRenderer(mImpl->mRenderer);
+ mImpl->mRenderer.Reset();
+
+ mThicknessIndex = Property::INVALID_INDEX;
+ mStartAngleIndex = Property::INVALID_INDEX;
+ mSweepAngleIndex = Property::INVALID_INDEX;
+}
+
void ArcVisual::DoCreatePropertyMap( Property::Map& map ) const
{
+ float thickness, startAngle, sweepAngle;
+ if(mImpl->mRenderer)
+ {
+ // Update values from Renderer
+ thickness = mImpl->mRenderer.GetProperty<float>(mThicknessIndex);
+ startAngle = mImpl->mRenderer.GetProperty<float>(mStartAngleIndex);
+ sweepAngle = mImpl->mRenderer.GetProperty<float>(mSweepAngleIndex);
+ }
+ else
+ {
+ thickness = mThickness;
+ startAngle = mStartAngle;
+ sweepAngle = mSweepAngle;
+ }
+
map.Clear();
map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::ARC );
- map.Insert( Toolkit::DevelArcVisual::Property::THICKNESS, mThickness );
- map.Insert( Toolkit::DevelArcVisual::Property::START_ANGLE, mStartAngle );
- map.Insert( Toolkit::DevelArcVisual::Property::SWEEP_ANGLE, mSweepAngle );
+ map.Insert(Toolkit::DevelArcVisual::Property::THICKNESS, thickness);
+ map.Insert(Toolkit::DevelArcVisual::Property::START_ANGLE, startAngle);
+ map.Insert(Toolkit::DevelArcVisual::Property::SWEEP_ANGLE, sweepAngle);
map.Insert( Toolkit::DevelArcVisual::Property::CAP, mCapType );
}
shader = mFactoryCache.GetShader( VisualFactoryCache::ARC_BUTT_CAP_SHADER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_BUTT_CAP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_ARC_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_ARC_VISUAL_BUTT_CAP_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::ARC_BUTT_CAP_SHADER, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::ARC_ROUND_CAP_SHADER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUND_CAP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_ARC_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_ARC_VISUAL_ROUND_CAP_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::ARC_ROUND_CAP_SHADER, shader );
}
}
mImpl->mRenderer = Renderer::New( geometry, shader );
- mThicknessIndex = mImpl->mRenderer.RegisterProperty( THICKNESS_NAME, mThickness );
- mStartAngleIndex = mImpl->mRenderer.RegisterProperty( START_ANGLE_NAME, mStartAngle );
- mSweepAngleIndex = mImpl->mRenderer.RegisterProperty( SWEEP_ANGLE_NAME, mSweepAngle );
+ mThicknessIndex = mImpl->mRenderer.RegisterProperty(DevelArcVisual::Property::THICKNESS, THICKNESS_NAME, mThickness);
+ mStartAngleIndex = mImpl->mRenderer.RegisterProperty(DevelArcVisual::Property::START_ANGLE, START_ANGLE_NAME, mStartAngle);
+ mSweepAngleIndex = mImpl->mRenderer.RegisterProperty(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_NAME, mSweepAngle);
mRadiusIndex = mImpl->mRenderer.RegisterProperty( RADIUS_NAME, mRadius );
void DoSetOnScene( Actor& actor ) override;
/**
+ * @copydoc Visual::Base::DoSetOffScene
+ */
+ void DoSetOffScene(Actor& actor) override;
+
+ /**
* @copydoc Visual::Base::OnSetTransform
*/
void OnSetTransform() override;
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
const char * const POSITION_ATTRIBUTE_NAME("aPosition");
const char * const DRIFT_ATTRIBUTE_NAME("aDrift");
const char * const INDEX_NAME("indices");
-
-const char* VERTEX_SHADER =
- "INPUT mediump vec2 aPosition;\n"
- "INPUT mediump vec2 aDrift;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
- "uniform mediump float borderSize;\n"
-
- "//Visual size and offset\n"
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
-
- "vec2 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " return (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy;\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " vec2 position = ComputeVertexPosition() + aDrift*borderSize;\n"
- " gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);\n"
- "}\n";
-
-const char* FRAGMENT_SHADER =
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec4 borderColor;\n"
- "uniform lowp vec3 mixColor;\n"
-
- "void main()\n"
- "{\n"
- " OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;\n"
- "}\n";
-
-const char* VERTEX_SHADER_ANTI_ALIASING =
- "INPUT mediump vec2 aPosition;\n"
- "INPUT mediump vec2 aDrift;\n"
- "OUTPUT mediump float vAlpha;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
- "uniform mediump float borderSize;\n"
-
- "void main()\n"
- "{\n"
- " vec2 position = aPosition*(uSize.xy+vec2(0.75)) + aDrift*(borderSize+1.5);\n"
- " gl_Position = uMvpMatrix * vec4(position, 0.0, 1.0);\n"
- " vAlpha = min( abs(aDrift.x), abs(aDrift.y) )*(borderSize+1.5);"
- "}\n";
-
-const char* FRAGMENT_SHADER_ANTI_ALIASING =
- "INPUT mediump float vAlpha;\n"
-
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec4 borderColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform mediump float borderSize;\n"
-
- "void main()\n"
- "{\n"
- " OUT_COLOR = vec4(mixColor, 1.0) * borderColor * uColor;\n"
- " OUT_COLOR.a *= smoothstep(0.0, 1.5, vAlpha) * smoothstep( borderSize + 1.5, borderSize, vAlpha );\n"
- "}\n";
}
BorderVisualPtr BorderVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ANTI_ALIASING, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ANTI_ALIASING );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_BORDER_VISUAL_ANTI_ALIASING_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_BORDER_VISUAL_ANTI_ALIASING_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_BORDER_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_BORDER_VISUAL_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER, shader );
}
}
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
namespace Internal
{
-namespace
-{
-
-const char* VERTEX_SHADER =
- "INPUT mediump vec2 aPosition;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
-
- "//Visual size and offset\n"
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
- "uniform mediump vec2 extraSize;\n"
-
- "vec4 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
- "}\n";
-
-
-const char* FRAGMENT_SHADER =
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
-
- "void main()\n"
- "{\n"
- " OUT_COLOR = vec4(mixColor, 1.0) * uColor;\n"
- "}\n";
-
-const char* VERTEX_SHADER_ROUNDED_CORNER =
- "INPUT mediump vec2 aPosition;\n"
- "OUTPUT mediump vec2 vPosition;\n"
- "OUTPUT mediump vec2 vRectSize;\n"
- "OUTPUT mediump float vCornerRadius;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
-
- "//Visual size and offset\n"
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec2 extraSize;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
- "uniform mediump float cornerRadius;\n"
- "uniform mediump float cornerRadiusPolicy;\n"
-
- "vec4 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " mediump float minSize = min( visualSize.x, visualSize.y );\n"
- " vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n"
- " vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n"
- " vRectSize = visualSize / 2.0 - vCornerRadius;\n"
- " vPosition = aPosition* visualSize;\n"
- " return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
- "}\n";
-
-//float distance = length( max( abs( position - center ), size ) - size ) - radius;
-const char* FRAGMENT_SHADER_ROUNDED_CORNER =
- "INPUT mediump vec2 vPosition;\n"
- "INPUT mediump vec2 vRectSize;\n"
- "INPUT mediump float vCornerRadius;\n"
-
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
-
- "void main()\n"
- "{\n"
- " mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n"
- " OUT_COLOR = vec4(mixColor, 1.0) * uColor;\n"
- " OUT_COLOR.a *= 1.0 - smoothstep( -1.0, 1.0, dist );\n"
- "}\n";
-
-const char* VERTEX_SHADER_BLUR_EDGE =
- "INPUT mediump vec2 aPosition;\n"
- "OUTPUT mediump vec2 vPosition;\n"
- "OUTPUT mediump vec2 vRectSize;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
-
- "//Visual size and offset\n"
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec2 extraSize;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
- "uniform mediump float blurRadius;\n"
-
- "vec4 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize + blurRadius * 2.0;\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " vRectSize = visualSize / 2.0;\n"
- " vPosition = aPosition* visualSize;\n"
- " return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
- "}\n";
-
-const char* FRAGMENT_SHADER_BLUR_EDGE =
- "INPUT mediump vec2 vPosition;\n"
- "INPUT mediump vec2 vRectSize;\n"
-
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform mediump float blurRadius;\n"
-
- "void main()\n"
- "{\n"
- " mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );\n"
- " OUT_COLOR = vec4(mixColor, 1.0) * uColor;\n"
- " OUT_COLOR.a *= blur.x * blur.y;\n"
- "}\n";
-
-}
-
ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
ColorVisualPtr colorVisualPtr( new ColorVisual( factoryCache ) );
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_BLUR_EDGE, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_BLUR_EDGE );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_COLOR_VISUAL_BLUR_EDGE_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_COLOR_VISUAL_BLUR_EDGE_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_COLOR_VISUAL_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_COLOR_VISUAL_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ROUNDED_CORNER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUNDED_CORNER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_COLOR_VISUAL_ROUNDED_CORNER_SHADER_VERT.data(), Dali::Shader::GetFragmentShaderPrefix() + SHADER_COLOR_VISUAL_ROUNDED_CORNER_SHADER_FRAG.data() );
mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER, shader );
}
}
#include <dali-toolkit/internal/visuals/gradient/linear-gradient.h>
#include <dali-toolkit/internal/visuals/gradient/radial-gradient.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-bounding-box-rounded-corner-shader-vert.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-bounding-box-shader-vert.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-linear-rounded-corner-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-linear-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-radial-rounded-corner-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-radial-shader-frag.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-user-space-rounded-corner-shader-vert.h>
+#include <dali-toolkit/internal/graphics/generated/gradient-visual-user-space-shader-vert.h>
namespace Dali
{
}
};
-const char* VERTEX_SHADER[] =
+const std::string_view VERTEX_SHADER[] =
{
-// vertex shader for gradient units as OBJECT_BOUNDING_BOX
-DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump mat3 uAlignmentMatrix;\n
- varying mediump vec2 vTexCoord;\n
- \n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
- \n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- }\n
-),
-
-// vertex shader for gradient units as USER_SPACE
-DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump mat3 uAlignmentMatrix;\n
- varying mediump vec2 vTexCoord;\n
- \n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vertexPosition.xyz *= uSize;\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- \n
- vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
- }\n
-),
-
-// vertex shader for gradient units as OBJECT_BOUNDING_BOX with corner radius
-DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump mat3 uAlignmentMatrix;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- varying mediump float vCornerRadius;\n
- \n
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
- uniform mediump float cornerRadius;\n
- uniform mediump float cornerRadiusPolicy;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- mediump float minSize = min( visualSize.x, visualSize.y );\n
- vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n
- vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n
- vRectSize = visualSize * 0.5 - vCornerRadius;\n
- vPosition = aPosition * visualSize;\n
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
- \n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- }\n
-),
-
-// vertex shader for gradient units as USER_SPACE with corner radius
-DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump mat3 uAlignmentMatrix;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- varying mediump float vCornerRadius;\n
- \n
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
- uniform mediump float cornerRadius;\n
- uniform mediump float cornerRadiusPolicy;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- mediump float minSize = min( visualSize.x, visualSize.y );\n
- vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n
- vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n
- vRectSize = visualSize * 0.5 - vCornerRadius;\n
- vPosition = aPosition * visualSize;\n
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n
- vertexPosition.xyz *= uSize;\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- \n
- vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;\n
- }\n
-)
+ // vertex shader for gradient units as OBJECT_BOUNDING_BOX
+ SHADER_GRADIENT_VISUAL_BOUNDING_BOX_SHADER_VERT,
+
+ // vertex shader for gradient units as USER_SPACE
+ SHADER_GRADIENT_VISUAL_USER_SPACE_SHADER_VERT,
+
+ // vertex shader for gradient units as OBJECT_BOUNDING_BOX with corner radius
+ SHADER_GRADIENT_VISUAL_BOUNDING_BOX_ROUNDED_CORNER_SHADER_VERT,
+
+ // vertex shader for gradient units as USER_SPACE with corner radius
+ SHADER_GRADIENT_VISUAL_USER_SPACE_ROUNDED_CORNER_SHADER_VERT
};
-const char* FRAGMENT_SHADER[] =
+const std::string_view FRAGMENT_SHADER[] =
{
-// fragment shader for linear gradient
-DALI_COMPOSE_SHADER(
- uniform sampler2D sTexture;\n // sampler1D?
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- varying mediump vec2 vTexCoord;\n
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
- }\n
-),
-
-// fragment shader for radial gradient
-DALI_COMPOSE_SHADER(
- uniform sampler2D sTexture;\n // sampler1D?
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- varying mediump vec2 vTexCoord;\n
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
- }\n
-),
-
-// fragment shader for linear gradient with corner radius
-DALI_COMPOSE_SHADER(
- uniform sampler2D sTexture;\n // sampler1D?
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- varying mediump float vCornerRadius;\n
- \n
- void main()\n
- {\n
- mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
- gl_FragColor = texture2D( sTexture, vec2( vTexCoord.y, 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
- gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
- }\n
-),
-
-// fragment shader for radial gradient with corner radius
-DALI_COMPOSE_SHADER(
- uniform sampler2D sTexture;\n // sampler1D?
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- varying mediump float vCornerRadius;\n
- \n
- void main()\n
- {\n
- mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
- gl_FragColor = texture2D( sTexture, vec2( length(vTexCoord), 0.5 ) ) * vec4(mixColor, 1.0) * uColor;\n
- gl_FragColor *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
- }\n
-)
+ // fragment shader for linear gradient
+ SHADER_GRADIENT_VISUAL_LINEAR_SHADER_FRAG,
+
+ // fragment shader for radial gradient
+ SHADER_GRADIENT_VISUAL_RADIAL_SHADER_FRAG,
+
+ // fragment shader for linear gradient with corner radius
+ SHADER_GRADIENT_VISUAL_LINEAR_ROUNDED_CORNER_SHADER_FRAG,
+
+ // fragment shader for radial gradient with corner radius
+ SHADER_GRADIENT_VISUAL_RADIAL_ROUNDED_CORNER_SHADER_FRAG
};
Dali::WrapMode::Type GetWrapMode( Toolkit::GradientVisual::SpreadMethod::Type spread )
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali/integration-api/debug.h>
namespace Dali
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
-const char* VERTEX_SHADER =
- "INPUT mediump vec2 aPosition;\n"
- "OUTPUT mediump vec2 vTexCoord;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
- "uniform mediump vec4 pixelArea;"
- "//Visual size and offset\n"
-
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
- "uniform mediump vec2 extraSize;\n"
-
- "vec4 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
- "}\n"
- "\n"
- "void main()\n"
- "{\n"
- " gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
- " vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n"
- "}\n";
-
-const char* FRAGMENT_SHADER_NO_ATLAS =
- "INPUT mediump vec2 vTexCoord;\n"
-
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform lowp float preMultipliedAlpha;\n"
-
- "void main()\n"
- "{\n"
- " OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n"
- "}\n";
-
-
-const char* FRAGMENT_SHADER_ATLAS_CLAMP =
- "INPUT mediump vec2 vTexCoord;\n"
-
- "uniform sampler2D sTexture;\n"
- "uniform mediump vec4 uAtlasRect;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform lowp float preMultipliedAlpha;\n"
-
- "void main()\n"
- "{\n"
- " mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );\n"
- " OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );\n"
- "}\n";
-
-
-const char* FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP =
- "INPUT mediump vec2 vTexCoord;\n"
-
- "uniform sampler2D sTexture;\n"
- "uniform mediump vec4 uAtlasRect;\n"
- "// WrapMode -- 0: CLAMP; 1: REPEAT; 2: REFLECT;"
- "uniform lowp vec2 wrapMode;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform lowp float preMultipliedAlpha;\n"
- "mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )\n"
-
- "{\n"
- " mediump float coord;\n"
- " if( wrap > 1.5 )\n // REFLECT"
- " coord = 1.0-abs(fract(coordinate*0.5)*2.0 - 1.0);\n"
- " else \n// warp == 0 or 1"
- " coord = mix(coordinate, fract( coordinate ), wrap);\n"
- " return clamp( mix(range.x, range.y, coord), range.x, range.y );"
- "}\n"
-
- "void main()\n"
- "{\n"
- " mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),"
- " wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );\n"
- " OUT_COLOR = TEXTURE( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );\n"
- "}\n";
-
-const char* VERTEX_SHADER_ROUNDED_CORNER =
- "INPUT mediump vec2 aPosition;\n"
- "OUTPUT mediump vec2 vTexCoord;\n"
- "OUTPUT mediump vec2 vPosition;\n"
- "OUTPUT mediump vec2 vRectSize;\n"
- "OUTPUT mediump float vCornerRadius;\n"
-
- "uniform highp mat4 uMvpMatrix;\n"
- "uniform highp vec3 uSize;\n"
- "uniform mediump vec4 pixelArea;"
-
- "//Visual size and offset\n"
- "uniform mediump vec2 offset;\n"
- "uniform highp vec2 size;\n"
- "uniform mediump vec4 offsetSizeMode;\n"
- "uniform mediump vec2 origin;\n"
- "uniform mediump vec2 anchorPoint;\n"
- "uniform mediump float cornerRadius;\n"
- "uniform mediump float cornerRadiusPolicy;\n"
- "uniform mediump vec2 extraSize;\n"
-
- "vec4 ComputeVertexPosition()\n"
- "{\n"
- " vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n"
- " vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n"
- " mediump float minSize = min( visualSize.x, visualSize.y );\n"
- " vCornerRadius = mix( cornerRadius * minSize, cornerRadius, cornerRadiusPolicy);\n"
- " vCornerRadius = min( vCornerRadius, minSize * 0.5 );\n"
- " vRectSize = visualSize * 0.5 - vCornerRadius;\n"
- " vPosition = aPosition* visualSize;\n"
- " return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position = uMvpMatrix * ComputeVertexPosition();\n"
- " vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n"
- "}\n";
-
-
-//float distance = length( max( abs( position - center ), size ) - size ) - radius;
-const char* FRAGMENT_SHADER_ROUNDED_CORNER =
- "INPUT mediump vec2 vTexCoord;\n"
- "INPUT mediump vec2 vPosition;\n"
- "INPUT mediump vec2 vRectSize;\n"
- "INPUT mediump float vCornerRadius;\n"
-
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform lowp vec3 mixColor;\n"
- "uniform lowp float preMultipliedAlpha;\n"
-
- "void main()\n"
- "{\n"
- " mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n"
- " mediump float opacity = 1.0 - smoothstep( -1.0, 1.0, dist );\n"
-
- " OUT_COLOR = TEXTURE( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n"
- " OUT_COLOR.a *= opacity;\n"
- " OUT_COLOR.rgb *= mix( 1.0, opacity, preMultipliedAlpha );\n"
- "}\n";
-
// global string variable to caching complate vertex shader
static std::string gVertexShader;
shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ATLAS_CLAMP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(),
+ Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_ATLAS_CLAMP_SHADER_FRAG.data() );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_CUSTOM_WRAP );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(),
+ Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_ATLAS_VARIOUS_WRAP_SHADER_FRAG.data() );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_CUSTOM_WRAP, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ROUNDED_CORNER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUNDED_CORNER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_ROUNDED_CORNER_SHADER_VERT.data(),
+ Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_ROUNDED_CORNER_SHADER_FRAG.data() );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ROUNDED_CORNER, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER );
if( !shader )
{
- shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_NO_ATLAS );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data(),
+ Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_NO_ATLAS_SHADER_FRAG.data() );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER, shader );
}
{
if(gVertexShader.empty())
{
- gVertexShader = Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER;
+ gVertexShader = Dali::Shader::GetVertexShaderPrefix() + SHADER_IMAGE_VISUAL_SHADER_VERT.data();
}
return gVertexShader;
{
if(gFragmentShaderNoAtlas.empty())
{
- gFragmentShaderNoAtlas = Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_NO_ATLAS;
+ gFragmentShaderNoAtlas = Dali::Shader::GetFragmentShaderPrefix() + SHADER_IMAGE_VISUAL_NO_ATLAS_SHADER_FRAG.data();
}
return gFragmentShaderNoAtlas;
}
return new ImageVisual( factoryCache, shaderFactory, imageUrl, size, fittingMode, samplingMode );
}
-ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
- ImageVisualShaderFactory& shaderFactory,
- const VisualUrl& imageUrl,
- ImageDimensions size,
- FittingMode::Type fittingMode,
- Dali::SamplingMode::Type samplingMode )
-: Visual::Base( factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE ),
- mPixelArea( FULL_TEXTURE_RECT ),
+ImageVisual::ImageVisual(VisualFactoryCache& factoryCache,
+ ImageVisualShaderFactory& shaderFactory,
+ const VisualUrl& imageUrl,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode)
+: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE),
+ mPixelArea(FULL_TEXTURE_RECT),
mPlacementActor(),
- mImageUrl( imageUrl ),
- mMaskingData( ),
- mDesiredSize( size ),
- mTextureId( TextureManager::INVALID_TEXTURE_ID ),
+ mImageUrl(imageUrl),
+ mMaskingData(),
+ mDesiredSize(size),
+ mTextureId(TextureManager::INVALID_TEXTURE_ID),
mTextures(),
- mImageVisualShaderFactory( shaderFactory ),
- mFittingMode( fittingMode ),
- mSamplingMode( samplingMode ),
- mWrapModeU( WrapMode::DEFAULT ),
- mWrapModeV( WrapMode::DEFAULT ),
- mLoadPolicy( Toolkit::ImageVisual::LoadPolicy::ATTACHED ),
- mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DETACHED ),
- mAtlasRect( 0.0f, 0.0f, 0.0f, 0.0f ),
- mAtlasRectSize( 0, 0 ),
- mAttemptAtlasing( false ),
- mLoading( false ),
- mOrientationCorrection( true )
+ mImageVisualShaderFactory(shaderFactory),
+ mFittingMode(fittingMode),
+ mSamplingMode(samplingMode),
+ mWrapModeU(WrapMode::DEFAULT),
+ mWrapModeV(WrapMode::DEFAULT),
+ mLoadPolicy(Toolkit::ImageVisual::LoadPolicy::ATTACHED),
+ mReleasePolicy(Toolkit::ImageVisual::ReleasePolicy::DETACHED),
+ mAtlasRect(0.0f, 0.0f, 0.0f, 0.0f),
+ mAtlasRectSize(0, 0),
+ mLoadState(TextureManager::LoadState::NOT_STARTED),
+ mAttemptAtlasing(false),
+ mOrientationCorrection(true)
{
EnablePreMultipliedAlpha( mFactoryCache.GetPreMultiplyOnLoad() );
}
? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
: TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
- textures = textureManager.LoadTexture( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode,
- mMaskingData, IsSynchronousLoadingRequired(), mTextureId,
- atlasRect, mAtlasRectSize, atlasing, mLoading, mWrapModeU,
- mWrapModeV, textureObserver, atlasUploadObserver, atlasManager,
- mOrientationCorrection, forceReload, preMultiplyOnLoad);
+ bool synchronousLoading = IsSynchronousLoadingRequired();
+ bool loadingStatus;
+
+ textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, mWrapModeU, mWrapModeV, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
if( textures )
{
+ if(loadingStatus)
+ {
+ mLoadState = TextureManager::LoadState::LOADING;
+ }
+ else
+ {
+ mLoadState = TextureManager::LoadState::LOAD_FINISHED;
+ }
+
EnablePreMultipliedAlpha( preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD );
}
+ else if(synchronousLoading)
+ {
+ // Synchronous loading is failed
+ mLoadState = TextureManager::LoadState::LOAD_FAILED;
+ }
if( atlasing ) // Flag needs to be set before creating renderer
{
mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
}
- if( mLoading == false )
+ if(mLoadState == TextureManager::LoadState::LOAD_FINISHED)
{
actor.AddRenderer( mImpl->mRenderer );
mPlacementActor.Reset();
// Image loaded and ready to display
ResourceReady( Toolkit::Visual::ResourceStatus::READY );
}
+ else if(mLoadState == TextureManager::LoadState::LOAD_FAILED)
+ {
+ Texture brokenImage = mFactoryCache.GetBrokenVisualImage();
+
+ mTextures = TextureSet::New();
+ mTextures.SetTexture(0u, brokenImage);
+ mImpl->mRenderer.SetTextures(mTextures);
+
+ actor.AddRenderer(mImpl->mRenderer);
+ mPlacementActor.Reset();
+
+ ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+ }
}
void ImageVisual::DoSetOffScene( Actor& actor )
{
RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+ mLoadState = TextureManager::LoadState::NOT_STARTED;
}
- mLoading = false;
mImpl->mRenderer.Reset();
mPlacementActor.Reset();
}
// reset the weak handle so that the renderer only get added to actor once
mPlacementActor.Reset();
}
+
// Image loaded
ResourceReady( Toolkit::Visual::ResourceStatus::READY );
- mLoading = false;
+ mLoadState = TextureManager::LoadState::LOAD_FINISHED;
}
// From Texture Manager
if( loadingSuccess )
{
resourceStatus = Toolkit::Visual::ResourceStatus::READY;
+ mLoadState = TextureManager::LoadState::LOAD_FINISHED;
}
else
{
resourceStatus = Toolkit::Visual::ResourceStatus::FAILED;
+ mLoadState = TextureManager::LoadState::LOAD_FAILED;
}
// use geometry if needed
// Signal to observers ( control ) that resources are ready. Must be all resources.
ResourceReady( resourceStatus );
- mLoading = false;
}
void ImageVisual::RemoveTexture()
Dali::Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy;
Vector4 mAtlasRect;
Dali::ImageDimensions mAtlasRectSize;
+ TextureManager::LoadState mLoadState; ///< The texture loading state
bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
- bool mLoading; ///< True if the texture is still loading.
bool mOrientationCorrection; ///< true if the image will have it's orientation corrected.
};
-
-
} // namespace Internal
} // namespace Toolkit
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
-//Shaders
-//If a shader requires certain textures, they must be listed in order,
-//as detailed in the TextureIndex enum documentation.
-
-//A basic shader that doesn't use textures at all.
-const char* SIMPLE_VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec3 aNormal;\n
- varying mediump vec3 vIllumination;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;\n
- uniform mediump mat4 uViewMatrix;\n
- uniform mediump mat3 uNormalMatrix;
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 lightPosition;\n
- uniform mediump vec2 uStageOffset;\n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform mediump vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- float scaleFactor = min( visualSize.x, visualSize.y );\n
- vec3 originFlipY = vec3(origin.x, -origin.y, 0.0);
- vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- vec4 normalisedVertexPosition = ComputeVertexPosition();\n
- vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- //Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
- vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
-
- vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
- mvLightPosition = uViewMatrix * mvLightPosition;\n
- vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-
- float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );\n
- vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
-
- gl_Position = vertexPosition;\n
- }\n
-);
-
-//Fragment shader corresponding to the texture-less shader.
-const char* SIMPLE_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec3 vIllumination;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- uniform lowp float preMultipliedAlpha;\n
-
- void main()\n
- {\n
- gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a ) * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-//Diffuse and specular illumination shader with albedo texture. Texture is index 0.
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- attribute highp vec3 aNormal;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vIllumination;\n
- varying mediump float vSpecular;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;
- uniform mediump mat4 uViewMatrix;\n
- uniform mediump mat3 uNormalMatrix;
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 lightPosition;\n
- uniform mediump vec2 uStageOffset;\n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform mediump vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- float scaleFactor = min( visualSize.x, visualSize.y );\n
- vec3 originFlipY = vec3(origin.x, -origin.y, 0.0);
- vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
- }\n
-
- void main()
- {\n
- vec4 normalisedVertexPosition = ComputeVertexPosition();\n
- vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- //Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
- vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );\n
-
- vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
- mvLightPosition = uViewMatrix * mvLightPosition;\n
- vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-
- vec3 viewDirection = normalize( -mvVertexPosition.xyz );
-
- float lightDiffuse = dot( vectorToLight, normal );\n
- lightDiffuse = max( 0.0,lightDiffuse );\n
- vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
-
- vec3 reflectDirection = reflect( -vectorToLight, normal );
- vSpecular = pow( max( dot( reflectDirection, viewDirection ), 0.0 ), 4.0 );
-
- vTexCoord = aTexCoord;\n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-//Fragment shader corresponding to the diffuse and specular illumination shader with albedo texture
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vIllumination;\n
- varying mediump float vSpecular;\n
- uniform sampler2D sDiffuse;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- uniform lowp float preMultipliedAlpha;\n
-
- void main()\n
- {\n
- vec4 texture = texture2D( sDiffuse, vTexCoord );\n
- vec4 visualMixColor = vec4( mixColor, 1.0 );\n
- gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb * visualMixColor.rgb + vSpecular * 0.3, texture.a * uColor.a * visualMixColor.a );\n
- }\n
-);
-
-//Diffuse and specular illumination shader with albedo texture, normal map and gloss map shader.
-//Diffuse (albedo) texture is index 0, normal is 1, gloss is 2. They must be declared in this order.
-const char* NORMAL_MAP_VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- attribute highp vec3 aNormal;\n
- attribute highp vec3 aTangent;\n
- attribute highp vec3 aBiNormal;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vLightDirection;\n
- varying mediump vec3 vHalfVector;\n
- uniform mediump vec3 uSize;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;
- uniform mediump mat4 uViewMatrix;\n
- uniform mediump mat3 uNormalMatrix;
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 lightPosition;\n
- uniform mediump vec2 uStageOffset;\n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform mediump vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- float scaleFactor = min( visualSize.x, visualSize.y );\n
- vec3 originFlipY = vec3(origin.x, -origin.y, 0.0);
- vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
- }\n
-
- void main()
- {\n
- vec4 normalisedVertexPosition = ComputeVertexPosition();\n
- vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
-
- vec3 tangent = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aTangent );
- vec3 binormal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aBiNormal );
- vec3 normal = normalize( uNormalMatrix * mat3( uObjectMatrix ) * aNormal );
-
- vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
- mvLightPosition = uViewMatrix * mvLightPosition;\n
- vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
- vLightDirection.x = dot( vectorToLight, tangent );
- vLightDirection.y = dot( vectorToLight, binormal );
- vLightDirection.z = dot( vectorToLight, normal );
-
- vec3 viewDirection = normalize( -mvVertexPosition.xyz );
- vec3 halfVector = normalize( viewDirection + vectorToLight );
- vHalfVector.x = dot( halfVector, tangent );
- vHalfVector.y = dot( halfVector, binormal );
- vHalfVector.z = dot( halfVector, normal );
-
- vTexCoord = aTexCoord;\n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-//Fragment shader corresponding to the shader that uses all textures (diffuse, normal and gloss maps)
-const char* NORMAL_MAP_FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec3 vLightDirection;\n
- varying mediump vec3 vHalfVector;\n
- uniform sampler2D sDiffuse;\n
- uniform sampler2D sNormal;\n
- uniform sampler2D sGloss;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- uniform lowp float preMultipliedAlpha;\n
-
- void main()\n
- {\n
- vec4 texture = texture2D( sDiffuse, vTexCoord );\n
- vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n
- vec4 glossMap = texture2D( sGloss, vTexCoord );\n
- vec4 visualMixColor = vec4( mixColor, 1.0 );\n
-
- float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );\n
- lightDiffuse = lightDiffuse * 0.5 + 0.5;\n
-
- float shininess = pow ( max ( dot ( normalize( vHalfVector ), normal ), 0.0 ), 16.0 ) ;
-
- gl_FragColor = vec4( texture.rgb * uColor.rgb * visualMixColor.rgb * lightDiffuse + shininess * glossMap.rgb, texture.a * uColor.a * visualMixColor.a );\n
- }\n
-);
-
} // unnamed namespace
MeshVisualPtr MeshVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
void MeshVisual::SupplyEmptyGeometry()
{
mGeometry = Geometry::New();
- mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MESH_VISUAL_SIMPLE_SHADER_VERT, SHADER_MESH_VISUAL_SIMPLE_SHADER_FRAG );
mImpl->mRenderer = Renderer::New( mGeometry, mShader );
DALI_LOG_ERROR( "Initialisation error in mesh visual.\n" );
{
if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING )
{
- mShader = Shader::New( NORMAL_MAP_VERTEX_SHADER, NORMAL_MAP_FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MESH_VISUAL_NORMAL_MAP_SHADER_VERT, SHADER_MESH_VISUAL_NORMAL_MAP_SHADER_FRAG );
}
else if( mShadingMode == Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_SPECULAR_LIGHTING )
{
- mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MESH_VISUAL_SHADER_VERT, SHADER_MESH_VISUAL_SHADER_FRAG );
}
else //Textureless
{
- mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_MESH_VISUAL_SIMPLE_SHADER_VERT, SHADER_MESH_VISUAL_SIMPLE_SHADER_FRAG );
}
UpdateShaderUniforms();
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/rendering-addon.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
namespace
{
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vMaskTexCoord;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];\n
- uniform mediump vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];\n
- \n
-
- // Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
- uniform mediump vec2 extraSize;\n
-
- void main()\n
- {\n
- mediump vec2 fixedFactor = vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );\n
- mediump vec2 stretch = vec2( uNinePatchFactorsX[ int( ( aPosition.x ) * 0.5 ) ].y, uNinePatchFactorsY[ int( ( aPosition.y ) * 0.5 ) ].y );\n
- \n
- mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );\n
- mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );\n
- \n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- \n
- mediump vec4 gridPosition = vec4( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal, 0.0, 1.0 );\n
- mediump vec4 vertexPosition = gridPosition;\n
- vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );\n
- vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
- \n
- vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );\n
- vMaskTexCoord = gridPosition.xy / visualSize;\n
- \n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* VERTEX_SHADER_3X3 = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vMaskTexCoord;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump vec2 uFixed[ 3 ];\n
- uniform mediump vec2 uStretchTotal;\n
- \n
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
- uniform mediump vec2 extraSize;\n
- \n
- void main()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- \n
- mediump vec2 size = visualSize.xy;\n
- \n
- mediump vec2 fixedFactor = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].y );\n
- mediump vec2 stretch = floor( aPosition * 0.5 );\n
- mediump vec2 fixedTotal = uFixed[ 2 ];\n
- \n
- mediump vec4 gridPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );\n
- mediump vec4 vertexPosition = gridPosition;\n
- vertexPosition.xy -= size * vec2( 0.5, 0.5 );\n
- vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;\n
- \n
- vertexPosition = uMvpMatrix * vertexPosition;\n
- \n
- vTexCoord = ( fixedFactor + stretch * uStretchTotal ) / ( fixedTotal + uStretchTotal );\n
- \n
- vMaskTexCoord = gridPosition.xy / size;\n
- gl_Position = vertexPosition;\n
- }\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- uniform lowp float preMultipliedAlpha;\n
- \n
- void main()\n
- {\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_MASK_SHADER = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vMaskTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sMask;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- uniform lowp float preMultipliedAlpha;\n
- uniform mediump float auxiliaryImageAlpha;\n
- \n
- void main()\n
- {\n
- // Where mask image is transparent, all of background image must show through.
- // where mask image is opaque, only mask should be shown
- // where mask is translucent, less of background should be shown.
- // auxiliaryImageAlpha controls how much of mask is visible
-
- mediump vec4 color = texture2D( sTexture, vTexCoord );\n
- mediump vec4 mask = texture2D( sMask, vMaskTexCoord );\n
-
- mediump vec3 mixedColor = color.rgb * mix( 1.0-mask.a, 1.0, 1.0-auxiliaryImageAlpha)
- + mask.rgb*mask.a * auxiliaryImageAlpha;\n
- gl_FragColor = vec4(mixedColor,1.0) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
/**
* @brief Creates the geometry formed from the vertices and indices
NPatchUtility::StretchRanges::SizeType xStretchCount = 0;
NPatchUtility::StretchRanges::SizeType yStretchCount = 0;
- auto fragmentShader = mAuxiliaryPixelBuffer ? FRAGMENT_MASK_SHADER
- : FRAGMENT_SHADER;
+ auto fragmentShader = mAuxiliaryPixelBuffer ? SHADER_NPATCH_VISUAL_MASK_SHADER_FRAG
+ : SHADER_NPATCH_VISUAL_SHADER_FRAG;
auto shaderType = mAuxiliaryPixelBuffer ? VisualFactoryCache::NINE_PATCH_MASK_SHADER
: VisualFactoryCache::NINE_PATCH_SHADER;
shader = mFactoryCache.GetShader( shaderType );
if( DALI_UNLIKELY( !shader ) )
{
- shader = Shader::New( VERTEX_SHADER_3X3, fragmentShader );
+ shader = Shader::New( SHADER_NPATCH_VISUAL_3X3_SHADER_VERT, fragmentShader );
// Only cache vanilla 9 patch shaders
mFactoryCache.SaveShader( shaderType, shader );
}
std::stringstream vertexShader;
vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
<< "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
- << VERTEX_SHADER;
+ << SHADER_NPATCH_VISUAL_SHADER_VERT;
shader = Shader::New( vertexShader.str(), fragmentShader );
}
if( ( xStretchCount == 1 && yStretchCount == 1 ) ||
( xStretchCount == 0 && yStretchCount == 0 ) )
{
- const char* vertexShader = VERTEX_SHADER_3X3;
+ const char* vertexShader = SHADER_NPATCH_VISUAL_3X3_SHADER_VERT.data();
if( !mImpl->mCustomShader->mVertexShader.empty() )
{
std::stringstream vertexShader;
vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
<< "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
- << VERTEX_SHADER;
+ << SHADER_NPATCH_VISUAL_SHADER_VERT;
shader = Shader::New( vertexShader.str(), fragmentShader, hints );
}
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
const char * const NORMAL( "aNormal" );
const char * const INDICES( "aIndices" );
-//A simple shader that applies diffuse lighting to a mono-coloured object.
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute highp vec3 aPosition;\n
- attribute highp vec2 aTexCoord;\n
- attribute highp vec3 aNormal;\n
- varying mediump vec3 vIllumination;\n
- uniform mediump vec3 uSize;\n
- uniform mediump vec3 uObjectDimensions;\n
- uniform mediump mat4 uMvpMatrix;\n
- uniform mediump mat4 uModelView;\n
- uniform mediump mat4 uViewMatrix;\n
- uniform mediump mat3 uNormalMatrix;\n
- uniform mediump mat4 uObjectMatrix;\n
- uniform mediump vec3 lightPosition;\n
- uniform mediump vec2 uStageOffset;\n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform mediump vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- float scaleFactor = min( visualSize.x / uObjectDimensions.x, visualSize.y / uObjectDimensions.y );\n
- vec3 originFlipY = vec3(origin.x, -origin.y, 0.0);
- vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);\n
-
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- vec4 normalisedVertexPosition = ComputeVertexPosition();\n
- vec4 vertexPosition = uObjectMatrix * normalisedVertexPosition;\n
- vertexPosition = uMvpMatrix * vertexPosition;\n
-
- //Illumination in Model-View space - Transform attributes and uniforms\n
- vec4 mvVertexPosition = uModelView * normalisedVertexPosition;\n
- vec3 normal = uNormalMatrix * mat3( uObjectMatrix ) * aNormal;\n
-
- vec4 mvLightPosition = vec4( ( lightPosition.xy - uStageOffset ), lightPosition.z, 1.0 );\n
- mvLightPosition = uViewMatrix * mvLightPosition;\n
- vec3 vectorToLight = normalize( mvLightPosition.xyz - mvVertexPosition.xyz );\n
-
- float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );\n
- vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );\n
-
- gl_Position = vertexPosition;\n
- }\n
-);
-
-//Very simple fragment shader that merely applies the vertex shading to the color at each fragment.
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
- precision mediump float;\n
- varying mediump vec3 vIllumination;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- void main()\n
- {\n
- vec4 baseColor = vec4(mixColor, 1.0) * uColor;\n
- gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );\n
- }\n
-);
-
} // unnamed namespace
PrimitiveVisualPtr PrimitiveVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
void PrimitiveVisual::CreateShader()
{
- mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ mShader = Shader::New( SHADER_PRIMITIVE_VISUAL_SHADER_VERT, SHADER_PRIMITIVE_VISUAL_SHADER_FRAG );
UpdateShaderUniforms();
}
Shader shader;
if( !mImpl->mCustomShader )
{
- shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, false );
+ shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, IsRoundedCornerRequired() );
}
else
{
#include <dali-toolkit/internal/text/script-run.h>
#include <dali-toolkit/internal/text/text-enumerations-impl.h>
#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
{
const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump vec4 pixelArea;\n
-
- varying mediump vec2 vTexCoord;\n
-
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform highp vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- vec4 ComputeVertexPosition()\n
- {\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
- }\n
-
- void main()\n
- {\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uTextColorAnimatable;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump float textTexture = texture2D( sTexture, vTexCoord ).r;\n
-
- // Set the color of the text to what it is animated to.
- gl_FragColor = uTextColorAnimatable * textTexture * uColor * vec4( mixColor, 1.0 );
- }\n
-);
-
-const char* FRAGMENT_SHADER_MULTI_COLOR_TEXT = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-
- gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );
- }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sStyle;\n
- uniform lowp vec4 uTextColorAnimatable;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump float textTexture = texture2D( sTexture, vTexCoord ).r;\n
- mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n
-
- // Draw the text as overlay above the style
- gl_FragColor = ( uTextColorAnimatable * textTexture + styleTexture * ( 1.0 - uTextColorAnimatable.a * textTexture ) ) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sStyle;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
- mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n
-
- // Draw the text as overlay above the style
- gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sMask;\n
- uniform lowp vec4 uTextColorAnimatable;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
- mediump float maskTexture = texture2D( sMask, vTexCoord ).r;\n
-
- // Set the color of non-transparent pixel in text to what it is animated to.
- // Markup text with multiple text colors are not animated (but can be supported later on if required).
- // Emoji color are not animated.
- mediump float vstep = step( 0.0001, textTexture.a );\n
- textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture );\n
-
- // Draw the text as overlay above the style
- gl_FragColor = textTexture * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- uniform sampler2D sTexture;\n
- uniform sampler2D sStyle;\n
- uniform sampler2D sMask;\n
- uniform lowp float uHasMultipleTextColors;\n
- uniform lowp vec4 uTextColorAnimatable;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
- mediump vec4 styleTexture = texture2D( sStyle, vTexCoord );\n
- mediump float maskTexture = texture2D( sMask, vTexCoord ).r;\n
-
- // Set the color of non-transparent pixel in text to what it is animated to.
- // Markup text with multiple text colors are not animated (but can be supported later on if required).
- // Emoji color are not animated.
- mediump float vstep = step( 0.0001, textTexture.a );\n
- textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) );\n
-
- // Draw the text as overlay above the style
- gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
/**
* Return Property index for the given string key
* param[in] stringKey the string index key
shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_MULTI_COLOR_TEXT );
+ shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_MULTI_COLOR_TEXT_SHADER_FRAG );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE );
+ shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_MULTI_COLOR_TEXT_WITH_STYLE_SHADER_FRAG );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT_WITH_STYLE, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT );
+ shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_SHADER_FRAG );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE );
+ shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_STYLE_SHADER_FRAG );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI );
+ shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_EMOJI_SHADER_FRAG );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI, shader );
}
shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI );
+ shader = Shader::New( SHADER_TEXT_VISUAL_SHADER_VERT, SHADER_TEXT_VISUAL_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI_SHADER_FRAG );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI, shader );
}
mExternalTextures(),
mLifecycleObservers(),
mLoadQueue(),
- mBrokenImageUrl(""),
mCurrentTextureId( 0 ),
mQueueLoadFlag(false)
{
}
if( !pixelBuffer )
{
- // use broken image
- pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
- PixelData pixelData;
- if( pixelBuffer )
- {
- pixelData = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
- }
- Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelData.GetPixelFormat(),
- pixelData.GetWidth(), pixelData.GetHeight() );
- texture.Upload( pixelData );
- textureSet = TextureSet::New();
- textureSet.SetTexture( 0u, texture );
+ DALI_LOG_ERROR("TextureManager::LoadAnimatedImageTexture: Synchronous loading is failed\n");
}
else
{
}
if( !data )
{
- // use broken image
- Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mBrokenImageUrl );
- if( pixelBuffer )
- {
- PreMultiply( pixelBuffer, preMultiplyOnLoad );
- data = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer
- }
- Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, data.GetPixelFormat(),
- data.GetWidth(), data.GetHeight() );
- texture.Upload( data );
- textureSet = TextureSet::New();
- textureSet.SetTexture( 0u, texture );
+ DALI_LOG_ERROR("TextureManager::LoadTexture: Synchronous loading is failed\n");
}
else
{
mTextureManager.AsyncLoadComplete( mLoadingInfoContainer, id, pixelBuffer );
}
-void TextureManager::SetBrokenImageUrl(const std::string& brokenImageUrl)
-{
- mBrokenImageUrl = brokenImageUrl;
-}
-
Geometry TextureManager::GetRenderGeometry(TextureId textureId, uint32_t& frontElements, uint32_t& backElements )
{
return RenderingAddOn::Get().IsValid() ?
void RemoveObserver( TextureManager::LifecycleObserver& observer );
/**
- * @brief Set an image to be used when a visual has failed to correctly render
- * @param[in] brokenImageUrl The broken image url.
- */
- void SetBrokenImageUrl(const std::string& brokenImageUrl);
-
- /**
* @brief Returns the geometry associated with texture.
* @param[in] textureId Id of the texture
* @param[out] frontElements number of front elements
std::vector< ExternalTextureInfo > mExternalTextures; ///< Externally provided textures
Dali::Vector<LifecycleObserver*> mLifecycleObservers; ///< Lifecycle observers of texture manager
Dali::Vector<LoadQueueElement> mLoadQueue; ///< Queue of textures to load after NotifyObservers
- std::string mBrokenImageUrl; ///< Broken image url
TextureId mCurrentTextureId; ///< The current value used for the unique Texture Id generation
bool mQueueLoadFlag; ///< Flag that causes Load Textures to be queued.
};
}
Internal::Visual::Base::Impl::Transform::Transform()
-: mOffset( 0.0f,0.0f ),
- mSize( 1.0f,1.0f ),
- mExtraSize( 0.0f,0.0f ),
- mOffsetSizeMode( 0.0f,0.0f,0.0f,0.0f ),
- mOrigin( Toolkit::Align::TOP_BEGIN ),
- mAnchorPoint( Toolkit::Align::TOP_BEGIN )
+: mOffset(0.0f, 0.0f),
+ mSize(1.0f, 1.0f),
+ mExtraSize(0.0f, 0.0f),
+ mOffsetSizeMode(0.0f, 0.0f, 0.0f, 0.0f),
+ mOrigin(Toolkit::Align::TOP_BEGIN),
+ mAnchorPoint(Toolkit::Align::TOP_BEGIN),
+ mOffsetIndex(Property::INVALID_INDEX),
+ mSizeIndex(Property::INVALID_INDEX)
{
}
void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer renderer, Toolkit::Direction::Type direction )
{
- renderer.RegisterProperty( SIZE, mSize );
- renderer.RegisterProperty( OFFSET, direction == Toolkit::Direction::LEFT_TO_RIGHT ? mOffset : mOffset * Vector2(-1.0f,1.0f));
+ mSizeIndex = renderer.RegisterProperty(SIZE, mSize);
+ mOffsetIndex = renderer.RegisterProperty(OFFSET, direction == Toolkit::Direction::LEFT_TO_RIGHT ? mOffset : mOffset * Vector2(-1.0f, 1.0f));
renderer.RegisterProperty( OFFSET_SIZE_MODE, mOffsetSizeMode );
renderer.RegisterProperty( ORIGIN, PointToVector2( mOrigin, direction ) - Vector2(0.5,0.5) );
renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) );
Vector4 mOffsetSizeMode;
Toolkit::Align::Type mOrigin;
Toolkit::Align::Type mAnchorPoint;
+ Property::Index mOffsetIndex;
+ Property::Index mSizeIndex;
};
Renderer mRenderer;
// Update values from Renderer
mImpl->mMixColor = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
+ if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
+ }
+ if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
+ }
if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
{
mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
// Update values from Renderer
mImpl->mMixColor = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
+ if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
+ }
+ if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
+ {
+ mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
+ }
if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
{
mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
{
return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
}
+ else if(key.indexKey == Toolkit::Visual::Transform::Property::OFFSET)
+ {
+ return Dali::Property(mImpl->mRenderer, OFFSET);
+ }
+ else if(key.indexKey == Toolkit::Visual::Transform::Property::SIZE)
+ {
+ return Dali::Property(mImpl->mRenderer, SIZE);
+ }
}
else
{
{
return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
}
+ else if(key.stringKey == OFFSET)
+ {
+ return Dali::Property(mImpl->mRenderer, OFFSET);
+ }
+ else if(key.stringKey == SIZE)
+ {
+ return Dali::Property(mImpl->mRenderer, SIZE);
+ }
}
// Other cases
// Register CORNER_RADIUS property
mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
mImpl->mRenderer.RegisterProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
- index = mImpl->mCornerRadiusIndex;
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+
+ index = mImpl->mCornerRadiusIndex;
mImpl->mNeedCornerRadius = true;
// Change shader
}
mAtlasManager->SetBrokenImage( mBrokenImageUrl );
- mTextureManager.SetBrokenImageUrl( mBrokenImageUrl );
}
} // namespace Internal
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
{
const char * const POSITION_ATTRIBUTE_NAME("aPosition");
const char * const INDEX_NAME("indices");
-
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
-attribute mediump vec2 aPosition;\n
-uniform highp mat4 uMvpMatrix;\n
-uniform highp vec3 uSize;\n
-\n
-
-//Visual size and offset
-uniform mediump vec2 offset;\n
-uniform highp vec2 size;\n
-uniform mediump vec4 offsetSizeMode;\n
-uniform mediump vec2 origin;\n
-uniform mediump vec2 anchorPoint;\n
-
-vec4 ComputeVertexPosition()\n
-{\n
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
- return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
-}\n
-
-void main()\n
-{\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
-}\n
-);
-
-const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
-\n
-void main()\n
-{\n
- gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
-}\n
-);
-
}
WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
Shader shader = mFactoryCache.GetShader( VisualFactoryCache::WIREFRAME_SHADER );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ shader = Shader::New( SHADER_WIREFRAME_VISUAL_SHADER_VERT, SHADER_WIREFRAME_VISUAL_SHADER_FRAG );
mFactoryCache.SaveShader( VisualFactoryCache::WIREFRAME_SHADER, shader );
}
/*
- * 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 TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 6;
+const unsigned int TOOLKIT_MICRO_VERSION = 11;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
{
/**
* @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
- * @details Name "offset", type Property::VECTOR2.
+ * @details Name "offset", type Property::VECTOR2, animatable.
* @SINCE_1_2.60
*
* @see OFFSET_POLICY
/**
* @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
- * @details Name "size", type Property::VECTOR2.
+ * @details Name "size", type Property::VECTOR2, animatable.
* @see SIZE_POLICY
*/
SIZE,
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.0.6
+Version: 2.0.11
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT