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

Unified Diff: src/core/SkLinearBitmapPipeline.h

Issue 2100323002: Reduce size of LinearBitmapPipeline (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Sync with new SK_VECTORCALL. Created 4 years, 5 months 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 | « src/core/SkBitmapProcShader.h ('k') | src/core/SkLinearBitmapPipeline.cpp » ('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 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;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkLinearBitmapPipeline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698