diff options
author | 2016-10-25 10:27:33 -0400 | |
---|---|---|
committer | 2016-10-25 17:30:38 +0000 | |
commit | aebfb45104eeb6dab5dbbedda13c2eaa7b7f7868 (patch) | |
tree | 7dcbf9bf86bd1b9fad0048dccbabb11e47a1d3fb /src/core/SkRasterPipeline.h | |
parent | cc813ae9a0afe4259f12b655d9336662a6e2c100 (diff) |
Move SkRasterPipeline further into SkOpts.
The portable code now becomes entirely focused on enum+ptr descriptions, leaving the concrete implementation of the pipeline to SkOpts::run_pipeline().
As implemented, the concrete implementation is basically the same, with a little more type safety.
Speed is essentially unchanged on my laptop, and that's having run_pipeline() rebuild its concrete state every call. There's room for improvement there if we split this into a compile_pipeline() / run_pipeline() sort of thing, which is my next planned CL.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3920
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Change-Id: Ie4c554f51040426de7c5c144afa5d9d9d8938012
Reviewed-on: https://skia-review.googlesource.com/3920
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkRasterPipeline.h')
-rw-r--r-- | src/core/SkRasterPipeline.h | 98 |
1 files changed, 31 insertions, 67 deletions
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h index 525a8dbe72..60279dd168 100644 --- a/src/core/SkRasterPipeline.h +++ b/src/core/SkRasterPipeline.h @@ -53,72 +53,31 @@ // TODO: There may be a better place to stuff tail, e.g. in the bottom alignment bits of // the Stage*. This mostly matters on 64-bit Windows where every register is precious. +#define SK_RASTER_PIPELINE_STAGES(M) \ + M(swap_src_dst) M(constant_color) \ + M(load_s_565) M(load_d_565) M(store_565) \ + M(load_s_srgb) M(load_d_srgb) M(store_srgb) \ + M(load_s_f16) M(load_d_f16) M(store_f16) \ + M(scale_u8) \ + M(lerp_u8) M(lerp_565) M(lerp_constant_float) \ + M(dst) \ + M(dstatop) M(dstin) M(dstout) M(dstover) \ + M(srcatop) M(srcin) M(srcout) M(srcover) \ + M(clear) M(modulate) M(multiply) M(plus_) M(screen) M(xor_) \ + M(colorburn) M(colordodge) M(darken) M(difference) \ + M(exclusion) M(hardlight) M(lighten) M(overlay) M(softlight) + class SkRasterPipeline { public: - struct Stage { - // It makes next() a good bit cheaper if we hold the next function to call here, - // rather than logically simpler choice of the function implementing this stage. - void (*fNext)(); - void* fCtx; - }; + // No pipeline may be more than kMaxStages long. + static const int kMaxStages = 32; SkRasterPipeline(); - // Run the pipeline constructed with append(), walking x through [x,x+n), - // generally in 4-pixel steps, with perhaps one jagged tail step. - void run(size_t x, size_t n); - void run(size_t n) { this->run(0, n); } - enum StockStage { - just_return, - swap_src_dst, - - store_565, - store_srgb, - store_f16, - - load_s_565, - load_s_srgb, - load_s_f16, - - load_d_565, - load_d_srgb, - load_d_f16, - - scale_u8, - - lerp_u8, - lerp_565, - lerp_constant_float, - - constant_color, - - dst, - dstatop, - dstin, - dstout, - dstover, - srcatop, - srcin, - srcout, - srcover, - clear, - modulate, - multiply, - plus_, - screen, - xor_, - colorburn, - colordodge, - darken, - difference, - exclusion, - hardlight, - lighten, - overlay, - softlight, - - kNumStockStages, + #define M(stage) stage, + SK_RASTER_PIPELINE_STAGES(M) + #undef M }; void append(StockStage, void* = nullptr); void append(StockStage stage, const void* ctx) { this->append(stage, const_cast<void*>(ctx)); } @@ -126,15 +85,20 @@ public: // Append all stages to this pipeline. void extend(const SkRasterPipeline&); -private: - using Stages = SkSTArray<10, Stage, /*MEM_COPY=*/true>; + // Run the pipeline constructed with append(), walking x through [x,x+n), + // generally in 4-pixel steps, with perhaps one jagged tail step. + void run(size_t x, size_t n) const; + void run(size_t n) const { this->run(0, n); } - void append(void (*body)(), void (*tail)(), void*); - Stages fBody, - fTail; - void (*fBodyStart)() = nullptr; - void (*fTailStart)() = nullptr; + struct Stage { + StockStage stage; + void* ctx; + }; + +private: + int fNum = 0; + Stage fStages[kMaxStages]; }; #endif//SkRasterPipeline_DEFINED |