aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-02-29 13:21:33 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-29 13:21:33 -0800
commit683ea9a08d43cc3a3a5ca7f1bc3452823a881f82 (patch)
treef362710082c7c47d685f649aa053f327da57c234
parent755539f0b1f3331359d1ea2b65b6bb93387b7821 (diff)
Simplify the poly union.
-rw-r--r--src/core/SkLinearBitmapPipeline.cpp18
-rw-r--r--src/core/SkLinearBitmapPipeline.h10
2 files changed, 8 insertions, 20 deletions
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp
index 347803cd30..4d4a4cfe4d 100644
--- a/src/core/SkLinearBitmapPipeline.cpp
+++ b/src/core/SkLinearBitmapPipeline.cpp
@@ -273,21 +273,6 @@ private:
Strategy fStrategy;
};
-class SkippedStage final : public SkLinearBitmapPipeline::BilerpProcessorInterface {
- void VECTORCALL pointListFew(int n, Sk4s xs, Sk4s ys) override {
- SkFAIL("Skipped stage.");
- }
- void VECTORCALL pointList4(Sk4s xs, Sk4s ys) override {
- SkFAIL("Skipped stage.");
- }
- void VECTORCALL bilerpList(Sk4s xs, Sk4s ys) override {
- SkFAIL("Skipped stage.");
- }
- void pointSpan(Span span) override {
- SkFAIL("Skipped stage.");
- }
-};
-
class TranslateMatrixStrategy {
public:
TranslateMatrixStrategy(SkVector offset)
@@ -390,7 +375,6 @@ static SkLinearBitmapPipeline::PointProcessorInterface* choose_matrix(
next,
SkVector{inverse.getTranslateX(), inverse.getTranslateY()});
} else {
- matrixProc->Initialize<SkippedStage>();
return next;
}
return matrixProc->get();
@@ -447,7 +431,6 @@ static SkLinearBitmapPipeline::PointProcessorInterface* choose_filter(
SkFilterQuality filterQuailty,
SkLinearBitmapPipeline::FilterStage* filterProc) {
if (SkFilterQuality::kNone_SkFilterQuality == filterQuailty) {
- filterProc->Initialize<SkippedStage>();
return next;
} else {
filterProc->Initialize<ExpandBilerp<>>(next);
@@ -689,7 +672,6 @@ static SkLinearBitmapPipeline::BilerpProcessorInterface* choose_tiler(
SkFAIL("Not implemented.");
break;
}
- tileProcY->Initialize<SkippedStage>();
} else {
switch (yMode) {
case SkShader::kClamp_TileMode:
diff --git a/src/core/SkLinearBitmapPipeline.h b/src/core/SkLinearBitmapPipeline.h
index 3d5dd31df3..c65b7538aa 100644
--- a/src/core/SkLinearBitmapPipeline.h
+++ b/src/core/SkLinearBitmapPipeline.h
@@ -29,9 +29,13 @@ public:
template<typename Base, size_t kSize>
class PolymorphicUnion {
public:
- PolymorphicUnion() {}
+ PolymorphicUnion() : fIsInitialized{false} {}
- ~PolymorphicUnion() { get()->~Base(); }
+ ~PolymorphicUnion() {
+ if (fIsInitialized) {
+ get()->~Base();
+ }
+ }
template<typename Variant, typename... Args>
void Initialize(Args&&... args) {
@@ -39,6 +43,7 @@ public:
"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); }
@@ -49,6 +54,7 @@ public:
struct SK_STRUCT_ALIGN(16) Space {
char space[kSize];
};
+ bool fIsInitialized;
mutable Space fSpace;
};