#include <functional>
#include <vector>
+struct SkJumper_Engine;
+
/**
* SkRasterPipeline provides a cheap way to chain together a pixel processing pipeline.
*
class SkRasterPipeline {
public:
- SkRasterPipeline(int size_hint=0);
+ explicit SkRasterPipeline(SkArenaAlloc*);
+
+ SkRasterPipeline(const SkRasterPipeline&) = delete;
+ SkRasterPipeline(SkRasterPipeline&&) = default;
+
+ SkRasterPipeline& operator=(const SkRasterPipeline&) = delete;
+ SkRasterPipeline& operator=(SkRasterPipeline&&) = default;
+
+ void reset();
enum StockStage {
#define M(stage) stage,
void run(size_t x, size_t n) const;
// Allocates a thunk which amortizes run() setup cost in alloc.
- std::function<void(size_t, size_t)> compile(SkArenaAlloc*) const;
+ std::function<void(size_t, size_t)> compile() const;
void dump() const;
- struct Stage {
- StockStage stage;
- void* ctx;
- };
-
// Conversion from sRGB can be subtly tricky when premultiplication is involved.
// Use these helpers to keep things sane.
void append_from_srgb(SkAlphaType);
- bool empty() const { return fStages.empty(); }
+ bool empty() const { return fStages == nullptr; }
+
+private:
+ struct StageList {
+ StageList* prev;
+ StockStage stage;
+ void* ctx;
+ };
+
+ static void BuildPipeline(const StageList*, const SkJumper_Engine&, void**);
+ void unchecked_append(StockStage, void*);
+ void extend(const StageList*);
- // Cheaply reset all state so that empty() returns true.
- void rewind();
+ SkArenaAlloc* fAlloc;
+ StageList* fStages;
+ int fSlotsNeeded;
+};
+
+template <size_t bytes>
+class SkRasterPipeline_ : public SkRasterPipeline {
+public:
+ SkRasterPipeline_()
+ : SkRasterPipeline(&fBuiltinAlloc)
+ , fBuiltinAlloc(fBuffer) {}
private:
- std::vector<Stage> fStages;
+ char fBuffer[bytes];
+ SkArenaAlloc fBuiltinAlloc;
};
+
#endif//SkRasterPipeline_DEFINED