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

Unified Diff: src/core/SkLinearBitmapPipeline.h

Issue 1998793002: Make an embeddable container to hold linear pipelines. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unused defs Created 4 years, 7 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.cpp ('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 853e56fd1b2f9b4d4439085eaa36fad01d4f7774..dce537aa6e6aa90f27f52667e468ee27a712a91a 100644
--- a/src/core/SkLinearBitmapPipeline.h
+++ b/src/core/SkLinearBitmapPipeline.h
@@ -13,6 +13,13 @@
#include "SkMatrix.h"
#include "SkShader.h"
+class SkEmbeddableLinearPipeline;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// SkLinearBitmapPipeline - encapsulates all the machinery for doing floating point pixel
+// processing in a linear color space.
+// Note: this class has unusual alignment requirements due to its use of SIMD instructions. The
+// class SkEmbeddableLinearPipeline below manages these requirements.
class SkLinearBitmapPipeline {
public:
SkLinearBitmapPipeline(
@@ -22,10 +29,14 @@ public:
SkColor paintColor,
const SkPixmap& srcPixmap);
-
+ SkLinearBitmapPipeline(
+ const SkLinearBitmapPipeline& pipeline,
+ const SkPixmap& srcPixmap,
+ SkXfermode::Mode xferMode,
+ const SkImageInfo& dstInfo);
static bool ClonePipelineForBlitting(
- void* blitterStorage,
+ SkEmbeddableLinearPipeline* pipelineStorage,
const SkLinearBitmapPipeline& pipeline,
SkMatrix::TypeMask matrixMask,
SkShader::TileMode xTileMode,
@@ -87,12 +98,6 @@ public:
using BlenderStage = Stage<BlendProcessorInterface, 40>;
private:
- SkLinearBitmapPipeline(
- const SkLinearBitmapPipeline& pipeline,
- const SkPixmap& srcPixmap,
- SkXfermode::Mode xferMode,
- const SkImageInfo& dstInfo);
-
PointProcessorInterface* fFirstStage;
MatrixStage fMatrixStage;
TileStage fTileStage;
@@ -101,4 +106,35 @@ private:
DestinationInterface* fLastStage;
};
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SkEmbeddableLinearPipeline - manage stricter alignment needs for SkLinearBitmapPipeline.
+class SkEmbeddableLinearPipeline {
+public:
+ SkEmbeddableLinearPipeline() { }
+ ~SkEmbeddableLinearPipeline() {
+ if (get() != nullptr) {
+ 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)...};
+ }
+
+ SkLinearBitmapPipeline* get() const { return fPipeline; }
+ 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};
+};
+
#endif // SkLinearBitmapPipeline_DEFINED
« no previous file with comments | « src/core/SkBitmapProcShader.cpp ('k') | src/core/SkLinearBitmapPipeline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698