am e7661212: am 4a47a38b: am cd108d55: Merge "emulator opengl: Small change to support more surface attributes"
* commit 'e76612125ce64486fff9e4089537e37a34018f05': emulator opengl: Small change to support more surface attributes
This commit is contained in:
@@ -117,6 +117,7 @@ struct egl_surface_t {
|
|||||||
EGLDisplay dpy;
|
EGLDisplay dpy;
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
|
|
||||||
|
|
||||||
egl_surface_t(EGLDisplay dpy, EGLConfig config);
|
egl_surface_t(EGLDisplay dpy, EGLConfig config);
|
||||||
virtual ~egl_surface_t();
|
virtual ~egl_surface_t();
|
||||||
|
|
||||||
@@ -131,17 +132,39 @@ struct egl_surface_t {
|
|||||||
uint32_t getRcSurface(){ return rcSurface; }
|
uint32_t getRcSurface(){ return rcSurface; }
|
||||||
|
|
||||||
virtual EGLBoolean isValid(){ return valid; }
|
virtual EGLBoolean isValid(){ return valid; }
|
||||||
virtual EGLint getWidth() const = 0;
|
|
||||||
virtual EGLint getHeight() const = 0;
|
void setWidth(EGLint w){ width = w; }
|
||||||
|
EGLint getWidth(){ return width; }
|
||||||
|
void setHeight(EGLint h){ height = h; }
|
||||||
|
EGLint getHeight(){ return height; }
|
||||||
|
void setTextureFormat(EGLint _texFormat){ texFormat = _texFormat; }
|
||||||
|
EGLint getTextureFormat(){ return texFormat; }
|
||||||
|
void setTextureTarget(EGLint _texTarget){ texTarget = _texTarget; }
|
||||||
|
EGLint getTextureTarget(){ return texTarget; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
//Surface attributes
|
||||||
|
//
|
||||||
|
EGLint width;
|
||||||
|
EGLint height;
|
||||||
|
EGLint texFormat;
|
||||||
|
EGLint texTarget;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EGLBoolean valid;
|
EGLBoolean valid;
|
||||||
uint32_t rcSurface; //handle to surface created via remote control
|
uint32_t rcSurface; //handle to surface created via remote control
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
egl_surface_t::egl_surface_t(EGLDisplay dpy, EGLConfig config)
|
egl_surface_t::egl_surface_t(EGLDisplay dpy, EGLConfig config)
|
||||||
: dpy(dpy), config(config), valid(EGL_FALSE), rcSurface(0)
|
: dpy(dpy), config(config), valid(EGL_FALSE), rcSurface(0)
|
||||||
{
|
{
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
texFormat = EGL_NO_TEXTURE;
|
||||||
|
texTarget = EGL_NO_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
egl_surface_t::~egl_surface_t()
|
egl_surface_t::~egl_surface_t()
|
||||||
@@ -166,14 +189,8 @@ struct egl_window_surface_t : public egl_surface_t {
|
|||||||
virtual void disconnect();
|
virtual void disconnect();
|
||||||
virtual EGLBoolean swapBuffers();
|
virtual EGLBoolean swapBuffers();
|
||||||
|
|
||||||
virtual EGLint getWidth() const { return width; }
|
|
||||||
virtual EGLint getHeight() const { return height; }
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ANativeWindow* nativeWindow;
|
ANativeWindow* nativeWindow;
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
android_native_buffer_t* buffer;
|
android_native_buffer_t* buffer;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -188,8 +205,11 @@ egl_window_surface_t::egl_window_surface_t (
|
|||||||
{
|
{
|
||||||
// keep a reference on the window
|
// keep a reference on the window
|
||||||
nativeWindow->common.incRef(&nativeWindow->common);
|
nativeWindow->common.incRef(&nativeWindow->common);
|
||||||
nativeWindow->query(nativeWindow, NATIVE_WINDOW_WIDTH, &width);
|
EGLint w,h;
|
||||||
nativeWindow->query(nativeWindow, NATIVE_WINDOW_HEIGHT, &height);
|
nativeWindow->query(nativeWindow, NATIVE_WINDOW_WIDTH, &w);
|
||||||
|
setWidth(w);
|
||||||
|
nativeWindow->query(nativeWindow, NATIVE_WINDOW_HEIGHT, &h);
|
||||||
|
setHeight(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
egl_window_surface_t::~egl_window_surface_t() {
|
egl_window_surface_t::~egl_window_surface_t() {
|
||||||
@@ -271,13 +291,8 @@ EGLBoolean egl_window_surface_t::swapBuffers()
|
|||||||
|
|
||||||
struct egl_pbuffer_surface_t : public egl_surface_t {
|
struct egl_pbuffer_surface_t : public egl_surface_t {
|
||||||
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
GLenum format;
|
GLenum format;
|
||||||
|
|
||||||
virtual EGLint getWidth() const { return width; }
|
|
||||||
virtual EGLint getHeight() const { return height; }
|
|
||||||
|
|
||||||
egl_pbuffer_surface_t(
|
egl_pbuffer_surface_t(
|
||||||
EGLDisplay dpy, EGLConfig config,
|
EGLDisplay dpy, EGLConfig config,
|
||||||
int32_t w, int32_t h, GLenum format);
|
int32_t w, int32_t h, GLenum format);
|
||||||
@@ -297,9 +312,10 @@ private:
|
|||||||
egl_pbuffer_surface_t::egl_pbuffer_surface_t(
|
egl_pbuffer_surface_t::egl_pbuffer_surface_t(
|
||||||
EGLDisplay dpy, EGLConfig config,
|
EGLDisplay dpy, EGLConfig config,
|
||||||
int32_t w, int32_t h, GLenum pixelFormat)
|
int32_t w, int32_t h, GLenum pixelFormat)
|
||||||
: egl_surface_t(dpy, config),
|
: egl_surface_t(dpy, config), format(pixelFormat)
|
||||||
width(w), height(h), format(pixelFormat)
|
|
||||||
{
|
{
|
||||||
|
setWidth(w);
|
||||||
|
setHeight(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
egl_pbuffer_surface_t::~egl_pbuffer_surface_t()
|
egl_pbuffer_surface_t::~egl_pbuffer_surface_t()
|
||||||
@@ -539,11 +555,31 @@ EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLin
|
|||||||
|
|
||||||
int32_t w = 0;
|
int32_t w = 0;
|
||||||
int32_t h = 0;
|
int32_t h = 0;
|
||||||
|
EGLint texFormat = EGL_NO_TEXTURE;
|
||||||
|
EGLint texTarget = EGL_NO_TEXTURE;
|
||||||
while (attrib_list[0]) {
|
while (attrib_list[0]) {
|
||||||
if (attrib_list[0] == EGL_WIDTH) w = attrib_list[1];
|
switch (attrib_list[0]) {
|
||||||
if (attrib_list[0] == EGL_HEIGHT) h = attrib_list[1];
|
case EGL_WIDTH:
|
||||||
|
w = attrib_list[1];
|
||||||
|
break;
|
||||||
|
case EGL_HEIGHT:
|
||||||
|
h = attrib_list[1];
|
||||||
|
break;
|
||||||
|
case EGL_TEXTURE_FORMAT:
|
||||||
|
texFormat = attrib_list[1];
|
||||||
|
break;
|
||||||
|
case EGL_TEXTURE_TARGET:
|
||||||
|
texTarget = attrib_list[1];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
attrib_list+=2;
|
attrib_list+=2;
|
||||||
}
|
}
|
||||||
|
if (((texFormat == EGL_NO_TEXTURE)&&(texTarget != EGL_NO_TEXTURE)) ||
|
||||||
|
((texFormat != EGL_NO_TEXTURE)&&(texTarget == EGL_NO_TEXTURE))) {
|
||||||
|
return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
|
||||||
|
}
|
||||||
// TODO: check EGL_TEXTURE_FORMAT - need to support eglBindTexImage
|
// TODO: check EGL_TEXTURE_FORMAT - need to support eglBindTexImage
|
||||||
|
|
||||||
GLenum pixelFormat;
|
GLenum pixelFormat;
|
||||||
@@ -558,6 +594,10 @@ EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLin
|
|||||||
return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
|
return setError(EGL_BAD_ALLOC, EGL_NO_SURFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//setup attributes
|
||||||
|
surface->setTextureFormat(texFormat);
|
||||||
|
surface->setTextureTarget(texTarget);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,6 +642,12 @@ EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface eglSurface, EGLint attribu
|
|||||||
case EGL_HEIGHT:
|
case EGL_HEIGHT:
|
||||||
*value = surface->getHeight();
|
*value = surface->getHeight();
|
||||||
break;
|
break;
|
||||||
|
case EGL_TEXTURE_FORMAT:
|
||||||
|
*value = surface->getTextureFormat();
|
||||||
|
break;
|
||||||
|
case EGL_TEXTURE_TARGET:
|
||||||
|
*value = surface->getTextureTarget();
|
||||||
|
break;
|
||||||
//TODO: complete other attributes
|
//TODO: complete other attributes
|
||||||
default:
|
default:
|
||||||
ret = setError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
|
ret = setError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
|
||||||
|
|||||||
Reference in New Issue
Block a user