summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/ContextShadow.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-10-22 13:02:20 +0100
committerBen Murdoch <benm@google.com>2010-10-26 15:21:41 +0100
commita94275402997c11dd2e778633dacf4b7e630a35d (patch)
treee66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/platform/graphics/ContextShadow.cpp
parent09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff)
downloadexternal_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip
external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz
external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/platform/graphics/ContextShadow.cpp')
-rw-r--r--WebCore/platform/graphics/ContextShadow.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/WebCore/platform/graphics/ContextShadow.cpp b/WebCore/platform/graphics/ContextShadow.cpp
index 1007962..87a1c5c 100644
--- a/WebCore/platform/graphics/ContextShadow.cpp
+++ b/WebCore/platform/graphics/ContextShadow.cpp
@@ -39,18 +39,20 @@ namespace WebCore {
ContextShadow::ContextShadow()
: m_type(NoShadow)
- , m_blurRadius(0)
+ , m_blurDistance(0)
+ , m_layerContext(0)
{
}
ContextShadow::ContextShadow(const Color& color, float radius, const FloatSize& offset)
: m_color(color)
- , m_blurRadius(round(radius))
+ , m_blurDistance(round(radius))
, m_offset(offset)
+ , m_layerContext(0)
{
// See comments in http://webkit.org/b/40793, it seems sensible
// to follow Skia's limit of 128 pixels of blur radius
- m_blurRadius = min(m_blurRadius, 128);
+ m_blurDistance = min(m_blurDistance, 128);
// The type of shadow is decided by the blur radius, shadow offset, and shadow color.
if (!m_color.isValid() || !color.alpha()) {
@@ -71,7 +73,7 @@ void ContextShadow::clear()
{
m_type = NoShadow;
m_color = Color();
- m_blurRadius = 0;
+ m_blurDistance = 0;
m_offset = FloatSize();
}
@@ -85,8 +87,9 @@ static const int BlurSumShift = 15;
void ContextShadow::blurLayerImage(unsigned char* imageData, const IntSize& size, int rowStride)
{
int channels[4] = { 3, 0, 1, 3 };
- int dmax = m_blurRadius >> 1;
- int dmin = dmax - 1 + (m_blurRadius & 1);
+ int d = max(2, static_cast<int>(floorf((2 / 3.f) * m_blurDistance)));
+ int dmax = d >> 1;
+ int dmin = dmax - 1 + (d & 1);
if (dmin < 0)
dmin = 0;
@@ -153,8 +156,8 @@ void ContextShadow::calculateLayerBoundingRect(const FloatRect& layerArea, const
destinationRect.move(m_offset);
m_layerRect = enclosingIntRect(destinationRect);
- // We expand the area by the blur radius * 2 to give extra space for the blur transition.
- m_layerRect.inflate((m_type == BlurShadow) ? ceil(m_blurRadius * 2) : 0);
+ // We expand the area by the blur radius to give extra space for the blur transition.
+ m_layerRect.inflate(m_type == BlurShadow ? m_blurDistance : 0);
if (!clipRect.contains(m_layerRect)) {
// No need to have the buffer larger than the clip.
@@ -167,7 +170,7 @@ void ContextShadow::calculateLayerBoundingRect(const FloatRect& layerArea, const
// We adjust again because the pixels at the borders are still
// potentially affected by the pixels outside the buffer.
if (m_type == BlurShadow)
- m_layerRect.inflate((m_type == BlurShadow) ? ceil(m_blurRadius * 2) : 0);
+ m_layerRect.inflate(m_type == BlurShadow ? m_blurDistance : 0);
}
}