am 71c92e77: Merge "Emulator\'s host translator EGL implementation."

* commit '71c92e77dc46cf457d45d1d2a64608cd9c88782a':
  Emulator's host translator EGL implementation.
This commit is contained in:
David Turner
2011-05-02 12:33:08 -07:00
committed by Android Git Automerger
30 changed files with 3849 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
LOCAL_PATH := $(call my-dir)
### EGL host implementation ########################
include $(CLEAR_VARS)
translator_path := $(LOCAL_PATH)/..
OS_SRCS:=
ifeq ($(HOST_OS),linux)
OS_SRCS = EglX11Api.cpp
LOCAL_LDLIBS := -lX11 -lGL -ldl
endif
ifeq ($(HOST_OS),darwin)
OS_SRCS = EglMacApi.cpp
endif
ifeq ($(HOST_OS),windows)
OS_SRCS = EglWindowsApi.cpp
endif
LOCAL_SRC_FILES := \
$(OS_SRCS) \
ThreadInfo.cpp \
EglImp.cpp \
EglConfig.cpp \
EglContext.cpp \
EglGlobalInfo.cpp \
EglValidate.cpp \
EglSurface.cpp \
EglWindowSurface.cpp \
EglPbufferSurface.cpp \
EglPixmapSurface.cpp \
EglThreadInfo.cpp \
EglDisplay.cpp
LOCAL_C_INCLUDES += \
$(translator_path)/include
LOCAL_CFLAGS := -g -O0
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := libEGL_translator
LOCAL_STATIC_LIBRARIES := libGLcommon libcutils
include $(BUILD_HOST_SHARED_LIBRARY)

View File

