| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/VideoPainter.h" | 6 #include "core/paint/VideoPainter.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/html/HTMLVideoElement.h" | 10 #include "core/html/HTMLVideoElement.h" |
| 11 #include "core/layout/LayoutVideo.h" | 11 #include "core/layout/LayoutVideo.h" |
| 12 #include "core/layout/PaintInfo.h" | 12 #include "core/layout/PaintInfo.h" |
| 13 #include "core/paint/ImagePainter.h" | 13 #include "core/paint/ImagePainter.h" |
| 14 #include "platform/geometry/LayoutPoint.h" | 14 #include "platform/geometry/LayoutPoint.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 18 void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
| 19 { | 19 { |
| 20 WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer()
; | 20 WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer()
; |
| 21 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma
ge(); | 21 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma
ge(); |
| 22 if (!displayingPoster && !mediaPlayer) | 22 if (!displayingPoster && !mediaPlayer) |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 LayoutRect rect = m_layoutVideo.videoBox(); | 25 LayoutRect rect(m_layoutVideo.videoBox()); |
| 26 if (rect.isEmpty()) | 26 if (rect.isEmpty()) |
| 27 return; | 27 return; |
| 28 rect.moveBy(paintOffset); | 28 rect.moveBy(paintOffset); |
| 29 | 29 |
| 30 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); | 30 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); |
| 31 contentRect.moveBy(paintOffset); | 31 contentRect.moveBy(paintOffset); |
| 32 GraphicsContext* context = paintInfo.context; | 32 GraphicsContext* context = paintInfo.context; |
| 33 bool clip = !contentRect.contains(rect); | 33 bool clip = !contentRect.contains(rect); |
| 34 if (clip) { | 34 if (clip) { |
| 35 context->save(); | 35 context->save(); |
| 36 context->clip(contentRect); | 36 context->clip(contentRect); |
| 37 } | 37 } |
| 38 | 38 |
| 39 if (displayingPoster) | 39 if (displayingPoster) |
| 40 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); | 40 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); |
| 41 else if ((m_layoutVideo.document().view() && m_layoutVideo.document().view()
->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_layoutVideo.acc
eleratedRenderingInUse()) | 41 else if ((m_layoutVideo.document().view() && m_layoutVideo.document().view()
->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_layoutVideo.acc
eleratedRenderingInUse()) |
| 42 m_layoutVideo.videoElement()->paintCurrentFrameInContext(context, pixelS
nappedIntRect(rect)); | 42 m_layoutVideo.videoElement()->paintCurrentFrameInContext(context, pixelS
nappedIntRect(rect)); |
| 43 | 43 |
| 44 if (clip) | 44 if (clip) |
| 45 context->restore(); | 45 context->restore(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace blink | 48 } // namespace blink |
| OLD | NEW |