bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    if (applier)
        applier->strokeStyle(scratch);

    bool result = scratchContext()->platformContext()->strokeContains(*m_path, point);
    scratch->restore();
    return result;
}
Exemplo n.º 2
0
FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderObject* object)
{
    // the bbox might grow if the path is stroked.
    // and CGPathGetBoundingBox doesn't support that, so we'll have
    // to make an alternative call...

    // FIXME: since this is mainly used to decide what to repaint,
    // perhaps it would be sufficient to just outset the fill bbox by
    // the stroke width - that should be way cheaper and simpler than
    // what we do here.

    CGPathRef cgPath = path.platformPath();

    CGContextRef context = scratchContext();
    CGContextSaveGState(context);

    CGContextBeginPath(context);
    CGContextAddPath(context, cgPath);

    GraphicsContext gc(context);
    applyStrokeStyleToContext(&gc, style, object);

    CGContextReplacePathWithStrokedPath(context);
    if (CGContextIsPathEmpty(context)) {
        // CGContextReplacePathWithStrokedPath seems to fail to create a path sometimes, this is not well understood.
        // returning here prevents CG from logging to the console from CGContextGetPathBoundingBox
        CGContextRestoreGState(context);
        return FloatRect();
    }

    CGRect box = CGContextGetPathBoundingBox(context);
    CGContextRestoreGState(context);

    return FloatRect(box);
}
Exemplo n.º 3
0
FloatRect strokeBoundingBox(const Path& path, RenderStyle* style, const RenderObject* object)
 {
     GraphicsContext* scratch = scratchContext();

     scratch->save();
     applyStrokeStyleToContext(scratch, style, object);
     FloatRect bbox = scratch->getPathBoundingBox(path);
     scratch->restore();

     return bbox;
}
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
{
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    if (applier)
        applier->strokeStyle(scratch);

    FloatRect result = scratch->platformContext()->getStrokeBounds(*m_path);

    scratch->restore();
    return result;
}
Exemplo n.º 5
0
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
{
    GraphicsContext* scratch = scratchContext();
    scratch->save();
    scratch->beginPath();
    scratch->addPath(*this);

    if (applier)
        applier->strokeStyle(scratch);

    FloatRect r = boundingBoxForCurrentStroke(scratch);
    scratch->restore();
    return r;
}
Exemplo n.º 6
0
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    applier->strokeStyle(scratch);

    SkPaint paint;
    scratch->setupStrokePaint(&paint);
    SkPath strokePath;
    paint.getFillPath(*platformPath(), &strokePath);
    bool contains = SkPathContainsPoint(&strokePath, point,
                                        SkPath::kWinding_FillType);

    scratch->restore();
    return contains;
}
Exemplo n.º 7
0
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
{   
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    if (applier)
        applier->strokeStyle(scratch);

    SkPaint paint;
    scratch->setupStrokePaint(&paint);
    SkPath boundingPath;
    paint.getFillPath(*platformPath(), &boundingPath);

    FloatRect r = boundingPath.getBounds();
    scratch->restore();
    return r;
}
Exemplo n.º 8
0
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
{
    GraphicsContext* gc = scratchContext();
    QPainterPathStroker stroke;
    if (applier) {
        applier->strokeStyle(gc);

        QPen pen = gc->pen();
        stroke.setWidth(pen.widthF());
        stroke.setCapStyle(pen.capStyle());
        stroke.setJoinStyle(pen.joinStyle());
        stroke.setMiterLimit(pen.miterLimit());
        stroke.setDashPattern(pen.dashPattern());
        stroke.setDashOffset(pen.dashOffset());
    }
    return stroke.createStroke(m_path).boundingRect();
}
Exemplo n.º 9
0
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    ASSERT(applier);

    CGContextRef context = scratchContext();

    CGContextSaveGState(context);
    CGContextBeginPath(context);
    CGContextAddPath(context, platformPath());

    GraphicsContext gc(context);
    applier->strokeStyle(&gc);

    bool hitSuccess = CGContextPathContainsPoint(context, point, kCGPathStroke);
    CGContextRestoreGState(context);
    
    return hitSuccess;
}
Exemplo n.º 10
0
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    ASSERT(applier);

    QPainterPathStroker stroke;
    GraphicsContext* gc = scratchContext();
    applier->strokeStyle(gc);

    QPen pen = gc->pen();
    stroke.setWidth(pen.widthF());
    stroke.setCapStyle(pen.capStyle());
    stroke.setJoinStyle(pen.joinStyle());
    stroke.setMiterLimit(pen.miterLimit());
    stroke.setDashPattern(pen.dashPattern());
    stroke.setDashOffset(pen.dashOffset());

    return stroke.createStroke(m_path).contains(point);
}
Exemplo n.º 11
0
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
{
    // FIXME(crbug.com/229267): Rewrite this to not require a scratch context.
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    if (applier)
        applier->strokeStyle(scratch);

    SkPaint paint;
    scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
    SkPath boundingPath;
    paint.getFillPath(m_path, &boundingPath);

    FloatRect boundingRect = boundingPath.getBounds();
    scratch->restore();
    return boundingRect;
}
Exemplo n.º 12
0
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
{
    CGContextRef context = scratchContext();

    CGContextSaveGState(context);
    CGContextBeginPath(context);
    CGContextAddPath(context, platformPath());

    if (applier) {
        GraphicsContext graphicsContext(context);
        applier->strokeStyle(&graphicsContext);
    }

    CGContextReplacePathWithStrokedPath(context);
    CGRect box = CGContextIsPathEmpty(context) ? CGRectZero : CGContextGetPathBoundingBox(context);
    CGContextRestoreGState(context);

    return box;
}
Exemplo n.º 13
0
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    // FIXME(crbug.com/229267): Rewrite this to not require a scratch context.
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    ASSERT(applier);
    applier->strokeStyle(scratch);

    SkPaint paint;
    scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
    SkPath strokePath;
    paint.getFillPath(m_path, &strokePath);

    bool contains = SkPathContainsPoint(&strokePath, point, SkPath::kWinding_FillType);

    scratch->restore();
    return contains;
}
Exemplo n.º 14
0
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    if (isNull())
        return false;

    ASSERT(applier);
    GraphicsContext* scratch = scratchContext();
    scratch->save();

    applier->strokeStyle(scratch);

    SkPaint paint;
    scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
    SkPath strokePath;
    paint.getFillPath(*platformPath(), &strokePath);
    bool contains = SkPathContainsPoint(&strokePath, point, SkPath::kWinding_FillType);

    scratch->restore();
    return contains;
}
Exemplo n.º 15
0
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const
{
    if (isNull())
        return FloatRect();

    GraphicsContext* scratch = scratchContext();
    scratch->save();

    if (applier)
        applier->strokeStyle(scratch);

    SkPaint paint;
    scratch->platformContext()->setupPaintForStroking(&paint, 0, 0);
    SkPath boundingPath;
    paint.getFillPath(*platformPath(), &boundingPath);

    FloatRect r = boundingPath.getBounds();
    scratch->restore();
    return r;
}
Exemplo n.º 16
0
bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
{
    if (path().isEmpty())
        return false;

    if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this))
        return false;

    CGMutablePathRef cgPath = path().platformPath();
    
    CGContextRef context = scratchContext();
    CGContextSaveGState(context);
    
    CGContextBeginPath(context);
    CGContextAddPath(context, cgPath);

    GraphicsContext gc(context);
    applyStrokeStyleToContext(&gc, style(), this);

    bool hitSuccess = CGContextPathContainsPoint(context, point, kCGPathStroke);
    CGContextRestoreGState(context);
    
    return hitSuccess;
}