OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/paint/VideoPainter.h" |
| 7 |
| 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" |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 void VideoPainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
| 21 { |
| 22 WebMediaPlayer* mediaPlayer = m_renderVideo.mediaElement()->webMediaPlayer()
; |
| 23 bool displayingPoster = m_renderVideo.videoElement()->shouldDisplayPosterIma
ge(); |
| 24 if (!displayingPoster && !mediaPlayer) |
| 25 return; |
| 26 |
| 27 LayoutRect rect = m_renderVideo.videoBox(); |
| 28 if (rect.isEmpty()) |
| 29 return; |
| 30 rect.moveBy(paintOffset); |
| 31 |
| 32 LayoutRect contentRect = m_renderVideo.contentBoxRect(); |
| 33 contentRect.moveBy(paintOffset); |
| 34 GraphicsContext* context = paintInfo.context; |
| 35 bool clip = !contentRect.contains(rect); |
| 36 if (clip) { |
| 37 context->save(); |
| 38 context->clip(contentRect); |
| 39 } |
| 40 |
| 41 if (displayingPoster) |
| 42 ImagePainter(m_renderVideo).paintIntoRect(context, rect); |
| 43 else if ((m_renderVideo.document().view() && m_renderVideo.document().view()
->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_renderVideo.acc
eleratedRenderingInUse()) |
| 44 m_renderVideo.videoElement()->paintCurrentFrameInContext(context, pixelS
nappedIntRect(rect)); |
| 45 |
| 46 if (clip) |
| 47 context->restore(); |
| 48 } |
| 49 |
| 50 } // namespace blink |
OLD | NEW |