INCLUDE(FindPkgConfig)
SET(BIN_DIR "/opt/usr/bin")
+SET(SCRIPT_DIR ${CMAKE_SOURCE_DIR}/scripts)
ADD_DEFINITIONS(-DDALI_STYLE_DIR="@dataReadOnlyDir@/toolkit/styles/")
+# Macro checks if the module is available and sets user variable
+MACRO( CHECK_MODULE_AND_SET PKG_VAR PKG_LIB_REQUIREMENTS VAR_TO_SET )
+ PKG_CHECK_MODULES(${PKG_VAR} "${PKG_LIB_REQUIREMENTS}")
+ IF( ${PKG_VAR}_FOUND )
+ SET( ${VAR_TO_SET} ON )
+ SET( ${VAR_TO_SET}_ENABLED ON )
+ ELSE()
+ SET( ${VAR_TO_SET}_ENABLED OFF )
+ ENDIF()
+ENDMACRO()
+
+SET(ELDBUS_REQUIRED 1.16.0)
+CHECK_MODULE_AND_SET(ELDBUS eldbus>=${ELDBUS_REQUIRED} ELDBUS_AVAILABLE)
+
INCLUDE_DIRECTORIES(
src/common
)
#!/bin/bash
-TEMP=`getopt -o rn --long rebuild,no-gen \
+TEMP=`getopt -o r --long rebuild \
-n 'genmake' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
opt_rebuild=false
-opt_generate=true
while true ; do
case "$1" in
-r|--rebuild) opt_rebuild=true ; shift ;;
- -n|--no-gen) opt_generate=false ; shift ;;
--) shift ; break ;;
*) shift ;; # Ignore
esac
function build
{
- if [ $opt_generate == true -o $opt_rebuild == false ] ; then
- (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
- if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
- fi
(cd build ; cmake .. -DMODULE=$1 ; make -j7 )
}
my $percent = 0;
if($total_exec > 0) { $percent = 100 * $total_covered_lines / $total_exec; }
- return [ $total_exec, $percent ];
+ return [ $total_exec, $percent, $total_covered_lines ];
}
#
print RESET;
}
+printf("Line Coverage: %d/%d\n", $percentref->[2], $percentref->[0]);
printf("Percentage of change covered: %5.2f%\n", $percent);
exit($percent<90);
#!/bin/bash
USAGE=$(cat <<EOF
-Usage note: retriever.sh [option] [directory]
+Usage note: retriever.sh [option] [directory] test-files
Options:
none retrieve TC names with corresponding startup and cleanup functions
- -f retrieveve TC name with corresponding "set" and "purpose" clauses
+ -f retrieve TC name with corresponding "set" and "purpose" clauses
-anum retrieve automatic TC number
-mnum retrieve manual TC number
}')
}
+
+
function tc_names {
if [[ -z "$1" ]]; then
exit
err_flag = 0;
tc_list = "";
}
+ BEGINFILE {
+ start_fun = "NULL";
+ clean_fun = "NULL";
+ }
/^void .*startup\(void\)/ {
gsub(/^void /, "");
gsub(/\(void\)$/,"");
' $*
}
-
-# usage note and exit:
-# - argument begin with '-' but is not recognised or number of arguments is > 3,
-# - argument doesn't begin with '-' and number of arguments is > 2
-if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f)$ || $# > 3 ) ) || ( "$1" != -* && $# > 2 ) ]]; then
- echo -e "$USAGE"
- exit 1
+TEMP=`getopt -o f::,a:,m: --long full::,anum:,mnum: \
+ -n 'retriever.sh' -- "$@"`
+
+if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+
+opt_full=false
+opt_full_dir=
+opt_anum=
+opt_mnum=
+
+while true ; do
+ case "$1" in
+ -f|--full) opt_full_dir="$2" ; opt_full="true" ; shift 2 ;;
+ -a|--anum) opt_anum="$2" ; shift 2 ;;
+ -m|--mnum) opt_mnum="$2" ; shift 2 ;;
+ --) shift ; break ;;
+ *) echo -e $USAGE ; exit 1 ;;
+ esac
+done
+
+#echo "###Retriever" >& 2
+#echo opt_full: {$opt_full} >& 2
+#echo opt_full_dir: {$opt_full_dir} >& 2
+
+DIR=.
+if [ -n "$opt_anum" ] ; then
+ DIR=$opt_anum
+ echo opt_anum: DIR=$DIR >& 2
+elif [ -n "$opt_mnum" ] ; then
+ DIR=$opt_mnum
+ echo opt_mnum: DIR=$DIR >& 2
+elif [ "$opt_full" == "true" ] ; then
+ if [ -n $opt_full_dir ] ; then
+ DIR=$opt_full_dir
+ echo opt_full: DIR=$DIR >& 2
+ fi
fi
-# get directory from last argument (or assume current one)
-if [[ ! "$1" =~ ^-(anum|mnum|f)$ ]]; then
- DIR=${1:-.}
-else
- DIR=${2:-.}
-fi
-# get filename from last argument
-if [[ $# == 3 && -f $DIR/$3 ]] ; then
- FILE=$3
-elif [[ $# == 2 && -f $DIR/$2 ]] ; then
- FILE=$2
+# get filename from first argument
+if [[ $# == 1 && -f $DIR/$1 ]] ; then
+ FILE=$1
+ shift;
fi
#echo "Dir: $DIR File: $FILE" >& 2
-
# populate $TC_FILES with files declared in CMakeLists.txt
if [[ -z $FILE ]]; then
- get_tc_files $DIR
+ if [[ ! $DIR == "." || $# == 0 ]] ; then
+ #echo Get tc files: DIR=$DIR >& 2
+ get_tc_files $DIR
+ else
+ TC_FILES=$(
+ for i in $* ; do
+ echo $DIR/$i
+ done
+ )
+ fi
if [ $? != 0 ]; then
exit 1
fi
- echo "Got all files" >& 2
+ echo "Got all files in `pwd`" >& 2
+ #echo "TC_FILES: $TC_FILES" >& 2
else
TC_FILES="$DIR/$FILE"
echo "TC_FILES: $TC_FILES" >& 2
# run appropriate subcommand
-case "$1" in
- -anum)
- tc_anum $TC_FILES ;;
- -mnum)
- tc_mnum $TC_FILES ;;
- -f)
- tc_fullinfo $TC_FILES ;;
- *)
- tc_names $TC_FILES ;;
-esac
+if [ "$opt_full" == "true" ] ; then
+ tc_fullinfo $TC_FILES
+elif [ -n "$opt_anum" ] ; then
+ tc_anum $TC_FILES
+elif [ -n "$opt_mnum" ] ; then
+ tc_mnum $TC_FILES
+else
+ tc_names $TC_FILES
+fi
#!/bin/bash
if [[ -z $1 ]]; then
- echo "Usage note: tcheadgen.sh <header_filename.h>"
+ echo "Usage note: tcheadgen.sh <header_filename.h> <test-sources>"
exit 1
fi
FILE="$PWD/$1"
+shift
+TC_FILES=$*
TFILE="/tmp/retr.csv$$"
HEADER_NAME=$(echo $1 | tr '[:lower:]' '[:upper:]' | sed -e 's/-/_/g' -e 's/\./_/')
SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
-$SCRIPT_DIR/retriever.sh > $TFILE
+$SCRIPT_DIR/retriever.sh $TC_FILES > $TFILE
if [ $? -ne 0 ]; then cat $TFILE; exit 1; fi
awk -F',' -v HEADER_NAME="$HEADER_NAME" '
BEGIN {
print "#endif // " HEADER_NAME
}' $TFILE > $FILE
unlink $TFILE
-
exit
fi
SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
-AUTO_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh -anum src/$MODULE_NAME)
+AUTO_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh --anum src/$MODULE_NAME)
if [ $? -ne 0 ]; then echo $AUTO_NUM; exit 1; fi
-MAN_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh -mnum src/$MODULE_NAME)
+MAN_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh --mnum src/$MODULE_NAME)
if [ $? -ne 0 ]; then echo $MAN_NUM; exit 1; fi
TFILE="/tmp/tempfile.xml"
fi
function regen {
- awk -v RS='\r\n' -v ORS='\r\n' -v MODULE_NAME=$MODULE_NAME -v AUTO_NUM=$AUTO_NUM -v MAN_NUM=$MAN_NUM '
+ awk -v RS='\r\n' -v ORS='\r\n' -v MODULE_NAME=$MODULE_NAME -v AUTO_NUM=$AUTO_NUM -v MAN_NUM=$MAN_NUM '
BEGIN {
found = 0;
replaced = 0;
}' $TFILE > $FILE
}
-(cd $SCRIPT_DIR/..; scripts/retriever.sh -f src/$MODULE_NAME $4 > ${TFILE}_pre)
+cmd="cd $SCRIPT_DIR/..; scripts/retriever.sh -fsrc/$MODULE_NAME $4 > ${TFILE}_pre"
+echo "$cmd"
+( eval $cmd )
if [ $? -ne 0 ]; then cat ${TFILE}_pre; exit 1; fi
cat ${TFILE}_pre | sort -t',' -k2,2 -s > $TFILE
gen
# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
utc-Dali-AddOns.cpp
- utc-Dali-Accessibility-Accessible.cpp
- utc-Dali-Accessibility-Controls.cpp
- utc-Dali-Accessibility-Controls-BridgeUp.cpp
- utc-Dali-Accessibility-Text.cpp
- utc-Dali-Accessibility-Value.cpp
utc-Dali-BidirectionalSupport.cpp
utc-Dali-ColorConversion.cpp
utc-Dali-Control-internal.cpp
utc-Dali-DebugRendering.cpp
+ utc-Dali-Dictionary.cpp
utc-Dali-FeedbackStyle.cpp
utc-Dali-ItemView-internal.cpp
utc-Dali-LogicalModel.cpp
utc-Dali-VisualUrl.cpp
)
-# Append list of test harness files (Won't get parsed for test cases)
-LIST(APPEND TC_SOURCES
+IF(ELDBUS_AVAILABLE)
+ LIST(APPEND TC_SOURCES
+ utc-Dali-Accessibility-Accessible.cpp
+ utc-Dali-Accessibility-Controls.cpp
+ utc-Dali-Accessibility-Controls-BridgeUp.cpp
+ utc-Dali-Accessibility-Text.cpp
+ utc-Dali-Accessibility-Value.cpp
+ )
+ENDIF()
+
+# List of test harness files (Won't get parsed for test cases)
+SET(TEST_HARNESS_SOURCES
../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
dali-toolkit-test-utils/toolkit-text-utils.cpp
dali-toolkit-test-utils/dummy-visual.cpp
dali-toolkit-test-utils/test-addon-manager.cpp
+)
+
+IF(ELDBUS_AVAILABLE)
+ LIST(APPEND TEST_HARNESS_SOURCES
dali-toolkit-test-utils/accessibility-test-utils.cpp
dali-toolkit-test-utils/dbus-wrapper.cpp
-)
+ )
+ENDIF()
+
PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
dali2-core
ADD_DEFINITIONS(-DTEST_RESOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/../../resources\" )
ADD_DEFINITIONS(-DDALI_ADDONS_PATH=\"${CMAKE_CURRENT_BINARY_DIR}\")
+IF(ELDBUS_AVAILABLE)
+ ADD_COMPILE_OPTIONS(-Wno-error=attributes)
+ ADD_DEFINITIONS(-DELDBUS_ENABLED)
+ENDIF()
+
FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
STRING(STRIP ${CMAKE_CXX_LINK_FLAGS} CMAKE_CXX_LINK_FLAGS)
INCLUDE_DIRECTORIES(
- ../../../
- ${${CAPI_LIB}_INCLUDE_DIRS}
- ../dali-toolkit/dali-toolkit-test-utils
- dali-toolkit-test-utils
+ ../../../
+ ${${CAPI_LIB}_INCLUDE_DIRS}
+ ../dali-toolkit/dali-toolkit-test-utils
+ dali-toolkit-test-utils
)
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+ADD_CUSTOM_COMMAND(
+ COMMAND ../../scripts/tcheadgen.sh ${EXEC_NAME}.h ${TC_SOURCES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT ${EXEC_NAME}.h
+ COMMENT "Generating test tables"
+ )
+
+# Add explicit dependency on auto-generated header.
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.h ${EXEC_NAME}.cpp ${TC_SOURCES} ${TEST_HARNESS_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
-lpthread --coverage -ldl -rdynamic
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/internal/helpers/color-conversion.h>
+#if defined(ELDBUS_ENABLED)
#include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
+#endif
using namespace Dali;
using namespace Dali::Toolkit;
void dali_color_conversion_startup(void)
{
test_return_value = TET_UNDEF;
+#if defined(ELDBUS_ENABLED)
DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+#endif
}
void dali_color_conversion_cleanup(void)
#include <toolkit-environment-variable.h> // for setting environment variable: DALI_DEBUG_RENDERING
+#if defined(ELDBUS_ENABLED)
#include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
+#endif
#include "dummy-control.h"
void dali_debug_rendering_startup(void)
{
test_return_value = TET_UNDEF;
+#if defined(ELDBUS_ENABLED)
DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+#endif
}
void dali_debug_rendering_cleanup(void)
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/builder/dictionary.h>
+using namespace Dali::Toolkit::Internal;
+
+
+std::string_view test_keys[20] =
+{
+ "testkey0", "testkey1", "testkey2", "testkey3", "testkey4", "testkey5", "testkey6", "testkey7", "testkey8", "testkey9",
+ "testkey10", "testkey11", "testkey12", "testkey13", "testkey14", "testkey15", "testkey16", "testkey17", "testkey18", "testkey19"
+};
+
+std::string_view testKeys[20] =
+{
+ "TestKey0", "TestKey1", "TestKey2", "TestKey3", "TestKey4", "TestKey5", "TestKey6", "TestKey7", "TestKey8", "TestKey9",
+ "TestKey10", "TestKey11", "TestKey12", "TestKey13", "TestKey14", "TestKey15", "TestKey16", "TestKey17", "TestKey18", "TestKey19"
+};
+
+
+int UtcDaliBuilderDictionaryNew(void)
+{
+ Dictionary<int> dictionary;
+
+ DictionaryKeys keys;
+ dictionary.GetKeys(keys);
+
+ DALI_TEST_CHECK( keys.empty() );
+ DALI_TEST_EQUALS( keys.size(), 0, TEST_LOCATION );
+ END_TEST;
+}
+
+
+int UtcDaliBuilderDictionaryAdd1(void)
+{
+ Dictionary<int> dictionary;
+
+ for(int i=0; i<10; i++)
+ {
+ char buffer[16];
+ sprintf(buffer, "testkey%d",i);
+ bool added=false;
+ if(i%2 == 0)
+ {
+ added = dictionary.Add(std::string(buffer), i);
+ }
+ else
+ {
+ added = dictionary.Add(buffer, i);
+ }
+ DALI_TEST_EQUALS(added, true, TEST_LOCATION);
+ }
+
+ DictionaryKeys keys;
+ dictionary.GetKeys(keys);
+
+ DALI_TEST_EQUALS( keys.size(), 10, TEST_LOCATION );
+ for(int i=0; i<10; i++)
+ {
+ char buffer[16];
+ sprintf(buffer, "testkey%d",i);
+ auto iter = std::find(keys.begin(), keys.end(), std::string(buffer));
+ DALI_TEST_CHECK(iter != keys.end());
+ }
+
+ END_TEST;
+}
+
+int UtcDaliBuilderDictionaryAdd2(void)
+{
+ Dictionary<int> dictionary;
+
+ for(int i=0; i<10; i++)
+ {
+ char buffer[16];
+ sprintf(buffer, "testkey%d",i);
+ bool added=false;
+ if(i%2 == 0)
+ {
+ added = dictionary.Add(std::string(buffer), i);
+ }
+ else
+ {
+ added = dictionary.Add(buffer, i);
+ }
+ DALI_TEST_EQUALS(added, true, TEST_LOCATION);
+ }
+
+ DictionaryKeys keys;
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 10, TEST_LOCATION );
+
+ bool added = dictionary.Add("testkey5", 1);
+ DALI_TEST_EQUALS(added, false, TEST_LOCATION);
+ DALI_TEST_EQUALS(*dictionary.Find("testkey5"), 5, TEST_LOCATION);
+
+ dictionary.Clear();
+ DALI_TEST_EQUALS(dictionary.Begin()==dictionary.End(), true, TEST_LOCATION);
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliBuilderDictionaryRemoveP(void)
+{
+ Dictionary<int> dictionary;
+
+ for(int i=0; i<10; i++)
+ {
+ bool added=false;
+ added = dictionary.Add(std::string(testKeys[i]), i);
+ DALI_TEST_EQUALS(added, true, TEST_LOCATION);
+ }
+
+ DictionaryKeys keys;
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 10, TEST_LOCATION );
+
+ for(int i=0; i<10; i++)
+ {
+ if(i%2==0)
+ {
+ dictionary.Remove(test_keys[i]); // Should fail (case sensitive)
+ }
+ else
+ {
+ dictionary.Remove(testKeys[i]);
+ }
+ }
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 5, TEST_LOCATION );
+
+ dictionary.Clear();
+ DALI_TEST_EQUALS(dictionary.Begin()==dictionary.End(), true, TEST_LOCATION);
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliBuilderDictionaryRemoveN(void)
+{
+ Dictionary<int> dictionary;
+
+ for(int i=0; i<10; i++)
+ {
+ bool added=false;
+ added = dictionary.Add(std::string(testKeys[i]), i);
+ DALI_TEST_EQUALS(added, true, TEST_LOCATION);
+ }
+
+ DictionaryKeys keys;
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 10, TEST_LOCATION );
+
+ dictionary.Remove("randomkey");
+ dictionary.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 10, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliBuilderDictionaryMerge1(void)
+{
+ // Test that "overlapping" dicts merge into 1 successfully
+ Dictionary<int> dictionary1;
+
+ for(int i=0; i<10; i++)
+ {
+ dictionary1.Add(std::string(test_keys[i]), i);
+ }
+
+ Dictionary<int> dictionary2;
+ for(int i=0; i<20; i++)
+ {
+ dictionary2.Add(std::string(testKeys[i]), i);
+ }
+
+ dictionary1.Merge(dictionary2);
+ DictionaryKeys keys;
+ dictionary1.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 30, TEST_LOCATION ); // Now have 2 case versions of 10 keys :/ - broken by design?
+
+ for(int i=0; i<20;++i)
+ {
+ // Check both cases of keys
+ auto ptr1 = dictionary1.FindConst(test_keys[i]);
+ auto ptr2 = dictionary1.FindConst(testKeys[i]);
+
+ DALI_TEST_CHECK( nullptr != ptr1 );
+ DALI_TEST_CHECK( nullptr != ptr2 );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliBuilderDictionaryMerge2(void)
+{
+ // Test that non-overlapping dicts merge successfully
+ Dictionary<int> dictionary1;
+ for(int i=0; i<10; i++) // Add first 10 from lowercase keys
+ {
+ dictionary1.Add(std::string(test_keys[i]), i);
+ }
+
+ Dictionary<int> dictionary2;
+ for(int i=10; i<20; i++) // add last 10 from capitalized keys
+ {
+ dictionary2.Add(std::string(testKeys[i]), i);
+ }
+
+ dictionary1.Merge(dictionary2);
+ DictionaryKeys keys;
+ dictionary1.GetKeys(keys);
+ DALI_TEST_EQUALS( keys.size(), 20, TEST_LOCATION ); // check it's an amalgam of both
+
+ for(int i=0; i<20;++i)
+ {
+ // Check both cases of keys
+ DALI_TEST_CHECK( nullptr != dictionary1.FindConst(test_keys[i]));
+ DALI_TEST_CHECK( nullptr != dictionary1.FindConst(testKeys[i]));
+ }
+
+ END_TEST;
+}
+
+
+template<typename EntryType>
+struct TestElement
+{
+ std::string key;
+ EntryType entry;
+ TestElement(std::string name, EntryType entry)
+ : key(std::move(name)),
+ entry(std::move(entry))
+ {
+ }
+};
+
+int UtcDaliBuilderDictionaryFindP(void)
+{
+ // Test that non-overlapping dicts merge successfully
+ Dictionary<int> dictionary;
+ for(int i=0; i<10; i++) // Add first 10 from lowercase keys
+ {
+ dictionary.Add(std::string(test_keys[i]), i);
+ }
+
+ // Test that the entries can be directly modified
+ for(int i=0; i<10; i++)
+ {
+ auto entryPtr = dictionary.Find(testKeys[i]);
+ DALI_TEST_CHECK( entryPtr != nullptr );
+ *entryPtr = i+10;
+ }
+
+ for(int i=0; i<10; ++i)
+ {
+ auto entryPtr = dictionary.Find(testKeys[i]);
+ DALI_TEST_CHECK( entryPtr != nullptr );
+ DALI_TEST_EQUALS( *entryPtr, i+10, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/internal/helpers/property-helper.h>
+#if defined(ELDBUS_ENABLED)
#include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
+#endif
using namespace Dali;
using namespace Dali::Toolkit;
void dali_property_helper_startup(void)
{
test_return_value = TET_UNDEF;
+#if defined(ELDBUS_ENABLED)
DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+#endif
}
void dali_property_helper_cleanup(void)
#include <dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h>
#undef private
+#if defined(ELDBUS_ENABLED)
#include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
+#endif
using namespace Dali;
using namespace Toolkit;
void dali_textselectionpopupinternal_startup(void)
{
test_return_value = TET_UNDEF;
+#if defined(ELDBUS_ENABLED)
DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+#endif
}
void dali_textselectionpopupinternal_cleanup(void)
END_TEST;
}
-
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
+#if defined(ELDBUS_ENABLED)
#include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
+#endif
using namespace Dali::Toolkit::Internal;
{
setenv( "LOG_TEXTURE_MANAGER", "3", 1 );
test_return_value = TET_UNDEF;
+#if defined(ELDBUS_ENABLED)
DBusWrapper::Install(std::unique_ptr<DBusWrapper>(new TestDBusWrapper));
+#endif
}
void utc_dali_toolkit_texture_manager_cleanup(void)
utc-Dali-StyleManager.cpp
)
-# Append list of test harness files (Won't get parsed for test cases)
-LIST(APPEND TC_SOURCES
+# List of test harness files (Won't get parsed for test cases)
+SET(TEST_HARNESS_SOURCES
../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
../dali-toolkit/dali-toolkit-test-utils
)
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+ADD_CUSTOM_COMMAND(
+ COMMAND ../../scripts/tcheadgen.sh ${EXEC_NAME}.h ${TC_SOURCES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT ${EXEC_NAME}.h
+ COMMENT "Generating test tables"
+ )
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.h ${EXEC_NAME}.cpp ${TC_SOURCES} ${TEST_HARNESS_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
-lpthread -ldl --coverage
utc-Dali-Flexbox-Layout.cpp
)
-# Append list of test harness files (Won't get parsed for test cases)
-LIST(APPEND TC_SOURCES
+# List of test harness files (Won't get parsed for test cases)
+SET(TEST_HARNESS_SOURCES
../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp
${GTEST_INCLUDE_DIRS}
)
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+ADD_CUSTOM_COMMAND(
+ COMMAND ../../scripts/tcheadgen.sh ${EXEC_NAME}.h ${TC_SOURCES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT ${EXEC_NAME}.h
+ COMMENT "Generating test tables"
+ )
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.h ${EXEC_NAME}.cpp ${TC_SOURCES} ${TEST_HARNESS_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
-lpthread --coverage
utc-Dali-NPatchUtilities.cpp
)
-# Append list of test harness files (Won't get parsed for test cases)
-LIST(APPEND TC_SOURCES
+# List of test harness files (Won't get parsed for test cases)
+SET(TEST_HARNESS_SOURCES
dali-toolkit-test-utils/toolkit-adaptor.cpp
dali-toolkit-test-utils/toolkit-application.cpp
dali-toolkit-test-utils/toolkit-clipboard.cpp
dali-toolkit-test-utils
)
-ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+ADD_CUSTOM_COMMAND(
+ COMMAND ${SCRIPT_DIR}/tcheadgen.sh ${EXEC_NAME}.h ${TC_SOURCES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT ${EXEC_NAME}.h
+ COMMENT "Generating test tables"
+ )
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.h ${EXEC_NAME}.cpp ${TC_SOURCES} ${TEST_HARNESS_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
${${CAPI_LIB}_LIBRARIES}
-lpthread --coverage
return true;
}
+bool TestGlAbstraction::IsAdvancedBlendEquationSupported()
+{
+ return true;
+}
+
+bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
+{
+ return true;
+}
+
+std::string TestGlAbstraction::GetShaderVersionPrefix()
+{
+ return std::string("");
+}
+
+std::string TestGlAbstraction::GetVertexShaderPrefix()
+{
+ return std::string("");
+}
+
+std::string TestGlAbstraction::GetFragmentShaderPrefix()
+{
+ return std::string("");
+}
+
bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
{
return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
bool IsSurfacelessContextSupported() const override;
+ bool IsAdvancedBlendEquationSupported() override;
+
+ bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override;
+
+ std::string GetShaderVersionPrefix();
+
+ std::string GetVertexShaderPrefix();
+
+ std::string GetFragmentShaderPrefix();
+
bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const override;
/* OpenGL ES 2.0 */
{
}
+ inline void BlendBarrier(void)
+ {
+ }
+
private:
inline void AddUniformCallToTraceStack(GLint location, std::string& value)
{
}
}
+void OnResourceReadySignal01( Control control )
+{
+ if(++gResourceReadySignalCounter == 1)
+ {
+ // It makes the first new visual be deleted immediately
+ // The first image will not be loaded.
+ control[ImageView::Property::IMAGE] = Property::Map().Add(ImageVisual::Property::URL, gImage_600_RGB)
+ .Add(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
+ control[ImageView::Property::IMAGE] = TEST_IMAGE_1;
+ }
+}
+
}
-int UtcDaliImageViewSetImageOnResourceReadySignal(void)
+int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
{
tet_infoline("Test setting image from within signal handler.");
END_TEST;
}
+
+int UtcDaliImageViewSetImageOnResourceReadySignal02(void)
+{
+ tet_infoline("Test setting image from within signal handler.");
+
+ ToolkitTestApplication application;
+
+ gResourceReadySignalCounter = 0;
+
+ ImageView imageView = ImageView::New( gImage_34_RGBA );
+ imageView.ResourceReadySignal().Connect( &OnResourceReadySignal01 );
+
+ application.GetScene().Add( imageView );
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ // Wait for loading an image
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gResourceReadySignalCounter, 2, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
+
+ END_TEST;
+}
DALI_TEST_EQUALS( extraSize, Vector2(0.5f,0.5f), TEST_LOCATION );
}
+int UtcDaliVisualSetTransform01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualSetTransform: ColorVisual" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(Visual::Property::OPACITY, 0.5f);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ TestTransform( application, visual );
+ TestMixColor( visual, ColorVisual::Property::MIX_COLOR, Color::BLUE );
+
+ END_TEST;
+}
+
int UtcDaliVisualSetTransform0(void)
{
ToolkitTestApplication application;
application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
+ // Either application.SendNotification() or the trigger can now complete the task.
application.SendNotification();
application.Render();
-
- // renderer is not added to actor until the rasterization is completed.
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
application.GetScene().Add( actor );
+ // Either application.SendNotification() or the trigger can now complete the task.
application.SendNotification();
application.Render();
-
- // renderer is not added to actor until the rasterization is completed.
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
application.GetScene().Add( actor );
visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
+ // Either application.SendNotification() or the trigger can now complete the task.
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
application.SendNotification();
application.Render();
-
- // renderer is not added to actor until the rasterization is completed.
- DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
-
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
#define DALI_TOOLKIT_INTERNAL_BUILDER_DICTIONARY_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* It enables lookup of keys via case-insensitive match.
*/
+using DictionaryKeys = std::vector<std::string>;
-typedef std::vector<std::string> DictionaryKeys;
inline void Merge( DictionaryKeys& toDict, const DictionaryKeys& fromDict )
{
- for( DictionaryKeys::const_iterator fromIter = fromDict.begin(); fromIter != fromDict.end(); ++fromIter )
+ for(const auto& element : fromDict)
{
- const std::string& fromKey = (*fromIter);
- DictionaryKeys::iterator toIter = std::find( toDict.begin(), toDict.end(), fromKey );
- if( toIter == toDict.end() )
+ auto iter = std::find(toDict.cbegin(), toDict.cend(), element);
+ if(iter == toDict.cend())
{
- toDict.push_back( fromKey );
+ toDict.push_back(element);
}
}
}
{
std::string key;
EntryType entry;
- Element( const std::string&name, EntryType entry )
- : key( name ),
- entry( entry )
+ Element(std::string name, EntryType entry)
+ : key(std::move(name)),
+ entry(std::move(entry))
{
}
};
- typedef std::vector<Element> Elements;
+ using Elements = std::vector<Element>;
Elements container;
+ auto FindElementCaseInsensitive(std::string_view key) const
+ {
+ return std::find_if(
+ Begin(), End(), [key](auto& e) { return Dali::CaseInsensitiveStringCompare(e.key, key); });
+ }
+
+ auto FindElement(std::string_view key)
+ {
+ return std::find_if(container.begin(), container.end(), [key](auto& e){
+ return bool(key == e.key);
+ });
+ }
+
public:
/**
* Only allow const iteration over the dictionary
*/
- typedef typename Elements::const_iterator iterator;
+ using iterator = typename Elements::const_iterator;
/**
* Constructor
*/
- Dictionary<EntryType>()
- {
- }
+ Dictionary<EntryType>() = default;
/**
* Add a key value pair to the dictionary.
* If the entry does not already exist, add it to the dictionary
- * using a shallow copy
*/
- bool Add( const std::string& name, const EntryType& entry )
+ bool Add(std::string name, EntryType entry)
{
- for( typename Elements::iterator iter = container.begin(); iter != container.end(); ++iter )
+ auto iter = FindElement(name);
+ if(iter != End())
{
- if( iter->key == name )
- {
- return false;
- }
+ return false;
}
- container.push_back( Element(name, entry) );
+
+ container.push_back(Element(std::move(name), std::move(entry)));
return true;
}
/**
* Add a key-value pair to the dictionary
* If the entry does not already exist, add it to the dictionary
- * (shallow copy)
*/
- bool Add( const char* name, const EntryType& entry )
+ bool Add(const char* name, EntryType entry)
{
- bool result=false;
- if( name != NULL )
+ if(name != nullptr)
{
- std::string theName(name);
- result=Add(theName, entry);
+ return Add(std::string(name), std::move(entry));
}
- return result;
+ return false;
}
/**
* Remove a key value pair from the dictionary.
*/
- void Remove( const std::string& name )
+ void Remove(std::string_view name)
{
- for( typename Elements::iterator iter = container.begin(); iter != container.end(); ++iter )
+ if(!name.empty())
{
- if( iter->key == name )
+ auto iter = FindElement(name);
+
+ if(iter != End())
{
container.erase( iter );
- break;
}
}
}
- /**
- * Remove a key value pair from the dictionary.
- */
- void Remove( const char* name )
- {
- if( name != NULL )
- {
- std::string theName(name);
- Remove(theName);
- }
- }
-
void Merge( const Dictionary<EntryType>& dictionary )
{
- for( typename Elements::const_iterator fromIter = dictionary.container.begin(); fromIter != dictionary.container.end(); ++fromIter )
+ for(const auto& element : dictionary.container)
{
- bool found=false;
- for( typename Elements::iterator toIter = container.begin(); toIter != container.end(); ++toIter )
+ auto iter = FindElement(element.key);
+
+ if(iter == End())
{
- if( fromIter->key == toIter->key )
- {
- found=true;
- toIter->entry = fromIter->entry;
- }
+ container.push_back(Element(element.key, element.entry));
}
- if( !found )
+ else
{
- container.push_back( Element(fromIter->key, fromIter->entry) );
+ iter->entry = element.entry;
}
}
}
* Find the element in the dictionary pointed at by key, and
* insensitive search, and return a const pointer to it, or NULL
*/
- const EntryType* FindConst( const std::string& key ) const
+ const EntryType* FindConst(std::string_view key) const
{
if( ! key.empty() )
{
- for( typename Elements::const_iterator iter = container.begin(); iter != container.end(); ++iter )
+ auto iter = FindElementCaseInsensitive(key);
+
+ if(iter != End())
{
- if( Dali::CaseInsensitiveStringCompare(iter->key, key ))
- {
- const EntryType* result = &(iter->entry);
- return result;
- }
+ return &(iter->entry);
}
}
- return NULL;
+ return nullptr;
}
/**
* Find the element in the dictionary pointed at by key using a case
* insensitive search, and return a non-const pointer to it, or NULL
*/
- EntryType* Find( const std::string& key ) const
+ EntryType* Find(std::string_view key) const
{
- EntryType* result = NULL;
if( ! key.empty() )
{
- for( typename Elements::const_iterator iter = container.begin(); iter != container.end(); ++iter )
+ auto iter = FindElementCaseInsensitive(key);
+
+ if(iter != End())
{
- if( Dali::CaseInsensitiveStringCompare(iter->key, key ))
- {
- // Const cast because of const_iterator. const_iterator because, STL.
- result = const_cast<EntryType*>(&(iter->entry));
- }
+ return const_cast<EntryType*>(&(iter->entry));
}
}
- return result;
- }
-
- /**
- * Find the element in the dictionary pointed at by key using a case
- * insensitive search, and return a const pointer to it, or NULL
- */
- const EntryType* FindConst( const char* key ) const
- {
- if( key != NULL )
- {
- std::string theKey(key);
- return FindConst( theKey );
- }
- return NULL;
+ return nullptr;
}
- /**
- * Find the element in the dictionary pointed at by key using a case
- * insensitive search, and return a non-const pointer to it, or NULL
- */
- EntryType* Find( const char* key ) const
- {
- if( key != NULL )
- {
- std::string theKey(key);
- return Find( theKey );
- }
- return NULL;
- }
- /**
- * Return an iterator pointing at the first entry in the dictionary
- */
- typename Elements::const_iterator Begin() const
+ iterator Begin() const
{
- return container.begin();
+ return container.cbegin();
}
/**
* Return an iterator pointing past the last entry in the dictionary
*/
- typename Elements::const_iterator End() const
+ iterator End() const
{
- return container.end();
+ return container.cend();
}
void GetKeys( DictionaryKeys& keys ) const
{
keys.clear();
- for( typename Elements::const_iterator iter = container.begin(); iter != container.end(); ++iter )
+ for(const auto& element : container)
{
- keys.push_back( (*iter).key );
+ keys.push_back(element.key);
}
}
}
void LoadingTask::Load()
-{;
+{
if( animatedImageLoading )
{
pixelBuffer = animatedImageLoading.LoadFrame( frameIndex );
if( mImpl->mCustomShader )
{
- shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource() : mImpl->mCustomShader->mVertexShader,
- mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource() : mImpl->mCustomShader->mFragmentShader,
+ shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
+ mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
mImpl->mCustomShader->mHints );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
DALI_ENUM_TO_STRING_WITH_SCOPE( DevelArcVisual::Cap, ROUND )
DALI_ENUM_TO_STRING_TABLE_END( CAP )
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- \n
- varying mediump vec2 vPosition;\n
- \n
- //Visual size and offset
- uniform mediump vec2 offset;\n
- uniform mediump vec2 size;\n
- uniform mediump vec4 offsetSizeMode;\n
- uniform mediump vec2 origin;\n
- uniform mediump vec2 anchorPoint;\n
-
- 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 = DALI_COMPOSE_SHADER(
- varying 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
- \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
- \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
- gl_FragColor = vec4( mixColor, 1.0 ) * uColor;\n
- gl_FragColor.a *= GetOpacity();\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_ROUND_CAP = DALI_COMPOSE_SHADER(
- varying 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
- \n
- const mediump float M_PI_OVER_2 = 1.57079632679;\n
- const mediump float M_PI_2 = 6.28318530718;\n
- \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
- gl_FragColor = vec4( mixColor, 1.0 ) * uColor;\n
- gl_FragColor.a *= GetOpacity();\n
- }\n
-);
+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";
}
shader = mFactoryCache.GetShader( VisualFactoryCache::ARC_BUTT_CAP_SHADER );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_BUTT_CAP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_BUTT_CAP );
mFactoryCache.SaveShader( VisualFactoryCache::ARC_BUTT_CAP_SHADER, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::ARC_ROUND_CAP_SHADER );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ROUND_CAP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUND_CAP );
mFactoryCache.SaveShader( VisualFactoryCache::ARC_ROUND_CAP_SHADER, shader );
}
}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/border-visual-properties.h>
const char * const DRIFT_ATTRIBUTE_NAME("aDrift");
const char * const INDEX_NAME("indices");
-
-const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aDrift;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump float borderSize;\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
-
- 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 = DALI_COMPOSE_SHADER(
- uniform lowp vec4 uColor;\n
- uniform lowp vec4 borderColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- gl_FragColor = vec4(mixColor, 1.0)*borderColor*uColor;\n
- }\n
-);
-
-const char* VERTEX_SHADER_ANTI_ALIASING = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- attribute mediump vec2 aDrift;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump float borderSize;\n
- varying mediump float vAlpha;\n
- \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 = DALI_COMPOSE_SHADER(
- uniform lowp vec4 uColor;\n
- uniform lowp vec4 borderColor;\n
- uniform lowp vec3 mixColor;\n
- uniform mediump float borderSize;\n
- varying mediump float vAlpha;\n
- \n
- void main()\n
- {\n
- gl_FragColor = vec4(mixColor, 1.0)*borderColor*uColor;\n
- gl_FragColor.a *= smoothstep(0.0, 1.5, vAlpha)*smoothstep( borderSize+1.5, borderSize, vAlpha );\n
- }\n
-);
+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 )
InitializeRenderer();
mBorderColorIndex = mImpl->mRenderer.RegisterProperty( Toolkit::BorderVisual::Property::COLOR, COLOR_NAME, mBorderColor );
- if( mBorderColor.a < 1.f || mAntiAliasing)
+ if( ( mBorderColor.a < 1.f || mAntiAliasing ) || IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER_ANTI_ALIASING, FRAGMENT_SHADER_ANTI_ALIASING );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ANTI_ALIASING, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ANTI_ALIASING );
mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER_ANTI_ALIASING, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::BORDER_SHADER );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER );
mFactoryCache.SaveShader( VisualFactoryCache::BORDER_SHADER, shader );
}
}
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
//INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
namespace
{
-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
- 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 = DALI_COMPOSE_SHADER(
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- gl_FragColor = vec4(mixColor, 1.0)*uColor;\n
- }\n
-);
-
-const char* VERTEX_SHADER_ROUNDED_CORNER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\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 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
- \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
- \n
- void main()\n
- {\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- }\n
-);
+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 = DALI_COMPOSE_SHADER(
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- varying mediump float vCornerRadius;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- \n
- void main()\n
- {\n
- mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
- gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
- gl_FragColor.a *= 1.0 - smoothstep( -1.0, 1.0, dist );\n
- }\n
-);
-
-const char* VERTEX_SHADER_BLUR_EDGE = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- \n
- //Visual size and offset
- 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
- \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
- \n
- void main()\n
- {\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_BLUR_EDGE = DALI_COMPOSE_SHADER(
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- uniform lowp vec4 uColor;\n
- uniform lowp vec3 mixColor;\n
- uniform mediump float blurRadius;\n
- \n
- void main()\n
- {\n
- mediump vec2 blur = 1.0 - smoothstep( vRectSize - blurRadius * 2.0, vRectSize, abs( vPosition ) );\n
- gl_FragColor = uColor * vec4( mixColor, 1.0 );\n
- gl_FragColor.a *= blur.x * blur.y;\n
- }\n
-);
+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";
}
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER_BLUR_EDGE, FRAGMENT_SHADER_BLUR_EDGE );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_BLUR_EDGE, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_BLUR_EDGE );
mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_BLUR_EDGE, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER );
mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER, shader );
}
}
shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER_ROUNDED_CORNER, FRAGMENT_SHADER_ROUNDED_CORNER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ROUNDED_CORNER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUNDED_CORNER );
mFactoryCache.SaveShader( VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER, shader );
}
}
mImpl->mRenderer.RegisterProperty( BLUR_RADIUS_NAME, mBlurRadius );
- if( mImpl->mMixColor.a < 1.f || !EqualsZero( mBlurRadius ) )
+ if( mImpl->mMixColor.a < 1.f || !EqualsZero( mBlurRadius ) || IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
#include <dali/public-api/object/property-array.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/gradient-visual-properties.h>
mImpl->mRenderer = Renderer::New( geometry, shader );
mImpl->mRenderer.SetTextures( textureSet );
- // If opaque then no need to have blending
- if( mIsOpaque )
+ // If opaque and then no need to have blending
+ if( mIsOpaque && !IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF );
}
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-string-constants.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 = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform highp vec3 uSize;\n
- uniform mediump vec4 pixelArea;
- 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
- uniform mediump vec2 extraSize;\n
-\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 = 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_SHADER_ATLAS_CLAMP = DALI_COMPOSE_SHADER(
- varying 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
- \n
- void main()\n
- {\n
- mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );\n
- gl_FragColor = texture2D( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-const char* FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP = DALI_COMPOSE_SHADER(
- varying 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
- \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
- \n
- void main()\n
- {\n
- mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),
- wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );\n
- gl_FragColor = texture2D( sTexture, texCoord ) * uColor * vec4( mixColor, 1.0 );\n
- }\n
-);
-
-const char* VERTEX_SHADER_ROUNDED_CORNER = DALI_COMPOSE_SHADER(
- attribute mediump vec2 aPosition;\n
- uniform highp mat4 uMvpMatrix;\n
- uniform mediump vec3 uSize;\n
- uniform mediump vec4 pixelArea;
- 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 mediump 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
- \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
-\n
- void main()\n
- {\n
- gl_Position = uMvpMatrix * ComputeVertexPosition();\n
- vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
- }\n
-);
+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 = DALI_COMPOSE_SHADER(
- varying mediump vec2 vTexCoord;\n
- varying mediump vec2 vPosition;\n
- varying mediump vec2 vRectSize;\n
- varying mediump float vCornerRadius;\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
- mediump float dist = length( max( abs( vPosition ), vRectSize ) - vRectSize ) - vCornerRadius;\n
- mediump float opacity = 1.0 - smoothstep( -1.0, 1.0, dist );\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
- gl_FragColor.a *= opacity;\n
- gl_FragColor.rgb *= mix( 1.0, opacity, preMultipliedAlpha );\n
- }\n
-);
+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;
+
+// global string variable to caching complate fragment shader (no atlas)
+static std::string gFragmentShaderNoAtlas;
} // unnamed namespace
shader = factoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
if( !shader )
{
- shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ATLAS_CLAMP );
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( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ATLAS_VARIOUS_WRAP );
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( VERTEX_SHADER_ROUNDED_CORNER, FRAGMENT_SHADER_ROUNDED_CORNER );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER_ROUNDED_CORNER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_ROUNDED_CORNER );
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( VERTEX_SHADER, FRAGMENT_SHADER_NO_ATLAS );
+ shader = Shader::New( Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER, Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_NO_ATLAS );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
factoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER, shader );
}
return shader;
}
-const char* ImageVisualShaderFactory::GetVertexShaderSource()
+std::string_view ImageVisualShaderFactory::GetVertexShaderSource()
{
- return VERTEX_SHADER;
+ if(gVertexShader.empty())
+ {
+ gVertexShader = Dali::Shader::GetVertexShaderPrefix() + VERTEX_SHADER;
+ }
+
+ return gVertexShader;
}
-const char* ImageVisualShaderFactory::GetFragmentShaderSource()
+std::string_view ImageVisualShaderFactory::GetFragmentShaderSource()
{
- return FRAGMENT_SHADER_NO_ATLAS;
+ if(gFragmentShaderNoAtlas.empty())
+ {
+ gFragmentShaderNoAtlas = Dali::Shader::GetFragmentShaderPrefix() + FRAGMENT_SHADER_NO_ATLAS;
+ }
+ return gFragmentShaderNoAtlas;
}
} // namespace Internal
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <string_view>
namespace Dali
{
* Request the default vertex shader source.
* @return The default vertex shader source.
*/
- const char* GetVertexShaderSource();
+ std::string_view GetVertexShaderSource();
/**
* Request the default fragment shader source.
* @return The default fragment shader source.
*/
- const char* GetFragmentShaderSource();
+ std::string_view GetFragmentShaderSource();
protected:
}
else
{
- vertexShader = mImageVisualShaderFactory.GetVertexShaderSource();
+ vertexShader = mImageVisualShaderFactory.GetVertexShaderSource().data();
}
std::string fragmentShader;
}
else
{
- fragmentShader = mImageVisualShaderFactory.GetFragmentShaderSource();
+ fragmentShader = mImageVisualShaderFactory.GetFragmentShaderSource().data();
}
// If the texture is native, we may need to change prefix and sampler in
return mPixelData;
}
-SvgRasterizeThread::SvgRasterizeThread( EventThreadCallback* trigger )
-: mTrigger( std::unique_ptr< EventThreadCallback >(trigger) ),
+SvgRasterizeThread::SvgRasterizeThread()
+: mTrigger( new EventThreadCallback( MakeCallback( this, &SvgRasterizeThread::ApplyRasterizedSVGToSampler ) ) ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() ),
- mIsThreadWaiting( false )
+ mIsThreadWaiting( false ),
+ mProcessorRegistered( false )
{
}
SvgRasterizeThread::~SvgRasterizeThread()
{
+ if( mProcessorRegistered )
+ {
+ Adaptor::Get().UnregisterProcessor( *this );
+ }
}
void SvgRasterizeThread::TerminateThread( SvgRasterizeThread*& thread )
}
}
mRasterizeTasks.push_back( task );
+
+ if( !mProcessorRegistered )
+ {
+ Adaptor::Get().RegisterProcessor( *this );
+ mProcessorRegistered = true;
+ }
}
if( wasEmpty)
}
}
}
+
+ UnregisterProcessor();
}
void SvgRasterizeThread::DeleteImage( VectorImageRenderer vectorRenderer )
}
}
+void SvgRasterizeThread::ApplyRasterizedSVGToSampler()
+{
+ while( RasterizingTaskPtr task = NextCompletedTask() )
+ {
+ task->GetSvgVisual()->ApplyRasterizedImage(task->GetVectorRenderer(), task->GetPixelData(), task->IsLoaded());
+ }
+
+ UnregisterProcessor();
+}
+
+void SvgRasterizeThread::Process()
+{
+ ApplyRasterizedSVGToSampler();
+}
+
+void SvgRasterizeThread::UnregisterProcessor()
+{
+ if ( mProcessorRegistered )
+ {
+ if( mRasterizeTasks.empty() && mCompletedTasks.empty() )
+ {
+ Adaptor::Get().UnregisterProcessor( *this );
+ mProcessorRegistered = false;
+ }
+ }
+}
+
+
} // namespace Internal
} // namespace Toolkit
#include <dali/public-api/rendering/texture-set.h>
#include <dali/devel-api/adaptor-framework/vector-image-renderer.h>
#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
+#include <dali/integration-api/processor-interface.h>
#include <memory>
// INTERNAL INCLUDES
/**
* The worker thread for SVG rasterization.
*/
-class SvgRasterizeThread : public Thread
+class SvgRasterizeThread : public Thread, Integration::Processor
{
public:
*
* @param[in] trigger The trigger to wake up the main thread.
*/
- SvgRasterizeThread( EventThreadCallback* trigger );
+ SvgRasterizeThread();
/**
* Terminate the svg rasterize thread, join and delete.
*/
void DeleteImage( VectorImageRenderer vectorImage );
+ /**
+ * @copydoc Dali::Integration::Processor::Process()
+ */
+ void Process() override;
+
private:
/**
*/
void AddCompletedTask( RasterizingTaskPtr task );
+ /**
+ * Applies the rasterized image to material
+ */
+ void ApplyRasterizedSVGToSampler();
+
+ /**
+ * @brief Unregister a previously registered processor
+ *
+ */
+ void UnregisterProcessor();
+
protected:
/**
std::unique_ptr< EventThreadCallback > mTrigger;
const Dali::LogFactoryInterface& mLogFactory;
bool mIsThreadWaiting;
+ bool mProcessorRegistered;
};
} // namespace Internal
}
else
{
- shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource() : mImpl->mCustomShader->mVertexShader,
- mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource() : mImpl->mCustomShader->mFragmentShader,
+ shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
+ mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
mImpl->mCustomShader->mHints );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
{
auto textureId = textureInfo.textureId;
mLoadQueue.PushBack( LoadQueueElement( textureId, observer) );
+
+ observer->DestructionSignal().Connect( this, &TextureManager::ObserverDestroyed );
}
void TextureManager::LoadTexture( TextureInfo& textureInfo, TextureUploadObserver* observer )
{
for( auto&& element : mLoadQueue )
{
+ if( !element.mObserver )
+ {
+ continue;
+ }
+
int cacheIndex = GetCacheIndexFromId( element.mTextureId );
if( cacheIndex != INVALID_CACHE_INDEX )
{
}
}
}
+
+ // Remove element from the LoadQueue
+ for( auto&& element : mLoadQueue )
+ {
+ if( element.mObserver == observer )
+ {
+ element.mObserver = nullptr;
+ }
+ }
}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
}
+bool Visual::Base::IsAdvancedBlendEquationApplied() const
+{
+ return IsPreMultipliedAlphaEnabled() && DevelRenderer::IsAdvancedBlendEquationApplied( mImpl->mRenderer );
+}
+
void Visual::Base::DoSetOffScene( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
Vector3(mImpl->mMixColor) );
}
- if( mImpl->mMixColor.a < 1.f )
+ if( mImpl->mMixColor.a < 1.f || IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
{
mImpl->mRenderer.SetProperty( mImpl->mMixColorIndex, Vector3(color) );
mImpl->mRenderer.SetProperty( DevelRenderer::Property::OPACITY, color.a );
- if( color.a < 1.f )
+ if( color.a < 1.f || IsAdvancedBlendEquationApplied() )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
}
{
// Ensure the blend mode is turned on if we are animating opacity, and
// turned off after the animation ends if the final value is opaque
- if( ! isInitialOpaque || mImpl->mMixColor.a < 1.0f )
+ if( ( ! isInitialOpaque || mImpl->mMixColor.a < 1.0f ) ||
+ ( mImpl->mRenderer && IsAdvancedBlendEquationApplied() ) )
{
if( mImpl->mRenderer )
{
if( mImpl->mRenderer )
{
DALI_LOG_INFO( gVisualBaseLogFilter, Debug::General, "Visual::Base::OnMixColorFinished()\n");
- mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE,
- ( mImpl->mMixColor.a < 1.0 ) ? BlendMode::ON : BlendMode::AUTO );
+
+ if( mImpl->mMixColor.a >= 1.f &&
+ !IsAdvancedBlendEquationApplied() )
+ {
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::AUTO );
+ }
+ else
+ {
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
+ }
}
delete mImpl->mBlendSlotDelegate;
mImpl->mBlendSlotDelegate = NULL;
bool IsPreMultipliedAlphaEnabled() const;
/**
+ * @brief Query whether advanced blend equation is applied.
+ *
+ * @return True is advanced blend equation is applied, false otherwise.
+ */
+ bool IsAdvancedBlendEquationApplied() const;
+
+ /**
* @brief Sets properties of custom shader
* @param[in] propertyMap Property map containing the custom shader data
*/
{
if( !mSvgRasterizeThread )
{
- mSvgRasterizeThread = new SvgRasterizeThread( new EventThreadCallback( MakeCallback( this, &VisualFactoryCache::ApplyRasterizedSVGToSampler ) ) );
+ mSvgRasterizeThread = new SvgRasterizeThread();
mSvgRasterizeThread->Start();
}
return mSvgRasterizeThread;
return *mVectorAnimationManager;
}
-void VisualFactoryCache::ApplyRasterizedSVGToSampler()
-{
- while( RasterizingTaskPtr task = mSvgRasterizeThread->NextCompletedTask() )
- {
- task->GetSvgVisual()->ApplyRasterizedImage(task->GetVectorRenderer(), task->GetPixelData(), task->IsLoaded());
- }
-}
-
Geometry VisualFactoryCache::CreateGridGeometry( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
*/
VectorAnimationManager& GetVectorAnimationManager();
-private: // for svg rasterization thread
-
- /**
- * Applies the rasterized image to material
- */
- void ApplyRasterizedSVGToSampler();
-
protected:
/**
{
namespace Toolkit
{
-const unsigned int TOOLKIT_MAJOR_VERSION = 1;
-const unsigned int TOOLKIT_MINOR_VERSION = 9;
-const unsigned int TOOLKIT_MICRO_VERSION = 36;
+const unsigned int TOOLKIT_MAJOR_VERSION = 2;
+const unsigned int TOOLKIT_MINOR_VERSION = 0;
+const unsigned int TOOLKIT_MICRO_VERSION = 0;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.9.36
+Version: 2.0.0
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT