void ScrollbarThemeOverlay::paintThumb(GraphicsContext& context, const ScrollbarThemeClient& scrollbar, const IntRect& rect) { if (DrawingRecorder::useCachedDrawingIfPossible(context, scrollbar, DisplayItem::ScrollbarThumb)) return; DrawingRecorder recorder(context, scrollbar, DisplayItem::ScrollbarThumb, rect); IntRect thumbRect = rect; if (scrollbar.orientation() == HorizontalScrollbar) { thumbRect.setHeight(thumbRect.height() - m_scrollbarMargin); } else { thumbRect.setWidth(thumbRect.width() - m_scrollbarMargin); if (scrollbar.isLeftSideVerticalScrollbar()) thumbRect.setX(thumbRect.x() + m_scrollbarMargin); } if (m_useSolidColor) { context.fillRect(thumbRect, m_color); return; } WebThemeEngine::State state = WebThemeEngine::StateNormal; if (scrollbar.pressedPart() == ThumbPart) state = WebThemeEngine::StatePressed; else if (scrollbar.hoveredPart() == ThumbPart) state = WebThemeEngine::StateHover; WebCanvas* canvas = context.canvas(); WebThemeEngine::Part part = WebThemeEngine::PartScrollbarHorizontalThumb; if (scrollbar.orientation() == VerticalScrollbar) part = WebThemeEngine::PartScrollbarVerticalThumb; Platform::current()->themeEngine()->paint(canvas, part, state, WebRect(rect), 0); }
void ScrollbarThemeAura::paintTrackPiece(GraphicsContext& gc, const Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart partType) { DisplayItem::Type displayItemType = trackPiecePartToDisplayItemType(partType); if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, displayItemType)) return; DrawingRecorder recorder(gc, scrollbar, displayItemType, rect); WebThemeEngine::State state = scrollbar.hoveredPart() == partType ? WebThemeEngine::StateHover : WebThemeEngine::StateNormal; if (useMockTheme() && !scrollbar.enabled()) state = WebThemeEngine::StateDisabled; IntRect alignRect = trackRect(scrollbar, false); WebThemeEngine::ExtraParams extraParams; extraParams.scrollbarTrack.isBack = (partType == BackTrackPart); extraParams.scrollbarTrack.trackX = alignRect.x(); extraParams.scrollbarTrack.trackY = alignRect.y(); extraParams.scrollbarTrack.trackWidth = alignRect.width(); extraParams.scrollbarTrack.trackHeight = alignRect.height(); Platform::current()->themeEngine()->paint( gc.canvas(), scrollbar.orientation() == HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalTrack : WebThemeEngine::PartScrollbarVerticalTrack, state, WebRect(rect), &extraParams); }
void ScrollbarThemeAura::paintButton(GraphicsContext& gc, const ScrollbarThemeClient& scrollbar, const IntRect& rect, ScrollbarPart part) { DisplayItem::Type displayItemType = buttonPartToDisplayItemType(part); if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, displayItemType)) return; PartPaintingParams params = buttonPartPaintingParams(scrollbar, scrollbar.currentPos(), part); if (!params.shouldPaint) return; DrawingRecorder recorder(gc, scrollbar, displayItemType, rect); Platform::current()->themeEngine()->paint(gc.canvas(), params.part, params.state, WebRect(rect), 0); }
void CrossfadeGeneratedImage::drawTile(GraphicsContext& context, const FloatRect& srcRect) { // Draw nothing if either of the images hasn't loaded yet. if (m_fromImage == Image::nullImage() || m_toImage == Image::nullImage()) return; SkPaint paint = context.fillPaint(); paint.setBlendMode(SkBlendMode::kSrcOver); paint.setAntiAlias(context.shouldAntialias()); FloatRect destRect((FloatPoint()), FloatSize(m_crossfadeSize)); paint.setFilterQuality(context.computeFilterQuality(this, destRect, srcRect)); drawCrossfade(context.canvas(), paint, ClampImageToSourceRect); }
void ScrollbarThemeAura::paintThumb(GraphicsContext& gc, const ScrollbarThemeClient& scrollbar, const IntRect& rect) { if (DrawingRecorder::useCachedDrawingIfPossible(gc, scrollbar, DisplayItem::ScrollbarThumb)) return; DrawingRecorder recorder(gc, scrollbar, DisplayItem::ScrollbarThumb, rect); WebThemeEngine::State state; WebCanvas* canvas = gc.canvas(); if (scrollbar.pressedPart() == ThumbPart) state = WebThemeEngine::StatePressed; else if (scrollbar.hoveredPart() == ThumbPart) state = WebThemeEngine::StateHover; else state = WebThemeEngine::StateNormal; Platform::current()->themeEngine()->paint(canvas, scrollbar.orientation() == HorizontalScrollbar ? WebThemeEngine::PartScrollbarHorizontalThumb : WebThemeEngine::PartScrollbarVerticalThumb, state, WebRect(rect), 0); }
void ScrollbarTheme::paintScrollCorner( GraphicsContext& context, const DisplayItemClient& displayItemClient, const IntRect& cornerRect) { if (cornerRect.isEmpty()) return; if (DrawingRecorder::useCachedDrawingIfPossible( context, displayItemClient, DisplayItem::kScrollbarCorner)) return; DrawingRecorder recorder(context, displayItemClient, DisplayItem::kScrollbarCorner, cornerRect); #if OS(MACOSX) context.fillRect(cornerRect, Color::white); #else Platform::current()->themeEngine()->paint( context.canvas(), WebThemeEngine::PartScrollbarCorner, WebThemeEngine::StateNormal, WebRect(cornerRect), 0); #endif }
void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) { WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer(); bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterImage(); if (!displayingPoster && !mediaPlayer) return; LayoutRect rect(m_layoutVideo.videoBox()); if (rect.isEmpty()) return; rect.moveBy(paintOffset); GraphicsContext* context = paintInfo.context; if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_layoutVideo, paintInfo.phase)) return; LayoutRect contentRect = m_layoutVideo.contentBoxRect(); contentRect.moveBy(paintOffset); LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutVideo, paintInfo.phase, contentRect); bool clip = !contentRect.contains(rect); if (clip) { context->save(); context->clip(contentRect); } if (displayingPoster) { ImagePainter(m_layoutVideo).paintIntoRect(context, rect); } else if ((m_layoutVideo.document().view() && m_layoutVideo.document().view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_layoutVideo.acceleratedRenderingInUse()) { SkPaint videoPaint = context->fillPaint(); videoPaint.setColor(SK_ColorBLACK); m_layoutVideo.videoElement()->paintCurrentFrame(context->canvas(), pixelSnappedIntRect(rect), &videoPaint); } if (clip) context->restore(); }