@@ -0,0 +1,284 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglConfig.h"
EglConfig::EglConfig(EGLint red_size,
EGLint green_size,
EGLint blue_size,
EGLint alpha_size,
EGLenum caveat,
EGLint config_id,
EGLint depth_size,
EGLint frame_buffer_level,
EGLint max_pbuffer_width,
EGLint max_pbuffer_height,
EGLint max_pbuffer_size,
EGLBoolean native_renderable,
EGLint native_visual_id,
EGLint native_visual_type,
EGLint samples_per_pixel,
EGLint stencil_size,
EGLint surface_type,
EGLenum transparent_type,
EGLint trans_red_val,
EGLint trans_green_val,
EGLint trans_blue_val,
EGLNativePixelFormatType frmt):
m_buffer_size(red_size + green_size + blue_size + alpha_size),
m_red_size(red_size),
m_green_size(green_size),
m_blue_size(blue_size),
m_alpha_size(alpha_size),
m_bind_to_tex_rgb(EGL_FALSE), //not supported for now
m_bind_to_tex_rgba(EGL_FALSE), //not supported for now
m_caveat(caveat),
m_config_id(config_id),
m_frame_buffer_level(frame_buffer_level),
m_depth_size(depth_size),
m_max_pbuffer_width(max_pbuffer_width),
m_max_pbuffer_height(max_pbuffer_height),
m_max_pbuffer_size(max_pbuffer_size),
m_max_swap_interval(MAX_SWAP_INTERVAL),
m_min_swap_interval(MIN_SWAP_INTERVAL),
m_native_renderable(native_renderable),
m_native_visual_id(native_visual_id),
m_native_visual_type(native_visual_type),
m_sample_buffers_num(samples_per_pixel > 0 ?1:0),
m_samples_per_pixel(samples_per_pixel),
m_stencil_size(stencil_size),
m_surface_type(surface_type),
m_transparent_type(transparent_type),
m_trans_red_val(trans_red_val),
m_trans_green_val(trans_green_val),
m_trans_blue_val(trans_blue_val),
m_nativeFormat(frmt){};
EglConfig::EglConfig(const EglConfig& conf):m_buffer_size(conf.m_buffer_size),
m_red_size(conf.m_red_size),
m_green_size(conf.m_green_size),
m_blue_size(conf.m_blue_size),
m_alpha_size(conf.m_alpha_size),
m_bind_to_tex_rgb(conf.m_bind_to_tex_rgb),
m_bind_to_tex_rgba(conf.m_bind_to_tex_rgba),
m_caveat(conf.m_caveat),
m_config_id(conf.m_config_id),
m_frame_buffer_level(conf.m_frame_buffer_level),
m_depth_size(conf.m_depth_size),
m_max_pbuffer_width(conf.m_max_pbuffer_width),
m_max_pbuffer_height(conf.m_max_pbuffer_height),
m_max_pbuffer_size(conf.m_max_pbuffer_size),
m_max_swap_interval(conf.m_max_swap_interval),
m_min_swap_interval(conf.m_min_swap_interval),
m_native_renderable(conf.m_native_renderable),
m_native_visual_id(conf.m_native_visual_id),
m_native_visual_type(conf.m_native_visual_type),
m_sample_buffers_num(conf.m_sample_buffers_num),
m_samples_per_pixel(conf.m_samples_per_pixel),
m_stencil_size(conf.m_stencil_size),
m_surface_type(conf.m_surface_type),
m_transparent_type(conf.m_transparent_type),
m_trans_red_val(conf.m_trans_red_val),
m_trans_green_val(conf.m_trans_green_val),
m_trans_blue_val(conf.m_trans_blue_val),
m_nativeFormat(conf.m_nativeFormat){};
bool EglConfig::getConfAttrib(EGLint attrib,EGLint* val) const {
switch(attrib) {
case EGL_BUFFER_SIZE:
*val = m_buffer_size;
break;
case EGL_RED_SIZE:
*val = m_red_size;
break;
case EGL_GREEN_SIZE:
*val = m_green_size;
break;
case EGL_BLUE_SIZE:
*val = m_blue_size;
break;
case EGL_ALPHA_SIZE:
*val = m_alpha_size;
break;
case EGL_BIND_TO_TEXTURE_RGB:
*val = m_bind_to_tex_rgb;
break;
case EGL_BIND_TO_TEXTURE_RGBA:
*val = m_bind_to_tex_rgba;
break;
case EGL_CONFIG_CAVEAT:
*val = m_caveat;
break;
case EGL_CONFIG_ID:
*val = m_config_id;
break;
case EGL_DEPTH_SIZE:
*val = m_depth_size;
break;
case EGL_LEVEL:
*val = m_frame_buffer_level;
break;
case EGL_MAX_PBUFFER_WIDTH:
*val = m_max_pbuffer_width;
break;
case EGL_MAX_PBUFFER_HEIGHT:
*val = m_max_pbuffer_height;
break;
case EGL_MAX_PBUFFER_PIXELS:
*val = m_max_pbuffer_size;
break;
case EGL_MAX_SWAP_INTERVAL:
*val = m_max_swap_interval;
break;
case EGL_MIN_SWAP_INTERVAL:
*val = m_min_swap_interval;
break;
case EGL_NATIVE_RENDERABLE:
*val = m_native_renderable;
break;
case EGL_NATIVE_VISUAL_ID:
*val = m_native_visual_id;
break;
case EGL_NATIVE_VISUAL_TYPE:
*val = m_native_visual_type;
break;
case EGL_SAMPLE_BUFFERS:
*val = m_sample_buffers_num;
break;
case EGL_SAMPLES:
*val = m_samples_per_pixel;
break;
case EGL_STENCIL_SIZE:
*val = m_stencil_size;
break;
case EGL_SURFACE_TYPE:
*val = m_surface_type;
break;
case EGL_TRANSPARENT_TYPE:
*val =m_transparent_type;
break;
case EGL_TRANSPARENT_RED_VALUE:
*val = m_trans_red_val;
break;
case EGL_TRANSPARENT_GREEN_VALUE:
*val = m_trans_green_val;
break;
case EGL_TRANSPARENT_BLUE_VALUE:
*val = m_trans_blue_val;
break;
default:
return false;
}
return true;
}
// checking compitabilty between *this configuration and another configuration
// the compitability is checked againsed red,green,blue,buffer stencil and depth sizes
bool EglConfig::compitableWith(const EglConfig& conf) const {
if(m_buffer_size != conf.m_buffer_size) return false;
if(m_red_size != conf.m_red_size) return false;
if(m_green_size != conf.m_green_size) return false;
if(m_blue_size != conf.m_blue_size) return false;
if(m_depth_size != conf.m_depth_size) return false;
if(m_stencil_size != conf.m_stencil_size) return false;
return true;
}
//following the sorting EGLconfig as in spec
bool EglConfig::operator<(const EglConfig& conf) const {
//1
if(m_caveat != conf.m_caveat) {
return m_caveat < conf.m_caveat; // EGL_NONE < EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG
}
//2 TODO:
//3
if(m_buffer_size != conf.m_buffer_size) {
return m_buffer_size < conf.m_buffer_size;
}
//4
if(m_sample_buffers_num != conf.m_sample_buffers_num) {
return m_sample_buffers_num < conf.m_sample_buffers_num;
}
//5
if(m_samples_per_pixel != conf.m_samples_per_pixel) {
return m_samples_per_pixel < conf.m_samples_per_pixel;
}
//6
if(m_depth_size != conf.m_depth_size) {
return m_depth_size < conf.m_depth_size;
}
//7
if(m_stencil_size != conf.m_stencil_size) {
return m_stencil_size < conf.m_stencil_size;
}
//8 implementation defined
if(m_native_visual_type != conf.m_native_visual_type) {
return m_native_visual_type < conf.m_native_visual_type;
}
//9
return m_config_id < conf.m_config_id;
}
bool EglConfig::operator>=(const EglConfig& conf) const {
return !((*this) < conf);
}
#define CHECK_PROP(dummy,prop_name,op) \
if((dummy.prop_name != EGL_DONT_CARE) && (dummy.prop_name op prop_name)) return false;
#define CHECK_PROP_CAST(dummy,prop_name,op) \
if((((EGLint)dummy.prop_name) != EGL_DONT_CARE) && (dummy.prop_name op prop_name)) return false;
//checking if config stands for all the selection crateria of dummy as defined by EGL spec
bool EglConfig::choosen(const EglConfig& dummy) {
//atleast
CHECK_PROP(dummy,m_buffer_size,>);
CHECK_PROP(dummy,m_red_size,>);
CHECK_PROP(dummy,m_green_size,>);
CHECK_PROP(dummy,m_blue_size,>);
CHECK_PROP(dummy,m_alpha_size,>);
CHECK_PROP(dummy,m_depth_size,>);
CHECK_PROP(dummy,m_stencil_size,>);
CHECK_PROP(dummy,m_sample_buffers_num,>);
CHECK_PROP(dummy,m_samples_per_pixel,>);
//exact
CHECK_PROP(dummy,m_frame_buffer_level,!=);
CHECK_PROP(dummy,m_config_id,!=);
CHECK_PROP(dummy,m_native_visual_type,!=);
CHECK_PROP(dummy,m_max_swap_interval ,!=);
CHECK_PROP(dummy,m_min_swap_interval ,!=);
CHECK_PROP(dummy,m_trans_red_val ,!=);
CHECK_PROP(dummy,m_trans_green_val ,!=);
CHECK_PROP(dummy,m_trans_blue_val ,!=);
//exact - when cast to EGLint is needed when comparing to EGL_DONT_CARE
CHECK_PROP_CAST(dummy,m_bind_to_tex_rgb ,!=);
CHECK_PROP_CAST(dummy,m_bind_to_tex_rgba,!=);
CHECK_PROP_CAST(dummy,m_caveat,!=);
CHECK_PROP_CAST(dummy,m_native_renderable ,!=);
CHECK_PROP_CAST(dummy,m_transparent_type ,!=);
//mask
if(dummy.m_surface_type != EGL_DONT_CARE &&
((dummy.m_surface_type & m_surface_type) != dummy.m_surface_type)) return false;
//passed all checks
return true;
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_CONFIG_H
#define EGL_CONFIG_H
#include<EGL/egl.h>
#define MIN_SWAP_INTERVAL 1
#define MAX_SWAP_INTERVAL 10
class EglConfig {
public:
bool getConfAttrib(EGLint attrib,EGLint* val) const;
bool operator<(const EglConfig& conf) const;
bool operator>=(const EglConfig& conf) const;
bool compitableWith(const EglConfig& conf) const; //compitability
bool choosen(const EglConfig& dummy);
EGLint surfaceType(){ return m_surface_type;};
EGLint id(){return m_config_id;};
EGLNativePixelFormatType nativeConfig(){ return m_nativeFormat;}
EglConfig(EGLint red_size,
EGLint green_size,
EGLint blue_size,
EGLint alpha_size,
EGLenum caveat,
EGLint config_id,
EGLint depth_size,
EGLint frame_buffer_level,
EGLint max_pbuffer_width,
EGLint max_pbuffer_height,
EGLint max_pbuffer_size,
EGLBoolean native_renderable,
EGLint native_visual_id,
EGLint native_visual_type,
EGLint samples_per_pixel,
EGLint stencil_size,
EGLint surface_type,
EGLenum transparent_type,
EGLint trans_red_val,
EGLint trans_green_val,
EGLint trans_blue_val,
EGLNativePixelFormatType frmt = 0);
EglConfig(const EglConfig& conf);
private:
const EGLint m_buffer_size;
const EGLint m_red_size;
const EGLint m_green_size;
const EGLint m_blue_size;
const EGLint m_alpha_size;
const EGLBoolean m_bind_to_tex_rgb;
const EGLBoolean m_bind_to_tex_rgba;
const EGLenum m_caveat;
const EGLint m_config_id;
const EGLint m_frame_buffer_level;
const EGLint m_depth_size;
const EGLint m_max_pbuffer_width;
const EGLint m_max_pbuffer_height;
const EGLint m_max_pbuffer_size;
const EGLint m_max_swap_interval;
const EGLint m_min_swap_interval;
const EGLBoolean m_native_renderable;
const EGLint m_native_visual_id;
const EGLint m_native_visual_type;
const EGLint m_sample_buffers_num;
const EGLint m_samples_per_pixel;
const EGLint m_stencil_size;
const EGLint m_surface_type;
const EGLenum m_transparent_type;
const EGLint m_trans_red_val;
const EGLint m_trans_green_val;
const EGLint m_trans_blue_val;
const EGLNativePixelFormatType m_nativeFormat;
};
#endif

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglContext.h"
unsigned int EglContext::s_nextContextHndl = 0;
bool EglContext::usingSurface(SurfacePtr surface) {
return surface.Ptr() == m_read.Ptr() || surface.Ptr() == m_draw.Ptr();
}
EglContext::EglContext(EGLNativeContextType context,ContextPtr shared_context,
EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr):
m_native(context),
m_config(config),
m_glesContext(glesCtx),
m_read(NULL),
m_draw(NULL),
m_destroy(false),
m_version(ver)
{
m_shareGroup = shared_context.Ptr()?
mngr->attachShareGroup(context,shared_context.Ptr()->getShareGroup().Ptr()):
mngr->createShareGroup(context);
m_hndl = ++s_nextContextHndl;
}
void EglContext::setSurfaces(SurfacePtr read,SurfacePtr draw)
{
m_read = read;
m_draw = draw;
}
bool EglContext::getAttrib(EGLint attrib,EGLint* value) {
switch(attrib) {
case EGL_CONFIG_ID:
*value = m_config->id();
break;
default:
return false;
}
return true;
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_CONTEXT_H
#define EGL_CONTEXT_H
#include <map>
#include <EGL/egl.h>
#include <GLcommon/SmartPtr.h>
#include <GLcommon/TranslatorIfaces.h>
#include <GLcommon/objectNameManager.h>
#include "EglConfig.h"
#include "EglSurface.h"
typedef enum{
GLES_1_1 = 0,
GLES_2_0 = 1,
MAX_GLES_VERSION //Must be last
}GLESVersion;
class EglContext;
typedef SmartPtr<EglContext> ContextPtr;
class EglContext {
public:
EglContext(EGLNativeContextType context,ContextPtr shared_context,EglConfig* config,GLEScontext* glesCtx,GLESVersion ver,ObjectNameManager* mngr);
bool usingSurface(SurfacePtr surface);
EGLNativeContextType nativeType(){return m_native;};
void markForDestruction(){m_destroy = true;}
bool destroy(){ return m_destroy;}
bool getAttrib(EGLint attrib,EGLint* value);
SurfacePtr read(){ return m_read;};
SurfacePtr draw(){ return m_draw;};
ShareGroupPtr getShareGroup(){return m_shareGroup;}
EglConfig* getConfig(){ return m_config;};
GLESVersion version(){return m_version;};
GLEScontext* getGlesContext(){return m_glesContext;}
void setSurfaces(SurfacePtr read,SurfacePtr draw);
unsigned int getHndl(){return m_hndl;}
private:
static unsigned int s_nextContextHndl;
EGLNativeContextType m_native;
EglConfig* m_config;
GLEScontext* m_glesContext;
ShareGroupPtr m_shareGroup;
SurfacePtr m_read;
SurfacePtr m_draw;
bool m_destroy;
GLESVersion m_version;
unsigned int m_hndl;
};
#endif

View File

@@ -0,0 +1,208 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglDisplay.h"
#include "EglOsApi.h"
#include <GLcommon/GLutils.h>
#include <utils/threads.h>
EglDisplay::EglDisplay(EGLNativeDisplayType dpy,bool isDefault):m_dpy(dpy),m_initialized(false),m_configInitialized(false),m_isDefault(isDefault){};
EglDisplay::~EglDisplay() {
android::Mutex::Autolock mutex(m_lock);
if(m_isDefault) {
EglOS::releaseDisplay(m_dpy);
}
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end(); it++) {
EglConfig* pConfig = *it;
if(pConfig) delete pConfig;
}
}
EGLNativeDisplayType EglDisplay::nativeType(){return m_dpy;}
void EglDisplay::initialize() {
android::Mutex::Autolock mutex(m_lock);
m_initialized = true;
initConfigurations();
m_configInitialized = true;
}
bool EglDisplay::isInitialize() { return m_initialized;}
void EglDisplay::terminate(){
android::Mutex::Autolock mutex(m_lock);
m_contexts.clear();
m_surfaces.clear();
m_initialized = false;
}
static bool compareEglConfigsPtrs(EglConfig* first,EglConfig* second) {
return *first < *second ;
}
void EglDisplay::initConfigurations() {
if(m_configInitialized) return;
EglOS::queryConfigs(m_dpy,m_configs);
m_configs.sort(compareEglConfigsPtrs);
}
EglConfig* EglDisplay::getConfig(EGLConfig conf) {
android::Mutex::Autolock mutex(m_lock);
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) {
if(static_cast<EGLConfig>(*it) == conf) {
return (*it);
}
}
return NULL;
}
SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
android::Mutex::Autolock mutex(m_lock);
SurfacesHndlMap::iterator it = m_surfaces.find(reinterpret_cast<unsigned int>(surface));
return it != m_surfaces.end() ?
(*it).second :
SurfacePtr(NULL);
}
ContextPtr EglDisplay::getContext(EGLContext ctx) {
android::Mutex::Autolock mutex(m_lock);
ContextsHndlMap::iterator it = m_contexts.find(reinterpret_cast<unsigned int>(ctx));
return it != m_contexts.end() ?
(*it).second :
ContextPtr(NULL);
}
bool EglDisplay::removeSurface(EGLSurface s) {
android::Mutex::Autolock mutex(m_lock);
SurfacesHndlMap::iterator it = m_surfaces.find(reinterpret_cast<unsigned int>(s));
if(it != m_surfaces.end()) {
m_surfaces.erase(it);
return true;
}
return false;
}
bool EglDisplay::removeSurface(SurfacePtr s) {
android::Mutex::Autolock mutex(m_lock);
SurfacesHndlMap::iterator it;
for(it = m_surfaces.begin(); it!= m_surfaces.end();it++)
{
if((*it).second == s.Ptr()) {
break;
}
}
if(it != m_surfaces.end()) {
m_surfaces.erase(it);
return true;
}
return false;
}
bool EglDisplay::removeContext(EGLContext ctx) {
android::Mutex::Autolock mutex(m_lock);
ContextsHndlMap::iterator it = m_contexts.find(reinterpret_cast<unsigned int>(ctx));
if(it != m_contexts.end()) {
m_contexts.erase(it);
return true;
}
return false;
}
bool EglDisplay::removeContext(ContextPtr ctx) {
android::Mutex::Autolock mutex(m_lock);
ContextsHndlMap::iterator it;
for(it = m_contexts.begin(); it != m_contexts.end();it++) {
if((*it).second == ctx.Ptr()){
break;
}
}
if(it != m_contexts.end()) {
m_contexts.erase(it);
return true;
}
return false;
}
EglConfig* EglDisplay::getConfig(EGLint id) {
android::Mutex::Autolock mutex(m_lock);
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) {
if((*it)->id() == id) {
return (*it);
}
}
return NULL;
}
int EglDisplay::getConfigs(EGLConfig* configs,int config_size) {
android::Mutex::Autolock mutex(m_lock);
int i = 0;
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && i < config_size ;i++,it++) {
configs[i] = static_cast<EGLConfig>(*it);
}
return i;
}
int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) {
android::Mutex::Autolock mutex(m_lock);
int added = 0;
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && added < config_size;it++) {
if( (*it)->choosen(dummy)){
configs[added++] = static_cast<EGLConfig>(*it);
}
}
//no need to sort since the configurations are saved already in sorted maner
return added;
}
EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
android::Mutex::Autolock mutex(m_lock);
unsigned int hndl = s.Ptr()->getHndl();
EGLSurface ret =reinterpret_cast<EGLSurface> (hndl);
if(m_surfaces.find(hndl) != m_surfaces.end()) {
return ret;
}
m_surfaces[hndl] = s;
return ret;
}
EGLContext EglDisplay::addContext(ContextPtr ctx ) {
android::Mutex::Autolock mutex(m_lock);
unsigned int hndl = ctx.Ptr()->getHndl();
EGLContext ret = reinterpret_cast<EGLContext> (hndl);
if(m_contexts.find(hndl) != m_contexts.end()) {
return ret;
}
m_contexts[hndl] = ctx;
return ret;
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_DISPLAY_H
#define EGL_DISPLAY_H
#include <list>
#include <map>
#include <EGL/egl.h>
#include <utils/threads.h>
#include <GLcommon/SmartPtr.h>
#include "EglConfig.h"
#include "EglContext.h"
#include "EglSurface.h"
#include "EglWindowSurface.h"
typedef std::list<EglConfig*> ConfigsList;
typedef std::map< unsigned int,ContextPtr > ContextsHndlMap;
typedef std::map< unsigned int,SurfacePtr > SurfacesHndlMap;
class EglDisplay {
public:
EglDisplay(EGLNativeDisplayType dpy,bool isDefault = true);
EGLNativeDisplayType nativeType();
int nConfigs(){ return m_configs.size();}
int getConfigs(EGLConfig* configs,int config_size);
int chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size);
EglConfig* getConfig(EGLConfig conf);
EglConfig* getConfig(EGLint id );
EGLSurface addSurface(SurfacePtr s );
SurfacePtr getSurface(EGLSurface surface);
bool removeSurface(EGLSurface s);
bool removeSurface(SurfacePtr s);
EGLContext addContext(ContextPtr ctx );
ContextPtr getContext(EGLContext ctx);
bool removeContext(EGLContext ctx);
bool removeContext(ContextPtr ctx);
ObjectNameManager* getManager(GLESVersion ver){ return &m_manager[ver];}
~EglDisplay();
void initialize();
void terminate();
bool isInitialize();
private:
void initConfigurations();
EGLNativeDisplayType m_dpy;
bool m_initialized;
bool m_configInitialized;
bool m_isDefault;
ConfigsList m_configs;
ContextsHndlMap m_contexts;
SurfacesHndlMap m_surfaces;
ObjectNameManager m_manager[MAX_GLES_VERSION];
android::Mutex m_lock;
};
#endif

View File

