Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Issue 2012333003: Clean up SkFloatBits (Closed)

Created:
4 years, 6 months ago by mtklein_C
Modified:
4 years, 6 months ago
Reviewers:
f(malita), mtklein, reed1
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Clean up SkFloatBits - 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 Committed: https://skia.googlesource.com/skia/+/785a5b941a4d74a1f272729fe8dca55c6eda6bb8

Patch Set 1 #

Patch Set 2 : clearer #

Patch Set 3 : explicit cast #

Patch Set 4 : add a bench #

Patch Set 5 : member #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -272 lines) Patch
M bench/MathBench.cpp View 1 2 3 4 1 chunk +26 lines, -0 lines 0 comments Download
M gyp/core.gypi View 1 chunk +0 lines, -1 line 0 comments Download
M include/private/SkFloatBits.h View 1 2 4 chunks +6 lines, -34 lines 0 comments Download
D src/core/SkFloatBits.cpp View 1 chunk +0 lines, -205 lines 0 comments Download
M tests/MathTest.cpp View 1 3 chunks +10 lines, -32 lines 0 comments Download

Messages

Total messages: 34 (19 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2012333003/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2012333003/1
4 years, 6 months ago (2016-05-26 21:47:48 UTC) #9
commit-bot: I haz the power
Dry run: None
4 years, 6 months ago (2016-05-26 21:51:27 UTC) #12
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2012333003/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2012333003/40001
4 years, 6 months ago (2016-05-26 21:54:59 UTC) #14
mtklein_C
You guys got me curious with that other CL.
4 years, 6 months ago (2016-05-26 22:06:30 UTC) #16
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 6 months ago (2016-05-26 22:19:03 UTC) #18
commit-bot: I haz the power
Dry run: None
4 years, 6 months ago (2016-05-26 22:19:11 UTC) #19
f(malita)
LGTM Real-world impact aside, I would expect the new impl to be cheaper than the ...
4 years, 6 months ago (2016-05-27 13:10:16 UTC) #20
mtklein
On 2016/05/27 13:10:16, f(malita) wrote: > LGTM > > Real-world impact aside, I would expect ...
4 years, 6 months ago (2016-05-27 13:58:12 UTC) #21
reed1
I think measuring the speed of the following might be interesting: 1. old impl 2. ...
4 years, 6 months ago (2016-05-27 14:29:15 UTC) #22
mtklein_C
On 2016/05/27 at 14:29:15, reed wrote: > I think measuring the speed of the following ...
4 years, 6 months ago (2016-05-27 14:50:06 UTC) #23
reed1
thanks for benching! lgtm
4 years, 6 months ago (2016-05-27 16:58:56 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2012333003/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2012333003/60001
4 years, 6 months ago (2016-05-27 17:02:31 UTC) #27
commit-bot: I haz the power
Try jobs failed on following builders: Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot on client.skia (JOB_FAILED, http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot/builds/8766)
4 years, 6 months ago (2016-05-27 17:07:22 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2012333003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2012333003/80001
4 years, 6 months ago (2016-05-27 17:34:57 UTC) #32
commit-bot: I haz the power
4 years, 6 months ago (2016-05-27 17:47:36 UTC) #34
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as
https://skia.googlesource.com/skia/+/785a5b941a4d74a1f272729fe8dca55c6eda6bb8

Powered by Google App Engine
This is Rietveld 408576698