OLD | NEW |
| (Empty) |
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 "EGLSurface.h" | |
28 | |
29 #if USE(EGL) && USE(GRAPHICS_SURFACE) | |
30 | |
31 #include "EGLConfigSelector.h" | |
32 #include "EGLHelper.h" | |
33 #include "GLPlatformContext.h" | |
34 | |
35 #if PLATFORM(X11) | |
36 #include "EGLXSurface.h" | |
37 #endif | |
38 | |
39 namespace WebCore { | |
40 | |
41 PassOwnPtr<GLTransportSurface> EGLTransportSurface::createTransportSurface(const
IntSize& size, SurfaceAttributes attributes) | |
42 { | |
43 OwnPtr<GLTransportSurface> surface; | |
44 #if PLATFORM(X11) | |
45 surface = adoptPtr(new EGLWindowTransportSurface(size, attributes)); | |
46 #endif | |
47 | |
48 if (surface) | |
49 return surface.release(); | |
50 | |
51 return nullptr; | |
52 } | |
53 | |
54 EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes
attributes) | |
55 : GLTransportSurface(size, attributes) | |
56 { | |
57 m_sharedDisplay = EGLHelper::eglDisplay(); | |
58 | |
59 if (m_sharedDisplay == EGL_NO_DISPLAY) | |
60 return; | |
61 | |
62 m_configSelector = adoptPtr(new EGLConfigSelector(attributes)); | |
63 } | |
64 | |
65 GLPlatformSurface::SurfaceAttributes EGLTransportSurface::attributes() const | |
66 { | |
67 return m_configSelector->attributes(); | |
68 } | |
69 | |
70 EGLTransportSurface::~EGLTransportSurface() | |
71 { | |
72 } | |
73 | |
74 void EGLTransportSurface::destroy() | |
75 { | |
76 if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY) | |
77 return; | |
78 | |
79 GLTransportSurface::destroy(); | |
80 | |
81 if (m_drawable) { | |
82 eglDestroySurface(m_sharedDisplay, m_drawable); | |
83 m_drawable = EGL_NO_SURFACE; | |
84 } | |
85 | |
86 m_configSelector = nullptr; | |
87 } | |
88 | |
89 PlatformSurfaceConfig EGLTransportSurface::configuration() | |
90 { | |
91 return m_configSelector->surfaceContextConfig(); | |
92 } | |
93 | |
94 PassOwnPtr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(Surfac
eAttributes attributes) | |
95 { | |
96 OwnPtr<GLPlatformSurface> surface; | |
97 #if PLATFORM(X11) | |
98 surface = adoptPtr(new EGLPixmapSurface(attributes)); | |
99 #endif | |
100 | |
101 if (surface) | |
102 return surface.release(); | |
103 | |
104 return nullptr; | |
105 } | |
106 | |
107 EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes) | |
108 : GLPlatformSurface(surfaceAttributes) | |
109 { | |
110 m_sharedDisplay = EGLHelper::eglDisplay(); | |
111 | |
112 if (m_sharedDisplay == EGL_NO_DISPLAY) | |
113 return; | |
114 | |
115 m_configSelector = adoptPtr(new EGLConfigSelector(surfaceAttributes)); | |
116 } | |
117 | |
118 EGLOffScreenSurface::~EGLOffScreenSurface() | |
119 { | |
120 } | |
121 | |
122 GLPlatformSurface::SurfaceAttributes EGLOffScreenSurface::attributes() const | |
123 { | |
124 return m_configSelector->attributes(); | |
125 } | |
126 | |
127 PlatformSurfaceConfig EGLOffScreenSurface::configuration() | |
128 { | |
129 return m_configSelector->pixmapContextConfig(); | |
130 } | |
131 | |
132 void EGLOffScreenSurface::destroy() | |
133 { | |
134 if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE) | |
135 return; | |
136 | |
137 if (m_drawable) { | |
138 eglDestroySurface(m_sharedDisplay, m_drawable); | |
139 m_drawable = EGL_NO_SURFACE; | |
140 } | |
141 | |
142 m_configSelector = nullptr; | |
143 } | |
144 | |
145 } | |
146 | |
147 #endif | |
OLD | NEW |