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

Unified 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: Addressed comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/paint/VideoPainter.h ('k') | Source/core/rendering/RenderImage.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/VideoPainter.cpp
diff --git a/Source/core/paint/VideoPainter.cpp b/Source/core/paint/VideoPainter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..974a754ca563b6319db7e7c7ef7e530720ab2a2d
--- /dev/null
+++ b/Source/core/paint/VideoPainter.cpp
@@ -0,0 +1,50 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/paint/VideoPainter.h"
+
+#include "core/dom/Document.h"
+#include "core/frame/FrameView.h"
+#include "core/html/HTMLVideoElement.h"
+#include "core/paint/ImagePainter.h"
+#include "core/rendering/PaintInfo.h"
+#include "core/rendering/RenderVideo.h"
+#include "platform/geometry/LayoutPoint.h"
+#include "platform/graphics/GraphicsContextStateSaver.h"
+#include "platform/graphics/media/MediaPlayer.h"
+
+namespace blink {
+
+void VideoPainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ WebMediaPlayer* mediaPlayer = m_renderVideo.mediaElement()->webMediaPlayer();
+ bool displayingPoster = m_renderVideo.videoElement()->shouldDisplayPosterImage();
+ if (!displayingPoster && !mediaPlayer)
+ return;
+
+ LayoutRect rect = m_renderVideo.videoBox();
+ if (rect.isEmpty())
+ return;
+ rect.moveBy(paintOffset);
+
+ LayoutRect contentRect = m_renderVideo.contentBoxRect();
+ contentRect.moveBy(paintOffset);
+ GraphicsContext* context = paintInfo.context;
+ bool clip = !contentRect.contains(rect);
+ if (clip) {
+ context->save();
+ context->clip(contentRect);
+ }
+
+ if (displayingPoster)
+ ImagePainter(m_renderVideo).paintIntoRect(context, rect);
+ else if ((m_renderVideo.document().view() && m_renderVideo.document().view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !m_renderVideo.acceleratedRenderingInUse())
+ m_renderVideo.videoElement()->paintCurrentFrameInContext(context, pixelSnappedIntRect(rect));
+
+ if (clip)
+ context->restore();
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/paint/VideoPainter.h ('k') | Source/core/rendering/RenderImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698