diff options
author | 2017-08-09 18:23:25 -0400 | |
---|---|---|
committer | 2017-08-10 14:34:35 +0000 | |
commit | c2f876bb8d8991e428467c1d7d24152eea629770 (patch) | |
tree | 5f94199f289e68b418dfc6cafc9516e81141454d /tools | |
parent | f4874bc5c14242dc482882252f8a8d482aa11508 (diff) |
Replace interp() with clut_{3,4}D stages.
I tried to follow exactly the same strategy as a start.
(Though I did fix the off-by-one dimensions.)
It does rather look like we only need 3D and 4D now
that I've looked at the call sites.
Looks like about a 20% speedup.
Change-Id: I8b1af64750ad1750716ee1ab0767e64591c7206a
Reviewed-on: https://skia-review.googlesource.com/32842
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/colorspaceinfo.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tools/colorspaceinfo.cpp b/tools/colorspaceinfo.cpp index 8250a03bcb..3e09a9aeeb 100644 --- a/tools/colorspaceinfo.cpp +++ b/tools/colorspaceinfo.cpp @@ -10,14 +10,16 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkCodec.h" +#include "SkColorSpacePriv.h" #include "SkColorSpace_A2B.h" #include "SkColorSpace_XYZ.h" -#include "SkColorSpacePriv.h" #include "SkCommandLineFlags.h" #include "SkICCPriv.h" #include "SkImageEncoder.h" #include "SkMatrix44.h" #include "SkOSFile.h" +#include "SkRasterPipeline.h" +#include "../src/jumper/SkJumper.h" #include "sk_tool_utils.h" @@ -264,6 +266,27 @@ static int cut_size(const SkColorLookUpTable& clut, int dimOrder[4]) { return cutWidth < cutHeight ? cutWidth : cutHeight; } +static void clut_interp(const SkColorLookUpTable& clut, float out[3], const float in[4]) { + // This is kind of a toy implementation. + // You generally wouldn't want to do this 1 pixel at a time. + + SkJumper_ColorLookupTableCtx ctx; + ctx.table = clut.table(); + for (int i = 0; i < clut.inputChannels(); i++) { + ctx.limits[i] = clut.gridPoints(i); + } + + SkSTArenaAlloc<256> alloc; + SkRasterPipeline p(&alloc); + p.append_constant_color(&alloc, in); + p.append(clut.inputChannels() == 3 ? SkRasterPipeline::clut_3D + : SkRasterPipeline::clut_4D, &ctx); + p.append(SkRasterPipeline::clamp_0); + p.append(SkRasterPipeline::clamp_1); + p.append(SkRasterPipeline::store_f32, &out); + p.run(0,0, 1,1); +} + static void draw_clut(SkCanvas* canvas, const SkColorLookUpTable& clut, int dimOrder[4]) { dump_clut(clut); @@ -291,7 +314,7 @@ static void draw_clut(SkCanvas* canvas, const SkColorLookUpTable& clut, int dimO const float w = row / (rows - 1.0f); const float input[4] = {x, y, z, w}; float output[3]; - clut.interp(output, input); + clut_interp(clut, output, input); paint.setColor(SkColorSetRGB(255*output[0], 255*output[1], 255*output[2])); canvas->drawRect(SkRect::MakeLTRB(ox + cutSize * x, oy + cutSize * y, ox + cutSize * (x + xStep), |