Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: src/core/SkLinearBitmapPipeline.h

Issue 2473143002: Use alignas to force alignment. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPostConfig.h ('k') | src/core/SkSmallAllocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLinearBitmapPipeline.h
diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h
index 91b573df5d8c5a95de93ff3b31a5c82741633c57..aa80b9c51774cafbea90e6398b688a37a7ac2b83 100644
--- a/src/core/SkLinearBitmapPipeline.h
+++ b/src/core/SkLinearBitmapPipeline.h
@@ -78,17 +78,17 @@ public:
// the pipeline on a new sampler.
Base* cloneStageTo(Next* next, Stage* cloneToStage) const;
- Base* get() const { return reinterpret_cast<Base*>(&fSpace); }
+ 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];
- };
- bool fIsInitialized;
- mutable Space fSpace;
+ // This could be implemented using std::aligned_storage, but MSVC does not implement this. Use the
mtklein_C 2016/11/03 20:47:36 This code is clearer and less reinterpret_cast-y t
+ // work around from:
+ // https://connect.microsoft.com/VisualStudio/feedback/details/1559873/std-aligned-storage-cannot-align-type-with-16-byte
+ mutable alignas(16) char fSpace[kSize];
+ bool fIsInitialized;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -111,16 +111,13 @@ public:
fIsInitialized = true;
}
- Base* get() const { return reinterpret_cast<Base*>(&fSpace); }
+ 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;
+ mutable alignas(16) char fSpace[kSize];
+ bool fIsInitialized;
};
@@ -134,7 +131,7 @@ public:
using MatrixStage = Stage<PointProcessorInterface, 160, PointProcessorInterface>;
using TileStage = Stage<PointProcessorInterface, 160, SampleProcessorInterface>;
using SampleStage = Stage<SampleProcessorInterface, 160, BlendProcessorInterface>;
- using BlenderStage = Stage<BlendProcessorInterface, 40>;
+ using BlenderStage = Stage<BlendProcessorInterface, 48>;
using Accessor = PolyMemory<PixelAccessorInterface, 64>;
private:
« no previous file with comments | « include/core/SkPostConfig.h ('k') | src/core/SkSmallAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698