@@ -0,0 +1,89 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglGlobalInfo.h"
#include "EglOsApi.h"
#include <string.h>
int EglGlobalInfo::m_refCount = 0;
EglGlobalInfo* EglGlobalInfo::m_singleton = NULL;
EglGlobalInfo::EglGlobalInfo(){
m_default = EglOS::getDefaultDisplay();
memset(m_gles_ifaces,0,sizeof(m_gles_ifaces));
}
EglGlobalInfo* EglGlobalInfo::getInstance() {
if(!m_singleton) {
m_singleton = new EglGlobalInfo();
m_refCount = 0;
}
m_refCount++;
return m_singleton;
}
void EglGlobalInfo::delInstance() {
m_refCount--;
if(m_refCount <= 0 && m_singleton) {
delete m_singleton;
m_singleton = NULL;
}
}
EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy) {
//search if it is not already exists
android::Mutex::Autolock mutex(m_lock);
for(DisplaysList::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if((*it)->nativeType() == dpy) return (*it);
}
EglDisplay* p_dpy = new EglDisplay(dpy);
if(p_dpy) {
m_displays.push_front(p_dpy);
return p_dpy;
}
return NULL;
}
bool EglGlobalInfo::removeDisplay(EGLDisplay dpy) {
android::Mutex::Autolock mutex(m_lock);
for(DisplaysList::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if(static_cast<EGLDisplay>(*it) == dpy) {
delete (*it);
m_displays.remove(*it);
return true;
}
}
return false;
}
EglDisplay* EglGlobalInfo::getDisplay(EGLNativeDisplayType dpy) {
android::Mutex::Autolock mutex(m_lock);
for(DisplaysList::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if((*it)->nativeType() == dpy) return (*it);
}
return NULL;
}
EglDisplay* EglGlobalInfo::getDisplay(EGLDisplay dpy) {
android::Mutex::Autolock mutex(m_lock);
for(DisplaysList::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if(static_cast<EGLDisplay>(*it) == dpy) return (*it);
}
return NULL;
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_GLOBAL_INFO
#define EGL_GLOBAL_INFO
#include <list>
#include <EGL/egl.h>
#include <utils/threads.h>
#include <GLcommon/TranslatorIfaces.h>
#include "EglDisplay.h"
#include "EglConfig.h"
#include "EglContext.h"
typedef std::list<EglDisplay*> DisplaysList;
class EglGlobalInfo {
public:
EglDisplay* addDisplay(EGLNativeDisplayType dpy);
EglDisplay* getDisplay(EGLNativeDisplayType dpy);
EglDisplay* getDisplay(EGLDisplay dpy);
bool removeDisplay(EGLDisplay dpy);
EGLNativeDisplayType getDefaultNativeDisplay(){ return m_default;};
void setIface(GLESiface* iface,GLESVersion ver) { m_gles_ifaces[ver] = iface;};
GLESiface* getIface(GLESVersion ver){ return m_gles_ifaces[ver];}
int nDisplays() const { return m_displays.size();};
static EglGlobalInfo* getInstance();
static void delInstance();
private:
EglGlobalInfo();
~EglGlobalInfo(){};
static EglGlobalInfo* m_singleton;
static int m_refCount;
DisplaysList m_displays;
EGLNativeDisplayType m_default;
GLESiface* m_gles_ifaces[MAX_GLES_VERSION];
android::Mutex m_lock;
};
#endif

View File

@@ -0,0 +1,916 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <EGL/egl.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <GLcommon/ThreadInfo.h>
#include <GLcommon/TranslatorIfaces.h>
#include "EglWindowSurface.h"
#include "EglPbufferSurface.h"
#include "EglPixmapSurface.h"
#include "EglGlobalInfo.h"
#include "EglThreadInfo.h"
#include "EglValidate.h"
#include "EglDisplay.h"
#include "EglContext.h"
#include "EglConfig.h"
#include "EglOsApi.h"
#define MINOR 1
#define MAJOR 4
EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance();
__thread EglThreadInfo* tls_thread = NULL;
static EGLiface s_eglIface = {
getThreadInfo: getThreadInfo // implemented in ThreadInfo.cpp
};
//extentions
typedef struct {
const char* name;
__eglMustCastToProperFunctionPointerType address;
} EglExtentionDescriptor;
#define EGL_EXTENTIONS 0
//supported extentions;
static EglExtentionDescriptor s_extentions[] = {};
//macros for accessing global egl info & tls objects
#define CURRENT_THREAD() \
if(!tls_thread) { \
tls_thread = new EglThreadInfo(); \
}
#define RETURN_ERROR(ret,err) \
CURRENT_THREAD() \
if(tls_thread->getError() == EGL_SUCCESS) { \
tls_thread->setError(err); \
} \
return ret;
#define VALIDATE_DISPLAY_RETURN(EGLDisplay,ret) \
EglDisplay* dpy = g_eglInfo->getDisplay(EGLDisplay); \
if(!dpy){ \
RETURN_ERROR(ret,EGL_BAD_DISPLAY); \
} \
if(!dpy->isInitialize()) { \
RETURN_ERROR(ret,EGL_NOT_INITIALIZED); \
}
#define VALIDATE_CONFIG_RETURN(EGLConfig,ret) \
EglConfig* cfg = dpy->getConfig(EGLConfig); \
if(!cfg) { \
RETURN_ERROR(ret,EGL_BAD_CONFIG); \
}
#define VALIDATE_SURFACE_RETURN(EGLSurface,ret,varName) \
SurfacePtr varName = dpy->getSurface(EGLSurface); \
if(!varName.Ptr()) { \
RETURN_ERROR(ret,EGL_BAD_SURFACE); \
}
#define VALIDATE_CONTEXT_RETURN(EGLContext,ret) \
ContextPtr ctx = dpy->getContext(EGLContext); \
if(!ctx.Ptr()) { \
RETURN_ERROR(ret,EGL_BAD_CONTEXT); \
}
#define VALIDATE_DISPLAY(EGLDisplay) \
VALIDATE_DISPLAY_RETURN(EGLDisplay,EGL_FALSE)
#define VALIDATE_CONFIG(EGLConfig) \
VALIDATE_CONFIG_RETURN(EGLConfig,EGL_FALSE)
#define VALIDATE_SURFACE(EGLSurface,varName) \
VALIDATE_SURFACE_RETURN(EGLSurface,EGL_FALSE,varName)
#define VALIDATE_CONTEXT(EGLContext) \
VALIDATE_CONTEXT_RETURN(EGLContext,EGL_FALSE)
EGLAPI EGLint EGLAPIENTRY eglGetError(void) {
CURRENT_THREAD();
EGLint err = tls_thread->getError();
tls_thread->setError(EGL_SUCCESS);
return err;
}
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) {
EglDisplay* dpy = NULL;
if( display_id == EGL_DEFAULT_DISPLAY) {
display_id = g_eglInfo->getDefaultNativeDisplay();
}
if ((dpy = g_eglInfo->getDisplay(display_id))) {
return dpy;
} else {
dpy = g_eglInfo->addDisplay(display_id);
if(dpy) return dpy;
return EGL_NO_DISPLAY;
}
}
static __translator_getGLESIfaceFunc loadIfaces(const char* libName){
void* libGLES = dlopen(libName, RTLD_NOW);
if(!libGLES) return NULL;
__translator_getGLESIfaceFunc func = (__translator_getGLESIfaceFunc)dlsym(libGLES,"__translator_getIfaces");
if(!func) return NULL;
return func;
}
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) {
EglDisplay* dpy = g_eglInfo->getDisplay(display);
if(!dpy) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_DISPLAY);
}
if(major) *major = MAJOR;
if(minor) *minor = MINOR;
if(!g_eglInfo->getIface(GLES_1_1)) {
__translator_getGLESIfaceFunc func = loadIfaces("libGLES_CM_translator.so");
if(func){
g_eglInfo->setIface(func(&s_eglIface),GLES_1_1);
} else {
return EGL_FALSE;
}
}
dpy->initialize();
return EGL_TRUE;
}
//TODO check this func definitions later on
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay display) {
VALIDATE_DISPLAY(display);
dpy->terminate();
return EGL_TRUE;
}
EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay display, EGLint name) {
VALIDATE_DISPLAY(display);
static const char* vendor = "Google";
static const char* version = "1.4";
static const char* extensions = "EGL_KHR_image_base EGL_KHR_gl_texture_2d_image"; //XXX: Not implemented yet
if(!EglValidate::stringName(name)) {
RETURN_ERROR(NULL,EGL_BAD_PARAMETER);
}
switch(name) {
case EGL_VENDOR:
return vendor;
case EGL_VERSION:
return version;
case EGL_EXTENSIONS:
return extensions;
}
return NULL;
}
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay display, EGLConfig *configs,
EGLint config_size, EGLint *num_config) {
VALIDATE_DISPLAY(display);
if(!num_config) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
}
if(configs == NULL) {
*num_config = dpy->nConfigs();
} else {
*num_config = dpy->getConfigs(configs,config_size);
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *attrib_list,
EGLConfig *configs, EGLint config_size,
EGLint *num_config) {
VALIDATE_DISPLAY(display);
if(!num_config) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
}
//selection defaults
EGLint surface_type = EGL_WINDOW_BIT;
EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE;
EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE;
EGLenum caveat = EGL_DONT_CARE;
EGLint config_id = EGL_DONT_CARE;
EGLBoolean native_renderable = EGL_DONT_CARE;
EGLint native_visual_type = EGL_DONT_CARE;
EGLint max_swap_interval = EGL_DONT_CARE;
EGLint min_swap_interval = EGL_DONT_CARE;
EGLint trans_red_val = EGL_DONT_CARE;
EGLint trans_green_val = EGL_DONT_CARE;
EGLint trans_blue_val = EGL_DONT_CARE;
EGLenum transparent_type = EGL_NONE;
EGLint buffer_size = 0;
EGLint red_size = 0;
EGLint green_size = 0;
EGLint blue_size = 0;
EGLint alpha_size = 0;
EGLint depth_size = 0;
EGLint frame_buffer_level = 0;
EGLint sample_buffers_num = 0;
EGLint samples_per_pixel = 0;
EGLint stencil_size = 0;
if(!EglValidate::noAttribs(attrib_list)) { //there are attribs
int i = 0 ;
bool hasConfigId = false;
while(attrib_list[i] != EGL_NONE && !hasConfigId) {
switch(attrib_list[i]) {
case EGL_MAX_PBUFFER_WIDTH:
case EGL_MAX_PBUFFER_HEIGHT:
case EGL_MAX_PBUFFER_PIXELS:
case EGL_NATIVE_VISUAL_ID:
continue; //we dont care from those selection crateria
case EGL_LEVEL:
if(attrib_list[i+1] == EGL_DONT_CARE) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
frame_buffer_level = attrib_list[i+1];
break;
case EGL_BUFFER_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
buffer_size = attrib_list[i+1];
break;
case EGL_RED_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
red_size = attrib_list[i+1];
break;
case EGL_GREEN_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
green_size = attrib_list[i+1];
break;
case EGL_BLUE_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
blue_size = attrib_list[i+1];
break;
case EGL_ALPHA_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
alpha_size = attrib_list[i+1];
break;
case EGL_BIND_TO_TEXTURE_RGB:
bind_to_tex_rgb = attrib_list[i+1];
break;
case EGL_BIND_TO_TEXTURE_RGBA:
bind_to_tex_rgba = attrib_list[i+1];
break;
case EGL_CONFIG_CAVEAT:
if(attrib_list[i+1] != EGL_NONE && attrib_list[i+1] != EGL_SLOW_CONFIG && attrib_list[i+1] != EGL_NON_CONFORMANT_CONFIG) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
caveat = attrib_list[i+1];
break;
case EGL_CONFIG_ID:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
config_id = attrib_list[i+1];
hasConfigId = true;
break;
case EGL_DEPTH_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
depth_size = attrib_list[i+1];
break;
case EGL_MAX_SWAP_INTERVAL:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
max_swap_interval = attrib_list[i+1];
break;
case EGL_MIN_SWAP_INTERVAL:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
min_swap_interval = attrib_list[i+1];
break;
case EGL_NATIVE_RENDERABLE:
native_renderable = attrib_list[i+1];
break;
case EGL_NATIVE_VISUAL_TYPE:
native_visual_type = attrib_list[i+1];
break;
if(attrib_list[i+1] < 0 || attrib_list[i+1] > 1 ) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
case EGL_SAMPLE_BUFFERS:
sample_buffers_num = attrib_list[i+1];
break;
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
case EGL_SAMPLES:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
samples_per_pixel = attrib_list[i+1];
break;
case EGL_STENCIL_SIZE:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
stencil_size = attrib_list[i+1];
break;
case EGL_SURFACE_TYPE:
surface_type = attrib_list[i+1];
break;
case EGL_TRANSPARENT_TYPE:
if(attrib_list[i+1] != EGL_NONE && attrib_list[i+1] != EGL_TRANSPARENT_RGB ) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
transparent_type = attrib_list[i+1];
break;
case EGL_TRANSPARENT_RED_VALUE:
trans_red_val = attrib_list[i+1];
break;
case EGL_TRANSPARENT_GREEN_VALUE:
trans_green_val = attrib_list[i+1];
break;
case EGL_TRANSPARENT_BLUE_VALUE:
trans_blue_val = attrib_list[i+1];
break;
default:
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
i+=2;
}
if(hasConfigId) {
EglConfig* pConfig = dpy->getConfig(config_id);
if(pConfig) {
configs[0] = static_cast<EGLConfig>(pConfig);
*num_config = 0;
return EGL_TRUE;
} else {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
}
}
EglConfig dummy(red_size,green_size,blue_size,alpha_size,caveat,config_id,depth_size,
frame_buffer_level,0,0,0,native_renderable,0,native_visual_type,
samples_per_pixel,stencil_size,surface_type,transparent_type,
trans_red_val,trans_green_val,trans_blue_val);
*num_config = dpy->chooseConfigs(dummy,configs,config_size);
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay display, EGLConfig config,
EGLint attribute, EGLint *value) {
VALIDATE_DISPLAY(display);
VALIDATE_CONFIG(config);
if(!EglValidate::confAttrib(attribute)){
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
return cfg->getConfAttrib(attribute,value)? EGL_TRUE:EGL_FALSE;
}
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay display, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list) {
VALIDATE_DISPLAY_RETURN(display,EGL_NO_SURFACE);
VALIDATE_CONFIG_RETURN(config,EGL_NO_SURFACE);
if(!(cfg->surfaceType() & EGL_WINDOW_BIT)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_MATCH);
}
if(!EglOS::validNativeWin(win)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_NATIVE_WINDOW);
}
if(!EglValidate::noAttribs(attrib_list)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE);
}
if(EglWindowSurface::alreadyAssociatedWithConfig(win)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
unsigned int width,height;
if(!EglOS::checkWindowPixelFormatMatch(dpy->nativeType(),win,cfg,&width,&height)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
SurfacePtr wSurface(new EglWindowSurface(win,cfg,width,height));
if(!wSurface.Ptr()) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
return dpy->addSurface(wSurface);
}
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay display, EGLConfig config,
const EGLint *attrib_list) {
VALIDATE_DISPLAY_RETURN(display,EGL_NO_SURFACE);
VALIDATE_CONFIG_RETURN(config,EGL_NO_SURFACE);
if(!(cfg->surfaceType() & EGL_PBUFFER_BIT)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_MATCH);
}
SurfacePtr pbSurface(new EglPbufferSurface(cfg));
if(!pbSurface.Ptr()) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
if(!EglValidate::noAttribs(attrib_list)) { //there are attribs
int i = 0 ;
while(attrib_list[i] != EGL_NONE) {
if(!pbSurface.Ptr()->setAttrib(attrib_list[i],attrib_list[i+1])) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE);
}
i+=2;
}
}
EGLint width,height,largest,texTarget,texFormat;
EglPbufferSurface* tmpPbSurfacePtr = static_cast<EglPbufferSurface*>(pbSurface.Ptr());
tmpPbSurfacePtr->getDim(&width,&height,&largest);
tmpPbSurfacePtr->getTexInfo(&texTarget,&texFormat);
if(!EglValidate::pbufferAttribs(width,height,texFormat == EGL_NO_TEXTURE,texTarget == EGL_NO_TEXTURE)) {
//TODO: RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_VALUE); dont have bad_value
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE);
}
EGLNativePbufferType pb = EglOS::createPbuffer(dpy->nativeType(),cfg,tmpPbSurfacePtr);
if(!pb) {
//TODO: RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_VALUE); dont have bad value
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE);
}
tmpPbSurfacePtr->setNativePbuffer(pb);
return dpy->addSurface(pbSurface);
}
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay display, EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint *attrib_list) {
VALIDATE_DISPLAY_RETURN(display,EGL_NO_SURFACE);
VALIDATE_CONFIG_RETURN(config,EGL_NO_SURFACE);
if(!(cfg->surfaceType() & EGL_PIXMAP_BIT)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_MATCH);
}
if(!EglValidate::noAttribs(attrib_list)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ATTRIBUTE);
}
if(EglPixmapSurface::alreadyAssociatedWithConfig(pixmap)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
unsigned int width,height;
if(!EglOS::checkPixmapPixelFormatMatch(dpy->nativeType(),pixmap,cfg,&width,&height)) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
SurfacePtr pixSurface(new EglPixmapSurface(pixmap,cfg));
if(!pixSurface.Ptr()) {
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_ALLOC);
}
return dpy->addSurface(pixSurface);
}
static bool destroySurfaceIfNotCurrent(EglDisplay* dpy,SurfacePtr surface) {
ThreadInfo* thread = getThreadInfo();
EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
if(currCtx && !currCtx->usingSurface(surface)){
if(surface.Ptr()->type() == EglSurface::PBUFFER) {
EglOS::releasePbuffer(dpy->nativeType(),reinterpret_cast<EGLNativePbufferType>(surface.Ptr()->native()));
return true;
}
}
return false;
}
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface surface) {
VALIDATE_DISPLAY(display);
SurfacePtr srfc = dpy->getSurface(surface);
if(!srfc.Ptr()) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
srfc.Ptr()->destroy(); //mark surface for destruction
if(destroySurfaceIfNotCurrent(dpy,srfc)) { //removes surface from the list if not current
dpy->removeSurface(surface);
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay display, EGLSurface surface,
EGLint attribute, EGLint *value) {
VALIDATE_DISPLAY(display);
VALIDATE_SURFACE(surface,srfc);
if(!srfc.Ptr()->getAttrib(attribute,value)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay display, EGLSurface surface,
EGLint attribute, EGLint value) {
VALIDATE_DISPLAY(display);
VALIDATE_SURFACE(surface,srfc);
if(!srfc.Ptr()->setAttrib(attribute,value)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
return EGL_TRUE;
}
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay display, EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list) {
VALIDATE_DISPLAY_RETURN(display,EGL_NO_CONTEXT);
VALIDATE_CONFIG_RETURN(config,EGL_NO_CONTEXT);
GLESVersion version = GLES_1_1;
if(!EglValidate::noAttribs(attrib_list)) {
int i = 0;
while(attrib_list[i] != EGL_NONE) {
switch(attrib_list[i]) {
case EGL_CONTEXT_CLIENT_VERSION:
if(attrib_list[i+1] == 2) {
version = GLES_2_0;
} else {
version = GLES_1_1;
}
break;
default:
RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_ATTRIBUTE);
}
i+=2;
}
}
GLESiface* iface = g_eglInfo->getIface(version);
GLEScontext* glesCtx = NULL;
if(iface) {
glesCtx = iface->createGLESContext();
} else { // there is no interface for this gles version
RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_ATTRIBUTE);
}
ContextPtr sharedCtxPtr;
EGLNativeContextType nativeShared = NULL;
if(share_context != EGL_NO_CONTEXT) {
sharedCtxPtr = dpy->getContext(share_context);
if(!sharedCtxPtr.Ptr()) {
RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_CONTEXT);
}
nativeShared = sharedCtxPtr->nativeType();
}
EGLNativeContextType nativeContext = EglOS::createContext(dpy->nativeType(),cfg,nativeShared);
if(nativeContext) {
ContextPtr ctx(new EglContext(nativeContext,sharedCtxPtr,cfg,glesCtx,version,dpy->getManager(version)));
return dpy->addContext(ctx);
} else {
iface->deleteGLESContext(glesCtx);
}
return EGL_NO_CONTEXT;
}
static bool destroyContextIfNotCurrent(EglDisplay* dpy,ContextPtr ctx ) {
ThreadInfo* thread = getThreadInfo();
EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
if(ctx.Ptr() != currCtx ){
EglOS::destroyContext(dpy->nativeType(),ctx.Ptr()->nativeType());
return true;
}
return false;
}
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay display, EGLContext context) {
VALIDATE_DISPLAY(display);
VALIDATE_CONTEXT(context);
ctx.Ptr()->destroy(); //mark for destruction
if(destroyContextIfNotCurrent(dpy,ctx)){ //removes the context from the list if it is not current
g_eglInfo->getIface(ctx.Ptr()->version())->deleteGLESContext(ctx.Ptr()->getGlesContext());
dpy->removeContext(context);
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay display, EGLSurface draw,
EGLSurface read, EGLContext context) {
VALIDATE_DISPLAY(display);
bool releaseContext = EglValidate::releaseContext(context,read,draw);
if(!releaseContext && EglValidate::badContextMatch(context,read,draw)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_MATCH);
}
VALIDATE_CONTEXT(context);
VALIDATE_SURFACE(draw,newDrawSrfc);
VALIDATE_SURFACE(read,newReadSrfc);
EglSurface* newDrawPtr = newDrawSrfc.Ptr();
EglSurface* newReadPtr = newReadSrfc.Ptr();
EglContext* newCtx = ctx.Ptr();
ThreadInfo* thread = getThreadInfo();
EglContext* prevCtx = static_cast<EglContext*>(thread->eglContext);
if(releaseContext) { //releasing current context
if(prevCtx) {
g_eglInfo->getIface(prevCtx->version())->flush();
if(!EglOS::makeCurrent(dpy->nativeType(),NULL,NULL,NULL)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ACCESS);
}
thread->updateInfo(newCtx,dpy,NULL,newCtx->getShareGroup(),dpy->getManager(newCtx->version()));
ctx.Ptr()->setSurfaces(SurfacePtr(NULL),SurfacePtr(NULL));
}
} else { //assining new context
//surfaces compitability check
if(!((*ctx->getConfig()).compitableWith((*newDrawPtr->getConfig()))) ||
!((*ctx->getConfig()).compitableWith((*newReadPtr->getConfig())))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_MATCH);
}
//checking native window validity
if(newReadPtr->type() == EglSurface::WINDOW && !EglOS::validNativeWin(reinterpret_cast<EGLNativeWindowType>(newReadPtr->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_WINDOW);
}
if(newDrawPtr->type() == EglSurface::WINDOW && !EglOS::validNativeWin(reinterpret_cast<EGLNativeWindowType>(newDrawPtr->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_WINDOW);
}
//checking native pixmap validity
if(newReadPtr->type() == EglSurface::PIXMAP && !EglOS::validNativePixmap(reinterpret_cast<EGLNativePixmapType>(newReadPtr->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP);
}
if(newDrawPtr->type() == EglSurface::PIXMAP && !EglOS::validNativePixmap(reinterpret_cast<EGLNativePixmapType>(newDrawPtr->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP);
}
if(prevCtx) {
g_eglInfo->getIface(prevCtx->version())->flush();
}
if(!EglOS::makeCurrent(dpy->nativeType(),newReadPtr,newDrawPtr,newCtx->nativeType())) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ACCESS);
}
//TODO: handle the following errors
// EGL_BAD_CURRENT_SURFACE , EGL_CONTEXT_LOST , EGL_BAD_ACCESS
thread->updateInfo(newCtx,dpy,newCtx->getGlesContext(),newCtx->getShareGroup(),dpy->getManager(newCtx->version()));
newCtx->setSurfaces(newReadSrfc,newDrawSrfc);
g_eglInfo->getIface(newCtx->version())->initContext(newCtx->getGlesContext());
}
SurfacePtr prevRead;
SurfacePtr prevDraw;
//removing terminated surfaces & context
if(prevCtx) {
prevRead = prevCtx->read();
if(prevRead.Ptr()->destroy()){
if(destroySurfaceIfNotCurrent(dpy,prevRead)) { //removes surface from the list if not current
dpy->removeSurface(prevRead);
}
}
prevDraw = prevCtx->draw();
if(prevDraw.Ptr()->destroy()){
if(destroySurfaceIfNotCurrent(dpy,prevDraw)) { //removes surface from the list if not current
dpy->removeSurface(prevDraw);
}
}
if(prevCtx->destroy()) {
ContextPtr prevCtxPtr = ContextPtr(prevCtx);
if(destroyContextIfNotCurrent(dpy,prevCtxPtr)){ //removes the context from the list if it is not current
g_eglInfo->getIface(prevCtx->version())->deleteGLESContext(prevCtx->getGlesContext());
dpy->removeContext(prevCtxPtr);
}
}
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay display, EGLContext context,
EGLint attribute, EGLint *value) {
VALIDATE_DISPLAY(display);
VALIDATE_CONTEXT(context);
if(!ctx->getAttrib(attribute,value)){
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay display, EGLSurface surface) {
VALIDATE_DISPLAY(display);
VALIDATE_SURFACE(surface,Srfc);
ThreadInfo* thread = getThreadInfo();
EglContext* currentCtx = static_cast<EglContext*>(thread->eglContext);
//if surface not window return
if(Srfc.Ptr()->type() != EglSurface::WINDOW){
RETURN_ERROR(EGL_TRUE,EGL_SUCCESS);
}
if(!currentCtx || !currentCtx->usingSurface(Srfc) || !EglOS::validNativeWin(reinterpret_cast<EGLNativeWindowType>(Srfc.Ptr()->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
EglOS::swapBuffers(dpy->nativeType(),reinterpret_cast<EGLNativeWindowType>(Srfc.Ptr()->native()));
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay display, EGLint interval) {
VALIDATE_DISPLAY(display);
ThreadInfo* thread = getThreadInfo();
EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
if(currCtx) {
if(!currCtx->read().Ptr() || !currCtx->draw().Ptr() || currCtx->draw().Ptr()->type()!=EglSurface::WINDOW) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_CURRENT_SURFACE);
}
EglOS::swapInterval(dpy->nativeType(),reinterpret_cast<EGLNativeWindowType>(currCtx->draw().Ptr()->native()),interval);
} else {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
return EGL_TRUE;
}
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) {
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
if(dpy && ctx){
return dpy->getContext(ContextPtr(ctx));
}
return EGL_NO_CONTEXT;
}
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) {
if(!EglValidate::surfaceTarget(readdraw)) return EGL_NO_SURFACE;
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
EglContext* ctx = static_cast<EglContext*>(thread->eglContext);
if(dpy && ctx) {
SurfacePtr surface = readdraw == EGL_READ ? ctx->read() : ctx->draw();
return dpy->getSurface(surface);
}
return EGL_NO_SURFACE;
}
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) {
ThreadInfo* thread = getThreadInfo();
return (thread->eglContext) ? thread->eglDisplay : EGL_NO_DISPLAY;
}
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) {
EGLenum api = eglQueryAPI();
eglBindAPI(EGL_OPENGL_ES_API);
return eglWaitClient();
}
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) {
if(!EglValidate::engine(engine)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
}
ThreadInfo* thread = getThreadInfo();
EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
if(currCtx) {
EglSurface* read = currCtx->read().Ptr();
EglSurface* draw = currCtx->read().Ptr();
if(read) {
if(read->type() == EglSurface::WINDOW &&
!EglOS::validNativeWin(reinterpret_cast<EGLNativeWindowType>(read->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
if(read->type() == EglSurface::PIXMAP &&
!EglOS::validNativePixmap(reinterpret_cast<EGLNativePixmapType>(read->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
}
if(draw) {
if(draw->type() == EglSurface::WINDOW &&
!EglOS::validNativeWin(reinterpret_cast<EGLNativeWindowType>(draw->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
if(draw->type() == EglSurface::PIXMAP &&
!EglOS::validNativePixmap(reinterpret_cast<EGLNativePixmapType>(draw->native()))) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_SURFACE);
}
}
}
EglOS::waitNative();
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) {
if(!EglValidate::supportedApi(api)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_PARAMETER);
}
CURRENT_THREAD();
tls_thread->setApi(api);
return EGL_TRUE;
}
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void) {
CURRENT_THREAD();
return tls_thread->getApi();
}
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) {
ThreadInfo* thread = getThreadInfo();
EglContext* currCtx = static_cast<EglContext*>(thread->eglContext);
if(currCtx) {
if(!currCtx->read().Ptr() || !currCtx->draw().Ptr()) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_CURRENT_SURFACE);
}
g_eglInfo->getIface(currCtx->version())->finish();
}
return EGL_TRUE;
}
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) {
ThreadInfo* thread = getThreadInfo();
EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
return eglMakeCurrent(dpy,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
}
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname){
if(!strncmp(procname,"egl",3)) { //EGL proc
for(int i=0;i < EGL_EXTENSIONS;i++){
if(strcmp(procname,s_extentions[i].name) == 0){
return s_extentions[i].address;
}
}
} else if (!strncmp(procname,"gl",2)){ //GL proc
//TODO:call glGetProcAdress
}
return NULL;
}
//not supported for now
/************************* NOT SUPPORTED FOR NOW ***********************/
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
EGLDisplay display, EGLenum buftype, EGLClientBuffer buffer,
EGLConfig config, const EGLint *attrib_list) {
VALIDATE_DISPLAY(display);
VALIDATE_CONFIG(config);
//we do not support for now openVG, and the only client API resources which may be bound in this fashion are OpenVG
RETURN_ERROR(EGL_NO_SURFACE,EGL_BAD_PARAMETER);
}
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay display, EGLSurface surface,
EGLNativePixmapType target) {
VALIDATE_DISPLAY(display);
VALIDATE_SURFACE(surface,srfc);
if(!EglOS::validNativePixmap(target)) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP);
}
//we do not need to support this for android , since we are not gonna use pixmaps
RETURN_ERROR(EGL_FALSE,EGL_BAD_NATIVE_PIXMAP);
}
/***********************************************************************/
//do last ( only if needed)
/*********************************************************************************************************/
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
//TODO:
return 0;
}
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) {
//TODO:
return 0;
}
/*********************************************************************************************************/

