try Herb's new to_srgb

This was 6-8% faster than the previous code on my Trashcan.

Change-Id: I70081009e233c83226d6d302f871fb7e86cdc438
Reviewed-on: https://skia-review.googlesource.com/16986
Reviewed-by: Matt Sarett <msarett@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2017-05-15 17:36:59 -04:00 committed by Skia Commit-Bot
parent c090c647e4
commit f45e3d78a4
4 changed files with 2152 additions and 2185 deletions

View File

@ -125,3 +125,21 @@ public:
} }
}; };
DEF_BENCH( return (new SkRasterPipeline_2dot2); ) DEF_BENCH( return (new SkRasterPipeline_2dot2); )
class SkRasterPipelineToSRGB : public Benchmark {
public:
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
const char* onGetName() override {
return "SkRasterPipeline_to_srgb";
}
void onDraw(int loops, SkCanvas*) override {
SkRasterPipeline p;
p.append(SkRasterPipeline::to_srgb);
while (loops --> 0) {
p.run(0,N);
}
}
};
DEF_BENCH( return (new SkRasterPipelineToSRGB); )

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -621,12 +621,11 @@ STAGE(from_srgb) {
} }
STAGE(to_srgb) { STAGE(to_srgb) {
auto fn = [&](F l) { auto fn = [&](F l) {
F sqrt = rcp (rsqrt(l)), F t = rsqrt(l);
ftrt = rsqrt(rsqrt(l)); auto lo = l * 12.92f;
auto lo = l * 12.46f; auto hi = mad(t, mad(t, -0.0024542345f, 0.013832027f), 1.1334244f)
auto hi = min(1.0f, mad(0.411192f, ftrt, * rcp(0.14513608f + t);
mad(0.689206f, sqrt, -0.0988f))); return if_then_else(l < 0.00465985f, lo, hi);
return if_then_else(l < 0.0043f, lo, hi);
}; };
r = fn(r); r = fn(r);
g = fn(g); g = fn(g);