Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / HTMLVideoElement.h
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 public:
51     static PassRefPtrWillBeRawPtr<HTMLVideoElement> create(Document&);
52     virtual void trace(Visitor*) OVERRIDE;
53
54     unsigned videoWidth() const;
55     unsigned videoHeight() const;
56
57     // Fullscreen
58     void webkitEnterFullscreen(ExceptionState&);
59     void webkitExitFullscreen();
60     bool webkitSupportsFullscreen();
61     bool webkitDisplayingFullscreen();
62
63     // Statistics
64     unsigned webkitDecodedFrameCount() const;
65     unsigned webkitDroppedFrameCount() const;
66
67     // Used by canvas to gain raw pixel access
68     void paintCurrentFrameInContext(GraphicsContext*, const IntRect&) const;
69
70     // Used by WebGL to do GPU-GPU textures copy if possible.
71     // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h.
72     bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, Platform3DObject texture, GC3Dint level, GLenum internalFormat, GLenum type, bool premultiplyAlpha, bool flipY);
73
74     bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; }
75
76     KURL posterImageURL() const;
77
78     // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not depend on it.
79     virtual KURL mediaPlayerPosterURL() OVERRIDE;
80
81     // CanvasImageSource implementation
82     virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus*) const OVERRIDE;
83     virtual bool isVideoElement() const OVERRIDE { return true; }
84     virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE;
85     virtual FloatSize sourceSize() const OVERRIDE;
86     virtual const KURL& sourceURL() const OVERRIDE { return currentSrc(); }
87
88 private:
89     HTMLVideoElement(Document&);
90
91     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
92     virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
93     virtual void attach(const AttachContext& = AttachContext()) OVERRIDE;
94     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
95     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
96     virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
97     virtual bool hasVideo() const OVERRIDE { return webMediaPlayer() && webMediaPlayer()->hasVideo(); }
98     bool supportsFullscreen() const;
99     virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
100     virtual const AtomicString imageSourceURL() const OVERRIDE;
101
102     bool hasAvailableVideoFrame() const;
103     virtual void updateDisplayState() OVERRIDE;
104     virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
105     virtual void setDisplayMode(DisplayMode) OVERRIDE;
106
107     OwnPtrWillBeMember<HTMLImageLoader> m_imageLoader;
108
109     AtomicString m_defaultPosterURL;
110 };
111
112 } //namespace
113
114 #endif