Commit 702e2bac authored by akling@apple.com's avatar akling@apple.com

Remove GraphicsContext::strokeArc(), which is unused.

From Blink r149608 by <jbroman@chromium.org>
<http://src.chromium.org/viewvc/blink?view=revision&revision=149608>

This is no longer used since almost a year ago, when HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) was inlined.

* platform/graphics/GraphicsContext.h:
* platform/graphics/blackberry/GraphicsContextBlackBerry.cpp:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
* platform/graphics/cg/GraphicsContextCG.cpp:
* platform/graphics/wince/GraphicsContextWinCE.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149566 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9786fd24
2013-05-04 Andreas Kling <akling@apple.com>
Remove GraphicsContext::strokeArc(), which is unused.
From Blink r149608 by <jbroman@chromium.org>
<http://src.chromium.org/viewvc/blink?view=revision&revision=149608>
This is no longer used since almost a year ago, when HAVE(PATH_BASED_BORDER_RADIUS_DRAWING) was inlined.
* platform/graphics/GraphicsContext.h:
* platform/graphics/blackberry/GraphicsContextBlackBerry.cpp:
* platform/graphics/cairo/GraphicsContextCairo.cpp:
* platform/graphics/cg/GraphicsContextCG.cpp:
* platform/graphics/wince/GraphicsContextWinCE.cpp:
2013-05-04 Andreas Kling <akling@apple.com>
Remove unused CSSSelector::isCustomPseudoType().
......
......@@ -268,9 +268,6 @@ namespace WebCore {
void fillEllipse(const FloatRect&);
void strokeEllipse(const FloatRect&);
// Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
void strokeArc(const IntRect&, int startAngle, int angleSpan);
void fillRect(const FloatRect&);
void fillRect(const FloatRect&, const Color&, ColorSpace);
void fillRect(const FloatRect&, Generator&);
......
......@@ -166,14 +166,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
platformContext()->addEllipse(FloatRect(rect));
}
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
if (paintingDisabled())
return;
platformContext()->addArc(rect, startAngle, angleSpan);
}
void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool)
{
if (paintingDisabled())
......
......@@ -365,63 +365,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
cairo_new_path(cr);
}
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
if (paintingDisabled() || strokeStyle() == NoStroke)
return;
int x = rect.x();
int y = rect.y();
float w = rect.width();
float h = rect.height();
float scaleFactor = h / w;
float reverseScaleFactor = w / h;
float hRadius = w / 2;
float vRadius = h / 2;
float fa = startAngle;
float falen = fa + angleSpan;
cairo_t* cr = platformContext()->cr();
cairo_save(cr);
if (w != h)
cairo_scale(cr, 1., scaleFactor);
cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, deg2rad(-fa), deg2rad(-falen));
if (w != h)
cairo_scale(cr, 1., reverseScaleFactor);
int patternWidth = 0;
switch (strokeStyle()) {
case DottedStroke:
patternWidth = floorf(strokeThickness() / 2.f);
break;
case DashedStroke:
patternWidth = 3 * floorf(strokeThickness() / 2.f);
break;
default:
break;
}
setSourceRGBAFromColor(cr, strokeColor());
if (patternWidth) {
float distance = 0;
if (hRadius == vRadius)
distance = (piFloat * hRadius) / 2.f;
else // We are elliptical and will have to estimate the distance
distance = (piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.f)) / 2.f;
double patternOffset = calculateStrokePatternOffset(floorf(distance), patternWidth);
double patternWidthAsDouble = patternWidth;
cairo_set_dash(cr, &patternWidthAsDouble, 1, patternOffset);
}
cairo_stroke(cr);
cairo_restore(cr);
}
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
{
if (paintingDisabled())
......
......@@ -412,95 +412,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
drawPath(path);
}
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f)
return;
CGContextRef context = platformContext();
CGContextSaveGState(context);
CGContextBeginPath(context);
CGContextSetShouldAntialias(context, false);
int x = rect.x();
int y = rect.y();
float w = (float)rect.width();
float h = (float)rect.height();
float scaleFactor = h / w;
float reverseScaleFactor = w / h;
if (w != h)
scale(FloatSize(1, scaleFactor));
float hRadius = w / 2;
float vRadius = h / 2;
float fa = startAngle;
float falen = fa + angleSpan;
float start = -fa * piFloat / 180.0f;
float end = -falen * piFloat / 180.0f;
CGContextAddArc(context, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, start, end, true);
if (w != h)
scale(FloatSize(1, reverseScaleFactor));
float width = strokeThickness();
int patWidth = 0;
switch (strokeStyle()) {
case DottedStroke:
patWidth = (int)(width / 2);
break;
case DashedStroke:
patWidth = 3 * (int)(width / 2);
break;
default:
break;
}
if (patWidth) {
// Example: 80 pixels with a width of 30 pixels.
// Remainder is 20. The maximum pixels of line we could paint
// will be 50 pixels.
int distance;
if (hRadius == vRadius)
distance = static_cast<int>((piFloat * hRadius) / 2.0f);
else // We are elliptical and will have to estimate the distance
distance = static_cast<int>((piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0f)) / 2.0f);
int remainder = distance % patWidth;
int coverage = distance - remainder;
int numSegments = coverage / patWidth;
float patternOffset = 0.0f;
// Special case 1px dotted borders for speed.
if (patWidth == 1)
patternOffset = 1.0f;
else {
bool evenNumberOfSegments = !(numSegments % 2);
if (remainder)
evenNumberOfSegments = !evenNumberOfSegments;
if (evenNumberOfSegments) {
if (remainder) {
patternOffset += patWidth - remainder;
patternOffset += remainder / 2.0f;
} else
patternOffset = patWidth / 2.0f;
} else {
if (remainder)
patternOffset = (patWidth - remainder) / 2.0f;
}
}
const CGFloat dottedLine[2] = { static_cast<CGFloat>(patWidth), static_cast<CGFloat>(patWidth) };
CGContextSetLineDash(context, patternOffset, dottedLine, 2);
}
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points)
{
ASSERT(numberOfPoints > 0);
......
......@@ -783,81 +783,6 @@ void getEllipsePointByAngle(double angle, double a, double b, float& x, float& y
}
}
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
if (!m_data->m_opacity || paintingDisabled() || strokeStyle() == NoStroke || rect.isEmpty())
return;
ScopeDCProvider dcProvider(m_data);
if (!m_data->m_dc)
return;
IntRect trRect = m_data->mapRect(rect);
TransparentLayerDC transparentDC(m_data, trRect, &rect);
HDC dc = transparentDC.hdc();
if (!dc)
return;
trRect.move(transparentDC.toShift());
OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle());
HGDIOBJ oldPen = SelectObject(dc, pen.get());
double a = trRect.width() * 0.5;
double b = trRect.height() * 0.5;
int centerX = stableRound(trRect.x() + a);
int centerY = stableRound(trRect.y() + b);
float fstartX, fstartY, fendX, fendY;
int startX, startY, endX, endY;
getEllipsePointByAngle(deg2rad((double)startAngle), a, b, fstartX, fstartY);
getEllipsePointByAngle(deg2rad((double)startAngle + angleSpan), a, b, fendX, fendY);
startX = stableRound(fstartX);
startY = stableRound(fstartY);
endX = stableRound(fendX);
endY = stableRound(fendY);
startX += centerX;
startY = centerY - startY;
endX += centerX;
endY = centerY - endY;
RECT clipRect;
if (startX < endX) {
clipRect.left = startX;
clipRect.right = endX;
} else {
clipRect.left = endX;
clipRect.right = startX;
}
if (startY < endY) {
clipRect.top = startY;
clipRect.bottom = endY;
} else {
clipRect.top = endY;
clipRect.bottom = startY;
}
OwnPtr<HRGN> clipRgn = adoptPtr(CreateRectRgn(0, 0, 0, 0));
bool newClip;
if (GetClipRgn(dc, clipRgn.get()) <= 0) {
newClip = true;
clipRgn = adoptPtr(CreateRectRgn(clipRect.left, clipRect.top, clipRect.right, clipRect.bottom));
SelectClipRgn(dc, clipRgn.get());
} else {
newClip = false;
IntersectClipRect(dc, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
}
HGDIOBJ oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
Ellipse(dc, trRect.x(), trRect.y(), trRect.maxX(), trRect.maxY());
SelectObject(dc, oldBrush);
if (newClip)
SelectClipRgn(dc, 0);
else
SelectClipRgn(dc, clipRgn.get());
SelectObject(dc, oldPen);
}
void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
{
if (!m_data->m_opacity || paintingDisabled() || npoints <= 1 || !points)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment