1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief EGL unique resources
22 *//*--------------------------------------------------------------------*/
24 #include "egluUnique.hpp"
25 #include "eglwLibrary.hpp"
26 #include "eglwEnums.hpp"
33 UniqueDisplay::UniqueDisplay (const Library& egl, EGLDisplay display)
39 UniqueDisplay::~UniqueDisplay (void)
41 if (m_display != EGL_NO_DISPLAY)
42 m_egl.terminate(m_display);
45 UniqueDisplay::operator bool (void) const
47 return m_display != EGL_NO_DISPLAY;
50 UniqueSurface::UniqueSurface (const Library& egl, EGLDisplay display, EGLSurface surface)
57 UniqueSurface::~UniqueSurface (void)
59 if (m_surface != EGL_NO_SURFACE)
60 m_egl.destroySurface(m_display, m_surface);
63 UniqueSurface::operator bool (void) const
65 return m_surface != EGL_NO_SURFACE;
68 UniqueContext::UniqueContext (const Library& egl, EGLDisplay display, EGLContext context)
75 UniqueContext::~UniqueContext (void)
77 if (m_context != EGL_NO_CONTEXT)
78 m_egl.destroyContext(m_display, m_context);
81 UniqueContext::operator bool (void) const
83 return m_context != EGL_NO_CONTEXT;
86 ScopedCurrentContext::ScopedCurrentContext (const Library& egl, EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context)
90 EGLU_CHECK_CALL(m_egl, makeCurrent(display, draw, read, context));
93 ScopedCurrentContext::~ScopedCurrentContext (void)
95 m_egl.makeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
98 UniqueImage::UniqueImage (const Library& egl, EGLDisplay display, EGLImage image)
100 , m_display (display)
105 UniqueImage::~UniqueImage (void)
107 if (m_image != EGL_NO_IMAGE)
108 m_egl.destroyImageKHR(m_display, m_image);
111 UniqueImage::operator bool (void) const
113 return m_image != EGL_NO_IMAGE;