static inline Rect GetClipBounds(SkCanvas *aCanvas) { SkRect clipBounds; aCanvas->getClipBounds(&clipBounds); return SkRectToRect(clipBounds); }
bool PathSkia::StrokeContainsPoint(const StrokeOptions &aStrokeOptions, const Point &aPoint, const Matrix &aTransform) const { Matrix inverse = aTransform; inverse.Invert(); Point transformed = inverse * aPoint; SkPaint paint; StrokeOptionsToPaint(paint, aStrokeOptions); SkPath strokePath; paint.getFillPath(mPath, &strokePath); Rect bounds = aTransform.TransformBounds(SkRectToRect(strokePath.getBounds())); if (aPoint.x < bounds.x || aPoint.y < bounds.y || aPoint.x > bounds.XMost() || aPoint.y > bounds.YMost()) { return false; } SkRegion pointRect; pointRect.setRect(int32_t(SkFloatToScalar(transformed.x - 1.f)), int32_t(SkFloatToScalar(transformed.y - 1.f)), int32_t(SkFloatToScalar(transformed.x + 1.f)), int32_t(SkFloatToScalar(transformed.y + 1.f))); SkRegion pathRegion; return pathRegion.setPath(strokePath, pointRect); }
Rect PathSkia::GetStrokedBounds(const StrokeOptions &aStrokeOptions, const Matrix &aTransform) const { SkPaint paint; StrokeOptionsToPaint(paint, aStrokeOptions); SkPath result; paint.getFillPath(mPath, &result); Rect bounds = SkRectToRect(result.getBounds()); return aTransform.TransformBounds(bounds); }
Rect PathSkia::GetBounds(const Matrix &aTransform) const { Rect bounds = SkRectToRect(mPath.getBounds()); return aTransform.TransformBounds(bounds); }