View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglOsApi.h"
//TODO: implementation for mac for all funcs
namespace EglOS {
EGLNativeDisplayType getDefaultDisplay() {return NULL}
bool releaseDisplay(EGLNativeDisplayType dpy) {
return false;
}
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt){
return NULL;
}
void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut) {
}
bool validNativeWin(EGLNativeWindowType win) {
return true;
}
bool validNativePixmap(EGLNativePixmapType pix) {
return true;
}
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
return false;
}
bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) {
return false;
}
EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){
return NULL;
}
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
return NULL;
}
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) {
return false;
}
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){
return false;
}
void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
}
void waitNative() {
}
void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval){
}
};

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_OS_API_H
#define EGL_OS_API_H
#include <EGL/egl.h>
#include <GL/gl.h>
#include "EglConfig.h"
#include "EglDisplay.h"
#include "EglPbufferSurface.h"
#define PBUFFER_MAX_WIDTH 32767
#define PBUFFER_MAX_HEIGHT 32767
#define PBUFFER_MAX_PIXELS 32767*32767
namespace EglOS{
void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut);
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb);
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx);
bool releaseDisplay(EGLNativeDisplayType dpy);
bool validNativeWin(EGLNativeWindowType win);
bool validNativePixmap(EGLNativePixmapType pix);
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height);
bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height);
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType);
void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win);
void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval);
void waitNative();
EGLNativeDisplayType getDefaultDisplay();
EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* pb);
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext);
};
#endif

