From 297726f36fa766e1faec25330142e2a5b3ccdc5b Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 17 Nov 2016 14:25:30 -0500 Subject: Use SkSmallAllocator for Blender stage. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4969 Change-Id: I5466e6b906c1f268860011957a5a00361c6bb66a Reviewed-on: https://skia-review.googlesource.com/4969 Reviewed-by: Mike Klein Commit-Queue: Herb Derby --- src/core/SkLinearBitmapPipeline.cpp | 54 +++++++++---------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) (limited to 'src/core/SkLinearBitmapPipeline.cpp') 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 -SkLinearBitmapPipeline::Stage::~Stage() { - if (fIsInitialized) { - this->get()->~Base(); - } -} - -template -template -void SkLinearBitmapPipeline::Stage::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)...); - fIsInitialized = true; -}; - -template -template -void SkLinearBitmapPipeline::Stage::initSink(Args&& ... args) { - SkASSERTF(sizeof(Variant) <= sizeof(fSpace), - "Size Variant: %d, Space: %d", sizeof(Variant), sizeof(fSpace)); - new (&fSpace) Variant(std::forward(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>(postAlpha); - } else { - // kOpaque_SkAlphaType is treated the same as kPremul_SkAlphaType - blenderStage->initSink>(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(next, dimensions, xTile, yTile, pixelAccessor); } } + +Blender* SkLinearBitmapPipeline::chooseBlenderForShading( + SkAlphaType alphaType, + float postAlpha) { + if (alphaType == kUnpremul_SkAlphaType) { + return fMemory.createT>(postAlpha); + } else { + // kOpaque_SkAlphaType is treated the same as kPremul_SkAlphaType + return fMemory.createT>(postAlpha); + } +} -- cgit v1.2.3