Home | History | Annotate | Download | only in egl
      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 
     29 namespace eglw
     30 {
     31 class Library;
     32 }
     33 
     34 namespace eglu
     35 {
     36 
     37 class UniqueDisplay
     38 {
     39 public:
     40 							UniqueDisplay	(const eglw::Library& egl, eglw::EGLDisplay display);
     41 							~UniqueDisplay	(void);
     42 
     43 	eglw::EGLDisplay		operator*		(void) const { return m_display; }
     44 	operator				bool			(void) const;
     45 
     46 private:
     47 	const eglw::Library&	m_egl;
     48 	eglw::EGLDisplay		m_display;
     49 
     50 	// Disabled
     51 	UniqueDisplay&			operator=		(const UniqueDisplay&);
     52 							UniqueDisplay	(const UniqueDisplay&);
     53 };
     54 
     55 class UniqueSurface
     56 {
     57 public:
     58 							UniqueSurface	(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface surface);
     59 							~UniqueSurface	(void);
     60 
     61 	eglw::EGLSurface		operator*		(void) const { return m_surface; }
     62 	operator				bool			(void) const;
     63 
     64 private:
     65 	const eglw::Library&	m_egl;
     66 	eglw::EGLDisplay		m_display;
     67 	eglw::EGLSurface		m_surface;
     68 
     69 	// Disabled
     70 	UniqueSurface&			operator=		(const UniqueSurface&);
     71 							UniqueSurface	(const UniqueSurface&);
     72 };
     73 
     74 class UniqueContext
     75 {
     76 public:
     77 							UniqueContext	(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLContext context);
     78 							~UniqueContext	(void);
     79 
     80 	eglw::EGLContext		operator*		(void) const { return m_context; }
     81 	operator				bool			(void) const;
     82 
     83 private:
     84 	const eglw::Library&	m_egl;
     85 	eglw::EGLDisplay		m_display;
     86 	eglw::EGLContext		m_context;
     87 
     88 	// Disabled
     89 	UniqueContext			operator=		(const UniqueContext&);
     90 							UniqueContext	(const UniqueContext&);
     91 };
     92 
     93 class ScopedCurrentContext
     94 {
     95 public:
     96 	ScopedCurrentContext	(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLSurface draw, eglw::EGLSurface read, eglw::EGLContext context);
     97 	~ScopedCurrentContext	(void);
     98 
     99 private:
    100 	const eglw::Library&	m_egl;
    101 	eglw::EGLDisplay		m_display;
    102 };
    103 
    104 class UniqueImage
    105 {
    106 public:
    107 							UniqueImage		(const eglw::Library& egl, eglw::EGLDisplay display, eglw::EGLImage image);
    108 							~UniqueImage	(void);
    109 
    110 	eglw::EGLImage			operator*		(void) const { return m_image; }
    111 	operator				bool			(void) const;
    112 
    113 private:
    114 	const eglw::Library&	m_egl;
    115 	eglw::EGLDisplay		m_display;
    116 	eglw::EGLImage			m_image;
    117 
    118 	// Disabled
    119 	UniqueImage				operator=		(const UniqueImage&);
    120 							UniqueImage		(const UniqueImage&);
    121 };
    122 
    123 } // eglu
    124 
    125 #endif // _EGLUUNIQUE_HPP
    126