1 /* 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef HTMLVideoElement_h 27 #define HTMLVideoElement_h 28 29 #include "core/html/HTMLMediaElement.h" 30 #include "core/html/canvas/CanvasImageSource.h" 31 #include "platform/graphics/GraphicsTypes3D.h" 32 33 namespace blink { 34 class WebGraphicsContext3D; 35 } 36 37 namespace blink { 38 39 class ExceptionState; 40 class HTMLImageLoader; 41 class GraphicsContext; 42 43 // GL types as defined in OpenGL ES 2.0 header file gl2.h from khronos.org. 44 // That header cannot be included directly due to a conflict with NPAPI headers. 45 // See crbug.com/328085. 46 typedef unsigned GLenum; 47 typedef int GC3Dint; 48 49 class HTMLVideoElement FINAL : public HTMLMediaElement, public CanvasImageSource { 50 DEFINE_WRAPPERTYPEINFO(); 51 public: 52 static PassRefPtrWillBeRawPtr<HTMLVideoElement> create(Document&); 53 virtual void trace(Visitor*) OVERRIDE; 54 55 unsigned videoWidth() const; 56 unsigned videoHeight() const; 57 58 // Fullscreen 59 void webkitEnterFullscreen(ExceptionState&); 60 void webkitExitFullscreen(); 61 bool webkitSupportsFullscreen(); 62 bool webkitDisplayingFullscreen(); 63 64 // Statistics 65 unsigned webkitDecodedFrameCount() const; 66 unsigned webkitDroppedFrameCount() const; 67 68 // Used by canvas to gain raw pixel access 69 void paintCurrentFrameInContext(GraphicsContext*, const IntRect&) const; 70 71 // Used by WebGL to do GPU-GPU textures copy if possible. 72 // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h. 73 bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, Platform3DObject texture, GC3Dint level, GLenum internalFormat, GLenum type, bool premultiplyAlpha, bool flipY); 74 shouldDisplayPosterImage()75 bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; } 76 77 KURL posterImageURL() const; 78 79 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not depend on it. 80 virtual KURL mediaPlayerPosterURL() OVERRIDE; 81 82 // CanvasImageSource implementation 83 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus*) const OVERRIDE; isVideoElement()84 virtual bool isVideoElement() const OVERRIDE { return true; } 85 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; 86 virtual FloatSize sourceSize() const OVERRIDE; sourceURL()87 virtual const KURL& sourceURL() const OVERRIDE { return currentSrc(); } 88 isHTMLVideoElement()89 virtual bool isHTMLVideoElement() const OVERRIDE { return true; } 90 91 private: 92 HTMLVideoElement(Document&); 93 94 virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE; 95 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 96 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; 97 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; 98 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 99 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE; hasVideo()100 virtual bool hasVideo() const OVERRIDE { return webMediaPlayer() && webMediaPlayer()->hasVideo(); } 101 bool supportsFullscreen() const; 102 virtual bool isURLAttribute(const Attribute&) const OVERRIDE; 103 virtual const AtomicString imageSourceURL() const OVERRIDE; 104 105 bool hasAvailableVideoFrame() const; 106 virtual void updateDisplayState() OVERRIDE; 107 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; 108 virtual void setDisplayMode(DisplayMode) OVERRIDE; 109 110 OwnPtrWillBeMember<HTMLImageLoader> m_imageLoader; 111 112 AtomicString m_defaultPosterURL; 113 }; 114 115 } // namespace blink 116 117 #endif // HTMLVideoElement_h 118