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

Unified Diff: bench/SkRasterPipelineBench.cpp

Issue 2162063003: Tune linear->sRGB constants to round-trip all bytes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Perfect 131 Created 4 years, 5 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 | « no previous file | src/core/SkSRGB.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/SkRasterPipelineBench.cpp
diff --git a/bench/SkRasterPipelineBench.cpp b/bench/SkRasterPipelineBench.cpp
index b3b87982af826474b37dd40032efb99fb5e24ca0..0243940a106e13b94d4225c283502b41239b90a9 100644
--- a/bench/SkRasterPipelineBench.cpp
+++ b/bench/SkRasterPipelineBench.cpp
@@ -139,24 +139,15 @@ static void SK_VECTORCALL srcover(SkRasterPipeline::Stage* st, size_t x,
st->next(x, r,g,b,a, dr,dg,db,da);
}
-static Sk4f clamp(const Sk4f& x) {
- return Sk4f::Min(Sk4f::Max(x, 0.0f), 255.0f);
-}
-
static void SK_VECTORCALL store_srgb(SkRasterPipeline::Stage* st, size_t x,
Sk4f r, Sk4f g, Sk4f b, Sk4f a,
Sk4f dr, Sk4f dg, Sk4f db, Sk4f da) {
auto ptr = st->ctx<uint32_t*>() + x;
- r = clamp(sk_linear_to_srgb(r));
- g = clamp(sk_linear_to_srgb(g));
- b = clamp(sk_linear_to_srgb(b));
- a = clamp( 255.0f * a );
-
- ( SkNx_cast<int>(r)
- | SkNx_cast<int>(g) << 8
- | SkNx_cast<int>(b) << 16
- | SkNx_cast<int>(a) << 24 ).store(ptr);
+ ( sk_linear_to_srgb(r)
+ | sk_linear_to_srgb(g) << 8
+ | sk_linear_to_srgb(b) << 16
+ | Sk4f_round(255.0f*a) << 24).store(ptr);
}
static void SK_VECTORCALL store_srgb_tail(SkRasterPipeline::Stage* st, size_t x,
@@ -164,9 +155,8 @@ static void SK_VECTORCALL store_srgb_tail(SkRasterPipeline::Stage* st, size_t x,
Sk4f dr, Sk4f dg, Sk4f db, Sk4f da) {
auto ptr = st->ctx<uint32_t*>() + x;
- auto rgba = sk_linear_to_srgb({r[0], g[0], b[0], 0});
- rgba = {rgba[0], rgba[1], rgba[2], 255.0f*a[0]};
- rgba = clamp(rgba);
+ Sk4i rgba = sk_linear_to_srgb({r[0], g[0], b[0], 0});
+ rgba = {rgba[0], rgba[1], rgba[2], (int)(255.0f * a[0] + 0.5f)};
SkNx_cast<uint8_t>(rgba).store(ptr);
}
« no previous file with comments | « no previous file | src/core/SkSRGB.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698