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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma
ge(); | 22 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma
ge(); |
23 if (!displayingPoster && !mediaPlayer) | 23 if (!displayingPoster && !mediaPlayer) |
24 return; | 24 return; |
25 | 25 |
26 LayoutRect rect(m_layoutVideo.videoBox()); | 26 LayoutRect rect(m_layoutVideo.videoBox()); |
27 if (rect.isEmpty()) | 27 if (rect.isEmpty()) |
28 return; | 28 return; |
29 rect.moveBy(paintOffset); | 29 rect.moveBy(paintOffset); |
30 | 30 |
31 GraphicsContext* context = paintInfo.context; | 31 GraphicsContext* context = paintInfo.context; |
32 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_layo
utVideo, paintInfo.phase)) | 32 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, m_layo
utVideo, paintInfo.phase, paintOffset)) |
33 return; | 33 return; |
34 | 34 |
35 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); | 35 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); |
36 contentRect.moveBy(paintOffset); | 36 contentRect.moveBy(paintOffset); |
37 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutVideo, paintIn
fo.phase, contentRect); | 37 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutVideo, paintIn
fo.phase, contentRect, paintOffset); |
38 | 38 |
39 bool clip = !contentRect.contains(rect); | 39 bool clip = !contentRect.contains(rect); |
40 if (clip) { | 40 if (clip) { |
41 context->save(); | 41 context->save(); |
42 // TODO(chrishtr): this should be pixel-snapped. | 42 // TODO(chrishtr): this should be pixel-snapped. |
43 context->clip(FloatRect(contentRect)); | 43 context->clip(FloatRect(contentRect)); |
44 } | 44 } |
45 | 45 |
46 if (displayingPoster) { | 46 if (displayingPoster) { |
47 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); | 47 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); |
48 } else if ((paintInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLaye
rs) || !m_layoutVideo.acceleratedRenderingInUse()) { | 48 } else if ((paintInfo.globalPaintFlags() & GlobalPaintFlattenCompositingLaye
rs) || !m_layoutVideo.acceleratedRenderingInUse()) { |
49 SkPaint videoPaint = context->fillPaint(); | 49 SkPaint videoPaint = context->fillPaint(); |
50 videoPaint.setColor(SK_ColorBLACK); | 50 videoPaint.setColor(SK_ColorBLACK); |
51 m_layoutVideo.videoElement()->paintCurrentFrame(context->canvas(), pixel
SnappedIntRect(rect), &videoPaint); | 51 m_layoutVideo.videoElement()->paintCurrentFrame(context->canvas(), pixel
SnappedIntRect(rect), &videoPaint); |
52 } | 52 } |
53 if (clip) | 53 if (clip) |
54 context->restore(); | 54 context->restore(); |
55 } | 55 } |
56 | 56 |
57 } // namespace blink | 57 } // namespace blink |
OLD | NEW |