View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglPbufferSurface.h"
bool EglPbufferSurface::setAttrib(EGLint attrib,EGLint val) {
switch(attrib) {
case EGL_WIDTH:
if(val < 0) return false;
m_width = val;
break;
case EGL_HEIGHT:
if(val < 0) return false;
m_height = val;
break;
case EGL_LARGEST_PBUFFER:
m_largest = val;
break;
case EGL_TEXTURE_FORMAT:
if(val != EGL_NO_TEXTURE && val != EGL_TEXTURE_RGB && val != EGL_TEXTURE_RGBA) return false;
m_texFormat = val;
break;
case EGL_TEXTURE_TARGET:
if(val != EGL_NO_TEXTURE && val != EGL_TEXTURE_2D) return false;
m_texTarget = val;
break;
case EGL_MIPMAP_TEXTURE:
m_texMipmap = val;
break;
default:
return false;
}
return true;
}
bool EglPbufferSurface::getAttrib(EGLint attrib,EGLint* val) {
switch(attrib) {
case EGL_CONFIG_ID:
*val = m_config->id();
break;
case EGL_WIDTH:
*val = m_width;
break;
case EGL_HEIGHT:
*val = m_height;
break;
case EGL_LARGEST_PBUFFER:
*val = m_largest;
break;
case EGL_TEXTURE_FORMAT:
*val = m_texFormat;
break;
case EGL_TEXTURE_TARGET:
*val = m_texTarget;
break;
case EGL_MIPMAP_TEXTURE:
*val = m_texMipmap;
break;
default:
return false;
}
return true;
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_PBUFFER_SURFACE_H
#define EGL_PBUFFER_SURFACE_H
#include "EglSurface.h"
class EglPbufferSurface:public EglSurface {
public:
EglPbufferSurface(EglConfig* config):EglSurface(PBUFFER,config,0,0),
m_texFormat(EGL_NO_TEXTURE),
m_texTarget(EGL_NO_TEXTURE),
m_texMipmap(EGL_FALSE),
m_largest(EGL_FALSE),
m_nativePbuffer(0){};
void* native(){ return (void*)m_nativePbuffer;};
void setNativePbuffer(EGLNativePbufferType pb){ m_nativePbuffer = pb;};
bool setAttrib(EGLint attrib,EGLint val);
bool getAttrib(EGLint attrib,EGLint* val);
void getDim(EGLint* width,EGLint* height,EGLint* largest){
*width = m_width;
*height = m_height;
*largest = m_largest;
};
void getTexInfo(EGLint* format,EGLint* target){ *format = m_texFormat; *target = m_texTarget;}
private:
EGLint m_texFormat;
EGLint m_texTarget;
EGLint m_texMipmap;
EGLint m_largest;
EGLNativePbufferType m_nativePbuffer;
};
#endif

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglPixmapSurface.h"
std::set<EGLNativePixmapType> EglPixmapSurface::s_associatedPixmaps;
bool EglPixmapSurface::alreadyAssociatedWithConfig(EGLNativePixmapType pix) {
return s_associatedPixmaps.find(pix) != s_associatedPixmaps.end();
}
EglPixmapSurface::EglPixmapSurface(EGLNativePixmapType pix,EglConfig* config):EglSurface(PIXMAP,config,0,0),m_pixmap(pix) {
s_associatedPixmaps.insert(pix);
}
EglPixmapSurface::~EglPixmapSurface() {
s_associatedPixmaps.erase(m_pixmap);
}
bool EglPixmapSurface::getAttrib(EGLint attrib,EGLint* val) {
switch(attrib) {
case EGL_CONFIG_ID:
*val = m_config->id();
break;
case EGL_WIDTH:
*val = m_width;
break;
case EGL_HEIGHT:
*val = m_height;
break;
case EGL_LARGEST_PBUFFER:
case EGL_TEXTURE_FORMAT:
case EGL_TEXTURE_TARGET:
case EGL_MIPMAP_TEXTURE:
break;
default:
return false;
}
return true;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_PIXMAP_SURFACE_H
#define EGL_PIXMAP_SURFACE_H
#include <set>
#include <EGL/egl.h>
#include "EglSurface.h"
class EglPixmapSurface: public EglSurface {
public:
EglPixmapSurface(EGLNativePixmapType pix,EglConfig* config);
~EglPixmapSurface();
void* native(){ return (void*)m_pixmap;};
bool getAttrib(EGLint attrib,EGLint* val);
static bool alreadyAssociatedWithConfig(EGLNativePixmapType pix);
private:
EGLNativePixmapType m_pixmap;
static std::set<EGLNativeWindowType> s_associatedPixmaps;
};
#endif

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglSurface.h"
unsigned int EglSurface::s_nextSurfaceHndl = 0;
bool EglSurface::setAttrib(EGLint attrib,EGLint val) {
switch(attrib) {
case EGL_WIDTH:
case EGL_HEIGHT:
case EGL_LARGEST_PBUFFER:
case EGL_TEXTURE_FORMAT:
case EGL_TEXTURE_TARGET:
case EGL_MIPMAP_TEXTURE:
break;
default:
return false;
}
return true;
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_SURFACE_H
#define EGL_SURFACE_H
#include <EGL/egl.h>
#include <map>
#include <GLcommon/SmartPtr.h>
#include "EglConfig.h"
class EglSurface;
typedef SmartPtr<EglSurface> SurfacePtr;
class EglSurface {
public:
typedef enum {
WINDOW = 0,
PBUFFER = 1,
PIXMAP = 3
} ESurfaceType;
ESurfaceType type(){ return m_type;};
virtual void* native() = 0;
virtual bool setAttrib(EGLint attrib,EGLint val);
virtual bool getAttrib(EGLint attrib,EGLint* val) = 0;
void setDim(int width,int height){ m_width = width; m_height = height;};
void markForDestruction(){m_destroy = true;};
bool destroy(){return m_destroy;};
EglConfig* getConfig(){return m_config;};
unsigned int getHndl(){return m_hndl;};
private:
static unsigned int s_nextSurfaceHndl;
ESurfaceType m_type;
bool m_destroy;
unsigned int m_hndl;
protected:
EglSurface(ESurfaceType type,EglConfig* config,EGLint width,EGLint height):m_type(type),
m_destroy(false),
m_config(config),
m_width(width),
m_height(height){ m_hndl = ++s_nextSurfaceHndl;};
EglConfig* m_config;
EGLint m_width;
EGLint m_height;
};
#endif

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglThreadInfo.h"
#include "EglOsApi.h"
EglThreadInfo::EglThreadInfo():m_err(EGL_SUCCESS),m_api(EGL_OPENGL_ES_API) {}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_THREAD_INFO_H
#define EGL_THREAD_INFO_H
#include <EGL/egl.h>
#include "EglDisplay.h"
#include "EglContext.h"
#include "EglSurface.h"
#include "EglPbufferSurface.h"
class EglThreadInfo {
public:
EglThreadInfo();
void setError(EGLint err) { m_err = err;}
EGLint getError(){ return m_err;}
void destroyContextIfNotCurrent(ContextPtr context );
void setApi(EGLenum api){m_api = api;}
EGLenum getApi(){return m_api;}
private:
EglDisplay* m_currentDisplay;
EGLint m_err;
EGLenum m_api;
};
#endif

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglValidate.h"
#include <GLcommon/GLutils.h>
bool EglValidate::confAttrib(EGLint attrib) {
switch(attrib) {
case EGL_BUFFER_SIZE:
case EGL_RED_SIZE:
case EGL_GREEN_SIZE:
case EGL_BLUE_SIZE:
case EGL_ALPHA_SIZE:
case EGL_BIND_TO_TEXTURE_RGB:
case EGL_BIND_TO_TEXTURE_RGBA:
case EGL_CONFIG_CAVEAT:
case EGL_CONFIG_ID:
case EGL_DEPTH_SIZE:
case EGL_LEVEL:
case EGL_MAX_PBUFFER_WIDTH:
case EGL_MAX_PBUFFER_HEIGHT:
case EGL_MAX_PBUFFER_PIXELS:
case EGL_MAX_SWAP_INTERVAL:
case EGL_MIN_SWAP_INTERVAL:
case EGL_NATIVE_RENDERABLE:
case EGL_NATIVE_VISUAL_ID:
case EGL_NATIVE_VISUAL_TYPE:
case EGL_SAMPLE_BUFFERS:
case EGL_SAMPLES:
case EGL_STENCIL_SIZE:
case EGL_SURFACE_TYPE:
case EGL_TRANSPARENT_TYPE:
case EGL_TRANSPARENT_RED_VALUE:
case EGL_TRANSPARENT_GREEN_VALUE:
case EGL_TRANSPARENT_BLUE_VALUE:
return true;
}
return false;
}
bool EglValidate::noAttribs(const EGLint* attrib) {
return !attrib || attrib[0] == EGL_NONE ;
}
bool EglValidate::pbufferAttribs(EGLint width,EGLint height,bool isTexFormatNoTex,bool isTexTargetNoTex) {
if(!isTexFormatNoTex) {
if (!(isPowerOf2(width) && isPowerOf2(height))) return false;
}
return isTexFormatNoTex == isTexTargetNoTex ;
}
bool EglValidate::releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2) {
return (ctx == EGL_NO_CONTEXT) &&
(s1 == EGL_NO_SURFACE) &&
(s2 == EGL_NO_SURFACE);
}
bool EglValidate::badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2) {
return ctx != EGL_NO_CONTEXT ? (s1 == EGL_NO_SURFACE || s2 == EGL_NO_SURFACE):
(s1 != EGL_NO_SURFACE || s2 != EGL_NO_SURFACE);
}
bool EglValidate::surfaceTarget(EGLint target) {
return target == EGL_READ || target == EGL_DRAW;
}
bool EglValidate::engine(EGLint engine) {
return engine == EGL_CORE_NATIVE_ENGINE;
}
bool EglValidate::stringName(EGLint name) {
return name == EGL_VENDOR ||
name == EGL_VERSION ||
name == EGL_EXTENSIONS;
}
bool EglValidate::supportedApi(EGLenum api) {
return api == EGL_OPENGL_ES_API;
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_VALIDATE_H
#define EGL_VALIDATE_H
#include <EGL/egl.h>
class EglValidate {
public:
static bool confAttrib(EGLint attrib);
static bool noAttribs(const EGLint* attrib);
static bool pbufferAttribs(EGLint width,EGLint height,bool texFormatIsNoTex,bool texTargetIsNoTex);
static bool releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2);
static bool badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2);
static bool surfaceTarget(EGLint target);
static bool engine(EGLint engine);
static bool stringName(EGLint name);
static bool supportedApi(EGLenum api);
};
#endif

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglWindowSurface.h"
std::set<EGLNativeWindowType> EglWindowSurface::s_associatedWins;
bool EglWindowSurface::alreadyAssociatedWithConfig(EGLNativeWindowType win) {
return s_associatedWins.find(win) != s_associatedWins.end();
}
EglWindowSurface::EglWindowSurface(EGLNativeWindowType win,EglConfig* config,unsigned int width,unsigned int height):EglSurface(WINDOW,config,width,height),m_win(win){
s_associatedWins.insert(win);
}
EglWindowSurface:: ~EglWindowSurface() {
s_associatedWins.erase(m_win);
}
bool EglWindowSurface::getAttrib(EGLint attrib,EGLint* val) {
switch(attrib) {
case EGL_CONFIG_ID:
*val = m_config->id();
break;
case EGL_WIDTH:
*val = m_width;
break;
case EGL_HEIGHT:
*val = m_height;
break;
case EGL_LARGEST_PBUFFER:
case EGL_TEXTURE_FORMAT:
case EGL_TEXTURE_TARGET:
case EGL_MIPMAP_TEXTURE:
break;
default:
return false;
}
return true;
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGL_WINDOW_SURFACE_H
#define EGL_WINDOW_SURFACE_H
#include <set>
#include <EGL/egl.h>
#include "EglSurface.h"
#include "EglConfig.h"
class EglWindowSurface: public EglSurface {
public:
EglWindowSurface(EGLNativeWindowType win,EglConfig* config,unsigned width,unsigned int height);
~EglWindowSurface();
bool getAttrib(EGLint attrib,EGLint* val);
void* native(){ return (void *)m_win;};
static bool alreadyAssociatedWithConfig(EGLNativeWindowType win);
private:
EGLNativeWindowType m_win;
static std::set<EGLNativeWindowType> s_associatedWins;
};
#endif

View File

@@ -0,0 +1,278 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglOsApi.h"
#include <windows.h>
#include <GL/wglext.h>
#define IS_TRUE(a) \
if(a != true) return false;
namespace EglOS{
bool WGLExtensionSupported(const char *extension_name)
{
// this is pointer to function which returns pointer to string with list of all wgl extensions
PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglGetExtensionsStringEXT = NULL;
// determine pointer to wglGetExtensionsStringEXT function
_wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) wglGetProcAddress("wglGetExtensionsStringEXT");
if (strstr(_wglGetExtensionsString(), extension_name) == NULL)
{
// string was not found
return false;
}
// extension is supported
return true;
}
EGLNativeDisplayType getDefaultDisplay() {
return GetDC();
}
bool releaseDisplay(EGLNativeDisplay dpy) {
return DeleteDC(dpy);
}
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt,int index){
int supportedSurfaces,visualType,visualId;
int caveat,transparentType,samples;
int tRed,tGreen,tBlue;
int pMaxWidth,pMaxHeight,pMaxPixels;
int configId,level,renderable;
bool window,bitmap,pbuffer,transparent;
if(frmt->iPixelType != PFD_TYPE_RGBA) return NULL; // other formats are not supported yet
supportedSurfaces = 0;
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_DRAW_TO_WINDOW_ARB,&window));
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_DRAW_TO_BITMAP_ARB,&bitmap));
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_DRAW_TO_PBUFFER_ARB,&pbuffer));
if(window) supportedSurfaces |= EGL_WINDOW_BIT;
if(bitmap) supportedSurfaces |= EGL_PIXMAP_BIT;
if(pbuffer) supportedSurfaces |= EGL_PBUFFER_BIT;
//default values
visualId = 0;
visualType = EGL_NONE;
caveat = EGL_NONE;
pMaxWidth = PBUFFER_MAX_WIDTH;
pMaxHeight = PBUFFER_MAX_HEIGHT;
pMaxPixels = PBUFFER_MAX_PIXELS;
samples = 0 ;
level = 0 ;
renderable = EGL_FALSE;
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_TRANSPARENT_ARB,&transparent));
if(transparent) {
transparentType = EGL_TRANSPARENT_RGB;
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_TRANSPARENT_RED_VALUE_ARB,&tRed));
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_TRANSPARENT_GREEN_VALUE_ARB,&tGreen));
IS_TRUE(wglGetPixelFormatAttribivARB(dpy,index,0,1,WGL_TRANSPARENT_BLUE_VALUE_ARB,&tBlue));
} else {
transparentType = EGL_NONE;
}
return new EglConfig(frmt->cRedBits,frmt->cGreenBits,frmt->cBlueBits,frmt->cAlphaBits,caveat,
index,frmt->cDepthBits,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,
visualId,visualType,samples,frmt->cStencilBits,supportedSurfaces,transparentType,tRed,tGreen,tBlue,frmt);
}
void queryConfigs(EGLNativeDisplayType dpy,ConfigList& listOut) {
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat = 1;
//quering num of formats
nFormats = DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
EglConfig* p = pixelFormatToConfig(dpy,&pfd,iPixelFormat);
//inserting first format
if(p) listOut.push_front(p);
//inserting rest of formats
for(iPixelFormat++;iPixelFormat < nFormats; iPixelFormat++) {
DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
EglConfig* pConfig = pixelFormatToConfig(dpy,&pfd,iPixelFormat);
if(pConfig) listOut.push_front(pConfig);
}
}
bool validNativeWin(EGLNativeWindowType win) {
return IsWindow(win);
}
bool validNativePixmap(EGLNativePixmapType pix) {
BITMAP bm;
return GetObject(pix, sizeof(BITMAP), (LPSTR)&bm);
}
static bool setPixelFormat(EGLNativeDisplayType dpy,EglConfig* cfg) {
int iPixelFormat = ChoosePixelFormat(dpy,cfg->nativeConfig());
if(!iPixelFormat) return false;
if(!SetPixelFormat(dpy,iPixelFormat,cfg->nativeConfig())) return false;
return true;
}
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
RECT r;
if(!GetClientRect(win,&r)) return false;
*width = r.right - r.left;
*height = r.bottom - r.top;
return setPixelFormat(dpy,cfg);
}
bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg) {
BITMAP bm;
if(!GetObject(pix, sizeof(BITMAP), (LPSTR)&bm)) return false;
*width = bm.bmWidth;
*height = bm.bmHeight;
return setPixelFormat(dpy,cfg);
}
EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbSurface* pbSurface) {
//converting configuration into WGL pixel Format
EGLint red,green,blue,alpha,depth,stencil;
bool gotAttribs = getConfAttrib(EGL_RED_SIZE,&red) &&
getConfAttrib(EGL_GREEN_SIZE,&green) &&
getConfAttrib(EGL_BLUE_SIZE,&blue) &&
getConfAttrib(EGL_ALPHA_SIZE,&alpha) &&
getConfAttrib(EGL_DEPTH_SIZE,&depth) &&
getConfAttrib(EGL_STENCIL_SIZE,&stencil) ;
if(!gotAttribs) return false;
int wglPixelFormatAttribs[] = {
WGL_SUPPORT_OPENGL_ARB ,TRUE,
WGL_DRAW_TO_BUFFER_ARB ,TRUE,
WGL_BIND_TO_TEXTURE_RGBA_ARB ,TRUE,
WGL_COLOR_BITS_ARB ,red+green+blue,
WGL_RED_BITS_ARB ,red,
WGL_GREEN_BITS_ARB ,green,
WGL_BLUE_BITS_ARB ,blue,
WGL_ALPHA_BITS_ARB ,alpha,
WGL_STENCIL_BITS_ARB ,stencil,
WGL_DEPTH_BITS_ARB ,depth,
WGL_DOUBLE_BUFFER_ARB ,TRUE,
0
};
int pixfmt;
unsigned int numpf;
if(!wglChoosePixelFormatARB(dpy,wglPixelFormatAttribs, NULL, 1, &pixfmt, &numpf)) {
DWORD err = GetLastError();
return NULL;
}
EGLint width,height,largest,texTarget,texFormat;
pbSurface->getDim(&width,&height,&largest);
pbSurface->getTexInfo(&texTarget,&texFormat);
int wglTexFormat = WGL_NO_TEXTURE_ARB;
int wglTexTarget = (texTarget == EGL_TEXTURE_2D)? WGL_TEXTURE_2D_ARB:
WGL_NO_TEXTURE_ARB;
switch(texFormat) {
case EGL_TEXTURE_RGB:
wglTexFormat = WGL_TEXTURE_RGB_ARB;
break;
case EGL_TEXTURE_RGBA:
wglTexFormat = WGL_TEXTURE_RGB_ARBA;
break;
}
int pbAttribs[] = {
WGL_TEXTURE_TARGET_ARB ,wglTexTarget,
WGL_TEXTURE_FORMAT_ARB ,wglTexFormat,
WGL_TEXTURE_LARGEST_ARB ,largest,
0
};
EGLNativePbufferType pb = wglCreatePbufferARB(dpy,pixfmt,width,height,pbAttribs);
if(!pb) {
DWORD err = GetLastError();
return NULL;
}
return pb;
}
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) {
if(wglReleasePbufferDCARB(pb,dis) || wglDestroyPbufferArb(pb)){
DWORD err = GetLastError();
return false;
}
return true;
}
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
EGLNativeContextType ctx = NULL;
if(!setPixelFormat(dpy,cfg)) return NULL;
ctx = wglCreateContext(dpy);
if(ctx && sharedContext) {
if(!wglShareLists(sharedContext,ctx)) {
wglDeleteContext(ctx);
return NULL;
}
}
return ctx;
}
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) {
if(!wglDeleteContext(ctx)) {
DWORD err = GetLastError();
return false;
}
return true;
}
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx) {
return ctx ? :wglMakeCurrent(dpy,NULL): wglMakeContextCurrentARB(dpy,draw->native(),read->native());
}
void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
if(!SwapBuffers(dpy)) {
DWORD err = GetLastError();
}
}
void waitNative(){}
void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval) {
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
if (WGLExtensionSupported("WGL_EXT_swap_control"))
{
// Extension is supported, init pointers.
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) LogGetProcAddress("wglSwapIntervalEXT");
}
wglSwapIntervalEXT(interval);
}
};

