[EFL][WebGL] Add proper checks to enable GraphicsSurface usage on EGL without XCompos...
[WebKit-https.git] / Source / WebCore / platform / graphics / opengl / GLPlatformSurface.cpp
1 /*
2  * Copyright (C) 2012 Intel Corporation. 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 INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #include "config.h"
27 #include "GLPlatformSurface.h"
28
29 #if USE(ACCELERATED_COMPOSITING)
30
31 #if USE(GLX)
32 #include "GLXSurface.h"
33 #endif
34
35 #if USE(EGL)
36 #include "EGLSurface.h"
37 #endif
38
39 #include "NotImplemented.h"
40
41 namespace WebCore {
42
43 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createOffScreenSurface(SurfaceAttributes attributes)
44 {
45 #if USE(GLX)
46     OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXOffScreenSurface(attributes));
47
48     if (surface->drawable())
49         return surface.release();
50 #else
51     UNUSED_PARAM(attributes);
52 #endif
53
54     return nullptr;
55 }
56
57 PassOwnPtr<GLPlatformSurface> GLPlatformSurface::createTransportSurface(SurfaceAttributes attributes)
58 {
59 #if USE(GLX)
60     OwnPtr<GLPlatformSurface> surface = adoptPtr(new GLXTransportSurface(attributes));
61 #elif USE(EGL)
62     OwnPtr<GLPlatformSurface> surface = adoptPtr(new EGLWindowTransportSurface(attributes));
63 #endif
64
65     if (surface && surface->handle() && surface->drawable())
66         return surface.release();
67
68     return nullptr;
69 }
70
71 GLPlatformSurface::GLPlatformSurface(SurfaceAttributes)
72     : m_sharedDisplay(0)
73     , m_drawable(0)
74     , m_bufferHandle(0)
75 {
76 }
77
78 GLPlatformSurface::~GLPlatformSurface()
79 {
80 }
81
82 PlatformBufferHandle GLPlatformSurface::handle() const
83 {
84     return m_bufferHandle;
85 }
86
87 PlatformDrawable GLPlatformSurface::drawable() const
88 {
89     return m_drawable;
90 }
91
92 const IntRect& GLPlatformSurface::geometry() const
93 {
94     return m_rect;
95 }
96
97 PlatformDisplay GLPlatformSurface::sharedDisplay() const
98 {
99     return m_sharedDisplay;
100 }
101
102 PlatformSurfaceConfig GLPlatformSurface::configuration()
103 {
104     return 0;
105 }
106
107 void GLPlatformSurface::swapBuffers()
108 {
109     notImplemented();
110 }
111
112 void GLPlatformSurface::updateContents(const uint32_t)
113 {
114 }
115
116 void GLPlatformSurface::setGeometry(const IntRect&)
117 {
118 }
119
120 void GLPlatformSurface::destroy()
121 {
122 }
123
124 GLPlatformSurface::SurfaceAttributes GLPlatformSurface::attributes() const
125 {
126     return GLPlatformSurface::Default;
127 }
128
129 }
130
131 #endif