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; LayoutRect contentRect = m_layoutVideo.contentBoxRect(); contentRect.moveBy(paintOffset); Optional<ClipRecorder> clipRecorder; if (!contentRect.contains(rect)) { clipRecorder.emplace(context, m_layoutVideo, paintInfo.displayItemTypeForClipping(), contentRect); } if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layoutVideo, paintInfo.phase, paintOffset)) return; LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, paintInfo.phase, contentRect, paintOffset); // Video frames are only painted in software for printing or capturing node images via web APIs. bool forceSoftwareVideoPaint = paintInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLayers; if (displayingPoster || !forceSoftwareVideoPaint) { // This will display the poster image, if one is present, and otherwise paint nothing. ImagePainter(m_layoutVideo).paintIntoRect(context, rect); } else { SkPaint videoPaint = context.fillPaint(); videoPaint.setColor(SK_ColorBLACK); m_layoutVideo.videoElement()->paintCurrentFrame(context.canvas(), pixelSnappedIntRect(rect), &videoPaint); } }
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(); }