View File

@@ -0,0 +1,216 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "EglOsApi.h"
#include <string.h>
#include <GL/glx.h>
#define IS_SUCCESS(a) \
if(a != Success) return false;
namespace EglOS {
EGLNativeDisplayType getDefaultDisplay() {return XOpenDisplay(0);}
bool releaseDisplay(EGLNativeDisplayType dpy) {
return XCloseDisplay(dpy);
}
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt){
int bSize,red,green,blue,alpha,depth,stencil;
int supportedSurfaces,visualType,visualId;
int caveat,transparentType,samples;
int tRed,tGreen,tBlue;
int pMaxWidth,pMaxHeight,pMaxPixels;
int tmp;
int configId,level,renderable;
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_TYPE,&tmp));
if(tmp == GLX_TRANSPARENT_INDEX) {
return NULL; // not supporting transparent index
} else if( tmp == GLX_NONE) {
transparentType = EGL_NONE;
} else {
transparentType = EGL_TRANSPARENT_RGB;
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_RED_VALUE,&tRed));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_GREEN_VALUE,&tGreen));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_TRANSPARENT_BLUE_VALUE,&tBlue));
}
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_BUFFER_SIZE,&bSize));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_RED_SIZE,&red));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_GREEN_SIZE,&green));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_BLUE_SIZE,&blue));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_ALPHA_SIZE,&alpha));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_DEPTH_SIZE,&depth));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_STENCIL_SIZE,&stencil));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_X_RENDERABLE,&renderable));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_X_VISUAL_TYPE,&visualType));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_VISUAL_ID,&visualId));
//supported surfaces types
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_DRAWABLE_TYPE,&tmp));
supportedSurfaces = 0;
if(tmp & GLX_WINDOW_BIT) {
supportedSurfaces |= EGL_WINDOW_BIT;
} else {
visualId = 0;
visualType = EGL_NONE;
}
if(tmp & GLX_PIXMAP_BIT) supportedSurfaces |= EGL_PIXMAP_BIT;
if(tmp & GLX_PBUFFER_BIT) supportedSurfaces |= EGL_PBUFFER_BIT;
caveat = 0;
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_CONFIG_CAVEAT,&tmp));
if (tmp == GLX_NONE) caveat = EGL_NONE;
else if(tmp == GLX_SLOW_CONFIG) caveat = EGL_SLOW_CONFIG;
else if(tmp == GLX_NON_CONFORMANT_CONFIG) caveat = EGL_NON_CONFORMANT_CONFIG;
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_MAX_PBUFFER_WIDTH,&pMaxWidth));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_MAX_PBUFFER_HEIGHT,&pMaxHeight));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_MAX_PBUFFER_HEIGHT,&pMaxPixels));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_LEVEL,&level));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_FBCONFIG_ID,&configId));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,*frmt,GLX_SAMPLES,&samples));
return new EglConfig(red,green,blue,alpha,caveat,configId,depth,level,pMaxWidth,pMaxHeight,
pMaxPixels,renderable,visualId,visualType,samples,stencil,
supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
}
void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut) {
int n;
EGLNativePixelFormatType* frmtList = glXGetFBConfigs(dpy,0,&n);
for(int i =0 ;i < n ; i++) {
EglConfig* conf = pixelFormatToConfig(dpy,&frmtList[i]);
if(conf) listOut.push_back(conf);
}
listOut.sort();
XFree(frmtList);
}
bool validNativeWin(EGLNativeWindowType win) {
//TODO: use XGetgeometry to check validity
return true;
}
bool validNativePixmap(EGLNativePixmapType pix) {
//TODO: use XGetgeometry to check validity
return true;
}
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
//TODO: to check what does ATI & NVIDIA enforce on win pixelformat
unsigned int depth,configDepth,border;
int r,g,b,x,y;
IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_RED_SIZE,&r));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_GREEN_SIZE,&g));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_BLUE_SIZE,&b));
configDepth = r + g + b;
Window root;
if(!XGetGeometry(dpy,win,&root,&x,&y,width,height,&border,&depth)) return false;
return depth >= configDepth;
}
bool checkPixmapPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativePixmapType pix,EglConfig* cfg,unsigned int* width,unsigned int* height) {
unsigned int depth,configDepth,border;
int r,g,b,x,y;
IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_RED_SIZE,&r));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_GREEN_SIZE,&g));
IS_SUCCESS(glXGetFBConfigAttrib(dpy,cfg->nativeConfig(),GLX_BLUE_SIZE,&b));
configDepth = r + g + b;
Window root;
if(!XGetGeometry(dpy,pix,&root,&x,&y,width,height,&border,&depth)) return false;
return depth >= configDepth;
}
EGLNativePbufferType createPbuffer(EGLNativeDisplayType dpy,EglConfig* cfg,EglPbufferSurface* srfc){
EGLint width,height,largest;
srfc->getDim(&width,&height,&largest);
int attribs[] = {
GLX_PBUFFER_WIDTH ,width,
GLX_PBUFFER_HEIGHT ,height,
GLX_LARGEST_PBUFFER ,largest,
None
};
return glXCreatePbuffer(dpy,cfg->nativeConfig(),attribs);
}
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb) {
glXDestroyPbuffer(dis,pb);
return true;
}
EGLNativeContextType createContext(EGLNativeDisplayType dpy,EglConfig* cfg,EGLNativeContextType sharedContext) {
return glXCreateNewContext(dpy,cfg->nativeConfig(),GLX_RGBA_TYPE,sharedContext,true);
}
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) {
glXDestroyContext(dpy,ctx);
return true;
}
GLXDrawable convertSurface(EglSurface* srfc) {
if(!srfc) return None;
switch(srfc->type()){
case EglSurface::PIXMAP:
return (GLXPixmap)srfc->native();
case EglSurface::PBUFFER:
return (GLXPbuffer)srfc->native();
case EglSurface::WINDOW:
default:
return (GLXWindow)srfc->native();
}
}
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){
return glXMakeContextCurrent(dpy,convertSurface(draw),convertSurface(read),ctx);
}
void swapBuffers(EGLNativeDisplayType dpy,EGLNativeWindowType win) {
glXSwapBuffers(dpy,win);
}
void waitNative() {
glXWaitX();
}
void swapInterval(EGLNativeDisplayType dpy,EGLNativeWindowType win,int interval){
const char* extensions = glXQueryExtensionsString(dpy,DefaultScreen(dpy));
typedef void (*GLXSWAPINTERVALEXT)(Display*,GLXDrawable,int);
GLXSWAPINTERVALEXT glXSwapIntervalEXT = NULL;
if(strstr(extensions,"EXT_swap_control")) {
glXSwapIntervalEXT = (GLXSWAPINTERVALEXT)glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT");
}
if(glXSwapIntervalEXT) {
glXSwapIntervalEXT(dpy,win,interval);
}
}
};

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <GLcommon/ThreadInfo.h>
__thread ThreadInfo* thread = NULL;
void ThreadInfo::updateInfo(void* eglCtx,void* dpy,void* glesCtx,ShareGroupPtr share,ObjectNameManager* manager) {
eglContext = eglCtx;
eglDisplay = dpy;
glesContext = glesCtx;
shareGroup = share;
objManager = manager;
}
#ifdef __linux__
ThreadInfo* getThreadInfo(){
if(!thread) {
thread = new ThreadInfo();
}
return thread;
}
#else
#include <cutils/threads.h>
static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
static void tlsDestruct(void *ptr)
{
if (ptr) {
ThreadInfo *ti = (ThreadInfo *)ptr;
delete ti;
}
}
RenderThreadInfo *getRenderThreadInfo()
{
ThreadInfo *ti = (ThreadInfo *)thread_store_get(&s_tls);
if (!ti) {
ti = new RenderThreadInfo();
thread_store_set(&s_tls, ti, tlsDestruct);
}
return ti;
}
#endif

