1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // WindowSurfaceEGL.h: EGL implementation of egl::Surface for windows
8
9 #include "libANGLE/renderer/gl/egl/WindowSurfaceEGL.h"
10
11 #include "libANGLE/Surface.h"
12 #include "libANGLE/renderer/gl/egl/egl_utils.h"
13
14 namespace rx
15 {
16
WindowSurfaceEGL(const egl::SurfaceState & state,const FunctionsEGL * egl,EGLConfig config,EGLNativeWindowType window)17 WindowSurfaceEGL::WindowSurfaceEGL(const egl::SurfaceState &state,
18 const FunctionsEGL *egl,
19 EGLConfig config,
20 EGLNativeWindowType window)
21 : SurfaceEGL(state, egl, config), mWindow(window)
22 {}
23
~WindowSurfaceEGL()24 WindowSurfaceEGL::~WindowSurfaceEGL() {}
25
initialize(const egl::Display * display)26 egl::Error WindowSurfaceEGL::initialize(const egl::Display *display)
27 {
28 constexpr EGLint kForwardedWindowSurfaceAttributes[] = {
29 EGL_RENDER_BUFFER, EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_GL_COLORSPACE,
30 EGL_COLOR_COMPONENT_TYPE_EXT};
31
32 native_egl::AttributeVector nativeAttribs =
33 native_egl::TrimAttributeMap(mState.attributes, kForwardedWindowSurfaceAttributes);
34 native_egl::FinalizeAttributeVector(&nativeAttribs);
35
36 mSurface = mEGL->createWindowSurface(mConfig, mWindow, nativeAttribs.data());
37 if (mSurface == EGL_NO_SURFACE)
38 {
39 return egl::Error(mEGL->getError(), "eglCreateWindowSurface failed");
40 }
41
42 return egl::NoError();
43 }
44
45 } // namespace rx
46