Chromium Code Reviews| Index: src/core/SkLinearBitmapPipeline.h |
| diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h |
| index 32e464100fc2144696193d77a5547ece56befd02..0d0d5e1278e16bd06bc24d87015064a30c5823ea 100644 |
| --- a/src/core/SkLinearBitmapPipeline.h |
| +++ b/src/core/SkLinearBitmapPipeline.h |
| @@ -8,11 +8,9 @@ |
| #ifndef SkLinearBitmapPipeline_DEFINED |
| #define SkLinearBitmapPipeline_DEFINED |
| - |
| #include "SkColor.h" |
| #include "SkImageInfo.h" |
| #include "SkMatrix.h" |
| -#include "SkNx.h" |
| #include "SkShader.h" |
| class SkLinearBitmapPipeline { |
| @@ -27,31 +25,31 @@ public: |
| void shadeSpan4f(int x, int y, SkPM4f* dst, int count); |
| - template<typename Base, size_t kSize> |
| - class PolymorphicUnion { |
| + template<typename Base, size_t kSize, typename Next = void> |
| + class Stage { |
| public: |
| - PolymorphicUnion() : fIsInitialized{false} {} |
| + Stage() : fIsInitialized{false} {} |
| + ~Stage(); |
| - ~PolymorphicUnion() { |
| - if (fIsInitialized) { |
| - this->get()->~Base(); |
| - } |
| - } |
| + template<typename Variant, typename... Args> |
| + void initStage(Next* next, Args&& ... args); |
| template<typename Variant, typename... Args> |
| - void Initialize(Args&&... args) { |
| - SkASSERTF(sizeof(Variant) <= sizeof(fSpace), |
| - "Size Variant: %d, Space: %d", sizeof(Variant), sizeof(fSpace)); |
| + void initSink(Args&& ... args); |
| - new(&fSpace) Variant(std::forward<Args>(args)...); |
| - fIsInitialized = true; |
| - }; |
| + template <typename To, typename From> |
| + To* getInterface(); |
| + |
| + // Note: There is no cloneSinkTo method because to code usually places the top part of |
|
mtklein
2016/04/08 19:30:29
to -> the ?
herb_g
2016/04/08 19:51:55
Done.
|
| + // the pipeline on a new sampler. |
|
mtklein
2016/04/08 19:30:29
Copy this stage to `cloneToStage` with `next` as i
herb_g
2016/04/08 19:51:55
Done.
|
| + Base* cloneStageTo(Next* next, Stage* cloneToStage) const; |
| Base* get() const { return reinterpret_cast<Base*>(&fSpace); } |
| Base* operator->() const { return this->get(); } |
| Base& operator*() const { return *(this->get()); } |
| private: |
| + std::function<void (Next*, void*)> fStageCloner; |
| struct SK_STRUCT_ALIGN(16) Space { |
| char space[kSize]; |
| }; |
| @@ -61,22 +59,22 @@ public: |
| class PointProcessorInterface; |
| class SampleProcessorInterface; |
| - class PixelPlacerInterface; |
| + class MixProcessorInterface; |
| class DestinationInterface; |
| - // These values were generated by the assert above in PolymorphicUnion. |
| - using MatrixStage = PolymorphicUnion<PointProcessorInterface, 160>; |
| - using TileStage = PolymorphicUnion<PointProcessorInterface, 160>; |
| - using SampleStage = PolymorphicUnion<SampleProcessorInterface,100>; |
| - using PixelStage = PolymorphicUnion<PixelPlacerInterface, 80>; |
| + // These values were generated by the assert above in Stage::init{Sink|Stage}. |
| + using MatrixStage = Stage<PointProcessorInterface, 160, PointProcessorInterface>; |
| + using TileStage = Stage<PointProcessorInterface, 160, SampleProcessorInterface>; |
| + using SampleStage = Stage<SampleProcessorInterface, 100, MixProcessorInterface>; |
| + using MixStage = Stage<MixProcessorInterface, 80>; |
|
mtklein
2016/04/08 19:30:29
BlendStage or XferStage?
herb_g
2016/04/08 19:51:55
Done.
|
| private: |
| PointProcessorInterface* fFirstStage; |
| - MatrixStage fMatrixStage; |
| - TileStage fTiler; |
| - SampleStage fSampleStage; |
| - PixelStage fPixelStage; |
| - DestinationInterface* fLastStage; |
| + MatrixStage fMatrixStage; |
| + TileStage fTileStage; |
| + SampleStage fSampleStage; |
| + MixStage fMixStage; |
| + DestinationInterface* fLastStage; |
| }; |
| #endif // SkLinearBitmapPipeline_DEFINED |