Home | History | Annotate | Download | only in egl
      1 #ifndef _EGLUNATIVEPIXMAP_HPP
      2 #define _EGLUNATIVEPIXMAP_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 native pixmap abstraction
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "tcuDefs.hpp"
     27 #include "tcuFactoryRegistry.hpp"
     28 #include "eglwDefs.hpp"
     29 #include "tcuVector.hpp"
     30 
     31 namespace tcu
     32 {
     33 class TextureLevel;
     34 }
     35 
     36 namespace eglu
     37 {
     38 
     39 class NativeDisplay;
     40 
     41 class NativePixmap
     42 {
     43 public:
     44 	enum Capability
     45 	{
     46 		CAPABILITY_CREATE_SURFACE_LEGACY				= (1<<0),	//!< EGL surface can be created with eglCreatePixmapSurface()
     47 		CAPABILITY_CREATE_SURFACE_PLATFORM				= (1<<1),	//!< EGL surface can be created with eglCreatePlatformPixmapSurface()
     48 		CAPABILITY_CREATE_SURFACE_PLATFORM_EXTENSION	= (1<<2),	//!< EGL surface can be created with eglCreatePlatformPixmapSurfaceEXT()
     49 		CAPABILITY_READ_PIXELS							= (1<<3)
     50 	};
     51 
     52 	virtual								~NativePixmap			(void) {}
     53 
     54 	//! Return EGLNativePixmapType that can be used with eglCreatePixmapSurface(). Default implementation throws tcu::NotSupportedError().
     55 	virtual eglw::EGLNativePixmapType	getLegacyNative			(void);
     56 
     57 	//! Return native pointer that can be used with eglCreatePlatformPixmapSurface(). Default implementation throws tcu::NotSupportedError().
     58 	virtual void*						getPlatformNative		(void);
     59 
     60 	//! Return native pointer that can be used with eglCreatePlatformPixmapSurfaceEXT(). Default implementation throws tcu::NotSupportedError().
     61 	virtual void*						getPlatformExtension	(void);
     62 
     63 	// Read pixels from pixmap. Default implementation throws tcu::NotSupportedError()
     64 	virtual void						readPixels				(tcu::TextureLevel* dst);
     65 
     66 	// These values are initialized in constructor.
     67 	Capability							getCapabilities			(void) const { return m_capabilities; }
     68 
     69 protected:
     70 										NativePixmap			(Capability capabilities);
     71 
     72 private:
     73 										NativePixmap			(const NativePixmap&);
     74 	NativePixmap&						operator=				(const NativePixmap&);
     75 
     76 	const Capability					m_capabilities;
     77 };
     78 
     79 class NativePixmapFactory : public tcu::FactoryBase
     80 {
     81 public:
     82 	virtual								~NativePixmapFactory	(void);
     83 
     84 	//! Create generic pixmap.
     85 	virtual NativePixmap*				createPixmap			(NativeDisplay* nativeDisplay, int width, int height) const = 0;
     86 
     87 	//! Create pixmap that matches given EGL config. Defaults to generic createPixmap().
     88 	virtual NativePixmap*				createPixmap			(NativeDisplay* nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, int width, int height) const;
     89 
     90 	NativePixmap::Capability			getCapabilities			(void) const { return m_capabilities; }
     91 
     92 protected:
     93 										NativePixmapFactory		(const std::string& name, const std::string& description, NativePixmap::Capability capabilities);
     94 
     95 private:
     96 										NativePixmapFactory		(const NativePixmapFactory&);
     97 	NativePixmapFactory&				operator=				(const NativePixmapFactory&);
     98 
     99 	const NativePixmap::Capability		m_capabilities;
    100 };
    101 
    102 typedef tcu::FactoryRegistry<NativePixmapFactory> NativePixmapFactoryRegistry;
    103 
    104 } // eglu
    105 
    106 #endif // _EGLUNATIVEPIXMAP_HPP
    107