View File

@@ -0,0 +1,329 @@
/* -*- mode: c; tab-width: 8; -*- */
/* vi: set sw=4 ts=8: */
/* Reference version of egl.h for EGL 1.4.
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
*/
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#ifndef __egl_h_
#define __egl_h_
/* All platform-dependent types and macro boilerplate (such as EGLAPI
* and EGLAPIENTRY) should go in eglplatform.h.
*/
#include <EGL/eglplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/* EGL Types */
/* EGLint is defined in eglplatform.h */
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLClientBuffer;
/* EGL Versioning */
#define EGL_VERSION_1_0 1
#define EGL_VERSION_1_1 1
#define EGL_VERSION_1_2 1
#define EGL_VERSION_1_3 1
#define EGL_VERSION_1_4 1
/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
* enums are assigned unique values starting at 0x3000.
*/
/* EGL aliases */
#define EGL_FALSE 0
#define EGL_TRUE 1
/* Out-of-band handle values */
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
#define EGL_NO_CONTEXT ((EGLContext)0)
#define EGL_NO_DISPLAY ((EGLDisplay)0)
#define EGL_NO_SURFACE ((EGLSurface)0)
/* Out-of-band attribute value */
#define EGL_DONT_CARE ((EGLint)-1)
/* Errors / GetError return values */
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
#define EGL_BAD_ALLOC 0x3003
#define EGL_BAD_ATTRIBUTE 0x3004
#define EGL_BAD_CONFIG 0x3005
#define EGL_BAD_CONTEXT 0x3006
#define EGL_BAD_CURRENT_SURFACE 0x3007
#define EGL_BAD_DISPLAY 0x3008
#define EGL_BAD_MATCH 0x3009
#define EGL_BAD_NATIVE_PIXMAP 0x300A
#define EGL_BAD_NATIVE_WINDOW 0x300B
#define EGL_BAD_PARAMETER 0x300C
#define EGL_BAD_SURFACE 0x300D
#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */
/* Reserved 0x300F-0x301F for additional errors */
/* Config attributes */
#define EGL_BUFFER_SIZE 0x3020
#define EGL_ALPHA_SIZE 0x3021
#define EGL_BLUE_SIZE 0x3022
#define EGL_GREEN_SIZE 0x3023
#define EGL_RED_SIZE 0x3024
#define EGL_DEPTH_SIZE 0x3025
#define EGL_STENCIL_SIZE 0x3026
#define EGL_CONFIG_CAVEAT 0x3027
#define EGL_CONFIG_ID 0x3028
#define EGL_LEVEL 0x3029
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
#define EGL_MAX_PBUFFER_PIXELS 0x302B
#define EGL_MAX_PBUFFER_WIDTH 0x302C
#define EGL_NATIVE_RENDERABLE 0x302D
#define EGL_NATIVE_VISUAL_ID 0x302E
#define EGL_NATIVE_VISUAL_TYPE 0x302F
#define EGL_SAMPLES 0x3031
#define EGL_SAMPLE_BUFFERS 0x3032
#define EGL_SURFACE_TYPE 0x3033
#define EGL_TRANSPARENT_TYPE 0x3034
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
#define EGL_TRANSPARENT_RED_VALUE 0x3037
#define EGL_NONE 0x3038 /* Attrib list terminator */
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
#define EGL_MIN_SWAP_INTERVAL 0x303B
#define EGL_MAX_SWAP_INTERVAL 0x303C
#define EGL_LUMINANCE_SIZE 0x303D
#define EGL_ALPHA_MASK_SIZE 0x303E
#define EGL_COLOR_BUFFER_TYPE 0x303F
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */
#define EGL_CONFORMANT 0x3042
/* Reserved 0x3041-0x304F for additional config attributes */
/* Config attribute values */
#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */
#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */
#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */
/* More config attribute values, for EGL_TEXTURE_FORMAT */
#define EGL_NO_TEXTURE 0x305C
#define EGL_TEXTURE_RGB 0x305D
#define EGL_TEXTURE_RGBA 0x305E
#define EGL_TEXTURE_2D 0x305F
/* Config attribute mask bits */
#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */
#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */
#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */
/* QueryString targets */
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_EXTENSIONS 0x3055
#define EGL_CLIENT_APIS 0x308D
/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
#define EGL_HEIGHT 0x3056
#define EGL_WIDTH 0x3057
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_TEXTURE_FORMAT 0x3080
#define EGL_TEXTURE_TARGET 0x3081
#define EGL_MIPMAP_TEXTURE 0x3082
#define EGL_MIPMAP_LEVEL 0x3083
#define EGL_RENDER_BUFFER 0x3086
#define EGL_VG_COLORSPACE 0x3087
#define EGL_VG_ALPHA_FORMAT 0x3088
#define EGL_HORIZONTAL_RESOLUTION 0x3090
#define EGL_VERTICAL_RESOLUTION 0x3091
#define EGL_PIXEL_ASPECT_RATIO 0x3092
#define EGL_SWAP_BEHAVIOR 0x3093
#define EGL_MULTISAMPLE_RESOLVE 0x3099
/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
#define EGL_BACK_BUFFER 0x3084
#define EGL_SINGLE_BUFFER 0x3085
/* OpenVG color spaces */
#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */
#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */
/* OpenVG alpha formats */
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */
/* Constant scale factor by which fractional display resolutions &
* aspect ratio are scaled when queried as integer values.
*/
#define EGL_DISPLAY_SCALING 10000
/* Unknown display resolution/aspect ratio */
#define EGL_UNKNOWN ((EGLint)-1)
/* Back buffer swap behaviors */
#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */
/* CreatePbufferFromClientBuffer buffer types */
#define EGL_OPENVG_IMAGE 0x3096
/* QueryContext targets */
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
/* CreateContext attributes */
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
/* Multisample resolution behaviors */
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */
/* BindAPI/QueryAPI targets */
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
/* GetCurrentSurface targets */
#define EGL_DRAW 0x3059
#define EGL_READ 0x305A
/* WaitNative engines */
#define EGL_CORE_NATIVE_ENGINE 0x305B
/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
#define EGL_COLORSPACE EGL_VG_COLORSPACE
#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT
#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB
#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR
#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE
#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE
/* EGL extensions must request enum blocks from the Khronos
* API Registrar, who maintains the enumerant registry. Submit
* a bug in Khronos Bugzilla against task "Registry".
*/
/* EGL Functions */
EGLAPI EGLint EGLAPIENTRY eglGetError(void);
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLConfig *configs, EGLint config_size,
EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value);
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
EGLNativePixmapType target);
/* This is a generic function pointer type, whose name indicates it must
* be cast to the proper type *and calling convention* before use.
*/
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
/* Now, define eglGetProcAddress using the generic function ptr. type */
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname);
#ifdef __cplusplus
}
#endif
#endif /* __egl_h_ */

