aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkLinearBitmapPipeline.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2016-11-17 14:25:30 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-17 20:15:01 +0000
commit297726f36fa766e1faec25330142e2a5b3ccdc5b (patch)
tree6d456ef4604845c067640bbaf205994a7f0a42b7 /src/core/SkLinearBitmapPipeline.cpp
parent4e9bb7470d97c290530da94fcaf44cd1baa91329 (diff)
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 <mtklein@chromium.org> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkLinearBitmapPipeline.cpp')
-rw-r--r--src/core/SkLinearBitmapPipeline.cpp54
1 files changed, 12 insertions, 42 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);
+ }
+}