aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPM4fPriv.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-06-07 12:12:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-07 12:12:37 -0700
commit3db2028126e12a9c1c1fb2f878d552a2de0e1452 (patch)
treed851792e0ad76e61d51c42e03e429b14d2f21044 /src/core/SkPM4fPriv.h
parent12dfaaa53c23f3d03050bde8f64136ac1f44164a (diff)
linear -> sRGB: use fast approximate sqrt()
Since we're already approximating the sRGB gamma curve with a sqrt(), we might as well approximate with it a faster approximate sqrt(). On Intel, this .rsqrt().invert() version is 2-3x faster than .sqrt() (~3x faster on older machines, ~2x faster on newer machines). This should provide ~11 bits of precision, suspiciously exactly enough. Running dm --config srgb, there are diffs, but none perceptible. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2046063002 Review-Url: https://codereview.chromium.org/2046063002
Diffstat (limited to 'src/core/SkPM4fPriv.h')
-rw-r--r--src/core/SkPM4fPriv.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h
index 9650646d95..bf5ff5a1ad 100644
--- a/src/core/SkPM4fPriv.h
+++ b/src/core/SkPM4fPriv.h
@@ -41,7 +41,7 @@ static inline Sk4f srgb_to_linear(const Sk4f& s4) {
}
static inline Sk4f linear_to_srgb(const Sk4f& l4) {
- return set_alpha(l4.sqrt(), get_alpha(l4));
+ return set_alpha(l4.rsqrt().invert(), get_alpha(l4));
}
static inline float srgb_to_linear(float x) {