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

Unified Diff: Source/core/html/HTMLVideoElement.cpp

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: applied last corrections Created 6 years, 9 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/html/HTMLVideoElement.h ('k') | Source/core/html/canvas/CanvasImageSource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLVideoElement.cpp
diff --git a/Source/core/html/HTMLVideoElement.cpp b/Source/core/html/HTMLVideoElement.cpp
index d0b8b8d57e1bbd379de5dc66273ee639758867a4..3cc8b3d6c64828ca37e946a7e8259ca623eae76f 100644
--- a/Source/core/html/HTMLVideoElement.cpp
+++ b/Source/core/html/HTMLVideoElement.cpp
@@ -33,6 +33,7 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/html/HTMLImageLoader.h"
+#include "core/html/canvas/CanvasRenderingContext.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/frame/Settings.h"
#include "core/rendering/RenderImage.h"
@@ -173,7 +174,7 @@ void HTMLVideoElement::updateDisplayState()
setDisplayMode(Poster);
}
-void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& destRect)
+void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& destRect) const
{
MediaPlayer* player = HTMLMediaElement::player();
if (!player)
@@ -232,4 +233,34 @@ KURL HTMLVideoElement::mediaPlayerPosterURL()
return posterImageURL();
}
+PassRefPtr<Image> HTMLVideoElement::getSourceImageForCanvas(SourceImageMode mode, SourceImageStatus* status) const
+{
+ if (!hasAvailableVideoFrame()) {
+ *status = InvalidSourceImageStatus;
+ return nullptr;
+ }
+
+ IntSize intrinsicSize(videoWidth(), videoHeight());
+ OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(intrinsicSize);
+ if (!imageBuffer) {
+ *status = InvalidSourceImageStatus;
+ return nullptr;
+ }
+
+ paintCurrentFrameInContext(imageBuffer->context(), IntRect(IntPoint(0, 0), intrinsicSize));
+
+ *status = NormalSourceImageStatus;
+ return imageBuffer->copyImage(mode == CopySourceImageIfVolatile ? CopyBackingStore : DontCopyBackingStore, Unscaled);
+}
+
+bool HTMLVideoElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigin) const
+{
+ return !hasSingleSecurityOrigin() || (!(player() && player()->didPassCORSAccessCheck()) && destinationSecurityOrigin->taintsCanvas(currentSrc()));
+}
+
+FloatSize HTMLVideoElement::sourceSize() const
+{
+ return FloatSize(videoWidth(), videoHeight());
+}
+
}
« no previous file with comments | « Source/core/html/HTMLVideoElement.h ('k') | Source/core/html/canvas/CanvasImageSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698