Chromium Code Reviews| Index: src/core/SkLinearBitmapPipeline.h |
| diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h |
| index 3abdb8014aa134503d7694c7c9ba25705572d42e..d8b78ea833777269c50f42532abf33c231be375c 100644 |
| --- a/src/core/SkLinearBitmapPipeline.h |
| +++ b/src/core/SkLinearBitmapPipeline.h |
| @@ -84,7 +84,7 @@ public: |
| private: |
| std::function<void (Next*, void*)> fStageCloner; |
| - alignas(16) mutable char fSpace[kSize]; |
| + mutable char fSpace[kSize]; |
| bool fIsInitialized; |
| }; |
| @@ -113,8 +113,8 @@ public: |
| Base& operator*() const { return *(this->get()); } |
| private: |
| - alignas(16) mutable char fSpace[kSize]; |
| - bool fIsInitialized; |
| + mutable char fSpace[kSize]; |
| + bool fIsInitialized; |
| }; |
| @@ -125,8 +125,8 @@ public: |
| 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 MatrixStage = Stage<PointProcessorInterface, 56, PointProcessorInterface>; |
| + using TileStage = Stage<PointProcessorInterface, 48, SampleProcessorInterface>; |
| using SampleStage = Stage<SampleProcessorInterface, 160, BlendProcessorInterface>; |
| using BlenderStage = Stage<BlendProcessorInterface, 48>; |
| using Accessor = PolyMemory<PixelAccessorInterface, 64>; |
| @@ -147,29 +147,26 @@ class SkEmbeddableLinearPipeline { |
| public: |
| SkEmbeddableLinearPipeline() { } |
| ~SkEmbeddableLinearPipeline() { |
| - if (get() != nullptr) { |
| + if (inited) { |
| get()->~SkLinearBitmapPipeline(); |
| } |
| } |
| template <typename... Args> |
| void init(Args&&... args) { |
| - // Ensure that our pipeline is created at a 16 byte aligned address. |
| - fPipeline = (SkLinearBitmapPipeline*)SkAlign16((intptr_t)fPipelineStorage); |
| - new (fPipeline) SkLinearBitmapPipeline{std::forward<Args>(args)...}; |
| + new (fPipelineStorage) SkLinearBitmapPipeline{std::forward<Args>(args)...}; |
| + inited = true; |
| } |
| - SkLinearBitmapPipeline* get() const { return fPipeline; } |
| + SkLinearBitmapPipeline* get() const { |
| + return reinterpret_cast<SkLinearBitmapPipeline*>(fPipelineStorage); |
| + } |
| SkLinearBitmapPipeline& operator*() const { return *this->get(); } |
| SkLinearBitmapPipeline* operator->() const { return this->get(); } |
| private: |
| - enum { |
| - kActualSize = sizeof(SkLinearBitmapPipeline), |
| - kPaddedSize = SkAlignPtr(kActualSize + 12), |
| - }; |
| - void* fPipelineStorage[kPaddedSize / sizeof(void*)]; |
| - SkLinearBitmapPipeline* fPipeline{nullptr}; |
| + alignas(SkLinearBitmapPipeline) mutable char fPipelineStorage[sizeof(SkLinearBitmapPipeline)]; |
|
mtklein_C
2016/11/07 21:48:15
Does this really need to be mutable? Isn't it onl
herb_g
2016/11/08 14:59:34
It really does. The const on get() makes it so. In
|
| + bool inited {false}; |
|
mtklein_C
2016/11/07 21:48:15
fInited, or fIsInitialized to be consistent with w
herb_g
2016/11/08 14:59:33
Done.
|
| }; |
| #endif // SkLinearBitmapPipeline_DEFINED |