restore sRGB memset optimization
authorMike Klein <mtklein@chromium.org>
Wed, 30 Nov 2016 14:55:08 +0000 (09:55 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 30 Nov 2016 15:44:36 +0000 (15:44 +0000)
https://skia-review.googlesource.com/c/5275/ removed it, and perf noticed.

This is obviously not very pretty or scalable.  I plan to folow up with a more thorough and principled way to do this sort of constant-color + invariant-stage == constant-color optimization.

BUG=skia:6013

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD

Change-Id: I377386f67e66169cce6e0cb0831f3b7154496840
Reviewed-on: https://skia-review.googlesource.com/5338
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
src/opts/SkRasterPipeline_opts.h

index a40fe6c..163b9eb 100644 (file)
@@ -897,6 +897,29 @@ namespace SK_OPTS_NS {
                 default: break;
             }
         }
+        if (nstages == 3 && stages[0].stage == SkRasterPipeline::constant_color
+                         && stages[1].stage == SkRasterPipeline::to_srgb
+                         && stages[2].stage == SkRasterPipeline::store_8888) {
+            auto src = (const SkPM4f*)stages[0].ctx;
+            auto dst =    (uint32_t**)stages[2].ctx;
+            return Memset32{dst, Sk4f_toS32(src->to4f())};
+        }
+        if (nstages == 4 && stages[0].stage == SkRasterPipeline::constant_color
+                         && stages[1].stage == SkRasterPipeline::to_srgb
+                         && stages[2].stage == SkRasterPipeline::swap_rb
+                         && stages[3].stage == SkRasterPipeline::store_8888) {
+            auto src = (const SkPM4f*)stages[0].ctx;
+            auto dst =    (uint32_t**)stages[3].ctx;
+            return Memset32{dst, Sk4f_toS32(swizzle_rb(src->to4f())) };
+        }
+        if (nstages == 4 && stages[0].stage == SkRasterPipeline::constant_color
+                         && stages[1].stage == SkRasterPipeline::swap_rb
+                         && stages[2].stage == SkRasterPipeline::to_srgb
+                         && stages[3].stage == SkRasterPipeline::store_8888) {
+            auto src = (const SkPM4f*)stages[0].ctx;
+            auto dst =    (uint32_t**)stages[3].ctx;
+            return Memset32{dst, Sk4f_toS32(swizzle_rb(src->to4f())) };
+        }
 
         struct Compiled {
             Compiled(const SkRasterPipeline::Stage* stages, int nstages) {