Esempio n. 1
0
float calcBorderRadiiConstraintScaleFor(const FloatRect& rect, const FloatRoundedRect::Radii& radii)
{
    float factor = 1;
    float radiiSum;

    // top
    radiiSum = radii.topLeft().width() + radii.topRight().width(); // Casts to avoid integer overflow.
    if (radiiSum > rect.width())
        factor = std::min(rect.width() / radiiSum, factor);

    // bottom
    radiiSum = radii.bottomLeft().width() + radii.bottomRight().width();
    if (radiiSum > rect.width())
        factor = std::min(rect.width() / radiiSum, factor);

    // left
    radiiSum = radii.topLeft().height() + radii.bottomLeft().height();
    if (radiiSum > rect.height())
        factor = std::min(rect.height() / radiiSum, factor);

    // right
    radiiSum = radii.topRight().height() + radii.bottomRight().height();
    if (radiiSum > rect.height())
        factor = std::min(rect.height() / radiiSum, factor);

    ASSERT(factor <= 1);
    return factor;
}
void PrintTo(const FloatRoundedRect::Radii& radii, std::ostream* os)
{
    *os << "FloatRoundedRect::Radii("
        << ::testing::PrintToString(radii.topLeft()) << ", "
        << ::testing::PrintToString(radii.topRight()) << ", "
        << ::testing::PrintToString(radii.bottomRight()) << ", "
        << ::testing::PrintToString(radii.bottomLeft()) << ")";
}
Esempio n. 3
0
void FloatRoundedRect::Radii::includeLogicalEdges(const FloatRoundedRect::Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
    if (includeLogicalLeftEdge) {
        if (isHorizontal)
            m_bottomLeft = edges.bottomLeft();
        else
            m_topRight = edges.topRight();
        m_topLeft = edges.topLeft();
    }

    if (includeLogicalRightEdge) {
        if (isHorizontal)
            m_topRight = edges.topRight();
        else
            m_bottomLeft = edges.bottomLeft();
        m_bottomRight = edges.bottomRight();
    }
}
void ClipDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, WebDisplayItemList* list) const
{
    WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size());
    for (size_t i = 0; i < m_roundedRectClips.size(); ++i) {
        FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].radii();
        SkVector skRadii[4];
        skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft().width()),
            SkIntToScalar(rectRadii.topLeft().height()));
        skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRight().width()),
            SkIntToScalar(rectRadii.topRight().height()));
        skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomRight().width()),
            SkIntToScalar(rectRadii.bottomRight().height()));
        skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLeft().width()),
            SkIntToScalar(rectRadii.bottomLeft().height()));
        SkRRect skRoundedRect;
        skRoundedRect.setRectRadii(m_roundedRectClips[i].rect(), skRadii);
        webRoundedRects[i] = skRoundedRect;
    }
    list->appendClipItem(visualRect, m_clipRect, webRoundedRects);
}
void PrintTo(const FloatRoundedRect::Radii& radii, std::ostream* os)
{
    *os << "FloatRoundedRect::Radii(";
    PrintTo(radii.topLeft(), os);
    *os << ", ";
    PrintTo(radii.topRight(), os);
    *os << ", ";
    PrintTo(radii.bottomLeft(), os);
    *os << ", ";
    PrintTo(radii.bottomRight(), os);
    *os << ")";
}
Esempio n. 6
0
static void addRoundedRect(Path& path, const FloatRect& rect, const FloatRoundedRect::Radii& radii)
{
    path.addRoundedRect(rect, radii.topLeft(), radii.topRight(), radii.bottomLeft(), radii.bottomRight(), Path::PreferBezierRoundedRect);
}