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

Side by Side Diff: Source/core/rendering/RenderVideo.cpp

Issue 594043005: Move paint code from RenderImage/RenderVideo into ImagePainter/VideoPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments. Created 6 years, 2 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
« no previous file with comments | « Source/core/rendering/RenderVideo.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "core/rendering/RenderVideo.h" 28 #include "core/rendering/RenderVideo.h"
29 29
30 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
34 #include "core/html/HTMLVideoElement.h" 34 #include "core/html/HTMLVideoElement.h"
35 #include "core/paint/VideoPainter.h"
35 #include "core/rendering/PaintInfo.h" 36 #include "core/rendering/PaintInfo.h"
36 #include "core/rendering/RenderFullScreen.h" 37 #include "core/rendering/RenderFullScreen.h"
37 #include "platform/graphics/media/MediaPlayer.h" 38 #include "platform/graphics/media/MediaPlayer.h"
38 #include "public/platform/WebLayer.h" 39 #include "public/platform/WebLayer.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 using namespace HTMLNames; 43 using namespace HTMLNames;
43 44
44 RenderVideo::RenderVideo(HTMLVideoElement* video) 45 RenderVideo::RenderVideo(HTMLVideoElement* video)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return pixelSnappedIntRect(replacedContentRect(overriddenIntrinsicSize)); 138 return pixelSnappedIntRect(replacedContentRect(overriddenIntrinsicSize));
138 } 139 }
139 140
140 bool RenderVideo::shouldDisplayVideo() const 141 bool RenderVideo::shouldDisplayVideo() const
141 { 142 {
142 return !videoElement()->shouldDisplayPosterImage(); 143 return !videoElement()->shouldDisplayPosterImage();
143 } 144 }
144 145
145 void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) 146 void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
146 { 147 {
147 WebMediaPlayer* mediaPlayer = mediaElement()->webMediaPlayer(); 148 VideoPainter(*this).paintReplaced(paintInfo, paintOffset);
148 bool displayingPoster = videoElement()->shouldDisplayPosterImage();
149 if (!displayingPoster && !mediaPlayer)
150 return;
151
152 LayoutRect rect = videoBox();
153 if (rect.isEmpty())
154 return;
155 rect.moveBy(paintOffset);
156
157 LayoutRect contentRect = contentBoxRect();
158 contentRect.moveBy(paintOffset);
159 GraphicsContext* context = paintInfo.context;
160 bool clip = !contentRect.contains(rect);
161 if (clip) {
162 context->save();
163 context->clip(contentRect);
164 }
165
166 if (displayingPoster)
167 paintIntoRect(context, rect);
168 else if ((document().view() && document().view()->paintBehavior() & PaintBeh aviorFlattenCompositingLayers) || !acceleratedRenderingInUse())
169 videoElement()->paintCurrentFrameInContext(context, pixelSnappedIntRect( rect));
170
171 if (clip)
172 context->restore();
173 } 149 }
174 150
175 bool RenderVideo::acceleratedRenderingInUse() 151 bool RenderVideo::acceleratedRenderingInUse()
176 { 152 {
177 WebLayer* webLayer = mediaElement()->platformLayer(); 153 WebLayer* webLayer = mediaElement()->platformLayer();
178 return webLayer && !webLayer->isOrphan(); 154 return webLayer && !webLayer->isOrphan();
179 } 155 }
180 156
181 void RenderVideo::layout() 157 void RenderVideo::layout()
182 { 158 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 return CompositingReasonVideo; 254 return CompositingReasonVideo;
279 } 255 }
280 256
281 if (shouldDisplayVideo() && supportsAcceleratedRendering()) 257 if (shouldDisplayVideo() && supportsAcceleratedRendering())
282 return CompositingReasonVideo; 258 return CompositingReasonVideo;
283 259
284 return CompositingReasonNone; 260 return CompositingReasonNone;
285 } 261 }
286 262
287 } // namespace blink 263 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderVideo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698