Commit 6b0cf996 by Geoff Lang

Added an egl::Error class and updated libEGL to use it.

BUG=angle:520 Change-Id: I792c8ddd8e8b76184f566294196d089bc9d1902a Reviewed-on: https://chromium-review.googlesource.com/223270Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 4de44cb6
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
'libEGL/Config.h', 'libEGL/Config.h',
'libEGL/Display.cpp', 'libEGL/Display.cpp',
'libEGL/Display.h', 'libEGL/Display.h',
'libEGL/Error.cpp',
'libEGL/Error.h',
'libEGL/Surface.cpp', 'libEGL/Surface.cpp',
'libEGL/Surface.h', 'libEGL/Surface.h',
'libEGL/libEGL.cpp', 'libEGL/libEGL.cpp',
......
...@@ -71,11 +71,11 @@ Display::~Display() ...@@ -71,11 +71,11 @@ Display::~Display()
} }
} }
bool Display::initialize() Error Display::initialize()
{ {
if (isInitialized()) if (isInitialized())
{ {
return true; return Error(EGL_SUCCESS);
} }
mRenderer = glCreateRenderer(this, mDisplayId, mRequestedDisplayType); mRenderer = glCreateRenderer(this, mDisplayId, mRequestedDisplayType);
...@@ -83,7 +83,7 @@ bool Display::initialize() ...@@ -83,7 +83,7 @@ bool Display::initialize()
if (!mRenderer) if (!mRenderer)
{ {
terminate(); terminate();
return error(EGL_NOT_INITIALIZED, false); return Error(EGL_NOT_INITIALIZED);
} }
EGLint minSwapInterval = mRenderer->getMinSwapInterval(); EGLint minSwapInterval = mRenderer->getMinSwapInterval();
...@@ -116,13 +116,13 @@ bool Display::initialize() ...@@ -116,13 +116,13 @@ bool Display::initialize()
if (!isInitialized()) if (!isInitialized())
{ {
terminate(); terminate();
return false; return Error(EGL_NOT_INITIALIZED);
} }
initDisplayExtensionString(); initDisplayExtensionString();
initVendorString(); initVendorString();
return true; return Error(EGL_SUCCESS);
} }
void Display::terminate() void Display::terminate()
...@@ -193,7 +193,7 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value) ...@@ -193,7 +193,7 @@ bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList) Error Display::createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList, EGLSurface *outSurface)
{ {
const Config *configuration = mConfigSet.get(config); const Config *configuration = mConfigSet.get(config);
EGLint postSubBufferSupported = EGL_FALSE; EGLint postSubBufferSupported = EGL_FALSE;
...@@ -214,9 +214,9 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co ...@@ -214,9 +214,9 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
case EGL_BACK_BUFFER: case EGL_BACK_BUFFER:
break; break;
case EGL_SINGLE_BUFFER: case EGL_SINGLE_BUFFER:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); // Rendering directly to front buffer not supported return Error(EGL_BAD_MATCH); // Rendering directly to front buffer not supported
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
break; break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV: case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
...@@ -232,11 +232,11 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co ...@@ -232,11 +232,11 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
fixedSize = attribList[1]; fixedSize = attribList[1];
break; break;
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
case EGL_VG_ALPHA_FORMAT: case EGL_VG_ALPHA_FORMAT:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
attribList += 2; attribList += 2;
...@@ -245,7 +245,7 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co ...@@ -245,7 +245,7 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
if (width < 0 || height < 0) if (width < 0 || height < 0)
{ {
return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE); return Error(EGL_BAD_PARAMETER);
} }
if (!fixedSize) if (!fixedSize)
...@@ -256,29 +256,33 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co ...@@ -256,29 +256,33 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
if (hasExistingWindowSurface(window)) if (hasExistingWindowSurface(window))
{ {
return error(EGL_BAD_ALLOC, EGL_NO_SURFACE); return Error(EGL_BAD_ALLOC);
} }
if (mRenderer->testDeviceLost(false)) if (mRenderer->testDeviceLost(false))
{ {
if (!restoreLostDevice()) Error error = restoreLostDevice();
return EGL_NO_SURFACE; if (error.isError())
{
return error;
}
} }
Surface *surface = new Surface(this, configuration, window, fixedSize, width, height, postSubBufferSupported); Surface *surface = new Surface(this, configuration, window, fixedSize, width, height, postSubBufferSupported);
Error error = surface->initialize();
if (!surface->initialize()) if (error.isError())
{ {
delete surface; SafeDelete(surface);
return EGL_NO_SURFACE; return error;
} }
mSurfaceSet.insert(surface); mSurfaceSet.insert(surface);
return success(surface); *outSurface = surface;
return Error(EGL_SUCCESS);
} }
EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList) Error Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList, EGLSurface *outSurface)
{ {
EGLint width = 0, height = 0; EGLint width = 0, height = 0;
EGLenum textureFormat = EGL_NO_TEXTURE; EGLenum textureFormat = EGL_NO_TEXTURE;
...@@ -310,7 +314,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, ...@@ -310,7 +314,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
textureFormat = attribList[1]; textureFormat = attribList[1];
break; break;
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
break; break;
case EGL_TEXTURE_TARGET: case EGL_TEXTURE_TARGET:
...@@ -321,19 +325,19 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, ...@@ -321,19 +325,19 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
textureTarget = attribList[1]; textureTarget = attribList[1];
break; break;
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
break; break;
case EGL_MIPMAP_TEXTURE: case EGL_MIPMAP_TEXTURE:
if (attribList[1] != EGL_FALSE) if (attribList[1] != EGL_FALSE)
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
break; break;
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
case EGL_VG_ALPHA_FORMAT: case EGL_VG_ALPHA_FORMAT:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
attribList += 2; attribList += 2;
...@@ -342,86 +346,97 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle, ...@@ -342,86 +346,97 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
if (width < 0 || height < 0) if (width < 0 || height < 0)
{ {
return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE); return Error(EGL_BAD_PARAMETER);
} }
if (width == 0 || height == 0) if (width == 0 || height == 0)
{ {
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getRendererExtensions().textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height))) if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getRendererExtensions().textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height)))
{ {
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
} }
if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) || if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) ||
(textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE)) (textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE))
{ {
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
} }
if (!(configuration->mSurfaceType & EGL_PBUFFER_BIT)) if (!(configuration->mSurfaceType & EGL_PBUFFER_BIT))
{ {
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return Error(EGL_BAD_MATCH);
} }
if ((textureFormat == EGL_TEXTURE_RGB && configuration->mBindToTextureRGB != EGL_TRUE) || if ((textureFormat == EGL_TEXTURE_RGB && configuration->mBindToTextureRGB != EGL_TRUE) ||
(textureFormat == EGL_TEXTURE_RGBA && configuration->mBindToTextureRGBA != EGL_TRUE)) (textureFormat == EGL_TEXTURE_RGBA && configuration->mBindToTextureRGBA != EGL_TRUE))
{ {
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return Error(EGL_BAD_ATTRIBUTE);
} }
if (mRenderer->testDeviceLost(false)) if (mRenderer->testDeviceLost(false))
{ {
if (!restoreLostDevice()) Error error = restoreLostDevice();
return EGL_NO_SURFACE; if (error.isError())
{
return error;
}
} }
Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget); Surface *surface = new Surface(this, configuration, shareHandle, width, height, textureFormat, textureTarget);
Error error = surface->initialize();
if (!surface->initialize()) if (error.isError())
{ {
delete surface; SafeDelete(surface);
return EGL_NO_SURFACE; return error;
} }
mSurfaceSet.insert(surface); mSurfaceSet.insert(surface);
return success(surface); *outSurface = surface;
return Error(EGL_SUCCESS);
} }
EGLContext Display::createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess) Error Display::createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets,
bool robustAccess, EGLContext *outContext)
{ {
if (!mRenderer) if (!mRenderer)
{ {
return EGL_NO_CONTEXT; *outContext = EGL_NO_CONTEXT;
return Error(EGL_SUCCESS);
} }
else if (mRenderer->testDeviceLost(false)) // Lost device else if (mRenderer->testDeviceLost(false)) // Lost device
{ {
if (!restoreLostDevice()) Error error = restoreLostDevice();
if (error.isError())
{ {
return error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT); return error;
} }
} }
if (clientVersion > 2 && mRenderer->getMajorShaderModel() < 4) if (clientVersion > 2 && mRenderer->getMajorShaderModel() < 4)
{ {
return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); return Error(EGL_BAD_CONFIG);
} }
gl::Context *context = glCreateContext(clientVersion, shareContext, mRenderer, notifyResets, robustAccess); gl::Context *context = glCreateContext(clientVersion, shareContext, mRenderer, notifyResets, robustAccess);
mContextSet.insert(context); mContextSet.insert(context);
return success(context); *outContext = context;
return Error(EGL_SUCCESS);
} }
bool Display::restoreLostDevice() Error Display::restoreLostDevice()
{ {
for (ContextSet::iterator ctx = mContextSet.begin(); ctx != mContextSet.end(); ctx++) for (ContextSet::iterator ctx = mContextSet.begin(); ctx != mContextSet.end(); ctx++)
{ {
if ((*ctx)->isResetNotificationEnabled()) if ((*ctx)->isResetNotificationEnabled())
return false; // If reset notifications have been requested, application must delete all contexts first {
// If reset notifications have been requested, application must delete all contexts first
return Error(EGL_CONTEXT_LOST);
}
} }
// Release surface resources to make the Reset() succeed // Release surface resources to make the Reset() succeed
...@@ -432,16 +447,20 @@ bool Display::restoreLostDevice() ...@@ -432,16 +447,20 @@ bool Display::restoreLostDevice()
if (!mRenderer->resetDevice()) if (!mRenderer->resetDevice())
{ {
return error(EGL_BAD_ALLOC, false); return Error(EGL_BAD_ALLOC);
} }
// Restore any surfaces that may have been lost // Restore any surfaces that may have been lost
for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++) for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
{ {
(*surface)->resetSwapChain(); Error error = (*surface)->resetSwapChain();
if (error.isError())
{
return error;
}
} }
return true; return Error(EGL_SUCCESS);
} }
...@@ -463,7 +482,6 @@ void Display::notifyDeviceLost() ...@@ -463,7 +482,6 @@ void Display::notifyDeviceLost()
{ {
(*context)->markContextLost(); (*context)->markContextLost();
} }
egl::error(EGL_CONTEXT_LOST);
} }
void Display::recreateSwapChains() void Display::recreateSwapChains()
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "libEGL/Error.h"
#include "libEGL/Config.h" #include "libEGL/Config.h"
namespace gl namespace gl
...@@ -30,7 +31,7 @@ class Display ...@@ -30,7 +31,7 @@ class Display
public: public:
~Display(); ~Display();
bool initialize(); Error initialize();
void terminate(); void terminate();
static egl::Display *getDisplay(EGLNativeDisplayType displayId, EGLint displayType); static egl::Display *getDisplay(EGLNativeDisplayType displayId, EGLint displayType);
...@@ -43,9 +44,10 @@ class Display ...@@ -43,9 +44,10 @@ class Display
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
EGLSurface createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList); Error createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList, EGLSurface *outSurface);
EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList); Error createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList, EGLSurface *outSurface);
EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess); Error createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets,
bool robustAccess, EGLContext *outContext);
void destroySurface(egl::Surface *surface); void destroySurface(egl::Surface *surface);
void destroyContext(gl::Context *context); void destroyContext(gl::Context *context);
...@@ -70,7 +72,7 @@ class Display ...@@ -70,7 +72,7 @@ class Display
Display(EGLNativeDisplayType displayId, EGLint displayType); Display(EGLNativeDisplayType displayId, EGLint displayType);
bool restoreLostDevice(); Error restoreLostDevice();
EGLNativeDisplayType mDisplayId; EGLNativeDisplayType mDisplayId;
EGLint mRequestedDisplayType; EGLint mRequestedDisplayType;
......
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Error.cpp: Implements the egl::Error class which encapsulates an EGL error
// and optional error message.
#include "libEGL/Error.h"
#include "common/angleutils.h"
#include <cstdarg>
namespace egl
{
Error::Error(EGLint errorCode)
: mCode(errorCode),
mMessage()
{
}
Error::Error(EGLint errorCode, const char *msg, ...)
: mCode(errorCode),
mMessage()
{
va_list vararg;
va_start(vararg, msg);
mMessage = FormatString(msg, vararg);
va_end(vararg);
}
Error::Error(const Error &other)
: mCode(other.mCode),
mMessage(other.mMessage)
{
}
Error &Error::operator=(const Error &other)
{
mCode = other.mCode;
mMessage = other.mMessage;
return *this;
}
}
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Error.h: Defines the egl::Error class which encapsulates an EGL error
// and optional error message.
#ifndef LIBEGL_ERROR_H_
#define LIBEGL_ERROR_H_
#include <EGL/egl.h>
#include <string>
namespace egl
{
class Error
{
public:
explicit Error(EGLint errorCode);
Error(EGLint errorCode, const char *msg, ...);
Error(const Error &other);
Error &operator=(const Error &other);
EGLint getCode() const { return mCode; }
bool isError() const { return (mCode != EGL_SUCCESS); }
const std::string &getMessage() const { return mMessage; }
private:
EGLint mCode;
std::string mMessage;
};
}
#endif // LIBEGL_ERROR_H_
...@@ -74,20 +74,23 @@ Surface::~Surface() ...@@ -74,20 +74,23 @@ Surface::~Surface()
release(); release();
} }
bool Surface::initialize() Error Surface::initialize()
{ {
if (mNativeWindow.getNativeWindow()) if (mNativeWindow.getNativeWindow())
{ {
if (!mNativeWindow.initialize()) if (!mNativeWindow.initialize())
{ {
return false; return Error(EGL_BAD_SURFACE);
} }
} }
if (!resetSwapChain()) Error error = resetSwapChain();
return false; if (error.isError())
{
return error;
}
return true; return Error(EGL_SUCCESS);
} }
void Surface::release() void Surface::release()
...@@ -102,7 +105,7 @@ void Surface::release() ...@@ -102,7 +105,7 @@ void Surface::release()
} }
} }
bool Surface::resetSwapChain() Error Surface::resetSwapChain()
{ {
ASSERT(!mSwapChain); ASSERT(!mSwapChain);
...@@ -116,8 +119,7 @@ bool Surface::resetSwapChain() ...@@ -116,8 +119,7 @@ bool Surface::resetSwapChain()
{ {
ASSERT(false); ASSERT(false);
ERR("Could not retrieve the window dimensions"); return Error(EGL_BAD_SURFACE, "Could not retrieve the window dimensions");
return error(EGL_BAD_SURFACE, false);
} }
width = windowRect.right - windowRect.left; width = windowRect.right - windowRect.left;
...@@ -135,20 +137,20 @@ bool Surface::resetSwapChain() ...@@ -135,20 +137,20 @@ bool Surface::resetSwapChain()
mConfig->mDepthStencilFormat); mConfig->mDepthStencilFormat);
if (!mSwapChain) if (!mSwapChain)
{ {
return error(EGL_BAD_ALLOC, false); return Error(EGL_BAD_ALLOC);
} }
if (!resetSwapChain(width, height)) Error error = resetSwapChain(width, height);
if (error.isError())
{ {
delete mSwapChain; SafeDelete(mSwapChain);
mSwapChain = NULL; return error;
return false;
} }
return true; return Error(EGL_SUCCESS);
} }
bool Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight) Error Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight)
{ {
ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0); ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
ASSERT(mSwapChain); ASSERT(mSwapChain);
...@@ -158,20 +160,20 @@ bool Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -158,20 +160,20 @@ bool Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight)
if (status == EGL_CONTEXT_LOST) if (status == EGL_CONTEXT_LOST)
{ {
mDisplay->notifyDeviceLost(); mDisplay->notifyDeviceLost();
return false; return Error(status);
} }
else if (status != EGL_SUCCESS) else if (status != EGL_SUCCESS)
{ {
return error(status, false); return Error(status);
} }
mWidth = backbufferWidth; mWidth = backbufferWidth;
mHeight = backbufferHeight; mHeight = backbufferHeight;
return true; return Error(EGL_SUCCESS);
} }
bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) Error Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
{ {
ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0); ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
ASSERT(mSwapChain); ASSERT(mSwapChain);
...@@ -181,25 +183,25 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -181,25 +183,25 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
if (status == EGL_CONTEXT_LOST) if (status == EGL_CONTEXT_LOST)
{ {
mRenderer->notifyDeviceLost(); mRenderer->notifyDeviceLost();
return false; return Error(status);
} }
else if (status != EGL_SUCCESS) else if (status != EGL_SUCCESS)
{ {
return error(status, false); return Error(status);
} }
mWidth = backbufferWidth; mWidth = backbufferWidth;
mHeight = backbufferHeight; mHeight = backbufferHeight;
mSwapIntervalDirty = false; mSwapIntervalDirty = false;
return true; return Error(EGL_SUCCESS);
} }
bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) Error Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
{ {
if (!mSwapChain) if (!mSwapChain)
{ {
return true; return Error(EGL_SUCCESS);
} }
if (x + width > mWidth) if (x + width > mWidth)
...@@ -214,7 +216,7 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) ...@@ -214,7 +216,7 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
if (width == 0 || height == 0) if (width == 0 || height == 0)
{ {
return true; return Error(EGL_SUCCESS);
} }
EGLint status = mSwapChain->swapRect(x, y, width, height); EGLint status = mSwapChain->swapRect(x, y, width, height);
...@@ -222,16 +224,16 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) ...@@ -222,16 +224,16 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
if (status == EGL_CONTEXT_LOST) if (status == EGL_CONTEXT_LOST)
{ {
mRenderer->notifyDeviceLost(); mRenderer->notifyDeviceLost();
return false; return Error(status);
} }
else if (status != EGL_SUCCESS) else if (status != EGL_SUCCESS)
{ {
return error(status, false); return Error(status);
} }
checkForOutOfDateSwapChain(); checkForOutOfDateSwapChain();
return true; return Error(EGL_SUCCESS);
} }
EGLNativeWindowType Surface::getWindowHandle() EGLNativeWindowType Surface::getWindowHandle()
...@@ -369,17 +371,17 @@ bool Surface::checkForOutOfDateSwapChain() ...@@ -369,17 +371,17 @@ bool Surface::checkForOutOfDateSwapChain()
return false; return false;
} }
bool Surface::swap() Error Surface::swap()
{ {
return swapRect(0, 0, mWidth, mHeight); return swapRect(0, 0, mWidth, mHeight);
} }
bool Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height) Error Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
{ {
if (!mPostSubBufferSupported) if (!mPostSubBufferSupported)
{ {
// Spec is not clear about how this should be handled. // Spec is not clear about how this should be handled.
return true; return Error(EGL_SUCCESS);
} }
return swapRect(x, y, width, height); return swapRect(x, y, width, height);
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#ifndef LIBEGL_SURFACE_H_ #ifndef LIBEGL_SURFACE_H_
#define LIBEGL_SURFACE_H_ #define LIBEGL_SURFACE_H_
#include "libEGL/Error.h"
#include <EGL/egl.h> #include <EGL/egl.h>
#include "common/angleutils.h" #include "common/angleutils.h"
...@@ -39,13 +41,13 @@ class Surface ...@@ -39,13 +41,13 @@ class Surface
virtual ~Surface(); virtual ~Surface();
bool initialize(); Error initialize();
void release(); void release();
bool resetSwapChain(); Error resetSwapChain();
EGLNativeWindowType getWindowHandle(); EGLNativeWindowType getWindowHandle();
bool swap(); Error swap();
bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height); Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
virtual EGLint isPostSubBufferSupported() const; virtual EGLint isPostSubBufferSupported() const;
...@@ -80,9 +82,9 @@ private: ...@@ -80,9 +82,9 @@ private:
void subclassWindow(); void subclassWindow();
void unsubclassWindow(); void unsubclassWindow();
bool resizeSwapChain(int backbufferWidth, int backbufferHeight); Error resizeSwapChain(int backbufferWidth, int backbufferHeight);
bool resetSwapChain(int backbufferWidth, int backbufferHeight); Error resetSwapChain(int backbufferWidth, int backbufferHeight);
bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height); Error swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for. rx::NativeWindow mNativeWindow; // Handler for the Window that the surface is created for.
bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
......
...@@ -25,12 +25,14 @@ bool validateDisplay(egl::Display *display) ...@@ -25,12 +25,14 @@ bool validateDisplay(egl::Display *display)
{ {
if (display == EGL_NO_DISPLAY) if (display == EGL_NO_DISPLAY)
{ {
return egl::error(EGL_BAD_DISPLAY, false); recordError(egl::Error(EGL_BAD_DISPLAY));
return false;
} }
if (!display->isInitialized()) if (!display->isInitialized())
{ {
return egl::error(EGL_NOT_INITIALIZED, false); recordError(egl::Error(EGL_NOT_INITIALIZED));
return false;
} }
return true; return true;
...@@ -45,7 +47,8 @@ bool validateConfig(egl::Display *display, EGLConfig config) ...@@ -45,7 +47,8 @@ bool validateConfig(egl::Display *display, EGLConfig config)
if (!display->isValidConfig(config)) if (!display->isValidConfig(config))
{ {
return egl::error(EGL_BAD_CONFIG, false); recordError(egl::Error(EGL_BAD_CONFIG));
return false;
} }
return true; return true;
...@@ -60,7 +63,8 @@ bool validateContext(egl::Display *display, gl::Context *context) ...@@ -60,7 +63,8 @@ bool validateContext(egl::Display *display, gl::Context *context)
if (!display->isValidContext(context)) if (!display->isValidContext(context))
{ {
return egl::error(EGL_BAD_CONTEXT, false); recordError(egl::Error(EGL_BAD_CONTEXT));
return false;
} }
return true; return true;
...@@ -75,7 +79,8 @@ bool validateSurface(egl::Display *display, egl::Surface *surface) ...@@ -75,7 +79,8 @@ bool validateSurface(egl::Display *display, egl::Surface *surface)
if (!display->isValidSurface(surface)) if (!display->isValidSurface(surface))
{ {
return egl::error(EGL_BAD_SURFACE, false); recordError(egl::Error(EGL_BAD_SURFACE));
return false;
} }
return true; return true;
...@@ -88,12 +93,7 @@ EGLint __stdcall eglGetError(void) ...@@ -88,12 +93,7 @@ EGLint __stdcall eglGetError(void)
EVENT("()"); EVENT("()");
EGLint error = egl::getCurrentError(); EGLint error = egl::getCurrentError();
recordError(egl::Error(EGL_SUCCESS));
if (error != EGL_SUCCESS)
{
egl::setCurrentError(EGL_SUCCESS);
}
return error; return error;
} }
...@@ -115,7 +115,8 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis ...@@ -115,7 +115,8 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis
break; break;
default: default:
return egl::error(EGL_BAD_CONFIG, EGL_NO_DISPLAY); recordError(egl::Error(EGL_BAD_CONFIG));
return EGL_NO_DISPLAY;
} }
EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display); EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display);
...@@ -124,7 +125,8 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis ...@@ -124,7 +125,8 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis
// Validate the display device context // Validate the display device context
if (WindowFromDC(displayId) == NULL) if (WindowFromDC(displayId) == NULL)
{ {
return egl::success(EGL_NO_DISPLAY); recordError(egl::Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
} }
#endif #endif
...@@ -155,7 +157,8 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis ...@@ -155,7 +157,8 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis
case EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE:
if (!egl::Display::supportsPlatformD3D()) if (!egl::Display::supportsPlatformD3D())
{ {
return egl::success(EGL_NO_DISPLAY); recordError(egl::Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
} }
break; break;
...@@ -163,12 +166,14 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis ...@@ -163,12 +166,14 @@ EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_dis
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
if (!egl::Display::supportsPlatformOpenGL()) if (!egl::Display::supportsPlatformOpenGL())
{ {
return egl::success(EGL_NO_DISPLAY); recordError(egl::Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
} }
break; break;
default: default:
return egl::success(EGL_NO_DISPLAY); recordError(egl::Error(EGL_SUCCESS));
return EGL_NO_DISPLAY;
} }
return egl::Display::getDisplay(displayId, requestedDisplayType); return egl::Display::getDisplay(displayId, requestedDisplayType);
...@@ -181,20 +186,24 @@ EGLBoolean __stdcall eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) ...@@ -181,20 +186,24 @@ EGLBoolean __stdcall eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
if (dpy == EGL_NO_DISPLAY) if (dpy == EGL_NO_DISPLAY)
{ {
return egl::error(EGL_BAD_DISPLAY, EGL_FALSE); recordError(egl::Error(EGL_BAD_DISPLAY));
return EGL_FALSE;
} }
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
if (!display->initialize()) egl::Error error = display->initialize();
if (error.isError())
{ {
return egl::error(EGL_NOT_INITIALIZED, EGL_FALSE); recordError(error);
return EGL_FALSE;
} }
if (major) *major = 1; if (major) *major = 1;
if (minor) *minor = 4; if (minor) *minor = 4;
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglTerminate(EGLDisplay dpy) EGLBoolean __stdcall eglTerminate(EGLDisplay dpy)
...@@ -203,14 +212,16 @@ EGLBoolean __stdcall eglTerminate(EGLDisplay dpy) ...@@ -203,14 +212,16 @@ EGLBoolean __stdcall eglTerminate(EGLDisplay dpy)
if (dpy == EGL_NO_DISPLAY) if (dpy == EGL_NO_DISPLAY)
{ {
return egl::error(EGL_BAD_DISPLAY, EGL_FALSE); recordError(egl::Error(EGL_BAD_DISPLAY));
return EGL_FALSE;
} }
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
display->terminate(); display->terminate();
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name) const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name)
...@@ -223,19 +234,28 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name) ...@@ -223,19 +234,28 @@ const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name)
return NULL; return NULL;
} }
const char *result;
switch (name) switch (name)
{ {
case EGL_CLIENT_APIS: case EGL_CLIENT_APIS:
return egl::success("OpenGL_ES"); result = "OpenGL_ES";
break;
case EGL_EXTENSIONS: case EGL_EXTENSIONS:
return egl::success(egl::Display::getExtensionString(display)); result = egl::Display::getExtensionString(display);
break;
case EGL_VENDOR: case EGL_VENDOR:
return egl::success(display->getVendorString()); result = display->getVendorString();
break;
case EGL_VERSION: case EGL_VERSION:
return egl::success("1.4 (ANGLE " ANGLE_VERSION_STRING ")"); result = "1.4 (ANGLE " ANGLE_VERSION_STRING ")";
break;
default: default:
return egl::error(EGL_BAD_PARAMETER, (const char*)NULL); recordError(egl::Error(EGL_BAD_PARAMETER));
return NULL;
} }
recordError(egl::Error(EGL_SUCCESS));
return result;
} }
EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
...@@ -253,17 +273,20 @@ EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint co ...@@ -253,17 +273,20 @@ EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint co
if (!num_config) if (!num_config)
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
} }
const EGLint attribList[] = {EGL_NONE}; const EGLint attribList[] = {EGL_NONE};
if (!display->getConfigs(configs, attribList, config_size, num_config)) if (!display->getConfigs(configs, attribList, config_size, num_config))
{ {
return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE); recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_FALSE;
} }
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
...@@ -281,7 +304,8 @@ EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, ...@@ -281,7 +304,8 @@ EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
if (!num_config) if (!num_config)
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
} }
const EGLint attribList[] = {EGL_NONE}; const EGLint attribList[] = {EGL_NONE};
...@@ -293,7 +317,8 @@ EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, ...@@ -293,7 +317,8 @@ EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
display->getConfigs(configs, attrib_list, config_size, num_config); display->getConfigs(configs, attrib_list, config_size, num_config);
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
...@@ -310,10 +335,12 @@ EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint ...@@ -310,10 +335,12 @@ EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint
if (!display->getConfigAttrib(config, attribute, value)) if (!display->getConfigAttrib(config, attribute, value))
{ {
return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE); recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_FALSE;
} }
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
...@@ -330,10 +357,19 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG ...@@ -330,10 +357,19 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG
if (!isValidEGLNativeWindowType(win)) if (!isValidEGLNativeWindowType(win))
{ {
return egl::error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); recordError(egl::Error(EGL_BAD_NATIVE_WINDOW));
return EGL_NO_SURFACE;
}
EGLSurface surface = EGL_NO_SURFACE;
egl::Error error = display->createWindowSurface(win, config, attrib_list, &surface);
if (error.isError())
{
recordError(error);
return EGL_NO_SURFACE;
} }
return display->createWindowSurface(win, config, attrib_list); return surface;
} }
EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
...@@ -348,7 +384,15 @@ EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, c ...@@ -348,7 +384,15 @@ EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, c
return EGL_NO_SURFACE; return EGL_NO_SURFACE;
} }
return display->createOffscreenSurface(config, NULL, attrib_list); EGLSurface surface = EGL_NO_SURFACE;
egl::Error error = display->createOffscreenSurface(config, NULL, attrib_list, &surface);
if (error.isError())
{
recordError(error);
return EGL_NO_SURFACE;
}
return surface;
} }
EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
...@@ -365,7 +409,8 @@ EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EG ...@@ -365,7 +409,8 @@ EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EG
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(EGL_NO_SURFACE); recordError(egl::Error(EGL_SUCCESS));
return EGL_NO_SURFACE;
} }
EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface) EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
...@@ -382,12 +427,14 @@ EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface) ...@@ -382,12 +427,14 @@ EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
if (surface == EGL_NO_SURFACE) if (surface == EGL_NO_SURFACE)
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
display->destroySurface((egl::Surface*)surface); display->destroySurface((egl::Surface*)surface);
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
...@@ -405,7 +452,8 @@ EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint ...@@ -405,7 +452,8 @@ EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint
if (surface == EGL_NO_SURFACE) if (surface == EGL_NO_SURFACE)
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
switch (attribute) switch (attribute)
...@@ -465,10 +513,12 @@ EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint ...@@ -465,10 +513,12 @@ EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint
*value = eglSurface->isFixedSize(); *value = eglSurface->isFixedSize();
break; break;
default: default:
return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE); recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_FALSE;
} }
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value) EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
...@@ -486,7 +536,8 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf ...@@ -486,7 +536,8 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf
if (surface == EGL_NO_SURFACE) if (surface == EGL_NO_SURFACE)
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
switch (attribute) switch (attribute)
...@@ -498,10 +549,12 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf ...@@ -498,10 +549,12 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf
} }
break; break;
default: default:
return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE); recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_FALSE;
} }
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglBindAPI(EGLenum api) EGLBoolean __stdcall eglBindAPI(EGLenum api)
...@@ -512,16 +565,19 @@ EGLBoolean __stdcall eglBindAPI(EGLenum api) ...@@ -512,16 +565,19 @@ EGLBoolean __stdcall eglBindAPI(EGLenum api)
{ {
case EGL_OPENGL_API: case EGL_OPENGL_API:
case EGL_OPENVG_API: case EGL_OPENVG_API:
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); // Not supported by this implementation recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE; // Not supported by this implementation
case EGL_OPENGL_ES_API: case EGL_OPENGL_ES_API:
break; break;
default: default:
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
} }
egl::setCurrentAPI(api); egl::setCurrentAPI(api);
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLenum __stdcall eglQueryAPI(void) EGLenum __stdcall eglQueryAPI(void)
...@@ -530,7 +586,8 @@ EGLenum __stdcall eglQueryAPI(void) ...@@ -530,7 +586,8 @@ EGLenum __stdcall eglQueryAPI(void)
EGLenum API = egl::getCurrentAPI(); EGLenum API = egl::getCurrentAPI();
return egl::success(API); recordError(egl::Error(EGL_SUCCESS));
return API;
} }
EGLBoolean __stdcall eglWaitClient(void) EGLBoolean __stdcall eglWaitClient(void)
...@@ -539,7 +596,8 @@ EGLBoolean __stdcall eglWaitClient(void) ...@@ -539,7 +596,8 @@ EGLBoolean __stdcall eglWaitClient(void)
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(0); recordError(egl::Error(EGL_SUCCESS));
return 0;
} }
EGLBoolean __stdcall eglReleaseThread(void) EGLBoolean __stdcall eglReleaseThread(void)
...@@ -548,7 +606,8 @@ EGLBoolean __stdcall eglReleaseThread(void) ...@@ -548,7 +606,8 @@ EGLBoolean __stdcall eglReleaseThread(void)
eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); eglMakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
...@@ -566,10 +625,19 @@ EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum bu ...@@ -566,10 +625,19 @@ EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum bu
if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE || !buffer) if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE || !buffer)
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_NO_SURFACE;
}
EGLSurface surface = EGL_NO_SURFACE;
egl::Error error = display->createOffscreenSurface(config, (HANDLE)buffer, attrib_list, &surface);
if (error.isError())
{
recordError(error);
return EGL_NO_SURFACE;
} }
return display->createOffscreenSurface(config, (HANDLE)buffer, attrib_list); return surface;
} }
EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
...@@ -587,7 +655,8 @@ EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint ...@@ -587,7 +655,8 @@ EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
...@@ -604,30 +673,36 @@ EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint ...@@ -604,30 +673,36 @@ EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint
if (buffer != EGL_BACK_BUFFER) if (buffer != EGL_BACK_BUFFER)
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
} }
if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle()) if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
if (eglSurface->getBoundTexture()) if (eglSurface->getBoundTexture())
{ {
return egl::error(EGL_BAD_ACCESS, EGL_FALSE); recordError(egl::Error(EGL_BAD_ACCESS));
return EGL_FALSE;
} }
if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
{ {
return egl::error(EGL_BAD_MATCH, EGL_FALSE); recordError(egl::Error(EGL_BAD_MATCH));
return EGL_FALSE;
} }
if (!glBindTexImage(eglSurface)) if (!glBindTexImage(eglSurface))
{ {
return egl::error(EGL_BAD_MATCH, EGL_FALSE); recordError(egl::Error(EGL_BAD_MATCH));
return EGL_FALSE;
} }
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
...@@ -644,17 +719,20 @@ EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLi ...@@ -644,17 +719,20 @@ EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLi
if (buffer != EGL_BACK_BUFFER) if (buffer != EGL_BACK_BUFFER)
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
} }
if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle()) if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE) if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
{ {
return egl::error(EGL_BAD_MATCH, EGL_FALSE); recordError(egl::Error(EGL_BAD_MATCH));
return EGL_FALSE;
} }
gl::Texture2D *texture = eglSurface->getBoundTexture(); gl::Texture2D *texture = eglSurface->getBoundTexture();
...@@ -664,7 +742,8 @@ EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLi ...@@ -664,7 +742,8 @@ EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLi
texture->releaseTexImage(); texture->releaseTexImage();
} }
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval) EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval)
...@@ -682,12 +761,14 @@ EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval) ...@@ -682,12 +761,14 @@ EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval)
if (draw_surface == NULL) if (draw_surface == NULL)
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
draw_surface->setSwapInterval(interval); draw_surface->setSwapInterval(interval);
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
...@@ -712,27 +793,38 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte ...@@ -712,27 +793,38 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte
case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT: case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
if (attribute[1] == EGL_TRUE) if (attribute[1] == EGL_TRUE)
{ {
return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); // Unimplemented recordError(egl::Error(EGL_BAD_CONFIG)); // Unimplemented
return EGL_NO_CONTEXT;
// robust_access = true; // robust_access = true;
} }
else if (attribute[1] != EGL_FALSE) else if (attribute[1] != EGL_FALSE)
return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT); {
recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_NO_CONTEXT;
}
break; break;
case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT: case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT) if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT)
{
reset_notification = true; reset_notification = true;
}
else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT) else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT)
return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT); {
recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_NO_CONTEXT;
}
break; break;
default: default:
return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT); recordError(egl::Error(EGL_BAD_ATTRIBUTE));
return EGL_NO_CONTEXT;
} }
} }
} }
if (client_version != 2 && client_version != 3) if (client_version != 2 && client_version != 3)
{ {
return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); recordError(egl::Error(EGL_BAD_CONFIG));
return EGL_NO_CONTEXT;
} }
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
...@@ -743,18 +835,21 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte ...@@ -743,18 +835,21 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte
if (sharedGLContext->isResetNotificationEnabled() != reset_notification) if (sharedGLContext->isResetNotificationEnabled() != reset_notification)
{ {
return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT); recordError(egl::Error(EGL_BAD_MATCH));
return EGL_NO_CONTEXT;
} }
if (sharedGLContext->getClientVersion() != client_version) if (sharedGLContext->getClientVersion() != client_version)
{ {
return egl::error(EGL_BAD_CONTEXT, EGL_NO_CONTEXT); recordError(egl::Error(EGL_BAD_CONTEXT));
return EGL_NO_CONTEXT;
} }
// Can not share contexts between displays // Can not share contexts between displays
if (sharedGLContext->getRenderer() != display->getRenderer()) if (sharedGLContext->getRenderer() != display->getRenderer())
{ {
return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT); recordError(egl::Error(EGL_BAD_MATCH));
return EGL_NO_CONTEXT;
} }
} }
...@@ -763,7 +858,16 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte ...@@ -763,7 +858,16 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte
return EGL_NO_CONTEXT; return EGL_NO_CONTEXT;
} }
return display->createContext(config, client_version, static_cast<gl::Context*>(share_context), reset_notification, robust_access); EGLContext context = EGL_NO_CONTEXT;
egl::Error error = display->createContext(config, client_version, static_cast<gl::Context*>(share_context),
reset_notification, robust_access, &context);
if (error.isError())
{
recordError(error);
return EGL_NO_CONTEXT;
}
return context;
} }
EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx) EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
...@@ -780,12 +884,14 @@ EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx) ...@@ -780,12 +884,14 @@ EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
if (ctx == EGL_NO_CONTEXT) if (ctx == EGL_NO_CONTEXT)
{ {
return egl::error(EGL_BAD_CONTEXT, EGL_FALSE); recordError(egl::Error(EGL_BAD_CONTEXT));
return EGL_FALSE;
} }
display->destroyContext(context); display->destroyContext(context);
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
...@@ -800,7 +906,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface ...@@ -800,7 +906,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface
bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE); bool noSurface = (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE);
if (noContext != noSurface) if (noContext != noSurface)
{ {
return egl::error(EGL_BAD_MATCH, EGL_FALSE); recordError(egl::Error(EGL_BAD_MATCH));
return EGL_FALSE;
} }
if (ctx != EGL_NO_CONTEXT && !validateContext(display, context)) if (ctx != EGL_NO_CONTEXT && !validateContext(display, context))
...@@ -818,7 +925,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface ...@@ -818,7 +925,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface
if (renderer->isDeviceLost()) if (renderer->isDeviceLost())
{ {
return egl::error(EGL_CONTEXT_LOST, EGL_FALSE); recordError(egl::Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
} }
} }
...@@ -839,7 +947,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface ...@@ -839,7 +947,8 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface
glMakeCurrent(context, display, static_cast<egl::Surface*>(draw)); glMakeCurrent(context, display, static_cast<egl::Surface*>(draw));
return egl::success(EGL_TRUE); recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLContext __stdcall eglGetCurrentContext(void) EGLContext __stdcall eglGetCurrentContext(void)
...@@ -848,7 +957,8 @@ EGLContext __stdcall eglGetCurrentContext(void) ...@@ -848,7 +957,8 @@ EGLContext __stdcall eglGetCurrentContext(void)
EGLContext context = glGetCurrentContext(); EGLContext context = glGetCurrentContext();
return egl::success(context); recordError(egl::Error(EGL_SUCCESS));
return context;
} }
EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw) EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw)
...@@ -857,17 +967,18 @@ EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw) ...@@ -857,17 +967,18 @@ EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw)
if (readdraw == EGL_READ) if (readdraw == EGL_READ)
{ {
EGLSurface read = egl::getCurrentReadSurface(); recordError(egl::Error(EGL_SUCCESS));
return egl::success(read); return egl::getCurrentReadSurface();
} }
else if (readdraw == EGL_DRAW) else if (readdraw == EGL_DRAW)
{ {
EGLSurface draw = egl::getCurrentDrawSurface(); recordError(egl::Error(EGL_SUCCESS));
return egl::success(draw); return egl::getCurrentDrawSurface();
} }
else else
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_NO_SURFACE;
} }
} }
...@@ -877,7 +988,8 @@ EGLDisplay __stdcall eglGetCurrentDisplay(void) ...@@ -877,7 +988,8 @@ EGLDisplay __stdcall eglGetCurrentDisplay(void)
EGLDisplay dpy = egl::getCurrentDisplay(); EGLDisplay dpy = egl::getCurrentDisplay();
return egl::success(dpy); recordError(egl::Error(EGL_SUCCESS));
return dpy;
} }
EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
...@@ -895,7 +1007,8 @@ EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attr ...@@ -895,7 +1007,8 @@ EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attr
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(0); recordError(egl::Error(EGL_SUCCESS));
return 0;
} }
EGLBoolean __stdcall eglWaitGL(void) EGLBoolean __stdcall eglWaitGL(void)
...@@ -904,7 +1017,8 @@ EGLBoolean __stdcall eglWaitGL(void) ...@@ -904,7 +1017,8 @@ EGLBoolean __stdcall eglWaitGL(void)
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(0); recordError(egl::Error(EGL_SUCCESS));
return 0;
} }
EGLBoolean __stdcall eglWaitNative(EGLint engine) EGLBoolean __stdcall eglWaitNative(EGLint engine)
...@@ -913,7 +1027,8 @@ EGLBoolean __stdcall eglWaitNative(EGLint engine) ...@@ -913,7 +1027,8 @@ EGLBoolean __stdcall eglWaitNative(EGLint engine)
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(0); recordError(egl::Error(EGL_SUCCESS));
return 0;
} }
EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
...@@ -930,20 +1045,25 @@ EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) ...@@ -930,20 +1045,25 @@ EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
if (display->getRenderer()->isDeviceLost()) if (display->getRenderer()->isDeviceLost())
{ {
return egl::error(EGL_CONTEXT_LOST, EGL_FALSE); recordError(egl::Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
} }
if (surface == EGL_NO_SURFACE) if (surface == EGL_NO_SURFACE)
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
if (eglSurface->swap()) egl::Error error = eglSurface->swap();
if (error.isError())
{ {
return egl::success(EGL_TRUE); recordError(error);
return EGL_FALSE;
} }
return EGL_FALSE; recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
...@@ -960,12 +1080,14 @@ EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativ ...@@ -960,12 +1080,14 @@ EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativ
if (display->getRenderer()->isDeviceLost()) if (display->getRenderer()->isDeviceLost())
{ {
return egl::error(EGL_CONTEXT_LOST, EGL_FALSE); recordError(egl::Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
} }
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
return egl::success(0); recordError(egl::Error(EGL_SUCCESS));
return 0;
} }
EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height) EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
...@@ -974,7 +1096,8 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi ...@@ -974,7 +1096,8 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi
if (x < 0 || y < 0 || width < 0 || height < 0) if (x < 0 || y < 0 || width < 0 || height < 0)
{ {
return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); recordError(egl::Error(EGL_BAD_PARAMETER));
return EGL_FALSE;
} }
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
...@@ -987,20 +1110,25 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi ...@@ -987,20 +1110,25 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi
if (display->getRenderer()->isDeviceLost()) if (display->getRenderer()->isDeviceLost())
{ {
return egl::error(EGL_CONTEXT_LOST, EGL_FALSE); recordError(egl::Error(EGL_CONTEXT_LOST));
return EGL_FALSE;
} }
if (surface == EGL_NO_SURFACE) if (surface == EGL_NO_SURFACE)
{ {
return egl::error(EGL_BAD_SURFACE, EGL_FALSE); recordError(egl::Error(EGL_BAD_SURFACE));
return EGL_FALSE;
} }
if (eglSurface->postSubBuffer(x, y, width, height)) egl::Error error = eglSurface->postSubBuffer(x, y, width, height);
if (error.isError())
{ {
return egl::success(EGL_TRUE); recordError(error);
return EGL_FALSE;
} }
return EGL_FALSE; recordError(egl::Error(EGL_SUCCESS));
return EGL_TRUE;
} }
__eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char *procname) __eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char *procname)
......
...@@ -120,11 +120,11 @@ Current *GetCurrentData() ...@@ -120,11 +120,11 @@ Current *GetCurrentData()
return (current ? current : AllocateCurrent()); return (current ? current : AllocateCurrent());
} }
void setCurrentError(EGLint error) void recordError(const Error &error)
{ {
Current *current = GetCurrentData(); Current *current = GetCurrentData();
current->error = error; current->error = error.getCode();
} }
EGLint getCurrentError() EGLint getCurrentError()
...@@ -190,9 +190,4 @@ EGLSurface getCurrentReadSurface() ...@@ -190,9 +190,4 @@ EGLSurface getCurrentReadSurface()
return current->readSurface; return current->readSurface;
} }
void error(EGLint errorCode)
{
egl::setCurrentError(errorCode);
}
} }
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#ifndef LIBEGL_MAIN_H_ #ifndef LIBEGL_MAIN_H_
#define LIBEGL_MAIN_H_ #define LIBEGL_MAIN_H_
#include "libEGL/Error.h"
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
...@@ -23,7 +25,7 @@ struct Current ...@@ -23,7 +25,7 @@ struct Current
EGLSurface readSurface; EGLSurface readSurface;
}; };
void setCurrentError(EGLint error); void recordError(const Error &error);
EGLint getCurrentError(); EGLint getCurrentError();
void setCurrentAPI(EGLenum API); void setCurrentAPI(EGLenum API);
...@@ -38,24 +40,6 @@ EGLSurface getCurrentDrawSurface(); ...@@ -38,24 +40,6 @@ EGLSurface getCurrentDrawSurface();
void setCurrentReadSurface(EGLSurface surface); void setCurrentReadSurface(EGLSurface surface);
EGLSurface getCurrentReadSurface(); EGLSurface getCurrentReadSurface();
void error(EGLint errorCode);
template<class T>
const T &error(EGLint errorCode, const T &returnValue)
{
error(errorCode);
return returnValue;
}
template<class T>
const T &success(const T &returnValue)
{
egl::setCurrentError(EGL_SUCCESS);
return returnValue;
}
} }
#endif // LIBEGL_MAIN_H_ #endif // LIBEGL_MAIN_H_
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