aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRasterPipeline.h
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-05-24 07:53:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-24 14:54:15 +0000
commitb24704d35f67f5b460be9c92794892e06adceb46 (patch)
treebfa2c4929e37da568f8b9ccf704f0ea07c48a17e /src/core/SkRasterPipeline.h
parent3cac5b8d736a81134f2acd3bf4af9b92c6825f2a (diff)
SkRasterPipeline in SkArenaAlloc
Bug: skia:6673 Change-Id: Ia2bae4f6a9039a007a10b6b45bcf2f0854bf6e5c Reviewed-on: https://skia-review.googlesource.com/17794 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkRasterPipeline.h')
-rw-r--r--src/core/SkRasterPipeline.h49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/core/SkRasterPipeline.h b/src/core/SkRasterPipeline.h
index 372503381b..117ecf3158 100644
--- a/src/core/SkRasterPipeline.h
+++ b/src/core/SkRasterPipeline.h
@@ -16,6 +16,8 @@
#include <functional>
#include <vector>
+struct SkJumper_Engine;
+
/**
* SkRasterPipeline provides a cheap way to chain together a pixel processing pipeline.
*
@@ -110,7 +112,15 @@
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,
@@ -127,26 +137,43 @@ public:
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