am 2a8065fa: am 72a9510d: Merge "Add support for fatal errors to framework." into...
[platform/upstream/VK-GL-CTS.git] / framework / egl / egluUnique.hpp
1 #ifndef _EGLUUNIQUE_HPP
2 #define _EGLUUNIQUE_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief EGL unique resources
24  *//*--------------------------------------------------------------------*/
25
26 #include "egluDefs.hpp"
27 #include "eglwDefs.hpp"
28 #include "eglwEnums.hpp"
29
30 namespace eglw
31 {
32 class Library;
33 }
34
35 namespace eglu
36 {
37
38 class UniqueDisplay
39 {
40 public:
41                                                         UniqueDisplay   (const eglw::Library& egl, eglw::EGLDisplay display);
42                                                         ~UniqueDisplay  (void);
43
44         eglw::EGLDisplay                operator*               (void) const { return m_display; }
45         operator                                bool                    (void) const { return m_display != EGL_NO_DISPLAY; }
46
47 private:
48         const eglw::Library&    m_egl;
49         eglw::EGLDisplay                m_display;
50
51         // Disabled
52         UniqueDisplay&                  operator=               (const UniqueDisplay&);
53                                                         UniqueDisplay   (const UniqueDisplay&);
54 };
55
56 class UniqueSurface
57 {
58 public:
59                                                         UniqueSurface   (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface surface);
60                                                         ~UniqueSurface  (void);
61
62         eglw::EGLSurface                operator*               (void) const { return m_surface; }
63         operator                                bool                    (void) const { return m_surface != EGL_NO_SURFACE; }
64
65 private:
66         const eglw::Library&    m_egl;
67         eglw::EGLDisplay                m_display;
68         eglw::EGLSurface                m_surface;
69
70         // Disabled
71         UniqueSurface&                  operator=               (const UniqueSurface&);
72                                                         UniqueSurface   (const UniqueSurface&);
73 };
74
75 class UniqueContext
76 {
77 public:
78                                                         UniqueContext   (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLContext context);
79                                                         ~UniqueContext  (void);
80
81         eglw::EGLContext                operator*               (void) const { return m_context; }
82         operator                                bool                    (void) const { return m_context != EGL_NO_CONTEXT; }
83
84 private:
85         const eglw::Library&    m_egl;
86         eglw::EGLDisplay                m_display;
87         eglw::EGLContext                m_context;
88
89         // Disabled
90         UniqueContext                   operator=               (const UniqueContext&);
91                                                         UniqueContext   (const UniqueContext&);
92 };
93
94 class ScopedCurrentContext
95 {
96 public:
97         ScopedCurrentContext    (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface draw, eglw::EGLSurface read, eglw::EGLContext context);
98         ~ScopedCurrentContext   (void);
99
100 private:
101         const eglw::Library&    m_egl;
102         eglw::EGLDisplay                m_display;
103 };
104
105 class UniqueImage
106 {
107 public:
108                                                         UniqueImage             (const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLImage image);
109                                                         ~UniqueImage    (void);
110
111         eglw::EGLImage                  operator*               (void) const { return m_image; }
112         operator                                bool                    (void) const { return m_image != EGL_NO_IMAGE_KHR; }
113
114 private:
115         const eglw::Library&    m_egl;
116         eglw::EGLDisplay                m_display;
117         eglw::EGLImage                  m_image;
118
119         // Disabled
120         UniqueImage                             operator=               (const UniqueImage&);
121                                                         UniqueImage             (const UniqueImage&);
122 };
123
124 } // eglu
125
126 #endif // _EGLUUNIQUE_HPP