OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2013 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 "EGLXSurface.h" | |
28 | |
29 #if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE) | |
30 | |
31 #include "EGLConfigSelector.h" | |
32 | |
33 namespace WebCore { | |
34 | |
35 EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlat
formSurface::SurfaceAttributes attributes) | |
36 : EGLTransportSurface(size, attributes) | |
37 { | |
38 if (!m_configSelector) | |
39 return; | |
40 | |
41 if (!m_configSelector->surfaceContextConfig()) { | |
42 destroy(); | |
43 return; | |
44 } | |
45 | |
46 EGLint visualId = m_configSelector->nativeVisualId(m_configSelector->surface
ContextConfig()); | |
47 | |
48 if (visualId == -1) { | |
49 destroy(); | |
50 return; | |
51 } | |
52 | |
53 NativeWrapper::createOffScreenWindow(&m_bufferHandle, visualId, m_configSele
ctor->attributes() & GLPlatformSurface::SupportAlpha, size); | |
54 | |
55 if (!m_bufferHandle) { | |
56 destroy(); | |
57 return; | |
58 } | |
59 | |
60 m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfa
ceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0); | |
61 | |
62 if (m_drawable == EGL_NO_SURFACE) { | |
63 LOG_ERROR("Failed to create EGL surface(%d).", eglGetError()); | |
64 destroy(); | |
65 } | |
66 } | |
67 | |
68 EGLWindowTransportSurface::~EGLWindowTransportSurface() | |
69 { | |
70 } | |
71 | |
72 void EGLWindowTransportSurface::swapBuffers() | |
73 { | |
74 if (!eglSwapBuffers(m_sharedDisplay, m_drawable)) | |
75 LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError()); | |
76 } | |
77 | |
78 void EGLWindowTransportSurface::destroy() | |
79 { | |
80 EGLTransportSurface::destroy(); | |
81 | |
82 if (m_bufferHandle) { | |
83 NativeWrapper::destroyWindow(m_bufferHandle); | |
84 m_bufferHandle = 0; | |
85 } | |
86 } | |
87 | |
88 EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceA
ttributes) | |
89 : EGLOffScreenSurface(surfaceAttributes) | |
90 { | |
91 if (!m_configSelector) | |
92 return; | |
93 | |
94 EGLConfig config = m_configSelector->pixmapContextConfig(); | |
95 | |
96 if (!config) { | |
97 destroy(); | |
98 return; | |
99 } | |
100 | |
101 EGLint visualId = m_configSelector->nativeVisualId(config); | |
102 | |
103 if (visualId == -1) { | |
104 destroy(); | |
105 return; | |
106 } | |
107 | |
108 NativePixmap pixmap; | |
109 NativeWrapper::createPixmap(&pixmap, visualId, m_configSelector->attributes(
) & GLPlatformSurface::SupportAlpha); | |
110 m_bufferHandle = pixmap; | |
111 | |
112 if (!m_bufferHandle) { | |
113 destroy(); | |
114 return; | |
115 } | |
116 | |
117 m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGL
NativePixmapType>(m_bufferHandle), 0); | |
118 | |
119 if (m_drawable == EGL_NO_SURFACE) { | |
120 LOG_ERROR("Failed to create EGL surface(%d).", eglGetError()); | |
121 destroy(); | |
122 } | |
123 } | |
124 | |
125 EGLPixmapSurface::~EGLPixmapSurface() | |
126 { | |
127 } | |
128 | |
129 void EGLPixmapSurface::destroy() | |
130 { | |
131 EGLOffScreenSurface::destroy(); | |
132 | |
133 if (m_bufferHandle) { | |
134 NativeWrapper::destroyPixmap(m_bufferHandle); | |
135 m_bufferHandle = 0; | |
136 } | |
137 } | |
138 | |
139 } | |
140 | |
141 #endif | |
OLD | NEW |