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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 return; | 32 return; |
33 | 33 |
34 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 34 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
35 paintInfo.context, m_layoutVideo, paintInfo.phase)) | 35 paintInfo.context, m_layoutVideo, paintInfo.phase)) |
36 return; | 36 return; |
37 | 37 |
38 GraphicsContext& context = paintInfo.context; | 38 GraphicsContext& context = paintInfo.context; |
39 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); | 39 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); |
40 contentRect.moveBy(paintOffset); | 40 contentRect.moveBy(paintOffset); |
41 | 41 |
42 // Video frames are only painted in software for printing or capturing node im
ages via web APIs. | 42 // Video frames are only painted in software for printing or capturing node |
| 43 // images via web APIs. |
43 bool forceSoftwareVideoPaint = | 44 bool forceSoftwareVideoPaint = |
44 paintInfo.getGlobalPaintFlags() & GlobalPaintFlattenCompositingLayers; | 45 paintInfo.getGlobalPaintFlags() & GlobalPaintFlattenCompositingLayers; |
45 | 46 |
46 bool paintWithForeignLayer = !displayingPoster && !forceSoftwareVideoPaint && | 47 bool paintWithForeignLayer = !displayingPoster && !forceSoftwareVideoPaint && |
47 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | 48 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
48 if (paintWithForeignLayer) { | 49 if (paintWithForeignLayer) { |
49 if (WebLayer* layer = m_layoutVideo.mediaElement()->platformLayer()) { | 50 if (WebLayer* layer = m_layoutVideo.mediaElement()->platformLayer()) { |
50 IntRect pixelSnappedRect = pixelSnappedIntRect(contentRect); | 51 IntRect pixelSnappedRect = pixelSnappedIntRect(contentRect); |
51 recordForeignLayer(context, m_layoutVideo, | 52 recordForeignLayer(context, m_layoutVideo, |
52 DisplayItem::kForeignLayerVideo, layer, | 53 DisplayItem::kForeignLayerVideo, layer, |
53 pixelSnappedRect.location(), pixelSnappedRect.size()); | 54 pixelSnappedRect.location(), pixelSnappedRect.size()); |
54 return; | 55 return; |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 // TODO(trchen): Video rect could overflow the content rect due to object-fit. | 59 // TODO(trchen): Video rect could overflow the content rect due to object-fit. |
59 // Should apply a clip here like EmbeddedObjectPainter does. | 60 // Should apply a clip here like EmbeddedObjectPainter does. |
60 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, | 61 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, |
61 paintInfo.phase, contentRect); | 62 paintInfo.phase, contentRect); |
62 | 63 |
63 if (displayingPoster || !forceSoftwareVideoPaint) { | 64 if (displayingPoster || !forceSoftwareVideoPaint) { |
64 // This will display the poster image, if one is present, and otherwise pain
t nothing. | 65 // This will display the poster image, if one is present, and otherwise |
| 66 // paint nothing. |
65 ImagePainter(m_layoutVideo) | 67 ImagePainter(m_layoutVideo) |
66 .paintIntoRect(context, replacedRect, contentRect); | 68 .paintIntoRect(context, replacedRect, contentRect); |
67 } else { | 69 } else { |
68 SkPaint videoPaint = context.fillPaint(); | 70 SkPaint videoPaint = context.fillPaint(); |
69 videoPaint.setColor(SK_ColorBLACK); | 71 videoPaint.setColor(SK_ColorBLACK); |
70 m_layoutVideo.videoElement()->paintCurrentFrame( | 72 m_layoutVideo.videoElement()->paintCurrentFrame( |
71 context.canvas(), snappedReplacedRect, &videoPaint); | 73 context.canvas(), snappedReplacedRect, &videoPaint); |
72 } | 74 } |
73 } | 75 } |
74 | 76 |
75 } // namespace blink | 77 } // namespace blink |
OLD | NEW |