From: Adeel Kazmi Date: Wed, 18 Nov 2020 17:46:41 +0000 (+0000) Subject: Merge "Clean up the code to build successfully on macOS" into devel/master X-Git-Tag: dali_2.0.2~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=0db05961b8c65b81ab2e8795f3264cd6fb5cc919;hp=5861516316ce64d40f0ed5288ffe6a73f98f014a Merge "Clean up the code to build successfully on macOS" into devel/master --- diff --git a/automated-tests/README.md b/automated-tests/README.md index b2fc212..7d363fb 100644 --- a/automated-tests/README.md +++ b/automated-tests/README.md @@ -105,16 +105,35 @@ To execute a subset of tests, you can run individual test sets, e.g. ./execute.sh dali -To get coverage output (you need to first build dali libraries with +To get full coverage output (you need to first build dali libraries with --coverage), run ./coverage.sh +To check the coverage of your patch, (the build server uses its own copy +of these scripts), you can use + + ./patch-coverage.pl -q [diff-spec] + +to get a summary, or + + ./patch-coverage.pl [diff-spec] + +to get textual output, or + + ./patch-coverage.pl -o out.html [diff-spec] + +to get HTML output (used by build server). + +diff-spec is any refspec accepted by git-diff. If it's left out, it creates +a refspec to the latest commit, or uses the index/working tree. + + Testing on target ================= -To build for target, first build and install dali-core, dali-adaptor and dali-toolkit, then build dali-capi without --keep-packs option. +To build for target, first build and install dali-core, dali-adaptor and dali-toolkit. You will need to install libconfig-tiny-perl: @@ -226,14 +245,14 @@ Debugging On desktop, you can debug the tests by running gdb on the test program: $ cd automated-tests - $ gdb build/src/dali/tct-dali-core + $ ./execute.sh -d gdb> r replace `` with the name of the failing testcase. For example, using testcase UtcDaliActorAddP from the dali-core test suite: - $ gdb build/src/dali/tct-dali-core + $ ./execute.sh -d UtcDaliActorAddP gdb> r UtcDaliActorAddP diff --git a/automated-tests/patch-coverage.pl b/automated-tests/patch-coverage.pl index c5d9083..b3cf098 100755 --- a/automated-tests/patch-coverage.pl +++ b/automated-tests/patch-coverage.pl @@ -19,33 +19,59 @@ use strict; use Git; use Getopt::Long; use Error qw(:try); -use HTML::Element; use Pod::Usage; use File::Basename; -#use Data::Dumper; use File::stat; use Scalar::Util qw /looks_like_number/; use Cwd qw /getcwd/; use Term::ANSIColor qw(:constants); +use Data::Dumper; -# Program to run gcov on files in patch (that are in source dirs - needs to be dali-aware). +# Dali specific program to run lcov and parse output for files in patch -# A) Get patch -# B) Remove uninteresting files -# C) Find matching gcno/gcda files -# D) Copy and rename them to match source prefix (i.e. strip library name off front) -# E) Generate patch output with covered/uncovered lines marked in green/red -# F) Generate coverage data for changed lines -# G) Exit status should be 0 for high coverage (90% line coverage for all new/changed lines) +# A) Generate lcov output from lib & test cases +# B) Get patch using git diff +# C) Generate patch output with covered/uncovered lines marked in green/red +# D) Generate coverage data for changed lines +# E) Exit status should be 0 for high coverage (90% line coverage for all new/changed lines) # or 1 for low coverage # Sources for conversion of gcno/gcda files: -# ~/bin/lcov +# /usr/bin/lcov & genhtml # Python git-coverage (From http://stef.thewalter.net/git-coverage-useful-code-coverage.html) +# From genhtml: +sub read_info_file($); +sub get_info_entry($); +sub set_info_entry($$$$$$$$$;$$$$$$); +sub combine_info_entries($$$); +sub combine_info_files($$); +sub compress_brcount($); +sub brcount_to_db($); +sub db_to_brcount($;$); +sub brcount_db_combine($$$); +sub add_counts($$); +sub info(@); + our $repo = Git->repository(); our $debug=0; our $pd_debug=0; +our $root; +our %info_data; # Hash containing all data from .info files + +# Settings from genhtml: +our $func_coverage; # If set, generate function coverage statistics +our $no_func_coverage; # Disable func_coverage +our $br_coverage; # If set, generate branch coverage statistics +our $no_br_coverage; # Disable br_coverage +our $sort = 1; # If set, provide directory listings with sorted entries +our $no_sort; # Disable sort + +# Branch data combination types +our $BR_SUB = 0; +our $BR_ADD = 1; + +# Command line options our $opt_cached; our $opt_help; our $opt_output; @@ -64,6 +90,793 @@ GetOptions( %longOptions ) or pod2usage(2); pod2usage(1) if $opt_help; +# From genhtml: +# +# read_info_file(info_filename) +# +# Read in the contents of the .info file specified by INFO_FILENAME. Data will +# be returned as a reference to a hash containing the following mappings: +# +# %result: for each filename found in file -> \%data +# +# %data: "test" -> \%testdata +# "sum" -> \%sumcount +# "func" -> \%funcdata +# "found" -> $lines_found (number of instrumented lines found in file) +# "hit" -> $lines_hit (number of executed lines in file) +# "f_found" -> $fn_found (number of instrumented functions found in file) +# "f_hit" -> $fn_hit (number of executed functions in file) +# "b_found" -> $br_found (number of instrumented branches found in file) +# "b_hit" -> $br_hit (number of executed branches in file) +# "check" -> \%checkdata +# "testfnc" -> \%testfncdata +# "sumfnc" -> \%sumfnccount +# "testbr" -> \%testbrdata +# "sumbr" -> \%sumbrcount +# +# %testdata : name of test affecting this file -> \%testcount +# %testfncdata: name of test affecting this file -> \%testfnccount +# %testbrdata: name of test affecting this file -> \%testbrcount +# +# %testcount : line number -> execution count for a single test +# %testfnccount: function name -> execution count for a single test +# %testbrcount : line number -> branch coverage data for a single test +# %sumcount : line number -> execution count for all tests +# %sumfnccount : function name -> execution count for all tests +# %sumbrcount : line number -> branch coverage data for all tests +# %funcdata : function name -> line number +# %checkdata : line number -> checksum of source code line +# $brdata : vector of items: block, branch, taken +# +# Note that .info file sections referring to the same file and test name +# will automatically be combined by adding all execution counts. +# +# Note that if INFO_FILENAME ends with ".gz", it is assumed that the file +# is compressed using GZIP. If available, GUNZIP will be used to decompress +# this file. +# +# Die on error. +# +sub read_info_file($) +{ + my $tracefile = $_[0]; # Name of tracefile + my %result; # Resulting hash: file -> data + my $data; # Data handle for current entry + my $testdata; # " " + my $testcount; # " " + my $sumcount; # " " + my $funcdata; # " " + my $checkdata; # " " + my $testfncdata; + my $testfnccount; + my $sumfnccount; + my $testbrdata; + my $testbrcount; + my $sumbrcount; + my $line; # Current line read from .info file + my $testname; # Current test name + my $filename; # Current filename + my $hitcount; # Count for lines hit + my $count; # Execution count of current line + my $negative; # If set, warn about negative counts + my $changed_testname; # If set, warn about changed testname + my $line_checksum; # Checksum of current line + my $notified_about_relative_paths; + local *INFO_HANDLE; # Filehandle for .info file + + info("Reading data file $tracefile\n"); + + # Check if file exists and is readable + stat($tracefile); + if (!(-r _)) + { + die("ERROR: cannot read file $tracefile!\n"); + } + + # Check if this is really a plain file + if (!(-f _)) + { + die("ERROR: not a plain file: $tracefile!\n"); + } + + # Check for .gz extension + if ($tracefile =~ /\.gz$/) + { + # Check for availability of GZIP tool + system_no_output(1, "gunzip" ,"-h") + and die("ERROR: gunzip command not available!\n"); + + # Check integrity of compressed file + system_no_output(1, "gunzip", "-t", $tracefile) + and die("ERROR: integrity check failed for ". + "compressed file $tracefile!\n"); + + # Open compressed file + open(INFO_HANDLE, "-|", "gunzip -c '$tracefile'") + or die("ERROR: cannot start gunzip to decompress ". + "file $tracefile!\n"); + } + else + { + # Open decompressed file + open(INFO_HANDLE, "<", $tracefile) + or die("ERROR: cannot read file $tracefile!\n"); + } + + $testname = ""; + while () + { + chomp($_); + $line = $_; + + # Switch statement + foreach ($line) + { + /^TN:([^,]*)(,diff)?/ && do + { + # Test name information found + $testname = defined($1) ? $1 : ""; + if ($testname =~ s/\W/_/g) + { + $changed_testname = 1; + } + $testname .= $2 if (defined($2)); + last; + }; + + /^[SK]F:(.*)/ && do + { + # Filename information found + # Retrieve data for new entry + $filename = File::Spec->rel2abs($1, $root); + + if (!File::Spec->file_name_is_absolute($1) && + !$notified_about_relative_paths) + { + info("Resolved relative source file ". + "path \"$1\" with CWD to ". + "\"$filename\".\n"); + $notified_about_relative_paths = 1; + } + + $data = $result{$filename}; + ($testdata, $sumcount, $funcdata, $checkdata, + $testfncdata, $sumfnccount, $testbrdata, + $sumbrcount) = + get_info_entry($data); + + if (defined($testname)) + { + $testcount = $testdata->{$testname}; + $testfnccount = $testfncdata->{$testname}; + $testbrcount = $testbrdata->{$testname}; + } + else + { + $testcount = {}; + $testfnccount = {}; + $testbrcount = {}; + } + last; + }; + + /^DA:(\d+),(-?\d+)(,[^,\s]+)?/ && do + { + # Fix negative counts + $count = $2 < 0 ? 0 : $2; + if ($2 < 0) + { + $negative = 1; + } + # Execution count found, add to structure + # Add summary counts + $sumcount->{$1} += $count; + + # Add test-specific counts + if (defined($testname)) + { + $testcount->{$1} += $count; + } + + # Store line checksum if available + if (defined($3)) + { + $line_checksum = substr($3, 1); + + # Does it match a previous definition + if (defined($checkdata->{$1}) && + ($checkdata->{$1} ne + $line_checksum)) + { + die("ERROR: checksum mismatch ". + "at $filename:$1\n"); + } + + $checkdata->{$1} = $line_checksum; + } + last; + }; + + /^FN:(\d+),([^,]+)/ && do + { + last if (!$func_coverage); + + # Function data found, add to structure + $funcdata->{$2} = $1; + + # Also initialize function call data + if (!defined($sumfnccount->{$2})) { + $sumfnccount->{$2} = 0; + } + if (defined($testname)) + { + if (!defined($testfnccount->{$2})) { + $testfnccount->{$2} = 0; + } + } + last; + }; + + /^FNDA:(\d+),([^,]+)/ && do + { + last if (!$func_coverage); + # Function call count found, add to structure + # Add summary counts + $sumfnccount->{$2} += $1; + + # Add test-specific counts + if (defined($testname)) + { + $testfnccount->{$2} += $1; + } + last; + }; + + /^BRDA:(\d+),(\d+),(\d+),(\d+|-)/ && do { + # Branch coverage data found + my ($line, $block, $branch, $taken) = + ($1, $2, $3, $4); + + last if (!$br_coverage); + $sumbrcount->{$line} .= + "$block,$branch,$taken:"; + + # Add test-specific counts + if (defined($testname)) { + $testbrcount->{$line} .= + "$block,$branch,$taken:"; + } + last; + }; + + /^end_of_record/ && do + { + # Found end of section marker + if ($filename) + { + # Store current section data + if (defined($testname)) + { + $testdata->{$testname} = + $testcount; + $testfncdata->{$testname} = + $testfnccount; + $testbrdata->{$testname} = + $testbrcount; + } + + set_info_entry($data, $testdata, + $sumcount, $funcdata, + $checkdata, $testfncdata, + $sumfnccount, + $testbrdata, + $sumbrcount); + $result{$filename} = $data; + last; + } + }; + + # default + last; + } + } + close(INFO_HANDLE); + + # Calculate lines_found and lines_hit for each file + foreach $filename (keys(%result)) + { + $data = $result{$filename}; + + ($testdata, $sumcount, undef, undef, $testfncdata, + $sumfnccount, $testbrdata, $sumbrcount) = + get_info_entry($data); + + # Filter out empty files + if (scalar(keys(%{$sumcount})) == 0) + { + delete($result{$filename}); + next; + } + # Filter out empty test cases + foreach $testname (keys(%{$testdata})) + { + if (!defined($testdata->{$testname}) || + scalar(keys(%{$testdata->{$testname}})) == 0) + { + delete($testdata->{$testname}); + delete($testfncdata->{$testname}); + } + } + + $data->{"found"} = scalar(keys(%{$sumcount})); + $hitcount = 0; + + foreach (keys(%{$sumcount})) + { + if ($sumcount->{$_} > 0) { $hitcount++; } + } + + $data->{"hit"} = $hitcount; + + # Get found/hit values for function call data + $data->{"f_found"} = scalar(keys(%{$sumfnccount})); + $hitcount = 0; + + foreach (keys(%{$sumfnccount})) { + if ($sumfnccount->{$_} > 0) { + $hitcount++; + } + } + $data->{"f_hit"} = $hitcount; + + # Combine branch data for the same branches + (undef, $data->{"b_found"}, $data->{"b_hit"}) = compress_brcount($sumbrcount); + foreach $testname (keys(%{$testbrdata})) { + compress_brcount($testbrdata->{$testname}); + } + } + + if (scalar(keys(%result)) == 0) + { + die("ERROR: no valid records found in tracefile $tracefile\n"); + } + if ($negative) + { + warn("WARNING: negative counts found in tracefile ". + "$tracefile\n"); + } + if ($changed_testname) + { + warn("WARNING: invalid characters removed from testname in ". + "tracefile $tracefile\n"); + } + + return(\%result); +} + +sub print_simplified_info +{ + for my $key (keys(%info_data)) + { + print "K $key: \n"; + my $sumcountref = $info_data{$key}->{"sum"}; + for my $line (sort{$a<=>$b}(keys(%$sumcountref))) + { + print "L $line: $sumcountref->{$line}\n"; + } + } +} + +# From genhtml: +# +# get_info_entry(hash_ref) +# +# Retrieve data from an entry of the structure generated by read_info_file(). +# Return a list of references to hashes: +# (test data hash ref, sum count hash ref, funcdata hash ref, checkdata hash +# ref, testfncdata hash ref, sumfnccount hash ref, lines found, lines hit, +# functions found, functions hit) +# + +sub get_info_entry($) +{ + my $testdata_ref = $_[0]->{"test"}; + my $sumcount_ref = $_[0]->{"sum"}; + my $funcdata_ref = $_[0]->{"func"}; + my $checkdata_ref = $_[0]->{"check"}; + my $testfncdata = $_[0]->{"testfnc"}; + my $sumfnccount = $_[0]->{"sumfnc"}; + my $testbrdata = $_[0]->{"testbr"}; + my $sumbrcount = $_[0]->{"sumbr"}; + my $lines_found = $_[0]->{"found"}; + my $lines_hit = $_[0]->{"hit"}; + my $fn_found = $_[0]->{"f_found"}; + my $fn_hit = $_[0]->{"f_hit"}; + my $br_found = $_[0]->{"b_found"}; + my $br_hit = $_[0]->{"b_hit"}; + + return ($testdata_ref, $sumcount_ref, $funcdata_ref, $checkdata_ref, + $testfncdata, $sumfnccount, $testbrdata, $sumbrcount, + $lines_found, $lines_hit, $fn_found, $fn_hit, + $br_found, $br_hit); +} + + +# From genhtml: +# +# set_info_entry(hash_ref, testdata_ref, sumcount_ref, funcdata_ref, +# checkdata_ref, testfncdata_ref, sumfcncount_ref, +# testbrdata_ref, sumbrcount_ref[,lines_found, +# lines_hit, f_found, f_hit, $b_found, $b_hit]) +# +# Update the hash referenced by HASH_REF with the provided data references. +# + +sub set_info_entry($$$$$$$$$;$$$$$$) +{ + my $data_ref = $_[0]; + + $data_ref->{"test"} = $_[1]; + $data_ref->{"sum"} = $_[2]; + $data_ref->{"func"} = $_[3]; + $data_ref->{"check"} = $_[4]; + $data_ref->{"testfnc"} = $_[5]; + $data_ref->{"sumfnc"} = $_[6]; + $data_ref->{"testbr"} = $_[7]; + $data_ref->{"sumbr"} = $_[8]; + + if (defined($_[9])) { $data_ref->{"found"} = $_[9]; } + if (defined($_[10])) { $data_ref->{"hit"} = $_[10]; } + if (defined($_[11])) { $data_ref->{"f_found"} = $_[11]; } + if (defined($_[12])) { $data_ref->{"f_hit"} = $_[12]; } + if (defined($_[13])) { $data_ref->{"b_found"} = $_[13]; } + if (defined($_[14])) { $data_ref->{"b_hit"} = $_[14]; } +} + +# From genhtml: +# +# combine_info_entries(entry_ref1, entry_ref2, filename) +# +# Combine .info data entry hashes referenced by ENTRY_REF1 and ENTRY_REF2. +# Return reference to resulting hash. +# +sub combine_info_entries($$$) +{ + my $entry1 = $_[0]; # Reference to hash containing first entry + my $testdata1; + my $sumcount1; + my $funcdata1; + my $checkdata1; + my $testfncdata1; + my $sumfnccount1; + my $testbrdata1; + my $sumbrcount1; + + my $entry2 = $_[1]; # Reference to hash containing second entry + my $testdata2; + my $sumcount2; + my $funcdata2; + my $checkdata2; + my $testfncdata2; + my $sumfnccount2; + my $testbrdata2; + my $sumbrcount2; + + my %result; # Hash containing combined entry + my %result_testdata; + my $result_sumcount = {}; + my $result_funcdata; + my $result_testfncdata; + my $result_sumfnccount; + my $result_testbrdata; + my $result_sumbrcount; + my $lines_found; + my $lines_hit; + my $fn_found; + my $fn_hit; + my $br_found; + my $br_hit; + + my $testname; + my $filename = $_[2]; + + # Retrieve data + ($testdata1, $sumcount1, $funcdata1, $checkdata1, $testfncdata1, + $sumfnccount1, $testbrdata1, $sumbrcount1) = get_info_entry($entry1); + ($testdata2, $sumcount2, $funcdata2, $checkdata2, $testfncdata2, + $sumfnccount2, $testbrdata2, $sumbrcount2) = get_info_entry($entry2); + +# # Merge checksums +# $checkdata1 = merge_checksums($checkdata1, $checkdata2, $filename); +# +# # Combine funcdata +# $result_funcdata = merge_func_data($funcdata1, $funcdata2, $filename); +# +# # Combine function call count data +# $result_testfncdata = add_testfncdata($testfncdata1, $testfncdata2); +# ($result_sumfnccount, $fn_found, $fn_hit) = +# add_fnccount($sumfnccount1, $sumfnccount2); +# +# # Combine branch coverage data +# $result_testbrdata = add_testbrdata($testbrdata1, $testbrdata2); +# ($result_sumbrcount, $br_found, $br_hit) = +# combine_brcount($sumbrcount1, $sumbrcount2, $BR_ADD); +# + # Combine testdata + foreach $testname (keys(%{$testdata1})) + { + if (defined($testdata2->{$testname})) + { + # testname is present in both entries, requires + # combination + ($result_testdata{$testname}) = + add_counts($testdata1->{$testname}, + $testdata2->{$testname}); + } + else + { + # testname only present in entry1, add to result + $result_testdata{$testname} = $testdata1->{$testname}; + } + + # update sum count hash + ($result_sumcount, $lines_found, $lines_hit) = + add_counts($result_sumcount, + $result_testdata{$testname}); + } + + foreach $testname (keys(%{$testdata2})) + { + # Skip testnames already covered by previous iteration + if (defined($testdata1->{$testname})) { next; } + + # testname only present in entry2, add to result hash + $result_testdata{$testname} = $testdata2->{$testname}; + + # update sum count hash + ($result_sumcount, $lines_found, $lines_hit) = + add_counts($result_sumcount, + $result_testdata{$testname}); + } + + # Calculate resulting sumcount + + # Store result + set_info_entry(\%result, \%result_testdata, $result_sumcount, + $result_funcdata, $checkdata1, $result_testfncdata, + $result_sumfnccount, $result_testbrdata, + $result_sumbrcount, $lines_found, $lines_hit, + $fn_found, $fn_hit, $br_found, $br_hit); + + return(\%result); +} + +# From genhtml: +# +# combine_info_files(info_ref1, info_ref2) +# +# Combine .info data in hashes referenced by INFO_REF1 and INFO_REF2. Return +# reference to resulting hash. +# +sub combine_info_files($$) +{ + my %hash1 = %{$_[0]}; + my %hash2 = %{$_[1]}; + my $filename; + + foreach $filename (keys(%hash2)) + { + if ($hash1{$filename}) + { + # Entry already exists in hash1, combine them + $hash1{$filename} = + combine_info_entries($hash1{$filename}, + $hash2{$filename}, + $filename); + } + else + { + # Entry is unique in both hashes, simply add to + # resulting hash + $hash1{$filename} = $hash2{$filename}; + } + } + + return(\%hash1); +} + +# From genhtml: +# +# add_counts(data1_ref, data2_ref) +# +# DATA1_REF and DATA2_REF are references to hashes containing a mapping +# +# line number -> execution count +# +# Return a list (RESULT_REF, LINES_FOUND, LINES_HIT) where RESULT_REF +# is a reference to a hash containing the combined mapping in which +# execution counts are added. +# +sub add_counts($$) +{ + my $data1_ref = $_[0]; # Hash 1 + my $data2_ref = $_[1]; # Hash 2 + my %result; # Resulting hash + my $line; # Current line iteration scalar + my $data1_count; # Count of line in hash1 + my $data2_count; # Count of line in hash2 + my $found = 0; # Total number of lines found + my $hit = 0; # Number of lines with a count > 0 + + foreach $line (keys(%$data1_ref)) + { + $data1_count = $data1_ref->{$line}; + $data2_count = $data2_ref->{$line}; + + # Add counts if present in both hashes + if (defined($data2_count)) { $data1_count += $data2_count; } + + # Store sum in %result + $result{$line} = $data1_count; + + $found++; + if ($data1_count > 0) { $hit++; } + } + + # Add lines unique to data2_ref + foreach $line (keys(%$data2_ref)) + { + # Skip lines already in data1_ref + if (defined($data1_ref->{$line})) { next; } + + # Copy count from data2_ref + $result{$line} = $data2_ref->{$line}; + + $found++; + if ($result{$line} > 0) { $hit++; } + } + + return (\%result, $found, $hit); +} + + +# From genhtml: +sub compress_brcount($) +{ + my ($brcount) = @_; + my $db; + + $db = brcount_to_db($brcount); + return db_to_brcount($db, $brcount); +} + +# +# brcount_to_db(brcount) +# +# Convert brcount data to the following format: +# +# db: line number -> block hash +# block hash: block number -> branch hash +# branch hash: branch number -> taken value +# + +sub brcount_to_db($) +{ + my ($brcount) = @_; + my $line; + my $db; + + # Add branches to database + foreach $line (keys(%{$brcount})) { + my $brdata = $brcount->{$line}; + + foreach my $entry (split(/:/, $brdata)) { + my ($block, $branch, $taken) = split(/,/, $entry); + my $old = $db->{$line}->{$block}->{$branch}; + + if (!defined($old) || $old eq "-") { + $old = $taken; + } elsif ($taken ne "-") { + $old += $taken; + } + + $db->{$line}->{$block}->{$branch} = $old; + } + } + + return $db; +} + + +# +# db_to_brcount(db[, brcount]) +# +# Convert branch coverage data back to brcount format. If brcount is specified, +# the converted data is directly inserted in brcount. +# + +sub db_to_brcount($;$) +{ + my ($db, $brcount) = @_; + my $line; + my $br_found = 0; + my $br_hit = 0; + + # Convert database back to brcount format + foreach $line (sort({$a <=> $b} keys(%{$db}))) { + my $ldata = $db->{$line}; + my $brdata; + my $block; + + foreach $block (sort({$a <=> $b} keys(%{$ldata}))) { + my $bdata = $ldata->{$block}; + my $branch; + + foreach $branch (sort({$a <=> $b} keys(%{$bdata}))) { + my $taken = $bdata->{$branch}; + + $br_found++; + $br_hit++ if ($taken ne "-" && $taken > 0); + $brdata .= "$block,$branch,$taken:"; + } + } + $brcount->{$line} = $brdata; + } + + return ($brcount, $br_found, $br_hit); +} + + +# +# brcount_db_combine(db1, db2, op) +# +# db1 := db1 op db2, where +# db1, db2: brcount data as returned by brcount_to_db +# op: one of $BR_ADD and BR_SUB +# +sub brcount_db_combine($$$) +{ + my ($db1, $db2, $op) = @_; + + foreach my $line (keys(%{$db2})) { + my $ldata = $db2->{$line}; + + foreach my $block (keys(%{$ldata})) { + my $bdata = $ldata->{$block}; + + foreach my $branch (keys(%{$bdata})) { + my $taken = $bdata->{$branch}; + my $new = $db1->{$line}->{$block}->{$branch}; + + if (!defined($new) || $new eq "-") { + $new = $taken; + } elsif ($taken ne "-") { + if ($op == $BR_ADD) { + $new += $taken; + } elsif ($op == $BR_SUB) { + $new -= $taken; + $new = 0 if ($new < 0); + } + } + + $db1->{$line}->{$block}->{$branch} = $new; + } + } + } +} + +# From genhtml +sub info(@) +{ + if($debug) + { + # Print info string + printf(@_); + } +} + +# NEW STUFF + ## Format per file, repeated, no linebreak # # index c1..c2 c3 @@ -78,6 +891,12 @@ pod2usage(1) if $opt_help; # 3 lines of context # # output: +# : source / header files in dali/dali-toolkit +# \%filter: -> \%filedata +# %filedata: "patch" -> \@checklines +# "b_lines" -> \%b_lines +# @checklines: vector of \[start, length] # line numbers of new/modified lines +# %b_lines: -> patch line in b-file. sub parse_diff { my $patchref = shift; @@ -184,7 +1003,7 @@ sub parse_diff } } - return {%filter}; + return {%filter};#copy? - test and fixme } sub show_patch_lines @@ -203,133 +1022,11 @@ sub show_patch_lines } } -sub get_gcno_file -{ - # Assumes test cases have been run, and "make rename_cov_data" has been executed - - my $file = shift; - my ($name, $path, $suffix) = fileparse($file, (".c", ".cpp", ".h")); - my $gcno_file = $repo->wc_path() . "/build/tizen/.cov/$name.gcno"; - - # Note, will translate headers to their source's object, which - # may miss execution code in the headers (e.g. inlines are usually - # not all used in the implementation, and require getting coverage - # from test cases. - - if( -f $gcno_file ) - { - my $gcno_st = stat($gcno_file); - my $fq_file = $repo->wc_path() . $file; - my $src_st = stat($fq_file); - if($gcno_st->ctime < $src_st->mtime) - { - print "WARNING: GCNO $gcno_file older than SRC $fq_file\n"; - $gcno_file=""; - } - - } - else - { - print("WARNING: No equivalent gcno file for $file\n"); - } - return $gcno_file; -} - -our %gcovfiles=(); -sub get_coverage -{ - my $file = shift; - my $filesref = shift; - print("get_coverage($file)\n") if $debug; - my $gcno_file = get_gcno_file($file); - my @gcov_files = (); - my $gcovfile; - if( $gcno_file ) - { - print "Running gcov on $gcno_file:\n" if $debug; - open( my $fh, "gcov --preserve-paths $gcno_file |") || die "Can't run gcov:$!\n"; - while( <$fh> ) - { - print $_ if $debug>=3; - chomp; - if( m!'(.*\.gcov)'$! ) - { - my $coverage_file = $1; # File has / replaced with # and .. replaced with ^ - my $source_file = $coverage_file; - $source_file =~ s!\^!..!g; # Change ^ to .. - $source_file =~ s!\#!/!g; # change #'s to /s - $source_file =~ s!.gcov$!!; # Strip off .gcov suffix - - print "Matching $file against $source_file\n" if $debug >= 3; - # Only want the coverage files matching source file: - if(index( $source_file, $file ) > 0 ) - { - $gcovfile = $coverage_file; - # Some header files do not produce an equivalent gcov file so we shouldn't parse them - if(($source_file =~ /\.h$/) && (! -e $gcovfile)) - { - print "Omitting Header: $source_file\n" if $debug; - $gcovfile = "" - } - last; - } - } - } - close($fh); - - if($gcovfile) - { - if($gcovfiles{$gcovfile} == undef) - { - # Only parse a gcov file once - $gcovfiles{$gcovfile}->{"seen"}=1; - - print "Getting coverage data from $gcovfile\n" if $debug; - - open( FH, "< $gcovfile" ) || die "Can't open $gcovfile for reading:$!\n"; - while() - { - my ($cov, $line, @code ) = split( /:/, $_ ); - $cov =~ s/^\s+//; # Strip leading space - $line =~ s/^\s+//; - my $code=join(":", @code); - if($cov =~ /\#/) - { - # There is no coverage data for these executable lines - $gcovfiles{$gcovfile}->{"uncovered"}->{$line}++; - $gcovfiles{$gcovfile}->{"src"}->{$line}=$code; - } - elsif( $cov ne "-" && looks_like_number($cov) && $cov > 0 ) - { - $gcovfiles{$gcovfile}->{"covered"}->{$line}=$cov; - $gcovfiles{$gcovfile}->{"src"}->{$line}=$code; - } - else - { - # All other lines are not executable. - $gcovfiles{$gcovfile}->{"src"}->{$line}=$code; - } - } - close( FH ); - } - $filesref->{$file}->{"coverage"} = $gcovfiles{$gcovfile}; # store hashref - } - else - { - # No gcov output - the gcno file produced no coverage of the source/header - # Probably means that there is no coverage for the file (with the given - # test case - there may be some somewhere, but for the sake of speed, don't - # check (yet). - } - } -} - -# Run the git diff command to get the patch, then check the coverage -# output for the patch. +# Run the git diff command to get the patch +# Output - see parse_diff sub run_diff { - #print "run_diff(" . join(" ", @_) . ")\n"; my ($fh, $c) = $repo->command_output_pipe(@_); our @patch=(); while(<$fh>) @@ -343,23 +1040,8 @@ sub run_diff # @patch has slurped diff for all files... my $filesref = parse_diff ( \@patch ); - show_patch_lines($filesref) if $debug; - - print "Checking coverage:\n" if $debug; - - my $cwd=getcwd(); - chdir ".cov" || die "Can't find $cwd/.cov:$!\n"; + show_patch_lines($filesref) if $debug>1; - for my $file (keys(%$filesref)) - { - my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$}); - next if($path !~ /^dali/); - if($suffix eq ".cpp" || $suffix eq ".c" || $suffix eq ".h") - { - get_coverage($file, $filesref); - } - } - chdir $cwd; return $filesref; } @@ -378,44 +1060,56 @@ sub calc_patch_coverage_percentage my $uncovered_lines = 0; my $patchref = $filesref->{$file}->{"patch"}; - my $coverage_ref = $filesref->{$file}->{"coverage"}; - if( $coverage_ref ) + + my $abs_filename = File::Spec->rel2abs($file, $root); + my $sumcountref = $info_data{$abs_filename}->{"sum"}; + + if( $sumcountref ) { for my $patch (@$patchref) { for(my $i = 0; $i < $patch->[1]; $i++ ) { my $line = $i + $patch->[0]; - if($coverage_ref->{"covered"}->{$line}) - { - $covered_lines++; - $total_covered_lines++; - } - if($coverage_ref->{"uncovered"}->{$line}) + if(exists($sumcountref->{$line})) { - $uncovered_lines++; - $total_uncovered_lines++; + if( $sumcountref->{$line} > 0 ) + { + $covered_lines++; + $total_covered_lines++; + } + else + { + $uncovered_lines++; + $total_uncovered_lines++; + } } } } - $coverage_ref->{"covered_lines"} = $covered_lines; - $coverage_ref->{"uncovered_lines"} = $uncovered_lines; + $filesref->{$file}->{"covered_lines"} = $covered_lines; + $filesref->{$file}->{"uncovered_lines"} = $uncovered_lines; my $total = $covered_lines + $uncovered_lines; my $percent = 0; if($total > 0) { $percent = $covered_lines / $total; } - $coverage_ref->{"percent_covered"} = 100 * $percent; + $filesref->{$file}->{"percent_covered"} = 100 * $percent; + } + else + { + print "Can't find coverage data for $abs_filename\n"; } } my $total_exec = $total_covered_lines + $total_uncovered_lines; 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 ]; } +# +# sub patch_output { my $filesref = shift; @@ -424,18 +1118,22 @@ sub patch_output my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$}); next if($path !~ /^dali/); - my $patchref = $filesref->{$file}->{"patch"}; - my $b_lines_ref = $filesref->{$file}->{"b_lines"}; - my $coverage_ref = $filesref->{$file}->{"coverage"}; + my $fileref = $filesref->{$file}; + my $patchref = $fileref->{"patch"}; + my $b_lines_ref = $fileref->{"b_lines"}; + + my $abs_filename = File::Spec->rel2abs($file, $root); + my $sumcountref = $info_data{$abs_filename}->{"sum"}; + print BOLD, "$file "; - if($coverage_ref) + if($fileref) { - if( $coverage_ref->{"covered_lines"} > 0 + if( $fileref->{"covered_lines"} > 0 || - $coverage_ref->{"uncovered_lines"} > 0 ) + $fileref->{"uncovered_lines"} > 0 ) { - print GREEN, "Covered: " . $coverage_ref->{"covered_lines"}, RED, " Uncovered: " . $coverage_ref->{"uncovered_lines"}, RESET; + print GREEN, "Covered: " . $fileref->{"covered_lines"}, RED, " Uncovered: " . $fileref->{"uncovered_lines"}, RESET; } } else @@ -461,28 +1159,29 @@ sub patch_output my $line = $i + $patch->[0]; printf "%-6s ", $line; - if($coverage_ref) + if($sumcountref) { my $color; - if($coverage_ref->{"covered"}->{$line}) + if(exists($sumcountref->{$line})) { - $color=GREEN; - } - elsif($coverage_ref->{"uncovered"}->{$line}) - { - $color=BOLD . RED; + if($sumcountref->{$line} > 0) + { + $color=GREEN; + } + else + { + $color=BOLD . RED; + } } else { - $color=BLACK; + $color=CYAN; } - my $src=$coverage_ref->{"src"}->{$line}; - chomp($src); + my $src = $b_lines_ref->{$line}; print $color, "$src\n", RESET; } else { - # We don't have coverage data, so print it from the patch instead. my $src = $b_lines_ref->{$line}; print "$src\n"; } @@ -491,70 +1190,65 @@ sub patch_output } } - +# +# sub patch_html_output { my $filesref = shift; - my $html = HTML::Element->new('html'); - my $head = HTML::Element->new('head'); - my $title = HTML::Element->new('title'); - $title->push_content("Patch Coverage"); - $head->push_content($title, "\n"); - $html->push_content($head, "\n"); + open( my $filehandle, ">", $opt_output ) || die "Can't open $opt_output for writing:$!\n"; - my $body = HTML::Element->new('body'); - $body->attr('bgcolor', "white"); + my $OUTPUT_FH = select; + select $filehandle; + print < + + +Patch Coverage + + +EOH - foreach my $file (sort(keys(%$filesref))) + foreach my $file (keys(%$filesref)) { my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$}); next if($path !~ /^dali/); - my $patchref = $filesref->{$file}->{"patch"}; - my $b_lines_ref = $filesref->{$file}->{"b_lines"}; - my $coverage_ref = $filesref->{$file}->{"coverage"}; - - my $header = HTML::Element->new('h2'); - $header->push_content($file); - $body->push_content($header); - $body->push_content("\n"); - if($coverage_ref) + my $fileref = $filesref->{$file}; + my $patchref = $fileref->{"patch"}; + my $b_lines_ref = $fileref->{"b_lines"}; + + my $abs_filename = File::Spec->rel2abs($file, $root); + my $sumcountref = $info_data{$abs_filename}->{"sum"}; + + print "

$file

\n"; + + if($fileref) { - if( $coverage_ref->{"covered_lines"} > 0 + if( $fileref->{"covered_lines"} > 0 || - $coverage_ref->{"uncovered_lines"} > 0 ) + $fileref->{"uncovered_lines"} > 0 ) { - my $para = HTML::Element->new('p'); - my $covered = HTML::Element->new('span'); - $covered->attr('style', "color:green;"); - $covered->push_content("Covered: " . $coverage_ref->{"covered_lines"} ); - $para->push_content($covered); - - my $para2 = HTML::Element->new('p'); - my $uncovered = HTML::Element->new('span'); - $uncovered->attr('style', "color:red;"); - $uncovered->push_content("Uncovered: " . $coverage_ref->{"uncovered_lines"} ); - $para2->push_content($uncovered); - $body->push_content($para, $para2); - } - else - { - #print "coverage ref exists for $file:\n" . Data::Dumper::Dumper($coverage_ref) . "\n"; + print "

Covered: " . + $fileref->{"covered_lines"} . "

" . + "

Uncovered: " . + $fileref->{"uncovered_lines"} . "

"; } } else { - my $para = HTML::Element->new('p'); - my $span = HTML::Element->new('span'); + print "

"; + my $span=0; if($suffix eq ".cpp" || $suffix eq ".c" || $suffix eq ".h") { - $span->attr('style', "color:red;"); + print ""; + $span=1; } - $span->push_content("No coverage found"); - $para->push_content($span); - $body->push_content($para); + print "No coverage found"; + print "" if $span; } + print "

"; for my $patch (@$patchref) { @@ -563,71 +1257,54 @@ sub patch_html_output { $hunkstr .= " - " . ($patch->[0]+$patch->[1]-1); } + print "

" . $hunkstr . "

"; - my $para = HTML::Element->new('p'); - my $span = HTML::Element->new('span'); - $span->attr('style', "font-weight:bold;"); - $span->push_content($hunkstr); - $para->push_content($span); - $body->push_content($para); - - my $codeHunk = HTML::Element->new('pre'); + print "
";
             for(my $i = 0; $i < $patch->[1]; $i++ )
             {
                 my $line = $i + $patch->[0];
                 my $num_line_digits=log($line)/log(10);
                 for $i (0..(6-$num_line_digits-1))
                 {
-                    $codeHunk->push_content(" ");
+                    print " ";
                 }
+                print "$line  ";
 
-                $codeHunk->push_content("$line  ");
-
-                my $srcLine = HTML::Element->new('span');
-                if($coverage_ref)
+                if($sumcountref)
                 {
                     my $color;
-
-                    if($coverage_ref->{"covered"}->{$line})
+                    if(exists($sumcountref->{$line}))
                     {
-                        $srcLine->attr('style', "color:green;");
-                    }
-                    elsif($coverage_ref->{"uncovered"}->{$line})
-                    {
-                        $srcLine->attr('style', "color:red;font-weight:bold;");
+                        if($sumcountref->{$line} > 0)
+                        {
+                            print("");
+                        }
+                        else
+                        {
+                            print("");
+                        }
                     }
                     else
                     {
-                        $srcLine->attr('style', "color:black;font-weight:normal;");
+                        print("");
                     }
-                    my $src=$coverage_ref->{"src"}->{$line};
+                    my $src=$b_lines_ref->{$line};
                     chomp($src);
-                    $srcLine->push_content($src);
+                    print "$src\n";
                 }
                 else
                 {
-                    # We don't have coverage data, so print it from the patch instead.
                     my $src = $b_lines_ref->{$line};
-                    $srcLine->attr('style', "color:black;font-weight:normal;");
-                    $srcLine->push_content($src);
+                    print "$src\n";
                 }
-                $codeHunk->push_content($srcLine, "\n");
             }
-            $body->push_content($codeHunk, "\n");
+            print "<\pre>\n";
         }
     }
-    $body->push_content(HTML::Element->new('hr'));
-    $html->push_content($body, "\n");
 
-    open( my $filehandle, ">", $opt_output ) || die "Can't open $opt_output for writing:$!\n";
-
-    print $filehandle <
-EOH
-;
-    print $filehandle $html->as_HTML();
+    print $filehandle "
\n\n\n"; close $filehandle; + select $OUTPUT_FH; } @@ -635,14 +1312,32 @@ EOH ## MAIN ## ################################################################################ -my $cwd = getcwd(); -chdir $repo->wc_path(); -chdir "build/tizen"; -`make rename_cov_data`; +my $cwd = getcwd(); # expect this to be automated-tests folder -my @cmd=('--no-pager','diff','--no-ext-diff','-U0','--no-color'); +# execute coverage.sh, generating build/tizen/dali.info from lib, and +# *.dir/dali.info. Don't generate html +print `./coverage.sh -n`; +chdir ".."; +$root = getcwd(); + +our %info_data; # Hash of all data from .info files +my @info_files = split(/\n/, `find . -name dali.info`); +my %new_info; + +# Read in all specified .info files +foreach (@info_files) +{ + %new_info = %{read_info_file($_)}; + + # Combine %new_info with %info_data + %info_data = %{combine_info_files(\%info_data, \%new_info)}; +} + +# Generate git diff command +my @cmd=('--no-pager','diff','--no-ext-diff','-U0','--no-color'); my $status = $repo->command("status", "-s"); + if( $status eq "" && !scalar(@ARGV)) { # There are no changes in the index or working tree, and @@ -674,6 +1369,8 @@ else } push @cmd, @ARGV; + +# Execute diff & coverage from root directory my $filesref = run_diff(@cmd); chdir $cwd; @@ -693,6 +1390,9 @@ if( $filecount == 0 ) exit 0; # Exit with no error. } +#print_simplified_info() if $debug; +#exit 0; + my $percentref = calc_patch_coverage_percentage($filesref); if($percentref->[0] == 0) { @@ -717,6 +1417,7 @@ elsif( ! $opt_quiet ) print RESET; } +printf("Line Coverage: %d/%d\n", $percentref->[2], $percentref->[0]); printf("Percentage of change covered: %5.2f%\n", $percent); exit($percent<90); diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp index a694eeb..9e8c7a8 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.cpp @@ -112,6 +112,31 @@ bool TestGlAbstraction::IsSurfacelessContextSupported() const 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)); diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h index 99dca10..861f4ae 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h @@ -61,6 +61,16 @@ public: 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 */ @@ -1889,6 +1899,10 @@ public: { } + inline void BlendBarrier(void) + { + } + private: inline void AddUniformCallToTraceStack(GLint location, std::string& value) { diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp index 0b814e7..b53630d 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp @@ -21,8 +21,11 @@ #include #include #include + +#include #include +#include #include #include #include @@ -31,6 +34,8 @@ namespace TestHarness { typedef std::map RunningTestCases; +const double MAXIMUM_CHILD_LIFETIME(60.0f); // 1 minute + const char* basename(const char* path) { const char* ptr = path; @@ -247,25 +252,42 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re else // Parent process { TestCase tc(nextTestCase, tc_array[nextTestCase].name); + tc.startTime = std::chrono::steady_clock::now(); + children[pid] = tc; nextTestCase++; numRunningChildren++; } } - // Wait for the next child to finish - + // Check to see if any children have finished yet int32_t status = 0; - int32_t childPid = waitpid(-1, &status, 0); - if(childPid == -1) + int32_t childPid = waitpid(-1, &status, WNOHANG); + if(childPid == 0) + { + // No children have finished. + // Check if any have exceeded execution time + auto endTime = std::chrono::steady_clock::now(); + + for(auto& tc : children) + { + std::chrono::steady_clock::duration timeSpan = endTime - tc.second.startTime; + std::chrono::duration seconds = std::chrono::duration_cast>(timeSpan); + if(seconds.count() > MAXIMUM_CHILD_LIFETIME) + { + // Kill the child process. A subsequent call to waitpid will process signal result below. + kill(tc.first, SIGKILL); + } + } + } + else if(childPid == -1) // waitpid errored { perror("waitpid"); exit(EXIT_STATUS_WAITPID_FAILED); } - - if(WIFEXITED(status)) + else // a child has finished { - if(childPid > 0) + if(WIFEXITED(status)) { int32_t testResult = WEXITSTATUS(status); if(testResult) @@ -280,14 +302,11 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re } numRunningChildren--; } - } - - else if(WIFSIGNALED(status) || WIFSTOPPED(status)) - { - status = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status); - if(childPid > 0) + else if(WIFSIGNALED(status) || WIFSTOPPED(status)) { + status = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status); + RunningTestCases::iterator iter = children.find(childPid); if(iter != children.end()) { diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-harness.h b/automated-tests/src/dali/dali-test-suite-utils/test-harness.h index c4b5e03..b210918 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-harness.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-harness.h @@ -20,6 +20,7 @@ #include #include +#include #include namespace TestHarness @@ -39,29 +40,34 @@ const int32_t MAX_NUM_CHILDREN(16); struct TestCase { - int32_t testCase; - const char* testCaseName; + int32_t testCase; + const char* testCaseName; + std::chrono::steady_clock::time_point startTime; TestCase() : testCase(0), - testCaseName(NULL) + testCaseName(NULL), + startTime() { } TestCase(int32_t tc, const char* name) : testCase(tc), - testCaseName(name) + testCaseName(name), + startTime() { } TestCase(const TestCase& rhs) : testCase(rhs.testCase), - testCaseName(rhs.testCaseName) + testCaseName(rhs.testCaseName), + startTime(rhs.startTime) { } TestCase& operator=(const TestCase& rhs) { testCase = rhs.testCase; testCaseName = rhs.testCaseName; + startTime = rhs.startTime; return *this; } }; diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp old mode 100644 new mode 100755 index 0b2a35b..5ac38fa --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -7926,6 +7927,43 @@ int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void) END_TEST; } +int UtcDaliActorTouchAreaPropertyP(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get(); + DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION); + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f)); + touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get(); + DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION); + END_TEST; +} + +int UtcDaliActorTouchAreaPropertyN(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Make sure setting invalid types does not cause a crash + try + { + actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f); + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE); + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map()); + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array()); + tet_result(TET_PASS); + } + catch(...) + { + tet_result(TET_FAIL); + } + END_TEST; +} + int UtcDaliActorLowerBelowNegative(void) { TestApplication application; @@ -8575,3 +8613,40 @@ int UtcDaliActorGetParentNegative(void) } END_TEST; } + +int UtcDaliActorPropertyBlendEquation(void) +{ + TestApplication application; + + tet_infoline("Test SetProperty AdvancedBlendEquation"); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer1 = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 0.1f); + + actor.AddRenderer(renderer1); + actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400)); + application.GetScene().Add(actor); + + if( !Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) ) + { + actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN ); + int equation = actor.GetProperty( Dali::DevelActor::Property::BLEND_EQUATION ); + DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), false, TEST_LOCATION ); + } + + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) ) + { + actor.SetProperty( Dali::DevelActor::Property::BLEND_EQUATION, Dali::DevelBlendEquation::SCREEN ); + int equation = actor.GetProperty( Dali::DevelActor::Property::BLEND_EQUATION ); + DALI_TEST_EQUALS( ( Dali::DevelBlendEquation::SCREEN == equation ), true, TEST_LOCATION ); + } + + Renderer renderer2 = Renderer::New( geometry, shader ); + actor.AddRenderer(renderer2); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Layer.cpp b/automated-tests/src/dali/utc-Dali-Layer.cpp index c3b5410..a74a42f 100644 --- a/automated-tests/src/dali/utc-Dali-Layer.cpp +++ b/automated-tests/src/dali/utc-Dali-Layer.cpp @@ -144,7 +144,7 @@ int UtcDaliLayerGetDepth(void) END_TEST; } -int UtcDaliLayerRaise(void) +int UtcDaliLayerRaise1(void) { tet_infoline("Testing Dali::Layer::Raise()"); TestApplication application; @@ -168,7 +168,34 @@ int UtcDaliLayerRaise(void) END_TEST; } -int UtcDaliLayerLower(void) +int UtcDaliLayerRaise2(void) +{ + tet_infoline("Testing Dali::Layer raise Action"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + + application.GetScene().Add(layer1); + application.GetScene().Add(layer2); + DALI_TEST_EQUALS(layer1.GetProperty(Layer::Property::DEPTH), 1u, TEST_LOCATION); + + layer1.Raise(); + DALI_TEST_EQUALS(layer1.GetProperty(Layer::Property::DEPTH), 2u, TEST_LOCATION); + + // get root + Layer root = application.GetScene().GetLayer(0); + DALI_TEST_EQUALS(root.GetProperty(Layer::Property::DEPTH), 0u, TEST_LOCATION); + + GetImplementation(root).DoAction("raise", Property::Map()); + + DALI_TEST_EQUALS(root.GetProperty(Layer::Property::DEPTH), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer1.GetProperty(Layer::Property::DEPTH), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetProperty(Layer::Property::DEPTH), 0u, TEST_LOCATION); + END_TEST; +} + + +int UtcDaliLayerLower1(void) { tet_infoline("Testing Dali::Layer::Lower()"); TestApplication application; @@ -192,7 +219,33 @@ int UtcDaliLayerLower(void) END_TEST; } -int UtcDaliLayerRaiseToTop(void) + +int UtcDaliLayerLower2(void) +{ + tet_infoline("Testing Dali::Layer lower Action"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + + application.GetScene().Add(layer1); + application.GetScene().Add(layer2); + DALI_TEST_EQUALS(layer2.GetProperty(Layer::Property::DEPTH), 2u, TEST_LOCATION); + + layer2.Lower(); + DALI_TEST_EQUALS(layer2.GetProperty(Layer::Property::DEPTH), 1u, TEST_LOCATION); + + // get root + Layer root = application.GetScene().GetLayer(0); + GetImplementation(root).DoAction("lower", Property::Map()); + DALI_TEST_EQUALS(root.GetProperty(Layer::Property::DEPTH), 0u, TEST_LOCATION); + + GetImplementation(layer2).DoAction("lower", Property::Map()); + DALI_TEST_EQUALS(root.GetProperty(Layer::Property::DEPTH), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetProperty(Layer::Property::DEPTH), 0u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerRaiseToTop1(void) { tet_infoline("Testing Dali::Layer::RaiseToTop()"); TestApplication application; @@ -218,7 +271,33 @@ int UtcDaliLayerRaiseToTop(void) END_TEST; } -int UtcDaliLayerLowerToBottom(void) +int UtcDaliLayerRaiseToTop2(void) +{ + tet_infoline("Testing Dali::Layer raiseToTop Action"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + Layer layer3 = Layer::New(); + + application.GetScene().Add(layer1); + application.GetScene().Add(layer2); + application.GetScene().Add(layer3); + Layer root = application.GetScene().GetLayer(0); + + DALI_TEST_EQUALS(root.GetProperty(Layer::Property::DEPTH), 0u, TEST_LOCATION); + DALI_TEST_EQUALS(layer1.GetProperty(Layer::Property::DEPTH), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetProperty(Layer::Property::DEPTH), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(layer3.GetProperty(Layer::Property::DEPTH), 3u, TEST_LOCATION); + + GetImplementation(layer1).DoAction("raiseToTop", Property::Map()); + DALI_TEST_EQUALS(layer1.GetProperty(Layer::Property::DEPTH), 3u, TEST_LOCATION); + + GetImplementation(root).DoAction("raiseToTop", Property::Map()); + DALI_TEST_EQUALS(root.GetProperty(Layer::Property::DEPTH), 3u, TEST_LOCATION); + END_TEST; +} + +int UtcDaliLayerLowerToBottom1(void) { tet_infoline("Testing Dali::Layer::LowerToBottom()"); TestApplication application; @@ -239,6 +318,28 @@ int UtcDaliLayerLowerToBottom(void) END_TEST; } +int UtcDaliLayerLowerToBottom2(void) +{ + tet_infoline("Testing Dali::Layer lowerToBottom Action"); + TestApplication application; + Layer layer1 = Layer::New(); + Layer layer2 = Layer::New(); + Layer layer3 = Layer::New(); + + application.GetScene().Add(layer1); + application.GetScene().Add(layer2); + application.GetScene().Add(layer3); + + DALI_TEST_EQUALS(layer1.GetProperty(Layer::Property::DEPTH), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(layer2.GetProperty(Layer::Property::DEPTH), 2u, TEST_LOCATION); + DALI_TEST_EQUALS(layer3.GetProperty(Layer::Property::DEPTH), 3u, TEST_LOCATION); + + GetImplementation(layer3).DoAction("lowerToBottom", Property::Map()); + DALI_TEST_EQUALS(layer3.GetProperty(Layer::Property::DEPTH), 0u, TEST_LOCATION); + END_TEST; +} + + int UtcDaliLayerSetClipping(void) { tet_infoline("Testing Dali::Layer::SetClipping()"); diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index d77fabc..b50d710 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -21,7 +21,7 @@ #include #include #include - +#include #include #include @@ -256,12 +256,13 @@ int UtcDaliRendererDefaultProperties(void) DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ) DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY ) DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR ) + DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION ) */ Geometry geometry = CreateQuadGeometry(); Shader shader = CreateShader(); Renderer renderer = Renderer::New(geometry, shader); - DALI_TEST_EQUALS(renderer.GetPropertyCount(), 26, TEST_LOCATION); + DALI_TEST_EQUALS(renderer.GetPropertyCount(), 27, TEST_LOCATION); TEST_RENDERER_PROPERTY(renderer, "depthIndex", Property::INTEGER, true, false, false, Renderer::Property::DEPTH_INDEX, TEST_LOCATION); TEST_RENDERER_PROPERTY(renderer, "faceCullingMode", Property::INTEGER, true, false, false, Renderer::Property::FACE_CULLING_MODE, TEST_LOCATION); @@ -289,6 +290,7 @@ int UtcDaliRendererDefaultProperties(void) TEST_RENDERER_PROPERTY(renderer, "stencilOperationOnZPass", Property::INTEGER, true, false, false, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, TEST_LOCATION); TEST_RENDERER_PROPERTY(renderer, "opacity", Property::FLOAT, true, true, true, DevelRenderer::Property::OPACITY, TEST_LOCATION); TEST_RENDERER_PROPERTY(renderer, "renderingBehavior", Property::INTEGER, true, false, false, DevelRenderer::Property::RENDERING_BEHAVIOR, TEST_LOCATION); + TEST_RENDERER_PROPERTY(renderer, "blendEquation", Property::INTEGER, true, false, false, DevelRenderer::Property::BLEND_EQUATION, TEST_LOCATION); END_TEST; } @@ -654,6 +656,127 @@ int UtcDaliRendererBlendOptions04(void) END_TEST; } +int UtcDaliRendererBlendOptions05(void) +{ + TestApplication application; + + tet_infoline("Test SetAdvancedBlendEquation "); + + Geometry geometry = CreateQuadGeometry(); + Shader shader = CreateShader(); + Renderer renderer = Renderer::New( geometry, shader ); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::OPACITY, 0.1f); + + actor.AddRenderer(renderer); + actor.SetProperty(Actor::Property::SIZE, Vector2(400, 400)); + application.GetScene().Add(actor); + + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MAX ) ) + { + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MAX ); + int equationRgb = renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::MAX, equationRgb, TEST_LOCATION ); + } + + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) ) + { + renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true ); + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN ); + int equation = renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ); + + DALI_TEST_EQUALS( (int)DevelBlendEquation::SCREEN, equation, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelRenderer::IsAdvancedBlendEquationApplied( renderer ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + } + + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MULTIPLY ) ) + { + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::ADD ); + renderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true ); + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION_RGB, DevelBlendEquation::SCREEN ); + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION_ALPHA, DevelBlendEquation::MULTIPLY ); + int equationRgb = renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION_RGB ); + int equationAlpha = renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION_ALPHA ); + + DALI_TEST_EQUALS( (int)DevelBlendEquation::ADD, equationRgb, TEST_LOCATION ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::ADD, equationAlpha, TEST_LOCATION ); + DALI_TEST_EQUALS( DevelRenderer::IsAdvancedBlendEquationApplied( renderer ), false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + } + + tet_infoline("Error Checking\n"); + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MULTIPLY ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::OVERLAY ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::DARKEN ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::LIGHTEN ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR_DODGE ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR_BURN ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::HARD_LIGHT ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SOFT_LIGHT ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::DIFFERENCE ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::EXCLUSION ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::HUE ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SATURATION ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::COLOR ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::LUMINOSITY ) ) + { + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MULTIPLY ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::MULTIPLY, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SCREEN ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::SCREEN, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::OVERLAY ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::OVERLAY, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DARKEN ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::DARKEN, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LIGHTEN ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::LIGHTEN, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_DODGE ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR_DODGE, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR_BURN ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR_BURN, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HARD_LIGHT ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::HARD_LIGHT, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SOFT_LIGHT ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::SOFT_LIGHT, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::DIFFERENCE ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::DIFFERENCE, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::EXCLUSION ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::EXCLUSION, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::HUE ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::HUE, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::SATURATION ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::SATURATION, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::COLOR ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::COLOR, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + + renderer.SetProperty( DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::LUMINOSITY ); + DALI_TEST_EQUALS( (int)DevelBlendEquation::LUMINOSITY, renderer.GetProperty( DevelRenderer::Property::BLEND_EQUATION ), TEST_LOCATION ); + } + + END_TEST; +} + int UtcDaliRendererSetBlendMode01(void) { TestApplication application; @@ -2341,6 +2464,21 @@ int UtcDaliRendererEnumProperties(void) CheckEnumerationProperty(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT"); CheckEnumerationProperty(application, renderer, Renderer::Property::STENCIL_OPERATION_ON_Z_PASS, StencilOperation::KEEP, StencilOperation::REPLACE, StencilOperation::INCREMENT, "INCREMENT"); + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MAX ) && + Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::MIN ) ) + { + application.SendNotification(); + application.Render(); + CheckEnumerationProperty< DevelBlendEquation::Type >( application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::REVERSE_SUBTRACT, DevelBlendEquation::MAX, DevelBlendEquation::MIN, "MIN" ); + } + + if( Dali::Capabilities::IsBlendEquationSupported( DevelBlendEquation::SCREEN ) ) + { + application.SendNotification(); + application.Render(); + CheckEnumerationProperty< DevelBlendEquation::Type >( application, renderer, DevelRenderer::Property::BLEND_EQUATION, DevelBlendEquation::MIN, DevelBlendEquation::MULTIPLY, DevelBlendEquation::SCREEN, "SCREEN" ); + } + END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index 90fe393..303d672 100644 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -178,6 +178,8 @@ struct TouchFunctor signalData.receivedTouchEvent = handle; } + // Allows functor to be used for signal connection by string. + // No data stored, though, so quite useless. void operator()() { signalData.functorCalled = true; @@ -222,6 +224,25 @@ struct WheelEventReceivedFunctor WheelEventSignalData& signalData; }; +// Functor that sets the data when wheel-event signal is received +struct WheelEventReceivedVoidFunctor +{ + WheelEventReceivedVoidFunctor(WheelEventSignalData& data) + : signalData(data) + { + } + + // Signals connected through BaseObject::DoConnectSignal can only take void() methods + bool operator()(void) + { + signalData.functorCalled = true; + return true; + } + + WheelEventSignalData& signalData; +}; + + bool DummyTouchCallback(Actor actor, const TouchEvent& touch) { return true; @@ -844,6 +865,27 @@ int UtcDaliStageEventProcessingFinishedP(void) END_TEST; } +int UtcDaliStageEventProcessingFinishedP2(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + tet_printf("UtcDaliStageEventProcessingFinishedSignalP2 - check event processing finished signal connection by name\n"); + + bool eventProcessingFinished = false; + EventProcessingFinishedFunctor functor(eventProcessingFinished); + GetImplementation(stage).ConnectSignal(&application, "eventProcessingFinished", functor); + + Actor actor(Actor::New()); + stage.Add(actor); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(eventProcessingFinished); + + END_TEST; +} + int UtcDaliStageEventProcessingFinishedN(void) { TestApplication application; @@ -1103,6 +1145,35 @@ int UtcDaliStageTouchedSignalP(void) END_TEST; } + +int UtcDaliStageTouchedSignalP2(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + tet_printf("UtcDaliStageTouchedSignalP2 - check touched signal connection by name\n"); + + TouchedSignalData data; + TouchFunctor functor(data); + GetImplementation(stage).ConnectSignal(&application, "touched", functor); + + // Render and notify. + application.SendNotification(); + application.Render(); + + // Basic test: No actors, single touch (down then up). + { + GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f)); + + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + + GenerateTouch(application, PointState::UP, Vector2(10.0f, 10.0f)); + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + data.Reset(); + } + END_TEST; +} + int UtcDaliStageTouchedSignalN(void) { TestApplication application; @@ -1226,6 +1297,32 @@ int UtcDaliStageSignalWheelEventP(void) END_TEST; } + +int UtcDaliStageSignalWheelEventP2(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + tet_printf("UtcDaliStageSignalWheelEventP2 - check wheel signal connection by name\n"); + + WheelEventSignalData data; + WheelEventReceivedVoidFunctor functor(data); + GetImplementation(stage).ConnectSignal(&application, "wheelEvent", functor); + + Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u); + application.ProcessEvent(event); + + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + // It's meaningless, since there's no data passed to the functor :/ + + data.Reset(); + + Integration::WheelEvent event2(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1000u); + application.ProcessEvent(event2); + + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + END_TEST; +} + int UtcDaliStageContextLostSignalP(void) { TestApplication application; @@ -1242,6 +1339,23 @@ int UtcDaliStageContextLostSignalP(void) END_TEST; } +int UtcDaliStageContextLostSignalP2(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + tet_printf("UtcDaliStageContextLostSignalP2 - check context loss signal connection by name\n"); + + bool contextLost = false; + ContextStatusFunctor contextLostFunctor(contextLost); + GetImplementation(stage).ConnectSignal(&application, "contextLost", contextLostFunctor); + + Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier(); + notifier->NotifyContextLost(); + DALI_TEST_EQUALS(contextLost, true, TEST_LOCATION); + + END_TEST; +} + int UtcDaliStageContextLostSignalN(void) { TestApplication application; @@ -1283,6 +1397,27 @@ int UtcDaliStageContextRegainedSignalP(void) END_TEST; } +int UtcDaliStageContextRegainedSignalP2(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + tet_printf("UtcDaliStageContextRegainedSignalP2 - check context regained signal connection by name\n"); + + bool contextRegained = false; + ContextStatusFunctor contextRegainedFunctor(contextRegained); + GetImplementation(stage).ConnectSignal(&application, "contextRegained", contextRegainedFunctor); + + Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier(); + notifier->NotifyContextLost(); + notifier->NotifyContextRegained(); + DALI_TEST_EQUALS(contextRegained, true, TEST_LOCATION); + + END_TEST; +} + + + + int UtcDaliStageContextRegainedSignalN(void) { TestApplication application; @@ -1323,6 +1458,22 @@ int UtcDaliStageSceneCreatedSignalP(void) END_TEST; } +int UtcDaliStageSceneCreatedSignalP2(void) +{ + TestApplication application; + Stage stage = Stage::GetCurrent(); + + bool signalCalled = false; + SceneCreatedStatusFunctor sceneCreatedFunctor(signalCalled); + GetImplementation(stage).ConnectSignal(&application, "sceneCreated", sceneCreatedFunctor); + + Integration::Core& core = application.GetCore(); + core.SceneCreated(); + DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION); + + END_TEST; +} + int UtcDaliStageSceneCreatedSignalN(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp index 3c01346..275aa2a 100755 --- a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp @@ -2121,3 +2121,66 @@ int UtcDaliTouchEventIntercept(void) END_TEST; } +int UtcDaliTouchArea(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + + application.GetScene().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Connect to actor's touched signal + SignalData data; + TouchEventFunctor functor(data, false /* Do not consume */); + actor.TouchedSignal().Connect(&application, functor); + + // Emit a down signal + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(110.0f, 110.0f))); + // The actor touched signal is not called because the touch area is outside actor. + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // set a bigger touch area + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(200.0f, 200.0f)); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit a down signal + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(110.0f, 110.0f))); + // The actor touched signal is called because the touch area is inside touchArea. + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION); + DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor); + data.Reset(); + + // set a smaller touch area + actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(50.0f, 50.0f)); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Emit a down signal + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(80.0f, 80.0f))); + // The actor touched signal is not called because the touch area is outside touchArea. + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + data.Reset(); + + // Emit a down signal + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(30.0f, 30.0f))); + // The actor touched signal is called because the touch area is inside touchArea. + DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); + DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION); + DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor); + data.Reset(); + + END_TEST; +} diff --git a/dali/devel-api/actors/actor-devel.h b/dali/devel-api/actors/actor-devel.h index cda374f..5821af0 100755 --- a/dali/devel-api/actors/actor-devel.h +++ b/dali/devel-api/actors/actor-devel.h @@ -117,7 +117,30 @@ enum Type * @details Name "captureAllTouchAfterStart", type Property::BOOLEAN * @note Default is false, i.e. actor under touch event will receive the touch even if touch started on this actor */ - CAPTURE_ALL_TOUCH_AFTER_START + CAPTURE_ALL_TOUCH_AFTER_START, + + /** + * @brief If you set the TOUCH_AREA on an actor, when you touch the actor, the touch area is used rather than the size of the actor + * @details Name "touchArea", type Property::Vector2 + * @note Default is Vector2::ZERO. + * @note for example + * Actor actor = Actor::New(); + * actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f)); + * actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(200.0f, 200.0f)); + * actor.TouchedSignal().Connect(OnTouchCallback); + * + * If you want to reset the touch area to an area different with the size of the actor, you can set this TOUCH_AREA property. + */ + TOUCH_AREA, + + /** + * @brief Determines which blend equation will be used to render renderers of this actor. + * @pre To use Advanced Blend Equation(DevelBlendEquation::MULTIPLY ~ DevelBlendEquation::LUMINOSITY), the color to be rendered should be pre-multipled alpha. + * @details Name "blendEquation", type Property::INTEGER. + * @note Color of each renderer will be blended with rendering framebuffer. + * @note To check the blend equation is supported in the system, use Dali::Capabilities::IsBlendEquationSupported + */ + BLEND_EQUATION }; } // namespace Property diff --git a/dali/devel-api/animation/animation-data.cpp b/dali/devel-api/animation/animation-data.cpp index 844240a..9331efd 100644 --- a/dali/devel-api/animation/animation-data.cpp +++ b/dali/devel-api/animation/animation-data.cpp @@ -20,9 +20,7 @@ namespace Dali { -AnimationData::AnimationData() -{ -} +AnimationData::AnimationData() = default; AnimationData::~AnimationData() { diff --git a/dali/devel-api/animation/path-constrainer.cpp b/dali/devel-api/animation/path-constrainer.cpp index 47ae9d7..e431b99 100644 --- a/dali/devel-api/animation/path-constrainer.cpp +++ b/dali/devel-api/animation/path-constrainer.cpp @@ -35,18 +35,11 @@ PathConstrainer PathConstrainer::DownCast(BaseHandle handle) return PathConstrainer(dynamic_cast(handle.GetObjectPtr())); } -PathConstrainer::PathConstrainer() -{ -} +PathConstrainer::PathConstrainer() = default; -PathConstrainer::~PathConstrainer() -{ -} +PathConstrainer::~PathConstrainer() = default; -PathConstrainer::PathConstrainer(const PathConstrainer& handle) -: Handle(handle) -{ -} +PathConstrainer::PathConstrainer(const PathConstrainer& handle) = default; PathConstrainer::PathConstrainer(Internal::PathConstrainer* internal) : Handle(internal) diff --git a/dali/devel-api/common/capabilities.cpp b/dali/devel-api/common/capabilities.cpp new file mode 100644 index 0000000..fb04891 --- /dev/null +++ b/dali/devel-api/common/capabilities.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include +#include + +namespace Dali +{ + +namespace Capabilities +{ + +bool IsBlendEquationSupported( BlendEquation::Type blendEquation ) +{ + return IsBlendEquationSupported( static_cast( blendEquation ) ); +} + +bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ) +{ + Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); + return tls.IsBlendEquationSupported(blendEquation); +} + +} // namespace Capabilities + +} // namespace Dali \ No newline at end of file diff --git a/dali/devel-api/common/capabilities.h b/dali/devel-api/common/capabilities.h new file mode 100644 index 0000000..f56c27d --- /dev/null +++ b/dali/devel-api/common/capabilities.h @@ -0,0 +1,48 @@ +#ifndef DALI_CAPABILITIES_H +#define DALI_CAPABILITIES_H + +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Capabilities +{ + +/** + * @brief Returns whether the blend equation is supported in the system or not. + * @param[in] blendEquation blend equation to be checked. + * @return True if the blend equation supported. + */ +DALI_CORE_API bool IsBlendEquationSupported( BlendEquation::Type blendEquation ); + +/** + * @brief Returns whether the blend equation is supported in the system or not. + * @param[in] blendEquation blend equation to be checked. + * @return True if the blend equation supported. + */ +DALI_CORE_API bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ); + +} // namespace Capabilities + +} // namespace Dali + +#endif // DALI_CAPABILITIES_H \ No newline at end of file diff --git a/dali/devel-api/common/owner-container.h b/dali/devel-api/common/owner-container.h index d276cd7..c8c37d5 100644 --- a/dali/devel-api/common/owner-container.h +++ b/dali/devel-api/common/owner-container.h @@ -48,9 +48,7 @@ public: /** * Create a pointer-container. */ - OwnerContainer() - { - } + OwnerContainer() = default; /** * Non-virtual destructor; OwnerContainer is not suitable as base class. @@ -88,6 +86,21 @@ public: } /** + * Erases a range of elements.(delete from heap). + */ + Iterator Erase(Iterator first, Iterator last) + { + auto itr = first; + while(itr < last) + { + Delete(*itr); + ++itr; + } + + return Vector::Erase(first, last); + } + + /** * Erase an object from OwnerContainer * @param object to remove */ diff --git a/dali/devel-api/common/singleton-service.cpp b/dali/devel-api/common/singleton-service.cpp index 49ff27e..716cc63 100644 --- a/dali/devel-api/common/singleton-service.cpp +++ b/dali/devel-api/common/singleton-service.cpp @@ -23,18 +23,14 @@ namespace Dali { -SingletonService::SingletonService() -{ -} +SingletonService::SingletonService() = default; SingletonService SingletonService::Get() { return Internal::ThreadLocalStorage::GetSingletonService(); } -SingletonService::~SingletonService() -{ -} +SingletonService::~SingletonService() = default; void SingletonService::Register(const std::type_info& info, BaseHandle singleton) { diff --git a/dali/devel-api/common/stage.cpp b/dali/devel-api/common/stage.cpp index 07c2deb..1729b5a 100644 --- a/dali/devel-api/common/stage.cpp +++ b/dali/devel-api/common/stage.cpp @@ -30,24 +30,13 @@ namespace Dali { using Internal::Core; -Stage::Stage() -{ -} +Stage::Stage() = default; -Stage::~Stage() -{ -} +Stage::~Stage() = default; -Stage::Stage(const Stage& handle) -: BaseHandle(handle) -{ -} +Stage::Stage(const Stage& handle) = default; -Stage& Stage::operator=(const Stage& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +Stage& Stage::operator=(const Stage& rhs) = default; Stage::Stage(Internal::Stage* internal) : BaseHandle(internal) diff --git a/dali/devel-api/events/touch-point.cpp b/dali/devel-api/events/touch-point.cpp index eba10cb..07f90d0 100644 --- a/dali/devel-api/events/touch-point.cpp +++ b/dali/devel-api/events/touch-point.cpp @@ -36,8 +36,6 @@ TouchPoint::TouchPoint(int32_t id, PointState::Type state, float screenX, float { } -TouchPoint::~TouchPoint() -{ -} +TouchPoint::~TouchPoint() = default; } // namespace Dali diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index a6dba21..d65e823 100644 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -9,6 +9,7 @@ SET( devel_api_src_files ${devel_api_src_dir}/animation/animation-devel.cpp ${devel_api_src_dir}/animation/path-constrainer.cpp ${devel_api_src_dir}/common/addon-binder.cpp + ${devel_api_src_dir}/common/capabilities.cpp ${devel_api_src_dir}/common/hash.cpp ${devel_api_src_dir}/common/singleton-service.cpp ${devel_api_src_dir}/common/stage-devel.cpp @@ -64,6 +65,7 @@ SET( devel_api_core_animation_header_files SET( devel_api_core_common_header_files ${devel_api_src_dir}/common/addon-binder.h ${devel_api_src_dir}/common/bitwise-enum.h + ${devel_api_src_dir}/common/capabilities.h ${devel_api_src_dir}/common/circular-queue.h ${devel_api_src_dir}/common/hash.h ${devel_api_src_dir}/common/singleton-service.h diff --git a/dali/devel-api/rendering/renderer-devel.cpp b/dali/devel-api/rendering/renderer-devel.cpp index 303f389..d0913b6 100644 --- a/dali/devel-api/rendering/renderer-devel.cpp +++ b/dali/devel-api/rendering/renderer-devel.cpp @@ -16,12 +16,18 @@ */ // INTERNAL INCLUDES +#include #include namespace Dali { namespace DevelRenderer { +bool IsAdvancedBlendEquationApplied(const Renderer& renderer) +{ + return GetImplementation(renderer).IsAdvancedBlendEquationApplied(); +} + void AddDrawCommand(Dali::Renderer renderer, const DrawCommand& drawCommand) { auto& impl = GetImplementation(renderer); diff --git a/dali/devel-api/rendering/renderer-devel.h b/dali/devel-api/rendering/renderer-devel.h index 59d9247..9c1ad32 100644 --- a/dali/devel-api/rendering/renderer-devel.h +++ b/dali/devel-api/rendering/renderer-devel.h @@ -23,6 +23,43 @@ namespace Dali { + +namespace DevelBlendEquation +{ + +/** + * @brief Enumeration for blend equation. + */ +enum Type +{ + ADD = Dali::BlendEquation::ADD, + SUBTRACT = Dali::BlendEquation::SUBTRACT, + REVERSE_SUBTRACT = Dali::BlendEquation::REVERSE_SUBTRACT, + + // OpenGL es 3.0 enumeration + MIN = 0x8007, + MAX = 0x8008, + + // OpenGL es 3.2 or KHR_Blend_Equation_Advanced enumeration + MULTIPLY = 0x9294, + SCREEN = 0x9295, + OVERLAY = 0x9296, + DARKEN = 0x9297, + LIGHTEN = 0x9298, + COLOR_DODGE = 0x9299, + COLOR_BURN = 0x929A, + HARD_LIGHT = 0x929B, + SOFT_LIGHT = 0x929C, + DIFFERENCE = 0x929E, + EXCLUSION = 0x92A0, + HUE = 0x92AD, + SATURATION = 0x92AE, + COLOR = 0x92AF, + LUMINOSITY = 0x92B0 +}; + +} // namespace DevelBlendEquation + namespace DevelRenderer { /** @@ -104,6 +141,12 @@ enum Type * @details Name "renderingBehavior", type Property::INTEGER. */ RENDERING_BEHAVIOR = STENCIL_OPERATION_ON_Z_PASS + 2, + + /** + * @brief name "blendEquation", type INTEGER + * @note The default value is BlendEquation::ADD + */ + BLEND_EQUATION, }; } // namespace Property @@ -120,6 +163,14 @@ enum Type } // namespace Rendering + +/** + * @brief Query whether current blend equation is advanced option. + * @param[in] renderer to be checked whether it has been applied advanced blend equation or not + * @return True if current blend equation is advanced. + */ +DALI_CORE_API bool IsAdvancedBlendEquationApplied( const Renderer& renderer ); + } // namespace DevelRenderer } // namespace Dali diff --git a/dali/devel-api/signals/signal-delegate.h b/dali/devel-api/signals/signal-delegate.h index 18a5286..4980851 100644 --- a/dali/devel-api/signals/signal-delegate.h +++ b/dali/devel-api/signals/signal-delegate.h @@ -44,9 +44,7 @@ public: /** * @brief Destructor. */ - ~SignalDelegate() - { - } + ~SignalDelegate() = default; public: /** diff --git a/dali/devel-api/update/update-proxy.cpp b/dali/devel-api/update/update-proxy.cpp index c2ba2ad..a79159b 100644 --- a/dali/devel-api/update/update-proxy.cpp +++ b/dali/devel-api/update/update-proxy.cpp @@ -93,8 +93,6 @@ UpdateProxy::UpdateProxy(Internal::UpdateProxy& impl) { } -UpdateProxy::~UpdateProxy() -{ -} +UpdateProxy::~UpdateProxy() = default; } // namespace Dali diff --git a/dali/integration-api/bitmap.h b/dali/integration-api/bitmap.h index 7a21048..1500f12 100644 --- a/dali/integration-api/bitmap.h +++ b/dali/integration-api/bitmap.h @@ -266,9 +266,7 @@ public: /** * Virtual destructor, no deletion through this interface */ - virtual ~PackedPixelsProfile() - { - } + virtual ~PackedPixelsProfile() = default; }; /** @@ -316,9 +314,7 @@ public: /** * Virtual destructor, no deletion through this interface */ - virtual ~CompressedProfile() - { - } + virtual ~CompressedProfile() = default; }; virtual const CompressedProfile* GetCompressedProfile() const diff --git a/dali/integration-api/context-notifier.h b/dali/integration-api/context-notifier.h index cd437e1..4e9c136 100644 --- a/dali/integration-api/context-notifier.h +++ b/dali/integration-api/context-notifier.h @@ -50,9 +50,7 @@ protected: /** * Virtual destructor, no deletion through this interface */ - virtual ~ContextNotifierInterface() - { - } + virtual ~ContextNotifierInterface() = default; }; } // namespace Integration diff --git a/dali/integration-api/debug.cpp b/dali/integration-api/debug.cpp index 53df468..ebbc339 100644 --- a/dali/integration-api/debug.cpp +++ b/dali/integration-api/debug.cpp @@ -19,22 +19,8 @@ #include // EXTERNAL INCLUDES +#include #include -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include namespace Dali { @@ -46,12 +32,6 @@ Dali::DebugPropertyValueMap gValueMap; #endif -namespace // unnamed namespace -{ -const uint64_t NANOSECONDS_PER_SECOND = 1e+9; - -} - namespace Integration { namespace Log @@ -253,15 +233,20 @@ std::string FormatToString(const char* format, ...) return s; } +#ifdef DEBUG_ENABLED + void GetNanoseconds(uint64_t& timeInNanoseconds) { - timespec timeSpec; - clock_gettime(CLOCK_MONOTONIC, &timeSpec); + // Get the time of a monotonic clock since its epoch. + auto epoch = std::chrono::steady_clock::now().time_since_epoch(); + + auto duration = std::chrono::duration_cast(epoch); - // Convert all values to uint64_t to match our return type - timeInNanoseconds = (static_cast(timeSpec.tv_sec) * NANOSECONDS_PER_SECOND) + static_cast(timeSpec.tv_nsec); + timeInNanoseconds = static_cast(duration.count()); } +#endif // DEBUG_ENABLED + } // namespace Log } // namespace Integration diff --git a/dali/integration-api/debug.h b/dali/integration-api/debug.h index 5b2f40c..fe6c0d7 100644 --- a/dali/integration-api/debug.h +++ b/dali/integration-api/debug.h @@ -467,9 +467,15 @@ public: \ /******************************************************************************** * Time instrumentation * ********************************************************************************/ - #if defined(DEBUG_ENABLED) + /** + * @brief Get the monotonic time since the clock's epoch. + * + * @param[out] timeInNanoseconds The time in nanoseconds since the reference point. + * + * @note The maximum value timeInNanoseconds can hold is 0xFFFFFFFFFFFFFFFF which is 1.844674407e+19. Therefore, this can overflow after approximately 584 years. + */ void GetNanoseconds(uint64_t& timeInNanoseconds); #define DALI_LOG_TIMER_START(timeVariable) \ diff --git a/dali/integration-api/events/event.cpp b/dali/integration-api/events/event.cpp index c14a78c..e6953da 100644 --- a/dali/integration-api/events/event.cpp +++ b/dali/integration-api/events/event.cpp @@ -22,9 +22,7 @@ namespace Dali { namespace Integration { -Event::~Event() -{ -} +Event::~Event() = default; Event::Event(Type eventType) : type(eventType) diff --git a/dali/integration-api/events/hover-event-integ.cpp b/dali/integration-api/events/hover-event-integ.cpp index cdbae9a..53744b1 100644 --- a/dali/integration-api/events/hover-event-integ.cpp +++ b/dali/integration-api/events/hover-event-integ.cpp @@ -32,9 +32,7 @@ HoverEvent::HoverEvent(uint32_t time) { } -HoverEvent::~HoverEvent() -{ -} +HoverEvent::~HoverEvent() = default; } // namespace Integration diff --git a/dali/integration-api/events/key-event-integ.cpp b/dali/integration-api/events/key-event-integ.cpp index 0e09d2a..eac7cd3 100644 --- a/dali/integration-api/events/key-event-integ.cpp +++ b/dali/integration-api/events/key-event-integ.cpp @@ -67,9 +67,7 @@ KeyEvent::KeyEvent(const std::string& keyName, { } -KeyEvent::~KeyEvent() -{ -} +KeyEvent::~KeyEvent() = default; } // namespace Integration diff --git a/dali/integration-api/events/multi-point-event-integ.cpp b/dali/integration-api/events/multi-point-event-integ.cpp index f06994f..abc6505 100644 --- a/dali/integration-api/events/multi-point-event-integ.cpp +++ b/dali/integration-api/events/multi-point-event-integ.cpp @@ -37,9 +37,7 @@ MultiPointEvent::MultiPointEvent(Type eventType, uint32_t time) { } -MultiPointEvent::~MultiPointEvent() -{ -} +MultiPointEvent::~MultiPointEvent() = default; void MultiPointEvent::AddPoint(const Point& point) { diff --git a/dali/integration-api/events/point.cpp b/dali/integration-api/events/point.cpp index 6ce4e16..ebba967 100644 --- a/dali/integration-api/events/point.cpp +++ b/dali/integration-api/events/point.cpp @@ -47,9 +47,7 @@ Point::Point(const TouchPoint& touchPoint) { } -Point::~Point() -{ -} +Point::~Point() = default; void Point::SetDeviceId(int32_t deviceId) { diff --git a/dali/integration-api/events/touch-event-combiner.cpp b/dali/integration-api/events/touch-event-combiner.cpp index b38510b..6a5ebc8 100644 --- a/dali/integration-api/events/touch-event-combiner.cpp +++ b/dali/integration-api/events/touch-event-combiner.cpp @@ -78,9 +78,7 @@ TouchEventCombiner::TouchEventCombiner(uint32_t minMotionTime, Vector2 minMotion DALI_ASSERT_ALWAYS(minMotionDistance.x >= 0.0f && minMotionDistance.y >= 0.0f && "Negative values not allowed\n"); } -TouchEventCombiner::~TouchEventCombiner() -{ -} +TouchEventCombiner::~TouchEventCombiner() = default; TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(const Point& point, uint32_t time, TouchEvent& touchEvent, HoverEvent& hoverEvent) { diff --git a/dali/integration-api/events/touch-event-integ.cpp b/dali/integration-api/events/touch-event-integ.cpp index ea2e516..e1b1a7a 100644 --- a/dali/integration-api/events/touch-event-integ.cpp +++ b/dali/integration-api/events/touch-event-integ.cpp @@ -32,9 +32,7 @@ TouchEvent::TouchEvent(uint32_t time) { } -TouchEvent::~TouchEvent() -{ -} +TouchEvent::~TouchEvent() = default; } // namespace Integration diff --git a/dali/integration-api/events/wheel-event-integ.cpp b/dali/integration-api/events/wheel-event-integ.cpp index efb3132..e72fbcd 100644 --- a/dali/integration-api/events/wheel-event-integ.cpp +++ b/dali/integration-api/events/wheel-event-integ.cpp @@ -44,9 +44,7 @@ WheelEvent::WheelEvent(Type type, int direction, unsigned int modifiers, Vector2 { } -WheelEvent::~WheelEvent() -{ -} +WheelEvent::~WheelEvent() = default; } // namespace Integration diff --git a/dali/integration-api/gl-abstraction.h b/dali/integration-api/gl-abstraction.h index 8ce11d0..11a96b1 100644 --- a/dali/integration-api/gl-abstraction.h +++ b/dali/integration-api/gl-abstraction.h @@ -19,6 +19,7 @@ */ #include +#include /* * This file is based on gl3.h, the following licence is included for conformance. @@ -96,9 +97,7 @@ protected: /** * Virtual protected destructor, no deletion through this interface */ - virtual ~GlAbstraction() - { - } + virtual ~GlAbstraction() = default; public: /** @@ -120,6 +119,36 @@ public: virtual bool IsSurfacelessContextSupported() const = 0; /** + * Returns current gles can support advanced blend equation + * @Return true current gles support advanced blend equation + */ + virtual bool IsAdvancedBlendEquationSupported() = 0; + + /** + * Returns current gles can support the blend equation + * @Return true current gles support the blend equation + */ + virtual bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ) = 0; + + /** + * Returns shader prefix of shading language version. + * @Return shader prefix of shading language version. + */ + virtual std::string GetShaderVersionPrefix() = 0; + + /** + * Returns vertex shader prefix including shading language version. + * @Return vertex shader prefix including shading language version. + */ + virtual std::string GetVertexShaderPrefix() = 0; + + /** + * Returns fragment shader prefix including shading language version and extension information. + * @Return fragment shader prefix including shading language version and extension information. + */ + virtual std::string GetFragmentShaderPrefix() = 0; + + /** * Determine whether to convert pixel format or not. * @param[in] imageGlFormat GLformat of input image. * @param[in] textureGlFormat GLformat of Texture. @@ -384,6 +413,7 @@ public: virtual void TexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) = 0; virtual void TexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0; virtual void GetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) = 0; + virtual void BlendBarrier (void) = 0; // clang-format on }; diff --git a/dali/integration-api/gl-defines.h b/dali/integration-api/gl-defines.h index ab7e5e2..8bb7d18 100644 --- a/dali/integration-api/gl-defines.h +++ b/dali/integration-api/gl-defines.h @@ -805,6 +805,23 @@ #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +// GL_blend_equation_advanced / GLES 3.2 +#define GL_MULTIPLY 0x9294 +#define GL_SCREEN 0x9295 +#define GL_OVERLAY 0x9296 +#define GL_DARKEN 0x9297 +#define GL_LIGHTEN 0x9298 +#define GL_COLORDODGE 0x9299 +#define GL_COLORBURN 0x929A +#define GL_HARDLIGHT 0x929B +#define GL_SOFTLIGHT 0x929C +#define GL_DIFFERENCE 0x929E +#define GL_EXCLUSION 0x92A0 +#define GL_HSL_HUE 0x92AD +#define GL_HSL_SATURATION 0x92AE +#define GL_HSL_COLOR 0x92AF +#define GL_HSL_LUMINOSITY 0x92B0 + /*------------------------------------------------------------------------* * EXT extension tokens *------------------------------------------------------------------------*/ diff --git a/dali/integration-api/gl-sync-abstraction.h b/dali/integration-api/gl-sync-abstraction.h index 398d297..cbe440e 100644 --- a/dali/integration-api/gl-sync-abstraction.h +++ b/dali/integration-api/gl-sync-abstraction.h @@ -35,9 +35,7 @@ protected: /** * Virtual protected destructor, no deletion through this interface */ - virtual ~GlSyncAbstraction() - { - } + virtual ~GlSyncAbstraction() = default; public: class SyncObject @@ -48,9 +46,7 @@ public: * Core from deleting SyncObjects - only Adaptor implementation is able to delete * them. */ - virtual ~SyncObject() - { - } + virtual ~SyncObject() = default; public: /** diff --git a/dali/integration-api/platform-abstraction.h b/dali/integration-api/platform-abstraction.h index 4bc3d09..64ce4f7 100644 --- a/dali/integration-api/platform-abstraction.h +++ b/dali/integration-api/platform-abstraction.h @@ -144,9 +144,7 @@ protected: /** * Virtual destructor. */ - virtual ~PlatformAbstraction() - { - } + virtual ~PlatformAbstraction() = default; }; // class PlatformAbstraction diff --git a/dali/integration-api/processor-interface.h b/dali/integration-api/processor-interface.h index 3334a6b..70c01bd 100644 --- a/dali/integration-api/processor-interface.h +++ b/dali/integration-api/processor-interface.h @@ -41,9 +41,7 @@ protected: /** * Virtual protected destructor */ - virtual ~Processor() - { - } + virtual ~Processor() = default; }; } // namespace Integration diff --git a/dali/integration-api/render-controller.h b/dali/integration-api/render-controller.h index 30ab2d3..f337dd6 100644 --- a/dali/integration-api/render-controller.h +++ b/dali/integration-api/render-controller.h @@ -32,9 +32,7 @@ protected: /** * Virtual protected destructor, no deletion through this interface */ - virtual ~RenderController() - { - } + virtual ~RenderController() = default; public: /** diff --git a/dali/integration-api/resource-types.h b/dali/integration-api/resource-types.h index 9d70589..fd0decf 100644 --- a/dali/integration-api/resource-types.h +++ b/dali/integration-api/resource-types.h @@ -60,9 +60,7 @@ struct BitmapResourceType /** * Destructor. */ - ~BitmapResourceType() - { - } + ~BitmapResourceType() = default; /** * Attributes are copied from the request. diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index d24d0ad..9a6af8e 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -38,29 +38,18 @@ Scene Scene::DownCast(BaseHandle handle) return Scene(dynamic_cast(handle.GetObjectPtr())); } -Scene::Scene() -{ -} +Scene::Scene() = default; -Scene::~Scene() -{ -} +Scene::~Scene() = default; -Scene::Scene(const Scene& handle) -: BaseHandle(handle) -{ -} +Scene::Scene(const Scene& handle) = default; Scene::Scene(Internal::Scene* internal) : BaseHandle(internal) { } -Scene& Scene::operator=(const Scene& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} +Scene& Scene::operator=(const Scene& rhs) = default; void Scene::Add(Actor actor) { diff --git a/dali/internal/common/blending-options.cpp b/dali/internal/common/blending-options.cpp index d2255fa..596e544 100644 --- a/dali/internal/common/blending-options.cpp +++ b/dali/internal/common/blending-options.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -27,18 +27,18 @@ const int MASK_SRC_FACTOR_RGB = 0x0000000F; const int MASK_SRC_FACTOR_ALPHA = 0x000000F0; const int MASK_DEST_FACTOR_RGB = 0x00000F00; const int MASK_DEST_FACTOR_ALPHA = 0x0000F000; -const int MASK_EQUATION_RGB = 0x000F0000; -const int MASK_EQUATION_ALPHA = 0x00F00000; +const int MASK_EQUATION_RGB = 0x00FF0000; +const int MASK_EQUATION_ALPHA = 0xFF000000; const int SHIFT_TO_SRC_FACTOR_RGB = 0; const int SHIFT_TO_SRC_FACTOR_ALPHA = 4; const int SHIFT_TO_DEST_FACTOR_RGB = 8; const int SHIFT_TO_DEST_FACTOR_ALPHA = 12; const int SHIFT_TO_EQUATION_RGB = 16; -const int SHIFT_TO_EQUATION_ALPHA = 20; +const int SHIFT_TO_EQUATION_ALPHA = 24; static unsigned int CLEAR_BLEND_FUNC_MASK = 0xFFFF0000; // Bottom 16 bits cleared -static unsigned int CLEAR_BLEND_EQUATION_MASK = 0xFF00FFFF; // 8 bits cleared +static unsigned int CLEAR_BLEND_EQUATION_MASK = 0x0000FFFF; // Top 16 bits cleared /** * Utility to store one of the BlendFunc values. @@ -148,54 +148,203 @@ void StoreBlendFactor( unsigned int& options, BlendFactor::Type factor, int bitS * @param[in] factor The BlendEquation value. * @param[in] bitshift Used to shift to the correct part of options. */ -void StoreBlendEquation( unsigned int& options, BlendEquation::Type factor, int bitShift ) +void StoreBlendEquation( unsigned int& options, DevelBlendEquation::Type factor, int bitShift ) { + // Must be same order as BLENDING_EQUATIONS, below: + enum { + ADD_BITVAL = 0u, + SUBTRACT_BITVAL, + REVERSE_SUBTRACT_BITVAL, + MIN_BITVAL, + MAX_BITVAL, + MULTIPLY_BITVAL, + SCREEN_BITVAL, + OVERLAY_BITVAL, + DARKEN_BITVAL, + LIGHTEN_BITVAL, + COLOR_DODGE_BITVAL, + COLOR_BURN_BITVAL, + HARD_LIGHT_BITVAL, + SOFT_LIGHT_BITVAL, + DIFFERENCE_BITVAL, + EXCLUSION_BITVAL, + HUE_BITVAL, + SATURATION_BITVAL, + COLOR_BITVAL, + LUMINOSITY_BITVAL + }; + switch ( factor ) { - case BlendEquation::ADD: + case DevelBlendEquation::ADD: { - options |= ( 0u << bitShift ); + options |= ( ADD_BITVAL << bitShift ); break; } - case BlendEquation::SUBTRACT: + case DevelBlendEquation::SUBTRACT: { - options |= ( 1u << bitShift ); + options |= ( SUBTRACT_BITVAL << bitShift ); break; } - case BlendEquation::REVERSE_SUBTRACT: + case DevelBlendEquation::REVERSE_SUBTRACT: { - options |= ( 2u << bitShift ); + options |= ( REVERSE_SUBTRACT_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::MIN: + { + options |= ( MIN_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::MAX: + { + options |= ( MAX_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::MULTIPLY: + { + options |= ( MULTIPLY_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::SCREEN: + { + options |= ( SCREEN_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::OVERLAY: + { + options |= ( OVERLAY_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::DARKEN: + { + options |= ( DARKEN_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::LIGHTEN: + { + options |= ( LIGHTEN_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::COLOR_DODGE: + { + options |= ( COLOR_DODGE_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::COLOR_BURN: + { + options |= ( COLOR_BURN_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::HARD_LIGHT: + { + options |= ( HARD_LIGHT_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::SOFT_LIGHT: + { + options |= ( SOFT_LIGHT_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::DIFFERENCE: + { + options |= ( DIFFERENCE_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::EXCLUSION: + { + options |= ( EXCLUSION_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::HUE: + { + options |= ( HUE_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::SATURATION: + { + options |= ( SATURATION_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::COLOR: + { + options |= ( COLOR_BITVAL << bitShift ); + break; + } + + case DevelBlendEquation::LUMINOSITY: + { + options |= ( LUMINOSITY_BITVAL << bitShift ); break; } } } const unsigned int BLENDING_FACTOR_COUNT = 15; -const unsigned int BLENDING_EQUATION_COUNT = 3; +const unsigned int BLENDING_EQUATION_COUNT = 20; +const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_START = 5; +const unsigned int BLENDING_EQUATION_ADVANCED_INDEX_END = 19; BlendFactor::Type BLENDING_FACTORS[ BLENDING_FACTOR_COUNT ] = - { BlendFactor::ZERO, - BlendFactor::ONE, - BlendFactor::SRC_COLOR, - BlendFactor::ONE_MINUS_SRC_COLOR, - BlendFactor::SRC_ALPHA, - BlendFactor::ONE_MINUS_SRC_ALPHA, - BlendFactor::DST_ALPHA, - BlendFactor::ONE_MINUS_DST_ALPHA, - BlendFactor::DST_COLOR, - BlendFactor::ONE_MINUS_DST_COLOR, - BlendFactor::SRC_ALPHA_SATURATE, - BlendFactor::CONSTANT_COLOR, - BlendFactor::ONE_MINUS_CONSTANT_COLOR, - BlendFactor::CONSTANT_ALPHA, - BlendFactor::ONE_MINUS_CONSTANT_ALPHA }; - -BlendEquation::Type BLENDING_EQUATIONS[ BLENDING_EQUATION_COUNT ] = - { BlendEquation::ADD, - BlendEquation::SUBTRACT, - BlendEquation::REVERSE_SUBTRACT }; +{ + BlendFactor::ZERO, + BlendFactor::ONE, + BlendFactor::SRC_COLOR, + BlendFactor::ONE_MINUS_SRC_COLOR, + BlendFactor::SRC_ALPHA, + BlendFactor::ONE_MINUS_SRC_ALPHA, + BlendFactor::DST_ALPHA, + BlendFactor::ONE_MINUS_DST_ALPHA, + BlendFactor::DST_COLOR, + BlendFactor::ONE_MINUS_DST_COLOR, + BlendFactor::SRC_ALPHA_SATURATE, + BlendFactor::CONSTANT_COLOR, + BlendFactor::ONE_MINUS_CONSTANT_COLOR, + BlendFactor::CONSTANT_ALPHA, + BlendFactor::ONE_MINUS_CONSTANT_ALPHA +}; + +DevelBlendEquation::Type BLENDING_EQUATIONS[ BLENDING_EQUATION_COUNT ] = +{ + DevelBlendEquation::ADD, + DevelBlendEquation::SUBTRACT, + DevelBlendEquation::REVERSE_SUBTRACT, + DevelBlendEquation::MIN, + DevelBlendEquation::MAX, + DevelBlendEquation::MULTIPLY, + DevelBlendEquation::SCREEN, + DevelBlendEquation::OVERLAY, + DevelBlendEquation::DARKEN, + DevelBlendEquation::LIGHTEN, + DevelBlendEquation::COLOR_DODGE, + DevelBlendEquation::COLOR_BURN, + DevelBlendEquation::HARD_LIGHT, + DevelBlendEquation::SOFT_LIGHT, + DevelBlendEquation::DIFFERENCE, + DevelBlendEquation::EXCLUSION, + DevelBlendEquation::HUE, + DevelBlendEquation::SATURATION, + DevelBlendEquation::COLOR, + DevelBlendEquation::LUMINOSITY +}; /** * Utility to retrieve one of the BlendFunc values. @@ -221,7 +370,7 @@ BlendFactor::Type RetrieveBlendFactor( unsigned int options, int mask, int bitSh * @param[in] bitshift Used to shift to the correct part of options. * @return The blending equation. */ -BlendEquation::Type RetrieveBlendEquation( unsigned int options, int mask, int bitShift ) +DevelBlendEquation::Type RetrieveBlendEquation( unsigned int options, int mask, int bitShift ) { unsigned int index = options & mask; index = index >> bitShift; @@ -246,12 +395,10 @@ BlendingOptions::BlendingOptions() SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA ); - SetBlendEquation( BlendEquation::ADD, BlendEquation::ADD ); + SetBlendEquation( DevelBlendEquation::ADD, DevelBlendEquation::ADD ); } -BlendingOptions::~BlendingOptions() -{ -} +BlendingOptions::~BlendingOptions() = default; void BlendingOptions::SetBitmask( unsigned int bitmask ) { @@ -294,7 +441,7 @@ BlendFactor::Type BlendingOptions::GetBlendDestFactorAlpha() const return RetrieveBlendFactor( mBitmask, MASK_DEST_FACTOR_ALPHA, SHIFT_TO_DEST_FACTOR_ALPHA ); } -void BlendingOptions::SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha ) +void BlendingOptions::SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha ) { mBitmask &= CLEAR_BLEND_EQUATION_MASK; // Clear the BlendEquation values @@ -302,12 +449,12 @@ void BlendingOptions::SetBlendEquation( BlendEquation::Type equationRgb, BlendEq StoreBlendEquation( mBitmask, equationAlpha, SHIFT_TO_EQUATION_ALPHA ); } -BlendEquation::Type BlendingOptions::GetBlendEquationRgb() const +DevelBlendEquation::Type BlendingOptions::GetBlendEquationRgb() const { return RetrieveBlendEquation( mBitmask, MASK_EQUATION_RGB, SHIFT_TO_EQUATION_RGB ); } -BlendEquation::Type BlendingOptions::GetBlendEquationAlpha() const +DevelBlendEquation::Type BlendingOptions::GetBlendEquationAlpha() const { return RetrieveBlendEquation( mBitmask, MASK_EQUATION_ALPHA, SHIFT_TO_EQUATION_ALPHA ); } @@ -337,6 +484,47 @@ const Vector4* BlendingOptions::GetBlendColor() const return mBlendColor.Get(); } +bool BlendingOptions::IsAdvancedBlendEquationApplied() +{ + unsigned int indexRgb = mBitmask & MASK_EQUATION_RGB; + indexRgb = indexRgb >> SHIFT_TO_EQUATION_RGB; + unsigned int indexA = mBitmask & MASK_EQUATION_ALPHA; + indexA = indexA >> SHIFT_TO_EQUATION_ALPHA; + + return ( ( ( indexRgb >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexRgb <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) || + ( ( indexA >= BLENDING_EQUATION_ADVANCED_INDEX_START ) && ( indexA <= BLENDING_EQUATION_ADVANCED_INDEX_END ) ) ); +} + +bool BlendingOptions::IsAdvancedBlendEquation( DevelBlendEquation::Type equation ) +{ + switch ( equation ) + { + case DevelBlendEquation::MULTIPLY: + case DevelBlendEquation::SCREEN: + case DevelBlendEquation::OVERLAY: + case DevelBlendEquation::DARKEN: + case DevelBlendEquation::LIGHTEN: + case DevelBlendEquation::COLOR_DODGE: + case DevelBlendEquation::COLOR_BURN: + case DevelBlendEquation::HARD_LIGHT: + case DevelBlendEquation::SOFT_LIGHT: + case DevelBlendEquation::DIFFERENCE: + case DevelBlendEquation::EXCLUSION: + case DevelBlendEquation::HUE: + case DevelBlendEquation::SATURATION: + case DevelBlendEquation::COLOR: + case DevelBlendEquation::LUMINOSITY: + { + return true; + } + + default: + { + return false; + } + } +} + } // namespace Internal } // namespace Dali diff --git a/dali/internal/common/blending-options.h b/dali/internal/common/blending-options.h index b469c26..f150685 100644 --- a/dali/internal/common/blending-options.h +++ b/dali/internal/common/blending-options.h @@ -2,7 +2,7 @@ #define DALI_BLENDING_OPTIONS_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. @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include #include #include @@ -83,17 +84,17 @@ struct BlendingOptions /** * @copydoc Dali::RenderableActor::SetBlendEquation() */ - void SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha ); + void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha ); /** * @copydoc Dali::RenderableActor::GetBlendEquation() */ - BlendEquation::Type GetBlendEquationRgb() const; + DevelBlendEquation::Type GetBlendEquationRgb() const; /** * @copydoc Dali::RenderableActor::GetBlendEquation() */ - BlendEquation::Type GetBlendEquationAlpha() const; + DevelBlendEquation::Type GetBlendEquationAlpha() const; /** * Set the blend color. @@ -108,6 +109,18 @@ struct BlendingOptions */ const Vector4* GetBlendColor() const; + /** + * Query whether current blend equation is advanced option. + * @return True if current blend equation is advanced. + */ + bool IsAdvancedBlendEquationApplied(); + + /** + * Query whether input blend equation is advanced option. + * @return True if input blend equation is advanced. + */ + static bool IsAdvancedBlendEquation( DevelBlendEquation::Type equation ); + private: // Undefined copy constructor. diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index fd17bd2..cffc170 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -91,6 +91,7 @@ Core::Core( RenderController& renderController, Integration::PartialUpdateAvailable partialUpdateAvailable ) : mRenderController( renderController ), mPlatform(platform), + mGlAbstraction(glAbstraction), mProcessingEvent(false), mForceNextUpdate( false ) { @@ -248,9 +249,9 @@ void Core::SceneCreated() mRelayoutController->OnApplicationSceneCreated(); - for( auto iter = mScenes.begin(); iter != mScenes.end(); ++iter ) + for( const auto& scene : mScenes ) { - Dali::Actor sceneRootLayer = (*iter)->GetRootLayer(); + Dali::Actor sceneRootLayer = scene->GetRootLayer(); mRelayoutController->RequestRelayoutTree( sceneRootLayer ); } } @@ -422,6 +423,11 @@ AnimationPlaylist& Core::GetAnimationPlaylist() const return *(mAnimationPlaylist); } +Integration::GlAbstraction& Core::GetGlAbstraction() const +{ + return mGlAbstraction; +} + void Core::AddScene( Scene* scene ) { mScenes.push_back( scene ); diff --git a/dali/internal/common/core-impl.h b/dali/internal/common/core-impl.h index 1e72470..478bfcd 100644 --- a/dali/internal/common/core-impl.h +++ b/dali/internal/common/core-impl.h @@ -311,6 +311,13 @@ private: */ AnimationPlaylist& GetAnimationPlaylist() const; + /** + * @brief Returns GlAbstraction. + * @note Use only for the capability. Do not use this for bypass context + * @return GlAbstraction + */ + Integration::GlAbstraction& GetGlAbstraction() const; + private: /** @@ -349,6 +356,10 @@ private: // The object registry ObjectRegistryPtr mObjectRegistry; + // GlAbstraction for capabilities of GL + // Not to use this for bypass Context. + Integration::GlAbstraction& mGlAbstraction; + bool mProcessingEvent : 1; ///< True during ProcessEvents() bool mForceNextUpdate:1; ///< True if the next rendering is really required. diff --git a/dali/internal/common/image-attributes.cpp b/dali/internal/common/image-attributes.cpp old mode 100755 new mode 100644 index 9adf588..005e3b2 --- a/dali/internal/common/image-attributes.cpp +++ b/dali/internal/common/image-attributes.cpp @@ -39,18 +39,9 @@ struct ImageAttributes::ImageAttributesImpl { } - ~ImageAttributesImpl() - { - } + ~ImageAttributesImpl() = default; - ImageAttributesImpl(const ImageAttributesImpl& rhs) - : width( rhs.width ), - height( rhs.height ), - scaling( rhs.scaling ), - filtering( rhs.filtering ), - mOrientationCorrection( rhs.mOrientationCorrection ) - { - } + ImageAttributesImpl(const ImageAttributesImpl& rhs) = default; ImageAttributesImpl& operator=(const ImageAttributesImpl& rhs) { diff --git a/dali/internal/common/message-buffer.cpp b/dali/internal/common/message-buffer.cpp index 5893f91..1621567 100644 --- a/dali/internal/common/message-buffer.cpp +++ b/dali/internal/common/message-buffer.cpp @@ -162,11 +162,7 @@ MessageBuffer::Iterator::Iterator(WordType* current) } } -MessageBuffer::Iterator::Iterator(const Iterator& copy) -: mCurrent( copy.mCurrent ), - mMessageSize( copy.mMessageSize ) -{ -} +MessageBuffer::Iterator::Iterator(const Iterator& copy) = default; } // namespace Internal diff --git a/dali/internal/common/message.h b/dali/internal/common/message.h index 382aa9d..bd2410f 100644 --- a/dali/internal/common/message.h +++ b/dali/internal/common/message.h @@ -41,16 +41,12 @@ public: /** * Construct the message base. */ - MessageBase( ) - { - } + MessageBase() = default; /** * Virtual destructor */ - virtual ~MessageBase() - { - } + virtual ~MessageBase() = default; /** * Called to process the message. @@ -90,9 +86,7 @@ public: /** * Virtual destructor */ - ~Message() override - { - } + ~Message() override = default; /** * @copydoc MessageBase::Process @@ -143,9 +137,7 @@ public: /** * Virtual destructor */ - ~MessageValue1() override - { - } + ~MessageValue1() override = default; /** * @copydoc MessageBase::Process @@ -201,9 +193,7 @@ public: /** * Virtual destructor */ - ~MessageValue2() override - { - } + ~MessageValue2() override = default; /** * @copydoc MessageBase::Process @@ -262,9 +252,7 @@ public: /** * Virtual destructor */ - ~MessageValue3() override - { - } + ~MessageValue3() override = default; /** * @copydoc MessageBase::Process @@ -327,9 +315,7 @@ public: /** * Virtual destructor */ - ~MessageValue4() override - { - } + ~MessageValue4() override = default; /** * @copydoc MessageBase::Process @@ -396,9 +382,7 @@ public: /** * Virtual destructor */ - ~MessageValue5() override - { - } + ~MessageValue5() override = default; /** * @copydoc MessageBase::Process @@ -469,9 +453,7 @@ public: /** * Virtual destructor */ - ~MessageValue6() override - { - } + ~MessageValue6() override = default; /** * @copydoc MessageBase::Process @@ -522,9 +504,7 @@ public: /** * Virtual destructor */ - ~MessageDoubleBuffered0() override - { - } + ~MessageDoubleBuffered0() override = default; /** * @copydoc MessageBase::Process @@ -576,9 +556,7 @@ public: /** * Virtual destructor */ - ~MessageDoubleBuffered1() override - { - } + ~MessageDoubleBuffered1() override = default; /** * @copydoc MessageBase::Process @@ -633,9 +611,7 @@ public: /** * Virtual destructor */ - ~MessageDoubleBuffered2() override - { - } + ~MessageDoubleBuffered2() override = default; /** * @copydoc MessageBase::Process @@ -695,9 +671,7 @@ public: /** * Virtual destructor */ - ~MessageDoubleBuffered3() override - { - } + ~MessageDoubleBuffered3() override = default; /** * @copydoc MessageBase::Process @@ -760,9 +734,7 @@ public: /** * Virtual destructor */ - ~MessageDoubleBuffered4() override - { - } + ~MessageDoubleBuffered4() override = default; /** * @copydoc MessageBase::Process diff --git a/dali/internal/common/shader-saver.h b/dali/internal/common/shader-saver.h index e53185c..8b83ae3 100644 --- a/dali/internal/common/shader-saver.h +++ b/dali/internal/common/shader-saver.h @@ -50,7 +50,7 @@ protected: * Destructor. Protected as no derived class should ever be deleted * through a reference to this pure abstract interface. */ - virtual ~ShaderSaver(){} + virtual ~ShaderSaver() = default; }; } // namespace Internal diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 0e0342d..b6960ed 100755 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -143,25 +144,27 @@ DALI_PROPERTY( "keyboardFocusable", BOOLEAN, true, false, false, Dali: DALI_PROPERTY( "siblingOrder", INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER ) DALI_PROPERTY( "updateSizeHint", VECTOR2, true, false, false, Dali::DevelActor::Property::UPDATE_SIZE_HINT ) DALI_PROPERTY( "captureAllTouchAfterStart", BOOLEAN, true, false, false, Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START ) +DALI_PROPERTY( "touchArea", VECTOR2, true, false, false, Dali::DevelActor::Property::TOUCH_AREA ) +DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION ) DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties ) // Signals -const char* const SIGNAL_HOVERED = "hovered"; -const char* const SIGNAL_WHEEL_EVENT = "wheelEvent"; -const char* const SIGNAL_ON_SCENE = "onScene"; -const char* const SIGNAL_OFF_SCENE = "offScene"; -const char* const SIGNAL_ON_RELAYOUT = "onRelayout"; -const char* const SIGNAL_TOUCHED = "touched"; -const char* const SIGNAL_VISIBILITY_CHANGED = "visibilityChanged"; -const char* const SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged"; -const char* const SIGNAL_CHILD_ADDED = "childAdded"; -const char* const SIGNAL_CHILD_REMOVED = "childRemoved"; +static constexpr std::string_view SIGNAL_HOVERED = "hovered"; +static constexpr std::string_view SIGNAL_WHEEL_EVENT = "wheelEvent"; +static constexpr std::string_view SIGNAL_ON_SCENE = "onScene"; +static constexpr std::string_view SIGNAL_OFF_SCENE = "offScene"; +static constexpr std::string_view SIGNAL_ON_RELAYOUT = "onRelayout"; +static constexpr std::string_view SIGNAL_TOUCHED = "touched"; +static constexpr std::string_view SIGNAL_VISIBILITY_CHANGED = "visibilityChanged"; +static constexpr std::string_view SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged"; +static constexpr std::string_view SIGNAL_CHILD_ADDED = "childAdded"; +static constexpr std::string_view SIGNAL_CHILD_REMOVED = "childRemoved"; // Actions -const char* const ACTION_SHOW = "show"; -const char* const ACTION_HIDE = "hide"; +static constexpr std::string_view ACTION_SHOW = "show"; +static constexpr std::string_view ACTION_HIDE = "hide"; BaseHandle CreateActor() { @@ -170,19 +173,19 @@ BaseHandle CreateActor() TypeRegistration mType( typeid(Dali::Actor), typeid(Dali::Handle), CreateActor, ActorDefaultProperties ); -SignalConnectorType signalConnector2( mType, SIGNAL_HOVERED, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector3( mType, SIGNAL_WHEEL_EVENT, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector4( mType, SIGNAL_ON_SCENE, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector5( mType, SIGNAL_OFF_SCENE, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector6( mType, SIGNAL_ON_RELAYOUT, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector7( mType, SIGNAL_TOUCHED, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector8( mType, SIGNAL_VISIBILITY_CHANGED, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector9( mType, SIGNAL_LAYOUT_DIRECTION_CHANGED, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector10( mType, SIGNAL_CHILD_ADDED, &Actor::DoConnectSignal ); -SignalConnectorType signalConnector11( mType, SIGNAL_CHILD_REMOVED, &Actor::DoConnectSignal ); +SignalConnectorType signalConnector2(mType, std::string(SIGNAL_HOVERED), &Actor::DoConnectSignal); +SignalConnectorType signalConnector3(mType, std::string(SIGNAL_WHEEL_EVENT), &Actor::DoConnectSignal); +SignalConnectorType signalConnector4(mType, std::string(SIGNAL_ON_SCENE), &Actor::DoConnectSignal); +SignalConnectorType signalConnector5(mType, std::string(SIGNAL_OFF_SCENE), &Actor::DoConnectSignal); +SignalConnectorType signalConnector6(mType, std::string(SIGNAL_ON_RELAYOUT), &Actor::DoConnectSignal); +SignalConnectorType signalConnector7(mType, std::string(SIGNAL_TOUCHED), &Actor::DoConnectSignal); +SignalConnectorType signalConnector8(mType, std::string(SIGNAL_VISIBILITY_CHANGED), &Actor::DoConnectSignal); +SignalConnectorType signalConnector9(mType, std::string(SIGNAL_LAYOUT_DIRECTION_CHANGED), &Actor::DoConnectSignal); +SignalConnectorType signalConnector10(mType, std::string(SIGNAL_CHILD_ADDED), &Actor::DoConnectSignal); +SignalConnectorType signalConnector11(mType, std::string(SIGNAL_CHILD_REMOVED), &Actor::DoConnectSignal); -TypeAction a1( mType, ACTION_SHOW, &Actor::DoAction ); -TypeAction a2( mType, ACTION_HIDE, &Actor::DoAction ); +TypeAction a1(mType, std::string(ACTION_SHOW), &Actor::DoAction); +TypeAction a2(mType, std::string(ACTION_HIDE), &Actor::DoAction); /** * @brief Extract a given dimension from a Vector2 @@ -237,7 +240,7 @@ void EmitVisibilityChangedSignalRecursively( ActorPtr actor, bool visible, Devel if( actor->GetChildCount() > 0 ) { - for( ActorPtr& child : actor->GetChildrenInternal() ) + for( auto& child : actor->GetChildrenInternal() ) { EmitVisibilityChangedSignalRecursively( child, visible, DevelActor::VisibilityChange::PARENT ); } @@ -515,10 +518,9 @@ ActorPtr Actor::FindChildByName( const std::string& actorName ) } else if( mChildren ) { - ActorIter end = mChildren->end(); - for( ActorIter iter = mChildren->begin(); iter != end; ++iter ) + for( const auto& actor : *mChildren ) { - child = (*iter)->FindChildByName( actorName ); + child = actor->FindChildByName( actorName ); if( child ) { @@ -538,10 +540,9 @@ ActorPtr Actor::FindChildById( const uint32_t id ) } else if( mChildren ) { - ActorIter end = mChildren->end(); - for( ActorIter iter = mChildren->begin(); iter != end; ++iter ) + for( const auto& actor : *mChildren ) { - child = (*iter)->FindChildById( id ); + child = actor->FindChildById( id ); if( child ) { @@ -836,6 +837,8 @@ void Actor::SetOpacity( float opacity ) // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodePropertyComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty::BakeW, opacity ); + + RequestRenderingMessage( GetEventThreadServices().GetUpdateManager() ); } float Actor::GetCurrentOpacity() const @@ -855,6 +858,8 @@ void Actor::SetColor( const Vector4& color ) // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty::Bake, color ); + + RequestRenderingMessage( GetEventThreadServices().GetUpdateManager() ); } void Actor::SetColorRed( float red ) @@ -863,6 +868,8 @@ void Actor::SetColorRed( float red ) // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodePropertyComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty::BakeX, red ); + + RequestRenderingMessage( GetEventThreadServices().GetUpdateManager() ); } void Actor::SetColorGreen( float green ) @@ -871,6 +878,8 @@ void Actor::SetColorGreen( float green ) // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodePropertyComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty::BakeY, green ); + + RequestRenderingMessage( GetEventThreadServices().GetUpdateManager() ); } void Actor::SetColorBlue( float blue ) @@ -879,6 +888,8 @@ void Actor::SetColorBlue( float blue ) // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodePropertyComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty::BakeZ, blue ); + + RequestRenderingMessage( GetEventThreadServices().GetUpdateManager() ); } const Vector4& Actor::GetCurrentColor() const @@ -1186,6 +1197,12 @@ uint32_t Actor::AddRenderer( Renderer& renderer ) mRenderers = new RendererContainer; } + if(mIsBlendEquationSet) + { + renderer.SetBlendMode(Dali::BlendMode::ON); + renderer.SetBlendEquation(static_cast(mBlendEquation)); + } + uint32_t index = static_cast( mRenderers->size() ); // 4,294,967,295 renderers per actor RendererPtr rendererPtr = RendererPtr( &renderer ); mRenderers->push_back( rendererPtr ); @@ -1242,6 +1259,34 @@ void Actor::RemoveRenderer( uint32_t index ) } } +void Actor::SetBlendEquation(DevelBlendEquation::Type blendEquation) +{ + if(Dali::Capabilities::IsBlendEquationSupported(blendEquation)) + { + if(mBlendEquation != blendEquation) + { + mBlendEquation = blendEquation; + uint32_t rendererCount = GetRendererCount(); + for(uint32_t i = 0; i < rendererCount; ++i) + { + RendererPtr renderer = GetRendererAt(i); + renderer->SetBlendMode(Dali::BlendMode::ON); + renderer->SetBlendEquation(static_cast(blendEquation)); + } + } + mIsBlendEquationSet = true; + } + else + { + DALI_LOG_ERROR("Invalid blend equation is entered.\n"); + } +} + +DevelBlendEquation::Type Actor::GetBlendEquation() const +{ + return mBlendEquation; +} + void Actor::SetDrawMode( DrawMode::Type drawMode ) { // this flag is not animatable so keep the value @@ -1364,43 +1409,45 @@ bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra bool connected( true ); Actor* actor = static_cast< Actor* >( object ); // TypeRegistry guarantees that this is the correct type. - if( 0 == signalName.compare( SIGNAL_HOVERED ) ) + std::string_view name(signalName); + + if(name == SIGNAL_HOVERED) { actor->HoveredSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_WHEEL_EVENT ) ) + else if(signalName == SIGNAL_WHEEL_EVENT) { actor->WheelEventSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_ON_SCENE ) ) + else if(name == SIGNAL_ON_SCENE) { actor->OnSceneSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_OFF_SCENE ) ) + else if(name == SIGNAL_OFF_SCENE) { actor->OffSceneSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_ON_RELAYOUT ) ) + else if(name == SIGNAL_ON_RELAYOUT) { actor->OnRelayoutSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_TOUCHED ) ) + else if(name == SIGNAL_TOUCHED) { actor->TouchedSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_VISIBILITY_CHANGED ) ) + else if(name == SIGNAL_VISIBILITY_CHANGED) { actor->VisibilityChangedSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_LAYOUT_DIRECTION_CHANGED ) ) + else if(name == SIGNAL_LAYOUT_DIRECTION_CHANGED) { actor->LayoutDirectionChangedSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_CHILD_ADDED ) ) + else if(name == SIGNAL_CHILD_ADDED) { actor->ChildAddedSignal().Connect( tracker, functor ); } - else if( 0 == signalName.compare( SIGNAL_CHILD_REMOVED ) ) + else if(name == SIGNAL_CHILD_REMOVED) { actor->ChildRemovedSignal().Connect( tracker, functor ); } @@ -1441,6 +1488,7 @@ Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node ) mTargetPosition( Vector3::ZERO ), mTargetScale( Vector3::ONE ), mAnimatedSize( Vector3::ZERO ), + mTouchArea( Vector2::ZERO ), mName(), mSortedDepth( 0u ), mDepth( 0u ), @@ -1463,7 +1511,9 @@ Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node ) mLayoutDirection( LayoutDirection::LEFT_TO_RIGHT ), mDrawMode( DrawMode::NORMAL ), mColorMode( Node::DEFAULT_COLOR_MODE ), - mClippingMode( ClippingMode::DISABLED ) + mClippingMode( ClippingMode::DISABLED ), + mBlendEquation( DevelBlendEquation::ADD ), + mIsBlendEquationSet( false ) { } @@ -1480,10 +1530,9 @@ Actor::~Actor() // to guard against GetParent() & Unparent() calls from CustomActor destructors. if( mChildren ) { - ActorConstIter endIter = mChildren->end(); - for( ActorIter iter = mChildren->begin(); iter != endIter; ++iter ) + for( const auto& actor : *mChildren ) { - (*iter)->SetParent( nullptr ); + actor->SetParent( nullptr ); } } delete mChildren; @@ -1527,10 +1576,9 @@ void Actor::ConnectToScene( uint32_t parentDepth ) RecursiveConnectToScene( connectionList, parentDepth + 1 ); // Notify applications about the newly connected actors. - const ActorIter endIter = connectionList.end(); - for( ActorIter iter = connectionList.begin(); iter != endIter; ++iter ) + for( const auto& actor : connectionList ) { - (*iter)->NotifyStageConnection(); + actor->NotifyStageConnection(); } RelayoutRequest(); @@ -1554,11 +1602,10 @@ void Actor::RecursiveConnectToScene( ActorContainer& connectionList, uint32_t de // Recursively connect children if( mChildren ) { - ActorConstIter endIter = mChildren->end(); - for( ActorIter iter = mChildren->begin(); iter != endIter; ++iter ) + for( const auto& actor : *mChildren ) { - (*iter)->SetScene( *mScene ); - (*iter)->RecursiveConnectToScene( connectionList, depth + 1 ); + actor->SetScene( *mScene ); + actor->RecursiveConnectToScene( connectionList, depth + 1 ); } } } @@ -1621,10 +1668,9 @@ void Actor::DisconnectFromStage() RecursiveDisconnectFromStage( disconnectionList ); // Notify applications about the newly disconnected actors. - const ActorIter endIter = disconnectionList.end(); - for( ActorIter iter = disconnectionList.begin(); iter != endIter; ++iter ) + for( const auto& actor : disconnectionList ) { - (*iter)->NotifyStageDisconnection(); + actor->NotifyStageDisconnection(); } } @@ -1636,10 +1682,9 @@ void Actor::RecursiveDisconnectFromStage( ActorContainer& disconnectionList ) // Recursively disconnect children if( mChildren ) { - ActorConstIter endIter = mChildren->end(); - for( ActorIter iter = mChildren->begin(); iter != endIter; ++iter ) + for( const auto& child : *mChildren ) { - (*iter)->RecursiveDisconnectFromStage( disconnectionList ); + child->RecursiveDisconnectFromStage( disconnectionList ); } } @@ -1730,9 +1775,9 @@ void Actor::DepthTraverseActorTree( OwnerPointer& sceneG // Create/add to children of this node if( mChildren ) { - for( ActorContainer::iterator it = mChildren->begin(); it != mChildren->end(); ++it ) + for( const auto& child : *mChildren ) { - Actor* childActor = (*it).Get(); + Actor* childActor = child.Get(); ++depthIndex; childActor->DepthTraverseActorTree( sceneGraphNodeDepths, depthIndex ); } @@ -1865,12 +1910,13 @@ bool Actor::DoAction( BaseObject* object, const std::string& actionName, const P if( actor ) { - if( 0 == actionName.compare( ACTION_SHOW ) ) + std::string_view name(actionName); + if(name == ACTION_SHOW) { actor->SetVisible( true ); done = true; } - else if( 0 == actionName.compare( ACTION_HIDE ) ) + else if(name == ACTION_HIDE) { actor->SetVisible( false ); done = true; @@ -2231,9 +2277,9 @@ void Actor::NegotiateDimension( Dimension::Type dimension, const Vector2& alloca // Check that we havn't gotten into an infinite loop ActorDimensionPair searchActor = ActorDimensionPair( this, dimension ); bool recursionFound = false; - for( ActorDimensionStack::iterator it = recursionStack.begin(), itEnd = recursionStack.end(); it != itEnd; ++it ) + for( auto& element : recursionStack ) { - if( *it == searchActor ) + if( element == searchActor ) { recursionFound = true; break; @@ -2498,6 +2544,8 @@ void Actor::SetVisibleInternal( bool visible, SendMessage::Type sendMessage ) { // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodePropertyMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mVisible, &AnimatableProperty::Bake, visible ); + + RequestRenderingMessage( GetEventThreadServices().GetUpdateManager() ); } mVisible = visible; @@ -2639,7 +2687,7 @@ void Actor::RaiseToTop() ActorContainer& siblings = *(mParent->mChildren); if( siblings.back() != this ) // If not already at end { - ActorContainer::iterator iter = std::find( siblings.begin(), siblings.end(), this ); + auto iter = std::find( siblings.begin(), siblings.end(), this ); if( iter != siblings.end() ) { siblings.erase(iter); @@ -2667,7 +2715,7 @@ void Actor::LowerToBottom() { ActorPtr thisPtr(this); // ensure this actor remains referenced. - ActorContainer::iterator iter = std::find( siblings.begin(), siblings.end(), this ); + auto iter = std::find( siblings.begin(), siblings.end(), this ); if( iter != siblings.end() ) { siblings.erase(iter); @@ -2695,8 +2743,8 @@ void Actor::RaiseAbove( Internal::Actor& target ) { ActorPtr thisPtr(this); // ensure this actor remains referenced. - ActorContainer::iterator targetIter = std::find( siblings.begin(), siblings.end(), &target ); - ActorContainer::iterator thisIter = std::find( siblings.begin(), siblings.end(), this ); + auto targetIter = std::find( siblings.begin(), siblings.end(), &target ); + auto thisIter = std::find( siblings.begin(), siblings.end(), this ); if( thisIter < targetIter ) { siblings.erase(thisIter); @@ -2728,8 +2776,8 @@ void Actor::LowerBelow( Internal::Actor& target ) { ActorPtr thisPtr(this); // ensure this actor remains referenced. - ActorContainer::iterator targetIter = std::find( siblings.begin(), siblings.end(), &target ); - ActorContainer::iterator thisIter = std::find( siblings.begin(), siblings.end(), this ); + auto targetIter = std::find( siblings.begin(), siblings.end(), &target ); + auto thisIter = std::find( siblings.begin(), siblings.end(), this ); if( thisIter > targetIter ) { @@ -2775,7 +2823,7 @@ void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::LayoutDirec if( actor->GetChildCount() > 0 ) { - for( ActorPtr& child : actor->GetChildrenInternal() ) + for( const auto& child : actor->GetChildrenInternal() ) { InheritLayoutDirectionRecursively( child, direction ); } diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index a982904..367beeb 100755 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1241,6 +1241,16 @@ public: */ void RemoveRenderer( uint32_t index ); + /** + * Set BlendEquation at each renderer that added on this Actor. + */ + void SetBlendEquation( DevelBlendEquation::Type blendEquation ); + + /** + * @brief Get Blend Equation that applied to this Actor + */ + DevelBlendEquation::Type GetBlendEquation() const; + public: /** @@ -1382,6 +1392,25 @@ public: return mCaptureAllTouchAfterStart; } + /** + * Sets the touch area of an actor. + * @param [in] area The new area. + */ + void SetTouchArea(Vector2 area) + { + mTouchArea = area; + } + + /** + * Retrieve the Actor's touch area. + * @return The Actor's touch area. + */ + const Vector2& GetTouchArea() const + { + return mTouchArea; + } + + // Gestures /** @@ -2026,6 +2055,7 @@ protected: Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position) Vector3 mTargetScale; ///< Event-side storage for scale Vector3 mAnimatedSize; ///< Event-side storage for size animation + Vector2 mTouchArea; ///< touch area std::string mName; ///< Name of the actor uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order. @@ -2051,6 +2081,8 @@ protected: DrawMode::Type mDrawMode : 3; ///< Cached: How the actor and its children should be drawn ColorMode mColorMode : 3; ///< Cached: Determines whether mWorldColor is inherited ClippingMode::Type mClippingMode : 3; ///< Cached: Determines which clipping mode (if any) to use. + DevelBlendEquation::Type mBlendEquation : 16;///< Cached: Determines which blend equation will be used to render renderers. + bool mIsBlendEquationSet : 1; ///< Flag to identify whether the Blend equation is set private: diff --git a/dali/internal/event/actors/actor-property-handler.cpp b/dali/internal/event/actors/actor-property-handler.cpp old mode 100644 new mode 100755 index 099466e..76f82f5 --- a/dali/internal/event/actors/actor-property-handler.cpp +++ b/dali/internal/event/actors/actor-property-handler.cpp @@ -574,6 +574,26 @@ void Actor::PropertyHandler::SetDefaultProperty( Internal::Actor& actor, Propert break; } + case Dali::DevelActor::Property::TOUCH_AREA: + { + Vector2 vec2Value; + if( property.Get( vec2Value ) ) + { + actor.SetTouchArea( vec2Value ); + } + break; + } + + case Dali::DevelActor::Property::BLEND_EQUATION: + { + int value; + if( property.Get( value ) ) + { + actor.SetBlendEquation( static_cast( value ) ); + } + break; + } + default: { // this can happen in the case of a non-animatable default property so just do nothing @@ -1603,6 +1623,18 @@ bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor break; } + case Dali::DevelActor::Property::TOUCH_AREA: + { + value = actor.GetTouchArea(); + break; + } + + case Dali::DevelActor::Property::BLEND_EQUATION: + { + value = actor.GetBlendEquation(); + break; + } + default: { // Must be a scene-graph only property diff --git a/dali/internal/event/actors/custom-actor-internal.cpp b/dali/internal/event/actors/custom-actor-internal.cpp index f85f07b..33f302a 100644 --- a/dali/internal/event/actors/custom-actor-internal.cpp +++ b/dali/internal/event/actors/custom-actor-internal.cpp @@ -43,9 +43,7 @@ CustomActor::CustomActor( const SceneGraph::Node& node, CustomActorImpl& extensi SetRelayoutEnabled( extension.IsRelayoutEnabled() ); } -CustomActor::~CustomActor() -{ -} +CustomActor::~CustomActor() = default; Dali::TypeInfo CustomActor::GetTypeInfo() { diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index dfb3011..d164abb 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -67,10 +67,10 @@ DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, LayerDefaul // Actions -const char* const ACTION_RAISE = "raise"; -const char* const ACTION_LOWER = "lower"; -const char* const ACTION_RAISE_TO_TOP = "raiseToTop"; -const char* const ACTION_LOWER_TO_BOTTOM = "lowerToBottom"; +static constexpr std::string_view ACTION_RAISE = "raise"; +static constexpr std::string_view ACTION_LOWER = "lower"; +static constexpr std::string_view ACTION_RAISE_TO_TOP = "raiseToTop"; +static constexpr std::string_view ACTION_LOWER_TO_BOTTOM = "lowerToBottom"; BaseHandle Create() { @@ -79,10 +79,10 @@ BaseHandle Create() TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create, LayerDefaultProperties ); -TypeAction a1( mType, ACTION_RAISE, &Layer::DoAction ); -TypeAction a2( mType, ACTION_LOWER, &Layer::DoAction ); -TypeAction a3( mType, ACTION_RAISE_TO_TOP, &Layer::DoAction ); -TypeAction a4( mType, ACTION_LOWER_TO_BOTTOM, &Layer::DoAction ); +TypeAction a1(mType, std::string(ACTION_RAISE), &Layer::DoAction); +TypeAction a2(mType, std::string(ACTION_LOWER), &Layer::DoAction); +TypeAction a3(mType, std::string(ACTION_RAISE_TO_TOP), &Layer::DoAction); +TypeAction a4(mType, std::string(ACTION_LOWER_TO_BOTTOM), &Layer::DoAction); } // unnamed namespace @@ -507,22 +507,24 @@ bool Layer::DoAction( BaseObject* object, const std::string& actionName, const P if( layer ) { - if( 0 == actionName.compare( ACTION_RAISE ) ) + std::string_view name(actionName); + + if(name == ACTION_RAISE) { layer->Raise(); done = true; } - else if( 0 == actionName.compare( ACTION_LOWER ) ) + else if(name == ACTION_LOWER) { layer->Lower(); done = true; } - else if( 0 == actionName.compare( ACTION_RAISE_TO_TOP ) ) + else if(name == ACTION_RAISE_TO_TOP) { layer->RaiseToTop(); done = true; } - else if( 0 == actionName.compare( ACTION_LOWER_TO_BOTTOM ) ) + else if(name == ACTION_LOWER_TO_BOTTOM) { layer->LowerToBottom(); done = true; diff --git a/dali/internal/event/actors/layer-list.cpp b/dali/internal/event/actors/layer-list.cpp index e378101..60c7bee 100644 --- a/dali/internal/event/actors/layer-list.cpp +++ b/dali/internal/event/actors/layer-list.cpp @@ -65,9 +65,7 @@ LayerList* LayerList::New( SceneGraph::UpdateManager& updateManager ) return new LayerList( updateManager ); } -LayerList::~LayerList() -{ -} +LayerList::~LayerList() = default; uint32_t LayerList::GetLayerCount() const { diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index db41040..e9d7578 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -56,13 +56,13 @@ namespace // Signals -const char* const SIGNAL_FINISHED = "finished"; +static constexpr std::string_view SIGNAL_FINISHED = "finished"; // Actions -const char* const ACTION_PLAY = "play"; -const char* const ACTION_STOP = "stop"; -const char* const ACTION_PAUSE = "pause"; +static constexpr std::string_view ACTION_PLAY = "play"; +static constexpr std::string_view ACTION_STOP = "stop"; +static constexpr std::string_view ACTION_PAUSE = "pause"; BaseHandle Create() { @@ -71,11 +71,11 @@ BaseHandle Create() TypeRegistration mType( typeid( Dali::Animation ), typeid( Dali::BaseHandle ), Create ); -SignalConnectorType signalConnector1( mType, SIGNAL_FINISHED, &Animation::DoConnectSignal ); +SignalConnectorType signalConnector1(mType, std::string(SIGNAL_FINISHED), &Animation::DoConnectSignal); -TypeAction action1( mType, ACTION_PLAY, &Animation::DoAction ); -TypeAction action2( mType, ACTION_STOP, &Animation::DoAction ); -TypeAction action3( mType, ACTION_PAUSE, &Animation::DoAction ); +TypeAction action1(mType, std::string(ACTION_PLAY), &Animation::DoAction); +TypeAction action2(mType, std::string(ACTION_STOP), &Animation::DoAction); +TypeAction action3(mType, std::string(ACTION_PAUSE), &Animation::DoAction); const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::BAKE ); const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BAKE_FINAL ); @@ -137,7 +137,6 @@ void ValidateParameters( Property::Type propertyType, Property::Type destination } // anonymous namespace - AnimationPtr Animation::New(float durationSeconds) { if( durationSeconds < 0.0f ) @@ -155,26 +154,13 @@ AnimationPtr Animation::New(float durationSeconds) return animation; } -Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha ) -: mAnimation( nullptr ), - mEventThreadServices( eventThreadServices ), - mPlaylist( playlist ), - mFinishedSignal(), - mConnectors(), - mConnectorTargetValues(), - mPlayRange( Vector2(0.0f,1.0f)), - mDurationSeconds( durationSeconds ), - mSpeedFactor(1.0f), - mNotificationCount( 0 ), - mLoopCount(1), - mCurrentLoop(0), - mEndAction( endAction ), - mDisconnectAction( disconnectAction ), - mDefaultAlpha( defaultAlpha ), - mState(Dali::Animation::STOPPED), - mProgressReachedMarker( 0.0f ), - mDelaySeconds( 0.0f ), - mAutoReverseEnabled( false ) +Animation::Animation(EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha) +: mEventThreadServices(eventThreadServices), + mPlaylist(playlist), + mDefaultAlpha(defaultAlpha), + mDurationSeconds(durationSeconds), + mEndAction(endAction), + mDisconnectAction(disconnectAction) { } @@ -457,67 +443,67 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha { case Property::BOOLEAN: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByBoolean(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByBoolean(relativeValue.Get()), + alpha, + period)); break; } case Property::INTEGER: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByInteger(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByInteger(relativeValue.Get()), + alpha, + period)); break; } case Property::FLOAT: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByFloat(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByFloat(relativeValue.Get()), + alpha, + period)); break; } case Property::VECTOR2: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByVector2(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByVector2(relativeValue.Get()), + alpha, + period)); break; } case Property::VECTOR3: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByVector3(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByVector3(relativeValue.Get()), + alpha, + period)); break; } case Property::VECTOR4: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateByVector4(relativeValue.Get()), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateByVector4(relativeValue.Get()), + alpha, + period)); break; } @@ -525,12 +511,12 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha { AngleAxis angleAxis = relativeValue.Get(); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new RotateByAngleAxis(angleAxis.angle, angleAxis.axis), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + RotateByAngleAxis(angleAxis.angle, angleAxis.axis), + alpha, + period)); break; } @@ -578,78 +564,78 @@ void Animation::AnimateTo(Property& target, Property::Value destinationValue, Al { case Property::BOOLEAN: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToBoolean( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToBoolean(destinationValue.Get()), + alpha, + period)); break; } case Property::INTEGER: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToInteger( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToInteger(destinationValue.Get()), + alpha, + period)); break; } case Property::FLOAT: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToFloat( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToFloat(destinationValue.Get()), + alpha, + period)); break; } case Property::VECTOR2: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToVector2( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToVector2(destinationValue.Get()), + alpha, + period)); break; } case Property::VECTOR3: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToVector3( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToVector3(destinationValue.Get()), + alpha, + period)); break; } case Property::VECTOR4: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new AnimateToVector4( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + AnimateToVector4(destinationValue.Get()), + alpha, + period)); break; } case Property::ROTATION: { - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new RotateToQuaternion( destinationValue.Get() ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + RotateToQuaternion(destinationValue.Get()), + alpha, + period)); break; } @@ -717,99 +703,85 @@ void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Alp { case Dali::Property::BOOLEAN: { - const KeyFrameBoolean* kf; - GetSpecialization(keyFrames, kf); - KeyFrameBooleanPtr kfCopy = KeyFrameBoolean::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameBooleanFunctor(kfCopy), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameBooleanFunctor(*kf), // takes a copy of the keyframe + alpha, + period)); break; } case Dali::Property::INTEGER: { - const KeyFrameInteger* kf; - GetSpecialization(keyFrames, kf); - KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameIntegerFunctor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameIntegerFunctor(*kf, interpolation), // takes a copy of the keyframe + alpha, + period)); break; } case Dali::Property::FLOAT: { - const KeyFrameNumber* kf; - GetSpecialization(keyFrames, kf); - KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameNumberFunctor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameNumberFunctor(*kf, interpolation), // takes a copy of the keyframe + alpha, + period)); break; } case Dali::Property::VECTOR2: { - const KeyFrameVector2* kf; - GetSpecialization(keyFrames, kf); - KeyFrameVector2Ptr kfCopy = KeyFrameVector2::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameVector2Functor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameVector2Functor(*kf, interpolation), // takes a copy of the keyframe + alpha, + period)); break; } case Dali::Property::VECTOR3: { - const KeyFrameVector3* kf; - GetSpecialization(keyFrames, kf); - KeyFrameVector3Ptr kfCopy = KeyFrameVector3::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameVector3Functor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameVector3Functor(*kf, interpolation), // takes a copy of the keyframe + alpha, + period)); break; } case Dali::Property::VECTOR4: { - const KeyFrameVector4* kf; - GetSpecialization(keyFrames, kf); - KeyFrameVector4Ptr kfCopy = KeyFrameVector4::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameVector4Functor(kfCopy,interpolation), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameVector4Functor(*kf, interpolation), // takes a copy of the keyframe + alpha, + period)); break; } case Dali::Property::ROTATION: { - const KeyFrameQuaternion* kf; - GetSpecialization(keyFrames, kf); - KeyFrameQuaternionPtr kfCopy = KeyFrameQuaternion::Clone(*kf); - AddAnimatorConnector( AnimatorConnector::New( object, - target.propertyIndex, - target.componentIndex, - new KeyFrameQuaternionFunctor(kfCopy), - alpha, - period ) ); + auto kf = GetSpecialization(keyFrames); + AddAnimatorConnector(AnimatorConnector::New(object, + target.propertyIndex, + target.componentIndex, + KeyFrameQuaternionFunctor(*kf), // takes a copy of the keyframe + alpha, + period)); break; } @@ -874,7 +846,7 @@ bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* bool connected( false ); Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type. - if( 0 == signalName.compare( SIGNAL_FINISHED ) ) + if(SIGNAL_FINISHED == signalName) { animation->FinishedSignal().Connect( tracker, functor ); connected = true; @@ -914,23 +886,23 @@ void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, PathPtr pathCopy = Path::Clone(path); //Position animation - AddAnimatorConnector( AnimatorConnector::New( actor, - Dali::Actor::Property::POSITION, - Property::INVALID_COMPONENT_INDEX, - new PathPositionFunctor( pathCopy ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(actor, + Dali::Actor::Property::POSITION, + Property::INVALID_COMPONENT_INDEX, + PathPositionFunctor(pathCopy), + alpha, + period)); //If forward is zero, PathRotationFunctor will always return the unit quaternion if( forward != Vector3::ZERO ) { //Rotation animation - AddAnimatorConnector( AnimatorConnector::New( actor, - Dali::Actor::Property::ORIENTATION, - Property::INVALID_COMPONENT_INDEX, - new PathRotationFunctor( pathCopy, forward ), - alpha, - period ) ); + AddAnimatorConnector(AnimatorConnector::New(actor, + Dali::Actor::Property::ORIENTATION, + Property::INVALID_COMPONENT_INDEX, + PathRotationFunctor(pathCopy, forward), + alpha, + period)); } } @@ -938,24 +910,24 @@ void Animation::Show(Actor& actor, float delaySeconds) { ExtendDuration( TimePeriod(delaySeconds, 0) ); - AddAnimatorConnector( AnimatorConnector::New( actor, - Dali::Actor::Property::VISIBLE, - Property::INVALID_COMPONENT_INDEX, - new AnimateToBoolean(SHOW_VALUE), - mDefaultAlpha, - TimePeriod(delaySeconds, 0.0f/*immediate*/) ) ); + AddAnimatorConnector(AnimatorConnector::New(actor, + Dali::Actor::Property::VISIBLE, + Property::INVALID_COMPONENT_INDEX, + AnimateToBoolean(SHOW_VALUE), + mDefaultAlpha, + TimePeriod(delaySeconds, 0.0f /*immediate*/))); } void Animation::Hide(Actor& actor, float delaySeconds) { ExtendDuration( TimePeriod(delaySeconds, 0) ); - AddAnimatorConnector( AnimatorConnector::New( actor, - Dali::Actor::Property::VISIBLE, - Property::INVALID_COMPONENT_INDEX, - new AnimateToBoolean(HIDE_VALUE), - mDefaultAlpha, - TimePeriod(delaySeconds, 0.0f/*immediate*/) ) ); + AddAnimatorConnector(AnimatorConnector::New(actor, + Dali::Actor::Property::VISIBLE, + Property::INVALID_COMPONENT_INDEX, + AnimateToBoolean(HIDE_VALUE), + mDefaultAlpha, + TimePeriod(delaySeconds, 0.0f /*immediate*/))); } bool Animation::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes ) @@ -965,7 +937,9 @@ bool Animation::DoAction( BaseObject* object, const std::string& actionName, con if( animation ) { - if( 0 == actionName.compare( ACTION_PLAY ) ) + std::string_view name(actionName); + + if(name == ACTION_PLAY) { if( Property::Value* value = attributes.Find("duration", Property::FLOAT) ) { @@ -975,12 +949,12 @@ bool Animation::DoAction( BaseObject* object, const std::string& actionName, con animation->Play(); done = true; } - else if( 0 == actionName.compare( ACTION_STOP ) ) + else if(name == ACTION_STOP) { animation->Stop(); done = true; } - else if( 0 == actionName.compare( ACTION_PAUSE ) ) + else if(name == ACTION_PAUSE) { animation->Pause(); done = true; diff --git a/dali/internal/event/animation/animation-impl.h b/dali/internal/event/animation/animation-impl.h index 3820ade..6d715fe 100644 --- a/dali/internal/event/animation/animation-impl.h +++ b/dali/internal/event/animation/animation-impl.h @@ -61,12 +61,11 @@ using AnimationConstIter = AnimationContainer::const_iterator; class Animation : public BaseObject { public: - - enum Type + enum Type : uint8_t { - TO, ///< Animating TO the given value - BY, ///< Animating BY the given value - BETWEEN ///< Animating BETWEEN key-frames + TO, ///< Animating TO the given value + BY, ///< Animating BY the given value + BETWEEN ///< Animating BETWEEN key-frames }; using EndAction = Dali::Animation::EndAction; @@ -492,7 +491,7 @@ private: Animation::Type animatorType{TO}; }; - enum class Notify + enum class Notify : uint8_t { USE_CURRENT_VALUE, ///< Set the current value for the property USE_TARGET_VALUE, ///< Set the animator's target value for the property @@ -521,36 +520,33 @@ private: void SendFinalProgressNotificationMessage(); private: + using AnimatorConnectorContainer = OwnerContainer; + using ConnectorTargetValuesContainer = std::vector; - const SceneGraph::Animation* mAnimation; + const SceneGraph::Animation* mAnimation{ nullptr }; EventThreadServices& mEventThreadServices; - AnimationPlaylist& mPlaylist; - - Dali::Animation::AnimationSignalType mFinishedSignal; - - Dali::Animation::AnimationSignalType mProgressReachedSignal; - - using AnimatorConnectorContainer = OwnerContainer; - AnimatorConnectorContainer mConnectors; ///< Owned by the Animation - - using ConnectorTargetValuesContainer = std::vector; - ConnectorTargetValuesContainer mConnectorTargetValues; //< Used to store animating property target value information - - Vector2 mPlayRange; - - float mDurationSeconds; - float mSpeedFactor; - int32_t mNotificationCount; ///< Keep track of how many Finished signals have been emitted. - int32_t mLoopCount; - int32_t mCurrentLoop; - EndAction mEndAction; - EndAction mDisconnectAction; - AlphaFunction mDefaultAlpha; - Dali::Animation::State mState; - float mProgressReachedMarker; - float mDelaySeconds; - bool mAutoReverseEnabled; ///< Flag to identify that the looping mode is auto reverse. + AnimationPlaylist& mPlaylist; + + Dali::Animation::AnimationSignalType mFinishedSignal{}; + Dali::Animation::AnimationSignalType mProgressReachedSignal{}; + + AnimatorConnectorContainer mConnectors{}; ///< Owned by the Animation + ConnectorTargetValuesContainer mConnectorTargetValues{}; //< Used to store animating property target value information + + AlphaFunction mDefaultAlpha; + Vector2 mPlayRange{0.0f, 1.0f}; + float mDurationSeconds; + float mSpeedFactor{1.0f}; + int32_t mNotificationCount{0}; ///< Keep track of how many Finished signals have been emitted. + int32_t mLoopCount{1}; + int32_t mCurrentLoop{0}; + float mProgressReachedMarker{0.0f}; + float mDelaySeconds{0.0f}; + EndAction mEndAction; + EndAction mDisconnectAction; + Dali::Animation::State mState{Dali::Animation::STOPPED}; + bool mAutoReverseEnabled{false}; ///< Flag to identify that the looping mode is auto reverse. }; } // namespace Internal diff --git a/dali/internal/event/animation/animation-playlist.cpp b/dali/internal/event/animation/animation-playlist.cpp index c39385f..d48d28d 100644 --- a/dali/internal/event/animation/animation-playlist.cpp +++ b/dali/internal/event/animation/animation-playlist.cpp @@ -35,13 +35,9 @@ AnimationPlaylist* AnimationPlaylist::New() return new AnimationPlaylist(); } -AnimationPlaylist::AnimationPlaylist() -{ -} +AnimationPlaylist::AnimationPlaylist() = default; -AnimationPlaylist::~AnimationPlaylist() -{ -} +AnimationPlaylist::~AnimationPlaylist() = default; void AnimationPlaylist::AnimationCreated( Animation& animation ) { diff --git a/dali/internal/event/animation/animator-connector-base.h b/dali/internal/event/animation/animator-connector-base.h index 8e839fb..8699012 100644 --- a/dali/internal/event/animation/animator-connector-base.h +++ b/dali/internal/event/animation/animator-connector-base.h @@ -49,21 +49,16 @@ public: /** * Constructor. */ - AnimatorConnectorBase( - Object& object, - Property::Index propertyIndex, - int32_t componentIndex, - Internal::AnimatorFunctionBase* animatorFunction, - AlphaFunction alpha, - const TimePeriod& period) - : mParent( nullptr ), - mObject( &object ), - mAnimator( nullptr ), - mAnimatorFunction( animatorFunction ), + AnimatorConnectorBase(Object& object, + Property::Index propertyIndex, + int32_t componentIndex, + AlphaFunction alpha, + const TimePeriod& period) + : mObject(&object), mAlphaFunction(alpha), mTimePeriod(period), - mPropertyIndex( propertyIndex ), - mComponentIndex( componentIndex ) + mPropertyIndex(propertyIndex), + mComponentIndex(componentIndex) { object.AddObserver( *this ); } @@ -77,13 +72,6 @@ public: { mObject->RemoveObserver( *this ); } - - // If there is not a SceneGraph::Animator, the AnimatorConnector is responsible for deleting the mAnimatorFunction - // otherwise, the animator function ownership is transferred to the SceneGraph::Animator - if( !mAnimator ) - { - delete mAnimatorFunction; - } } /** @@ -96,7 +84,6 @@ public: void CreateAnimator() { DALI_ASSERT_DEBUG( mAnimator == nullptr ); - DALI_ASSERT_DEBUG( mAnimatorFunction != nullptr ); DALI_ASSERT_DEBUG( mParent != nullptr ); //Get the PropertyOwner the animator is going to animate @@ -206,18 +193,15 @@ private: } protected: - - Animation* mParent; ///< The parent owns the connector. - Object* mObject; ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called. - SceneGraph::AnimatorBase* mAnimator; - Internal::AnimatorFunctionBase* mAnimatorFunction; ///< Owned by the animator connector until an Scenegraph::Animator is created + Animation* mParent{nullptr}; ///< The parent owns the connector. + Object* mObject; ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called. + SceneGraph::AnimatorBase* mAnimator{nullptr}; AlphaFunction mAlphaFunction; - TimePeriod mTimePeriod; + TimePeriod mTimePeriod; Property::Index mPropertyIndex; - int32_t mComponentIndex; - + int32_t mComponentIndex; }; } // namespace Internal diff --git a/dali/internal/event/animation/animator-connector.h b/dali/internal/event/animation/animator-connector.h index e0a2894..434fdc9 100644 --- a/dali/internal/event/animation/animator-connector.h +++ b/dali/internal/event/animation/animator-connector.h @@ -18,6 +18,9 @@ * */ +//EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include @@ -41,6 +44,10 @@ namespace Internal template < typename PropertyType > class AnimatorConnector : public AnimatorConnectorBase { + using AnimatorFunction = std::function; + + AnimatorFunction mAnimatorFunction; + public: using AnimatorType = SceneGraph::Animator< PropertyType, PropertyAccessor >; @@ -56,40 +63,39 @@ public: * @param[in] period The time period of the animator. * @return A pointer to a newly allocated animator connector. */ - static AnimatorConnectorBase* New( Object& object, - Property::Index propertyIndex, - int32_t componentIndex, - AnimatorFunctionBase* animatorFunction, - AlphaFunction alpha, - const TimePeriod& period ) + static AnimatorConnectorBase* New(Object& object, + Property::Index propertyIndex, + int32_t componentIndex, + AnimatorFunction animatorFunction, + AlphaFunction alpha, + const TimePeriod& period) { - return new AnimatorConnector( object, - propertyIndex, - componentIndex, - animatorFunction, - alpha, - period ); + return new AnimatorConnector(object, + propertyIndex, + componentIndex, + std::move(animatorFunction), + alpha, + period); } /** * Virtual destructor. */ - ~AnimatorConnector() override - { - } + ~AnimatorConnector() override = default; private: /** * Private constructor; see also AnimatorConnector::New(). */ - AnimatorConnector( Object& object, - Property::Index propertyIndex, - int32_t componentIndex, - Internal::AnimatorFunctionBase* animatorFunction, - AlphaFunction alpha, - const TimePeriod& period ) - : AnimatorConnectorBase( object, propertyIndex, componentIndex, animatorFunction, alpha, period ) + AnimatorConnector(Object& object, + Property::Index propertyIndex, + int32_t componentIndex, + AnimatorFunction animatorFunction, + AlphaFunction alpha, + const TimePeriod& period) + : AnimatorConnectorBase(object, propertyIndex, componentIndex, alpha, period), + mAnimatorFunction(std::move(animatorFunction)) { } @@ -115,7 +121,11 @@ private: { if( baseProperty.IsTransformManagerProperty() ) { - mAnimator = SceneGraph::AnimatorTransformProperty< PropertyType,TransformManagerPropertyAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); // Don't reset transform manager properties - TransformManager will do it more efficiently } else @@ -126,8 +136,12 @@ private: else { // Create the animator and resetter - mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction, - mAlphaFunction, mTimePeriod ); + mAnimator = AnimatorType::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); + resetterRequired = true; } return resetterRequired; @@ -140,6 +154,10 @@ private: template <> class AnimatorConnector< float > : public AnimatorConnectorBase { + using AnimatorFunction = std::function; + + AnimatorFunction mAnimatorFunction; + public: using AnimatorType = SceneGraph::Animator< float, PropertyAccessor >; @@ -155,40 +173,39 @@ public: * @param[in] period The time period of the animator. * @return A pointer to a newly allocated animator connector. */ - static AnimatorConnectorBase* New( Object& object, - Property::Index propertyIndex, - int32_t componentIndex, - AnimatorFunctionBase* animatorFunction, - AlphaFunction alpha, - const TimePeriod& period ) + static AnimatorConnectorBase* New(Object& object, + Property::Index propertyIndex, + int32_t componentIndex, + AnimatorFunction animatorFunction, + AlphaFunction alpha, + const TimePeriod& period) { - return new AnimatorConnector( object, - propertyIndex, - componentIndex, - animatorFunction, - alpha, - period ); + return new AnimatorConnector(object, + propertyIndex, + componentIndex, + std::move(animatorFunction), + alpha, + period); } /** * Virtual destructor. */ - ~AnimatorConnector() override - { - } + ~AnimatorConnector() override = default; private: /** * Private constructor; see also AnimatorConnector::New(). */ - AnimatorConnector( Object& object, - Property::Index propertyIndex, - int32_t componentIndex, - Internal::AnimatorFunctionBase* animatorFunction, - AlphaFunction alpha, - const TimePeriod& period ) - : AnimatorConnectorBase( object, propertyIndex, componentIndex, animatorFunction, alpha, period ) + AnimatorConnector(Object& object, + Property::Index propertyIndex, + int32_t componentIndex, + AnimatorFunction animatorFunction, + AlphaFunction alpha, + const TimePeriod& period) + : AnimatorConnectorBase(object, propertyIndex, componentIndex, alpha, period), + mAnimatorFunction(std::move(animatorFunction)) { } @@ -214,7 +231,11 @@ private: { if( baseProperty.IsTransformManagerProperty() ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); // Don't reset transform manager properties - TransformManager will do it more efficiently } else @@ -225,8 +246,12 @@ private: else { // Create the animator and resetter - mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction, - mAlphaFunction, mTimePeriod ); + mAnimator = AnimatorType::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); + resetterRequired = true; } } @@ -246,20 +271,20 @@ private: { case 0: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 1: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } default: @@ -283,15 +308,27 @@ private: { if( mComponentIndex == 0 ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); } else if( mComponentIndex == 1 ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); } else if( mComponentIndex == 2 ) { - mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod ); + mAnimator = SceneGraph::AnimatorTransformProperty >::New(propertyOwner, + baseProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); } } else @@ -309,29 +346,29 @@ private: { case 0: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 1: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 2: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } default: @@ -357,38 +394,38 @@ private: { case 0: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 1: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 2: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } case 3: { - mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW >::New( propertyOwner, - *animatableProperty, - mAnimatorFunction, - mAlphaFunction, - mTimePeriod ); + mAnimator = SceneGraph::Animator >::New(propertyOwner, + *animatableProperty, + std::move(mAnimatorFunction), + mAlphaFunction, + mTimePeriod); break; } diff --git a/dali/internal/event/animation/key-frame-channel.h b/dali/internal/event/animation/key-frame-channel.h index 05e5fde..c7f0444 100644 --- a/dali/internal/event/animation/key-frame-channel.h +++ b/dali/internal/event/animation/key-frame-channel.h @@ -18,6 +18,9 @@ * */ +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include @@ -27,176 +30,76 @@ namespace Dali { namespace Internal { - -class KeyFrameChannelBase -{ -public: - enum KeyFrameChannelId - { - Translate, Rotate, Scale, - }; - - KeyFrameChannelBase(KeyFrameChannelId channel_id) - : mChannelId(channel_id) - { - } - - virtual ~KeyFrameChannelBase() - { - } - - KeyFrameChannelId GetId() const - { - return mChannelId; - } - - virtual bool IsActive(float progress) = 0; - -protected: - KeyFrameChannelId mChannelId; -}; - - -template -class KeyFrameChannel : public KeyFrameChannelBase +template +struct KeyFrameChannel { -public: - using ProgressValues = std::vector >; - - KeyFrameChannel(KeyFrameChannelId channel_id, ProgressValues& values ) - : KeyFrameChannelBase(channel_id), - mValues(values) - { - } - - - ~KeyFrameChannel() override - { - } - - bool IsActive (float progress) override; - - V GetValue(float progress, Dali::Animation::Interpolation interpolation) const; - - bool FindInterval(typename ProgressValues::iterator& start, - typename ProgressValues::iterator& end, - float progress) const; - - ProgressValues& mValues; -}; + using ProgressValues = std::vector>; -template -bool KeyFrameChannel::IsActive (float progress) -{ - bool active = false; - if(!mValues.empty()) + bool IsActive(float progress) const { - ProgressValue& first = mValues.front(); - - if( progress >= first.GetProgress() ) + if(!mValues.empty() && (progress >= mValues[0].GetProgress())) { - active = true; + return true; } + return false; } - return active; -} - -/** - * Use a linear search to find the interval containing progress - */ -template -bool KeyFrameChannel::FindInterval( - typename ProgressValues::iterator& start, - typename ProgressValues::iterator& end, - float progress) const -{ - bool found = false; - typename std::vector >::iterator iter = mValues.begin(); - typename std::vector >::iterator prevIter = iter; - - while(iter != mValues.end() && iter->GetProgress() <= progress) - { - prevIter = iter; - ++iter; - } - - if(iter == mValues.end()) - { - --prevIter; - --iter; - } - - if(prevIter->GetProgress() <= progress - && - iter->GetProgress() > progress) - { - found = true; - start = prevIter; - end = iter; - } - - return found; -} -template -V KeyFrameChannel::GetValue (float progress, Dali::Animation::Interpolation interpolation) const -{ - ProgressValue& firstPV = mValues.front(); - - typename std::vector >::iterator start; - typename std::vector >::iterator end; - - V interpolatedV = firstPV.GetValue(); - if(progress >= mValues.back().GetProgress() ) - { - interpolatedV = mValues.back().GetValue(); // This should probably be last value... - } - else if(FindInterval(start, end, progress)) + V GetValue(float progress, Dali::Animation::Interpolation interpolation) const { - float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress()); + V interpolatedV{}; - if( interpolation == Dali::Animation::LINEAR ) + if(progress >= mValues.back().GetProgress()) { - Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress); + interpolatedV = mValues.back().GetValue(); } else { - //Calculate prev and next values - V prev; - if( start != mValues.begin() ) - { - prev = (start-1)->GetValue(); - } - else - { - //Project next value through start point - prev = start->GetValue() + (start->GetValue()-(start+1)->GetValue()); - } + auto end = std::find_if(mValues.begin(), mValues.end(), [=](const auto& element) { return element.GetProgress() > progress; }); + auto start = end - 1; - V next; - if( end != mValues.end()-1) - { - next = (end+1)->GetValue(); - } - else + const bool validInterval = (end != mValues.end()) && (start->GetProgress() <= progress); + + if(validInterval) { - //Project prev value through end point - next = end->GetValue() + (end->GetValue()-(end-1)->GetValue()); + float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress()); + if(interpolation == Dali::Animation::LINEAR) + { + Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress); + } + else + { + //Calculate prev and next values + V prev; + if(start != mValues.begin()) + { + prev = (start - 1)->GetValue(); + } + else + { + //Project next value through start point + prev = start->GetValue() + (start->GetValue() - (start + 1)->GetValue()); + } + + V next; + if(end != mValues.end() - 1) + { + next = (end + 1)->GetValue(); + } + else + { + //Project prev value through end point + next = end->GetValue() + (end->GetValue() - (end - 1)->GetValue()); + } + + CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress); + } } - - CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress); } + return interpolatedV; } - return interpolatedV; -} - -using KeyFrameChannelNumber = KeyFrameChannel; -using KeyFrameChannelVector2 = KeyFrameChannel; -using KeyFrameChannelVector3 = KeyFrameChannel; -using KeyFrameChannelVector4 = KeyFrameChannel; -using KeyFrameChannelQuaternion = KeyFrameChannel; -using KeyFrameChannelAngleAxis = KeyFrameChannel; + ProgressValues mValues; +}; } // Internal } // namespace Dali diff --git a/dali/internal/event/animation/key-frames-impl.cpp b/dali/internal/event/animation/key-frames-impl.cpp index 1e89e0f..7ecfd6b 100644 --- a/dali/internal/event/animation/key-frames-impl.cpp +++ b/dali/internal/event/animation/key-frames-impl.cpp @@ -28,17 +28,6 @@ KeyFrames* KeyFrames::New() return new KeyFrames(); } -KeyFrames::KeyFrames() - : mType(Property::NONE), - mKeyFrames(nullptr) -{ -} - -KeyFrames::~KeyFrames() -{ -} - - void KeyFrames::CreateKeyFramesSpec(Property::Type type) { mType = type; @@ -47,37 +36,37 @@ void KeyFrames::CreateKeyFramesSpec(Property::Type type) { case Property::BOOLEAN: { - mKeyFrames = Internal::KeyFrameBoolean::New(); + mKeyFrames = std::make_unique(); break; } case Property::INTEGER: { - mKeyFrames = Internal::KeyFrameInteger::New(); + mKeyFrames = std::make_unique(); break; } case Property::FLOAT: { - mKeyFrames = Internal::KeyFrameNumber::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR2: { - mKeyFrames = Internal::KeyFrameVector2::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR3: { - mKeyFrames = Internal::KeyFrameVector3::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR4: { - mKeyFrames = Internal::KeyFrameVector4::New(); + mKeyFrames = std::make_unique(); break; } case Property::ROTATION: { - mKeyFrames = Internal::KeyFrameQuaternion::New(); + mKeyFrames = std::make_unique(); break; } default: @@ -93,7 +82,7 @@ Property::Type KeyFrames::GetType() const return mType; } -void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) +void KeyFrames::Add(float time, const Property::Value& value, AlphaFunction alpha) { if(mType == Property::NONE) { @@ -103,49 +92,51 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) // Once we have created a type, can only add values of the same type DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" ); - DALI_ASSERT_DEBUG(mKeyFrames); + auto keyframes = mKeyFrames.get(); + + DALI_ASSERT_DEBUG(keyframes); switch(mType) { case Property::BOOLEAN: { - Internal::KeyFrameBoolean* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameBoolean* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::INTEGER: { - Internal::KeyFrameInteger* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameInteger* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::FLOAT: { - Internal::KeyFrameNumber* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameNumber* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR2: { - Internal::KeyFrameVector2* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector2* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR3: { - Internal::KeyFrameVector3* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector3* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR4: { - Internal::KeyFrameVector4* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector4* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::ROTATION: { - Internal::KeyFrameQuaternion* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameQuaternion* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } @@ -157,7 +148,7 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) KeyFrameSpec* KeyFrames::GetKeyFramesBase() const { - return mKeyFrames.Get(); + return mKeyFrames.get(); } Property::Value KeyFrames::GetLastKeyFrameValue() const diff --git a/dali/internal/event/animation/key-frames-impl.h b/dali/internal/event/animation/key-frames-impl.h index 78df8e8..1f21625 100644 --- a/dali/internal/event/animation/key-frames-impl.h +++ b/dali/internal/event/animation/key-frames-impl.h @@ -18,12 +18,14 @@ * */ +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include #include #include -#include #include namespace Dali @@ -32,7 +34,6 @@ namespace Internal { class KeyFrameSpec; class KeyFrames; -using KeyFramesPtr = IntrusivePtr; /** * KeyFrames class is responsible for creating and building a specialized KeyFrame class @@ -43,24 +44,7 @@ class KeyFrames : public BaseObject public: static KeyFrames* New(); - /** - * Instantiate an empty KeyFrames object - */ - KeyFrames(); - -protected: - ~KeyFrames() override; - private: - /** - * Don't allow copy constructor - */ - KeyFrames(const KeyFrames& rhs); - - /** - * Don't allow copy operator - */ - KeyFrames& operator=(const KeyFrames& rhs); /** * Create a specialization from the given type, and store it to the mSpec @@ -86,7 +70,7 @@ public: * @param[in] alpha An alpha function to blend between this key frame and the * next key frame. */ - void Add(float time, Property::Value value, AlphaFunction alpha); + void Add(float time, const Property::Value& value, AlphaFunction alpha); /** * Return the key frames without specialization. The GetSpecialization methods @@ -100,23 +84,18 @@ public: Dali::Property::Value GetLastKeyFrameValue() const; private: - Dali::Property::Type mType; // Type of the specialization - IntrusivePtr mKeyFrames; // Pointer to the specialized key frame object + Dali::Property::Type mType{Property::NONE}; // Type of the specialization + std::unique_ptr mKeyFrames; // Pointer to the specialized key frame object }; - /** * This is the base class for the individual template specializations, allowing a ptr to be - * stored in the handle object above. It inherits from RefObject to allow smart pointers - * to be used for the specializations. Note that the derived template class below - * allows for a copy constructor so that the specialization object can be cloned before - * being passed to the scene-graph for animation. + * stored in the handle object above. */ -class KeyFrameSpec : public RefObject +class KeyFrameSpec { public: - - KeyFrameSpec() {} + virtual ~KeyFrameSpec() = default; virtual std::size_t GetNumberOfKeyFrames() const = 0; @@ -126,85 +105,19 @@ public: * @param[out] value The value of the given key frame */ virtual void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) = 0; - -protected: - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - ~KeyFrameSpec() override {} }; - /** - * The base template class for each key frame specialization. It stores a vector of - * ProgressValue pairs in mPVs, and uses the existing interface for KeyFrameChannel - * to point at this vector. + * The base template class for each key frame specialization. */ template class KeyFrameBaseSpec : public KeyFrameSpec { -private: - using PV = ProgressValue; - using PVContainer = std::vector; - - PVContainer mPVs; // The ProgressValue pairs - KeyFrameChannel* mKeyFrames; // The key frame interpolator - -public: - static KeyFrameBaseSpec* New() - { - return new KeyFrameBaseSpec(); - } - - static KeyFrameBaseSpec* Clone(const KeyFrameBaseSpec& keyFrames) - { - return new KeyFrameBaseSpec(keyFrames); - } - - /** - * Constructor - */ - KeyFrameBaseSpec() - { - mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); - } - -protected: - /** - * Copy Constructor - * Allow cloning of this object - */ - KeyFrameBaseSpec(const KeyFrameBaseSpec& keyFrames) - : mPVs(keyFrames.mPVs) - { - mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); - } - - KeyFrameBaseSpec& operator=( const KeyFrameBaseSpec& keyFrames ) - { - if( this != &keyFrames ) - { - mPVs.clear(); - mPVs = keyFrames.mPVs; - delete mKeyFrames; - mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); - } - return *this; - } - - /** - * Destructor. Ensure progress value pairs are cleared down - */ - ~KeyFrameBaseSpec() override - { - delete mKeyFrames; - mPVs.clear(); - } + KeyFrameChannel mChannel; // The key frame channel public: /** - * Add a key frame to the progress value vector. Key frames should be added + * Add a key frame to the channel. Key frames should be added * in time order (this method does not sort the vector by time) * @param[in] t - progress * @param[in] v - value @@ -212,16 +125,16 @@ public: */ void AddKeyFrame(float t, V v, AlphaFunction alpha) { - mPVs.push_back(PV(t, v)); + mChannel.mValues.push_back({t, v}); } /** * Get the number of key frames - * @return The size of the progress value vector + * @return Channel size */ std::size_t GetNumberOfKeyFrames() const override { - return mPVs.size(); + return mChannel.mValues.size(); } /** @@ -230,11 +143,12 @@ public: * @param[out] time The progress of the given key frame * @param[out] value The value of the given key frame */ - virtual void GetKeyFrame(unsigned int index, float& time, V& value) const + void GetKeyFrame(unsigned int index, float& time, V& value) const { - DALI_ASSERT_ALWAYS( index < mPVs.size() && "KeyFrame index is out of bounds" ); - time = mPVs[index].mProgress; - value = mPVs[index].mValue; + DALI_ASSERT_ALWAYS(index < mChannel.mValues.size() && "KeyFrame index is out of bounds"); + const auto& element = mChannel.mValues[index]; + time = element.mProgress; + value = element.mValue; } /** @@ -242,7 +156,7 @@ public: */ void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) override { - value = mPVs[index].mValue; + value = mChannel.mValues[index].mValue; } /** @@ -253,7 +167,7 @@ public: */ bool IsActive(float progress) const { - return mKeyFrames->IsActive(progress); + return mChannel.IsActive(progress); } /** @@ -263,7 +177,7 @@ public: */ V GetValue(float progress, Dali::Animation::Interpolation interpolation) const { - return mKeyFrames->GetValue(progress, interpolation); + return mChannel.GetValue(progress, interpolation); } }; @@ -275,82 +189,10 @@ using KeyFrameVector3 = KeyFrameBaseSpec; using KeyFrameVector4 = KeyFrameBaseSpec; using KeyFrameQuaternion = KeyFrameBaseSpec; -using KeyFrameBooleanPtr = IntrusivePtr; -using KeyFrameNumberPtr = IntrusivePtr; -using KeyFrameIntegerPtr = IntrusivePtr; -using KeyFrameVector2Ptr = IntrusivePtr; -using KeyFrameVector3Ptr = IntrusivePtr; -using KeyFrameVector4Ptr = IntrusivePtr; -using KeyFrameQuaternionPtr = IntrusivePtr; - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameBoolean*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameNumber*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameNumber*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameInteger*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameInteger*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector2*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector3*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector3*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector4*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector4*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameQuaternion*& keyFrameSpec) -{ - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); -} - -inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameQuaternion*& keyFrameSpec) +template +auto GetSpecialization(const Internal::KeyFrames& keyFrames) { - keyFrameSpec = static_cast(keyFrames.GetKeyFramesBase()); + return static_cast(keyFrames.GetKeyFramesBase()); } } // Internal diff --git a/dali/internal/event/animation/linear-constrainer-impl.cpp b/dali/internal/event/animation/linear-constrainer-impl.cpp index c357e41..1b4c463 100644 --- a/dali/internal/event/animation/linear-constrainer-impl.cpp +++ b/dali/internal/event/animation/linear-constrainer-impl.cpp @@ -63,9 +63,7 @@ LinearConstrainer::LinearConstrainer() { } -LinearConstrainer::~LinearConstrainer() -{ -} +LinearConstrainer::~LinearConstrainer() = default; Property::Value LinearConstrainer::GetDefaultProperty( Property::Index index ) const { diff --git a/dali/internal/event/animation/path-constrainer-impl.cpp b/dali/internal/event/animation/path-constrainer-impl.cpp index 63eb9f7..bcae22e 100644 --- a/dali/internal/event/animation/path-constrainer-impl.cpp +++ b/dali/internal/event/animation/path-constrainer-impl.cpp @@ -64,9 +64,7 @@ PathConstrainer::PathConstrainer() { } -PathConstrainer::~PathConstrainer() -{ -} +PathConstrainer::~PathConstrainer() = default; Property::Value PathConstrainer::GetDefaultProperty( Property::Index index ) const { diff --git a/dali/internal/event/animation/path-impl.cpp b/dali/internal/event/animation/path-impl.cpp index c5455a4..c891349 100644 --- a/dali/internal/event/animation/path-impl.cpp +++ b/dali/internal/event/animation/path-impl.cpp @@ -86,9 +86,7 @@ Path::Path() { } -Path::~Path() -{ -} +Path::~Path() = default; Path* Path::Clone(const Path& path) { diff --git a/dali/internal/event/animation/progress-value.h b/dali/internal/event/animation/progress-value.h index 0a7ca11..1657bec 100644 --- a/dali/internal/event/animation/progress-value.h +++ b/dali/internal/event/animation/progress-value.h @@ -44,9 +44,7 @@ public: { } - ~ProgressValue () - { - } + ~ProgressValue() = default; float GetProgress () const { diff --git a/dali/internal/event/animation/property-input-accessor.h b/dali/internal/event/animation/property-input-accessor.h index 6cc3d80..482d1ca 100644 --- a/dali/internal/event/animation/property-input-accessor.h +++ b/dali/internal/event/animation/property-input-accessor.h @@ -53,11 +53,7 @@ public: /** * Copy from a PropertyInputAccessor */ - PropertyInputAccessor( const PropertyInputAccessor& accessor ) - : mInput( accessor.mInput ), - mComponentIndex( accessor.mComponentIndex ) - { - } + PropertyInputAccessor(const PropertyInputAccessor& accessor) = default; /** * Copy from a PropertyInputAccessor diff --git a/dali/internal/event/animation/property-input-indexer.h b/dali/internal/event/animation/property-input-indexer.h index e9088af..ed1ea0b 100644 --- a/dali/internal/event/animation/property-input-indexer.h +++ b/dali/internal/event/animation/property-input-indexer.h @@ -73,9 +73,7 @@ public: /** * Virtual Destructor */ - ~PropertyInputIndexer() override - { - } + ~PropertyInputIndexer() override = default; /** * @copydoc Dali::Internal::PropertyInput::GetType() diff --git a/dali/internal/event/common/base-object-impl.h b/dali/internal/event/common/base-object-impl.h index 5bb491f..501521d 100755 --- a/dali/internal/event/common/base-object-impl.h +++ b/dali/internal/event/common/base-object-impl.h @@ -70,7 +70,7 @@ public: /** * Virtual destructor */ - virtual ~Observer() {} + virtual ~Observer() = default; }; /** diff --git a/dali/internal/event/common/complete-notification-interface.h b/dali/internal/event/common/complete-notification-interface.h index 40ae686..d802d4f 100644 --- a/dali/internal/event/common/complete-notification-interface.h +++ b/dali/internal/event/common/complete-notification-interface.h @@ -37,14 +37,12 @@ protected: /** * Constructor, not to be directly instantiated. */ - CompleteNotificationInterface() - {} + CompleteNotificationInterface() = default; /** * Virtual destructor as this is an interface, no deletion through this interface though. */ - virtual ~CompleteNotificationInterface() - {} + virtual ~CompleteNotificationInterface() = default; public: diff --git a/dali/internal/event/common/connectable.h b/dali/internal/event/common/connectable.h index 8c2d1e7..cb087fe 100644 --- a/dali/internal/event/common/connectable.h +++ b/dali/internal/event/common/connectable.h @@ -35,7 +35,7 @@ public: /** * @brief Destructor */ - virtual ~Connectable() {} + virtual ~Connectable() = default; /** * @brief Check if the object is on the scene diff --git a/dali/internal/event/common/event-thread-services.h b/dali/internal/event/common/event-thread-services.h index 68e52e6..7e75e29 100644 --- a/dali/internal/event/common/event-thread-services.h +++ b/dali/internal/event/common/event-thread-services.h @@ -54,8 +54,7 @@ public: /** * Virtual destructor */ - virtual ~EventThreadServices() - { } + virtual ~EventThreadServices() = default; /** * Get the EventThreadServices diff --git a/dali/internal/event/common/notification-manager.cpp b/dali/internal/event/common/notification-manager.cpp index 9dc08ba..f80b6e2 100644 --- a/dali/internal/event/common/notification-manager.cpp +++ b/dali/internal/event/common/notification-manager.cpp @@ -86,9 +86,7 @@ struct NotificationManager::Impl eventInterfaceQueue.Reserve( 4 ); } - ~Impl() - { - } + ~Impl() = default; // queueMutex must be locked whilst accessing queue MessageQueueMutex queueMutex; diff --git a/dali/internal/event/common/object-connector.h b/dali/internal/event/common/object-connector.h index 22319b8..40fa975 100644 --- a/dali/internal/event/common/object-connector.h +++ b/dali/internal/event/common/object-connector.h @@ -41,12 +41,12 @@ public: /** * @brief Default constructor. */ - ObjectConnector() {} + ObjectConnector() = default; /** * @brief Destructor. */ - ~ObjectConnector() {} + ~ObjectConnector() = default; /** * @brief Copy constructor diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 64d9c8c..fffe3ee 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -109,7 +109,7 @@ public: /** * Virtual destructor */ - virtual ~Observer(){} + virtual ~Observer() = default; }; /** diff --git a/dali/internal/event/common/object-registry-impl.cpp b/dali/internal/event/common/object-registry-impl.cpp index 8ef38e1..a12f485 100644 --- a/dali/internal/event/common/object-registry-impl.cpp +++ b/dali/internal/event/common/object-registry-impl.cpp @@ -53,13 +53,9 @@ ObjectRegistryPtr ObjectRegistry::New() return ObjectRegistryPtr( new ObjectRegistry() ); } -ObjectRegistry::ObjectRegistry() -{ -} +ObjectRegistry::ObjectRegistry() = default; -ObjectRegistry::~ObjectRegistry() -{ -} +ObjectRegistry::~ObjectRegistry() = default; void ObjectRegistry::RegisterObject( Dali::BaseObject* object ) { diff --git a/dali/internal/event/common/property-conditions-impl.cpp b/dali/internal/event/common/property-conditions-impl.cpp index 06557ae..f1a502f 100644 --- a/dali/internal/event/common/property-conditions-impl.cpp +++ b/dali/internal/event/common/property-conditions-impl.cpp @@ -30,10 +30,7 @@ PropertyCondition::PropertyCondition() } -PropertyCondition::~PropertyCondition() -{ - -} +PropertyCondition::~PropertyCondition() = default; } // namespace Internal diff --git a/dali/internal/event/common/property-input-impl.h b/dali/internal/event/common/property-input-impl.h index e1e307d..996fde7 100644 --- a/dali/internal/event/common/property-input-impl.h +++ b/dali/internal/event/common/property-input-impl.h @@ -57,9 +57,7 @@ public: /** * Virtual destructor. */ - virtual ~PropertyInputImpl() - { - } + virtual ~PropertyInputImpl() = default; /** * Query the type of property input. diff --git a/dali/internal/event/common/property-metadata.h b/dali/internal/event/common/property-metadata.h index a363ea1..3dbf675 100644 --- a/dali/internal/event/common/property-metadata.h +++ b/dali/internal/event/common/property-metadata.h @@ -61,9 +61,7 @@ public: /** * @brief Virtual Destructor. */ - virtual ~PropertyMetadata() - { - } + virtual ~PropertyMetadata() = default; /** * @brief Returns whether the property is animatable (i.e. if its a scene graph property). @@ -233,9 +231,7 @@ public: /** * @brief Destructor. */ - ~AnimatablePropertyMetadata() override - { - } + ~AnimatablePropertyMetadata() override = default; private: @@ -296,9 +292,7 @@ public: /** * @brief Destructor. */ - ~CustomPropertyMetadata() override - { - } + ~CustomPropertyMetadata() override = default; private: diff --git a/dali/internal/event/common/property-notification-manager.cpp b/dali/internal/event/common/property-notification-manager.cpp index 45cec79..b879923 100644 --- a/dali/internal/event/common/property-notification-manager.cpp +++ b/dali/internal/event/common/property-notification-manager.cpp @@ -33,9 +33,7 @@ PropertyNotificationManager* PropertyNotificationManager::New() return new PropertyNotificationManager; } -PropertyNotificationManager::~PropertyNotificationManager() -{ -} +PropertyNotificationManager::~PropertyNotificationManager() = default; void PropertyNotificationManager::PropertyNotificationCreated( PropertyNotification& propertyNotification ) { @@ -70,9 +68,7 @@ void PropertyNotificationManager::NotifyProperty( SceneGraph::PropertyNotificati } } -PropertyNotificationManager::PropertyNotificationManager() -{ -} +PropertyNotificationManager::PropertyNotificationManager() = default; } // namespace Internal diff --git a/dali/internal/event/common/property-notifier.h b/dali/internal/event/common/property-notifier.h index 6fd0ea5..3899719 100644 --- a/dali/internal/event/common/property-notifier.h +++ b/dali/internal/event/common/property-notifier.h @@ -44,9 +44,7 @@ public: /** * Virtual destructor. */ - virtual ~PropertyNotifier() - { - } + virtual ~PropertyNotifier() = default; /** * Provide notification signals for a changed property. diff --git a/dali/internal/event/common/stage-impl.cpp b/dali/internal/event/common/stage-impl.cpp index beae510..804008f 100644 --- a/dali/internal/event/common/stage-impl.cpp +++ b/dali/internal/event/common/stage-impl.cpp @@ -62,25 +62,25 @@ namespace // Signals -const char* const SIGNAL_KEY_EVENT = "keyEvent"; -const char* const SIGNAL_KEY_EVENT_GENERATED = "keyEventGenerated"; -const char* const SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished"; -const char* const SIGNAL_TOUCHED = "touched"; -const char* const SIGNAL_WHEEL_EVENT = "wheelEvent"; -const char* const SIGNAL_CONTEXT_LOST = "contextLost"; -const char* const SIGNAL_CONTEXT_REGAINED = "contextRegained"; -const char* const SIGNAL_SCENE_CREATED = "sceneCreated"; +static constexpr std::string_view SIGNAL_KEY_EVENT = "keyEvent"; +static constexpr std::string_view SIGNAL_KEY_EVENT_GENERATED = "keyEventGenerated"; +static constexpr std::string_view SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished"; +static constexpr std::string_view SIGNAL_TOUCHED = "touched"; +static constexpr std::string_view SIGNAL_WHEEL_EVENT = "wheelEvent"; +static constexpr std::string_view SIGNAL_CONTEXT_LOST = "contextLost"; +static constexpr std::string_view SIGNAL_CONTEXT_REGAINED = "contextRegained"; +static constexpr std::string_view SIGNAL_SCENE_CREATED = "sceneCreated"; TypeRegistration mType( typeid(Dali::Stage), typeid(Dali::BaseHandle), nullptr ); -SignalConnectorType signalConnector1( mType, SIGNAL_KEY_EVENT, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector2( mType, SIGNAL_EVENT_PROCESSING_FINISHED, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector4( mType, SIGNAL_WHEEL_EVENT, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector5( mType, SIGNAL_CONTEXT_LOST, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector6( mType, SIGNAL_CONTEXT_REGAINED, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector7( mType, SIGNAL_SCENE_CREATED, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector8( mType, SIGNAL_KEY_EVENT_GENERATED, &Stage::DoConnectSignal ); -SignalConnectorType signalConnector9( mType, SIGNAL_TOUCHED, &Stage::DoConnectSignal ); +SignalConnectorType signalConnector1(mType, std::string(SIGNAL_KEY_EVENT), &Stage::DoConnectSignal); +SignalConnectorType signalConnector2(mType, std::string(SIGNAL_EVENT_PROCESSING_FINISHED), &Stage::DoConnectSignal); +SignalConnectorType signalConnector4(mType, std::string(SIGNAL_WHEEL_EVENT), &Stage::DoConnectSignal); +SignalConnectorType signalConnector5(mType, std::string(SIGNAL_CONTEXT_LOST), &Stage::DoConnectSignal); +SignalConnectorType signalConnector6(mType, std::string(SIGNAL_CONTEXT_REGAINED), &Stage::DoConnectSignal); +SignalConnectorType signalConnector7(mType, std::string(SIGNAL_SCENE_CREATED), &Stage::DoConnectSignal); +SignalConnectorType signalConnector8(mType, std::string(SIGNAL_KEY_EVENT_GENERATED), &Stage::DoConnectSignal); +SignalConnectorType signalConnector9(mType, std::string(SIGNAL_TOUCHED), &Stage::DoConnectSignal); } // unnamed namespace @@ -218,36 +218,37 @@ bool Stage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra { bool connected( true ); Stage* stage = static_cast< Stage* >(object); // TypeRegistry guarantees that this is the correct type. + std::string_view name(signalName); - if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) ) + if(name == SIGNAL_KEY_EVENT) { stage->KeyEventSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT_GENERATED ) ) + else if(name == SIGNAL_KEY_EVENT_GENERATED) { stage->KeyEventGeneratedSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_EVENT_PROCESSING_FINISHED ) ) + else if(name == SIGNAL_EVENT_PROCESSING_FINISHED) { stage->EventProcessingFinishedSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCHED ) ) + else if(name == SIGNAL_TOUCHED) { stage->TouchedSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_WHEEL_EVENT ) ) + else if(name == SIGNAL_WHEEL_EVENT) { stage->WheelEventSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_LOST ) ) + else if(name == SIGNAL_CONTEXT_LOST) { stage->ContextLostSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_REGAINED ) ) + else if(name == SIGNAL_CONTEXT_REGAINED) { stage->ContextRegainedSignal().Connect( tracker, functor ); } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_SCENE_CREATED ) ) + else if(name == SIGNAL_SCENE_CREATED) { stage->SceneCreatedSignal().Connect( tracker, functor ); } @@ -400,9 +401,7 @@ Stage::Stage( SceneGraph::UpdateManager& updateManager ) { } -Stage::~Stage() -{ -} +Stage::~Stage() = default; } // namespace Internal diff --git a/dali/internal/event/common/thread-local-storage.cpp b/dali/internal/event/common/thread-local-storage.cpp index 2424d41..0628fbe 100644 --- a/dali/internal/event/common/thread-local-storage.cpp +++ b/dali/internal/event/common/thread-local-storage.cpp @@ -59,9 +59,7 @@ ThreadLocalStorage::ThreadLocalStorage(Core* core) threadLocal = this; } -ThreadLocalStorage::~ThreadLocalStorage() -{ -} +ThreadLocalStorage::~ThreadLocalStorage() = default; void ThreadLocalStorage::Remove() { @@ -151,6 +149,26 @@ AnimationPlaylist& ThreadLocalStorage::GetAnimationPlaylist() return mCore->GetAnimationPlaylist(); } +bool ThreadLocalStorage::IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ) +{ + return mCore->GetGlAbstraction().IsBlendEquationSupported( blendEquation ); +} + +std::string ThreadLocalStorage::GetShaderVersionPrefix() +{ + return mCore->GetGlAbstraction().GetShaderVersionPrefix(); +} + +std::string ThreadLocalStorage::GetVertexShaderPrefix() +{ + return mCore->GetGlAbstraction().GetVertexShaderPrefix(); +} + +std::string ThreadLocalStorage::GetFragmentShaderPrefix() +{ + return mCore->GetGlAbstraction().GetFragmentShaderPrefix(); +} + void ThreadLocalStorage::AddScene( Scene* scene ) { mCore->AddScene( scene ); diff --git a/dali/internal/event/common/thread-local-storage.h b/dali/internal/event/common/thread-local-storage.h index f994a12..052b438 100644 --- a/dali/internal/event/common/thread-local-storage.h +++ b/dali/internal/event/common/thread-local-storage.h @@ -163,6 +163,28 @@ public: AnimationPlaylist& GetAnimationPlaylist(); /** + * @brief Returns whether the blend equation is supported in the system or not. + * @param[in] blendEquation blend equation to be checked. + * @return True if the blend equation supported. + */ + bool IsBlendEquationSupported( DevelBlendEquation::Type blendEquation ); + + /** + * @brief Returns shader prefix of shading language version. + */ + std::string GetShaderVersionPrefix(); + + /** + * @brief Returns vertex shader prefix including shading language version. + */ + std::string GetVertexShaderPrefix(); + + /** + * @brief Returns fragment shader prefix including shading language version and extension information. + */ + std::string GetFragmentShaderPrefix(); + + /** * Add a Scene to the Core. * This is only used by the Scene to add itself to the core when the Scene is created. * @param[in] scene The Scene. diff --git a/dali/internal/event/common/type-info-impl.cpp b/dali/internal/event/common/type-info-impl.cpp index 81155ef..7230c36 100644 --- a/dali/internal/event/common/type-info-impl.cpp +++ b/dali/internal/event/common/type-info-impl.cpp @@ -176,9 +176,7 @@ TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dal DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name"); } -TypeInfo::~TypeInfo() -{ -} +TypeInfo::~TypeInfo() = default; BaseHandle TypeInfo::CreateInstance() const { diff --git a/dali/internal/event/common/type-registry-impl.cpp b/dali/internal/event/common/type-registry-impl.cpp index 9c79314..de44e8e 100644 --- a/dali/internal/event/common/type-registry-impl.cpp +++ b/dali/internal/event/common/type-registry-impl.cpp @@ -49,10 +49,7 @@ TypeRegistry *TypeRegistry::Get() return _reg; } -TypeRegistry::TypeRegistry() -{ - -} +TypeRegistry::TypeRegistry() = default; TypeRegistry::~TypeRegistry() { diff --git a/dali/internal/event/effects/shader-factory.cpp b/dali/internal/event/effects/shader-factory.cpp index 59832f9..c91f2ed 100644 --- a/dali/internal/event/effects/shader-factory.cpp +++ b/dali/internal/event/effects/shader-factory.cpp @@ -60,9 +60,7 @@ void shaderBinaryFilename( size_t shaderHash, std::string& filename ) } -ShaderFactory::ShaderFactory() -{ -} +ShaderFactory::ShaderFactory() = default; ShaderFactory::~ShaderFactory() { diff --git a/dali/internal/event/events/gesture-event-processor.cpp b/dali/internal/event/events/gesture-event-processor.cpp index 5c9be29..d25d90b 100644 --- a/dali/internal/event/events/gesture-event-processor.cpp +++ b/dali/internal/event/events/gesture-event-processor.cpp @@ -48,9 +48,7 @@ GestureEventProcessor::GestureEventProcessor( SceneGraph::UpdateManager& updateM { } -GestureEventProcessor::~GestureEventProcessor() -{ -} +GestureEventProcessor::~GestureEventProcessor() = default; void GestureEventProcessor::ProcessTouchEvent( Scene& scene, const Integration::TouchEvent& event) { diff --git a/dali/internal/event/events/gesture-event.cpp b/dali/internal/event/events/gesture-event.cpp index 9591ac3..680fa6d 100644 --- a/dali/internal/event/events/gesture-event.cpp +++ b/dali/internal/event/events/gesture-event.cpp @@ -23,10 +23,7 @@ namespace Dali namespace Internal { - -GestureEvent::~GestureEvent() -{ -} +GestureEvent::~GestureEvent() = default; GestureEvent::GestureEvent( GestureType::Value gesture, GestureState gestureState ) : gestureType( gesture ), diff --git a/dali/internal/event/events/gesture-recognizer.h b/dali/internal/event/events/gesture-recognizer.h index f53e573..bef97a7 100644 --- a/dali/internal/event/events/gesture-recognizer.h +++ b/dali/internal/event/events/gesture-recognizer.h @@ -44,7 +44,8 @@ class RecognizerObserver public: virtual void Process( Scene& scene, const T& event ) = 0; - virtual ~RecognizerObserver(){}; + virtual ~RecognizerObserver() = default; + ; }; @@ -116,7 +117,7 @@ protected: /** * Virtual destructor. */ - ~GestureRecognizer() override {} + ~GestureRecognizer() override = default; protected: Vector2 mScreenSize; diff --git a/dali/internal/event/events/gesture-requests.h b/dali/internal/event/events/gesture-requests.h index be7ab70..aad5e37 100644 --- a/dali/internal/event/events/gesture-requests.h +++ b/dali/internal/event/events/gesture-requests.h @@ -73,9 +73,7 @@ struct PanGestureRequest : public GestureRequest /** * Virtual destructor */ - ~PanGestureRequest() override - { - } + ~PanGestureRequest() override = default; // Data Members @@ -105,9 +103,7 @@ struct TapGestureRequest : public GestureRequest /** * Virtual destructor */ - ~TapGestureRequest() override - { - } + ~TapGestureRequest() override = default; // Data Members @@ -137,9 +133,7 @@ struct LongPressGestureRequest : public GestureRequest /** * Virtual destructor */ - ~LongPressGestureRequest() override - { - } + ~LongPressGestureRequest() override = default; // Data Members diff --git a/dali/internal/event/events/hit-test-algorithm-impl.cpp b/dali/internal/event/events/hit-test-algorithm-impl.cpp index 587df4d..25d6a42 100644 --- a/dali/internal/event/events/hit-test-algorithm-impl.cpp +++ b/dali/internal/event/events/hit-test-algorithm-impl.cpp @@ -603,9 +603,7 @@ bool HitTestForEachRenderTask( const Vector2& sceneSize, } // unnamed namespace -HitTestInterface::~HitTestInterface() -{ -} +HitTestInterface::~HitTestInterface() = default; bool HitTest( const Vector2& sceneSize, RenderTaskList& taskList, LayerList& layerList, const Vector2& screenCoordinates, Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func ) { diff --git a/dali/internal/event/events/key-event-processor.cpp b/dali/internal/event/events/key-event-processor.cpp old mode 100755 new mode 100644 index e72adc3..1bb2f1a --- a/dali/internal/event/events/key-event-processor.cpp +++ b/dali/internal/event/events/key-event-processor.cpp @@ -35,9 +35,7 @@ KeyEventProcessor::KeyEventProcessor( Scene& scene ) { } -KeyEventProcessor::~KeyEventProcessor() -{ -} +KeyEventProcessor::~KeyEventProcessor() = default; void KeyEventProcessor::ProcessKeyEvent( const Integration::KeyEvent& event ) { diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp index 3c832a5..75b07de 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-detector-impl.cpp @@ -85,9 +85,7 @@ LongPressGestureDetector::LongPressGestureDetector(unsigned int minTouches, unsi { } -LongPressGestureDetector::~LongPressGestureDetector() -{ -} +LongPressGestureDetector::~LongPressGestureDetector() = default; void LongPressGestureDetector::SetTouchesRequired(unsigned int touches) { diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp index 1dae742..3ff0618 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-event.cpp @@ -30,9 +30,7 @@ LongPressGestureEvent::LongPressGestureEvent( GestureState state ) { } -LongPressGestureEvent::~LongPressGestureEvent() -{ -} +LongPressGestureEvent::~LongPressGestureEvent() = default; } // namespace Internal diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp index 1090aab..224e74f 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp @@ -113,9 +113,7 @@ LongPressGestureProcessor::LongPressGestureProcessor() { } -LongPressGestureProcessor::~LongPressGestureProcessor() -{ -} +LongPressGestureProcessor::~LongPressGestureProcessor() = default; void LongPressGestureProcessor::Process( Scene& scene, const LongPressGestureEvent& longPressEvent ) { diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp index bc1e201..efdaf04 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-detector-impl.cpp @@ -302,9 +302,7 @@ PanGestureDetector::PanGestureDetector( const SceneGraph::PanGesture& sceneObjec { } -PanGestureDetector::~PanGestureDetector() -{ -} +PanGestureDetector::~PanGestureDetector() = default; const SceneGraph::PanGesture& PanGestureDetector::GetPanGestureSceneObject() const { diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp index fa17b11..d67d463 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-event.cpp @@ -32,9 +32,7 @@ PanGestureEvent::PanGestureEvent(GestureState state) { } -PanGestureEvent::~PanGestureEvent() -{ -} +PanGestureEvent::~PanGestureEvent() = default; } // namespace Internal diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp index 5b61546..aa20b73 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp @@ -73,9 +73,7 @@ PanGestureRecognizer::PanGestureRecognizer( Observer& observer, Vector2 screenSi } } -PanGestureRecognizer::~PanGestureRecognizer() -{ -} +PanGestureRecognizer::~PanGestureRecognizer() = default; void PanGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp index 6584d2d..2f62e91 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-detector-impl.cpp @@ -62,9 +62,7 @@ PinchGestureDetector::PinchGestureDetector() { } -PinchGestureDetector::~PinchGestureDetector() -{ -} +PinchGestureDetector::~PinchGestureDetector() = default; void PinchGestureDetector::EmitPinchGestureSignal(Dali::Actor actor, const Dali::PinchGesture& pinch) { diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp index fa9841b..f65150d 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-event.cpp @@ -35,9 +35,7 @@ PinchGestureEvent::PinchGestureEvent(GestureState state) { } -PinchGestureEvent::~PinchGestureEvent() -{ -} +PinchGestureEvent::~PinchGestureEvent() = default; } // namespace Internal diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp index 88172af..210cbf0 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-processor.cpp @@ -115,9 +115,7 @@ PinchGestureProcessor::PinchGestureProcessor() { } -PinchGestureProcessor::~PinchGestureProcessor() -{ -} +PinchGestureProcessor::~PinchGestureProcessor() = default; void PinchGestureProcessor::SetMinimumPinchDistance( float value ) { diff --git a/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp b/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp index 134dee4..9108a11 100644 --- a/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp +++ b/dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp @@ -78,9 +78,7 @@ PinchGestureRecognizer::PinchGestureRecognizer( Observer& observer, Vector2 scre SetMinimumPinchDistance( minimumPinchDistance ); } -PinchGestureRecognizer::~PinchGestureRecognizer() -{ -} +PinchGestureRecognizer::~PinchGestureRecognizer() = default; void PinchGestureRecognizer::SetMinimumPinchDistance(float value) { diff --git a/dali/internal/event/events/ray-test.cpp b/dali/internal/event/events/ray-test.cpp old mode 100644 new mode 100755 index cee959d..69a947a --- a/dali/internal/event/events/ray-test.cpp +++ b/dali/internal/event/events/ray-test.cpp @@ -156,7 +156,7 @@ bool RayTest::ActorTest(const Internal::Actor& actor, const Vector4& rayOrigin, // Ray travels distance * rayDirLocal to intersect with plane. distance = a / b; - const Vector3& size = node.GetSize(EventThreadServices::Get().GetEventBufferIndex()); + const Vector2& size = actor.GetTouchArea() == Vector2::ZERO ? Vector2(node.GetSize(EventThreadServices::Get().GetEventBufferIndex())) : actor.GetTouchArea(); hitPointLocal.x = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f; hitPointLocal.y = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f; diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp index bdca9c6..a3f13c4 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-detector-impl.cpp @@ -79,9 +79,7 @@ TapGestureDetector::TapGestureDetector( unsigned int tapsRequired ) { } -TapGestureDetector::~TapGestureDetector() -{ -} +TapGestureDetector::~TapGestureDetector() = default; void TapGestureDetector::SetMinimumTapsRequired(unsigned int taps) { diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp index 405a906..cbc3e0a 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-event.cpp @@ -31,9 +31,7 @@ TapGestureEvent::TapGestureEvent( GestureState state ) { } -TapGestureEvent::~TapGestureEvent() -{ -} +TapGestureEvent::~TapGestureEvent() = default; } // namespace Internal diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp index e710f75..7b3fce6 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-processor.cpp @@ -86,9 +86,7 @@ TapGestureProcessor::TapGestureProcessor() { } -TapGestureProcessor::~TapGestureProcessor() -{ -} +TapGestureProcessor::~TapGestureProcessor() = default; void TapGestureProcessor::Process( Scene& scene, const TapGestureEvent& tapEvent ) { diff --git a/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp b/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp index 5daa963..15b6e7e 100644 --- a/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp +++ b/dali/internal/event/events/tap-gesture/tap-gesture-recognizer.cpp @@ -55,9 +55,7 @@ TapGestureRecognizer::TapGestureRecognizer( Observer& observer, Vector2 screenSi { } -TapGestureRecognizer::~TapGestureRecognizer() -{ -} +TapGestureRecognizer::~TapGestureRecognizer() = default; void TapGestureRecognizer::SendEvent(const Integration::TouchEvent& event) { diff --git a/dali/internal/event/events/wheel-event-processor.cpp b/dali/internal/event/events/wheel-event-processor.cpp index a5c93e8..216102c 100644 --- a/dali/internal/event/events/wheel-event-processor.cpp +++ b/dali/internal/event/events/wheel-event-processor.cpp @@ -128,9 +128,7 @@ WheelEventProcessor::WheelEventProcessor( Scene& scene ) { } -WheelEventProcessor::~WheelEventProcessor() -{ -} +WheelEventProcessor::~WheelEventProcessor() = default; void WheelEventProcessor::ProcessWheelEvent( const Integration::WheelEvent& event ) { diff --git a/dali/internal/event/render-tasks/render-task-defaults.h b/dali/internal/event/render-tasks/render-task-defaults.h index 8163f92..5d0d419 100644 --- a/dali/internal/event/render-tasks/render-task-defaults.h +++ b/dali/internal/event/render-tasks/render-task-defaults.h @@ -51,7 +51,7 @@ protected: /** * Virtual destructor */ - virtual ~RenderTaskDefaults(){} + virtual ~RenderTaskDefaults() = default; }; } // namespace Internal diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index ef47828..838e047 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -65,6 +65,7 @@ DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS ) DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelRenderer::Property::OPACITY ) DALI_PROPERTY( "renderingBehavior", INTEGER, true, false, false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR ) +DALI_PROPERTY( "blendEquation", INTEGER, true, false, false, Dali::DevelRenderer::Property::BLEND_EQUATION ) DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties ) // Property string to enumeration tables: @@ -86,6 +87,23 @@ DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_EQUATION ) DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, ADD ) DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, SUBTRACT ) DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, REVERSE_SUBTRACT ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MIN ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MAX ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, MULTIPLY ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SCREEN ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, OVERLAY ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, DARKEN ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, LIGHTEN ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR_DODGE ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR_BURN ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, HARD_LIGHT ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SOFT_LIGHT ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, DIFFERENCE ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, EXCLUSION ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, HUE ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, SATURATION ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, COLOR ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelBlendEquation, LUMINOSITY ) DALI_ENUM_TO_STRING_TABLE_END( BLEND_EQUATION ) DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_FACTOR ) @@ -281,21 +299,26 @@ void Renderer::GetBlendFunc( BlendFactor::Type& srcFactorRgb, destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha(); } -void Renderer::SetBlendEquation( BlendEquation::Type equationRgba ) +void Renderer::SetBlendEquation( DevelBlendEquation::Type equationRgba ) { mBlendingOptions.SetBlendEquation( equationRgba, equationRgba ); SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() ); } -void Renderer::SetBlendEquation( BlendEquation::Type equationRgb, - BlendEquation::Type equationAlpha ) +void Renderer::SetBlendEquation( DevelBlendEquation::Type equationRgb, + DevelBlendEquation::Type equationAlpha ) { + if( mBlendingOptions.IsAdvancedBlendEquation( equationRgb ) || mBlendingOptions.IsAdvancedBlendEquation( equationAlpha ) ) + { + DALI_LOG_ERROR("Advanced blend equation requires to be set by using SetBlendEquation( DevelBlendEquation::Type equationRgba )."); + return; + } mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha ); SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() ); } -void Renderer::GetBlendEquation( BlendEquation::Type& equationRgb, - BlendEquation::Type& equationAlpha ) const +void Renderer::GetBlendEquation( DevelBlendEquation::Type& equationRgb, + DevelBlendEquation::Type& equationAlpha ) const { // These are not animatable, the cached values are up-to-date. equationRgb = mBlendingOptions.GetBlendEquationRgb(); @@ -343,6 +366,19 @@ bool Renderer::IsPreMultipliedAlphaEnabled() const return mPremultipledAlphaEnabled; } +bool Renderer::IsAdvancedBlendEquationApplied() const +{ + DevelBlendEquation::Type equationRgb, equationAlpha; + GetBlendEquation( equationRgb, equationAlpha ); + + if( equationRgb != equationAlpha ) + { + return false; + } + + return mBlendingOptions.IsAdvancedBlendEquation( equationRgb ); +} + const SceneGraph::Renderer& Renderer::GetRendererSceneObject() const { return static_cast( GetSceneObject() ); @@ -377,13 +413,29 @@ void Renderer::SetDefaultProperty( Property::Index index, } break; } + case Dali::DevelRenderer::Property::BLEND_EQUATION: + { + DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb(); + + if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) ) + { + mBlendingOptions.SetBlendEquation( convertedValue, convertedValue ); + SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() ); + } + break; + } case Dali::Renderer::Property::BLEND_EQUATION_RGB: { - BlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb(); + DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb(); - if( Scripting::GetEnumerationProperty< BlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) ) + if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) ) { - BlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha(); + if( mBlendingOptions.IsAdvancedBlendEquation( convertedValue ) ) + { + DALI_LOG_ERROR("Advanced blend equation requires to be set by using DevelBlendEquation::BLEND_EQUATION."); + break; + } + DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha(); mBlendingOptions.SetBlendEquation( convertedValue, alphaEquation ); SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() ); } @@ -391,11 +443,16 @@ void Renderer::SetDefaultProperty( Property::Index index, } case Dali::Renderer::Property::BLEND_EQUATION_ALPHA: { - BlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationAlpha(); + DevelBlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationAlpha(); - if( Scripting::GetEnumerationProperty< BlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) ) + if( Scripting::GetEnumerationProperty< DevelBlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) ) { - BlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb(); + if( mBlendingOptions.IsAdvancedBlendEquation( convertedValue ) ) + { + DALI_LOG_ERROR("Advanced blend equation requires to be set by using DevelBlendEquation::BLEND_EQUATION."); + break; + } + DevelBlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb(); mBlendingOptions.SetBlendEquation( rgbEquation, convertedValue ); SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() ); } @@ -775,6 +832,11 @@ bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& v value = mBlendMode; break; } + case Dali::DevelRenderer::Property::BLEND_EQUATION: + { + value = static_cast( mBlendingOptions.GetBlendEquationRgb() ); + break; + } case Dali::Renderer::Property::BLEND_EQUATION_RGB: { value = static_cast( mBlendingOptions.GetBlendEquationRgb() ); @@ -943,6 +1005,14 @@ bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& value = sceneObject.GetBlendMode(); break; } + case Dali::DevelRenderer::Property::BLEND_EQUATION: + { + uint32_t bitMask = sceneObject.GetBlendingOptions(); + BlendingOptions blendingOptions; + blendingOptions.SetBitmask( bitMask ); + value = static_cast( blendingOptions.GetBlendEquationRgb() ); + break; + } case Dali::Renderer::Property::BLEND_EQUATION_RGB: { uint32_t bitMask = sceneObject.GetBlendingOptions(); diff --git a/dali/internal/event/rendering/renderer-impl.h b/dali/internal/event/rendering/renderer-impl.h index 2ec0e5c..6849bf3 100755 --- a/dali/internal/event/rendering/renderer-impl.h +++ b/dali/internal/event/rendering/renderer-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_RENDERER_H /* - * 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. @@ -123,19 +123,19 @@ public: BlendFactor::Type& srcFactorAlpha, BlendFactor::Type& destFactorAlpha ) const; /** - * @copydoc Dali::Renderer::SetBlendEquation() + * @brief Set same Blend Equation for the RGB and alpha */ - void SetBlendEquation( BlendEquation::Type equationRgba ); + void SetBlendEquation( DevelBlendEquation::Type equationRgba ); /** - * @copydoc Dali::Renderer::SetBlendEquation() + * @brief Set Blend Equation separately for the RGB and alpha */ - void SetBlendEquation( BlendEquation::Type equationRgb, BlendEquation::Type equationAlpha ); + void SetBlendEquation( DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha ); /** - * @copydoc Dali::Renderer::GetBlendEquation() + * @brief Get Blend Equation of rgb and alpha */ - void GetBlendEquation( BlendEquation::Type& equationRgb, BlendEquation::Type& equationAlpha ) const; + void GetBlendEquation( DevelBlendEquation::Type& equationRgb, DevelBlendEquation::Type& equationAlpha ) const; /** * @copydoc Dali::Renderer::SetIndexedDrawFirstElement @@ -162,6 +162,13 @@ public: bool IsPreMultipliedAlphaEnabled() const; /** + * @brief Query whether Blend Equation Advanced is used in this renderer + * + * @return True is Blend Equation Advanced is used, false otherwise. + */ + bool IsAdvancedBlendEquationApplied() const; + + /** * @brief Get the scene graph object * * @return the scene object diff --git a/dali/internal/event/rendering/shader-impl.cpp b/dali/internal/event/rendering/shader-impl.cpp index 3c3dcf9..aa85ac7 100644 --- a/dali/internal/event/rendering/shader-impl.cpp +++ b/dali/internal/event/rendering/shader-impl.cpp @@ -223,6 +223,23 @@ Shader::~Shader() } } +std::string Shader::GetShaderVersionPrefix() +{ + Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); + return tls.GetShaderVersionPrefix(); +} + +std::string Shader::GetVertexShaderPrefix() +{ + Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); + return tls.GetVertexShaderPrefix(); +} + +std::string Shader::GetFragmentShaderPrefix() +{ + Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); + return tls.GetFragmentShaderPrefix(); +} } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/rendering/shader-impl.h b/dali/internal/event/rendering/shader-impl.h index 565e6e4..9476f40 100644 --- a/dali/internal/event/rendering/shader-impl.h +++ b/dali/internal/event/rendering/shader-impl.h @@ -106,6 +106,23 @@ private: Internal::ShaderDataPtr mShaderData; +public: + + /** + * @copydoc Dali::Shader::GetShaderVersionPrefix() + */ + static std::string GetShaderVersionPrefix(); + + /** + * @copydoc Dali::Shader::GetVertexShaderPrefix() + */ + static std::string GetVertexShaderPrefix(); + + /** + * @copydoc Dali::Shader::GetFragmentShaderPrefix() + */ + static std::string GetFragmentShaderPrefix(); + }; } // namespace Internal diff --git a/dali/internal/event/rendering/texture-impl.cpp b/dali/internal/event/rendering/texture-impl.cpp index 54d611f..ccf284b 100644 --- a/dali/internal/event/rendering/texture-impl.cpp +++ b/dali/internal/event/rendering/texture-impl.cpp @@ -217,11 +217,20 @@ bool Texture::ApplyNativeFragmentShader(std::string& shader) const char* fragmentPrefix = mNativeImage->GetCustomFragmentPrefix(); const char* customSamplerTypename = mNativeImage->GetCustomSamplerTypename(); + size_t prefixIndex = shader.find(Dali::Shader::GetShaderVersionPrefix()); if(fragmentPrefix != nullptr) { modified = true; - fragmentShader = fragmentPrefix; - fragmentShader += "\n"; + if(prefixIndex == std::string::npos) + { + fragmentShader = fragmentPrefix; + fragmentShader += "\n"; + } + else + { + fragmentShader.clear(); + shader.insert(prefixIndex + Dali::Shader::GetShaderVersionPrefix().length(), std::string(fragmentPrefix) + "\n"); + } } fragmentShader += shader; diff --git a/dali/internal/event/size-negotiation/memory-pool-relayout-container.cpp b/dali/internal/event/size-negotiation/memory-pool-relayout-container.cpp index e71af13..97df7e8 100644 --- a/dali/internal/event/size-negotiation/memory-pool-relayout-container.cpp +++ b/dali/internal/event/size-negotiation/memory-pool-relayout-container.cpp @@ -29,9 +29,7 @@ MemoryPoolRelayoutContainer::MemoryPoolRelayoutContainer( MemoryPoolObjectAlloca { } -MemoryPoolRelayoutContainer::~MemoryPoolRelayoutContainer() -{ -} +MemoryPoolRelayoutContainer::~MemoryPoolRelayoutContainer() = default; bool MemoryPoolRelayoutContainer::Contains( const Dali::Actor& actor ) { diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp index 33a5245..5f81a1a 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp @@ -183,10 +183,8 @@ void RelayoutController::RequestRelayout( Dali::Actor& actor, Dimension::Type di } // Remove any redundant sub-tree heads - for( std::vector< Dali::Actor >::iterator it = potentialRedundantSubRoots.begin(), itEnd = potentialRedundantSubRoots.end(); it != itEnd; ++it ) + for( auto& subRoot : potentialRedundantSubRoots ) { - Dali::Actor subRoot = *it; - RemoveRequest( subRoot ); } @@ -366,17 +364,9 @@ void RelayoutController::AddRequest( Dali::Actor& actor ) Internal::Actor* actorPtr = &GetImplementation( actor ); // Only add the rootActor if it is not already recorded - bool found = false; - for( auto&& item : mDirtyLayoutSubTrees ) - { - if( item == actorPtr ) - { - found = true; - break; - } - } + auto itr = std::find( mDirtyLayoutSubTrees.begin(), mDirtyLayoutSubTrees.end(), actorPtr ); - if( !found ) + if( itr == mDirtyLayoutSubTrees.end() ) { mDirtyLayoutSubTrees.PushBack( actorPtr ); } @@ -386,15 +376,10 @@ void RelayoutController::RemoveRequest( Dali::Actor& actor ) { Internal::Actor* actorPtr = &GetImplementation( actor ); - // Remove actor from dirty sub trees - for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it ) - { - if( *it == actorPtr ) - { - mDirtyLayoutSubTrees.Erase( it ); - break; - } - } + mDirtyLayoutSubTrees.Erase( std::remove( mDirtyLayoutSubTrees.begin(), + mDirtyLayoutSubTrees.end(), + actorPtr ), + mDirtyLayoutSubTrees.end() ); } void RelayoutController::Request() @@ -427,10 +412,8 @@ void RelayoutController::Relayout() // 1. Finds all top-level controls from the dirty list and allocate them the size of the scene // These controls are paired with the parent/scene size and added to the stack. - for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it ) + for( auto& dirtyActor : mDirtyLayoutSubTrees ) { - Internal::Actor* dirtyActor = *it; - // Need to test if actor is valid (could have been deleted and had the pointer cleared) if( dirtyActor ) { @@ -502,13 +485,11 @@ void RelayoutController::SetProcessingCoreEvents( bool processingEvents ) void RelayoutController::FindAndZero( const RawActorList& list, const Dali::RefObject* object ) { // Object has been destroyed so clear it from this list - for( RawActorList::Iterator it = list.Begin(), itEnd = list.End(); it != itEnd; ++it ) + for( auto& actor : list ) { - BaseObject* actor = *it; - if( actor && ( actor == object ) ) { - *it = NULL; // Reset the pointer in the list. We don't want to remove it in case something is iterating over the list. + actor = nullptr; // Reset the pointer in the list. We don't want to remove it in case something is iterating over the list. } } } diff --git a/dali/internal/render/common/render-instruction-container.cpp b/dali/internal/render/common/render-instruction-container.cpp index 4389f2f..d2b08af 100644 --- a/dali/internal/render/common/render-instruction-container.cpp +++ b/dali/internal/render/common/render-instruction-container.cpp @@ -35,9 +35,7 @@ RenderInstructionContainer::RenderInstructionContainer() { } -RenderInstructionContainer::~RenderInstructionContainer() -{ -} +RenderInstructionContainer::~RenderInstructionContainer() = default; void RenderInstructionContainer::ResetAndReserve( BufferIndex bufferIndex, uint32_t capacityRequired ) { diff --git a/dali/internal/render/common/render-item.cpp b/dali/internal/render/common/render-item.cpp index d0daa83..5492878 100755 --- a/dali/internal/render/common/render-item.cpp +++ b/dali/internal/render/common/render-item.cpp @@ -56,10 +56,7 @@ RenderItem::RenderItem() { } -RenderItem::~RenderItem() -{ -} - +RenderItem::~RenderItem() = default; ClippingBox RenderItem::CalculateViewportSpaceAABB( const Vector3& size, const int viewportWidth, const int viewportHeight ) const { diff --git a/dali/internal/render/data-providers/node-data-provider.h b/dali/internal/render/data-providers/node-data-provider.h index 9603a77..0f768a3 100644 --- a/dali/internal/render/data-providers/node-data-provider.h +++ b/dali/internal/render/data-providers/node-data-provider.h @@ -40,7 +40,7 @@ public: /** * Constructor. Nothing to do as a pure interface. */ - NodeDataProvider() { } + NodeDataProvider() = default; /** * @param bufferIndex to use @@ -68,7 +68,7 @@ protected: /** * Virtual destructor, this is an interface, no deletion through this interface */ - ~NodeDataProvider() override { } + ~NodeDataProvider() override = default; }; } // SceneGraph diff --git a/dali/internal/render/data-providers/render-data-provider.cpp b/dali/internal/render/data-providers/render-data-provider.cpp index 004044b..eb75345 100644 --- a/dali/internal/render/data-providers/render-data-provider.cpp +++ b/dali/internal/render/data-providers/render-data-provider.cpp @@ -31,9 +31,7 @@ RenderDataProvider::RenderDataProvider( AnimatableProperty< float >& opacity ) { } -RenderDataProvider::~RenderDataProvider() -{ -} +RenderDataProvider::~RenderDataProvider() = default; void RenderDataProvider::SetUniformMap(const UniformMapDataProvider& uniformMapDataProvider) { diff --git a/dali/internal/render/data-providers/uniform-map-data-provider.h b/dali/internal/render/data-providers/uniform-map-data-provider.h index 158bf3f..9160908 100644 --- a/dali/internal/render/data-providers/uniform-map-data-provider.h +++ b/dali/internal/render/data-providers/uniform-map-data-provider.h @@ -39,9 +39,7 @@ public: /** * Constructor */ - UniformMapDataProvider() - { - } + UniformMapDataProvider() = default; /** * Return true if the uniform map has been changed this frame @@ -66,9 +64,7 @@ protected: /** * No deletion through this interface */ - virtual ~UniformMapDataProvider() - { - } + virtual ~UniformMapDataProvider() = default; }; } // namespace SceneGraph diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index 0cdc6f0..f92d0d0 100644 --- a/dali/internal/render/gl-resources/context.cpp +++ b/dali/internal/render/gl-resources/context.cpp @@ -111,9 +111,7 @@ Context::Context( Integration::GlAbstraction& glAbstraction, OwnerContainer< Con { } -Context::~Context() -{ -} +Context::~Context() = default; void Context::GlContextCreated() { diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h index 89538f0..fe4d2dd 100644 --- a/dali/internal/render/gl-resources/context.h +++ b/dali/internal/render/gl-resources/context.h @@ -408,8 +408,16 @@ public: */ void BlendEquation(GLenum mode) { - // use BlendEquationSeparate to set the rgb and alpha modes the same - BlendEquationSeparate( mode, mode ); + // DO NOT USE BlendEquationSeparate to set the same rgb and alpha modes + // KHR blending extensions require use of glBlendEquation + + if( mBlendEquationSeparateModeRGB != mode || mBlendEquationSeparateModeAlpha != mode ) + { + mBlendEquationSeparateModeRGB = mode; + mBlendEquationSeparateModeAlpha = mode; + LOG_GL("BlendEquation %d\n", mode); + CHECK_GL( mGlAbstraction, mGlAbstraction.BlendEquation( mode ) ); + } } /** @@ -1727,7 +1735,7 @@ public: } /** - * Wrapper for OpenGL ES 3.0 glUnmapBubffer() + * Wrapper for OpenGL ES 3.0 glUnmapBuffer() */ GLboolean UnmapBuffer(GLenum target) { @@ -1735,6 +1743,7 @@ public: GLboolean val = CHECK_GL( mGlAbstraction, mGlAbstraction.UnmapBuffer(target) ); return val; } + /** * Wrapper for OpenGL ES 2.0 glViewport() */ @@ -1756,6 +1765,15 @@ public: } /** + * Wrapper for OpenGL ES 3.2 and GL_KHR_blend_equation_advanced extention glBlendBarrier() + */ + void BlendBarrier() + { + LOG_GL( "BlendBarrier\n" ); + CHECK_GL( mGlAbstraction, mGlAbstraction.BlendBarrier() ); + } + + /** * Get the implementation defined MAX_TEXTURE_SIZE. This values is cached when the context is created * @return The implementation defined MAX_TEXTURE_SIZE */ diff --git a/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp b/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp index e9d3271..576475a 100644 --- a/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp +++ b/dali/internal/render/gl-resources/frame-buffer-state-cache.cpp @@ -40,9 +40,7 @@ FrameBufferStateCache::FrameBufferStateCache() { } -FrameBufferStateCache::~FrameBufferStateCache() -{ -} +FrameBufferStateCache::~FrameBufferStateCache() = default; GLbitfield FrameBufferStateCache::GetClearMask( GLbitfield mask, bool forceClear, bool scissorTestEnabled ) { diff --git a/dali/internal/render/gl-resources/gl-resource-owner.h b/dali/internal/render/gl-resources/gl-resource-owner.h index a0642ee..f1c684b 100644 --- a/dali/internal/render/gl-resources/gl-resource-owner.h +++ b/dali/internal/render/gl-resources/gl-resource-owner.h @@ -35,8 +35,7 @@ public: /** * Virtual destructor. */ - virtual ~GlResourceOwner() - { } + virtual ~GlResourceOwner() = default; /** * Reset all GL resources. diff --git a/dali/internal/render/renderers/render-frame-buffer.cpp b/dali/internal/render/renderers/render-frame-buffer.cpp index cdd5c2e..8210648 100644 --- a/dali/internal/render/renderers/render-frame-buffer.cpp +++ b/dali/internal/render/renderers/render-frame-buffer.cpp @@ -52,9 +52,7 @@ FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments ) { } -FrameBuffer::~FrameBuffer() -{ -} +FrameBuffer::~FrameBuffer() = default; void FrameBuffer::Destroy( Context& context ) { diff --git a/dali/internal/render/renderers/render-geometry.cpp b/dali/internal/render/renderers/render-geometry.cpp index a24712a..d3a2809 100644 --- a/dali/internal/render/renderers/render-geometry.cpp +++ b/dali/internal/render/renderers/render-geometry.cpp @@ -41,9 +41,7 @@ Geometry::Geometry() { } -Geometry::~Geometry() -{ -} +Geometry::~Geometry() = default; void Geometry::GlContextCreated( Context& context ) { diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index bce1343..cb316e8 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -165,9 +165,7 @@ void Renderer::Initialize( Context& context ) mContext = &context; } -Renderer::~Renderer() -{ -} +Renderer::~Renderer() = default; void Renderer::SetGeometry( Render::Geometry* geometry ) { @@ -203,8 +201,21 @@ void Renderer::SetBlending( Context& context, bool blend ) mBlendingOptions.GetBlendDestFactorAlpha() ); // Set blend equations - context.BlendEquationSeparate( mBlendingOptions.GetBlendEquationRgb(), - mBlendingOptions.GetBlendEquationAlpha() ); + Dali::DevelBlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb(); + Dali::DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha(); + + if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled ) + { + if( rgbEquation != alphaEquation ) + { + DALI_LOG_ERROR( "Advanced Blend Equation have to be appried by using BlendEquation.\n" ); + } + context.BlendEquation( rgbEquation ); + } + else + { + context.BlendEquationSeparate( rgbEquation, alphaEquation ); + } } mUpdated = true; @@ -651,6 +662,11 @@ void Renderer::Render( Context& context, mUpdateAttributesLocation = false; } + if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled ) + { + context.BlendBarrier(); + } + if(mDrawCommands.empty()) { SetBlending( context, blend ); diff --git a/dali/internal/render/renderers/render-sampler.h b/dali/internal/render/renderers/render-sampler.h index c042995..1adf2f9 100644 --- a/dali/internal/render/renderers/render-sampler.h +++ b/dali/internal/render/renderers/render-sampler.h @@ -46,8 +46,7 @@ struct Sampler /** * Destructor */ - ~Sampler() - {} + ~Sampler() = default; bool operator==(const Sampler& rhs) const { diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index 73b73e2..f77ddb6 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -697,8 +697,7 @@ Texture::Texture( NativeImageInterfacePtr nativeImageInterface ) { } -Texture::~Texture() -{} +Texture::~Texture() = default; void Texture::Destroy( Context& context ) { diff --git a/dali/internal/render/renderers/render-vertex-buffer.cpp b/dali/internal/render/renderers/render-vertex-buffer.cpp index cfec857..385b7b8 100644 --- a/dali/internal/render/renderers/render-vertex-buffer.cpp +++ b/dali/internal/render/renderers/render-vertex-buffer.cpp @@ -125,9 +125,7 @@ VertexBuffer::VertexBuffer() { } -VertexBuffer::~VertexBuffer() -{ -} +VertexBuffer::~VertexBuffer() = default; void VertexBuffer::SetFormat( VertexBuffer::Format* format ) { diff --git a/dali/internal/render/shaders/program-cache.h b/dali/internal/render/shaders/program-cache.h index 6d91e34..42d31b6 100644 --- a/dali/internal/render/shaders/program-cache.h +++ b/dali/internal/render/shaders/program-cache.h @@ -40,14 +40,12 @@ public: /** * Constructor */ - ProgramCache() - { } + ProgramCache() = default; /** * Destructor, virtual as this is an interface */ - virtual ~ProgramCache() - { } + virtual ~ProgramCache() = default; public: // API diff --git a/dali/internal/render/shaders/program-controller.cpp b/dali/internal/render/shaders/program-controller.cpp index 1245787..1452564 100644 --- a/dali/internal/render/shaders/program-controller.cpp +++ b/dali/internal/render/shaders/program-controller.cpp @@ -41,9 +41,7 @@ ProgramController::ProgramController( Integration::GlAbstraction& glAbstraction mProgramCache.Reserve( 32 ); } -ProgramController::~ProgramController() -{ -} +ProgramController::~ProgramController() = default; void ProgramController::ResetProgramMatrices() { diff --git a/dali/internal/update/animation/property-accessor.h b/dali/internal/update/animation/property-accessor.h index e512628..813dacf 100644 --- a/dali/internal/update/animation/property-accessor.h +++ b/dali/internal/update/animation/property-accessor.h @@ -50,9 +50,7 @@ public: /** * Non-virtual destructor; PropertyAccessor is not suitable as a base class. */ - ~PropertyAccessor() - { - } + ~PropertyAccessor() = default; /** * Query whether the accessor is set. @@ -142,9 +140,7 @@ public: /** * Non-virtual destructor; PropertyAccessor is not suitable as a base class. */ - ~TransformManagerPropertyAccessor() - { - } + ~TransformManagerPropertyAccessor() = default; /** * Query whether the accessor is set. @@ -235,9 +231,7 @@ public: /** * Non-virtual destructor; PropertyAccessor is not suitable as a base class. */ - ~TransformManagerPropertyComponentAccessor() - { - } + ~TransformManagerPropertyComponentAccessor() = default; /** * Query whether the accessor is set. diff --git a/dali/internal/update/animation/property-component-accessor.h b/dali/internal/update/animation/property-component-accessor.h index 180dda3..a8604fc 100644 --- a/dali/internal/update/animation/property-component-accessor.h +++ b/dali/internal/update/animation/property-component-accessor.h @@ -49,9 +49,7 @@ public: /** * Non-virtual destructor; PropertyComponentAccessorX is not suitable as a base class. */ - ~PropertyComponentAccessorX() - { - } + ~PropertyComponentAccessorX() = default; /** * Query whether the accessor is set. @@ -141,9 +139,7 @@ public: /** * Non-virtual destructor; PropertyComponentAccessorY is not suitable as a base class. */ - ~PropertyComponentAccessorY() - { - } + ~PropertyComponentAccessorY() = default; /** * Query whether the accessor is set. @@ -232,9 +228,7 @@ public: /** * Non-virtual destructor; PropertyComponentAccessorZ is not suitable as a base class. */ - ~PropertyComponentAccessorZ() - { - } + ~PropertyComponentAccessorZ() = default; /** * Query whether the accessor is set. @@ -323,9 +317,7 @@ public: /** * Non-virtual destructor; PropertyComponentAccessorW is not suitable as a base class. */ - ~PropertyComponentAccessorW() - { - } + ~PropertyComponentAccessorW() = default; /** * Query whether the accessor is set. diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index f0d961d..10a735f 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -78,13 +78,12 @@ Animation::Animation( float durationSeconds, float speedFactor, const Vector2& p mDisconnectAction(disconnectAction), mState(Stopped), mProgressReachedSignalRequired( false ), - mAutoReverseEnabled( false ) + mAutoReverseEnabled( false ), + mIsActive{ false } { } -Animation::~Animation() -{ -} +Animation::~Animation() = default; void Animation::operator delete( void* ptr ) { @@ -426,58 +425,58 @@ void Animation::Update( BufferIndex bufferIndex, float elapsedSeconds, bool& loo void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animationFinished ) { + mIsActive[bufferIndex] = false; + const Vector2 playRange( mPlayRange * mDurationSeconds ); float elapsedSecondsClamped = Clamp( mElapsedSeconds, playRange.x, playRange.y ); + //Remove animators whose PropertyOwner has been destroyed + mAnimators.Erase(std::remove_if(mAnimators.begin(), + mAnimators.end(), + [](auto animator) { return animator->Orphan(); }), + mAnimators.end()); + //Loop through all animators - bool applied(true); - for ( auto&& iter = mAnimators.Begin(); iter != mAnimators.End(); ) + for(auto& animator : mAnimators) { - AnimatorBase *animator = *iter; - - if( animator->Orphan() ) - { - //Remove animators whose PropertyOwner has been destroyed - iter = mAnimators.Erase(iter); - } - else + bool applied(true); + if(animator->IsEnabled()) { - if( animator->IsEnabled() ) - { - const float intervalDelay( animator->GetIntervalDelay() ); + const float intervalDelay(animator->GetIntervalDelay()); - if( elapsedSecondsClamped >= intervalDelay ) + if(elapsedSecondsClamped >= intervalDelay) + { + // Calculate a progress specific to each individual animator + float progress(1.0f); + const float animatorDuration = animator->GetDuration(); + if(animatorDuration > 0.0f) // animators can be "immediate" { - // Calculate a progress specific to each individual animator - float progress(1.0f); - const float animatorDuration = animator->GetDuration(); - if (animatorDuration > 0.0f) // animators can be "immediate" - { - progress = Clamp((elapsedSecondsClamped - intervalDelay) / animatorDuration, 0.0f , 1.0f ); - } - animator->Update(bufferIndex, progress, bake); + progress = Clamp((elapsedSecondsClamped - intervalDelay) / animatorDuration, 0.0f, 1.0f); } - applied = true; - } - else - { - applied = false; - } + animator->Update(bufferIndex, progress, bake); - if ( animationFinished ) - { - animator->SetActive( false ); + if (animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration) + { + mIsActive[bufferIndex] = true; + } } + applied = true; + } + else + { + applied = false; + } - if (applied) - { - INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED); - } + if(animationFinished) + { + animator->SetActive(false); + } - ++iter; + if(applied) + { + INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED); } } - } } // namespace SceneGraph diff --git a/dali/internal/update/animation/scene-graph-animation.h b/dali/internal/update/animation/scene-graph-animation.h index a4e309f..0617041 100644 --- a/dali/internal/update/animation/scene-graph-animation.h +++ b/dali/internal/update/animation/scene-graph-animation.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_ANIMATION_H /* - * Copyright (c) 2019 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. @@ -259,6 +259,16 @@ public: } /** + * Query whether the animation is currently active (i.e. at least one of the animators has been updated in either frame) + * @return True if the animation is currently active + */ + bool IsActive() const + { + // As we have double buffering, if animator is updated in either frame, it needs to be rendered. + return mIsActive[0] || mIsActive[1]; + } + + /** * @brief Sets the looping mode. * * Animation plays forwards and then restarts from the beginning or runs backwards again. @@ -349,6 +359,7 @@ protected: bool mProgressReachedSignalRequired; // Flag to indicate the progress marker was hit bool mAutoReverseEnabled; // Flag to identify that the looping mode is auto reverse. + bool mIsActive[2]; // Flag to indicate whether the animation is active in the current frame (which is double buffered) }; }; //namespace SceneGraph diff --git a/dali/internal/update/animation/scene-graph-animator.h b/dali/internal/update/animation/scene-graph-animator.h index 120aa24..3ff3144 100644 --- a/dali/internal/update/animation/scene-graph-animator.h +++ b/dali/internal/update/animation/scene-graph-animator.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include @@ -45,59 +46,6 @@ namespace Internal using Interpolation = Dali::Animation::Interpolation; -/** - * AnimatorFunction base class. - * Needs to be declared first so AnimatorBase knows about it's destructor - * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator - */ -struct AnimatorFunctionBase -{ - /** - * Constructor - */ - AnimatorFunctionBase() {} - - /* - * Virtual destructor (Intended as base class) - */ - virtual ~AnimatorFunctionBase() {} - - ///Stub "()" operators. - virtual bool operator()(float progress, const bool& property) - { - return property; - } - - virtual float operator()(float progress, const int32_t& property) - { - return static_cast( property ); - } - - virtual float operator()(float progress, const float& property) - { - return property; - } - - virtual Vector2 operator()(float progress, const Vector2& property) - { - return property; - } - - virtual Vector3 operator()(float progress, const Vector3& property) - { - return property; - } - - virtual Vector4 operator()(float progress, const Vector4& property) - { - return property; - } - - virtual Quaternion operator()(float progress, const Quaternion& property) - { - return property; - } -}; namespace SceneGraph { @@ -135,17 +83,14 @@ public: * Constructor. */ AnimatorBase( PropertyOwner* propertyOwner, - AnimatorFunctionBase* animatorFunction, AlphaFunction alphaFunction, const TimePeriod& timePeriod ) : mLifecycleObserver( nullptr ), mPropertyOwner( propertyOwner ), - mAnimatorFunction( animatorFunction ), mDurationSeconds( timePeriod.durationSeconds ), mIntervalDelaySeconds( timePeriod.delaySeconds ), mSpeedFactor( 1.0f ), mCurrentProgress( 0.f ), - mLoopCount( 1 ), mAlphaFunction( alphaFunction ), mDisconnectAction( Dali::Animation::BAKE_FINAL ), mAnimationPlaying( false ), @@ -160,7 +105,6 @@ public: */ ~AnimatorBase() override { - delete mAnimatorFunction; if (mPropertyOwner && mConnectedToSceneGraph) { mPropertyOwner->RemoveObserver(*this); @@ -560,16 +504,15 @@ protected: LifecycleObserver* mLifecycleObserver; PropertyOwner* mPropertyOwner; - AnimatorFunctionBase* mAnimatorFunction; + float mDurationSeconds; float mIntervalDelaySeconds; float mSpeedFactor; float mCurrentProgress; - int32_t mLoopCount; - AlphaFunction mAlphaFunction; + int32_t mLoopCount{1}; Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage. bool mAnimationPlaying:1; ///< whether disconnect has been applied while it's running. bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage. @@ -580,9 +523,13 @@ protected: /** * An animator for a specific property type PropertyType. */ -template < typename PropertyType, typename PropertyAccessorType > -class Animator : public AnimatorBase +template +class Animator final : public AnimatorBase { + using AnimatorFunction = std::function; + + AnimatorFunction mAnimatorFunction; + public: /** @@ -593,25 +540,18 @@ public: * @param[in] timePeriod The time period of this animation. * @return A newly allocated animator. */ - static AnimatorBase* New( const PropertyOwner& propertyOwner, - const PropertyBase& property, - AnimatorFunctionBase* animatorFunction, - AlphaFunction alphaFunction, - const TimePeriod& timePeriod ) + static AnimatorBase* New(const PropertyOwner& propertyOwner, + const PropertyBase& property, + AnimatorFunction animatorFunction, + AlphaFunction alphaFunction, + const TimePeriod& timePeriod) { // The property was const in the actor-thread, but animators are used in the scene-graph thread. - return new Animator( const_cast( &propertyOwner ), - const_cast( &property ), - animatorFunction, - alphaFunction, - timePeriod ); - } - - /** - * Virtual destructor. - */ - ~Animator() override - { + return new Animator(const_cast(&propertyOwner), + const_cast(&property), + std::move(animatorFunction), + alphaFunction, + timePeriod); } /** @@ -622,7 +562,7 @@ public: const PropertyType& current = mPropertyAccessor.Get( bufferIndex ); // need to cast the return value in case property is integer - const PropertyType result = static_cast( (*mAnimatorFunction)( alpha, current ) ); + const PropertyType result = static_cast(mAnimatorFunction(alpha, current)); if ( bake ) { @@ -639,13 +579,14 @@ private: /** * Private constructor; see also Animator::New(). */ - Animator( PropertyOwner* propertyOwner, - PropertyBase* property, - AnimatorFunctionBase* animatorFunction, - AlphaFunction alphaFunction, - const TimePeriod& timePeriod ) - : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ), - mPropertyAccessor( property ) + Animator(PropertyOwner* propertyOwner, + PropertyBase* property, + AnimatorFunction animatorFunction, + AlphaFunction alphaFunction, + const TimePeriod& timePeriod) + : AnimatorBase(propertyOwner, alphaFunction, timePeriod), + mAnimatorFunction(std::move(animatorFunction)), + mPropertyAccessor(property) { // WARNING - this object is created in the event-thread // The scene-graph mPropertyOwner object cannot be observed here @@ -668,9 +609,13 @@ protected: /** * An animator for a specific property type PropertyType. */ -template -class AnimatorTransformProperty : public AnimatorBase +template +class AnimatorTransformProperty final : public AnimatorBase { + using AnimatorFunction = std::function; + + AnimatorFunction mAnimatorFunction; + public: /** @@ -681,26 +626,19 @@ public: * @param[in] timePeriod The time period of this animation. * @return A newly allocated animator. */ - static AnimatorBase* New( const PropertyOwner& propertyOwner, - const PropertyBase& property, - AnimatorFunctionBase* animatorFunction, - AlphaFunction alphaFunction, - const TimePeriod& timePeriod ) + static AnimatorBase* New(const PropertyOwner& propertyOwner, + const PropertyBase& property, + AnimatorFunction animatorFunction, + AlphaFunction alphaFunction, + const TimePeriod& timePeriod) { // The property was const in the actor-thread, but animators are used in the scene-graph thread. - return new AnimatorTransformProperty( const_cast( &propertyOwner ), - const_cast( &property ), - animatorFunction, - alphaFunction, - timePeriod ); - } - - /** - * Virtual destructor. - */ - ~AnimatorTransformProperty() override - { + return new AnimatorTransformProperty(const_cast(&propertyOwner), + const_cast(&property), + std::move(animatorFunction), + alphaFunction, + timePeriod); } /** @@ -711,7 +649,7 @@ public: const PropertyType& current = mPropertyAccessor.Get( bufferIndex ); // need to cast the return value in case property is integer - const PropertyType result = static_cast( (*mAnimatorFunction)( alpha, current ) ); + const PropertyType result = static_cast(mAnimatorFunction(alpha, current)); if ( bake ) { @@ -728,13 +666,14 @@ private: /** * Private constructor; see also Animator::New(). */ - AnimatorTransformProperty( PropertyOwner* propertyOwner, - PropertyBase* property, - AnimatorFunctionBase* animatorFunction, - AlphaFunction alphaFunction, - const TimePeriod& timePeriod ) - : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ), - mPropertyAccessor( property ) + AnimatorTransformProperty(PropertyOwner* propertyOwner, + PropertyBase* property, + AnimatorFunction animatorFunction, + AlphaFunction alphaFunction, + const TimePeriod& timePeriod) + : AnimatorBase(propertyOwner, alphaFunction, timePeriod), + mAnimatorFunction(std::move(animatorFunction)), + mPropertyAccessor(property) { // WARNING - this object is created in the event-thread // The scene-graph mPropertyOwner object cannot be observed here @@ -755,15 +694,14 @@ protected: // Update functions -struct AnimateByInteger : public AnimatorFunctionBase +struct AnimateByInteger { AnimateByInteger(const int& relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - float operator()(float alpha, const int32_t& property) override + float operator()(float alpha, const int32_t& property) { // integers need to be correctly rounded return roundf(static_cast( property ) + static_cast( mRelative ) * alpha ); @@ -772,15 +710,14 @@ struct AnimateByInteger : public AnimatorFunctionBase int32_t mRelative; }; -struct AnimateToInteger : public AnimatorFunctionBase +struct AnimateToInteger { AnimateToInteger(const int& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - float operator()(float alpha, const int32_t& property) override + float operator()(float alpha, const int32_t& property) { // integers need to be correctly rounded return roundf(static_cast( property ) + (static_cast(mTarget - property) * alpha) ); @@ -789,15 +726,14 @@ struct AnimateToInteger : public AnimatorFunctionBase int32_t mTarget; }; -struct AnimateByFloat : public AnimatorFunctionBase +struct AnimateByFloat { AnimateByFloat(const float& relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - float operator()(float alpha, const float& property) override + float operator()(float alpha, const float& property) { return float(property + mRelative * alpha); } @@ -805,15 +741,14 @@ struct AnimateByFloat : public AnimatorFunctionBase float mRelative; }; -struct AnimateToFloat : public AnimatorFunctionBase +struct AnimateToFloat { AnimateToFloat(const float& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - float operator()(float alpha, const float& property) override + float operator()(float alpha, const float& property) { return float(property + ((mTarget - property) * alpha)); } @@ -821,15 +756,14 @@ struct AnimateToFloat : public AnimatorFunctionBase float mTarget; }; -struct AnimateByVector2 : public AnimatorFunctionBase +struct AnimateByVector2 { AnimateByVector2(const Vector2& relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - Vector2 operator()(float alpha, const Vector2& property) override + Vector2 operator()(float alpha, const Vector2& property) { return Vector2(property + mRelative * alpha); } @@ -837,15 +771,14 @@ struct AnimateByVector2 : public AnimatorFunctionBase Vector2 mRelative; }; -struct AnimateToVector2 : public AnimatorFunctionBase +struct AnimateToVector2 { AnimateToVector2(const Vector2& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - Vector2 operator()(float alpha, const Vector2& property) override + Vector2 operator()(float alpha, const Vector2& property) { return Vector2(property + ((mTarget - property) * alpha)); } @@ -853,15 +786,14 @@ struct AnimateToVector2 : public AnimatorFunctionBase Vector2 mTarget; }; -struct AnimateByVector3 : public AnimatorFunctionBase +struct AnimateByVector3 { AnimateByVector3(const Vector3& relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - Vector3 operator()(float alpha, const Vector3& property) override + Vector3 operator()(float alpha, const Vector3& property) { return Vector3(property + mRelative * alpha); } @@ -869,15 +801,14 @@ struct AnimateByVector3 : public AnimatorFunctionBase Vector3 mRelative; }; -struct AnimateToVector3 : public AnimatorFunctionBase +struct AnimateToVector3 { AnimateToVector3(const Vector3& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - Vector3 operator()(float alpha, const Vector3& property) override + Vector3 operator()(float alpha, const Vector3& property) { return Vector3(property + ((mTarget - property) * alpha)); } @@ -885,15 +816,14 @@ struct AnimateToVector3 : public AnimatorFunctionBase Vector3 mTarget; }; -struct AnimateByVector4 : public AnimatorFunctionBase +struct AnimateByVector4 { AnimateByVector4(const Vector4& relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - Vector4 operator()(float alpha, const Vector4& property) override + Vector4 operator()(float alpha, const Vector4& property) { return Vector4(property + mRelative * alpha); } @@ -901,15 +831,14 @@ struct AnimateByVector4 : public AnimatorFunctionBase Vector4 mRelative; }; -struct AnimateToVector4 : public AnimatorFunctionBase +struct AnimateToVector4 { AnimateToVector4(const Vector4& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - Vector4 operator()(float alpha, const Vector4& property) override + Vector4 operator()(float alpha, const Vector4& property) { return Vector4(property + ((mTarget - property) * alpha)); } @@ -917,15 +846,14 @@ struct AnimateToVector4 : public AnimatorFunctionBase Vector4 mTarget; }; -struct AnimateByOpacity : public AnimatorFunctionBase +struct AnimateByOpacity { AnimateByOpacity(const float& relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - Vector4 operator()(float alpha, const Vector4& property) override + Vector4 operator()(float alpha, const Vector4& property) { Vector4 result(property); result.a += mRelative * alpha; @@ -936,15 +864,14 @@ struct AnimateByOpacity : public AnimatorFunctionBase float mRelative; }; -struct AnimateToOpacity : public AnimatorFunctionBase +struct AnimateToOpacity { AnimateToOpacity(const float& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - Vector4 operator()(float alpha, const Vector4& property) override + Vector4 operator()(float alpha, const Vector4& property) { Vector4 result(property); result.a = property.a + ((mTarget - property.a) * alpha); @@ -955,15 +882,14 @@ struct AnimateToOpacity : public AnimatorFunctionBase float mTarget; }; -struct AnimateByBoolean : public AnimatorFunctionBase +struct AnimateByBoolean { AnimateByBoolean(bool relativeValue) : mRelative(relativeValue) { } - using AnimatorFunctionBase::operator(); - bool operator()(float alpha, const bool& property) override + bool operator()(float alpha, const bool& property) { // Alpha is not useful here, just keeping to the same template as other update functors return bool(alpha >= 1.0f ? (property || mRelative) : property); @@ -972,15 +898,14 @@ struct AnimateByBoolean : public AnimatorFunctionBase bool mRelative; }; -struct AnimateToBoolean : public AnimatorFunctionBase +struct AnimateToBoolean { AnimateToBoolean(bool targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - bool operator()(float alpha, const bool& property) override + bool operator()(float alpha, const bool& property) { // Alpha is not useful here, just keeping to the same template as other update functors return bool(alpha >= 1.0f ? mTarget : property); @@ -989,7 +914,7 @@ struct AnimateToBoolean : public AnimatorFunctionBase bool mTarget; }; -struct RotateByAngleAxis : public AnimatorFunctionBase +struct RotateByAngleAxis { RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis) : mAngleRadians( angleRadians ), @@ -997,8 +922,7 @@ struct RotateByAngleAxis : public AnimatorFunctionBase { } - using AnimatorFunctionBase::operator(); - Quaternion operator()(float alpha, const Quaternion& rotation) override + Quaternion operator()(float alpha, const Quaternion& rotation) { if (alpha > 0.0f) { @@ -1012,15 +936,14 @@ struct RotateByAngleAxis : public AnimatorFunctionBase Vector3 mAxis; }; -struct RotateToQuaternion : public AnimatorFunctionBase +struct RotateToQuaternion { RotateToQuaternion(const Quaternion& targetValue) : mTarget(targetValue) { } - using AnimatorFunctionBase::operator(); - Quaternion operator()(float alpha, const Quaternion& rotation) override + Quaternion operator()(float alpha, const Quaternion& rotation) { return Quaternion::Slerp(rotation, mTarget, alpha); } @@ -1028,162 +951,157 @@ struct RotateToQuaternion : public AnimatorFunctionBase Quaternion mTarget; }; - -struct KeyFrameBooleanFunctor : public AnimatorFunctionBase +struct KeyFrameBooleanFunctor { - KeyFrameBooleanFunctor(KeyFrameBooleanPtr keyFrames) - : mKeyFrames(keyFrames) + KeyFrameBooleanFunctor(KeyFrameBoolean keyFrames) + : mKeyFrames(std::move(keyFrames)) { } - using AnimatorFunctionBase::operator(); - bool operator()(float progress, const bool& property) override + bool operator()(float progress, const bool& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return mKeyFrames->GetValue(progress, Dali::Animation::LINEAR); + return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR); } return property; } - KeyFrameBooleanPtr mKeyFrames; + KeyFrameBoolean mKeyFrames; }; -struct KeyFrameIntegerFunctor : public AnimatorFunctionBase +struct KeyFrameIntegerFunctor { - KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation) - : mKeyFrames(keyFrames),mInterpolation(interpolation) + KeyFrameIntegerFunctor(KeyFrameInteger keyFrames, Interpolation interpolation) + : mKeyFrames(std::move(keyFrames)), + mInterpolation(interpolation) { } - using AnimatorFunctionBase::operator(); - float operator()(float progress, const int32_t& property) override + float operator()(float progress, const int32_t& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return static_cast( mKeyFrames->GetValue(progress, mInterpolation) ); + return static_cast(mKeyFrames.GetValue(progress, mInterpolation)); } return static_cast( property ); } - KeyFrameIntegerPtr mKeyFrames; + KeyFrameInteger mKeyFrames; Interpolation mInterpolation; }; -struct KeyFrameNumberFunctor : public AnimatorFunctionBase +struct KeyFrameNumberFunctor { - KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation) - : mKeyFrames(keyFrames),mInterpolation(interpolation) + KeyFrameNumberFunctor(KeyFrameNumber keyFrames, Interpolation interpolation) + : mKeyFrames(std::move(keyFrames)), + mInterpolation(interpolation) { } - using AnimatorFunctionBase::operator(); - float operator()(float progress, const float& property) override + float operator()(float progress, const float& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return mKeyFrames->GetValue(progress, mInterpolation); + return mKeyFrames.GetValue(progress, mInterpolation); } return property; } - KeyFrameNumberPtr mKeyFrames; + KeyFrameNumber mKeyFrames; Interpolation mInterpolation; }; -struct KeyFrameVector2Functor : public AnimatorFunctionBase +struct KeyFrameVector2Functor { - KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames, Interpolation interpolation) - : mKeyFrames(keyFrames),mInterpolation(interpolation) + KeyFrameVector2Functor(KeyFrameVector2 keyFrames, Interpolation interpolation) + : mKeyFrames(std::move(keyFrames)), + mInterpolation(interpolation) { } - using AnimatorFunctionBase::operator(); - Vector2 operator()(float progress, const Vector2& property) override + Vector2 operator()(float progress, const Vector2& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return mKeyFrames->GetValue(progress, mInterpolation); + return mKeyFrames.GetValue(progress, mInterpolation); } return property; } - KeyFrameVector2Ptr mKeyFrames; + KeyFrameVector2 mKeyFrames; Interpolation mInterpolation; }; - -struct KeyFrameVector3Functor : public AnimatorFunctionBase +struct KeyFrameVector3Functor { - KeyFrameVector3Functor(KeyFrameVector3Ptr keyFrames, Interpolation interpolation) - : mKeyFrames(keyFrames),mInterpolation(interpolation) + KeyFrameVector3Functor(KeyFrameVector3 keyFrames, Interpolation interpolation) + : mKeyFrames(std::move(keyFrames)), + mInterpolation(interpolation) { } - using AnimatorFunctionBase::operator(); - Vector3 operator()(float progress, const Vector3& property) override + Vector3 operator()(float progress, const Vector3& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return mKeyFrames->GetValue(progress, mInterpolation); + return mKeyFrames.GetValue(progress, mInterpolation); } return property; } - KeyFrameVector3Ptr mKeyFrames; + KeyFrameVector3 mKeyFrames; Interpolation mInterpolation; }; -struct KeyFrameVector4Functor : public AnimatorFunctionBase +struct KeyFrameVector4Functor { - KeyFrameVector4Functor(KeyFrameVector4Ptr keyFrames, Interpolation interpolation) - : mKeyFrames(keyFrames),mInterpolation(interpolation) + KeyFrameVector4Functor(KeyFrameVector4 keyFrames, Interpolation interpolation) + : mKeyFrames(std::move(keyFrames)), + mInterpolation(interpolation) { } - using AnimatorFunctionBase::operator(); - Vector4 operator()(float progress, const Vector4& property) override + Vector4 operator()(float progress, const Vector4& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return mKeyFrames->GetValue(progress, mInterpolation); + return mKeyFrames.GetValue(progress, mInterpolation); } return property; } - KeyFrameVector4Ptr mKeyFrames; + KeyFrameVector4 mKeyFrames; Interpolation mInterpolation; }; -struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase +struct KeyFrameQuaternionFunctor { - KeyFrameQuaternionFunctor(KeyFrameQuaternionPtr keyFrames) - : mKeyFrames(keyFrames) + KeyFrameQuaternionFunctor(KeyFrameQuaternion keyFrames) + : mKeyFrames(std::move(keyFrames)) { } - using AnimatorFunctionBase::operator(); - Quaternion operator()(float progress, const Quaternion& property) override + Quaternion operator()(float progress, const Quaternion& property) { - if(mKeyFrames->IsActive(progress)) + if(mKeyFrames.IsActive(progress)) { - return mKeyFrames->GetValue(progress, Dali::Animation::LINEAR); + return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR); } return property; } - KeyFrameQuaternionPtr mKeyFrames; + KeyFrameQuaternion mKeyFrames; }; -struct PathPositionFunctor : public AnimatorFunctionBase +struct PathPositionFunctor { PathPositionFunctor( PathPtr path ) : mPath(path) { } - using AnimatorFunctionBase::operator(); - Vector3 operator()(float progress, const Vector3& property) override + Vector3 operator()(float progress, const Vector3& property) { Vector3 position(property); static_cast( mPath->SamplePosition(progress, position) ); @@ -1193,7 +1111,7 @@ struct PathPositionFunctor : public AnimatorFunctionBase PathPtr mPath; }; -struct PathRotationFunctor : public AnimatorFunctionBase +struct PathRotationFunctor { PathRotationFunctor( PathPtr path, const Vector3& forward ) : mPath(path), @@ -1202,8 +1120,7 @@ struct PathRotationFunctor : public AnimatorFunctionBase mForward.Normalize(); } - using AnimatorFunctionBase::operator(); - Quaternion operator()(float progress, const Quaternion& property) override + Quaternion operator()(float progress, const Quaternion& property) { Vector3 tangent; if( mPath->SampleTangent(progress, tangent) ) diff --git a/dali/internal/update/animation/scene-graph-constraint.h b/dali/internal/update/animation/scene-graph-constraint.h index ef32672..4015114 100644 --- a/dali/internal/update/animation/scene-graph-constraint.h +++ b/dali/internal/update/animation/scene-graph-constraint.h @@ -72,9 +72,7 @@ public: /** * Virtual destructor. */ - ~Constraint() override - { - } + ~Constraint() override = default; /** * @copydoc Dali::Internal::SceneGraph::ConstraintBase::Apply() diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index a586a0d..35daa3e 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -77,8 +77,7 @@ public: /** * Virtual destructor. */ - ~AnimatablePropertyBase() override - {} + ~AnimatablePropertyBase() override = default; protected: // for derived classes @@ -144,9 +143,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -317,9 +314,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -498,9 +493,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -680,9 +673,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -952,9 +943,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1278,9 +1267,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1663,9 +1650,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1822,9 +1807,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1985,9 +1968,7 @@ public: /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() diff --git a/dali/internal/update/common/discard-queue.cpp b/dali/internal/update/common/discard-queue.cpp index 855f7b1..2131cbd 100644 --- a/dali/internal/update/common/discard-queue.cpp +++ b/dali/internal/update/common/discard-queue.cpp @@ -47,9 +47,7 @@ DiscardQueue::DiscardQueue( RenderQueue& renderQueue ) { } -DiscardQueue::~DiscardQueue() -{ -} +DiscardQueue::~DiscardQueue() = default; void DiscardQueue::Add( BufferIndex updateBufferIndex, Node* node ) { diff --git a/dali/internal/update/common/inherited-property.h b/dali/internal/update/common/inherited-property.h index 4cd573e..dc3559f 100644 --- a/dali/internal/update/common/inherited-property.h +++ b/dali/internal/update/common/inherited-property.h @@ -68,9 +68,7 @@ public: /** * Virtual destructor. */ - ~InheritedVector3() override - { - } + ~InheritedVector3() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -219,9 +217,7 @@ public: /** * Virtual destructor. */ - ~InheritedColor() override - { - } + ~InheritedColor() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -388,9 +384,7 @@ public: /** * Virtual destructor. */ - ~InheritedQuaternion() override - { - } + ~InheritedQuaternion() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -538,9 +532,7 @@ public: /** * Virtual destructor. */ - ~InheritedMatrix() override - { - } + ~InheritedMatrix() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() diff --git a/dali/internal/update/common/property-base.cpp b/dali/internal/update/common/property-base.cpp index 18504e0..23abd3e 100644 --- a/dali/internal/update/common/property-base.cpp +++ b/dali/internal/update/common/property-base.cpp @@ -26,14 +26,9 @@ namespace Internal namespace SceneGraph { +PropertyBase::PropertyBase() = default; -PropertyBase::PropertyBase() -{ -} - -PropertyBase::~PropertyBase() -{ -} +PropertyBase::~PropertyBase() = default; } // namespace SceneGraph diff --git a/dali/internal/update/common/property-owner-messages.cpp b/dali/internal/update/common/property-owner-messages.cpp index 9cc7014..85e3b05 100644 --- a/dali/internal/update/common/property-owner-messages.cpp +++ b/dali/internal/update/common/property-owner-messages.cpp @@ -29,13 +29,9 @@ namespace SceneGraph // Messages for a property owner -PropertyOwnerMessageBase::PropertyOwnerMessageBase() -{ -} +PropertyOwnerMessageBase::PropertyOwnerMessageBase() = default; -PropertyOwnerMessageBase::~PropertyOwnerMessageBase() -{ -} +PropertyOwnerMessageBase::~PropertyOwnerMessageBase() = default; } // namespace SceneGraph diff --git a/dali/internal/update/common/property-owner-messages.h b/dali/internal/update/common/property-owner-messages.h index 8af4362..db5759d 100644 --- a/dali/internal/update/common/property-owner-messages.h +++ b/dali/internal/update/common/property-owner-messages.h @@ -98,9 +98,7 @@ public: /** * Virtual destructor */ - ~AnimatablePropertyMessage() override - { - } + ~AnimatablePropertyMessage() override = default; /** * @copydoc MessageBase::Process @@ -176,9 +174,7 @@ public: /** * Virtual destructor */ - ~AnimatablePropertyComponentMessage() override - { - } + ~AnimatablePropertyComponentMessage() override = default; /** * @copydoc MessageBase::Process diff --git a/dali/internal/update/common/property-owner.h b/dali/internal/update/common/property-owner.h index 5fbfc5a..d8f3330 100644 --- a/dali/internal/update/common/property-owner.h +++ b/dali/internal/update/common/property-owner.h @@ -80,8 +80,7 @@ public: /** * Virtual destructor, no deletion through this interface */ - virtual ~Observer() {} - + virtual ~Observer() = default; }; /** diff --git a/dali/internal/update/common/scene-graph-buffers.cpp b/dali/internal/update/common/scene-graph-buffers.cpp index c6e6161..a4194a1 100644 --- a/dali/internal/update/common/scene-graph-buffers.cpp +++ b/dali/internal/update/common/scene-graph-buffers.cpp @@ -36,9 +36,7 @@ SceneGraphBuffers::SceneGraphBuffers() { } -SceneGraphBuffers::~SceneGraphBuffers() -{ -} +SceneGraphBuffers::~SceneGraphBuffers() = default; void SceneGraphBuffers::Swap() { diff --git a/dali/internal/update/common/scene-graph-connection-change-propagator.cpp b/dali/internal/update/common/scene-graph-connection-change-propagator.cpp index 73a3c2e..b97e2e0 100644 --- a/dali/internal/update/common/scene-graph-connection-change-propagator.cpp +++ b/dali/internal/update/common/scene-graph-connection-change-propagator.cpp @@ -22,14 +22,9 @@ namespace Internal { namespace SceneGraph { +ConnectionChangePropagator::ConnectionChangePropagator() = default; -ConnectionChangePropagator::ConnectionChangePropagator() -{ -} - -ConnectionChangePropagator::~ConnectionChangePropagator() -{ -} +ConnectionChangePropagator::~ConnectionChangePropagator() = default; void ConnectionChangePropagator::Add(Observer& observer) { diff --git a/dali/internal/update/common/scene-graph-connection-change-propagator.h b/dali/internal/update/common/scene-graph-connection-change-propagator.h index 72f520e..3621541 100644 --- a/dali/internal/update/common/scene-graph-connection-change-propagator.h +++ b/dali/internal/update/common/scene-graph-connection-change-propagator.h @@ -59,8 +59,7 @@ public: /** * Virtual destructor, no deletion through this interface */ - virtual ~Observer() {} - + virtual ~Observer() = default; }; /** diff --git a/dali/internal/update/common/scene-graph-property-notification.cpp b/dali/internal/update/common/scene-graph-property-notification.cpp index ecc6ab9..c3e5fd9 100644 --- a/dali/internal/update/common/scene-graph-property-notification.cpp +++ b/dali/internal/update/common/scene-graph-property-notification.cpp @@ -122,9 +122,7 @@ PropertyNotification::PropertyNotification(Object& object, } } -PropertyNotification::~PropertyNotification() -{ -} +PropertyNotification::~PropertyNotification() = default; bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg ) { diff --git a/dali/internal/update/common/uniform-map.cpp b/dali/internal/update/common/uniform-map.cpp index 5045c2e..c68ac13 100644 --- a/dali/internal/update/common/uniform-map.cpp +++ b/dali/internal/update/common/uniform-map.cpp @@ -23,10 +23,7 @@ namespace Internal { namespace SceneGraph { - -UniformMap::UniformMap() -{ -} +UniformMap::UniformMap() = default; UniformMap::~UniformMap() { diff --git a/dali/internal/update/common/uniform-map.h b/dali/internal/update/common/uniform-map.h index b3afaa2..2df39e2 100644 --- a/dali/internal/update/common/uniform-map.h +++ b/dali/internal/update/common/uniform-map.h @@ -92,7 +92,7 @@ public: /** * Virtual destructor, no deletion through this interface */ - virtual ~Observer() {} + virtual ~Observer() = default; }; /** diff --git a/dali/internal/update/controllers/render-message-dispatcher.cpp b/dali/internal/update/controllers/render-message-dispatcher.cpp index 19d02c9..466697c 100644 --- a/dali/internal/update/controllers/render-message-dispatcher.cpp +++ b/dali/internal/update/controllers/render-message-dispatcher.cpp @@ -40,9 +40,7 @@ RenderMessageDispatcher::RenderMessageDispatcher( RenderManager& renderManager, { } -RenderMessageDispatcher::~RenderMessageDispatcher() -{ -} +RenderMessageDispatcher::~RenderMessageDispatcher() = default; void RenderMessageDispatcher::AddRenderer( OwnerPointer< Render::Renderer >& renderer ) { diff --git a/dali/internal/update/controllers/scene-controller-impl.cpp b/dali/internal/update/controllers/scene-controller-impl.cpp index 718f966..ee528e8 100644 --- a/dali/internal/update/controllers/scene-controller-impl.cpp +++ b/dali/internal/update/controllers/scene-controller-impl.cpp @@ -38,9 +38,7 @@ SceneControllerImpl::SceneControllerImpl( RenderMessageDispatcher& renderMessage { } -SceneControllerImpl::~SceneControllerImpl() -{ -} +SceneControllerImpl::~SceneControllerImpl() = default; } // namespace SceneGraph diff --git a/dali/internal/update/controllers/scene-controller.h b/dali/internal/update/controllers/scene-controller.h index a30bb49..5eb5aea 100644 --- a/dali/internal/update/controllers/scene-controller.h +++ b/dali/internal/update/controllers/scene-controller.h @@ -41,16 +41,12 @@ public: /** * Constructor */ - SceneController() - { - } + SceneController() = default; /** * Destructor */ - virtual ~SceneController() - { - } + virtual ~SceneController() = default; /** * Return the render message dispatcher diff --git a/dali/internal/update/gestures/gesture-properties.h b/dali/internal/update/gestures/gesture-properties.h index c1f73b3..41eb695 100644 --- a/dali/internal/update/gestures/gesture-properties.h +++ b/dali/internal/update/gestures/gesture-properties.h @@ -62,9 +62,7 @@ public: /** * Virtual destructor. */ - ~GestureProperty() override - { - } + ~GestureProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -151,9 +149,7 @@ public: /** * Virtual destructor. */ - ~GesturePropertyVector2() override - { - } + ~GesturePropertyVector2() override = default; /** * @copydoc Dali::PropertyInput::GetVector2() @@ -174,9 +170,7 @@ public: /** * Virtual destructor. */ - ~GesturePropertyBool() override - { - } + ~GesturePropertyBool() override = default; /** * @copydoc Dali::PropertyInput::GetBoolean() diff --git a/dali/internal/update/gestures/scene-graph-pan-gesture.h b/dali/internal/update/gestures/scene-graph-pan-gesture.h index 017a5de..8386102 100644 --- a/dali/internal/update/gestures/scene-graph-pan-gesture.h +++ b/dali/internal/update/gestures/scene-graph-pan-gesture.h @@ -77,19 +77,12 @@ public: */ struct Info { - Info() - { - } + Info() = default; /** * Copy constructor */ - Info( const Info& rhs ) - : velocity( rhs.velocity ), - displacement( rhs.displacement ), - position( rhs.position ) - { - } + Info(const Info& rhs) = default; /** * Assignment operator diff --git a/dali/internal/update/manager/frame-callback-processor.cpp b/dali/internal/update/manager/frame-callback-processor.cpp index 5c713f2..ca36566 100644 --- a/dali/internal/update/manager/frame-callback-processor.cpp +++ b/dali/internal/update/manager/frame-callback-processor.cpp @@ -42,9 +42,7 @@ FrameCallbackProcessor::FrameCallbackProcessor( UpdateManager& updateManager, Tr { } -FrameCallbackProcessor::~FrameCallbackProcessor() -{ -} +FrameCallbackProcessor::~FrameCallbackProcessor() = default; void FrameCallbackProcessor::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode ) { diff --git a/dali/internal/update/manager/free-list.h b/dali/internal/update/manager/free-list.h index 2072912..fb6cb56 100644 --- a/dali/internal/update/manager/free-list.h +++ b/dali/internal/update/manager/free-list.h @@ -49,8 +49,7 @@ struct FreeList /** * Destructor */ - ~FreeList() - {} + ~FreeList() = default; /** * Adds a new item to the list. If there is no more space in the vector it will diff --git a/dali/internal/update/manager/render-instruction-processor.cpp b/dali/internal/update/manager/render-instruction-processor.cpp index 4d1b55d..057e66e 100644 --- a/dali/internal/update/manager/render-instruction-processor.cpp +++ b/dali/internal/update/manager/render-instruction-processor.cpp @@ -351,9 +351,7 @@ RenderInstructionProcessor::RenderInstructionProcessor() mSortComparitors.PushBack( CompareItems3DWithClipping ); } -RenderInstructionProcessor::~RenderInstructionProcessor() -{ -} +RenderInstructionProcessor::~RenderInstructionProcessor() = default; inline void RenderInstructionProcessor::SortRenderItems( BufferIndex bufferIndex, RenderList& renderList, Layer& layer, bool respectClippingOrder ) { diff --git a/dali/internal/update/manager/render-task-processor.cpp b/dali/internal/update/manager/render-task-processor.cpp index 73ea5cf..f74337b 100644 --- a/dali/internal/update/manager/render-task-processor.cpp +++ b/dali/internal/update/manager/render-task-processor.cpp @@ -167,24 +167,14 @@ bool AddRenderablesForTask( BufferIndex updateBufferIndex, // Set the information in the node. node.SetClippingInformation( currentClippingId, clippingDepth, scissorDepth ); + RenderableContainer& target = DALI_LIKELY( inheritedDrawMode == DrawMode::NORMAL ) ? + layer->colorRenderables : layer->overlayRenderables; for( uint32_t i = 0; i < count; ++i ) { SceneGraph::Renderer* renderer = node.GetRendererAt( i ); + target.PushBack( Renderable( &node, renderer ) ); - // Normal is the more-likely draw mode to occur. - if( DALI_LIKELY( inheritedDrawMode == DrawMode::NORMAL ) ) - { - layer->colorRenderables.PushBack( Renderable( &node, renderer ) ); - } - else - { - layer->overlayRenderables.PushBack( Renderable( &node, renderer ) ); - } - - if( renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY ) - { - keepRendering = true; - } + keepRendering = keepRendering || ( renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY ); } // Recurse children. @@ -308,13 +298,9 @@ bool ProcessTasks( BufferIndex updateBufferIndex, } // Anonymous namespace. -RenderTaskProcessor::RenderTaskProcessor() -{ -} +RenderTaskProcessor::RenderTaskProcessor() = default; -RenderTaskProcessor::~RenderTaskProcessor() -{ -} +RenderTaskProcessor::~RenderTaskProcessor() = default; bool RenderTaskProcessor::Process( BufferIndex updateBufferIndex, RenderTaskList& renderTasks, diff --git a/dali/internal/update/manager/transform-manager-property.h b/dali/internal/update/manager/transform-manager-property.h index fc1583b..e2874d3 100644 --- a/dali/internal/update/manager/transform-manager-property.h +++ b/dali/internal/update/manager/transform-manager-property.h @@ -311,9 +311,7 @@ public: /** * Virtual destructor. */ - ~TransformManagerVector3Input() override - { - } + ~TransformManagerVector3Input() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -473,9 +471,7 @@ public: /** * Virtual destructor. */ - ~TransformManagerQuaternionInput() override - { - } + ~TransformManagerQuaternionInput() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -624,9 +620,7 @@ public: /** * Virtual destructor. */ - ~TransformManagerMatrixInput() override - { - } + ~TransformManagerMatrixInput() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() diff --git a/dali/internal/update/manager/transform-manager.cpp b/dali/internal/update/manager/transform-manager.cpp index c2cc4bb..277ccfb 100644 --- a/dali/internal/update/manager/transform-manager.cpp +++ b/dali/internal/update/manager/transform-manager.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -82,8 +82,7 @@ TransformManager::TransformManager() mReorder(false) {} -TransformManager::~TransformManager() -{} +TransformManager::~TransformManager() = default; TransformId TransformManager::CreateTransform() { @@ -229,8 +228,10 @@ void TransformManager::ResetToBaseValue() } } -void TransformManager::Update() +bool TransformManager::Update() { + bool componentsChanged = false; + if( mReorder ) { //If some transform component has change its parent or has been removed since last update @@ -322,8 +323,11 @@ void TransformManager::Update() mBoundingSpheres[i] = mWorld[i].GetTranslation(); mBoundingSpheres[i].w = Length( centerToEdgeWorldSpace ); + componentsChanged = componentsChanged || mComponentDirty[i]; mComponentDirty[i] = false; } + + return componentsChanged; } void TransformManager::SwapComponents( unsigned int i, unsigned int j ) @@ -382,31 +386,26 @@ Vector3& TransformManager::GetVector3PropertyValue( TransformId id, TransformMan case TRANSFORM_PROPERTY_POSITION: { TransformId index( mIds[id] ); - mComponentDirty[ index ] = true; return mTxComponentAnimatable[ index ].mPosition; } case TRANSFORM_PROPERTY_SCALE: { TransformId index( mIds[id] ); - mComponentDirty[ index ] = true; return mTxComponentAnimatable[ index ].mScale; } case TRANSFORM_PROPERTY_PARENT_ORIGIN: { TransformId index( mIds[id] ); - mComponentDirty[ index ] = true; return mTxComponentStatic[ index ].mParentOrigin; } case TRANSFORM_PROPERTY_ANCHOR_POINT: { TransformId index( mIds[id] ); - mComponentDirty[ index ] = true; return mTxComponentStatic[ index ].mAnchorPoint; } case TRANSFORM_PROPERTY_SIZE: { TransformId index( mIds[id] ); - mComponentDirty[ index ] = true; return mSize[ index ]; } default: @@ -835,7 +834,6 @@ void TransformManager::BakeZVector3PropertyValue( TransformId id, TransformManag Quaternion& TransformManager::GetQuaternionPropertyValue( TransformId id ) { TransformId index( mIds[id] ); - mComponentDirty[ index ] = true; return mTxComponentAnimatable[ index ].mOrientation; } diff --git a/dali/internal/update/manager/transform-manager.h b/dali/internal/update/manager/transform-manager.h index d003f57..068c39ff 100644 --- a/dali/internal/update/manager/transform-manager.h +++ b/dali/internal/update/manager/transform-manager.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_TRANSFORM_MANAGER_H /* - * 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. @@ -192,8 +192,9 @@ public: /** * Recomputes all world transform matrices + * @return true if any component has been changed in this frame, false otherwise */ - void Update(); + bool Update(); /** * Resets all the animatable properties to its base value diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 58fb0bc..a7ca327 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -189,7 +189,8 @@ struct UpdateManager::Impl previousUpdateScene( false ), renderTaskWaiting( false ), renderersAdded( false ), - surfaceRectChanged( false ) + surfaceRectChanged( false ), + renderingRequired( false ) { sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue ); @@ -298,6 +299,7 @@ struct UpdateManager::Impl bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing bool surfaceRectChanged; ///< True if the default surface rect is changed + bool renderingRequired; ///< True if required to render the current frame private: @@ -734,8 +736,10 @@ bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, uint32_t lastVSync return gestureUpdated; } -void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds ) +bool UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds ) { + bool animationActive = false; + auto&& iter = mImpl->animations.Begin(); bool animationLooped = false; @@ -747,6 +751,8 @@ void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds ) bool progressMarkerReached = false; animation->Update( bufferIndex, elapsedSeconds, looped, finished, progressMarkerReached ); + animationActive = animationActive || animation->IsActive(); + if ( progressMarkerReached ) { mImpl->notificationManager.QueueMessage( Internal::NotifyProgressReachedMessage( mImpl->animationPlaylist, animation ) ); @@ -772,6 +778,8 @@ void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds ) // The application should be notified by NotificationManager, in another thread mImpl->notificationManager.QueueCompleteNotification( &mImpl->animationPlaylist ); } + + return animationActive; } void UpdateManager::ConstrainCustomObjects( BufferIndex bufferIndex ) @@ -852,7 +860,7 @@ void UpdateManager::UpdateRenderers( BufferIndex bufferIndex ) //Apply constraints ConstrainPropertyOwner( *renderer, bufferIndex ); - renderer->PrepareRender( bufferIndex ); + mImpl->renderingRequired = renderer->PrepareRender( bufferIndex ) || mImpl->renderingRequired; } } @@ -884,17 +892,20 @@ uint32_t UpdateManager::Update( float elapsedSeconds, //Clear nodes/resources which were previously discarded mImpl->discardQueue.Clear( bufferIndex ); + bool isAnimationRunning = IsAnimationRunning(); + //Process Touches & Gestures const bool gestureUpdated = ProcessGestures( bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds ); bool updateScene = // The scene-graph requires an update if.. (mImpl->nodeDirtyFlags & RenderableUpdateFlags) || // ..nodes were dirty in previous frame OR - IsAnimationRunning() || // ..at least one animation is running OR + isAnimationRunning || // ..at least one animation is running OR mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR mImpl->frameCallbackProcessor || // ..a frame callback processor is existed OR gestureUpdated; // ..a gesture property was updated bool keepRendererRendering = false; + mImpl->renderingRequired = false; // Although the scene-graph may not require an update, we still need to synchronize double-buffered // values if the scene was updated in the previous frame. @@ -919,7 +930,7 @@ uint32_t UpdateManager::Update( float elapsedSeconds, if( updateScene || mImpl->previousUpdateScene ) { //Animate - Animate( bufferIndex, elapsedSeconds ); + bool animationActive = Animate( bufferIndex, elapsedSeconds ); //Constraint custom objects ConstrainCustomObjects( bufferIndex ); @@ -957,7 +968,10 @@ uint32_t UpdateManager::Update( float elapsedSeconds, UpdateRenderers( bufferIndex ); //Update the transformations of all the nodes - mImpl->transformManager.Update(); + if ( mImpl->transformManager.Update() ) + { + mImpl->nodeDirtyFlags |= NodePropertyFlags::TRANSFORM; + } //Process Property Notifications ProcessPropertyNotifications( bufferIndex ); @@ -982,7 +996,6 @@ uint32_t UpdateManager::Update( float elapsedSeconds, } } - std::size_t numberOfRenderInstructions = 0; for ( auto&& scene : mImpl->scenes ) { @@ -991,13 +1004,19 @@ uint32_t UpdateManager::Update( float elapsedSeconds, scene->scene->GetRenderInstructions().ResetAndReserve( bufferIndex, static_cast( scene->taskList->GetTasks().Count() ) ); - keepRendererRendering |= mImpl->renderTaskProcessor.Process( bufferIndex, - *scene->taskList, - *scene->root, - scene->sortedLayerList, - scene->scene->GetRenderInstructions(), - renderToFboEnabled, - isRenderingToFbo ); + // If there are animations running, only add render instruction if at least one animation is currently active (i.e. not delayed) + // or the nodes are dirty + if ( !isAnimationRunning || animationActive || mImpl->renderingRequired || (mImpl->nodeDirtyFlags & RenderableUpdateFlags) ) + { + keepRendererRendering |= mImpl->renderTaskProcessor.Process( bufferIndex, + *scene->taskList, + *scene->root, + scene->sortedLayerList, + scene->scene->GetRenderInstructions(), + renderToFboEnabled, + isRenderingToFbo ); + + } numberOfRenderInstructions += scene->scene->GetRenderInstructions().Count( bufferIndex ); } @@ -1139,6 +1158,11 @@ void UpdateManager::SetRenderingBehavior( DevelStage::Rendering renderingBehavio mImpl->renderingBehavior = renderingBehavior; } +void UpdateManager::RequestRendering() +{ + mImpl->renderingRequired = true; +} + void UpdateManager::SetLayerDepths( const SortedLayerPointers& layers, const Layer* rootLayer ) { for ( auto&& scene : mImpl->scenes ) diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index bf5d3e4..8f272d8 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -98,9 +98,7 @@ struct NodeDepthPair struct NodeDepths { - NodeDepths() - { - } + NodeDepths() = default; void Add( SceneGraph::Node* node, uint32_t sortedDepth ) { @@ -646,6 +644,14 @@ public: void SetRenderingBehavior( DevelStage::Rendering renderingBehavior ); /** + * Request to render the current frame + * @note This is a temporary workaround (to be removed in the future) to request the rendering of + * the current frame if the color or visibility of any actor is updated. It MUST NOT be used + * for any other purposes. + */ + void RequestRendering(); + + /** * Sets the depths of all layers. * @param layers The layers in depth order. * @param[in] rootLayer The root layer of the sorted layers. @@ -711,8 +717,9 @@ private: * Perform animation updates * @param[in] bufferIndex to use * @param[in] elapsedSeconds time since last frame + * @return true if at least one animations is currently active or false otherwise */ - void Animate( BufferIndex bufferIndex, float elapsedSeconds ); + bool Animate( BufferIndex bufferIndex, float elapsedSeconds ); /** * Applies constraints to CustomObjects @@ -1110,6 +1117,17 @@ inline void SetRenderingBehaviorMessage( UpdateManager& manager, DevelStage::Ren new (slot) LocalType( &manager, &UpdateManager::SetRenderingBehavior, renderingBehavior ); } +inline void RequestRenderingMessage( UpdateManager& manager ) +{ + using LocalType = Message; + + // Reserve some memory inside the message queue + uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); + + // Construct message in the message queue memory; note that delete should not be called on the return value + new (slot) LocalType( &manager, &UpdateManager::RequestRendering ); +} + /** * Create a message for setting the depth of a layer * @param[in] manager The update manager @@ -1328,9 +1346,7 @@ public: /** * Virtual destructor */ - ~IndexBufferMessage() override - { - } + ~IndexBufferMessage() override = default; /** * @copydoc MessageBase::Process diff --git a/dali/internal/update/manager/update-proxy-impl.cpp b/dali/internal/update/manager/update-proxy-impl.cpp index 11a5385..297391b 100644 --- a/dali/internal/update/manager/update-proxy-impl.cpp +++ b/dali/internal/update/manager/update-proxy-impl.cpp @@ -66,9 +66,7 @@ UpdateProxy::UpdateProxy( SceneGraph::UpdateManager& updateManager, SceneGraph:: { } -UpdateProxy::~UpdateProxy() -{ -} +UpdateProxy::~UpdateProxy() = default; bool UpdateProxy::GetPosition( uint32_t id, Vector3& position ) const { diff --git a/dali/internal/update/nodes/node-messages.cpp b/dali/internal/update/nodes/node-messages.cpp index edac935..2b6a666 100644 --- a/dali/internal/update/nodes/node-messages.cpp +++ b/dali/internal/update/nodes/node-messages.cpp @@ -35,9 +35,7 @@ NodePropertyMessageBase::NodePropertyMessageBase(UpdateManager& updateManager) { } -NodePropertyMessageBase::~NodePropertyMessageBase() -{ -} +NodePropertyMessageBase::~NodePropertyMessageBase() = default; } // namespace SceneGraph diff --git a/dali/internal/update/nodes/node-messages.h b/dali/internal/update/nodes/node-messages.h index c7da093..0fc422f 100644 --- a/dali/internal/update/nodes/node-messages.h +++ b/dali/internal/update/nodes/node-messages.h @@ -95,9 +95,7 @@ public: /** * Virtual destructor */ - ~NodePropertyMessage() override - { - } + ~NodePropertyMessage() override = default; /** * @copydoc MessageBase::Process @@ -175,9 +173,7 @@ public: /** * Virtual destructor */ - ~NodePropertyComponentMessage() override - { - } + ~NodePropertyComponentMessage() override = default; /** * @copydoc MessageBase::Process @@ -253,9 +249,7 @@ public: /** * Virtual destructor */ - ~NodeTransformPropertyMessage() override - { - } + ~NodeTransformPropertyMessage() override = default; /** * @copydoc MessageBase::Process @@ -331,9 +325,7 @@ public: /** * Virtual destructor */ - ~NodeTransformComponentMessage() override - { - } + ~NodeTransformComponentMessage() override = default; /** * @copydoc MessageBase::Process diff --git a/dali/internal/update/nodes/scene-graph-layer.cpp b/dali/internal/update/nodes/scene-graph-layer.cpp old mode 100755 new mode 100644 index 0c3c641..14cdc54 --- a/dali/internal/update/nodes/scene-graph-layer.cpp +++ b/dali/internal/update/nodes/scene-graph-layer.cpp @@ -56,9 +56,7 @@ Layer::Layer() mAllChildTransformsClean[ 1 ] = false; } -Layer::~Layer() -{ -} +Layer::~Layer() = default; void Layer::SetSortFunction( Dali::Layer::SortFunctionType function ) { diff --git a/dali/internal/update/render-tasks/scene-graph-camera.cpp b/dali/internal/update/render-tasks/scene-graph-camera.cpp index 5a4a529..e644bb3 100644 --- a/dali/internal/update/render-tasks/scene-graph-camera.cpp +++ b/dali/internal/update/render-tasks/scene-graph-camera.cpp @@ -185,9 +185,7 @@ Camera* Camera::New() return new Camera(); } -Camera::~Camera() -{ -} +Camera::~Camera() = default; void Camera::SetNode( const Node* node ) { diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp index 63d9118..eb495ba 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp @@ -49,9 +49,7 @@ RenderTaskList::RenderTaskList() { } -RenderTaskList::~RenderTaskList() -{ -} +RenderTaskList::~RenderTaskList() = default; void RenderTaskList::operator delete( void* ptr ) { diff --git a/dali/internal/update/rendering/scene-graph-renderer.cpp b/dali/internal/update/rendering/scene-graph-renderer.cpp index e821f6e..cce7464 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.cpp +++ b/dali/internal/update/rendering/scene-graph-renderer.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -181,7 +181,7 @@ void Renderer::operator delete( void* ptr ) } -void Renderer::PrepareRender( BufferIndex updateBufferIndex ) +bool Renderer::PrepareRender( BufferIndex updateBufferIndex ) { if( mRegenerateUniformMap == UNIFORM_MAP_READY ) { @@ -221,6 +221,8 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex ) mRegenerateUniformMap--; } + bool rendererUpdated = mUniformMapChanged[updateBufferIndex] || mResendFlag; + if( mResendFlag != 0 ) { if( mResendFlag & RESEND_GEOMETRY ) @@ -365,6 +367,8 @@ void Renderer::PrepareRender( BufferIndex updateBufferIndex ) mResendFlag = 0; } + + return rendererUpdated; } void Renderer::SetTextures( TextureSet* textureSet ) diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index b3ab63e..a06fa2a 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H /* - * 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. @@ -339,8 +339,9 @@ public: * Prepare the object for rendering. * This is called by the UpdateManager when an object is due to be rendered in the current frame. * @param[in] updateBufferIndex The current update buffer index. + * @return Whether this renderer has been updated in the current frame */ - void PrepareRender( BufferIndex updateBufferIndex ); + bool PrepareRender( BufferIndex updateBufferIndex ); /** * Retrieve the Render thread renderer diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index ee06114..0b455bd 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -33,9 +33,7 @@ namespace Dali { -Actor::Actor() -{ -} +Actor::Actor() = default; Actor Actor::New() { @@ -49,9 +47,7 @@ Actor Actor::DownCast(BaseHandle handle) return Actor(dynamic_cast(handle.GetObjectPtr())); } -Actor::~Actor() -{ -} +Actor::~Actor() = default; Actor::Actor(const Actor& copy) = default; diff --git a/dali/public-api/actors/camera-actor.cpp b/dali/public-api/actors/camera-actor.cpp index fab6bef..93c1cfd 100644 --- a/dali/public-api/actors/camera-actor.cpp +++ b/dali/public-api/actors/camera-actor.cpp @@ -47,18 +47,11 @@ CameraActor CameraActor::DownCast(BaseHandle handle) return CameraActor(dynamic_cast(handle.GetObjectPtr())); } -CameraActor::CameraActor() -{ -} +CameraActor::CameraActor() = default; -CameraActor::~CameraActor() -{ -} +CameraActor::~CameraActor() = default; -CameraActor::CameraActor(const CameraActor& copy) -: Actor(copy) -{ -} +CameraActor::CameraActor(const CameraActor& copy) = default; CameraActor& CameraActor::operator=(const CameraActor& rhs) { diff --git a/dali/public-api/actors/custom-actor-impl.cpp b/dali/public-api/actors/custom-actor-impl.cpp index cd36dbd..1ff533b 100644 --- a/dali/public-api/actors/custom-actor-impl.cpp +++ b/dali/public-api/actors/custom-actor-impl.cpp @@ -39,9 +39,7 @@ CustomActorImpl::CustomActorImpl(ActorFlags flags) { } -CustomActorImpl::~CustomActorImpl() -{ -} +CustomActorImpl::~CustomActorImpl() = default; void CustomActorImpl::Initialize(Internal::CustomActor& owner) { diff --git a/dali/public-api/actors/custom-actor.cpp b/dali/public-api/actors/custom-actor.cpp index 62de9b7..bceb7e1 100644 --- a/dali/public-api/actors/custom-actor.cpp +++ b/dali/public-api/actors/custom-actor.cpp @@ -38,18 +38,14 @@ TypeRegistration mType(typeid(Dali::CustomActor), typeid(Dali::Actor), Create); } // namespace -CustomActor::CustomActor() -{ -} +CustomActor::CustomActor() = default; CustomActor CustomActor::DownCast(BaseHandle handle) { return CustomActor(dynamic_cast(handle.GetObjectPtr())); } -CustomActor::~CustomActor() -{ -} +CustomActor::~CustomActor() = default; CustomActor::CustomActor(const CustomActor& copy) = default; diff --git a/dali/public-api/actors/layer.cpp b/dali/public-api/actors/layer.cpp index 3da3365..1f1be7c 100644 --- a/dali/public-api/actors/layer.cpp +++ b/dali/public-api/actors/layer.cpp @@ -25,9 +25,7 @@ namespace Dali { using Dali::Layer; -Layer::Layer() -{ -} +Layer::Layer() = default; Layer Layer::New() { @@ -41,9 +39,7 @@ Layer Layer::DownCast(BaseHandle handle) return Layer(dynamic_cast(handle.GetObjectPtr())); } -Layer::~Layer() -{ -} +Layer::~Layer() = default; Layer::Layer(const Layer& copy) = default; diff --git a/dali/public-api/animation/animation.cpp b/dali/public-api/animation/animation.cpp index 508280c..d1987c5 100644 --- a/dali/public-api/animation/animation.cpp +++ b/dali/public-api/animation/animation.cpp @@ -27,9 +27,7 @@ namespace Dali { -Animation::Animation() -{ -} +Animation::Animation() = default; Animation::Animation(Internal::Animation* animation) : BaseHandle(animation) @@ -48,9 +46,7 @@ Animation Animation::DownCast(BaseHandle handle) return Animation(dynamic_cast(handle.GetObjectPtr())); } -Animation::~Animation() -{ -} +Animation::~Animation() = default; Animation::Animation(const Animation& handle) = default; diff --git a/dali/public-api/animation/animation.h b/dali/public-api/animation/animation.h index f7ba6bc..73599f4 100644 --- a/dali/public-api/animation/animation.h +++ b/dali/public-api/animation/animation.h @@ -19,7 +19,7 @@ */ // EXTERNAL INCLUDES -#include // uint32_t +#include // uint32_t, uint8_t // INTERNAL INCLUDES #include @@ -131,7 +131,7 @@ public: * @brief Enumeration for what to do when the animation ends, is stopped, or is destroyed. * @SINCE_1_0.0 */ - enum EndAction + enum EndAction : uint8_t { BAKE, ///< When the animation ends, the animated property values are saved. @SINCE_1_0.0 DISCARD, ///< When the animation ends, the animated property values are forgotten. @SINCE_1_0.0 @@ -142,7 +142,7 @@ public: * @brief Enumeration for what interpolation method to use on key-frame animations. * @SINCE_1_0.0 */ - enum Interpolation + enum Interpolation : uint8_t { LINEAR, ///< Values in between key frames are interpolated using a linear polynomial. (Default) @SINCE_1_0.0 CUBIC ///< Values in between key frames are interpolated using a cubic polynomial. @SINCE_1_0.0 @@ -155,7 +155,7 @@ public: * * @SINCE_1_1.21 */ - enum State + enum State : uint8_t { STOPPED, ///< Animation has stopped @SINCE_1_1.21 PLAYING, ///< The animation is playing @SINCE_1_1.21 @@ -167,7 +167,7 @@ public: * * @SINCE_1_2.60 */ - enum LoopingMode + enum LoopingMode : uint8_t { RESTART, ///< When the animation arrives at the end in looping mode, the animation restarts from the beginning. @SINCE_1_2.60 AUTO_REVERSE ///< When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again. @SINCE_1_2.60 diff --git a/dali/public-api/animation/constraint.cpp b/dali/public-api/animation/constraint.cpp index 2622943..4175919 100644 --- a/dali/public-api/animation/constraint.cpp +++ b/dali/public-api/animation/constraint.cpp @@ -38,18 +38,14 @@ Internal::PropertyConstraint

* CreatePropertyConstraint(CallbackBase* func) const Constraint::RemoveAction Constraint::DEFAULT_REMOVE_ACTION = Constraint::BAKE; -Constraint::Constraint() -{ -} +Constraint::Constraint() = default; Constraint Constraint::Clone(Handle object) { return Constraint(GetImplementation(*this).Clone(GetImplementation(object))); } -Constraint::~Constraint() -{ -} +Constraint::~Constraint() = default; Constraint::Constraint(const Constraint& constraint) = default; diff --git a/dali/public-api/animation/constraints.h b/dali/public-api/animation/constraints.h index 63bcf0d..56571b7 100644 --- a/dali/public-api/animation/constraints.h +++ b/dali/public-api/animation/constraints.h @@ -47,9 +47,7 @@ struct EqualToConstraint * @brief Constructor. * @SINCE_1_0.0 */ - EqualToConstraint() - { - } + EqualToConstraint() = default; /** * @brief Overrides functor for float properties. diff --git a/dali/public-api/animation/key-frames.cpp b/dali/public-api/animation/key-frames.cpp index d2394dd..bff6040 100644 --- a/dali/public-api/animation/key-frames.cpp +++ b/dali/public-api/animation/key-frames.cpp @@ -37,13 +37,9 @@ KeyFrames KeyFrames::DownCast(BaseHandle handle) return KeyFrames(dynamic_cast(handle.GetObjectPtr())); } -KeyFrames::KeyFrames() -{ -} +KeyFrames::KeyFrames() = default; -KeyFrames::~KeyFrames() -{ -} +KeyFrames::~KeyFrames() = default; KeyFrames::KeyFrames(const KeyFrames& handle) = default; @@ -60,7 +56,7 @@ Property::Type KeyFrames::GetType() const void KeyFrames::Add(float time, Property::Value value) { - Add(time, value, AlphaFunction::DEFAULT); + Add(time, std::move(value), AlphaFunction::DEFAULT); } void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) diff --git a/dali/public-api/animation/linear-constrainer.cpp b/dali/public-api/animation/linear-constrainer.cpp index 8a99504..3f147a4 100644 --- a/dali/public-api/animation/linear-constrainer.cpp +++ b/dali/public-api/animation/linear-constrainer.cpp @@ -34,13 +34,9 @@ LinearConstrainer LinearConstrainer::DownCast(BaseHandle handle) return LinearConstrainer(dynamic_cast(handle.GetObjectPtr())); } -LinearConstrainer::LinearConstrainer() -{ -} +LinearConstrainer::LinearConstrainer() = default; -LinearConstrainer::~LinearConstrainer() -{ -} +LinearConstrainer::~LinearConstrainer() = default; LinearConstrainer::LinearConstrainer(const LinearConstrainer& handle) = default; diff --git a/dali/public-api/animation/path.cpp b/dali/public-api/animation/path.cpp index f16b7ba..d5666a3 100644 --- a/dali/public-api/animation/path.cpp +++ b/dali/public-api/animation/path.cpp @@ -34,13 +34,9 @@ Path Path::DownCast(BaseHandle handle) return Path(dynamic_cast(handle.GetObjectPtr())); } -Path::Path() -{ -} +Path::Path() = default; -Path::~Path() -{ -} +Path::~Path() = default; Path::Path(const Path& handle) = default; diff --git a/dali/public-api/animation/time-period.cpp b/dali/public-api/animation/time-period.cpp index f8f5840..4646b22 100644 --- a/dali/public-api/animation/time-period.cpp +++ b/dali/public-api/animation/time-period.cpp @@ -32,8 +32,6 @@ TimePeriod::TimePeriod(float delay, float duration) { } -TimePeriod::~TimePeriod() -{ -} +TimePeriod::~TimePeriod() = default; } // namespace Dali diff --git a/dali/public-api/common/dali-vector.cpp b/dali/public-api/common/dali-vector.cpp index e12f4ab..4f153aa 100644 --- a/dali/public-api/common/dali-vector.cpp +++ b/dali/public-api/common/dali-vector.cpp @@ -28,9 +28,7 @@ VectorBase::VectorBase() { } -VectorBase::~VectorBase() -{ -} +VectorBase::~VectorBase() = default; VectorBase::SizeType VectorBase::Capacity() const { diff --git a/dali/public-api/common/dali-vector.h b/dali/public-api/common/dali-vector.h index 5a61b64..8564cec 100644 --- a/dali/public-api/common/dali-vector.h +++ b/dali/public-api/common/dali-vector.h @@ -234,17 +234,13 @@ protected: // API for deriving classes * @brief Empty constructor. * @SINCE_1_0.0 */ - VectorAlgorithms() - { - } + VectorAlgorithms() = default; /** * @brief Empty destructor. * @SINCE_1_0.0 */ - ~VectorAlgorithms() - { - } + ~VectorAlgorithms() = default; /** * @brief Copy vector contents. @@ -392,12 +388,8 @@ template<> class VectorAlgorithms : public VectorBase { private: - VectorAlgorithms() - { - } - ~VectorAlgorithms() - { - } + VectorAlgorithms() = default; + ~VectorAlgorithms() = default; }; /// @endcond @@ -433,9 +425,7 @@ public: // API * @brief Default constructor. Does not allocate any space. * @SINCE_1_0.0 */ - Vector() - { - } + Vector() = default; /** * @brief Destructor. Releases the allocated space. diff --git a/dali/public-api/dali-core-version.cpp b/dali/public-api/dali-core-version.cpp index 8ff52e1..4d04632 100644 --- a/dali/public-api/dali-core-version.cpp +++ b/dali/public-api/dali-core-version.cpp @@ -25,9 +25,9 @@ namespace Dali { -const uint32_t CORE_MAJOR_VERSION = 1; -const uint32_t CORE_MINOR_VERSION = 9; -const uint32_t CORE_MICRO_VERSION = 34; +const uint32_t CORE_MAJOR_VERSION = 2; +const uint32_t CORE_MINOR_VERSION = 0; +const uint32_t CORE_MICRO_VERSION = 1; const char* const CORE_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/dali/public-api/events/gesture-detector.cpp b/dali/public-api/events/gesture-detector.cpp index 36a838a..63b3fd1 100644 --- a/dali/public-api/events/gesture-detector.cpp +++ b/dali/public-api/events/gesture-detector.cpp @@ -28,23 +28,16 @@ GestureDetector::GestureDetector(Internal::GestureDetector* internal) { } -GestureDetector::GestureDetector() -{ -} +GestureDetector::GestureDetector() = default; GestureDetector GestureDetector::DownCast(BaseHandle handle) { return GestureDetector(dynamic_cast(handle.GetObjectPtr())); } -GestureDetector::~GestureDetector() -{ -} +GestureDetector::~GestureDetector() = default; -GestureDetector::GestureDetector(const GestureDetector& handle) -: Handle(handle) -{ -} +GestureDetector::GestureDetector(const GestureDetector& handle) = default; GestureDetector& GestureDetector::operator=(const GestureDetector& rhs) { diff --git a/dali/public-api/events/gesture.cpp b/dali/public-api/events/gesture.cpp index be6badd..20c1ca4 100644 --- a/dali/public-api/events/gesture.cpp +++ b/dali/public-api/events/gesture.cpp @@ -23,9 +23,7 @@ namespace Dali { -Gesture::Gesture() -{ -} +Gesture::Gesture() = default; Gesture::Gesture(Internal::Gesture* internal) : BaseHandle(internal) @@ -40,9 +38,7 @@ Gesture& Gesture::operator=(const Gesture& rhs) = default; Gesture& Gesture::operator=(Gesture&& rhs) = default; -Gesture::~Gesture() -{ -} +Gesture::~Gesture() = default; GestureType::Value Gesture::GetType() const { diff --git a/dali/public-api/events/hover-event.cpp b/dali/public-api/events/hover-event.cpp index 21968dc..754db44 100644 --- a/dali/public-api/events/hover-event.cpp +++ b/dali/public-api/events/hover-event.cpp @@ -33,9 +33,7 @@ HoverEvent::HoverEvent(const HoverEvent& rhs) = default; HoverEvent::HoverEvent(HoverEvent&& rhs) = default; -HoverEvent::~HoverEvent() -{ -} +HoverEvent::~HoverEvent() = default; HoverEvent& HoverEvent::operator=(const HoverEvent& rhs) = default; diff --git a/dali/public-api/events/key-event.cpp b/dali/public-api/events/key-event.cpp index 7235d4d..fe6bfcf 100644 --- a/dali/public-api/events/key-event.cpp +++ b/dali/public-api/events/key-event.cpp @@ -32,9 +32,7 @@ KeyEvent::KeyEvent(const KeyEvent& rhs) = default; KeyEvent::KeyEvent(KeyEvent&& rhs) = default; -KeyEvent::~KeyEvent() -{ -} +KeyEvent::~KeyEvent() = default; KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) = default; diff --git a/dali/public-api/events/long-press-gesture-detector.cpp b/dali/public-api/events/long-press-gesture-detector.cpp index ca7b4e3..abc7ee4 100644 --- a/dali/public-api/events/long-press-gesture-detector.cpp +++ b/dali/public-api/events/long-press-gesture-detector.cpp @@ -28,9 +28,7 @@ LongPressGestureDetector::LongPressGestureDetector(Internal::LongPressGestureDet { } -LongPressGestureDetector::LongPressGestureDetector() -{ -} +LongPressGestureDetector::LongPressGestureDetector() = default; LongPressGestureDetector LongPressGestureDetector::New() { @@ -58,14 +56,9 @@ LongPressGestureDetector LongPressGestureDetector::DownCast(BaseHandle handle) return LongPressGestureDetector(dynamic_cast(handle.GetObjectPtr())); } -LongPressGestureDetector::~LongPressGestureDetector() -{ -} +LongPressGestureDetector::~LongPressGestureDetector() = default; -LongPressGestureDetector::LongPressGestureDetector(const LongPressGestureDetector& handle) -: GestureDetector(handle) -{ -} +LongPressGestureDetector::LongPressGestureDetector(const LongPressGestureDetector& handle) = default; LongPressGestureDetector& LongPressGestureDetector::operator=(const LongPressGestureDetector& rhs) { diff --git a/dali/public-api/events/pan-gesture-detector.cpp b/dali/public-api/events/pan-gesture-detector.cpp index 343cf98..a129a81 100644 --- a/dali/public-api/events/pan-gesture-detector.cpp +++ b/dali/public-api/events/pan-gesture-detector.cpp @@ -36,9 +36,7 @@ PanGestureDetector::PanGestureDetector(Internal::PanGestureDetector* internal) { } -PanGestureDetector::PanGestureDetector() -{ -} +PanGestureDetector::PanGestureDetector() = default; PanGestureDetector PanGestureDetector::New() { @@ -52,14 +50,9 @@ PanGestureDetector PanGestureDetector::DownCast(BaseHandle handle) return PanGestureDetector(dynamic_cast(handle.GetObjectPtr())); } -PanGestureDetector::~PanGestureDetector() -{ -} +PanGestureDetector::~PanGestureDetector() = default; -PanGestureDetector::PanGestureDetector(const PanGestureDetector& handle) -: GestureDetector(handle) -{ -} +PanGestureDetector::PanGestureDetector(const PanGestureDetector& handle) = default; PanGestureDetector& PanGestureDetector::operator=(const PanGestureDetector& rhs) { diff --git a/dali/public-api/events/pinch-gesture-detector.cpp b/dali/public-api/events/pinch-gesture-detector.cpp index 933f336..f2244f6 100644 --- a/dali/public-api/events/pinch-gesture-detector.cpp +++ b/dali/public-api/events/pinch-gesture-detector.cpp @@ -28,9 +28,7 @@ PinchGestureDetector::PinchGestureDetector(Internal::PinchGestureDetector* inter { } -PinchGestureDetector::PinchGestureDetector() -{ -} +PinchGestureDetector::PinchGestureDetector() = default; PinchGestureDetector PinchGestureDetector::New() { @@ -44,14 +42,9 @@ PinchGestureDetector PinchGestureDetector::DownCast(BaseHandle handle) return PinchGestureDetector(dynamic_cast(handle.GetObjectPtr())); } -PinchGestureDetector::~PinchGestureDetector() -{ -} +PinchGestureDetector::~PinchGestureDetector() = default; -PinchGestureDetector::PinchGestureDetector(const PinchGestureDetector& handle) -: GestureDetector(handle) -{ -} +PinchGestureDetector::PinchGestureDetector(const PinchGestureDetector& handle) = default; PinchGestureDetector& PinchGestureDetector::operator=(const PinchGestureDetector& rhs) { diff --git a/dali/public-api/events/rotation-gesture-detector.cpp b/dali/public-api/events/rotation-gesture-detector.cpp index 778fac4..0f84368 100644 --- a/dali/public-api/events/rotation-gesture-detector.cpp +++ b/dali/public-api/events/rotation-gesture-detector.cpp @@ -28,9 +28,7 @@ RotationGestureDetector::RotationGestureDetector(Internal::RotationGestureDetect { } -RotationGestureDetector::RotationGestureDetector() -{ -} +RotationGestureDetector::RotationGestureDetector() = default; RotationGestureDetector RotationGestureDetector::New() { @@ -44,14 +42,9 @@ RotationGestureDetector RotationGestureDetector::DownCast(BaseHandle handle) return RotationGestureDetector(dynamic_cast(handle.GetObjectPtr())); } -RotationGestureDetector::~RotationGestureDetector() -{ -} +RotationGestureDetector::~RotationGestureDetector() = default; -RotationGestureDetector::RotationGestureDetector(const RotationGestureDetector& handle) -: GestureDetector(handle) -{ -} +RotationGestureDetector::RotationGestureDetector(const RotationGestureDetector& handle) = default; RotationGestureDetector& RotationGestureDetector::operator=(const RotationGestureDetector& rhs) { diff --git a/dali/public-api/events/tap-gesture-detector.cpp b/dali/public-api/events/tap-gesture-detector.cpp index ee42cc1..fa9376d 100644 --- a/dali/public-api/events/tap-gesture-detector.cpp +++ b/dali/public-api/events/tap-gesture-detector.cpp @@ -28,9 +28,7 @@ TapGestureDetector::TapGestureDetector(Internal::TapGestureDetector* internal) { } -TapGestureDetector::TapGestureDetector() -{ -} +TapGestureDetector::TapGestureDetector() = default; TapGestureDetector TapGestureDetector::New() { @@ -51,14 +49,9 @@ TapGestureDetector TapGestureDetector::DownCast(BaseHandle handle) return TapGestureDetector(dynamic_cast(handle.GetObjectPtr())); } -TapGestureDetector::~TapGestureDetector() -{ -} +TapGestureDetector::~TapGestureDetector() = default; -TapGestureDetector::TapGestureDetector(const TapGestureDetector& handle) -: GestureDetector(handle) -{ -} +TapGestureDetector::TapGestureDetector(const TapGestureDetector& handle) = default; TapGestureDetector& TapGestureDetector::operator=(const TapGestureDetector& rhs) { diff --git a/dali/public-api/events/wheel-event.cpp b/dali/public-api/events/wheel-event.cpp index e179135..95436f5 100644 --- a/dali/public-api/events/wheel-event.cpp +++ b/dali/public-api/events/wheel-event.cpp @@ -32,9 +32,7 @@ WheelEvent::WheelEvent(const WheelEvent& rhs) = default; WheelEvent::WheelEvent(WheelEvent&& rhs) = default; -WheelEvent::~WheelEvent() -{ -} +WheelEvent::~WheelEvent() = default; WheelEvent& WheelEvent::operator=(const WheelEvent& rhs) = default; diff --git a/dali/public-api/images/native-image-interface.h b/dali/public-api/images/native-image-interface.h index 249cd91..717e365 100644 --- a/dali/public-api/images/native-image-interface.h +++ b/dali/public-api/images/native-image-interface.h @@ -163,9 +163,7 @@ protected: * The implementation should destroy the NativeImage resources. * @SINCE_1_0.0 */ - ~NativeImageInterface() override - { - } + ~NativeImageInterface() override = default; }; /** diff --git a/dali/public-api/images/pixel-data.cpp b/dali/public-api/images/pixel-data.cpp index 8b401bd..7086e7d 100644 --- a/dali/public-api/images/pixel-data.cpp +++ b/dali/public-api/images/pixel-data.cpp @@ -34,13 +34,9 @@ PixelData PixelData::New(uint8_t* buffer, return PixelData(internal.Get()); } -PixelData::PixelData() -{ -} +PixelData::PixelData() = default; -PixelData::~PixelData() -{ -} +PixelData::~PixelData() = default; PixelData::PixelData(Internal::PixelData* internal) : BaseHandle(internal) diff --git a/dali/public-api/math/matrix3.h b/dali/public-api/math/matrix3.h index 693857a..8876bc1 100644 --- a/dali/public-api/math/matrix3.h +++ b/dali/public-api/math/matrix3.h @@ -159,9 +159,7 @@ public: * @brief Destructor. * @SINCE_1_0.0 */ - ~Matrix3() - { - } + ~Matrix3() = default; /** * @brief Sets the matrix to the identity matrix. diff --git a/dali/public-api/math/quaternion.cpp b/dali/public-api/math/quaternion.cpp index eb68c50..e682660 100644 --- a/dali/public-api/math/quaternion.cpp +++ b/dali/public-api/math/quaternion.cpp @@ -113,9 +113,7 @@ Quaternion::Quaternion(const Vector3& v0, const Vector3& v1) } } -Quaternion::~Quaternion() -{ -} +Quaternion::~Quaternion() = default; bool Quaternion::IsIdentity() const { diff --git a/dali/public-api/object/base-handle.cpp b/dali/public-api/object/base-handle.cpp index c9675ed..121cc0d 100644 --- a/dali/public-api/object/base-handle.cpp +++ b/dali/public-api/object/base-handle.cpp @@ -33,13 +33,9 @@ BaseHandle::BaseHandle(Dali::BaseObject* handle) { } -BaseHandle::BaseHandle() -{ -} +BaseHandle::BaseHandle() = default; -BaseHandle::~BaseHandle() -{ -} +BaseHandle::~BaseHandle() = default; BaseHandle::BaseHandle(const BaseHandle& handle) = default; diff --git a/dali/public-api/object/base-object.cpp b/dali/public-api/object/base-object.cpp index 41d00e6..98ed327 100644 --- a/dali/public-api/object/base-object.cpp +++ b/dali/public-api/object/base-object.cpp @@ -34,9 +34,7 @@ BaseObject::BaseObject() { } -BaseObject::~BaseObject() -{ -} +BaseObject::~BaseObject() = default; void BaseObject::RegisterObject() { diff --git a/dali/public-api/object/handle.cpp b/dali/public-api/object/handle.cpp index d765582..b09c0e5 100644 --- a/dali/public-api/object/handle.cpp +++ b/dali/public-api/object/handle.cpp @@ -33,18 +33,14 @@ Handle::Handle(Dali::Internal::Object* handle) { } -Handle::Handle() -{ -} +Handle::Handle() = default; Handle Handle::New() { return Handle(Internal::Object::New().Get()); } -Handle::~Handle() -{ -} +Handle::~Handle() = default; Handle::Handle(const Handle& handle) = default; diff --git a/dali/public-api/object/object-registry.cpp b/dali/public-api/object/object-registry.cpp index 7830abd..b7f9a37 100644 --- a/dali/public-api/object/object-registry.cpp +++ b/dali/public-api/object/object-registry.cpp @@ -23,13 +23,9 @@ namespace Dali { -ObjectRegistry::ObjectRegistry() -{ -} +ObjectRegistry::ObjectRegistry() = default; -ObjectRegistry::~ObjectRegistry() -{ -} +ObjectRegistry::~ObjectRegistry() = default; ObjectRegistry::ObjectRegistry(const ObjectRegistry& copy) = default; diff --git a/dali/public-api/object/property-conditions.cpp b/dali/public-api/object/property-conditions.cpp index 46ee48f..9929d6e 100644 --- a/dali/public-api/object/property-conditions.cpp +++ b/dali/public-api/object/property-conditions.cpp @@ -29,9 +29,7 @@ PropertyCondition::PropertyCondition() { } -PropertyCondition::~PropertyCondition() -{ -} +PropertyCondition::~PropertyCondition() = default; PropertyCondition::PropertyCondition(const PropertyCondition& handle) = default; diff --git a/dali/public-api/object/property-input.cpp b/dali/public-api/object/property-input.cpp index 3b6c820..1f83cb5 100644 --- a/dali/public-api/object/property-input.cpp +++ b/dali/public-api/object/property-input.cpp @@ -20,8 +20,6 @@ namespace Dali { -PropertyInput::~PropertyInput() -{ -} +PropertyInput::~PropertyInput() = default; } // namespace Dali diff --git a/dali/public-api/object/property-map.cpp b/dali/public-api/object/property-map.cpp index 4e9aaaa..7a500c6 100644 --- a/dali/public-api/object/property-map.cpp +++ b/dali/public-api/object/property-map.cpp @@ -98,22 +98,16 @@ bool Property::Map::Empty() const return mImpl->mStringValueContainer.empty() && mImpl->mIndexValueContainer.empty(); } -void Property::Map::Insert(const char* key, const Value& value) +void Property::Map::Insert(std::string key, Value value) { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - mImpl->mStringValueContainer.push_back(std::make_pair(key, value)); + mImpl->mStringValueContainer.push_back(std::make_pair(std::move(key), std::move(value))); } -void Property::Map::Insert(const std::string& key, const Value& value) +void Property::Map::Insert(Property::Index key, Value value) { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - mImpl->mStringValueContainer.push_back(std::make_pair(key, value)); -} - -void Property::Map::Insert(Property::Index key, const Value& value) -{ - DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - mImpl->mIndexValueContainer.push_back(std::make_pair(key, value)); + mImpl->mIndexValueContainer.push_back(std::make_pair(key, std::move(value))); } Property::Value& Property::Map::GetValue(SizeType position) const @@ -194,19 +188,17 @@ KeyValuePair Property::Map::GetKeyValue(SizeType position) const } else { - Key key(mImpl->mIndexValueContainer[position - numStringKeys].first); - KeyValuePair keyValue(key, mImpl->mIndexValueContainer[position - numStringKeys].second); - return keyValue; + return mImpl->mIndexValueContainer[position - numStringKeys]; } } -Property::Value* Property::Map::Find(const char* key) const +Property::Value* Property::Map::Find(std::string_view key) const { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); for(auto&& iter : mImpl->mStringValueContainer) { - if(iter.first == key) + if(key == iter.first) { return &iter.second; } @@ -214,11 +206,6 @@ Property::Value* Property::Map::Find(const char* key) const return nullptr; // Not found } -Property::Value* Property::Map::Find(const std::string& key) const -{ - return Find(key.c_str()); -} - Property::Value* Property::Map::Find(Property::Index key) const { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); @@ -233,7 +220,7 @@ Property::Value* Property::Map::Find(Property::Index key) const return nullptr; // Not found } -Property::Value* Property::Map::Find(Property::Index indexKey, const std::string& stringKey) const +Property::Value* Property::Map::Find(Property::Index indexKey, std::string_view stringKey) const { Property::Value* valuePtr = Find(indexKey); if(!valuePtr) @@ -243,13 +230,13 @@ Property::Value* Property::Map::Find(Property::Index indexKey, const std::string return valuePtr; } -Property::Value* Property::Map::Find(const std::string& key, Property::Type type) const +Property::Value* Property::Map::Find(std::string_view key, Property::Type type) const { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); for(auto&& iter : mImpl->mStringValueContainer) { - if((iter.second.GetType() == type) && (iter.first == key)) + if((iter.second.GetType() == type) && (key == iter.first)) { return &iter.second; } @@ -306,7 +293,7 @@ void Property::Map::Merge(const Property::Map& from) } } -const Property::Value& Property::Map::operator[](const std::string& key) const +const Property::Value& Property::Map::operator[](std::string_view key) const { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); @@ -321,7 +308,7 @@ const Property::Value& Property::Map::operator[](const std::string& key) const DALI_ASSERT_ALWAYS(!"Invalid Key"); } -Property::Value& Property::Map::operator[](const std::string& key) +Property::Value& Property::Map::operator[](std::string_view key) { DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); @@ -334,8 +321,8 @@ Property::Value& Property::Map::operator[](const std::string& key) } // Create and return reference to new value - mImpl->mStringValueContainer.push_back(std::make_pair(key, Property::Value())); - return (mImpl->mStringValueContainer.end() - 1)->second; + mImpl->mStringValueContainer.push_back(std::make_pair(std::string(key), Property::Value())); + return mImpl->mStringValueContainer.back().second; } const Property::Value& Property::Map::operator[](Property::Index key) const @@ -367,7 +354,7 @@ Property::Value& Property::Map::operator[](Property::Index key) // Create and return reference to new value mImpl->mIndexValueContainer.push_back(std::make_pair(key, Property::Value())); - return (mImpl->mIndexValueContainer.end() - 1)->second; + return mImpl->mIndexValueContainer.back().second; } Property::Map& Property::Map::operator=(const Property::Map& other) diff --git a/dali/public-api/object/property-map.h b/dali/public-api/object/property-map.h index 115a7fa..45431f5 100644 --- a/dali/public-api/object/property-map.h +++ b/dali/public-api/object/property-map.h @@ -22,6 +22,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -109,17 +110,7 @@ public: * @param[in] key The key to insert * @param[in] value The value to insert */ - void Insert(const char* key, const Value& value); - - /** - * @brief Inserts the key-value pair in the Map, with the key type as string. - * - * Does not check for duplicates. - * @SINCE_1_0.0 - * @param[in] key The key to insert - * @param[in] value The value to insert - */ - void Insert(const std::string& key, const Value& value); + void Insert(std::string key, Value value); /** * @brief Inserts the key-value pair in the Map, with the key type as index. @@ -129,7 +120,7 @@ public: * @param[in] key The key to insert * @param[in] value The value to insert */ - void Insert(Property::Index key, const Value& value); + void Insert(Property::Index key, Value value); /** * @brief Inserts the key-value pair in the Map, with the key type as string. @@ -140,24 +131,9 @@ public: * @param value to insert * @return a reference to this object */ - inline Property::Map& Add(const char* key, const Value& value) + Property::Map& Add(std::string key, Value value) { - Insert(key, value); - return *this; - } - - /** - * @brief Inserts the key-value pair in the Map, with the key type as string. - * - * Does not check for duplicates - * @SINCE_1_2.5 - * @param key to insert - * @param value to insert - * @return a reference to this object - */ - inline Property::Map& Add(const std::string& key, const Value& value) - { - Insert(key, value); + Insert(std::move(key), std::move(value)); return *this; } @@ -170,9 +146,9 @@ public: * @param value to insert * @return a reference to this object */ - inline Property::Map& Add(Property::Index key, const Value& value) + Property::Map& Add(Property::Index key, Value value) { - Insert(key, value); + Insert(key, std::move(value)); return *this; } @@ -243,17 +219,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find(const char* key) const; - - /** - * @brief Finds the value for the specified key if it exists. - * - * @SINCE_1_0.0 - * @param[in] key The key to find - * - * @return A const pointer to the value if it exists, NULL otherwise - */ - Value* Find(const std::string& key) const; + Value* Find(std::string_view key) const; /** * @brief Finds the value for the specified key if it exists. @@ -276,7 +242,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find(Property::Index indexKey, const std::string& stringKey) const; + Value* Find(Property::Index indexKey, std::string_view stringKey) const; /** * @brief Finds the value for the specified key if it exists and its type is type. @@ -287,7 +253,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find(const std::string& key, Property::Type type) const; + Value* Find(std::string_view key, Property::Type type) const; /** * @brief Finds the value for the specified key if it exists and its type is type. @@ -326,7 +292,7 @@ public: * * @note Will assert if invalid-key is given. */ - const Value& operator[](const std::string& key) const; + const Value& operator[](std::string_view key) const; /** * @brief Operator to access the element with the specified string key. @@ -338,7 +304,7 @@ public: * * @note If an element with the key does not exist, then it is created. */ - Value& operator[](const std::string& key); + Value& operator[](std::string_view key); /** * @brief Const operator to access element with the specified index key. diff --git a/dali/public-api/object/property-notification.cpp b/dali/public-api/object/property-notification.cpp index 682b845..6f9e26f 100644 --- a/dali/public-api/object/property-notification.cpp +++ b/dali/public-api/object/property-notification.cpp @@ -29,9 +29,7 @@ namespace Dali { -PropertyNotification::PropertyNotification() -{ -} +PropertyNotification::PropertyNotification() = default; PropertyNotification::PropertyNotification(Internal::PropertyNotification* propertyNotification) : BaseHandle(propertyNotification) @@ -43,9 +41,7 @@ PropertyNotification PropertyNotification::DownCast(BaseHandle handle) return PropertyNotification(dynamic_cast(handle.GetObjectPtr())); } -PropertyNotification::~PropertyNotification() -{ -} +PropertyNotification::~PropertyNotification() = default; PropertyNotification::PropertyNotification(const PropertyNotification& copy) = default; diff --git a/dali/public-api/object/property.cpp b/dali/public-api/object/property.cpp index 77aa921..37a272a 100644 --- a/dali/public-api/object/property.cpp +++ b/dali/public-api/object/property.cpp @@ -53,8 +53,6 @@ Property::Property(Handle& obj, const std::string& propertyName, int32_t compInd propertyIndex = object.GetPropertyIndex(propertyName); } -Property::~Property() -{ -} +Property::~Property() = default; } // namespace Dali diff --git a/dali/public-api/object/type-info.cpp b/dali/public-api/object/type-info.cpp index 76e147c..50a1fc9 100644 --- a/dali/public-api/object/type-info.cpp +++ b/dali/public-api/object/type-info.cpp @@ -25,13 +25,9 @@ namespace Dali { -TypeInfo::TypeInfo() -{ -} +TypeInfo::TypeInfo() = default; -TypeInfo::~TypeInfo() -{ -} +TypeInfo::~TypeInfo() = default; TypeInfo::TypeInfo(const TypeInfo& copy) = default; diff --git a/dali/public-api/object/type-registry.cpp b/dali/public-api/object/type-registry.cpp index e9a0ab2..93e0d0e 100644 --- a/dali/public-api/object/type-registry.cpp +++ b/dali/public-api/object/type-registry.cpp @@ -27,13 +27,9 @@ namespace Dali { -TypeRegistry::TypeRegistry() -{ -} +TypeRegistry::TypeRegistry() = default; -TypeRegistry::~TypeRegistry() -{ -} +TypeRegistry::~TypeRegistry() = default; TypeRegistry::TypeRegistry(const TypeRegistry& copy) = default; diff --git a/dali/public-api/object/weak-handle.h b/dali/public-api/object/weak-handle.h index 91a0795..b3a8aa7 100644 --- a/dali/public-api/object/weak-handle.h +++ b/dali/public-api/object/weak-handle.h @@ -162,9 +162,7 @@ public: /** * @copydoc Dali::WeakHandleBase::~WeakHandleBase() */ - ~WeakHandle() - { - } + ~WeakHandle() = default; /** * @copydoc Dali::WeakHandleBase::WeakHandleBase(const WeakHandleBase&) diff --git a/dali/public-api/render-tasks/render-task-list.cpp b/dali/public-api/render-tasks/render-task-list.cpp index 60bfeda..eabd958 100644 --- a/dali/public-api/render-tasks/render-task-list.cpp +++ b/dali/public-api/render-tasks/render-task-list.cpp @@ -23,18 +23,14 @@ namespace Dali { -RenderTaskList::RenderTaskList() -{ -} +RenderTaskList::RenderTaskList() = default; RenderTaskList RenderTaskList::DownCast(BaseHandle handle) { return RenderTaskList(dynamic_cast(handle.GetObjectPtr())); } -RenderTaskList::~RenderTaskList() -{ -} +RenderTaskList::~RenderTaskList() = default; RenderTaskList::RenderTaskList(const RenderTaskList& handle) = default; diff --git a/dali/public-api/render-tasks/render-task.cpp b/dali/public-api/render-tasks/render-task.cpp index bba07a4..1688b26 100644 --- a/dali/public-api/render-tasks/render-task.cpp +++ b/dali/public-api/render-tasks/render-task.cpp @@ -48,18 +48,14 @@ const bool RenderTask::DEFAULT_CLEAR_ENABLED = false; const bool RenderTask::DEFAULT_CULL_MODE = true; const uint32_t RenderTask::DEFAULT_REFRESH_RATE = REFRESH_ALWAYS; -RenderTask::RenderTask() -{ -} +RenderTask::RenderTask() = default; RenderTask RenderTask::DownCast(BaseHandle handle) { return RenderTask(dynamic_cast(handle.GetObjectPtr())); } -RenderTask::~RenderTask() -{ -} +RenderTask::~RenderTask() = default; RenderTask::RenderTask(const RenderTask& handle) = default; diff --git a/dali/public-api/rendering/frame-buffer.cpp b/dali/public-api/rendering/frame-buffer.cpp index 8fc7aeb..4b45a92 100644 --- a/dali/public-api/rendering/frame-buffer.cpp +++ b/dali/public-api/rendering/frame-buffer.cpp @@ -56,13 +56,9 @@ FrameBuffer FrameBuffer::New(uint32_t width, uint32_t height, Attachment::Mask a return FrameBuffer(frameBuffer.Get()); } -FrameBuffer::FrameBuffer() -{ -} +FrameBuffer::FrameBuffer() = default; -FrameBuffer::~FrameBuffer() -{ -} +FrameBuffer::~FrameBuffer() = default; FrameBuffer::FrameBuffer(const FrameBuffer& handle) = default; diff --git a/dali/public-api/rendering/geometry.cpp b/dali/public-api/rendering/geometry.cpp index 09e9303..6c82097 100644 --- a/dali/public-api/rendering/geometry.cpp +++ b/dali/public-api/rendering/geometry.cpp @@ -29,13 +29,9 @@ Geometry Geometry::New() return Geometry(geometry.Get()); } -Geometry::Geometry() -{ -} +Geometry::Geometry() = default; -Geometry::~Geometry() -{ -} +Geometry::~Geometry() = default; Geometry::Geometry(const Geometry& handle) = default; diff --git a/dali/public-api/rendering/renderer.cpp b/dali/public-api/rendering/renderer.cpp index be49c1b..f857986 100644 --- a/dali/public-api/rendering/renderer.cpp +++ b/dali/public-api/rendering/renderer.cpp @@ -31,13 +31,9 @@ Renderer Renderer::New(Geometry& geometry, Shader& shader) return Renderer(renderer.Get()); } -Renderer::Renderer() -{ -} +Renderer::Renderer() = default; -Renderer::~Renderer() -{ -} +Renderer::~Renderer() = default; Renderer::Renderer(const Renderer& handle) = default; diff --git a/dali/public-api/rendering/sampler.cpp b/dali/public-api/rendering/sampler.cpp index 8dd4eaa..990e2ee 100644 --- a/dali/public-api/rendering/sampler.cpp +++ b/dali/public-api/rendering/sampler.cpp @@ -29,13 +29,9 @@ Sampler Sampler::New() return Sampler(sampler.Get()); } -Sampler::Sampler() -{ -} +Sampler::Sampler() = default; -Sampler::~Sampler() -{ -} +Sampler::~Sampler() = default; Sampler::Sampler(const Sampler& handle) = default; diff --git a/dali/public-api/rendering/shader.cpp b/dali/public-api/rendering/shader.cpp index d452ea3..9adf7de 100644 --- a/dali/public-api/rendering/shader.cpp +++ b/dali/public-api/rendering/shader.cpp @@ -31,13 +31,9 @@ Shader Shader::New(const std::string& vertexShader, return Shader(renderer.Get()); } -Shader::Shader() -{ -} +Shader::Shader() = default; -Shader::~Shader() -{ -} +Shader::~Shader() = default; Shader::Shader(const Shader& handle) = default; @@ -57,4 +53,19 @@ Shader::Shader(Internal::Shader* pointer) { } +std::string Shader::GetShaderVersionPrefix() +{ + return Dali::Internal::Shader::GetShaderVersionPrefix(); +} + +std::string Shader::GetVertexShaderPrefix() +{ + return Dali::Internal::Shader::GetVertexShaderPrefix(); +} + +std::string Shader::GetFragmentShaderPrefix() +{ + return Dali::Internal::Shader::GetFragmentShaderPrefix(); +} + } // namespace Dali diff --git a/dali/public-api/rendering/shader.h b/dali/public-api/rendering/shader.h index 2535639..f20c707 100644 --- a/dali/public-api/rendering/shader.h +++ b/dali/public-api/rendering/shader.h @@ -187,6 +187,33 @@ public: */ Shader& operator=(Shader&& rhs); + /** + * @brief Get shader preprocessor of shading language version. + * @note This can potentially block until GL has been initialized + * when the first time any DALi application is launched in the system. + * @SINCE_1_9.36 + * @return shader preprocessor string. + */ + static std::string GetShaderVersionPrefix(); + + /** + * @brief Get vertex shader preprocessor that includes shading language version. + * @note This can potentially block until GL has been initialized + * when the first time any DALi application is launched in the system. + * @SINCE_1_9.36 + * @return Vertex shader preprocessor string. + */ + static std::string GetVertexShaderPrefix(); + + /** + * @brief Get fragment shader preprocessor that includes shading language version. + * @note This can potentially block until GL has been initialized + * when the first time any DALi application is launched in the system. + * @SINCE_1_9.36 + * @return Fragment shader preprocessor string. + */ + static std::string GetFragmentShaderPrefix(); + public: /** * @brief This constructor is used by Dali New() methods. diff --git a/dali/public-api/rendering/texture-set.cpp b/dali/public-api/rendering/texture-set.cpp index 62e908a..6f9fa6b 100644 --- a/dali/public-api/rendering/texture-set.cpp +++ b/dali/public-api/rendering/texture-set.cpp @@ -31,13 +31,9 @@ TextureSet TextureSet::New() return TextureSet(textureSet.Get()); } -TextureSet::TextureSet() -{ -} +TextureSet::TextureSet() = default; -TextureSet::~TextureSet() -{ -} +TextureSet::~TextureSet() = default; TextureSet::TextureSet(const TextureSet& handle) = default; diff --git a/dali/public-api/rendering/texture.cpp b/dali/public-api/rendering/texture.cpp index c348a95..da81783 100644 --- a/dali/public-api/rendering/texture.cpp +++ b/dali/public-api/rendering/texture.cpp @@ -36,13 +36,9 @@ Texture Texture::New(NativeImageInterface& nativeImageInterface) return Texture(texture.Get()); } -Texture::Texture() -{ -} +Texture::Texture() = default; -Texture::~Texture() -{ -} +Texture::~Texture() = default; Texture::Texture(const Texture& handle) = default; diff --git a/dali/public-api/rendering/vertex-buffer.cpp b/dali/public-api/rendering/vertex-buffer.cpp index a267edd..4adb49b 100644 --- a/dali/public-api/rendering/vertex-buffer.cpp +++ b/dali/public-api/rendering/vertex-buffer.cpp @@ -31,13 +31,9 @@ VertexBuffer VertexBuffer::New(Dali::Property::Map& bufferFormat) return VertexBuffer(vertexBuffer.Get()); } -VertexBuffer::VertexBuffer() -{ -} +VertexBuffer::VertexBuffer() = default; -VertexBuffer::~VertexBuffer() -{ -} +VertexBuffer::~VertexBuffer() = default; VertexBuffer::VertexBuffer(const VertexBuffer& handle) = default; diff --git a/dali/public-api/signals/connection-tracker-interface.cpp b/dali/public-api/signals/connection-tracker-interface.cpp index 97da38a..7326407 100644 --- a/dali/public-api/signals/connection-tracker-interface.cpp +++ b/dali/public-api/signals/connection-tracker-interface.cpp @@ -20,12 +20,8 @@ namespace Dali { -ConnectionTrackerInterface::ConnectionTrackerInterface() -{ -} +ConnectionTrackerInterface::ConnectionTrackerInterface() = default; -ConnectionTrackerInterface::~ConnectionTrackerInterface() -{ -} +ConnectionTrackerInterface::~ConnectionTrackerInterface() = default; } // namespace Dali diff --git a/dali/public-api/signals/connection-tracker.cpp b/dali/public-api/signals/connection-tracker.cpp index ef7a4c5..5499ae9 100644 --- a/dali/public-api/signals/connection-tracker.cpp +++ b/dali/public-api/signals/connection-tracker.cpp @@ -24,9 +24,7 @@ namespace Dali { -ConnectionTracker::ConnectionTracker() -{ -} +ConnectionTracker::ConnectionTracker() = default; ConnectionTracker::~ConnectionTracker() { diff --git a/dali/public-api/signals/signal-slot-observers.cpp b/dali/public-api/signals/signal-slot-observers.cpp index b8c293a..67151a9 100644 --- a/dali/public-api/signals/signal-slot-observers.cpp +++ b/dali/public-api/signals/signal-slot-observers.cpp @@ -20,20 +20,12 @@ namespace Dali { -SignalObserver::SignalObserver() -{ -} +SignalObserver::SignalObserver() = default; -SignalObserver::~SignalObserver() -{ -} +SignalObserver::~SignalObserver() = default; -SlotObserver::SlotObserver() -{ -} +SlotObserver::SlotObserver() = default; -SlotObserver::~SlotObserver() -{ -} +SlotObserver::~SlotObserver() = default; } // namespace Dali diff --git a/dali/public-api/signals/slot-delegate.h b/dali/public-api/signals/slot-delegate.h index acbd1ff..a757da6 100644 --- a/dali/public-api/signals/slot-delegate.h +++ b/dali/public-api/signals/slot-delegate.h @@ -92,9 +92,7 @@ public: * * @SINCE_1_0.0 */ - ~SlotDelegate() - { - } + ~SlotDelegate() = default; /** * @brief Disconnects all signals from this object. diff --git a/dali/public-api/size-negotiation/relayout-container.h b/dali/public-api/size-negotiation/relayout-container.h index 19a076e..515b6b3 100644 --- a/dali/public-api/size-negotiation/relayout-container.h +++ b/dali/public-api/size-negotiation/relayout-container.h @@ -44,17 +44,13 @@ public: * * @SINCE_1_0.0 */ - RelayoutContainer() - { - } + RelayoutContainer() = default; /** * @brief Virtual destructor. * @SINCE_1_0.0 */ - virtual ~RelayoutContainer() - { - } + virtual ~RelayoutContainer() = default; /** * @brief Adds relayout information to the container if it doesn't already exist. diff --git a/packaging/dali.spec b/packaging/dali.spec index 0e58a69..5d3b5fd 100644 --- a/packaging/dali.spec +++ b/packaging/dali.spec @@ -1,6 +1,6 @@ Name: dali2 Summary: DALi 3D Engine -Version: 1.9.34 +Version: 2.0.1 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT