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/ColorSpaceProfile.h" |
| 16 #include "platform/graphics/GraphicsScreen.h" |
15 #include "platform/graphics/paint/ClipRecorder.h" | 17 #include "platform/graphics/paint/ClipRecorder.h" |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 | 20 |
19 void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 21 void VideoPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
20 { | 22 { |
21 WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer()
; | 23 WebMediaPlayer* mediaPlayer = m_layoutVideo.mediaElement()->webMediaPlayer()
; |
22 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma
ge(); | 24 bool displayingPoster = m_layoutVideo.videoElement()->shouldDisplayPosterIma
ge(); |
23 if (!displayingPoster && !mediaPlayer) | 25 if (!displayingPoster && !mediaPlayer) |
24 return; | 26 return; |
25 | 27 |
26 LayoutRect rect(m_layoutVideo.videoBox()); | 28 LayoutRect rect(m_layoutVideo.videoBox()); |
27 if (rect.isEmpty()) | 29 if (rect.isEmpty()) |
28 return; | 30 return; |
29 rect.moveBy(paintOffset); | 31 rect.moveBy(paintOffset); |
30 | 32 |
31 GraphicsContext& context = paintInfo.context; | 33 GraphicsContext& context = paintInfo.context; |
32 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); | 34 LayoutRect contentRect = m_layoutVideo.contentBoxRect(); |
33 contentRect.moveBy(paintOffset); | 35 contentRect.moveBy(paintOffset); |
34 | 36 |
35 Optional<ClipRecorder> clipRecorder; | 37 Optional<ClipRecorder> clipRecorder; |
36 if (!contentRect.contains(rect)) { | 38 if (!contentRect.contains(rect)) { |
37 clipRecorder.emplace(context, m_layoutVideo, paintInfo.displayItemTypeFo
rClipping(), contentRect); | 39 clipRecorder.emplace(context, m_layoutVideo, paintInfo.displayItemTypeFo
rClipping(), contentRect); |
38 } | 40 } |
39 | 41 |
40 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou
tVideo, paintInfo.phase, paintOffset)) | 42 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou
tVideo, paintInfo.phase, paintOffset)) |
41 return; | 43 return; |
42 | 44 |
| 45 RELEASE_ASSERT(currentScreenId()); // There should be an active graphics scr
een. |
| 46 |
43 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, paintInf
o.phase, contentRect, paintOffset); | 47 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutVideo, paintInf
o.phase, contentRect, paintOffset); |
44 | 48 |
45 // Video frames are only painted in software for printing or capturing node
images via web APIs. | 49 // Video frames are only painted in software for printing or capturing node
images via web APIs. |
46 bool forceSoftwareVideoPaint = paintInfo.globalPaintFlags() & GlobalPaintFla
ttenCompositingLayers; | 50 bool forceSoftwareVideoPaint = paintInfo.globalPaintFlags() & GlobalPaintFla
ttenCompositingLayers; |
47 | 51 |
48 if (displayingPoster || !forceSoftwareVideoPaint) { | 52 if (displayingPoster || !forceSoftwareVideoPaint) { |
49 // This wil display the poster image, if one is present, and otherwise p
aint nothing. | 53 // This wil display the poster image, if one is present, and otherwise p
aint nothing. |
50 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); | 54 ImagePainter(m_layoutVideo).paintIntoRect(context, rect); |
51 } else { | 55 } else { |
52 SkPaint videoPaint = context.fillPaint(); | 56 SkPaint videoPaint = context.fillPaint(); |
53 videoPaint.setColor(SK_ColorBLACK); | 57 videoPaint.setColor(Color::toDeviceColor(Color::black).rgb()); |
54 m_layoutVideo.videoElement()->paintCurrentFrame(context.canvas(), pixelS
nappedIntRect(rect), &videoPaint); | 58 RefPtr<ColorSpaceProfile> target = screenColorProfile(currentScreenId())
; |
| 59 m_layoutVideo.videoElement()->paintCurrentFrame(context.canvas(), pixelS
nappedIntRect(rect), &videoPaint, target.get()); |
55 } | 60 } |
56 } | 61 } |
57 | 62 |
58 } // namespace blink | 63 } // namespace blink |
OLD | NEW |