Bug 25920

Summary: Canvas drawImage does not support video
Product: WebKit Reporter: Dean McNamee <deanm>
Component: DOMAssignee: Oliver Hunt <oliver>
Status: RESOLVED FIXED    
Severity: Normal CC: ajwong, arv, dino, eric, oliver, simon.fraser, sjoerd
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: OS X 10.5   
Attachments:
Description Flags
Video->Canvas hyatt: review+

Description Dean McNamee 2009-05-21 02:02:03 PDT
According to the HTML5 spec, drawImage() should accept an HTMLVideoElement.

The current set of methods looks like:

        void drawImage(HTMLImageElement*, float x, float y);
        void drawImage(HTMLImageElement*, float x, float y, float width, float height, ExceptionCode&);
        void drawImage(HTMLImageElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
        void drawImage(HTMLCanvasElement*, float x, float y);
        void drawImage(HTMLCanvasElement*, float x, float y, float width, float height, ExceptionCode&);
        void drawImage(HTMLCanvasElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);


It looks like 3 new variants of drawImage should be added for HTMLVideoElement, and then javascript bindings should be updated.
Comment 1 Albert J. Wong 2009-05-23 03:13:26 PDT
I started looking into this.  Doesn't seem too hard (...famous last words...).  The biggest problem is being able to paint part of the current video frame, which the media players don't yet support.

I'm thinking of either adding a GetCurrentFrame method to the media player, or an additional paint function that can take a clipping parameter.
Comment 2 Oliver Hunt 2009-05-23 03:24:47 PDT
I already have an implementation on mac, we're just working out design and windows issues
Comment 3 Simon Fraser (smfr) 2009-05-26 13:22:47 PDT
<rdar://problem/6164797>
Comment 4 Albert J. Wong 2009-06-22 15:06:18 PDT
Hello,

Has there been any update on this issue?  We've itching to play around with videos on canvases :)
Comment 5 Oliver Hunt 2009-06-22 15:20:46 PDT
I'll be looking at this again once i've finished my current work with JSON
Comment 6 Oliver Hunt 2009-06-23 23:05:23 PDT
Created attachment 31769 [details]
Video->Canvas

Got eric to do the windows side of this for me.  See how windows slows progress? :D
Comment 7 Dave Hyatt 2009-06-23 23:07:35 PDT
Comment on attachment 31769 [details]
Video->Canvas

r=me
Comment 8 Oliver Hunt 2009-06-23 23:21:20 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	LayoutTests/ChangeLog
	A	LayoutTests/media/video-canvas-expected.txt
	A	LayoutTests/media/video-canvas.html
	M	WebCore/ChangeLog
	M	WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp
	M	WebCore/html/CanvasRenderingContext2D.cpp
	M	WebCore/html/CanvasRenderingContext2D.h
	M	WebCore/html/HTMLMediaElement.h
	M	WebCore/html/HTMLVideoElement.cpp
	M	WebCore/html/HTMLVideoElement.h
	M	WebCore/platform/graphics/MediaPlayer.cpp
	M	WebCore/platform/graphics/MediaPlayer.h
	M	WebCore/platform/graphics/MediaPlayerPrivate.h
	M	WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
	M	WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
	M	WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
	M	WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
Committed r45060