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 // PbufferSurfaceEGL.h: EGL implementation of egl::Surface for pbuffers
8
9 #include "libANGLE/renderer/gl/egl/PbufferSurfaceEGL.h"
10
11 #include "libANGLE/Surface.h"
12 #include "libANGLE/renderer/gl/egl/egl_utils.h"
13
14 namespace rx
15 {
16
PbufferSurfaceEGL(const egl::SurfaceState & state,const FunctionsEGL * egl,EGLConfig config)17 PbufferSurfaceEGL::PbufferSurfaceEGL(const egl::SurfaceState &state,
18 const FunctionsEGL *egl,
19 EGLConfig config)
20 : SurfaceEGL(state, egl, config)
21 {}
22
~PbufferSurfaceEGL()23 PbufferSurfaceEGL::~PbufferSurfaceEGL() {}
24
initialize(const egl::Display * display)25 egl::Error PbufferSurfaceEGL::initialize(const egl::Display *display)
26 {
27 constexpr EGLint kForwardedPBufferSurfaceAttributes[] = {
28 EGL_WIDTH, EGL_HEIGHT, EGL_LARGEST_PBUFFER, EGL_TEXTURE_FORMAT,
29 EGL_TEXTURE_TARGET, EGL_MIPMAP_TEXTURE, EGL_VG_COLORSPACE, EGL_VG_ALPHA_FORMAT,
30 };
31
32 native_egl::AttributeVector nativeAttribs =
33 native_egl::TrimAttributeMap(mState.attributes, kForwardedPBufferSurfaceAttributes);
34 native_egl::FinalizeAttributeVector(&nativeAttribs);
35
36 mSurface = mEGL->createPbufferSurface(mConfig, nativeAttribs.data());
37 if (mSurface == EGL_NO_SURFACE)
38 {
39 return egl::Error(mEGL->getError(), "eglCreatePbufferSurface failed");
40 }
41
42 return egl::NoError();
43 }
44
45 } // namespace rx
46