Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: Source/core/paint/VideoPainter.cpp

Issue 594043005: Move paint code from RenderImage/RenderVideo into ImagePainter/VideoPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/VideoPainter.h"
7
8 #include "core/dom/Document.h"
9 #include "core/frame/FrameView.h"
10 #include "core/html/HTMLVideoElement.h"
11 #include "core/paint/ImagePainter.h"
12 #include "core/rendering/PaintInfo.h"
13 #include "core/rendering/RenderVideo.h"
14 #include "platform/geometry/LayoutPoint.h"
15 #include "platform/graphics/GraphicsContextStateSaver.h"
16 #include "platform/graphics/media/MediaPlayer.h"
17
18 namespace blink {
19
20 void VideoPainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
21 {
22 WebMediaPlayer* mediaPlayer = m_renderVideo.mediaElement()->webMediaPlayer() ;
23 bool displayingPoster = m_renderVideo.videoElement()->shouldDisplayPosterIma ge();
24 if (!displayingPoster && !mediaPlayer)
25 return;
26
27 LayoutRect rect = m_renderVideo.videoBox();
28 if (rect.isEmpty())
29 return;
30 rect.moveBy(paintOffset);
31
32 LayoutRect contentRect = m_renderVideo.contentBoxRect();
33 contentRect.moveBy(paintOffset);
34 GraphicsContext* context = paintInfo.context;
35 bool clip = !contentRect.contains(rect);
36 if (clip) {
37 context->save();
38 context->clip(contentRect);
39 }
40
41 if (displayingPoster)
42 ImagePainter(m_renderVideo).paintIntoRect(context, rect);
43 else if ((m_renderVideo.document().view() && m_renderVideo.document().view() ->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_renderVideo.acc eleratedRenderingInUse())
44 m_renderVideo.videoElement()->paintCurrentFrameInContext(context, pixelS nappedIntRect(rect));
45
46 if (clip)
47 context->restore();
48 }
49
50 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698