aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/MathTest.cpp
Commit message (Collapse)AuthorAge
* Revert "Revert "SkTypes: extract SkTo""Gravatar Hal Canary2018-06-14
| | | | | | | | | | | | | | | | This reverts commit fdcfb8b7c23fbf18f872d2c31d27978235033876. > Original change's description: > > SkTypes: extract SkTo > > > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > > Reviewed-on: https://skia-review.googlesource.com/133620 > > Reviewed-by: Mike Klein <mtklein@google.com> Change-Id: Ida74fbc5c21248a724a5edbf9fae18a33bcb23aa Reviewed-on: https://skia-review.googlesource.com/134506 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Revert "SkTypes: extract SkTo"Gravatar Hal Canary2018-06-13
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2a2f67592602b18527bc3fd449132d420cd5b62e. Reason for revert: this appears to be what is holding up the Chrome roll. Original change's description: > SkTypes: extract SkTo > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > Reviewed-on: https://skia-review.googlesource.com/133620 > Reviewed-by: Mike Klein <mtklein@google.com> TBR=mtklein@google.com,halcanary@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Iafd738aedfb679a23c061a51afe4b98a8d4cdfae Reviewed-on: https://skia-review.googlesource.com/134504 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkTypes: extract SkToGravatar Hal Canary2018-06-12
| | | | | | Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 Reviewed-on: https://skia-review.googlesource.com/133620 Reviewed-by: Mike Klein <mtklein@google.com>
* handle huge normalize requests (including non-finite x or y)Gravatar Mike Reed2018-05-14
| | | | | | | | Bug: oss-fuzz:8023 Change-Id: I622b6e335d9efbe599fa9047b3a6fcee1664aa4a Reviewed-on: https://skia-review.googlesource.com/124581 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* exact divide by 255 with NEONGravatar Mike Klein2018-03-14
| | | | | | | Change-Id: Ib121eb0d5af1f22f48f517fe909112a77d92032e Reviewed-on: https://skia-review.googlesource.com/113666 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Herb Derby <herb@google.com>
* Extend math test to ensure our min/max/pin handle non-finitesGravatar Mike Reed2018-03-05
| | | | | | | | Bug: skia: Change-Id: I4fe544c32da071d161229b12f7b90a3296b0d499 Reviewed-on: https://skia-review.googlesource.com/112140 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* add saturate helper for float2int64Gravatar Mike Reed2018-01-31
| | | | | | | | Bug: skia: Change-Id: I157f8c047145874c4585ae870018163908389b26 Reviewed-on: https://skia-review.googlesource.com/102321 Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
* clone saturating cast code for doublesGravatar Mike Reed2017-10-10
| | | | | | | | Bug: skia: Change-Id: I4f35413995cf73c6f130476d6b36e530120aa7ed Reviewed-on: https://skia-review.googlesource.com/57901 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Reed <reed@google.com>
* make most of SkColorPriv.h privateGravatar Cary Clark2017-09-15
| | | | | | | | | | | | | created new file src/core/SkColorData.h for internal consumption. Note that many of the functions there are unused as well. Bug: skia: 6898 R: reed@google.com Change-Id: I25bfd5a9c21f53558c4ca65a77eb5d322d897c6d Reviewed-on: https://skia-review.googlesource.com/46848 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Mike Reed <reed@google.com>
* handle overflows in float->intGravatar Mike Reed2017-08-09
| | | | | | | | | | rects are already auto-vectorized, so no need to explicitly write a 4f version of SkRect::round() Bug: skia: Change-Id: I098945767bfcaa7093d770c376bd17ff3bdc9983 Reviewed-on: https://skia-review.googlesource.com/32060 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
* just use math.h for converting from float to intGravatar Mike Reed2017-08-04
| | | | | | | | Bug: skia: Change-Id: I40cce503cd4cef09c671511a705192efc5d67d71 Reviewed-on: https://skia-review.googlesource.com/31002 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Add test for QuickFDot6DivGravatar Yuqian Li2016-11-18
| | | | | | | | | | | | | This test will catch our (1 << 10) bug (which should be 1 << 9) BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4986 Change-Id: I25b607d1535a647284cee3b304a6f567f389e7f6 Reviewed-on: https://skia-review.googlesource.com/4986 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
* Add GrNextSizePow2Gravatar Robert Phillips2016-10-31
| | | | | | | | | | | GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4069 BUG=skia:5882 Change-Id: Ib9af5918716be594c3c07239eca179dbb4eb8566 Reviewed-on: https://skia-review.googlesource.com/4069 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Make SkFixedRound/Ceil/FloorToFixed as inline funcGravatar liyuqian2016-10-20
| | | | | | | | | | | | | The macros that we were using will return unsigned int32 instead of signed int32 because of the last 0xFFFF0000 mask. That may bring problems if we right shift that result. Special thanks to mtklein@google.com for helping me find out this issue. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2433233003 Review-Url: https://chromiumcodereview.appspot.com/2433233003
* Revert of My take on SkAlign changes. (patchset #3 id:40001 of ↵Gravatar mtklein2016-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/2368293002/ ) Reason for revert: Let's see if reverting this helps the roll. Original issue's description: > My take on SkAlign changes. > > Like the other change, it makes SkAlignN(x) macros work for pointers, and makes the macros themselves just syntax sugar for SkAlign<N>(x). We can still decide if we want to sed away the macros independently. > > This just does it in a somewhat less repetitive way, and adds some tests. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2368293002 > > No public API changes. > TBR=reed@google.com > > Committed: https://skia.googlesource.com/skia/+/e1a5f4e292384046678edc5c1e360b3e13dc118c TBR=cblume@chromium.org,mtklein@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2372083002
* My take on SkAlign changes.Gravatar mtklein2016-09-26
| | | | | | | | | | | | | | Like the other change, it makes SkAlignN(x) macros work for pointers, and makes the macros themselves just syntax sugar for SkAlign<N>(x). We can still decide if we want to sed away the macros independently. This just does it in a somewhat less repetitive way, and adds some tests. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2368293002 No public API changes. TBR=reed@google.com Review-Url: https://codereview.chromium.org/2368293002
* Fix SkFixedDiv macroGravatar liyuqian2016-07-13
| | | | | | | | | | Previously, the macro won't pass the unit test that I just added in this CL. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2149733002 Review-Url: https://codereview.chromium.org/2149733002
* Clean up SkFloatBitsGravatar mtklein2016-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - remove dead code - rewrite float -> int converters The strategy for the new converters is: - convert input to double - floor/ceil/round in double space - pin that double to [SK_MinS32, SK_MaxS32] - truncate that double to int32_t This simpler strategy does not work: - floor/ceil/round in float space - pin that float to [SK_MinS32, SK_MaxS32] - truncate that float to int32_t SK_MinS32 and SK_MaxS32 are not representable as floats: they round to the nearest float, ±2^31, which makes the pin insufficient for floats near SK_MinS32 (-2^31+1) or SK_MaxS32 (+2^31-1). float only has 24 bits of precision, and we need 31. double can represent all integers up to 50-something bits. An alternative is to pin in float to ±2147483520, the last exactly representable float before SK_MaxS32 (127 too small). Our tests test that we round as floor(x+0.5), which can return different numbers than round(x) for negative x. So this CL explicitly uses floor(x+0.5). I've updated the tests with ±inf and ±NaN, and tried to make them a little clearer, especially using SK_MinS32 instead of -SK_MaxS32. I have not timed anything here. I have never seen any of these methods in a profile. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2012333003 Review-Url: https://codereview.chromium.org/2012333003
* Remove Sk(Float|Double)PinToFixed functions, only used in tests.Gravatar brianosman2016-05-06
| | | | | | | | | | These were triggering compile-time floating point overflow for one user, and we don't use them. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1952303005 Review-Url: https://codereview.chromium.org/1952303005
* Add pinned versions of *ToFixed.Gravatar benjaminwagner2016-04-07
| | | | | | | BUG=skia:4632 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1707023002 Review URL: https://codereview.chromium.org/1707023002
* Reverse dependency between SkScalar.h and SkFixed.h.Gravatar benjaminwagner2016-04-07
| | | | | | | | | | | | | | | The following are unused in Chromium, Android, Mozilla, and Google3: - SkFixedToScalar - SkScalarToFixed The following are additionally unused in Skia: - SkStrAppendFixed - SkWriteBuffer::writeFixed BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1841123002 Review URL: https://codereview.chromium.org/1841123002
* Unit Tests: eliminate stray SkDebugf()s.Gravatar halcanary2016-02-24
| | | | | | GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1733113002 Review URL: https://codereview.chromium.org/1733113002
* de-proc sk_float_rsqrtGravatar mtklein2016-01-26
| | | | | | | | | | | | This is the first of many little baby steps to have us stop runtime-detecting NEON. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1616013003 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Committed: https://skia.googlesource.com/skia/+/efcc125acd2d71eb077caf6db65fdd6b9eb1dc0d Review URL: https://codereview.chromium.org/1616013003
* Revert of de-proc sk_float_rsqrt (patchset #3 id:40001 of ↵Gravatar mtklein2016-01-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1616013003/ ) Reason for revert: This is somehow blocking the Google3 roll in ways neither Ben nor I understand. Precautionary revert... will try again Monday. Original issue's description: > de-proc sk_float_rsqrt > > This is the first of many little baby steps to have us stop runtime-detecting NEON. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1616013003 > CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot > > Committed: https://skia.googlesource.com/skia/+/efcc125acd2d71eb077caf6db65fdd6b9eb1dc0d TBR=reed@google.com,mtklein@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1629503002
* de-proc sk_float_rsqrtGravatar mtklein2016-01-22
| | | | | | | | | | This is the first of many little baby steps to have us stop runtime-detecting NEON. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1616013003 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review URL: https://codereview.chromium.org/1616013003
* ubsan shift fixesGravatar caryclark2015-12-09
| | | | | | | | | | | Use an inline function that does a normal shift. When built for the sanitizer, add casts so that the shift is unsigned. Also make a few fixes to do unsigned shifts or avoid the shift altogether; and add an argument spec to some macros. R=reed@google.com,mtklein@google.com BUG=skia:4633 Review URL: https://codereview.chromium.org/1503423003
* Update fallback rsqrt implementation to use optimal constants.Gravatar jvanverth2015-07-23
| | | | | | | | | Improves max relative error from 0.00175126 to 0.000650197. Also add unit tests to check error bounds. BUG=chromium:511458 Review URL: https://codereview.chromium.org/1251423002
* Let's find out what's up with the TSAN bot test failures.Gravatar mtklein2015-03-18
| | | | | | BUG=skia: Review URL: https://codereview.chromium.org/1020573002
* Add float-to-half (binary16) conversion functions.Gravatar jvanverth2014-11-26
| | | | | | | | | | | Based on code by Fabian Giesen at https://fgiesen.wordpress.com/2012/03/28/half-to-float-done-quic/. These will be needed for creating binary16 textures from floating point data. BUG=skia:3103 Review URL: https://codereview.chromium.org/760753003
* remove unused SkIntToFloatCast_NoOverflowCheckGravatar caryclark2014-08-19
| | | | | | | | | R=reed@google.com, reed BUG=skia:2849 Author: caryclark@google.com Review URL: https://codereview.chromium.org/483273003
* Cleanup: Sanitize the order of includes under tests/Gravatar tfarina@chromium.org2014-01-24
| | | | | | | | | | | | | | | | Initially this was to make sure Test.h appeared after the Sk*.h includes. Patch generated by the following command line: $ ~/chromium/src/tools/sort-headers.py tests/*.cpp BUG=None TEST=tests R=robertphillips@google.com Review URL: https://codereview.chromium.org/145313004 git-svn-id: http://skia.googlecode.com/svn/trunk@13177 2bbb7eff-a529-9590-31e7-b0007b416f81
* Move macros from TestClassDef.h to Test.hGravatar commit-bot@chromium.org2014-01-14
| | | | | | | | | | | | | | Motivation: those macros don't make any sense without the definitions in Test.h. BUG= R=mtklein@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/138563004 git-svn-id: http://skia.googlecode.com/svn/trunk@13074 2bbb7eff-a529-9590-31e7-b0007b416f81
* Add REPORTF test macro.Gravatar halcanary@google.com2014-01-10
| | | | | | | | | | | | | | | | | | This macro replaces: SkString str; str.printf("Foo test Expected %d got %d", x, y); reporter->reportFailed(str); with the shorter code: REPORTF(reporter, ("Foo test Expected %d got %d", x, y)); The new form also appends __FILE__:__LINE__ to the message before calling reportFailed(). BUG= R=mtklein@google.com Review URL: https://codereview.chromium.org/132843002 git-svn-id: http://skia.googlecode.com/svn/trunk@13016 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "Revert "begin to remove SkLONGLONG and wean Skia off of Sk64""Gravatar reed@google.com2013-12-20
| | | | | | | | | | This reverts commit 15b986baf026a3da5e2cac8106a1b753df242c39. BUG= Review URL: https://codereview.chromium.org/119353003 git-svn-id: http://skia.googlecode.com/svn/trunk@12796 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "begin to remove SkLONGLONG and wean Skia off of Sk64"Gravatar reed@google.com2013-12-19
| | | | | | | | | | | | | | This reverts commit 784890196fdab96289f9389db43aca01f35db0f9. Revert "use LL suffix for 64bit literal" This reverts commit 9634295aff9bffd7a3875a0ca4a9b1a27d0793fc. BUG= Review URL: https://codereview.chromium.org/116543009 git-svn-id: http://skia.googlecode.com/svn/trunk@12790 2bbb7eff-a529-9590-31e7-b0007b416f81
* begin to remove SkLONGLONG and wean Skia off of Sk64Gravatar reed@google.com2013-12-19
| | | | | | | | | BUG= R=caryclark@google.com Review URL: https://codereview.chromium.org/99433009 git-svn-id: http://skia.googlecode.com/svn/trunk@12788 2bbb7eff-a529-9590-31e7-b0007b416f81
* remove unused SkFixed and SkFract functionsGravatar reed@google.com2013-12-19
| | | | | | | | | BUG= R=caryclark@google.com Review URL: https://codereview.chromium.org/113873008 git-svn-id: http://skia.googlecode.com/svn/trunk@12767 2bbb7eff-a529-9590-31e7-b0007b416f81
* remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floatsGravatar reed@google.com2013-12-17
| | | | | | | | | | | | | To keep the CL (slightly) managable, this does not make any changes to existing macros (e.g. SkScalarMul). Just tackling #ifdef constructs this time around. BUG= R=bsalomon@google.com, caryclark@google.com Review URL: https://codereview.chromium.org/117053002 git-svn-id: http://skia.googlecode.com/svn/trunk@12712 2bbb7eff-a529-9590-31e7-b0007b416f81
* Use DEFINE_TESTCLASS_SHORT macro in tests.Gravatar tfarina@chromium.org2013-12-12
| | | | | | | | | | | | | The three version of DEFINE_TESTCLASS macro is deprecated and thus just use the simple, short one. BUG=None TEST=out/Debug/tests R=mtklein@google.com, bsalomon@google.com, robertphillips@google.com Review URL: https://codereview.chromium.org/100113004 git-svn-id: http://skia.googlecode.com/svn/trunk@12653 2bbb7eff-a529-9590-31e7-b0007b416f81
* remove SkFloatToScalar macroGravatar commit-bot@chromium.org2013-11-25
| | | | | | | | | | | BUG= R=reed@google.com, djsollen@google.com Author: caryclark@google.com Review URL: https://codereview.chromium.org/85463005 git-svn-id: http://skia.googlecode.com/svn/trunk@12385 2bbb7eff-a529-9590-31e7-b0007b416f81
* Clean up SkTypes.h.Gravatar bungeman@google.com2013-10-11
| | | | | | | | | | | | | | | | | | | This change removes sk_stdint.h since it is only needed for vs2008 and earlier. This change removes SK_MMAP_SUPPORT define since it is no longer used. This change removes the stdio.h include from SkTypes.h since on many systems this is a very large header, few Skia files actually use it, it is available everywhere standard, and SkDebugf should be used instead. After this change there is no need for external users to put Skia's include/config into their own list of includes, saving the headache of having two header files of the same name and sometimes getting the wrong one depending on include order. R=bsalomon@google.com, djsollen@google.com Review URL: https://codereview.chromium.org/27044002 git-svn-id: http://skia.googlecode.com/svn/trunk@11738 2bbb7eff-a529-9590-31e7-b0007b416f81
* Add SkDivMod with a special case for ARM.Gravatar commit-bot@chromium.org2013-09-26
| | | | | | | | | | | BUG=skia:1663 R=djsollen@google.com, tomhudson@google.com, reed@google.com Author: mtklein@google.com Review URL: https://chromiumcodereview.appspot.com/24159009 git-svn-id: http://skia.googlecode.com/svn/trunk@11482 2bbb7eff-a529-9590-31e7-b0007b416f81
* Change old PRG to be SkLCGRandom; change new one to SkRandomGravatar commit-bot@chromium.org2013-09-09
| | | | | | | | | | | | | | The goal here is to get people to start using the new random number generator, while leaving the old one in place so we don't have to rebaseline GMs. R=reed@google.com, bsalomon@google.com Author: jvanverth@google.com Review URL: https://chromiumcodereview.appspot.com/23576015 git-svn-id: http://skia.googlecode.com/svn/trunk@11169 2bbb7eff-a529-9590-31e7-b0007b416f81
* Switch out random number generator for tests, benches, samples.Gravatar commit-bot@chromium.org2013-09-06
| | | | | | | | | | | | This change makes tests, benches and samples use the new SkMWCRandom PRNG. GMs will be saved for another time, as they'll require rebaselining. R=reed@google.com, bsalomon@google.com Author: jvanverth@google.com Review URL: https://chromiumcodereview.appspot.com/23653018 git-svn-id: http://skia.googlecode.com/svn/trunk@11136 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert r10705 (ARM Skia NEON patches - 04 - Clean SkFixed / SkLONGLONG) due ↵Gravatar robertphillips@google.com2013-08-15
| | | | | | to 1000+ linux_layout failures (http://build.chromium.org/p/tryserver.chromium/builders/linux_layout_rel/builds/18997/steps/webkit_tests/logs/stdio) git-svn-id: http://skia.googlecode.com/svn/trunk@10729 2bbb7eff-a529-9590-31e7-b0007b416f81
* ARM Skia NEON patches - 04 - Clean SkFixed / SkLONGLONGGravatar commit-bot@chromium.org2013-08-14
| | | | | | | | | | | | | | | It removes SkLONGLONG and uses int64_t to implement the SkFixed operations for which a SkLONGLONG version existed. It also removes the 32 bit version that are being replaced. BUG= R=djsollen@google.com, reed@google.com Author: kevin.petit.arm@gmail.com Review URL: https://chromiumcodereview.appspot.com/18539004 git-svn-id: http://skia.googlecode.com/svn/trunk@10705 2bbb7eff-a529-9590-31e7-b0007b416f81
* add endian tests (reviewed by bungeman)Gravatar reed@google.com2013-05-03
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@8993 2bbb7eff-a529-9590-31e7-b0007b416f81
* Sanitizing source files in Skia_Periodic_House_KeepingGravatar skia.committer@gmail.com2013-04-30
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@8919 2bbb7eff-a529-9590-31e7-b0007b416f81
* add wacky random shift so I can generate some zeros (without the optimizer ↵Gravatar reed@google.com2013-04-29
| | | | | | | | | | knowing) so I can test passing a 0 to SkCLZ() git-svn-id: http://skia.googlecode.com/svn/trunk@8904 2bbb7eff-a529-9590-31e7-b0007b416f81
* reland 8897 (was not a build-breaker) and fix MathTest (was a build-breaker)Gravatar reed@google.com2013-04-29
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@8899 2bbb7eff-a529-9590-31e7-b0007b416f81