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; }
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); }
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; }
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; }
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; }
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; }
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(); }
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; }
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); }
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; }
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; }
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; }
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; }
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; }
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; }