Index: src/core/SkLinearBitmapPipeline.h |
diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h |
index 452ab8ef4e2e01e27b67e1737b8a6179751d17ca..b0f7e9dd206c0d085418c42e28bc5fbe5de630e2 100644 |
--- a/src/core/SkLinearBitmapPipeline.h |
+++ b/src/core/SkLinearBitmapPipeline.h |
@@ -91,16 +91,51 @@ public: |
mutable Space fSpace; |
}; |
+/////////////////////////////////////////////////////////////////////////////////////////////////// |
+// PolyMemory |
+ template <typename Base, size_t kSize> |
+ class PolyMemory { |
+ public: |
+ PolyMemory() : fIsInitialized{false} { } |
+ ~PolyMemory() { |
+ if (fIsInitialized) { |
+ this->get()->~Base(); |
+ } |
+ } |
+ template<typename Variant, typename... Args> |
+ void init(Args&& ... args) { |
+ SkASSERTF(sizeof(Variant) <= sizeof(fSpace), |
+ "Size Variant: %d, Space: %d", sizeof(Variant), sizeof(fSpace)); |
+ |
+ new (&fSpace) Variant(std::forward<Args>(args)...); |
+ fIsInitialized = true; |
+ } |
+ |
+ Base* get() const { return reinterpret_cast<Base*>(&fSpace); } |
+ Base* operator->() const { return this->get(); } |
+ Base& operator*() const { return *(this->get()); } |
+ |
+ private: |
+ struct SK_STRUCT_ALIGN(16) Space { |
+ char space[kSize]; |
+ }; |
+ mutable Space fSpace; |
+ bool fIsInitialized; |
+ |
+ }; |
+ |
class PointProcessorInterface; |
class SampleProcessorInterface; |
class BlendProcessorInterface; |
class DestinationInterface; |
+ class PixelAccessorInterface; |
// 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, BlendProcessorInterface>; |
- using BlenderStage = Stage<BlendProcessorInterface, 40>; |
+ using MatrixStage = Stage<PointProcessorInterface, 160, PointProcessorInterface>; |
+ using TileStage = Stage<PointProcessorInterface, 160, SampleProcessorInterface>; |
+ using SampleStage = Stage<SampleProcessorInterface, 100, BlendProcessorInterface>; |
+ using BlenderStage = Stage<BlendProcessorInterface, 40>; |
+ using Accessor = PolyMemory<PixelAccessorInterface, 48>; |
private: |
PointProcessorInterface* fFirstStage; |
@@ -109,6 +144,7 @@ private: |
SampleStage fSampleStage; |
BlenderStage fBlenderStage; |
DestinationInterface* fLastStage; |
+ Accessor fAccessor; |
}; |
//////////////////////////////////////////////////////////////////////////////////////////////////// |