aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkOpts.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-09-29 13:40:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-09-29 18:11:29 +0000
commitfa9f241a85c55c32a3fe2ae0324811de998f7a2e (patch)
tree01308fe5602180eaaf0636fa635183ce9a93a7e7 /src/core/SkOpts.cpp
parent69e7eba6aef583eb0561019539b164d8e0eed025 (diff)
Add an enum layer of indirection for stock raster pipeline stages.
This is handy now, and becomes necessary with fancier backends: - most code can't speak the type of AVX pipeline stages, so indirection's definitely needed there; - if the pipleine is entirely composed of stock stages, these enum values become an abstract recipe that can be JITted. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2782 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Change-Id: Iedd62e99ce39e94cf3e6ffc78c428f0ccc182342 Reviewed-on: https://skia-review.googlesource.com/2782 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkOpts.cpp')
-rw-r--r--src/core/SkOpts.cpp68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/core/SkOpts.cpp b/src/core/SkOpts.cpp
index 1f686ff56b..5cac8ec3ca 100644
--- a/src/core/SkOpts.cpp
+++ b/src/core/SkOpts.cpp
@@ -90,37 +90,57 @@ namespace SkOpts {
DEFINE_DEFAULT(hash_fn);
#undef DEFINE_DEFAULT
-// Stages that are not sensitive to the tail parameter can be represented by one function.
-#define DEFINE_DEFAULT(stage, kCallNext) \
- decltype(stage) stage = body<SK_OPTS_NS::stage, kCallNext>
+ // TODO: might be nice to only create one instance of tail-insensitive stages.
- DEFINE_DEFAULT(srcover, true);
- DEFINE_DEFAULT(constant_color, true);
- DEFINE_DEFAULT(lerp_constant_float, true);
-#undef DEFINE_DEFAULT
+ SkRasterPipeline::Fn stages_4[] = {
+ stage_4<SK_OPTS_NS::store_565 , false>,
+ stage_4<SK_OPTS_NS::store_srgb, false>,
+ stage_4<SK_OPTS_NS::store_f16 , false>,
-// Stages that are sensitive to the tail parameter need two versions, _body and _tail.
-#define DEFINE_DEFAULT(stage, kCallNext) \
- decltype(stage##_body) stage##_body = body<SK_OPTS_NS::stage, kCallNext>; \
- decltype(stage##_tail) stage##_tail = tail<SK_OPTS_NS::stage, kCallNext>
+ stage_4<SK_OPTS_NS::load_s_565 , true>,
+ stage_4<SK_OPTS_NS::load_s_srgb, true>,
+ stage_4<SK_OPTS_NS::load_s_f16 , true>,
- DEFINE_DEFAULT(load_d_srgb, true);
- DEFINE_DEFAULT(load_s_srgb, true);
- DEFINE_DEFAULT( store_srgb, false);
+ stage_4<SK_OPTS_NS::load_d_565 , true>,
+ stage_4<SK_OPTS_NS::load_d_srgb, true>,
+ stage_4<SK_OPTS_NS::load_d_f16 , true>,
- DEFINE_DEFAULT(load_d_f16, true);
- DEFINE_DEFAULT(load_s_f16, true);
- DEFINE_DEFAULT( store_f16, false);
+ stage_4<SK_OPTS_NS::scale_u8, true>,
- DEFINE_DEFAULT(load_d_565, true);
- DEFINE_DEFAULT(load_s_565, true);
- DEFINE_DEFAULT( store_565, false);
+ stage_4<SK_OPTS_NS::lerp_u8 , true>,
+ stage_4<SK_OPTS_NS::lerp_565 , true>,
+ stage_4<SK_OPTS_NS::lerp_constant_float, true>,
- DEFINE_DEFAULT(scale_u8, true);
+ stage_4<SK_OPTS_NS::constant_color, true>,
- DEFINE_DEFAULT(lerp_u8, true);
- DEFINE_DEFAULT(lerp_565, true);
-#undef DEFINE_DEFAULT
+ stage_4<SK_OPTS_NS::srcover, true>,
+ };
+ static_assert(SK_ARRAY_COUNT(stages_4) == SkRasterPipeline::kNumStockStages, "");
+
+ SkRasterPipeline::Fn stages_1_3[] = {
+ stage_1_3<SK_OPTS_NS::store_565 , false>,
+ stage_1_3<SK_OPTS_NS::store_srgb, false>,
+ stage_1_3<SK_OPTS_NS::store_f16 , false>,
+
+ stage_1_3<SK_OPTS_NS::load_s_565 , true>,
+ stage_1_3<SK_OPTS_NS::load_s_srgb, true>,
+ stage_1_3<SK_OPTS_NS::load_s_f16 , true>,
+
+ stage_1_3<SK_OPTS_NS::load_d_565 , true>,
+ stage_1_3<SK_OPTS_NS::load_d_srgb, true>,
+ stage_1_3<SK_OPTS_NS::load_d_f16 , true>,
+
+ stage_1_3<SK_OPTS_NS::scale_u8, true>,
+
+ stage_1_3<SK_OPTS_NS::lerp_u8 , true>,
+ stage_1_3<SK_OPTS_NS::lerp_565 , true>,
+ stage_1_3<SK_OPTS_NS::lerp_constant_float, true>,
+
+ stage_1_3<SK_OPTS_NS::constant_color, true>,
+
+ stage_1_3<SK_OPTS_NS::srcover, true>,
+ };
+ static_assert(SK_ARRAY_COUNT(stages_1_3) == SkRasterPipeline::kNumStockStages, "");
// Each Init_foo() is defined in src/opts/SkOpts_foo.cpp.
void Init_ssse3();