aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-11-04 13:41:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-04 13:41:34 -0700
commit125b2aac5a38121b3c82545acd27e74366ca83aa (patch)
treede68ba60add4594347eb4ea075224fe92d11508e
parent2fd58a29d305accdefdcd7c7dbf1b902cd758a84 (diff)
Detect pipelines which can compile to memsets.
Any pipeline that looks like: - constant_color - store_fmt can be trivially converted into an sk_memset of the right size for fmt. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2477013002 Review-Url: https://codereview.chromium.org/2477013002
-rw-r--r--src/opts/SkRasterPipeline_opts.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 155558e776..ef0902371c 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -11,8 +11,10 @@
#include "SkColorPriv.h"
#include "SkHalf.h"
#include "SkPM4f.h"
+#include "SkPM4fPriv.h"
#include "SkRasterPipeline.h"
#include "SkSRGB.h"
+#include "SkUtils.h"
#include <utility>
namespace {
@@ -517,6 +519,31 @@ namespace SK_OPTS_NS {
SI std::function<void(size_t, size_t)> compile_pipeline(const SkRasterPipeline::Stage* stages,
int nstages) {
+ if (nstages == 2 && stages[0].stage == SkRasterPipeline::constant_color) {
+ SkPM4f src = *(const SkPM4f*)stages[0].ctx;
+ void* dst = stages[1].ctx;
+ switch (stages[1].stage) {
+ case SkRasterPipeline::store_565: {
+ auto v = SkPackRGB16(src.r() * SK_R16_MASK + 0.5f,
+ src.g() * SK_G16_MASK + 0.5f,
+ src.b() * SK_B16_MASK + 0.5f);
+ return [v,dst](size_t x, size_t n) { sk_memset16(*(uint16_t**)dst + x, v, n); };
+ }
+
+ case SkRasterPipeline::store_srgb: {
+ auto v = Sk4f_toS32(src.to4f_pmorder());
+ return [v,dst](size_t x, size_t n) { sk_memset32(*(uint32_t**)dst + x, v, n); };
+ }
+
+ case SkRasterPipeline::store_f16: {
+ auto v = src.toF16();
+ return [v,dst](size_t x, size_t n) { sk_memset64(*(uint64_t**)dst + x, v, n); };
+ }
+
+ default: break;
+ }
+ }
+
struct Compiled {
Compiled(const SkRasterPipeline::Stage* stages, int nstages) {
if (nstages == 0) {