Commit 31ecbd70 by Geoff Lang

Refactor eglQuerySurface and eglSurfaceAttrib.

BUG=angleproject:2075 Change-Id: I6911a2a1e665237e1d262c06f3ccf2d84cc09669 Reviewed-on: https://chromium-review.googlesource.com/586860Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 5505bdc7
......@@ -19,6 +19,7 @@
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Sampler.h"
#include "libANGLE/Shader.h"
#include "libANGLE/Surface.h"
#include "libANGLE/Texture.h"
#include "libANGLE/Uniform.h"
#include "libANGLE/VertexAttribute.h"
......@@ -1245,4 +1246,99 @@ void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value)
}
}
void QuerySurfaceAttrib(const Surface *surface, EGLint attribute, EGLint *value)
{
switch (attribute)
{
case EGL_GL_COLORSPACE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_VG_ALPHA_FORMAT:
UNIMPLEMENTED(); // FIXME
break;
case EGL_VG_COLORSPACE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_CONFIG_ID:
*value = surface->getConfig()->configID;
break;
case EGL_HEIGHT:
*value = surface->getHeight();
break;
case EGL_HORIZONTAL_RESOLUTION:
UNIMPLEMENTED(); // FIXME
break;
case EGL_LARGEST_PBUFFER:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MIPMAP_TEXTURE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MIPMAP_LEVEL:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MULTISAMPLE_RESOLVE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_PIXEL_ASPECT_RATIO:
*value = surface->getPixelAspectRatio();
break;
case EGL_RENDER_BUFFER:
*value = surface->getRenderBuffer();
break;
case EGL_SWAP_BEHAVIOR:
*value = surface->getSwapBehavior();
break;
case EGL_TEXTURE_FORMAT:
*value = surface->getTextureFormat();
break;
case EGL_TEXTURE_TARGET:
*value = surface->getTextureTarget();
break;
case EGL_VERTICAL_RESOLUTION:
UNIMPLEMENTED(); // FIXME
break;
case EGL_WIDTH:
*value = surface->getWidth();
break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
*value = surface->isPostSubBufferSupported();
break;
case EGL_FIXED_SIZE_ANGLE:
*value = surface->isFixedSize();
break;
case EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE:
*value = surface->flexibleSurfaceCompatibilityRequested();
break;
case EGL_SURFACE_ORIENTATION_ANGLE:
*value = surface->getOrientation();
break;
case EGL_DIRECT_COMPOSITION_ANGLE:
*value = surface->directComposition();
break;
default:
UNREACHABLE();
break;
}
}
void SetSurfaceAttrib(Surface *surface, EGLint attribute, EGLint value)
{
switch (attribute)
{
case EGL_MIPMAP_LEVEL:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MULTISAMPLE_RESOLVE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_SWAP_BEHAVIOR:
UNIMPLEMENTED(); // FIXME
break;
default:
UNREACHABLE();
break;
}
}
} // namespace egl
......@@ -137,9 +137,13 @@ GLint QueryProgramResourceLocation(const Program *program,
namespace egl
{
struct Config;
class Surface;
void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value);
void QuerySurfaceAttrib(const Surface *surface, EGLint attribute, EGLint *value);
void SetSurfaceAttrib(Surface *surface, EGLint attribute, EGLint value);
} // namespace egl
#endif // LIBANGLE_QUERYUTILS_H_
......@@ -2285,4 +2285,149 @@ Error ValidateProgramCacheResizeANGLE(const Display *display, EGLint limit, EGLe
return NoError();
}
Error ValidateSurfaceAttrib(const Display *display,
const Surface *surface,
EGLint attribute,
EGLint value)
{
ANGLE_TRY(ValidateDisplay(display));
ANGLE_TRY(ValidateSurface(display, surface));
if (surface == EGL_NO_SURFACE)
{
return EglBadSurface() << "Surface cannot be EGL_NO_SURFACE.";
}
switch (attribute)
{
case EGL_MIPMAP_LEVEL:
break;
case EGL_MULTISAMPLE_RESOLVE:
switch (value)
{
case EGL_MULTISAMPLE_RESOLVE_DEFAULT:
break;
case EGL_MULTISAMPLE_RESOLVE_BOX:
if ((surface->getConfig()->surfaceType & EGL_MULTISAMPLE_RESOLVE_BOX_BIT) == 0)
{
return EglBadMatch()
<< "Surface does not support EGL_MULTISAMPLE_RESOLVE_BOX.";
}
break;
default:
return EglBadAttribute() << "Invalid multisample resolve type.";
}
case EGL_SWAP_BEHAVIOR:
switch (value)
{
case EGL_BUFFER_PRESERVED:
if ((surface->getConfig()->surfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT) == 0)
{
return EglBadMatch()
<< "Surface does not support EGL_SWAP_BEHAVIOR_PRESERVED.";
}
break;
case EGL_BUFFER_DESTROYED:
break;
default:
return EglBadAttribute() << "Invalid swap behaviour.";
}
default:
return EglBadAttribute() << "Invalid surface attribute.";
}
return NoError();
}
Error ValidateQuerySurface(const Display *display,
const Surface *surface,
EGLint attribute,
EGLint *value)
{
ANGLE_TRY(ValidateDisplay(display));
ANGLE_TRY(ValidateSurface(display, surface));
if (surface == EGL_NO_SURFACE)
{
return EglBadSurface() << "Surface cannot be EGL_NO_SURFACE.";
}
switch (attribute)
{
case EGL_GL_COLORSPACE:
case EGL_VG_ALPHA_FORMAT:
case EGL_VG_COLORSPACE:
case EGL_CONFIG_ID:
case EGL_HEIGHT:
case EGL_HORIZONTAL_RESOLUTION:
case EGL_LARGEST_PBUFFER:
case EGL_MIPMAP_TEXTURE:
case EGL_MIPMAP_LEVEL:
case EGL_MULTISAMPLE_RESOLVE:
case EGL_PIXEL_ASPECT_RATIO:
case EGL_RENDER_BUFFER:
case EGL_SWAP_BEHAVIOR:
case EGL_TEXTURE_FORMAT:
case EGL_TEXTURE_TARGET:
case EGL_VERTICAL_RESOLUTION:
case EGL_WIDTH:
break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
if (!display->getExtensions().postSubBuffer)
{
return EglBadAttribute() << "EGL_POST_SUB_BUFFER_SUPPORTED_NV cannot be used "
"without EGL_ANGLE_surface_orientation support.";
}
break;
case EGL_FIXED_SIZE_ANGLE:
if (!display->getExtensions().windowFixedSize)
{
return EglBadAttribute() << "EGL_FIXED_SIZE_ANGLE cannot be used without "
"EGL_ANGLE_window_fixed_size support.";
}
break;
case EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE:
if (!display->getExtensions().flexibleSurfaceCompatibility)
{
return EglBadAttribute()
<< "EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE cannot be "
"used without EGL_ANGLE_flexible_surface_compatibility support.";
}
break;
case EGL_SURFACE_ORIENTATION_ANGLE:
if (!display->getExtensions().surfaceOrientation)
{
return EglBadAttribute() << "EGL_SURFACE_ORIENTATION_ANGLE cannot be "
"queried without "
"EGL_ANGLE_surface_orientation support.";
}
break;
case EGL_DIRECT_COMPOSITION_ANGLE:
if (!display->getExtensions().directComposition)
{
return EglBadAttribute() << "EGL_DIRECT_COMPOSITION_ANGLE cannot be "
"used without "
"EGL_ANGLE_direct_composition support.";
}
break;
default:
return EglBadAttribute() << "Invalid surface attribute.";
}
return NoError();
}
} // namespace egl
......@@ -147,6 +147,15 @@ Error ValidateProgramCachePopulateANGLE(const Display *display,
Error ValidateProgramCacheResizeANGLE(const Display *display, EGLint limit, EGLenum mode);
Error ValidateSurfaceAttrib(const Display *display,
const Surface *surface,
EGLint attribute,
EGLint value);
Error ValidateQuerySurface(const Display *display,
const Surface *surface,
EGLint attribute,
EGLint *value);
} // namespace egl
#define ANGLE_EGL_TRY(THREAD, EXPR) \
......
......@@ -393,123 +393,17 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy,
dpy, surface, attribute, value);
Thread *thread = GetCurrentThread();
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = (Surface *)surface;
const Display *display = static_cast<const Display *>(dpy);
const Surface *eglSurface = static_cast<const Surface *>(surface);
Error error = ValidateSurface(display, eglSurface);
Error error = ValidateQuerySurface(display, eglSurface, attribute, value);
if (error.isError())
{
thread->setError(error);
return EGL_FALSE;
}
if (surface == EGL_NO_SURFACE)
{
thread->setError(EglBadSurface());
return EGL_FALSE;
}
switch (attribute)
{
case EGL_VG_ALPHA_FORMAT:
UNIMPLEMENTED(); // FIXME
break;
case EGL_VG_COLORSPACE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_CONFIG_ID:
*value = eglSurface->getConfig()->configID;
break;
case EGL_HEIGHT:
*value = eglSurface->getHeight();
break;
case EGL_HORIZONTAL_RESOLUTION:
UNIMPLEMENTED(); // FIXME
break;
case EGL_LARGEST_PBUFFER:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MIPMAP_TEXTURE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MIPMAP_LEVEL:
UNIMPLEMENTED(); // FIXME
break;
case EGL_MULTISAMPLE_RESOLVE:
UNIMPLEMENTED(); // FIXME
break;
case EGL_PIXEL_ASPECT_RATIO:
*value = eglSurface->getPixelAspectRatio();
break;
case EGL_RENDER_BUFFER:
*value = eglSurface->getRenderBuffer();
break;
case EGL_SWAP_BEHAVIOR:
*value = eglSurface->getSwapBehavior();
break;
case EGL_TEXTURE_FORMAT:
*value = eglSurface->getTextureFormat();
break;
case EGL_TEXTURE_TARGET:
*value = eglSurface->getTextureTarget();
break;
case EGL_VERTICAL_RESOLUTION:
UNIMPLEMENTED(); // FIXME
break;
case EGL_WIDTH:
*value = eglSurface->getWidth();
break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
if (!display->getExtensions().postSubBuffer)
{
thread->setError(EglBadAttribute());
return EGL_FALSE;
}
*value = eglSurface->isPostSubBufferSupported();
break;
case EGL_FIXED_SIZE_ANGLE:
if (!display->getExtensions().windowFixedSize)
{
thread->setError(EglBadAttribute());
return EGL_FALSE;
}
*value = eglSurface->isFixedSize();
break;
case EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE:
if (!display->getExtensions().flexibleSurfaceCompatibility)
{
thread->setError(
EglBadAttribute()
<< "EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE cannot be "
"used without EGL_ANGLE_flexible_surface_compatibility support.");
return EGL_FALSE;
}
*value = eglSurface->flexibleSurfaceCompatibilityRequested();
break;
case EGL_SURFACE_ORIENTATION_ANGLE:
if (!display->getExtensions().surfaceOrientation)
{
thread->setError(EglBadAttribute() << "EGL_SURFACE_ORIENTATION_ANGLE cannot be "
"queried without "
"EGL_ANGLE_surface_orientation support.");
return EGL_FALSE;
}
*value = eglSurface->getOrientation();
break;
case EGL_DIRECT_COMPOSITION_ANGLE:
if (!display->getExtensions().directComposition)
{
thread->setError(EglBadAttribute() << "EGL_DIRECT_COMPOSITION_ANGLE cannot be "
"used without "
"EGL_ANGLE_direct_composition support.");
return EGL_FALSE;
}
*value = eglSurface->directComposition();
break;
default:
thread->setError(EglBadAttribute());
return EGL_FALSE;
}
QuerySurfaceAttrib(eglSurface, attribute, value);
thread->setError(NoError());
return EGL_TRUE;
......@@ -920,14 +814,14 @@ EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy,
Display *display = static_cast<Display *>(dpy);
Surface *eglSurface = static_cast<Surface *>(surface);
Error error = ValidateSurface(display, eglSurface);
Error error = ValidateSurfaceAttrib(display, eglSurface, attribute, value);
if (error.isError())
{
thread->setError(error);
return EGL_FALSE;
}
UNIMPLEMENTED(); // FIXME
SetSurfaceAttrib(eglSurface, attribute, value);
thread->setError(NoError());
return EGL_TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment