[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
mrobinson at webkit.org
mrobinson at webkit.org
Wed Dec 22 14:19:38 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 321e01e29161d6e296439fccd240fc53d2288ed9
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Oct 6 19:37:45 2010 +0000
2010-10-06 Alejandro G. Castro <alex at igalia.com>
Reviewed by Dirk Schulze.
ContextShadow should not use the blur radius as kernel size of the
box blurs
https://bugs.webkit.org/show_bug.cgi?id=46918
Calculate the size of the kernel in the blur algorithm using the radius instead
of using the blur distance directly. Change the name of the variables to match the
terminology in the spec.
* platform/graphics/ContextShadow.cpp:
(WebCore::ContextShadow::ContextShadow):
(WebCore::ContextShadow::clear):
(WebCore::ContextShadow::blurLayerImage):
(WebCore::ContextShadow::calculateLayerBoundingRect):
* platform/graphics/ContextShadow.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69223 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a7050c1..db4bd76 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-10-06 Alejandro G. Castro <alex at igalia.com>
+
+ Reviewed by Dirk Schulze.
+
+ ContextShadow should not use the blur radius as kernel size of the
+ box blurs
+ https://bugs.webkit.org/show_bug.cgi?id=46918
+
+ Calculate the size of the kernel in the blur algorithm using the radius instead
+ of using the blur distance directly. Change the name of the variables to match the
+ terminology in the spec.
+
+ * platform/graphics/ContextShadow.cpp:
+ (WebCore::ContextShadow::ContextShadow):
+ (WebCore::ContextShadow::clear):
+ (WebCore::ContextShadow::blurLayerImage):
+ (WebCore::ContextShadow::calculateLayerBoundingRect):
+ * platform/graphics/ContextShadow.h:
+
2010-10-06 Andras Becsi <abecsi at webkit.org>
Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/platform/graphics/ContextShadow.cpp b/WebCore/platform/graphics/ContextShadow.cpp
index 51d748f..79803b0 100644
--- a/WebCore/platform/graphics/ContextShadow.cpp
+++ b/WebCore/platform/graphics/ContextShadow.cpp
@@ -39,18 +39,18 @@ namespace WebCore {
ContextShadow::ContextShadow()
: m_type(NoShadow)
- , m_blurRadius(0)
+ , m_blurDistance(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)
{
// 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 +71,7 @@ void ContextShadow::clear()
{
m_type = NoShadow;
m_color = Color();
- m_blurRadius = 0;
+ m_blurDistance = 0;
m_offset = FloatSize();
}
@@ -85,8 +85,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 +154,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) ? 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 +168,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) ? m_blurRadius * 2 : 0);
+ m_layerRect.inflate(m_type == BlurShadow ? m_blurDistance : 0);
}
}
diff --git a/WebCore/platform/graphics/ContextShadow.h b/WebCore/platform/graphics/ContextShadow.h
index 335af8d..a396cbe 100644
--- a/WebCore/platform/graphics/ContextShadow.h
+++ b/WebCore/platform/graphics/ContextShadow.h
@@ -66,7 +66,7 @@ public:
} m_type;
Color m_color;
- int m_blurRadius;
+ int m_blurDistance;
FloatSize m_offset;
ContextShadow();
diff --git a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
index 3133041..6f5be28 100644
--- a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
@@ -187,7 +187,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
// drawShadowedRect still does not work with rotations.
// https://bugs.webkit.org/show_bug.cgi?id=45042
- float radiusTwice = m_blurRadius * 2;
+ float radiusTwice = m_blurDistance * 2;
cairo_t* cr = context->platformContext();
if ((!context->getCTM().isIdentityOrTranslationOrFlipped()) || (radiusTwice > rect.width())
|| (radiusTwice > rect.height()) || (m_type != BlurShadow)) {
@@ -200,7 +200,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
// Determine dimensions of shadow rect.
FloatRect shadowRect = FloatRect(rect.location(), shadowBufferSize);
- shadowRect.move(- m_blurRadius, - m_blurRadius);
+ shadowRect.move(- m_blurDistance, - m_blurDistance);
// Size of the tiling side.
int sideTileWidth = 1;
@@ -239,7 +239,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
cairo_set_operator(m_layerContext, CAIRO_OPERATOR_OVER);
// Draw the rectangle.
- IntRect templateRect = IntRect(m_blurRadius, m_blurRadius, shadowTemplateSize.width() - radiusTwice, shadowTemplateSize.height() - radiusTwice);
+ IntRect templateRect = IntRect(m_blurDistance, m_blurDistance, shadowTemplateSize.width() - radiusTwice, shadowTemplateSize.height() - radiusTwice);
appendWebCorePathToCairoContext(m_layerContext, Path::createRoundedRectangle(templateRect, topLeftRadius, topRightRadius,
bottomLeftRadius, bottomRightRadius));
@@ -275,7 +275,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
FloatRect tileRect = FloatRect(radiusTwice + topLeftRadius.width(), 0, sideTileWidth, radiusTwice);
FloatRect destRect = tileRect;
destRect.move(shadowRect.x(), shadowRect.y());
- destRect.setWidth(shadowRect.width() - topLeftRadius.width() - topRightRadius.width() - m_blurRadius * 4);
+ destRect.setWidth(shadowRect.width() - topLeftRadius.width() - topRightRadius.width() - m_blurDistance * 4);
FloatPoint phase = getPhase(destRect, tileRect);
AffineTransform patternTransform;
patternTransform.makeIdentity();
@@ -285,7 +285,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
tileRect = FloatRect(radiusTwice + bottomLeftRadius.width(), shadowTemplateSize.height() - radiusTwice, sideTileWidth, radiusTwice);
destRect = tileRect;
destRect.move(shadowRect.x(), shadowRect.y() + radiusTwice + rect.height() - shadowTemplateSize.height());
- destRect.setWidth(shadowRect.width() - bottomLeftRadius.width() - bottomRightRadius.width() - m_blurRadius * 4);
+ destRect.setWidth(shadowRect.width() - bottomLeftRadius.width() - bottomRightRadius.width() - m_blurDistance * 4);
phase = getPhase(destRect, tileRect);
drawPatternToCairoContext(cr, m_layerImage, shadowTemplateSize, tileRect, patternTransform, phase, CAIRO_OPERATOR_OVER, destRect);
@@ -293,7 +293,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
tileRect = FloatRect(shadowTemplateSize.width() - radiusTwice, radiusTwice + topRightRadius.height(), radiusTwice, sideTileWidth);
destRect = tileRect;
destRect.move(shadowRect.x() + radiusTwice + rect.width() - shadowTemplateSize.width(), shadowRect.y());
- destRect.setHeight(shadowRect.height() - topRightRadius.height() - bottomRightRadius.height() - m_blurRadius * 4);
+ destRect.setHeight(shadowRect.height() - topRightRadius.height() - bottomRightRadius.height() - m_blurDistance * 4);
phase = getPhase(destRect, tileRect);
drawPatternToCairoContext(cr, m_layerImage, shadowTemplateSize, tileRect, patternTransform, phase, CAIRO_OPERATOR_OVER, destRect);
@@ -301,7 +301,7 @@ void ContextShadow::drawRectShadow(GraphicsContext* context, const IntRect& rect
tileRect = FloatRect(0, radiusTwice + topLeftRadius.height(), radiusTwice, sideTileWidth);
destRect = tileRect;
destRect.move(shadowRect.x(), shadowRect.y());
- destRect.setHeight(shadowRect.height() - topLeftRadius.height() - bottomLeftRadius.height() - m_blurRadius * 4);
+ destRect.setHeight(shadowRect.height() - topLeftRadius.height() - bottomLeftRadius.height() - m_blurDistance * 4);
phase = FloatPoint(destRect.x() - tileRect.x(), destRect.y() - tileRect.y());
drawPatternToCairoContext(cr, m_layerImage, shadowTemplateSize, tileRect, patternTransform, phase, CAIRO_OPERATOR_OVER, destRect);
diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp
index e7566eb..b049181 100644
--- a/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/WebCore/platform/graphics/qt/FontQt.cpp
@@ -137,7 +137,7 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float
dy1 = -ctxShadow->offset().y();
// expand the clip rect to include the text shadow as well
clip.adjust(dx1, dx2, dy1, dy2);
- clip.adjust(-ctxShadow->m_blurRadius, -ctxShadow->m_blurRadius, ctxShadow->m_blurRadius, ctxShadow->m_blurRadius);
+ clip.adjust(-ctxShadow->m_blurDistance, -ctxShadow->m_blurDistance, ctxShadow->m_blurDistance, ctxShadow->m_blurDistance);
}
p->save();
p->setClipRect(clip.toRect(), Qt::IntersectClip);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list