aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-21 10:13:32 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-21 10:13:32 +0000
commit7c9d0f3104408a64d52b84643f116179022d73bd (patch)
tree85aa1d482887cfed57315f1ce8f1d928001236ae /src
parent0b45dc45d67144421904555ccf53782cc8d9969d (diff)
Factory methods for heap-allocated SkMaskFilter objects.
This is part of an effort to ensure that all SkPaint effects can only be allocated on the heap. This patch makes the constructors of SkMaskFilter and its subclasses non-public and instead provides factory methods for creating these objects on the heap. We temporarily keep constructor of publicly visible classes public behind a flag. BUG=skia:2187 R=scroggo@google.com, mtklein@google.com, reed@google.com Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/173633003 git-svn-id: http://skia.googlecode.com/svn/trunk@13527 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkEmbossMaskFilter.cpp9
-rw-r--r--src/views/SkWidgets.cpp4
2 files changed, 4 insertions, 9 deletions
diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp
index 6747bf5b38..ab549ccac8 100644
--- a/src/effects/SkEmbossMaskFilter.cpp
+++ b/src/effects/SkEmbossMaskFilter.cpp
@@ -49,7 +49,7 @@ SkMaskFilter* SkBlurMaskFilter::CreateEmboss(SkScalar blurSigma, const SkScalar
light.fAmbient = SkToU8(am);
light.fSpecular = SkToU8(sp);
- return SkNEW_ARGS(SkEmbossMaskFilter, (blurSigma, light));
+ return SkEmbossMaskFilter::Create(blurSigma, light);
}
///////////////////////////////////////////////////////////////////////////////
@@ -68,13 +68,6 @@ SkEmbossMaskFilter::SkEmbossMaskFilter(SkScalar blurSigma, const Light& light)
normalize(fLight.fDirection);
}
-SkEmbossMaskFilter::SkEmbossMaskFilter(const Light& light, SkScalar blurRadius)
- : fLight(light) {
- normalize(fLight.fDirection);
-
- fBlurSigma = SkBlurMask::ConvertRadiusToSigma(blurRadius);
-}
-
SkMask::Format SkEmbossMaskFilter::getFormat() const {
return SkMask::k3D_Format;
}
diff --git a/src/views/SkWidgets.cpp b/src/views/SkWidgets.cpp
index fb16f1ec0d..cde2b42738 100644
--- a/src/views/SkWidgets.cpp
+++ b/src/views/SkWidgets.cpp
@@ -234,6 +234,7 @@ static const char* computeAnimatorState(int enabled, int focused, SkButtonWidget
return "enabled";
}
+#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkEmbossMaskFilter.h"
@@ -255,7 +256,8 @@ static void create_emboss(SkPaint* paint, SkScalar radius, bool focus, bool pres
if (focus)
light.fDirection[2] += SK_Scalar1/4;
- paint->setMaskFilter(new SkEmbossMaskFilter(light, radius))->unref();
+ SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(radius);
+ paint->setMaskFilter(new SkEmbossMaskFilter(sigma, light))->unref();
}
void SkPushButtonWidget::onDraw(SkCanvas* canvas)