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_READ_PIXELS				= (1<<2)
     49 	};
     50 
     51 	virtual								~NativePixmap			(void) {}
     52 
     53 	//! Return EGLNativePixmapType that can be used with eglCreatePixmapSurface(). Default implementation throws tcu::NotSupportedError().
     54 	virtual eglw::EGLNativePixmapType	getLegacyNative			(void);
     55 
     56 	//! Return native pointer that can be used with eglCreatePlatformPixmapSurfaceEXT(). Default implementation throws tcu::NotSupportedError().
     57 	virtual void*						getPlatformNative		(void);
     58 
     59 	// Read pixels from pixmap. Default implementation throws tcu::NotSupportedError()
     60 	virtual void						readPixels				(tcu::TextureLevel* dst);
     61 
     62 	// These values are initialized in constructor.
     63 	Capability							getCapabilities			(void) const { return m_capabilities; }
     64 
     65 protected:
     66 										NativePixmap			(Capability capabilities);
     67 
     68 private:
     69 										NativePixmap			(const NativePixmap&);
     70 	NativePixmap&						operator=				(const NativePixmap&);
     71 
     72 	const Capability					m_capabilities;
     73 };
     74 
     75 class NativePixmapFactory : public tcu::FactoryBase
     76 {
     77 public:
     78 	virtual								~NativePixmapFactory	(void);
     79 
     80 	//! Create generic pixmap.
     81 	virtual NativePixmap*				createPixmap			(NativeDisplay* nativeDisplay, int width, int height) const = 0;
     82 
     83 	//! Create pixmap that matches given EGL config. Defaults to generic createPixmap().
     84 	virtual NativePixmap*				createPixmap			(NativeDisplay* nativeDisplay, eglw::EGLDisplay display, eglw::EGLConfig config, const eglw::EGLAttrib* attribList, int width, int height) const;
     85 
     86 	NativePixmap::Capability			getCapabilities			(void) const { return m_capabilities; }
     87 
     88 protected:
     89 										NativePixmapFactory		(const std::string& name, const std::string& description, NativePixmap::Capability capabilities);
     90 
     91 private:
     92 										NativePixmapFactory		(const NativePixmapFactory&);
     93 	NativePixmapFactory&				operator=				(const NativePixmapFactory&);
     94 
     95 	const NativePixmap::Capability		m_capabilities;
     96 };
     97 
     98 typedef tcu::FactoryRegistry<NativePixmapFactory> NativePixmapFactoryRegistry;
     99 
    100 } // eglu
    101 
    102 #endif // _EGLUNATIVEPIXMAP_HPP
    103