View File

@@ -0,0 +1,244 @@
#ifndef __eglext_h_
#define __eglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2010 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#include <EGL/eglplatform.h>
/*************************************************************/
/* Header file version number */
/* Current version at http://www.khronos.org/registry/egl/ */
/* $Revision: 11249 $ on $Date: 2010-05-05 09:54:28 -0700 (Wed, 05 May 2010) $ */
#define EGL_EGLEXT_VERSION 5
#ifndef EGL_KHR_config_attribs
#define EGL_KHR_config_attribs 1
#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */
#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */
#endif
#ifndef EGL_KHR_lock_surface
#define EGL_KHR_lock_surface 1
#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */
#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */
#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */
#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */
#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */
#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */
#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */
#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */
#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */
#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
#endif
#ifndef EGL_KHR_image
#define EGL_KHR_image 1
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
typedef void *EGLImageKHR;
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
#endif
#ifndef EGL_KHR_vg_parent_image
#define EGL_KHR_vg_parent_image 1
#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_gl_texture_2D_image
#define EGL_KHR_gl_texture_2D_image 1
#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_gl_texture_cubemap_image
#define EGL_KHR_gl_texture_cubemap_image 1
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_gl_texture_3D_image
#define EGL_KHR_gl_texture_3D_image 1
#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_gl_renderbuffer_image
#define EGL_KHR_gl_renderbuffer_image 1
#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_reusable_sync
#define EGL_KHR_reusable_sync 1
typedef void* EGLSyncKHR;
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
#define EGL_SYNC_STATUS_KHR 0x30F1
#define EGL_SIGNALED_KHR 0x30F2
#define EGL_UNSIGNALED_KHR 0x30F3
#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
#define EGL_CONDITION_SATISFIED_KHR 0x30F6
#define EGL_SYNC_TYPE_KHR 0x30F7
#define EGL_SYNC_REUSABLE_KHR 0x30FA
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */
#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif
#ifndef EGL_KHR_image_base
#define EGL_KHR_image_base 1
/* Most interfaces defined by EGL_KHR_image_pixmap above */
#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_image_pixmap
#define EGL_KHR_image_pixmap 1
/* Interfaces defined by EGL_KHR_image above */
#endif
#ifndef EGL_IMG_context_priority
#define EGL_IMG_context_priority 1
#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif
#ifndef EGL_NV_coverage_sample
#define EGL_NV_coverage_sample 1
#define EGL_COVERAGE_BUFFERS_NV 0x30E0
#define EGL_COVERAGE_SAMPLES_NV 0x30E1
#endif
#ifndef EGL_NV_depth_nonlinear
#define EGL_NV_depth_nonlinear 1
#define EGL_DEPTH_ENCODING_NV 0x30E2
#define EGL_DEPTH_ENCODING_NONE_NV 0
#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
#endif
#ifndef EGL_NV_sync
#define EGL_NV_sync 1
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6
#define EGL_SYNC_STATUS_NV 0x30E7
#define EGL_SIGNALED_NV 0x30E8
#define EGL_UNSIGNALED_NV 0x30E9
#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001
#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull
#define EGL_ALREADY_SIGNALED_NV 0x30EA
#define EGL_TIMEOUT_EXPIRED_NV 0x30EB
#define EGL_CONDITION_SATISFIED_NV 0x30EC
#define EGL_SYNC_TYPE_NV 0x30ED
#define EGL_SYNC_CONDITION_NV 0x30EE
#define EGL_SYNC_FENCE_NV 0x30EF
#define EGL_NO_SYNC_NV ((EGLSyncNV)0)
typedef void* EGLSyncNV;
typedef unsigned long long EGLTimeNV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
EGLBoolean eglDestroySyncNV (EGLSyncNV sync);
EGLBoolean eglFenceNV (EGLSyncNV sync);
EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif
#ifndef EGL_KHR_fence_sync
#define EGL_KHR_fence_sync 1
/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
#define EGL_SYNC_CONDITION_KHR 0x30F8
#define EGL_SYNC_FENCE_KHR 0x30F9
#endif
#ifndef EGL_ANDROID_image_native_buffer
#define EGL_ANDROID_image_native_buffer 1
struct android_native_buffer_t;
#define EGL_NATIVE_BUFFER_ANDROID 0x3140 /* eglCreateImageKHR target */
#endif
#ifndef EGL_ANDROID_swap_rectangle
#define EGL_ANDROID_swap_rectangle 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,109 @@
#ifndef __eglplatform_h_
#define __eglplatform_h_
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "EGL" component "Registry".
*/
#include <KHR/khrplatform.h>
/* Macros used in EGL function prototype declarations.
*
* EGL functions should be prototyped as:
*
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
*
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/
#ifndef EGLAPI
#define EGLAPI KHRONOS_APICALL
#endif
#ifndef EGLAPIENTRY
#define EGLAPIENTRY KHRONOS_APIENTRY
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*/
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef PIXELFORMATDESCRIPTOR EGLNativePixelFormatType;
typedef HGLRC EGLNativeContextType;
typedef HPBUFFERARB EGLNativePbufferType;
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#elif defined(__unix__)
/* X11 (tentative) */
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef GLXFBConfig EGLNativePixelFormatType;
typedef GLXContext EGLNativeContextType;
typedef GLXPbuffer EGLNativePbufferType;
typedef Display * EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#else
#error "Platform not recognized"
#endif
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type.
*/
typedef khronos_int32_t EGLint;
#endif /* __eglplatform_h */