Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Unified Diff: src/opts/SkRasterPipeline_opts.h

Issue 2477013002: Detect pipelines which can compile to memsets. (Closed)
Patch Set: natty Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkRasterPipeline_opts.h
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index bd42632b4b0cfb6ac049e15a41a2f589041b8f3c..ffc1101eeeb481fd1ecd32d81bfb2e7cd891dbf3 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 {
@@ -499,6 +501,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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698