aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkLinearBitmapPipeline.cpp54
-rw-r--r--src/core/SkLinearBitmapPipeline.h32
2 files changed, 17 insertions, 69 deletions
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp
index c9b71b987e..b32ff2da53 100644
--- a/src/core/SkLinearBitmapPipeline.cpp
+++ b/src/core/SkLinearBitmapPipeline.cpp
@@ -20,34 +20,6 @@
#include "SkOpts.h"
#include "SkPM4f.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// SkLinearBitmapPipeline::Stage
-template<typename Base, size_t kSize, typename Next>
-SkLinearBitmapPipeline::Stage<Base, kSize, Next>::~Stage() {
- if (fIsInitialized) {
- this->get()->~Base();
- }
-}
-
-template<typename Base, size_t kSize, typename Next>
-template<typename Variant, typename... Args>
-void SkLinearBitmapPipeline::Stage<Base, kSize, Next>::initStage(Next* next, Args&& ... args) {
- SkASSERTF(sizeof(Variant) <= sizeof(fSpace),
- "Size Variant: %d, Space: %d", sizeof(Variant), sizeof(fSpace));
-
- new (&fSpace) Variant(next, std::forward<Args>(args)...);
- fIsInitialized = true;
-};
-
-template<typename Base, size_t kSize, typename Next>
-template<typename Variant, typename... Args>
-void SkLinearBitmapPipeline::Stage<Base, kSize, Next>::initSink(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;
-};
-
namespace {
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -366,19 +338,6 @@ private:
float fPostAlpha;
};
-static SkLinearBitmapPipeline::BlendProcessorInterface* choose_blender_for_shading(
- SkAlphaType alphaType,
- float postAlpha,
- SkLinearBitmapPipeline::BlenderStage* blenderStage) {
- if (alphaType == kUnpremul_SkAlphaType) {
- blenderStage->initSink<SrcFPPixel<kUnpremul_SkAlphaType>>(postAlpha);
- } else {
- // kOpaque_SkAlphaType is treated the same as kPremul_SkAlphaType
- blenderStage->initSink<SrcFPPixel<kPremul_SkAlphaType>>(postAlpha);
- }
- return blenderStage->get();
-}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -418,7 +377,7 @@ SkLinearBitmapPipeline::SkLinearBitmapPipeline(
float postAlpha = SkColorGetA(paintColor) * (1.0f / 255.0f);
// As the stages are built, the chooser function may skip a stage. For example, with the
// identity matrix, the matrix stage is skipped, and the tilerStage is the first stage.
- auto blenderStage = choose_blender_for_shading(alphaType, postAlpha, &fBlenderStage);
+ auto blenderStage = this->chooseBlenderForShading(alphaType, postAlpha);
auto samplerStage = this->chooseSampler(
blenderStage, filterQuality, xTile, yTile, srcPixmap, paintColor);
auto tilerStage = this->chooseTiler(
@@ -727,3 +686,14 @@ SkLinearBitmapPipeline::SampleProcessorInterface* SkLinearBitmapPipeline::choose
return fMemory.createT<Sampler>(next, dimensions, xTile, yTile, pixelAccessor);
}
}
+
+Blender* SkLinearBitmapPipeline::chooseBlenderForShading(
+ SkAlphaType alphaType,
+ float postAlpha) {
+ if (alphaType == kUnpremul_SkAlphaType) {
+ return fMemory.createT<SrcFPPixel<kUnpremul_SkAlphaType>>(postAlpha);
+ } else {
+ // kOpaque_SkAlphaType is treated the same as kPremul_SkAlphaType
+ return fMemory.createT<SrcFPPixel<kPremul_SkAlphaType>>(postAlpha);
+ }
+}
diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h
index f936ffd7f9..472772e9ae 100644
--- a/src/core/SkLinearBitmapPipeline.h
+++ b/src/core/SkLinearBitmapPipeline.h
@@ -58,39 +58,14 @@ public:
void shadeSpan4f(int x, int y, SkPM4f* dst, int count);
void blitSpan(int32_t x, int32_t y, void* dst, int count);
- template<typename Base, size_t kSize, typename Next = void>
- class Stage {
- public:
- Stage() : fIsInitialized{false} {}
- ~Stage();
-
- template<typename Variant, typename... Args>
- void initStage(Next* next, Args&& ... args);
-
- template<typename Variant, typename... Args>
- void initSink(Args&& ... args);
-
- Base* get() const { return reinterpret_cast<Base*>(fSpace); }
- Base* operator->() const { return this->get(); }
- Base& operator*() const { return *(this->get()); }
-
- private:
- mutable char fSpace[kSize];
- 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 SampleStage = Stage<SampleProcessorInterface, 160, BlendProcessorInterface>;
- using BlenderStage = Stage<BlendProcessorInterface, 48>;
-
private:
- using MemoryAllocator = SkSmallAllocator<128, 4>;
+ using MemoryAllocator = SkSmallAllocator<5, 256>;
using MatrixCloner =
std::function<PointProcessorInterface* (PointProcessorInterface*, MemoryAllocator*)>;
using TilerCloner =
@@ -128,11 +103,14 @@ private:
const SkPixmap& srcPixmap,
const SkColor A8TintColor);
+ BlendProcessorInterface* chooseBlenderForShading(
+ SkAlphaType alphaType,
+ float postAlpha);
+
MemoryAllocator fMemory;
PointProcessorInterface* fFirstStage;
MatrixCloner fMatrixStageCloner;
TilerCloner fTileStageCloner;
- BlenderStage fBlenderStage;
DestinationInterface* fLastStage;
};