15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/*
25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions
65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met:
75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) *
135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */
255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef HTMLVideoElement_h
275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define HTMLVideoElement_h
285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
2953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLMediaElement.h"
30d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/html/canvas/CanvasImageSource.h"
31c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#include "platform/graphics/GraphicsTypes3D.h"
325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
3309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)namespace blink {
3409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class WebGraphicsContext3D;
3509380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)}
3609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
37c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
39df95704c49daea886ddad70775bda23618d6274dBen Murdochclass ExceptionState;
405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class HTMLImageLoader;
41c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)class GraphicsContext;
42c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)
43c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)// GL types as defined in OpenGL ES 2.0 header file gl2.h from khronos.org.
44c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)// That header cannot be included directly due to a conflict with NPAPI headers.
45c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)// See crbug.com/328085.
46c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)typedef unsigned GLenum;
47c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)typedef int GC3Dint;
485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
49d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class HTMLVideoElement FINAL : public HTMLMediaElement, public CanvasImageSource {
507242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    DEFINE_WRAPPERTYPEINFO();
515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public:
52323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles)    static PassRefPtrWillBeRawPtr<HTMLVideoElement> create(Document&);
535d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    virtual void trace(Visitor*) OVERRIDE;
545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    unsigned videoWidth() const;
565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    unsigned videoHeight() const;
5702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
5807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    // Fullscreen
5907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    void webkitEnterFullscreen(ExceptionState&);
6007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    void webkitExitFullscreen();
6107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    bool webkitSupportsFullscreen();
6207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    bool webkitDisplayingFullscreen();
6307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch
645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Statistics
655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    unsigned webkitDecodedFrameCount() const;
665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    unsigned webkitDroppedFrameCount() const;
675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    // Used by canvas to gain raw pixel access
69d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    void paintCurrentFrameInContext(GraphicsContext*, const IntRect&) const;
705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
71926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    // Used by WebGL to do GPU-GPU textures copy if possible.
72926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h.
73c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, Platform3DObject texture, GC3Dint level, GLenum internalFormat, GLenum type, bool premultiplyAlpha, bool flipY);
74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; }
765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
77926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    KURL posterImageURL() const;
78926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
7909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not depend on it.
8009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    virtual KURL mediaPlayerPosterURL() OVERRIDE;
8109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
82d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    // CanvasImageSource implementation
83d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus*) const OVERRIDE;
84d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    virtual bool isVideoElement() const OVERRIDE { return true; }
85d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE;
86d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    virtual FloatSize sourceSize() const OVERRIDE;
87f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)    virtual const KURL& sourceURL() const OVERRIDE { return currentSrc(); }
88d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
899e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)    virtual bool isHTMLVideoElement() const OVERRIDE { return true; }
909e12abdf8c3a23d52091ea54ebb6a04d327f9300Torne (Richard Coles)
915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private:
9209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    HTMLVideoElement(Document&);
935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
9419cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
9519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
96521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
97926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
99926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
100d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)    virtual bool hasVideo() const OVERRIDE { return webMediaPlayer() && webMediaPlayer()->hasVideo(); }
10107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch    bool supportsFullscreen() const;
1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)    virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
1038abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    virtual const AtomicString imageSourceURL() const OVERRIDE;
1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
10519cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    bool hasAvailableVideoFrame() const;
10619cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    virtual void updateDisplayState() OVERRIDE;
1071e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
10819cde67944066db31e633d9e386f2aa9bf9fadb3Torne (Richard Coles)    virtual void setDisplayMode(DisplayMode) OVERRIDE;
1095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1105d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    OwnPtrWillBeMember<HTMLImageLoader> m_imageLoader;
1115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
112926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    AtomicString m_defaultPosterURL;
1135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)};
1145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1157242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci} // namespace blink
1165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)
1177242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#endif // HTMLVideoElement_h
118