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 "core/paint/VideoPainter.h" | 5 #include "core/paint/VideoPainter.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/html/HTMLVideoElement.h" | 9 #include "core/html/HTMLVideoElement.h" |
10 #include "core/layout/LayoutVideo.h" | 10 #include "core/layout/LayoutVideo.h" |
11 #include "core/paint/ImagePainter.h" | 11 #include "core/paint/ImagePainter.h" |
12 #include "core/paint/LayoutObjectDrawingRecorder.h" | 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
13 #include "core/paint/PaintInfo.h" | 13 #include "core/paint/PaintInfo.h" |
14 #include "platform/geometry/LayoutPoint.h" | 14 #include "platform/geometry/LayoutPoint.h" |
15 #include "platform/graphics/paint/ClipRecorder.h" | 15 #include "platform/graphics/paint/ClipRecorder.h" |
16 #include "platform/graphics/paint/ForeignLayerDisplayItem.h" | |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 20 void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
20 { | 21 { |
21 WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer() ; | 22 WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer() ; |
22 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma ge(); | 23 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma ge(); |
23 if (!displayingPoster && !mediaPlayer) | 24 if (!displayingPoster && !mediaPlayer) |
24 return; | 25 return; |
25 | 26 |
26 LayoutRect rect(m_layoutVideo.videoBox()); | 27 LayoutRect rect(m_layoutVideo.videoBox()); |
27 if (rect.isEmpty()) | 28 if (rect.isEmpty()) |
28 return; | 29 return; |
29 rect.moveBy(paintOffset); | 30 rect.moveBy(paintOffset); |
30 | 31 |
31 GraphicsContext& context = paintInfo.context; | 32 GraphicsContext& context = paintInfo.context; |
32 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); | 33 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); |
33 contentRect.moveBy(paintOffset); | 34 contentRect.moveBy(paintOffset); |
34 | 35 |
35 Optional<ClipRecorder> clipRecorder; | 36 Optional<ClipRecorder> clipRecorder; |
36 if (!contentRect.contains(rect)) | 37 if (!contentRect.contains(rect)) |
37 clipRecorder.emplace(context, m_layoutVideo, paintInfo.displayItemTypeFo rClipping(), pixelSnappedIntRect(contentRect)); | 38 clipRecorder.emplace(context, m_layoutVideo, paintInfo.displayItemTypeFo rClipping(), pixelSnappedIntRect(contentRect)); |
38 | 39 |
39 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou tVideo, paintInfo.phase)) | 40 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou tVideo, paintInfo.phase)) |
40 return; | 41 return; |
41 | 42 |
42 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, paintInf o.phase, contentRect); | |
43 | 43 |
44 // Video frames are only painted in software for printing or capturing node images via web APIs. | 44 // Video frames are only painted in software for printing or capturing node images via web APIs. |
45 bool forceSoftwareVideoPaint = paintInfo.getGlobalPaintFlags() & GlobalPaint FlattenCompositingLayers; | 45 bool forceSoftwareVideoPaint = paintInfo.getGlobalPaintFlags() & GlobalPaint FlattenCompositingLayers; |
46 | 46 |
47 bool paintWithForeignLayer = | |
48 !displayingPoster && !forceSoftwareVideoPaint | |
49 && RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | |
50 if (paintWithForeignLayer) { | |
51 if (WebLayer* layer = m_layoutVideo.mediaElement()->platformLayer()) { | |
52 IntRect pixelSnappedRect = pixelSnappedIntRect(contentRect); | |
53 recordForeignLayer( | |
pdr.
2016/07/06 23:30:37
Wdyt about changing recordForeignLayer to take an
| |
54 context, m_layoutVideo, DisplayItem::ForeignLayerVideo, layer, | |
55 pixelSnappedRect.location(), pixelSnappedRect.size()); | |
56 return; | |
57 } | |
58 } | |
59 | |
60 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, paintInf o.phase, contentRect); | |
61 | |
47 if (displayingPoster || !forceSoftwareVideoPaint) { | 62 if (displayingPoster || !forceSoftwareVideoPaint) { |
48 // This will display the poster image, if one is present, and otherwise paint nothing. | 63 // This will display the poster image, if one is present, and otherwise paint nothing. |
49 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); | 64 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); |
50 } else { | 65 } else { |
51 SkPaint videoPaint = context.fillPaint(); | 66 SkPaint videoPaint = context.fillPaint(); |
52 videoPaint.setColor(SK_ColorBLACK); | 67 videoPaint.setColor(SK_ColorBLACK); |
53 m_layoutVideo.videoElement()->paintCurrentFrame(context.canvas(), pixelS nappedIntRect(rect), &videoPaint); | 68 m_layoutVideo.videoElement()->paintCurrentFrame(context.canvas(), pixelS nappedIntRect(rect), &videoPaint); |
54 } | 69 } |
55 } | 70 } |
56 | 71 |
57 } // namespace blink | 72 } // namespace blink |
OLD | NEW |