1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 #include "core/paint/VideoPainter.h"
8 #include "core/dom/Document.h"
9 #include "core/frame/FrameView.h"
10 #include "core/html/HTMLVideoElement.h"
11 #include "core/paint/ImagePainter.h"
12 #include "core/rendering/PaintInfo.h"
13 #include "core/rendering/RenderVideo.h"
14 #include "platform/geometry/LayoutPoint.h"
15 #include "platform/graphics/GraphicsContextStateSaver.h"
16 #include "platform/graphics/media/MediaPlayer.h"
20 void VideoPainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
22 WebMediaPlayer* mediaPlayer = m_renderVideo.mediaElement()->webMediaPlayer();
23 bool displayingPoster = m_renderVideo.videoElement()->shouldDisplayPosterImage();
24 if (!displayingPoster && !mediaPlayer)
27 LayoutRect rect = m_renderVideo.videoBox();
30 rect.moveBy(paintOffset);
32 LayoutRect contentRect = m_renderVideo.contentBoxRect();
33 contentRect.moveBy(paintOffset);
34 GraphicsContext* context = paintInfo.context;
35 bool clip = !contentRect.contains(rect);
38 context->clip(contentRect);
42 ImagePainter(m_renderVideo).paintIntoRect(context, rect);
43 else if ((m_renderVideo.document().view() && m_renderVideo.document().view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_renderVideo.acceleratedRenderingInUse())
44 m_renderVideo.videoElement()->paintCurrentFrameInContext(context, pixelSnappedIntRect(rect));