void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace) { if (rect.isRounded()) fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace); else fillRect(rect.rect(), color, colorSpace); }
void RenderThemeSafari::paintMenuListButtonGradients(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r) { if (r.isEmpty()) return; CGContextRef context = paintInfo.context->platformContext(); paintInfo.context->save(); RoundedRect bound = o->style()->getRoundedBorderFor(r); int radius = bound.radii().topLeft().width(); CGColorSpaceRef cspace = deviceRGBColorSpaceRef(); FloatRect topGradient(r.x(), r.y(), r.width(), r.height() / 2.0f); struct CGFunctionCallbacks topCallbacks = { 0, TopGradientInterpolate, NULL }; RetainPtr<CGFunctionRef> topFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &topCallbacks)); RetainPtr<CGShadingRef> topShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(topGradient.x(), topGradient.y()), CGPointMake(topGradient.x(), topGradient.maxY()), topFunction.get(), false, false)); FloatRect bottomGradient(r.x() + radius, r.y() + r.height() / 2.0f, r.width() - 2.0f * radius, r.height() / 2.0f); struct CGFunctionCallbacks bottomCallbacks = { 0, BottomGradientInterpolate, NULL }; RetainPtr<CGFunctionRef> bottomFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &bottomCallbacks)); RetainPtr<CGShadingRef> bottomShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(bottomGradient.x(), bottomGradient.y()), CGPointMake(bottomGradient.x(), bottomGradient.maxY()), bottomFunction.get(), false, false)); struct CGFunctionCallbacks mainCallbacks = { 0, MainGradientInterpolate, NULL }; RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NULL, 4, NULL, &mainCallbacks)); RetainPtr<CGShadingRef> mainShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.x(), r.y()), CGPointMake(r.x(), r.maxY()), mainFunction.get(), false, false)); RetainPtr<CGShadingRef> leftShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.x(), r.y()), CGPointMake(r.x() + radius, r.y()), mainFunction.get(), false, false)); RetainPtr<CGShadingRef> rightShading(AdoptCF, CGShadingCreateAxial(cspace, CGPointMake(r.maxX(), r.y()), CGPointMake(r.maxX() - radius, r.y()), mainFunction.get(), false, false)); paintInfo.context->save(); CGContextClipToRect(context, bound.rect()); paintInfo.context->addRoundedRectClip(bound); CGContextDrawShading(context, mainShading.get()); paintInfo.context->restore(); paintInfo.context->save(); CGContextClipToRect(context, topGradient); paintInfo.context->addRoundedRectClip(RoundedRect(enclosingIntRect(topGradient), bound.radii().topLeft(), bound.radii().topRight(), IntSize(), IntSize())); CGContextDrawShading(context, topShading.get()); paintInfo.context->restore(); if (!bottomGradient.isEmpty()) { paintInfo.context->save(); CGContextClipToRect(context, bottomGradient); paintInfo.context->addRoundedRectClip(RoundedRect(enclosingIntRect(bottomGradient), IntSize(), IntSize(), bound.radii().bottomLeft(), bound.radii().bottomRight())); CGContextDrawShading(context, bottomShading.get()); paintInfo.context->restore(); } paintInfo.context->save(); CGContextClipToRect(context, bound.rect()); paintInfo.context->addRoundedRectClip(bound); CGContextDrawShading(context, leftShading.get()); CGContextDrawShading(context, rightShading.get()); paintInfo.context->restore(); paintInfo.context->restore(); }
void GraphicsContext::fillRoundedRect(const RoundedRect& rect, const Color& color, ColorSpace colorSpace, BlendMode blendMode) { if (rect.isRounded()) { setCompositeOperation(compositeOperation(), blendMode); fillRoundedRect(rect.rect(), rect.radii().topLeft(), rect.radii().topRight(), rect.radii().bottomLeft(), rect.radii().bottomRight(), color, colorSpace); setCompositeOperation(compositeOperation()); } else fillRect(rect.rect(), color, colorSpace, compositeOperation(), blendMode); }
PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, WritingMode writingMode, float margin) { FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()); FloatRoundedRect bounds(rect, roundedRect.radii()); OwnPtr<Shape> shape = createInsetShape(bounds); shape->m_writingMode = writingMode; shape->m_margin = margin; return shape.release(); }
std::unique_ptr<Shape> Shape::createBoxShape(const RoundedRect& roundedRect, WritingMode writingMode, float margin) { ASSERT(roundedRect.rect().width() >= 0 && roundedRect.rect().height() >= 0); FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()); FloatRoundedRect bounds(rect, roundedRect.radii()); auto shape = std::make_unique<BoxShape>(bounds); shape->m_writingMode = writingMode; shape->m_margin = margin; return WTF::move(shape); }
PassOwnPtr<Shape> Shape::createLayoutBoxShape(const RoundedRect& roundedRect, WritingMode writingMode, Length margin, Length padding) { ASSERT(roundedRect.rect().width() >= 0 && roundedRect.rect().height() >= 0); FloatRect rect(0, 0, roundedRect.rect().width(), roundedRect.rect().height()); FloatRoundedRect bounds(rect, roundedRect.radii()); OwnPtr<Shape> shape = adoptPtr(new BoxShape(bounds)); shape->m_writingMode = writingMode; shape->m_margin = floatValueForLength(margin, 0); shape->m_padding = floatValueForLength(padding, 0); return shape.release(); }
void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedRect& roundedHoleRect, const Color& color, ColorSpace colorSpace) { if (paintingDisabled()) return; Path path; path.addRect(rect); if (!roundedHoleRect.radii().isZero()) path.addRoundedRect(roundedHoleRect); else path.addRect(roundedHoleRect.rect()); WindRule oldFillRule = fillRule(); Color oldFillColor = fillColor(); ColorSpace oldFillColorSpace = fillColorSpace(); setFillRule(RULE_EVENODD); setFillColor(color, colorSpace); fillPath(path); setFillRule(oldFillRule); setFillColor(oldFillColor, oldFillColorSpace); }
void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const RoundedRect& roundedHoleRect, const Color& color, ColorSpace) { if (paintingDisabled() || !color.isValid()) return; if (this->mustUseShadowBlur()) platformContext()->shadowBlur().drawInsetShadow(this, rect, roundedHoleRect.rect(), roundedHoleRect.radii()); Path path; path.addRect(rect); if (!roundedHoleRect.radii().isZero()) path.addRoundedRect(roundedHoleRect); else path.addRect(roundedHoleRect.rect()); cairo_t* cr = platformContext()->cr(); cairo_save(cr); setPathOnCairoContext(platformContext()->cr(), path.platformPath()->context()); fillCurrentCairoPath(this); cairo_restore(cr); }
void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect) { if (paintingDisabled()) return; BlackBerry::Platform::FloatRoundedRect r = BlackBerry::Platform::FloatRoundedRect( FloatRect(rect.rect()), FloatSize(rect.radii().topLeft()), FloatSize(rect.radii().topRight()), FloatSize(rect.radii().bottomLeft()), FloatSize(rect.radii().bottomRight())); platformContext()->clipOutRoundedRect(r); }
void GraphicsContext::clipOutRoundedRect(const RoundedRect& rect) { if (paintingDisabled()) return; if (!rect.isRounded()) { clipOut(rect.rect()); return; } Path path; path.addRoundedRect(rect); clipOut(path); }
void Path::addRoundedRect(const RoundedRect& r) { addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii().bottomLeft(), r.radii().bottomRight()); }