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

Unified Diff: src/core/SkXfermode4f.cpp

Issue 2046063002: linear -> sRGB: use fast approximate sqrt() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: found another Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPM4fPriv.h ('k') | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkXfermode4f.cpp
diff --git a/src/core/SkXfermode4f.cpp b/src/core/SkXfermode4f.cpp
index 4d224ac0ad788d59af06b219f716555eae01b0dd..8671df7b2fcf102a43f2d6f16ac7006d89310d54 100644
--- a/src/core/SkXfermode4f.cpp
+++ b/src/core/SkXfermode4f.cpp
@@ -68,10 +68,10 @@ static Sk4x4f load_4_srgb(const void* ptr) {
// Store an Sk4x4f back to 4 interlaced 8888 sRGB pixels.
static void store_4_srgb(void* ptr, const Sk4x4f& p) {
// Convert back to sRGB and [0,255], again approximating sRGB as gamma == 2.
- auto r = p.r.sqrt() * 255.0f + 0.5f,
- g = p.g.sqrt() * 255.0f + 0.5f,
- b = p.b.sqrt() * 255.0f + 0.5f,
- a = p.a * 255.0f + 0.5f;
+ auto r = p.r.rsqrt().invert() * 255.0f + 0.5f,
+ g = p.g.rsqrt().invert() * 255.0f + 0.5f,
+ b = p.b.rsqrt().invert() * 255.0f + 0.5f,
+ a = p.a * 255.0f + 0.5f;
Sk4x4f{r,g,b,a}.transpose((uint8_t*)ptr);
}
« no previous file with comments | « src/core/SkPM4fPriv.h ('k') | src/effects/gradients/Sk4fLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698