void TileCoverageMap::update() { FloatRect containerBounds = m_controller.bounds(); FloatRect visibleRect = m_controller.visibleRect(); FloatRect coverageRect = m_controller.coverageRect(); visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges. float widthScale = 1; float scale = 1; if (!containerBounds.isEmpty()) { widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1); float visibleHeight = visibleRect.height() - std::min(m_controller.topContentInset(), visibleRect.y()); scale = std::min(widthScale, visibleHeight / containerBounds.height()); } float indicatorScale = scale * m_controller.tileGrid().scale(); FloatRect mapBounds = containerBounds; mapBounds.scale(indicatorScale, indicatorScale); m_layer.get().setPosition(m_position + FloatPoint(2, 2)); m_layer.get().setBounds(mapBounds); m_layer.get().setNeedsDisplay(); visibleRect.scale(indicatorScale, indicatorScale); visibleRect.expand(2, 2); m_visibleRectIndicatorLayer->setPosition(visibleRect.location()); m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size())); coverageRect.scale(indicatorScale, indicatorScale); coverageRect.expand(2, 2); m_coverageRectIndicatorLayer->setPosition(coverageRect.location()); m_coverageRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), coverageRect.size())); Color visibleRectIndicatorColor; switch (m_controller.indicatorMode()) { case SynchronousScrollingBecauseOfStyleIndication: visibleRectIndicatorColor = Color(255, 0, 0); break; case SynchronousScrollingBecauseOfEventHandlersIndication: visibleRectIndicatorColor = Color(255, 255, 0); break; case AsyncScrollingIndication: visibleRectIndicatorColor = Color(0, 200, 0); break; } m_visibleRectIndicatorLayer.get().setBorderColor(visibleRectIndicatorColor); }
static inline void expandRectWithFilters(FloatRect& rect, const WebKit::WebFilterOperations& filters) { int top, right, bottom, left; filters.getOutsets(top, right, bottom, left); rect.move(-left, -top); rect.expand(left + right, top + bottom); }
void GeneratedImage::drawPattern(GraphicsContext& destContext, const FloatRect& srcRect, const FloatSize& scale, const FloatPoint& phase, SkBlendMode compositeOp, const FloatRect& destRect, const FloatSize& repeatSpacing) { FloatRect tileRect = srcRect; tileRect.expand(FloatSize(repeatSpacing)); std::unique_ptr<PaintController> paintController = PaintController::create(); GraphicsContext context(*paintController); context.beginRecording(tileRect); drawTile(context, srcRect); sk_sp<SkPicture> tilePicture = context.endRecording(); SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y()); patternMatrix.preScale(scale.width(), scale.height()); patternMatrix.preTranslate(tileRect.x(), tileRect.y()); RefPtr<Pattern> picturePattern = Pattern::createPicturePattern(std::move(tilePicture)); SkPaint fillPaint = destContext.fillPaint(); picturePattern->applyToPaint(fillPaint, patternMatrix); fillPaint.setColor(SK_ColorBLACK); fillPaint.setBlendMode(compositeOp); destContext.drawRect(destRect, fillPaint); }
void GeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const FloatSize& scale, const FloatPoint& phase, SkXfermode::Mode compositeOp, const FloatRect& destRect, const IntSize& repeatSpacing) { FloatRect tileRect = srcRect; tileRect.expand(repeatSpacing); SkPictureBuilder builder(tileRect, nullptr, destContext); builder.context().beginRecording(tileRect); drawTile(&builder.context(), srcRect); RefPtr<const SkPicture> tilePicture = builder.endRecording(); AffineTransform patternTransform; patternTransform.translate(phase.x(), phase.y()); patternTransform.scale(scale.width(), scale.height()); patternTransform.translate(tileRect.x(), tileRect.y()); RefPtr<Pattern> picturePattern = Pattern::createPicturePattern(tilePicture); picturePattern->setPatternSpaceTransform(patternTransform); SkPaint fillPaint = destContext->fillPaint(); picturePattern->applyToPaint(fillPaint); fillPaint.setColor(SK_ColorBLACK); fillPaint.setXfermodeMode(compositeOp); destContext->drawRect(destRect, fillPaint); }
FloatRect FEConvolveMatrix::mapPaintRect(const FloatRect& rect, bool forward) { FloatRect result = rect; result.moveBy(forward ? -m_targetOffset : m_targetOffset - m_kernelSize); result.expand(m_kernelSize); return result; }
Optional<FloatRect> StrokeEllipse::localBounds(const GraphicsContext& context) const { float strokeThickness = context.strokeThickness(); FloatRect bounds = m_rect; bounds.expand(strokeThickness, strokeThickness); return bounds; }
FloatRect FEConvolveMatrix::mapEffect(const FloatRect& rect) const { if (!parametersValid()) return rect; FloatRect result = rect; result.moveBy(-m_targetOffset); result.expand(FloatSize(m_kernelSize)); return result; }
void TextureMapperLayer::computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode mode) { if (!m_state.visible || !m_state.contentsVisible) return; FloatRect boundingRect; if (m_backingStore || m_state.masksToBounds || m_state.maskLayer || hasFilters()) boundingRect = layerRect(); else if (m_contentsLayer || m_state.solidColor.alpha()) boundingRect = m_state.contentsRect; if (m_currentFilters.hasOutsets()) { FilterOutsets outsets = m_currentFilters.outsets(); IntRect unfilteredTargetRect(boundingRect); boundingRect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top())); boundingRect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom()); boundingRect.unite(unfilteredTargetRect); } TransformationMatrix replicaMatrix; if (m_state.replicaLayer) { replicaMatrix = replicaTransform(); boundingRect.unite(replicaMatrix.mapRect(boundingRect)); } boundingRect = m_currentTransform.combined().mapRect(boundingRect); // Count all masks and filters as overlap layers. if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) { Region newOverlapRegion(enclosingIntRect(boundingRect)); nonOverlapRegion.subtract(newOverlapRegion); overlapRegion.unite(newOverlapRegion); return; } Region newOverlapRegion; Region newNonOverlapRegion(enclosingIntRect(boundingRect)); if (!m_state.masksToBounds) { for (auto* child : m_children) child->computeOverlapRegions(newOverlapRegion, newNonOverlapRegion, ResolveSelfOverlapIfNeeded); } if (m_state.replicaLayer) { newOverlapRegion.unite(replicaMatrix.mapRect(newOverlapRegion.bounds())); Region replicaRegion(replicaMatrix.mapRect(newNonOverlapRegion.bounds())); resolveOverlaps(replicaRegion, newOverlapRegion, newNonOverlapRegion); } if ((mode != ResolveSelfOverlapAlways) && shouldBlend()) { newNonOverlapRegion.unite(newOverlapRegion); newOverlapRegion = Region(); } overlapRegion.unite(newOverlapRegion); resolveOverlaps(newNonOverlapRegion, overlapRegion, nonOverlapRegion); }
Optional<FloatRect> StrokePath::localBounds(const GraphicsContext& context) const { // FIXME: Need to take stroke thickness into account correctly, via CGPathByStrokingPath(). float strokeThickness = context.strokeThickness(); FloatRect bounds = m_path.boundingRect(); bounds.expand(strokeThickness, strokeThickness); return bounds; }
FloatRect FEConvolveMatrix::mapPaintRect(const FloatRect& rect, bool forward) { FloatRect result = rect; if (parametersValid()) { result.moveBy(forward ? -m_targetOffset : m_targetOffset - m_kernelSize); result.expand(FloatSize(m_kernelSize)); } return result; }
static FloatRect outsetIndicatorRectIncludingShadow(const FloatRect rect) { #if ENABLE(LEGACY_FIND_INDICATOR_STYLE) FloatRect outsetRect = rect; outsetRect.move(-leftBorderThickness, -topBorderThickness); outsetRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness); return outsetRect; #else return inflateRect(rect, flatShadowBlurRadius + flatStyleHorizontalBorder, flatShadowBlurRadius + flatStyleVerticalBorder); #endif }
Optional<FloatRect> StrokeRect::localBounds(const GraphicsContext&) const { FloatRect bounds = m_rect; bounds.expand(m_lineWidth, m_lineWidth); return bounds; }
void ShadowList::adjustRectForShadow(FloatRect& rect) const { rect.expand(rectOutsetsIncludingOriginal()); }