Executing the tests
-------------------
+To see a list of all of the options:
+
+ ./execute.sh -h
+
To execute tests, cd into automated-tests and run
./execute.sh
This will execute dali and dali-internal test sets. Note that the output summary for the first will be printed before running the second.
-By default the tests execute in parallel, which is faster but does not produce any test case output. Use this to execute the tests in series:
+By default the tests execute in parallel, which is faster but does not produce any test case output files. Use this to execute the tests in series and log test output to stdout/err
- ./execute.sh -s
+ ./execute.sh -S
-To see the results, copy the style folder from web-tct_2.2.1_r1/tools/tct-mgr/style into automated-tests and run
+To use test kit lite, (which is very slow),
- firefox --new-window summary.xml
+ ./execute.sh -s
-To see a list of all of the options:
+To see the test kit lite results, copy the style folder from web-tct_2.2.1_r1/tools/tct-mgr/style into automated-tests and run
- ./execute.sh -h
+ firefox --new-window summary.xml
To execute a subset of tests, you can run individual test sets, e.g.
- ./execute.sh dali
+ ./execute.sh dali-toolkit
-To get coverage output, run
+To get coverage output (you need to first build dali libraries with
+--coverage), run
./coverage.sh
On desktop, you can debug the tests by running gdb on the test program:
$ cd automated-tests
- $ gdb build/src/dali/tct-dali-core
+ $ gdb build/src/dali-toolkit/tct-dali-toolkit-core
gdb> r <TestCase>
replace `<TestCase>` with the name of the failing testcase.
-For example, using testcase UtcDaliNinePatch01 from the dali-core test suite:
+For example, using testcase UtcDaliControlBackgroundProperties from the dali-toolkit test suite:
- $ gdb build/src/dali/tct-dali-core
- gdb> r UtcDaliNinePatch01
+ $ gdb build/src/dali-toolkit/tct-dali-toolkit-core
+ gdb> r UtcDaliControlBackgroundProperties
On target, you can re-install the test RPM and associated debug RPMs manually using
After installing the rpm and it's debug RPMs, you can find the executable in /opt/usr/bin/tct-dali-core. First ensure you have smack permissions set:
chsmack -e "^" /usr/bin/gdb
- chsmack -e "^" /opt/usr/bin/tct-dali-core/tct-dali-core
+ chsmack -e "^" /opt/usr/bin/tct-dali-toolkit-core/tct-dali-toolkit-core
then run it under gdb as above.
fi
done
fi
+
+echo "Build succeeded"
+exit 0
#!/bin/bash
-TEMP=`getopt -o hsr --long help,serial,rerun -n 'execute.sh' -- "$@"`
+TEMP=`getopt -o hsSm --long help,serial,tct,modules -n 'execute.sh' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
function usage
{
- echo -e "Usage: execute.sh\t\tExecute test cases from all modules in parallel"
- echo -e " execute.sh <testmodule>\tExecute test cases from the given module in parallel"
- echo -e " execute.sh -s\t\tExecute test cases in serial using Testkit-Lite"
- echo -e " execute.sh -r\t\tExecute test cases in parallel, re-running failed test cases in serial afterwards"
+ echo -e "Usage: execute.sh [-s|-S|-r] [module|testcase]"
+ echo -e " execute.sh\t\tExecute test cases from all modules in parallel"
+ 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 <testcase>\tFind and execute the given test case"
exit 2
}
-opt_serial=0
-opt_rerun=""
+opt_tct=0
+opt_serial=""
+opt_modules=0
while true ; do
case "$1" in
-h|--help) usage ;;
- -s|--serial) opt_serial=1 ; shift ;;
- -r|--rerun) opt_rerun="-r" ; shift ;;
+ -s|--tct) opt_tct=1 ; shift ;;
+ -S|--serial) opt_serial="-s" ; shift ;;
+ -m|--modules) opt_modules=1 ; shift ;;
--) shift; break;;
*) echo "Internal error $1!" ; exit 1 ;;
esac
done
-function execute
+function execute_tct
{
scripts/tctestsgen.sh $1 `pwd` desktop $2
testkit-lite -f `pwd`/tests.xml -o tct-${1}-core-tests.xml -A --comm localhost
scripts/add_style.pl $1
}
+function summary_start
+{
+ start=`date +"%Y-%m-%d_%H_%M_%S"`
+ cat > summary.xml <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="./style/summary.xsl"?>
+<result_summary plan_name="Core">
+ <other xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" />
+ <summary test_plan_name="Dali">
+ <start_at>$start</start_at>
+ <end_at>$start</end_at>
+ </summary>
+EOF
+}
+
+function summary_end
+{
+ cat >> summary.xml <<EOF
+</result_summary>
+EOF
+}
+if [ $opt_modules == 1 ] ; then
+ modules= get_modules
+ echo $modules
+ exit 0
+fi
# Clean up old test results
rm -f tct*core-tests.xml
# Clean up old coverage data
if [ -d ../build/tizen ] ; then
- rm -f ../build/tizen/dali-core/.libs/*.gcda
+ rm -f ../build/tizen/dali-toolkit/.libs/*.gcda
fi
find build \( -name "*.gcda" \) -exec rm '{}' \;
ASCII_BOLD="\e[1m"
ASCII_RESET="\e[0m"
-if [ $opt_serial = 1 ] ; then
+modules=`ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
+if [ -f summary.xml ] ; then unlink summary.xml ; fi
+
+if [ $opt_tct == 1 ] ; then
+ # Use Test-kit lite
# Run all test case executables serially, create XML output
if [ -n "$1" ] ; then
- execute $1 $*
+ execute_tct $1 $*
else
- for mod in `ls -1 src/ | grep -v CMakeList `
+ for mod in $modules
do
if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
echo -ne "$ASCII_BOLD"
echo -e "Executing $mod$ASCII_RESET"
- execute $mod $*
+ execute_tct $mod $*
fi
done
fi
scripts/summarize.pl
+
else
- # if $1 is an executable filename, execute it·
+ # Execute test cases using own test harness
if [ -z "$1" ] ; then
# No arguments:
- # Execute each test executable in turn, using parallel execution
- for mod in `ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
+ # Execute each test executable in turn (by default, runs tests in parallel)
+ summary_start
+ for mod in $modules
do
echo -e "$ASCII_BOLD"
echo -e "Executing $mod$ASCII_RESET"
- build/src/$mod/tct-$mod-core $opt_rerun
+ build/src/$mod/tct-$mod-core -r $opt_serial
done
+ summary_end
elif [ -f "build/src/$1/tct-$1-core" ] ; then
# First argument is an executable filename - execute only that with any
# remaining arguments
+ summary_start
module=$1
shift;
- build/src/$module/tct-$module-core $opt_rerun $*
+ build/src/$module/tct-$module-core -r $opt_serial $*
+ summary_end
else
# First argument is not an executable. Is it a test case name?
# Try executing each executable with the test case name until success/known failure
- for mod in `ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
+ for mod in $modules
do
output=`build/src/$mod/tct-$mod-core $1`
ret=$?
echo $1 not found
fi
fi
+
+if [ -f summary.xml ] ; then
+ scripts/output_summary.pl
+fi
+
+exit $?
--- /dev/null
+#!/usr/bin/perl
+
+# Reads summary.xml and produces human readable output
+
+use strict;
+use XML::Parser;
+use Encode;
+use Getopt::Long;
+use Cwd;
+
+my $pwd = getcwd;
+my $text = "";
+my $module="";
+my %modules=();
+
+sub handle_start
+{
+ my ($p, $elt, %attrs) = @_;
+
+ if($elt =~ /suite/)
+ {
+ $module=$attrs{"name"};
+ }
+ if($elt =~ /_case/)
+ {
+ $text = "";
+ }
+}
+
+sub handle_end
+{
+ my ($p, $elt) = @_;
+ if($elt =~ /pass_case/)
+ {
+ $modules{$module}->{"pass"}=$text;
+ $text="";
+ }
+ elsif($elt =~ /fail_case/)
+ {
+ $modules{$module}->{"fail"}=$text;
+ $text="";
+ }
+}
+
+sub handle_char
+{
+ my ($p, $str) = @_;
+ $text .= $str;
+}
+
+my($parser) = new XML::Parser(Handlers => {Start => \&handle_start,
+ End => \&handle_end,
+ Char => \&handle_char});
+$parser->parsefile("summary.xml");
+
+my $RED_COLOR="\e[1;31m";
+my $GREEN_COLOR="\e[1;32m";
+my $ASCII_RESET="\e[0m";
+my $ASCII_BOLD="\e[1m";
+
+print "\n";
+my $totalFailures=0;
+foreach $module (keys(%modules))
+{
+ my $result_colour = $GREEN_COLOR;
+ if( $modules{$module}->{"fail"} )
+ {
+ $result_colour = $RED_COLOR;
+ }
+ my $numPasses = $modules{$module}->{"pass"};
+ my $numFailures = $modules{$module}->{"fail"};
+ $totalFailures += $numFailures;
+ print( "$ASCII_BOLD$module results:$ASCII_RESET\n" );
+ printf("Number of test passes: %s%4d (%5.2f%%)%s\n", $ASCII_BOLD, $numPasses, 100.0 * $numPasses / ($numPasses+$numFailures), $ASCII_RESET);
+ printf("%sNumber of test failures:%s %s%4d%s\n\n", $result_colour, $ASCII_RESET, $ASCII_BOLD, $numFailures, $ASCII_RESET);
+}
+
+exit $totalFailures == 0;
#!/usr/bin/perl
+# Generates an XML summary of test cases from Test-kit lite output XML.
+
use strict;
use XML::Parser;
use Encode;
{
int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
- const char* optString = "r";
- bool optRerunFailed(false);
+ const char* optString = "rs";
+ bool optRerunFailed(true);
+ bool optRunSerially(false);
int nextOpt = 0;
do
case 'r':
optRerunFailed = true;
break;
+ case 's':
+ optRunSerially = true;
+ break;
case '?':
TestHarness::Usage(argv[0]);
exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
if( optind == argc ) // no testcase name in argument list
{
- result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed);
+ if( optRunSerially )
+ {
+ result = TestHarness::RunAll( argv[0], tc_array );
+ }
+ else
+ {
+ result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
+ }
}
else
{
void TestApplication::Initialize()
{
+ // We always need the first update!
+ mStatus.keepUpdating = Integration::KeepUpdating::STAGE_KEEP_RENDERING;
+
mCore = Dali::Integration::Core::New(
mRenderController,
mPlatformAbstraction,
void TestApplication::DoUpdate( unsigned int intervalMilliseconds )
{
+ if( GetUpdateStatus() == 0 &&
+ mRenderStatus.NeedsUpdate() == false &&
+ ! GetRenderController().WasCalled(TestRenderController::RequestUpdateFunc) )
+ {
+ fprintf(stderr, "WARNING - Update not required\n");
+ }
+
unsigned int nextVSyncTime = mLastVSyncTime + intervalMilliseconds;
float elapsedSeconds = intervalMilliseconds / 1e3f;
mCore->Update( elapsedSeconds, mLastVSyncTime, nextVSyncTime, mStatus );
+ GetRenderController().Initialize();
+
mLastVSyncTime = nextVSyncTime;
}
return mStatus.KeepUpdating();
}
+bool TestApplication::GetRenderNeedsUpdate()
+{
+ return mRenderStatus.NeedsUpdate();
+}
+bool TestApplication::GetRenderHasRendered()
+{
+ return mRenderStatus.HasRendered();
+}
+
bool TestApplication::RenderOnly( )
{
// Update Time values
bool UpdateOnly( unsigned int intervalMilliseconds = DEFAULT_RENDER_INTERVAL );
bool RenderOnly( );
void ResetContext();
+ bool GetRenderNeedsUpdate();
+ bool GetRenderHasRendered();
private:
void DoUpdate( unsigned int intervalMilliseconds );
mIsRenderbufferResult = 0;
mIsShaderResult = 0;
mIsTextureResult = 0;
- mVertexAttribArrayChanged = false;
-
+ mActiveTextureUnit = 0;
mCheckFramebufferStatusResult = 0;
mFramebufferStatus = 0;
mFramebufferColorAttached = 0;
mFramebufferDepthAttached = 0;
mFramebufferStencilAttached = 0;
-
mNumBinaryFormats = 0;
mBinaryFormats = 0;
mProgramBinaryLength = 0;
- mGetProgramBinaryCalled = false;
- mLastAutoTextureIdUsed = 0;
+ mVertexAttribArrayChanged = false;
+ mGetProgramBinaryCalled = false;
- mLastShaderIdUsed = 0;
- mLastProgramIdUsed = 0;
- mLastUniformIdUsed = 0;
mLastShaderCompiled = 0;
mLastClearBitMask = 0;
mClearCount = 0;
mLastBlendFuncDstRgb = 0;
mLastBlendFuncSrcAlpha = 0;
mLastBlendFuncDstAlpha = 0;
+ mLastAutoTextureIdUsed = 0;
+ mLastShaderIdUsed = 0;
+ mLastProgramIdUsed = 0;
+ mLastUniformIdUsed = 0;
mUniforms.clear();
mProgramUniforms1i.clear();
mProgramUniforms2f.clear();
mProgramUniforms3f.clear();
mProgramUniforms4f.clear();
+
+ for( unsigned int i=0; i<MAX_ATTRIBUTE_CACHE_SIZE; ++i )
+ {
+ mVertexAttribArrayState[i] = false;
+ }
}
void TestGlAbstraction::PreRender()
// EXTERNAL INCLUDES
#include <sstream>
#include <string>
+#include <cstring>
#include <map>
#include <cstdio>
#include <cstring> // for strcmp
inline void DeleteTextures(GLsizei n, const GLuint* textures)
{
std::stringstream out;
- out << n << ", " << textures << " = [" ;
+ out << n << ", " << textures << " = [";
for(GLsizei i=0; i<n; i++)
{
- out << textures[i] << ", " ;
+ out << textures[i] << ", ";
mDeletedTextureIds.push_back(textures[i]);
}
out << "]";
*/
TraceCallStack& TestGlSyncAbstraction::GetTrace() { return mTrace; }
+int TestGlSyncAbstraction::GetNumberOfSyncObjects()
+{
+ return mSyncObjects.size();
+}
+
} // Dali
*/
TraceCallStack& GetTrace();
+ /**
+ * Get the number of sync objects
+ *
+ * @return the number of sync objects
+ */
+ int GetNumberOfSyncObjects();
+
private:
typedef std::vector<TestSyncObject*> SyncContainer;
typedef SyncContainer::iterator SyncIter;
typedef std::map<int, TestCase> RunningTestCases;
-namespace
+const char* basename(const char* path)
{
-const char* RED_COLOR="\e[1;31m";
-const char* GREEN_COLOR="\e[1;32m";
-const char* ASCII_RESET="\e[0m";
-const char* ASCII_BOLD="\e[1m";
+ const char* ptr=path;
+ const char* slash=NULL;
+ for( ; *ptr != '\0' ; ++ptr )
+ {
+ if(*ptr == '/') slash=ptr;
+ }
+ if(slash != NULL) ++slash;
+ return slash;
}
-
int RunTestCase( struct ::testcase_s& testCase )
{
int result = EXIT_STATUS_TESTCASE_FAILED;
close(STDOUT_FILENO);
close(STDERR_FILENO);
}
- exit( RunTestCase( testCase ) );
+ else
+ {
+ printf("\n");
+ for(int i=0; i<80; ++i) printf("#");
+ printf("\nTC: %s\n", testCase.name);
+ fflush(stdout);
+ }
+
+ int status = RunTestCase( testCase );
+
+ if( ! suppressOutput )
+ {
+ fflush(stdout);
+ fflush(stderr);
+ fclose(stdout);
+ fclose(stderr);
+ }
+ exit( status );
}
else if(pid == -1)
{
else // Parent process
{
int status = 0;
- int childPid = waitpid(-1, &status, 0);
+ int childPid = waitpid(pid, &status, 0);
if( childPid == -1 )
{
perror("waitpid");
}
else if(WIFSIGNALED(status) )
{
+ int signal = WTERMSIG(status);
testResult = EXIT_STATUS_TESTCASE_ABORTED;
-
-#ifdef WCOREDUMP
- if(WCOREDUMP(status))
+ if( signal == SIGABRT )
+ {
+ printf("Test case %s failed: test case asserted\n", testCase.name );
+ }
+ else
{
- printf("Test case %s failed: due to a crash\n", testCase.name);
+ printf("Test case %s failed: exit with signal %s\n", testCase.name, strsignal(WTERMSIG(status)));
}
-#endif
- printf("Test case %s failed: exit with signal %s\n", testCase.name, strsignal(WTERMSIG(status)));
}
else if(WIFSTOPPED(status))
{
printf("Test case %s failed: stopped with signal %s\n", testCase.name, strsignal(WSTOPSIG(status)));
}
}
+ fflush(stdout);
+ fflush(stderr);
return testResult;
}
-void OutputStatistics( int numPasses, int numFailures )
+void OutputStatistics( const char* processName, int numPasses, int numFailures )
{
- const char* failureColor = GREEN_COLOR;
- if( numFailures > 0 )
+ FILE* fp=fopen("summary.xml", "a");
+ if( fp != NULL )
{
- failureColor = RED_COLOR;
+ 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);
}
- printf("\rNumber of test passes: %s%4d (%5.2f%%)%s\n", ASCII_BOLD, numPasses, 100.0f * (float)numPasses / (numPasses+numFailures), ASCII_RESET);
- printf("%sNumber of test failures:%s %s%4d%s\n", failureColor, ASCII_RESET, ASCII_BOLD, numFailures, ASCII_RESET);
-
}
-
-int RunAll(const char* processName, ::testcase tc_array[], bool reRunFailed)
+int RunAll( const char* processName, ::testcase tc_array[] )
{
int numFailures = 0;
int numPasses = 0;
// Run test cases in child process( to kill output/handle signals ), but run serially.
for( unsigned int i=0; tc_array[i].name; i++)
{
- int result = RunTestCaseInChildProcess( tc_array[i], true );
+ int result = RunTestCaseInChildProcess( tc_array[i], false );
if( result == 0 )
{
numPasses++;
}
}
- OutputStatistics(numPasses, numFailures);
+ OutputStatistics( processName, numPasses, numFailures);
return numFailures;
}
-
-
// Constantly runs up to MAX_NUM_CHILDREN processes
int RunAllInParallel( const char* processName, ::testcase tc_array[], bool reRunFailed)
{
}
}
- OutputStatistics( numPasses, numFailures );
+ OutputStatistics( processName, numPasses, numFailures );
if( reRunFailed )
{
* Run all test cases in serial
* @param[in] processName The name of this process
* @param[in] tc_array The array of auto-generated testkit-lite test cases
- * @param[in] reRunFailed True if failed test cases should be re-run
* @return 0 on success
*/
-int RunAll(const char* processName, testcase tc_array[], bool reRunFailed);
+int RunAll( const char* processName, testcase tc_array[] );
/**
* Find the named test case in the given array, and run it
return numCalls;
}
-
/**
* Search for a method in the stack with the given parameter list
* @param[in] method The name of the method
*/
bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) const
{
- bool found = false;
+ return FindIndexFromMethodAndParams( method, params ) > -1;
+}
+
+/**
+ * Search for a method in the stack with the given parameter list
+ * @param[in] method The name of the method
+ * @param[in] params A comma separated list of parameter values
+ * @return index in the stack where the method was found or -1 otherwise
+ */
+int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const
+{
+ int index = -1;
for( size_t i=0; i < mCallStack.size(); i++ )
{
if( 0 == mCallStack[i][0].compare(method) && 0 == mCallStack[i][1].compare(params) )
{
- found = true;
+ index = i;
break;
}
}
- return found;
+ return index;
}
/**
bool FindMethodAndParams(std::string method, std::string params) const;
/**
+ * Search for a method in the stack with the given parameter list
+ * @param[in] method The name of the method
+ * @param[in] params A comma separated list of parameter values
+ * @return index in the stack where the method was found or -1 otherwise
+ */
+ int FindIndexFromMethodAndParams(std::string method, std::string params) const;
+
+ /**
* Test if the given method and parameters are at a given index in the stack
* @param[in] index Index in the call stack
* @param[in] method Name of method to test
{
int result = TestHarness::EXIT_STATUS_BAD_ARGUMENT;
- const char* optString = "r";
- bool optRerunFailed(false);
+ const char* optString = "rs";
+ bool optRerunFailed(true);
+ bool optRunSerially(false);
int nextOpt = 0;
do
case 'r':
optRerunFailed = true;
break;
+ case 's':
+ optRunSerially = true;
+ break;
case '?':
TestHarness::Usage(argv[0]);
exit(TestHarness::EXIT_STATUS_BAD_ARGUMENT);
if( optind == argc ) // no testcase name in argument list
{
- result = TestHarness::RunAllInParallel(argv[0], tc_array, optRerunFailed);
+ if( optRunSerially )
+ {
+ result = TestHarness::RunAll( argv[0], tc_array );
+ }
+ else
+ {
+ result = TestHarness::RunAllInParallel( argv[0], tc_array, optRerunFailed );
+ }
}
else
{
END_TEST;
}
-int UtcDaliBubbleEmitterSetBlendMode(void)
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBlendMode " );
-
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 150, Vector2( 5.f, 10.f ));
- DALI_TEST_CHECK(emitter);
- Actor root = emitter.GetRootActor();
- Stage::GetCurrent().Add( root );
- root.SetPosition( Vector3::ZERO );
- root.SetParentOrigin( ParentOrigin::CENTER );
- root.SetAnchorPoint( AnchorPoint::CENTER );
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- Wait(application);
- DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
-
- emitter.SetBlendMode( true );
- Wait(application);
- DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ZERO, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
-
- emitter.SetBlendMode( false );
- Wait(application);
- DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
-
- END_TEST;
-}
-
int UtcDaliBubbleEmitterEmitBubble(void)
{
ToolkitTestApplication application;
Stage::GetCurrent().Add( actor );
controlRenderer.SetOnStage( actor );
- DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), 1, TEST_LOCATION );
+ int depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), 1.f, TEST_LOCATION );
controlRenderer.SetDepthIndex( -1.f );
- DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), -1, TEST_LOCATION );
+ depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), -1.f, TEST_LOCATION );
END_TEST;
#include <dali-toolkit/dali-toolkit.h>
#include <dali/devel-api/scripting/scripting.h>
-#include <dali/devel-api/rendering/material.h>
#include <dali/devel-api/rendering/renderer.h>
#include <test-native-image.h>
application.Render();
// conventional alpha blending
- Material material = imageView.GetRendererAt( 0 ).GetMaterial();
+ Renderer renderer = imageView.GetRendererAt( 0 );
BlendingFactor::Type srcFactorRgb;
BlendingFactor::Type destFactorRgb;
BlendingFactor::Type srcFactorAlpha;
BlendingFactor::Type destFactorAlpha;
- material.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ renderer.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE_MINUS_SRC_ALPHA );
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
- float alphaBlendingUniform;
- DALI_TEST_CHECK( gl.GetUniformValue<float>( "uAlphaBlending", alphaBlendingUniform ) );
- DALI_TEST_EQUALS( alphaBlendingUniform, 1.f, TEST_LOCATION );
+ Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ bool enable;
+ DALI_TEST_CHECK( value.Get( enable ) );
+ DALI_TEST_CHECK( !enable );
// pre-multiplied alpha blending
imageView.SetProperty( Toolkit::ImageView::Property::PRE_MULTIPLIED_ALPHA, true );
application.SendNotification();
application.Render();
- material.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ renderer.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::ONE );
DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE );
- DALI_TEST_CHECK( gl.GetUniformValue<float>( "uAlphaBlending", alphaBlendingUniform ) );
- DALI_TEST_EQUALS( alphaBlendingUniform, 0.f, TEST_LOCATION );
+ value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ DALI_TEST_CHECK( value.Get( enable ) );
+ DALI_TEST_CHECK( enable );
END_TEST;
}
controlRenderer.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- DALI_TEST_EQUALS( actor.GetRendererAt(0).GetMaterial().GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
+ int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLENDING_MODE );
+ DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::ON, TEST_LOCATION );
TestGlAbstraction& gl = application.GetGlAbstraction();
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetRendererAt(0).GetMaterial().GetBlendMode(), BlendingMode::AUTO, TEST_LOCATION );
+ int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLENDING_MODE );
+ DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::AUTO, TEST_LOCATION );
Vector4 actualColor(Vector4::ZERO);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetRendererAt(0).GetMaterial().GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
-
+ blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLENDING_MODE );
+ DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::ON, TEST_LOCATION );
END_TEST;
}
GetImpl(*this).SetBubbleDensity( density );
}
-void BubbleEmitter::SetBlendMode( bool enable )
-{
- GetImpl(*this).SetBlendMode( enable );
-}
-
void BubbleEmitter::EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
{
GetImpl(*this).EmitBubble( animation, emitPosition, direction, displacement );
void SetBubbleDensity( unsigned int density );
/**
- * @brief Enable different blending mode for rendering.
- *
- * @param[in] enable If false, the default blending function if ImageActor is used.
- */
- void SetBlendMode( bool enable );
-
- /**
* @brief Add a bubble movement to the animation.
*
* @param[in] animation The animation reference.
}
}
-void BubbleEmitter::SetBlendMode( bool enable )
-{
- if(enable)
- {
- // linear overlay
- mMaterial.SetBlendFunc(BlendingFactor::SRC_ALPHA, BlendingFactor::ONE,
- BlendingFactor::ZERO, BlendingFactor::ONE);
- }
- else
- {
- // using default blend func
- mMaterial.SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
- }
-}
-
// clear the resources created for the off screen rendering
void BubbleEmitter::OnRenderFinished(RenderTask& source)
{
void SetBubbleDensity( unsigned int density );
/**
- * @copydoc Toolkit::BubbleEmitter::SetBlendMode
- */
- void SetBlendMode( bool enable );
-
- /**
* @copydoc Toolkit::BubbleEmitter::EmitBubble
*/
void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
mMaterial = Material::New( mShader );
- mMaterial.SetFaceCullingMode(Material::NONE);
-
if( mRenderer )
{
mRenderer.SetMaterial( mMaterial );
+ mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::NONE);
}
UpdateShaderUniforms();
mBorderColorIndex = (mImpl->mRenderer).RegisterProperty( COLOR_NAME, mBorderColor );
if( mBorderColor.a < 1.f || mAntiAliasing)
{
- (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( SIZE_NAME, mBorderSize );
}
(mImpl->mRenderer).SetProperty( mBorderColorIndex, color );
if( color.a < 1.f )
{
- (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
}
material.SetShader( shader );
if( mAntiAliasing )
{
- material.SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
}
mBlendColorIndex = mImpl->mRenderer.RegisterProperty( COLOR_NAME, mBlendColor );
if( mBlendColor.a < 1.f )
{
- mImpl->mRenderer.GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
if( mImpl->mRenderer )
{
(mImpl->mRenderer).SetProperty( mBlendColorIndex, color );
- if( color.a < 1.f && (mImpl->mRenderer).GetMaterial().GetBlendMode() != BlendingMode::ON)
+ if( color.a < 1.f )
{
- (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
}
mImpl->mDepthIndex = index;
if( mImpl->mRenderer )
{
- mImpl->mRenderer.SetDepthIndex( mImpl->mDepthIndex );
+ mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
}
}
{
DoSetOnStage( actor );
- mImpl->mRenderer.SetDepthIndex( mImpl->mDepthIndex );
+ mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
actor.AddRenderer( mImpl->mRenderer );
mImpl->mFlags |= Impl::IS_ON_STAGE;
}
const std::string ATLAS_RECT_UNIFORM_NAME = "uAtlasRect";
const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
-// Set this uniform to 1.0 for conventional alpha blending; if pre-multiplied alpha blending, set this uniform to 0.0
-const std::string ALPHA_BLENDING_UNIFORM_NAME = "uAlphaBlending";
-
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
varying mediump vec2 vTexCoord;\n
uniform sampler2D sTexture;\n
uniform lowp vec4 uColor;\n
- uniform lowp float uAlphaBlending; // Set to 1.0 for conventional alpha blending; if pre-multiplied alpha blending, set to 0.0
\n
void main()\n
{\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4( uColor.rgb*max( uAlphaBlending, uColor.a ), uColor.a );\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
}\n
);
{
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
}
}
shader = Shader::New( VERTEX_SHADER, mNativeFragmentShaderCode );
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
else
{
{
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
}
}
InitializeRenderer( mImage );
}
- EnablePreMultipliedAlpha( mIsAlphaPreMultiplied );
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, mIsAlphaPreMultiplied);
}
void ImageRenderer::DoSetOffStage( Actor& actor )
factoryCache.SaveShader( RendererFactoryCache::IMAGE_SHADER, shader );
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
return shader;
}
mIsAlphaPreMultiplied = preMultipled;
if( mImpl->mRenderer )
{
- Material material = mImpl->mRenderer.GetMaterial();
-
- if( preMultipled )
- {
- material.SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE );
- if( !mImpl->mCustomShader || mImpl->mCustomShader->mVertexShader.empty())
- {
- material.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 0.f );
- }
- }
- else
- {
- // using default blend func
- material.SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
-
- Property::Index index = material.GetPropertyIndex( ALPHA_BLENDING_UNIFORM_NAME );
- if( index != Property::INVALID_INDEX ) // only set value when the property already exist on the Material
- {
- material.SetProperty( index, 1.f );
- }
- }
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, mIsAlphaPreMultiplied);
}
}
if( mHighlightRenderer )
{
- mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
+ mHighlightRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mTextDepth - 2 ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
}
Pixel::Format pixelFormat = mAtlasManager.GetPixelFormat( slot.mAtlasId );
Material material = Material::New( pixelFormat == Pixel::L8 ? mShaderL8 : mShaderRgba );
material.AddTexture( atlas, "sTexture" );
- material.SetBlendMode( BlendingMode::ON );
mAtlasManager.SetMaterial( slot.mAtlasId, material );
}
if( actor.GetRendererCount() )
{
Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
- renderer.SetDepthIndex( renderer.GetDepthIndex() - 1 );
+ int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
+ renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
shadowActor.SetParentOrigin( ParentOrigin::CENTER );
shadowActor.SetSize( actorSize );
containerActor.Add( shadowActor );
Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
- renderer.SetDepthIndex( DepthIndex::CONTENT + mDepth );
+ renderer.SetProperty( Dali::Renderer::Property::BLENDING_MODE, BlendingMode::ON );
+ renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT + mDepth );
Actor actor = Actor::New();
#if defined(DEBUG_ENABLED)
actor.SetName( "Text renderable actor" );
}
mCurrentRenderer = Renderer::New( geometry, material );
- mCurrentRenderer.SetDepthIndex( depth );
+ mCurrentRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, depth );
Self().AddRenderer( mCurrentRenderer );
}
Geometry geometry = mCurrentRenderer.GetGeometry();
mTargetRenderer = Renderer::New( geometry, material );
- mTargetRenderer.SetDepthIndex( mCurrentRenderer.GetDepthIndex() );
+ int depthIndex = mCurrentRenderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX);
+ mTargetRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex );
for( size_t i = 0; i < mBoxes.size(); ++i )
{
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 20;
+const unsigned int TOOLKIT_MICRO_VERSION = 21;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.1.20
+Version: 1.1.21
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-2-Clause and MIT
#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/common/loading-state.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/renderer.h>
#include <dali/devel-api/rendering/geometry.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
{ "WRAP_MODE_REPEAT", WrapMode::REPEAT },
{ "WRAP_MODE_MIRRORED_REPEAT", WrapMode::MIRRORED_REPEAT },
- { "MATERIAL_NONE", Material::NONE },
- { "MATERIAL_CULL_BACK", Material::CULL_BACK },
- { "MATERIAL_CULL_FRONT", Material::CULL_FRONT },
- { "MATERIAL_CULL_BACK_AND_FRONT", Material::CULL_BACK_AND_FRONT },
+ { "MATERIAL_NONE", Renderer::NONE },
+ { "MATERIAL_CULL_BACK", Renderer::CULL_BACK },
+ { "MATERIAL_CULL_FRONT", Renderer::CULL_FRONT },
+ { "MATERIAL_CULL_BACK_AND_FRONT", Renderer::CULL_BACK_AND_FRONT },
{ "GEOMETRY_POINTS", Geometry::POINTS },
{ "GEOMETRY_LINES", Geometry::LINES },
args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetNumberOfTextures() ) );
}
-/**
- * Set the culling mode for this material
- *
- * @method setFaceCullingMode
- * @for Material
- * @param {integer} cullingMode The culling mode for this material
- * @example
- * // face culling mode is one of the following
- * dali.MATERIAL_NONE // None of the faces should be culled
- * dali.MATERIAL_CULL_BACK // Cull back face, back face should never be shown
- * dali.MATERIAL_CULL_FRONT // Cull front face, back face should never be shown
- * dali.MATERIAL_CULL_BACK_AND_FRONT // Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
- *
- * material.setFaceCullingMode( dali.MATERIAL_NONE );
- */
-void MaterialApi::SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid cullingMode parameter" );
- }
- else
- {
- material.SetFaceCullingMode( static_cast<Material::FaceCullingMode>(mode) );
- }
-}
-
-/**
- * Set the blending mode.
- *
- * If blending is disabled (BLENDING_OFF) fade in and fade out animations do not work.
- *
- * @for Material
- * @method setBlendMode
- * @param { integer } mode The blending mode.
- * @example
- * // blend mode is one of the following
- * dali.BLENDING_OFF // Blending is disabled.
- * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
- * dali.BLENDING_ON // Blending is enabled.
- *
- * material.setBlendMode( dali.BLENDING_AUTO );
- */
-void MaterialApi::SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid blendMode parameter" );
- }
- else
- {
- material.SetBlendMode( static_cast<Dali::BlendingMode::Type>( mode ) );
- }
-}
-
-/**
- * Retrieves the blending mode.
- *
- * @for Material
- * @method getBlendMode
- * @return { integer } blendMode
- * @example returns one of the following:
- *
- * dali.BLENDING_OFF // Blending is disabled.
- * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
- * dali.BLENDING_ON // Blending is enabled.
- */
-void MaterialApi::GetBlendMode( const v8::FunctionCallbackInfo<v8::Value>& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetBlendMode() ) );
-}
-
-/**
- * Specify the pixel arithmetic used when the actor is blended.
- *
- * @for Material
- * @method setBlendFunc
- * @param {integer} srcFactorRgb Source Blending RGB
- * @param {integer} destFactorRgb Destination Blending RGB
- * @param {integer} srcFactorAlpha Source Blending Alpha
- * @param {integer} destFactorAlpha Destinatino Blending Alpha
- * @example
- * //blending constants
- * dali.BLEND_FACTOR_ZERO
- * dali.BLEND_FACTOR_ONE
- * dali.BLEND_FACTOR_SRC_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR
- * dali.BLEND_FACTOR_SRC_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
- * dali.BLEND_FACTOR_DST_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
- * dali.BLEND_FACTOR_DST_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR
- * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE
- * dali.BLEND_FACTOR_CONSTANT_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
- * dali.BLEND_FACTOR_CONSTANT_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
- *
- * material.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
- * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA );
- */
-void MaterialApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- int params[4];
- bool foundAllParams(false);
- V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 );
- if( foundAllParams )
- {
- material.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]),
- static_cast< Dali::BlendingFactor::Type>(params[1]),
- static_cast< Dali::BlendingFactor::Type>(params[2]),
- static_cast< Dali::BlendingFactor::Type>(params[3]) );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter");
- }
-}
-
-/**
- * Query the pixel arithmetic used when the actor is blended.
- *
- * @for Material
- * @method getBlendFunc
- * @return {Object} Blend properties
- * @example Blend properties object has 4 fields
- *
- * blendProperties.sourceRgb // source rgb enum
- * blendProperties.destinationRgb // destination rgb enum
- * blendProperties.sourceAlpha source // alpha enum
- * blendProperties.destinationAlpha // destination alpha enum
- */
-void MaterialApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- // Pass by reference doesn't work in Javascript
- // For now just return a vector 4...
-
- BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
-
- v8::Local<v8::Object> blendProperties = v8::Object::New( isolate );
-
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) );
-
- args.GetReturnValue().Set( blendProperties );
-}
-
-/**
- * Specify the equation used when the actor is blended.
- *
- * @for Material
- * @method setBlendEquation
- * @param { integer } equationRgb The equation used for combining red, green, and blue components.
- * @param { integer } equationAlpha The equation used for combining the alpha component.
- * @example
- * // blend equation is one of the following
- * dali.BLEND_EQUATION_ADD
- * dali.BLEND_EQUATION_SUBTRACT
- * dali.BLEND_EQUATION_REVERSE_SUBTRACT
- *
- * material.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT );
- */
-void MaterialApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- int params[2];
- bool foundAllParams(false);
- V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 );
- if( foundAllParams )
- {
- material.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter");
- }
-}
-
-/**
- * Query the equation used when the actor is blended.
- *
- * @for Material
- * @method getBlendEquation
- * @return {Object} Blend equations
- * @example Blend equations object has 2 fields
- *
- * blendEquations.equationRgb // equation used for combining rgb components
- * blendEquations.equationAlpha // equation used for combining alpha components
- */
-void MaterialApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- // Pass by reference doesn't work in Javascript
- // For now just return a vector 2...
-
- BlendingEquation::Type equationRgb, equationAlpha;
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- material.GetBlendEquation( equationRgb, equationAlpha );
-
- v8::Local<v8::Object> blendEquations = v8::Object::New( isolate );
-
- blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) );
- blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) );
-
- args.GetReturnValue().Set( blendEquations );
-}
-
} // namespace V8Plugin
} // namespace Dali
void SetTextureUniformName( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetTextureIndex( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetNumberOfTextures( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
}; // namespace MaterialApi
{ "SetTextureUniformName" , MaterialApi::SetTextureUniformName },
{ "GetTextureIndex" , MaterialApi::GetTextureIndex },
{ "GetNumberOfTextures" , MaterialApi::GetNumberOfTextures },
- { "SetFaceCullingMode" , MaterialApi::SetFaceCullingMode },
- { "SetBlendMode" , MaterialApi::SetBlendMode },
- { "GetBlendMode" , MaterialApi::GetBlendMode },
- { "SetBlendFunc" , MaterialApi::SetBlendFunc },
- { "GetBlendFunc" , MaterialApi::GetBlendFunc },
- { "SetBlendEquation" , MaterialApi::SetBlendEquation },
- { "GetBlendEquation" , MaterialApi::GetBlendEquation },
};
const unsigned int MaterialFunctionTableCount = sizeof(MaterialFunctionTable)/sizeof(MaterialFunctionTable[0]);
args.GetReturnValue().Set( localObject );
}
+/**
+ * Specify the pixel arithmetic used when the actor is blended.
+ *
+ * @for Renderer
+ * @method setBlendFunc
+ * @param {integer} srcFactorRgb Source Blending RGB
+ * @param {integer} destFactorRgb Destination Blending RGB
+ * @param {integer} srcFactorAlpha Source Blending Alpha
+ * @param {integer} destFactorAlpha Destination Blending Alpha
+ * @example
+ * //blending constants
+ * dali.BLEND_FACTOR_ZERO
+ * dali.BLEND_FACTOR_ONE
+ * dali.BLEND_FACTOR_SRC_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR
+ * dali.BLEND_FACTOR_SRC_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ * dali.BLEND_FACTOR_DST_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
+ * dali.BLEND_FACTOR_DST_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR
+ * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE
+ * dali.BLEND_FACTOR_CONSTANT_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
+ * dali.BLEND_FACTOR_CONSTANT_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
+ *
+ * renderer.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
+ * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA );
+ */
+void RendererApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ int params[4];
+ bool foundAllParams(false);
+ V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 );
+ if( foundAllParams )
+ {
+ renderer.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]),
+ static_cast< Dali::BlendingFactor::Type>(params[1]),
+ static_cast< Dali::BlendingFactor::Type>(params[2]),
+ static_cast< Dali::BlendingFactor::Type>(params[3]) );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter");
+ }
+}
+
+/**
+ * Query the pixel arithmetic used when the actor is blended.
+ *
+ * @for Renderer
+ * @method getBlendFunc
+ * @return {Object} Blend properties
+ * @example Blend properties object has 4 fields
+ *
+ * blendProperties.sourceRgb // source rgb enum
+ * blendProperties.destinationRgb // destination rgb enum
+ * blendProperties.sourceAlpha source // alpha enum
+ * blendProperties.destinationAlpha // destination alpha enum
+ */
+void RendererApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ // Pass by reference doesn't work in Javascript
+ // For now just return a vector 4...
+
+ BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+
+ v8::Local<v8::Object> blendProperties = v8::Object::New( isolate );
+
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) );
+
+ args.GetReturnValue().Set( blendProperties );
+}
+
+/**
+ * Specify the equation used when the actor is blended.
+ *
+ * @for Renderer
+ * @method setBlendEquation
+ * @param { integer } equationRgb The equation used for combining red, green, and blue components.
+ * @param { integer } equationAlpha The equation used for combining the alpha component.
+ * @example
+ * // blend equation is one of the following
+ * dali.BLEND_EQUATION_ADD
+ * dali.BLEND_EQUATION_SUBTRACT
+ * dali.BLEND_EQUATION_REVERSE_SUBTRACT
+ *
+ * renderer.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT );
+ */
+void RendererApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ int params[2];
+ bool foundAllParams(false);
+ V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 );
+ if( foundAllParams )
+ {
+ renderer.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter");
+ }
+}
+
+/**
+ * Query the equation used when the actor is blended.
+ *
+ * @for Renderer
+ * @method getBlendEquation
+ * @return {Object} Blend equations
+ * @example Blend equations object has 2 fields
+ *
+ * blendEquations.equationRgb // equation used for combining rgb components
+ * blendEquations.equationAlpha // equation used for combining alpha components
+ */
+void RendererApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ // Pass by reference doesn't work in Javascript
+ // For now just return a vector 2...
+
+ BlendingEquation::Type equationRgb, equationAlpha;
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ renderer.GetBlendEquation( equationRgb, equationAlpha );
+
+ v8::Local<v8::Object> blendEquations = v8::Object::New( isolate );
+
+ blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) );
+ blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) );
+
+ args.GetReturnValue().Set( blendEquations );
+}
+
} // namespace V8Plugin
} // namespace Dali
void GetGeometry( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
}; // namespace RendererApi
{ "GetGeometry" , RendererApi::GetGeometry },
{ "SetMaterial" , RendererApi::SetMaterial },
{ "GetMaterial" , RendererApi::GetMaterial },
+ { "SetBlendFunc" , RendererApi::SetBlendFunc },
+ { "GetBlendFunc" , RendererApi::GetBlendFunc },
+ { "SetBlendEquation" , RendererApi::SetBlendEquation },
+ { "GetBlendEquation" , RendererApi::GetBlendEquation },
};
const unsigned int RendererFunctionTableCount = sizeof(RendererFunctionTable)/sizeof(RendererFunctionTable[0]);