summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libEGL
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-08-05 12:59:44 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-08-05 16:43:22 +0200
commita6a12d8c0fc918972c15268f749ecc7c90b95d6c (patch)
treecb6d986d30ef97e932ab51768854d5d9b46729d3 /src/3rdparty/angle/src/libEGL
parent14f9c09542bd6cc19430473da9ce4c68f239ec7d (diff)
ANGLE: upgrade to 2.1~07d49ef5350a
This version of ANGLE provides partial ES3 support, numerous bug fixes, and several potentially useful vendor extensions. All patches have been rebased. The following changes are noted: 0000-General-fixes-for-ANGLE-2.1.patch contains compile fixes for the new ANGLE 0004-Make-it-possible-to-link-ANGLE-statically-for-single.patch has incorporated patch 0015. 0007-Make-DX9-DX11-mutually-exclusive.patch has been removed as it was fixed upstream. 0007-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch has been moved up to fill the patch number gap. 0010-ANGLE-Enable-D3D11-for-feature-level-9-cards.patch now contains patch 0014 and 0017. 0013-ANGLE-Allow-for-universal-program-binaries.patch has been removed as it is no longer relevant. 0014-ANGLE-D3D11-Fix-internal-index-buffer-for-level-9-ha.patch has been merged with patch 0010. 0015-ANGLE-Don-t-export-DLLMain-functions-for-static-buil.patch has been merged with patch 0004. 0016-ANGLE-WinRT-Call-Trim-when-application-suspends.patch has been removed and will be replaced by a follow-up patch using a different technique. 0017-ANGLE-D3D11-Don-t-use-mipmaps-in-level-9-textures.patch has been merged with patch 0010. 0018-ANGLE-WinRT-Create-swap-chain-using-physical-resolut.patch has been removed and will be replaced by a follow-up patch extending the EGL_ANGLE_window_fixed_size extension. 0019-Fix-ANGLE-build-with-Microsoft-Visual-Studio-14-CTP.patch is now patch 0007. [ChangeLog][Third-party libraries] ANGLE has been upgraded to version 2.1, bringing partial support for OpenGL ES3 over Direct3D 11, numerous bug fixes, and several new vendor extensions. Change-Id: I6d95ce1480462d67228d83c1e5c74a1706b5b21c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/libEGL')
-rw-r--r--src/3rdparty/angle/src/libEGL/Config.cpp17
-rw-r--r--src/3rdparty/angle/src/libEGL/Config.h1
-rw-r--r--src/3rdparty/angle/src/libEGL/Display.cpp192
-rw-r--r--src/3rdparty/angle/src/libEGL/Display.h23
-rw-r--r--src/3rdparty/angle/src/libEGL/Surface.cpp370
-rw-r--r--src/3rdparty/angle/src/libEGL/Surface.h54
-rw-r--r--src/3rdparty/angle/src/libEGL/libEGL.cpp1239
-rw-r--r--src/3rdparty/angle/src/libEGL/libEGL.def75
-rw-r--r--src/3rdparty/angle/src/libEGL/libEGL_mingw32.def73
-rw-r--r--src/3rdparty/angle/src/libEGL/libEGLd.def75
-rw-r--r--src/3rdparty/angle/src/libEGL/libEGLd_mingw32.def73
-rw-r--r--src/3rdparty/angle/src/libEGL/main.cpp83
-rw-r--r--src/3rdparty/angle/src/libEGL/main.h1
13 files changed, 1178 insertions, 1098 deletions
diff --git a/src/3rdparty/angle/src/libEGL/Config.cpp b/src/3rdparty/angle/src/libEGL/Config.cpp
index 5488cb6f4f..fdc41a95f0 100644
--- a/src/3rdparty/angle/src/libEGL/Config.cpp
+++ b/src/3rdparty/angle/src/libEGL/Config.cpp
@@ -13,8 +13,8 @@
#include <algorithm>
#include <vector>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#include "angle_gl.h"
+#include <EGL/eglext.h>
#include "common/debug.h"
@@ -36,6 +36,13 @@ Config::Config(rx::ConfigDesc desc, EGLint minInterval, EGLint maxInterval, EGLi
mBlueSize = 5;
mAlphaSize = 1;
break;
+ case GL_BGR5_A1_ANGLEX:
+ mBufferSize = 16;
+ mRedSize = 5;
+ mGreenSize = 5;
+ mBlueSize = 5;
+ mAlphaSize = 1;
+ break;
case GL_RGBA8_OES:
mBufferSize = 32;
mRedSize = 8;
@@ -122,6 +129,12 @@ Config::Config(rx::ConfigDesc desc, EGLint minInterval, EGLint maxInterval, EGLi
mTransparentRedValue = 0;
mTransparentGreenValue = 0;
mTransparentBlueValue = 0;
+
+ if (desc.es3Capable)
+ {
+ mRenderableType |= EGL_OPENGL_ES3_BIT_KHR;
+ mConformant |= EGL_OPENGL_ES3_BIT_KHR;
+ }
}
EGLConfig Config::getHandle() const
diff --git a/src/3rdparty/angle/src/libEGL/Config.h b/src/3rdparty/angle/src/libEGL/Config.h
index 680337b700..98441142f4 100644
--- a/src/3rdparty/angle/src/libEGL/Config.h
+++ b/src/3rdparty/angle/src/libEGL/Config.h
@@ -11,7 +11,6 @@
#ifndef INCLUDE_CONFIG_H_
#define INCLUDE_CONFIG_H_
-#define EGLAPI
#include <EGL/egl.h>
#include <set>
diff --git a/src/3rdparty/angle/src/libEGL/Display.cpp b/src/3rdparty/angle/src/libEGL/Display.cpp
index e75a4b6440..7cd83c3db4 100644
--- a/src/3rdparty/angle/src/libEGL/Display.cpp
+++ b/src/3rdparty/angle/src/libEGL/Display.cpp
@@ -1,6 +1,5 @@
-#include "../libGLESv2/precompiled.h"
//
-// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-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.
//
@@ -14,9 +13,11 @@
#include <algorithm>
#include <map>
#include <vector>
+#include <sstream>
+#include <iterator>
#include "common/debug.h"
-#include "libGLESv2/mathutil.h"
+#include "common/mathutil.h"
#include "libGLESv2/main.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/renderer/SwapChain.h"
@@ -26,43 +27,57 @@
namespace egl
{
-namespace
+
+typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
+static DisplayMap *GetDisplayMap()
{
- typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
- DisplayMap displays;
+ static DisplayMap displays;
+ return &displays;
}
-egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
+egl::Display *Display::getDisplay(EGLNativeDisplayType displayId, EGLint displayType)
{
- if (displays.find(displayId) != displays.end())
+ DisplayMap *displays = GetDisplayMap();
+ DisplayMap::const_iterator iter = displays->find(displayId);
+ if (iter != displays->end())
{
- return displays[displayId];
+ return iter->second;
}
-
+
// FIXME: Check if displayId is a valid display device context
- egl::Display *display = new egl::Display(displayId);
+ egl::Display *display = new egl::Display(displayId, displayType);
+ displays->insert(std::make_pair(displayId, display));
- displays[displayId] = display;
return display;
}
-Display::Display(EGLNativeDisplayType displayId)
+Display::Display(EGLNativeDisplayType displayId, EGLint displayType)
+ : mDisplayId(displayId),
+ mRequestedDisplayType(displayType),
+ mRenderer(NULL)
{
- mDisplayId = displayId;
- mRenderer = NULL;
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (mDisplayId)
+ mDisplayId->AddRef();
+#endif
}
Display::~Display()
{
terminate();
- DisplayMap::iterator thisDisplay = displays.find(mDisplayId);
-
- if (thisDisplay != displays.end())
+ DisplayMap *displays = GetDisplayMap();
+ DisplayMap::iterator iter = displays->find(mDisplayId);
+ if (iter != displays->end())
{
- displays.erase(thisDisplay);
+ displays->erase(iter);
}
+
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (mDisplayId)
+ mDisplayId->Release();
+#endif
}
bool Display::initialize()
@@ -72,8 +87,8 @@ bool Display::initialize()
return true;
}
- mRenderer = glCreateRenderer(this, mDisplayId);
-
+ mRenderer = glCreateRenderer(this, mDisplayId, mRequestedDisplayType);
+
if (!mRenderer)
{
terminate();
@@ -82,16 +97,16 @@ bool Display::initialize()
EGLint minSwapInterval = mRenderer->getMinSwapInterval();
EGLint maxSwapInterval = mRenderer->getMaxSwapInterval();
- EGLint maxTextureWidth = mRenderer->getMaxTextureWidth();
- EGLint maxTextureHeight = mRenderer->getMaxTextureHeight();
+ EGLint maxTextureSize = mRenderer->getRendererCaps().max2DTextureSize;
rx::ConfigDesc *descList;
int numConfigs = mRenderer->generateConfigs(&descList);
ConfigSet configSet;
for (int i = 0; i < numConfigs; ++i)
- configSet.add(descList[i], minSwapInterval, maxSwapInterval,
- maxTextureWidth, maxTextureHeight);
+ {
+ configSet.add(descList[i], minSwapInterval, maxSwapInterval, maxTextureSize, maxTextureSize);
+ }
// Give the sorted configs a unique ID and store them internally
EGLint index = 1;
@@ -113,7 +128,7 @@ bool Display::initialize()
return false;
}
- initExtensionString();
+ initDisplayExtensionString();
initVendorString();
return true;
@@ -192,6 +207,10 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
const Config *configuration = mConfigSet.get(config);
EGLint postSubBufferSupported = EGL_FALSE;
+ EGLint width = 0;
+ EGLint height = 0;
+ EGLint fixedSize = EGL_FALSE;
+
if (attribList)
{
while (*attribList != EGL_NONE)
@@ -212,6 +231,15 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
postSubBufferSupported = attribList[1];
break;
+ case EGL_WIDTH:
+ width = attribList[1];
+ break;
+ case EGL_HEIGHT:
+ height = attribList[1];
+ break;
+ case EGL_FIXED_SIZE_ANGLE:
+ fixedSize = attribList[1];
+ break;
case EGL_VG_COLORSPACE:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
case EGL_VG_ALPHA_FORMAT:
@@ -224,6 +252,17 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
}
}
+ if (width < 0 || height < 0)
+ {
+ return error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
+ }
+
+ if (!fixedSize)
+ {
+ width = -1;
+ height = -1;
+ }
+
if (hasExistingWindowSurface(window))
{
return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
@@ -235,7 +274,7 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
return EGL_NO_SURFACE;
}
- Surface *surface = new Surface(this, configuration, window, postSubBufferSupported);
+ Surface *surface = new Surface(this, configuration, window, fixedSize, width, height, postSubBufferSupported);
if (!surface->initialize())
{
@@ -320,7 +359,7 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
}
- if (textureFormat != EGL_NO_TEXTURE && !mRenderer->getNonPower2TextureSupport() && (!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);
}
@@ -361,22 +400,29 @@ EGLSurface Display::createOffscreenSurface(EGLConfig config, HANDLE shareHandle,
return success(surface);
}
-EGLContext Display::createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess)
+EGLContext Display::createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess)
{
if (!mRenderer)
{
- return NULL;
+ return EGL_NO_CONTEXT;
}
else if (mRenderer->testDeviceLost(false)) // Lost device
{
if (!restoreLostDevice())
- return NULL;
+ {
+ return error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT);
+ }
}
- gl::Context *context = glCreateContext(shareContext, mRenderer, notifyResets, robustAccess);
+ if (clientVersion > 2 && mRenderer->getMajorShaderModel() < 4)
+ {
+ return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
+ }
+
+ gl::Context *context = glCreateContext(clientVersion, shareContext, mRenderer, notifyResets, robustAccess);
mContextSet.insert(context);
- return context;
+ return success(context);
}
bool Display::restoreLostDevice()
@@ -470,51 +516,84 @@ bool Display::hasExistingWindowSurface(EGLNativeWindowType window)
return false;
}
-void Display::initExtensionString()
+std::string Display::generateClientExtensionString()
{
- bool shareHandleSupported = mRenderer->getShareHandleSupport();
+ std::vector<std::string> extensions;
- mExtensionString = "";
+ extensions.push_back("EGL_EXT_client_extensions");
- // Multi-vendor (EXT) extensions
- mExtensionString += "EGL_EXT_create_context_robustness ";
+ extensions.push_back("ANGLE_platform_angle");
- // ANGLE-specific extensions
- if (shareHandleSupported)
+ if (supportsPlatformD3D())
{
- mExtensionString += "EGL_ANGLE_d3d_share_handle_client_buffer ";
+ extensions.push_back("ANGLE_platform_angle_d3d");
}
- mExtensionString += "EGL_ANGLE_query_surface_pointer ";
-
-#if defined(ANGLE_ENABLE_D3D9)
- HMODULE swiftShader = GetModuleHandle(TEXT("swiftshader_d3d9.dll"));
- if (swiftShader)
+ if (supportsPlatformOpenGL())
{
- mExtensionString += "EGL_ANGLE_software_display ";
+ extensions.push_back("ANGLE_platform_angle_opengl");
}
-#endif
- if (shareHandleSupported)
+ std::ostringstream stream;
+ std::copy(extensions.begin(), extensions.end(), std::ostream_iterator<std::string>(stream, " "));
+ return stream.str();
+}
+
+void Display::initDisplayExtensionString()
+{
+ std::vector<std::string> extensions;
+
+ // Multi-vendor (EXT) extensions
+ extensions.push_back("EGL_EXT_create_context_robustness");
+
+ // ANGLE-specific extensions
+ if (mRenderer->getShareHandleSupport())
{
- mExtensionString += "EGL_ANGLE_surface_d3d_texture_2d_share_handle ";
+ extensions.push_back("EGL_ANGLE_d3d_share_handle_client_buffer");
+ extensions.push_back("EGL_ANGLE_surface_d3d_texture_2d_share_handle");
}
+ extensions.push_back("EGL_ANGLE_query_surface_pointer");
+ extensions.push_back("EGL_ANGLE_window_fixed_size");
+
if (mRenderer->getPostSubBufferSupport())
{
- mExtensionString += "EGL_NV_post_sub_buffer";
+ extensions.push_back("EGL_NV_post_sub_buffer");
}
- std::string::size_type end = mExtensionString.find_last_not_of(' ');
- if (end != std::string::npos)
+ // TODO: complete support for the EGL_KHR_create_context extension
+ //extensions.push_back("EGL_KHR_create_context");
+
+ std::ostringstream stream;
+ std::copy(extensions.begin(), extensions.end(), std::ostream_iterator<std::string>(stream, " "));
+ mDisplayExtensionString = stream.str();
+}
+
+const char *Display::getExtensionString(egl::Display *display)
+{
+ if (display != EGL_NO_DISPLAY)
{
- mExtensionString.resize(end+1);
+ return display->mDisplayExtensionString.c_str();
}
+ else
+ {
+ static std::string clientExtensions = generateClientExtensionString();
+ return clientExtensions.c_str();
+ }
+}
+
+bool Display::supportsPlatformD3D()
+{
+#if defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)
+ return true;
+#else
+ return false;
+#endif
}
-const char *Display::getExtensionString() const
+bool Display::supportsPlatformOpenGL()
{
- return mExtensionString.c_str();
+ return false;
}
void Display::initVendorString()
@@ -527,7 +606,6 @@ void Display::initVendorString()
{
char adapterLuidString[64];
snprintf(adapterLuidString, sizeof(adapterLuidString), " (adapter LUID: %08x%08x)", adapterLuid.HighPart, adapterLuid.LowPart);
-
mVendorString += adapterLuidString;
}
}
diff --git a/src/3rdparty/angle/src/libEGL/Display.h b/src/3rdparty/angle/src/libEGL/Display.h
index cd07bb3388..73ba7673ff 100644
--- a/src/3rdparty/angle/src/libEGL/Display.h
+++ b/src/3rdparty/angle/src/libEGL/Display.h
@@ -33,14 +33,19 @@ class Display
bool initialize();
void terminate();
- static egl::Display *getDisplay(EGLNativeDisplayType displayId);
+ static egl::Display *getDisplay(EGLNativeDisplayType displayId, EGLint displayType);
+
+ static const char *getExtensionString(egl::Display *display);
+
+ static bool supportsPlatformD3D();
+ static bool supportsPlatformOpenGL();
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
EGLSurface createWindowSurface(EGLNativeWindowType window, EGLConfig config, const EGLint *attribList);
EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
- EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
+ EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
void destroySurface(egl::Surface *surface);
void destroyContext(gl::Context *context);
@@ -60,17 +65,18 @@ class Display
const char *getExtensionString() const;
const char *getVendorString() const;
+ EGLNativeDisplayType getDisplayId() const { return mDisplayId; }
+
private:
DISALLOW_COPY_AND_ASSIGN(Display);
- Display(EGLNativeDisplayType displayId);
+ Display(EGLNativeDisplayType displayId, EGLint displayType);
bool restoreLostDevice();
EGLNativeDisplayType mDisplayId;
+ EGLint mRequestedDisplayType;
- bool mSoftwareDevice;
-
typedef std::set<Surface*> SurfaceSet;
SurfaceSet mSurfaceSet;
@@ -81,9 +87,12 @@ class Display
rx::Renderer *mRenderer;
- void initExtensionString();
+ static std::string generateClientExtensionString();
+
+ void initDisplayExtensionString();
+ std::string mDisplayExtensionString;
+
void initVendorString();
- std::string mExtensionString;
std::string mVendorString;
};
}
diff --git a/src/3rdparty/angle/src/libEGL/Surface.cpp b/src/3rdparty/angle/src/libEGL/Surface.cpp
index a2e2306ae5..fa7996152a 100644
--- a/src/3rdparty/angle/src/libEGL/Surface.cpp
+++ b/src/3rdparty/angle/src/libEGL/Surface.cpp
@@ -1,6 +1,5 @@
-#include "../libGLESv2/precompiled.h"
//
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-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.
//
@@ -23,90 +22,20 @@
#include "libEGL/main.h"
#include "libEGL/Display.h"
-#if defined(ANGLE_OS_WINRT)
-#include <wrl.h>
-#include <windows.foundation.h>
-#include <windows.ui.core.h>
-#include <windows.graphics.display.h>
-
-static bool getCoreWindowSize(const EGLNativeWindowType win, int *width, int *height)
-{
- Microsoft::WRL::ComPtr<ABI::Windows::UI::Core::ICoreWindow> window;
- HRESULT hr = win->QueryInterface(IID_PPV_ARGS(&window));
- if (FAILED(hr))
- {
- ERR("Failed to cast native display pointer to ICoreWindow *.");
- return false;
- }
-
-#if _MSC_VER<=1700
- Microsoft::WRL::ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> displayInformation;
- hr = RoGetActivationFactory(Microsoft::WRL::Wrappers::HString::MakeReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(),
- IID_PPV_ARGS(&displayInformation));
-#else
- Microsoft::WRL::ComPtr<ABI::Windows::Graphics::Display::IDisplayInformationStatics> displayInformationFactory;
- hr = RoGetActivationFactory(Microsoft::WRL::Wrappers::HString::MakeReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(),
- IID_PPV_ARGS(&displayInformationFactory));
- if (FAILED(hr))
- {
- ERR("Failed to get display information factory.");
- return false;
- }
-
- Microsoft::WRL::ComPtr<ABI::Windows::Graphics::Display::IDisplayInformation> displayInformation;
- hr = displayInformationFactory->GetForCurrentView(&displayInformation);
-#endif
- if (FAILED(hr))
- {
- ERR("Failed to get display information.");
- return false;
- }
-
-#if defined(ANGLE_OS_WINPHONE) && _MSC_VER>=1800 // Windows Phone 8.1
- Microsoft::WRL::ComPtr<ABI::Windows::Graphics::Display::IDisplayInformation2> displayInformation2;
- hr = displayInformation.As(&displayInformation2);
- if (FAILED(hr))
- {
- ERR("Failed to get extended display information.");
- return false;
- }
-
- DOUBLE scaleFactor;
- hr = displayInformation2->get_RawPixelsPerViewPixel(&scaleFactor);
- if (FAILED(hr))
- {
- ERR("Failed to get raw pixels per view pixel.");
- return false;
- }
-#else
- ABI::Windows::Graphics::Display::ResolutionScale resolutionScale;
- hr = displayInformation->get_ResolutionScale(&resolutionScale);
- if (FAILED(hr))
- {
- ERR("Failed to get resolution scale.");
- return false;
- }
- DOUBLE scaleFactor = DOUBLE(resolutionScale) / 100.0;
-#endif
-
- ABI::Windows::Foundation::Rect windowRect;
- hr = window->get_Bounds(&windowRect);
- if (FAILED(hr))
- {
- ERR("Failed to get ICoreWindow bounds.");
- return false;
- }
-
- *width = std::floor(windowRect.Width * scaleFactor + 0.5);
- *height = std::floor(windowRect.Height * scaleFactor + 0.5);
- return true;
-}
+#if defined(ANGLE_PLATFORM_WINRT)
+# include "wrl.h"
+# include "windows.graphics.display.h"
+# include "windows.ui.core.h"
+using namespace ABI::Windows::Graphics::Display;
+using namespace ABI::Windows::Foundation;
+using namespace ABI::Windows::UI::Core;
+using namespace Microsoft::WRL;
#endif
namespace egl
{
-Surface::Surface(Display *display, const Config *config, EGLNativeWindowType window, EGLint postSubBufferSupported)
+Surface::Surface(Display *display, const Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported)
: mDisplay(display), mConfig(config), mWindow(window), mPostSubBufferSupported(postSubBufferSupported)
{
mRenderer = mDisplay->getRenderer();
@@ -120,9 +49,21 @@ Surface::Surface(Display *display, const Config *config, EGLNativeWindowType win
mRenderBuffer = EGL_BACK_BUFFER;
mSwapBehavior = EGL_BUFFER_PRESERVED;
mSwapInterval = -1;
- mWidth = -1;
- mHeight = -1;
+ mWidth = width;
+ mHeight = height;
setSwapInterval(1);
+ mFixedSize = fixedSize;
+ mSwapFlags = rx::SWAP_NORMAL;
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (mWindow)
+ mWindow->AddRef();
+ mScaleFactor = 1.0;
+ mSizeToken.value = 0;
+ mDpiToken.value = 0;
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+ mOrientationToken.value = 0;
+# endif
+#endif
subclassWindow();
}
@@ -142,16 +83,88 @@ Surface::Surface(Display *display, const Config *config, HANDLE shareHandle, EGL
mSwapBehavior = EGL_BUFFER_PRESERVED;
mSwapInterval = -1;
setSwapInterval(1);
+ // This constructor is for offscreen surfaces, which are always fixed-size.
+ mFixedSize = EGL_TRUE;
+ mSwapFlags = rx::SWAP_NORMAL;
+#if defined(ANGLE_PLATFORM_WINRT)
+ mScaleFactor = 1.0;
+ mSizeToken.value = 0;
+ mDpiToken.value = 0;
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+ mOrientationToken.value = 0;
+# endif
+#endif
}
Surface::~Surface()
{
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (mSizeToken.value) {
+ ComPtr<ICoreWindow> coreWindow;
+ HRESULT hr = mWindow->QueryInterface(coreWindow.GetAddressOf());
+ ASSERT(SUCCEEDED(hr));
+
+ hr = coreWindow->remove_SizeChanged(mSizeToken);
+ ASSERT(SUCCEEDED(hr));
+ }
+ if (mDpiToken.value) {
+ ComPtr<IDisplayInformation> displayInformation;
+ HRESULT hr = mDisplay->getDisplayId()->QueryInterface(displayInformation.GetAddressOf());
+ ASSERT(SUCCEEDED(hr));
+
+ hr = displayInformation->remove_DpiChanged(mDpiToken);
+ ASSERT(SUCCEEDED(hr));
+ }
+# if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ if (mOrientationToken.value) {
+ ComPtr<IDisplayInformation> displayInformation;
+ HRESULT hr = mDisplay->getDisplayId()->QueryInterface(displayInformation.GetAddressOf());
+ ASSERT(SUCCEEDED(hr));
+
+ hr = displayInformation->remove_OrientationChanged(mOrientationToken);
+ ASSERT(SUCCEEDED(hr));
+ }
+# endif
+#endif
unsubclassWindow();
release();
}
bool Surface::initialize()
{
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (!mFixedSize) {
+ HRESULT hr;
+ ComPtr<IDisplayInformation> displayInformation;
+ hr = mDisplay->getDisplayId()->QueryInterface(displayInformation.GetAddressOf());
+ ASSERT(SUCCEEDED(hr));
+ onDpiChanged(displayInformation.Get(), 0);
+ hr = displayInformation->add_DpiChanged(Callback<ITypedEventHandler<DisplayInformation *, IInspectable *>>(this, &Surface::onDpiChanged).Get(),
+ &mDpiToken);
+ ASSERT(SUCCEEDED(hr));
+
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+ onOrientationChanged(displayInformation.Get(), 0);
+ hr = displayInformation->add_OrientationChanged(Callback<ITypedEventHandler<DisplayInformation *, IInspectable *>>(this, &Surface::onOrientationChanged).Get(),
+ &mOrientationToken);
+ ASSERT(SUCCEEDED(hr));
+# endif
+
+ ComPtr<ICoreWindow> coreWindow;
+ hr = mWindow->QueryInterface(coreWindow.GetAddressOf());
+ ASSERT(SUCCEEDED(hr));
+
+ Rect rect;
+ hr = coreWindow->get_Bounds(&rect);
+ ASSERT(SUCCEEDED(hr));
+ mWidth = rect.Width * mScaleFactor;
+ mHeight = rect.Height * mScaleFactor;
+ hr = coreWindow->add_SizeChanged(Callback<ITypedEventHandler<CoreWindow *, WindowSizeChangedEventArgs *>>(this, &Surface::onSizeChanged).Get(),
+ &mSizeToken);
+ ASSERT(SUCCEEDED(hr));
+ }
+#endif
+
if (!resetSwapChain())
return false;
@@ -168,6 +181,11 @@ void Surface::release()
mTexture->releaseTexImage();
mTexture = NULL;
}
+
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (mWindow)
+ mWindow->Release();
+#endif
}
bool Surface::resetSwapChain()
@@ -177,9 +195,9 @@ bool Surface::resetSwapChain()
int width;
int height;
- if (mWindow)
+#if !defined(ANGLE_PLATFORM_WINRT)
+ if (!mFixedSize)
{
-#if !defined(ANGLE_OS_WINRT)
RECT windowRect;
if (!GetClientRect(getWindowHandle(), &windowRect))
{
@@ -191,14 +209,9 @@ bool Surface::resetSwapChain()
width = windowRect.right - windowRect.left;
height = windowRect.bottom - windowRect.top;
-#else
- if (!getCoreWindowSize(mWindow, &width, &height))
- {
- return false;
- }
-#endif
}
else
+#endif
{
// non-window surface - size is determined at creation
width = mWidth;
@@ -228,7 +241,7 @@ bool Surface::resizeSwapChain(int backbufferWidth, int backbufferHeight)
ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
ASSERT(mSwapChain);
- EGLint status = mSwapChain->resize(backbufferWidth, backbufferHeight);
+ EGLint status = mSwapChain->resize(std::max(1, backbufferWidth), std::max(1, backbufferHeight));
if (status == EGL_CONTEXT_LOST)
{
@@ -251,7 +264,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
ASSERT(backbufferWidth >= 0 && backbufferHeight >= 0);
ASSERT(mSwapChain);
- EGLint status = mSwapChain->reset(backbufferWidth, backbufferHeight, mSwapInterval);
+ EGLint status = mSwapChain->reset(std::max(1, backbufferWidth), std::max(1, backbufferHeight), mSwapInterval);
if (status == EGL_CONTEXT_LOST)
{
@@ -292,7 +305,7 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
return true;
}
- EGLint status = mSwapChain->swapRect(x, y, width, height);
+ EGLint status = mSwapChain->swapRect(x, y, width, height, mSwapFlags);
if (status == EGL_CONTEXT_LOST)
{
@@ -318,7 +331,7 @@ EGLNativeWindowType Surface::getWindowHandle()
#define kSurfaceProperty _TEXT("Egl::SurfaceOwner")
#define kParentWndProc _TEXT("Egl::SurfaceParentWndProc")
-#if !defined(ANGLE_OS_WINRT)
+#if !defined(ANGLE_PLATFORM_WINRT)
static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
if (message == WM_SIZE)
@@ -336,9 +349,7 @@ static LRESULT CALLBACK SurfaceWindowProc(HWND hwnd, UINT message, WPARAM wparam
void Surface::subclassWindow()
{
-#if defined(ANGLE_OS_WINRT)
- mWindowSubclassed = false;
-#else
+#if !defined(ANGLE_PLATFORM_WINRT)
if (!mWindow)
{
return;
@@ -362,12 +373,14 @@ void Surface::subclassWindow()
SetProp(mWindow, kSurfaceProperty, reinterpret_cast<HANDLE>(this));
SetProp(mWindow, kParentWndProc, reinterpret_cast<HANDLE>(oldWndProc));
mWindowSubclassed = true;
+#else
+ mWindowSubclassed = false;
#endif
}
void Surface::unsubclassWindow()
{
-#if !defined(ANGLE_OS_WINRT)
+#if !defined(ANGLE_PLATFORM_WINRT)
if(!mWindowSubclassed)
{
return;
@@ -384,6 +397,7 @@ void Surface::unsubclassWindow()
if(parentWndFunc)
{
LONG_PTR prevWndFunc = SetWindowLongPtr(mWindow, GWLP_WNDPROC, parentWndFunc);
+ UNUSED_ASSERTION_VARIABLE(prevWndFunc);
ASSERT(prevWndFunc == reinterpret_cast<LONG_PTR>(SurfaceWindowProc));
}
@@ -395,33 +409,25 @@ void Surface::unsubclassWindow()
bool Surface::checkForOutOfDateSwapChain()
{
-#if !defined(ANGLE_OS_WINRT)
- RECT client;
- if (!GetClientRect(getWindowHandle(), &client))
- {
- ASSERT(false);
- return false;
- }
-
- // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information.
- int clientWidth = client.right - client.left;
- int clientHeight = client.bottom - client.top;
-#else
- int clientWidth;
- int clientHeight;
- if (!getCoreWindowSize(mWindow, &clientWidth, &clientHeight))
- {
- return false;
- }
-#endif
- bool sizeDirty = clientWidth != getWidth() || clientHeight != getHeight();
-
-#if !defined(ANGLE_OS_WINRT)
- if (IsIconic(getWindowHandle()))
+ int clientWidth = getWidth();
+ int clientHeight = getHeight();
+ bool sizeDirty = false;
+#if !defined(ANGLE_PLATFORM_WINRT)
+ if (!mFixedSize && !IsIconic(getWindowHandle()))
{
+ RECT client;
// The window is automatically resized to 150x22 when it's minimized, but the swapchain shouldn't be resized
// because that's not a useful size to render to.
- sizeDirty = false;
+ if (!GetClientRect(getWindowHandle(), &client))
+ {
+ ASSERT(false);
+ return false;
+ }
+
+ // Grow the buffer now, if the window has grown. We need to grow now to avoid losing information.
+ clientWidth = client.right - client.left;
+ clientHeight = client.bottom - client.top;
+ sizeDirty = clientWidth != getWidth() || clientHeight != getHeight();
}
#endif
@@ -461,18 +467,8 @@ bool Surface::postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height)
// Spec is not clear about how this should be handled.
return true;
}
-
- return swapRect(x, y, width, height);
-}
-
-EGLint Surface::getWidth() const
-{
- return mWidth;
-}
-EGLint Surface::getHeight() const
-{
- return mHeight;
+ return swapRect(x, y, width, height);
}
EGLint Surface::isPostSubBufferSupported() const
@@ -491,7 +487,7 @@ void Surface::setSwapInterval(EGLint interval)
{
return;
}
-
+
mSwapInterval = interval;
mSwapInterval = std::max(mSwapInterval, mRenderer->getMinSwapInterval());
mSwapInterval = std::min(mSwapInterval, mRenderer->getMaxSwapInterval());
@@ -499,6 +495,36 @@ void Surface::setSwapInterval(EGLint interval)
mSwapIntervalDirty = true;
}
+EGLint Surface::getConfigID() const
+{
+ return mConfig->mConfigID;
+}
+
+EGLint Surface::getWidth() const
+{
+ return mWidth;
+}
+
+EGLint Surface::getHeight() const
+{
+ return mHeight;
+}
+
+EGLint Surface::getPixelAspectRatio() const
+{
+ return mPixelAspectRatio;
+}
+
+EGLenum Surface::getRenderBuffer() const
+{
+ return mRenderBuffer;
+}
+
+EGLenum Surface::getSwapBehavior() const
+{
+ return mSwapBehavior;
+}
+
EGLenum Surface::getTextureFormat() const
{
return mTextureFormat;
@@ -519,8 +545,82 @@ gl::Texture2D *Surface::getBoundTexture() const
return mTexture;
}
+EGLint Surface::isFixedSize() const
+{
+ return mFixedSize;
+}
+
EGLenum Surface::getFormat() const
{
return mConfig->mRenderTargetFormat;
}
+
+#if defined(ANGLE_PLATFORM_WINRT)
+
+HRESULT Surface::onSizeChanged(ICoreWindow *, IWindowSizeChangedEventArgs *args)
+{
+ HRESULT hr;
+ Size size;
+ hr = args->get_Size(&size);
+ ASSERT(SUCCEEDED(hr));
+
+ resizeSwapChain(std::floor(size.Width * mScaleFactor + 0.5),
+ std::floor(size.Height * mScaleFactor + 0.5));
+
+ if (static_cast<egl::Surface*>(getCurrentDrawSurface()) == this)
+ {
+ glMakeCurrent(glGetCurrentContext(), static_cast<egl::Display*>(getCurrentDisplay()), this);
+ }
+
+ return S_OK;
+}
+
+HRESULT Surface::onDpiChanged(IDisplayInformation *displayInformation, IInspectable *)
+{
+ HRESULT hr;
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+ ComPtr<IDisplayInformation2> displayInformation2;
+ hr = displayInformation->QueryInterface(displayInformation2.GetAddressOf());
+ ASSERT(SUCCEEDED(hr));
+
+ hr = displayInformation2->get_RawPixelsPerViewPixel(&mScaleFactor);
+ ASSERT(SUCCEEDED(hr));
+# else
+ ResolutionScale resolutionScale;
+ hr = displayInformation->get_ResolutionScale(&resolutionScale);
+ ASSERT(SUCCEEDED(hr));
+
+ mScaleFactor = double(resolutionScale) / 100.0;
+# endif
+ return S_OK;
+}
+
+# if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+HRESULT Surface::onOrientationChanged(IDisplayInformation *displayInformation, IInspectable *)
+{
+ HRESULT hr;
+ DisplayOrientations orientation;
+ hr = displayInformation->get_CurrentOrientation(&orientation);
+ ASSERT(SUCCEEDED(hr));
+ switch (orientation) {
+ default:
+ case DisplayOrientations_Portrait:
+ mSwapFlags = rx::SWAP_NORMAL;
+ break;
+ case DisplayOrientations_Landscape:
+ mSwapFlags = rx::SWAP_ROTATE_90;
+ break;
+ case DisplayOrientations_LandscapeFlipped:
+ mSwapFlags = rx::SWAP_ROTATE_270;
+ break;
+ case DisplayOrientations_PortraitFlipped:
+ mSwapFlags = rx::SWAP_ROTATE_180;
+ break;
+ }
+ return S_OK;
+}
+# endif
+
+#endif
+
}
diff --git a/src/3rdparty/angle/src/libEGL/Surface.h b/src/3rdparty/angle/src/libEGL/Surface.h
index 1d2303c6eb..ebffce8fed 100644
--- a/src/3rdparty/angle/src/libEGL/Surface.h
+++ b/src/3rdparty/angle/src/libEGL/Surface.h
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-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.
//
@@ -11,11 +11,24 @@
#ifndef LIBEGL_SURFACE_H_
#define LIBEGL_SURFACE_H_
-#define EGLAPI
#include <EGL/egl.h>
#include "common/angleutils.h"
+#if defined(ANGLE_PLATFORM_WINRT)
+#include <EventToken.h>
+namespace ABI { namespace Windows {
+ namespace UI { namespace Core {
+ struct ICoreWindow;
+ struct IWindowSizeChangedEventArgs;
+ } }
+ namespace Graphics { namespace Display {
+ struct IDisplayInformation;
+ } }
+} }
+struct IInspectable;
+#endif
+
namespace gl
{
class Texture2D;
@@ -34,10 +47,10 @@ class Config;
class Surface
{
public:
- Surface(Display *display, const egl::Config *config, EGLNativeWindowType window, EGLint postSubBufferSupported);
+ Surface(Display *display, const egl::Config *config, EGLNativeWindowType window, EGLint fixedSize, EGLint width, EGLint height, EGLint postSubBufferSupported);
Surface(Display *display, const egl::Config *config, HANDLE shareHandle, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget);
- ~Surface();
+ virtual ~Surface();
bool initialize();
void release();
@@ -47,9 +60,6 @@ class Surface
bool swap();
bool postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
- virtual EGLint getWidth() const;
- virtual EGLint getHeight() const;
-
virtual EGLint isPostSubBufferSupported() const;
virtual rx::SwapChain *getSwapChain() const;
@@ -57,6 +67,12 @@ class Surface
void setSwapInterval(EGLint interval);
bool checkForOutOfDateSwapChain(); // Returns true if swapchain changed due to resize or interval update
+ virtual EGLint getConfigID() const;
+ virtual EGLint getWidth() const;
+ virtual EGLint getHeight() const;
+ virtual EGLint getPixelAspectRatio() const;
+ virtual EGLenum getRenderBuffer() const;
+ virtual EGLenum getSwapBehavior() const;
virtual EGLenum getTextureFormat() const;
virtual EGLenum getTextureTarget() const;
virtual EGLenum getFormat() const;
@@ -64,9 +80,19 @@ class Surface
virtual void setBoundTexture(gl::Texture2D *texture);
virtual gl::Texture2D *getBoundTexture() const;
+ EGLint isFixedSize() const;
+
private:
DISALLOW_COPY_AND_ASSIGN(Surface);
+#if defined(ANGLE_PLATFORM_WINRT)
+ HRESULT onSizeChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *);
+ HRESULT onDpiChanged(ABI::Windows::Graphics::Display::IDisplayInformation *, IInspectable *);
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+ HRESULT onOrientationChanged(ABI::Windows::Graphics::Display::IDisplayInformation *, IInspectable *);
+# endif
+#endif
+
Display *const mDisplay;
rx::Renderer *mRenderer;
@@ -79,7 +105,7 @@ private:
bool resetSwapChain(int backbufferWidth, int backbufferHeight);
bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
- const EGLNativeWindowType mWindow; // Window that the surface is created for.
+ const EGLNativeWindowType mWindow; // Window that the surface is created for.
bool mWindowSubclassed; // Indicates whether we successfully subclassed mWindow for WM_RESIZE hooking
const egl::Config *mConfig; // EGL config surface was created with
EGLint mHeight; // Height of surface
@@ -99,9 +125,19 @@ private:
// EGLenum vgColorSpace; // Color space for OpenVG
EGLint mSwapInterval;
EGLint mPostSubBufferSupported;
-
+ EGLint mFixedSize;
+ EGLint mSwapFlags;
+
bool mSwapIntervalDirty;
gl::Texture2D *mTexture;
+#if defined(ANGLE_PLATFORM_WINRT)
+ double mScaleFactor;
+ EventRegistrationToken mSizeToken;
+ EventRegistrationToken mDpiToken;
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+ EventRegistrationToken mOrientationToken;
+# endif
+#endif
};
}
diff --git a/src/3rdparty/angle/src/libEGL/libEGL.cpp b/src/3rdparty/angle/src/libEGL/libEGL.cpp
index b2944d5c0d..a08e1edeab 100644
--- a/src/3rdparty/angle/src/libEGL/libEGL.cpp
+++ b/src/3rdparty/angle/src/libEGL/libEGL.cpp
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2002-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.
//
@@ -10,6 +10,7 @@
#include "common/debug.h"
#include "common/version.h"
+#include "common/platform.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/main.h"
@@ -99,99 +100,139 @@ EGLDisplay __stdcall eglGetDisplay(EGLNativeDisplayType display_id)
{
EVENT("(EGLNativeDisplayType display_id = 0x%0.8p)", display_id);
- try
+ return egl::Display::getDisplay(display_id, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
+}
+
+EGLDisplay __stdcall eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list)
+{
+ EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
+ platform, native_display, attrib_list);
+
+ switch (platform)
{
- return egl::Display::getDisplay(display_id);
+ case EGL_PLATFORM_ANGLE_ANGLE:
+ break;
+
+ default:
+ return egl::error(EGL_BAD_CONFIG, EGL_NO_DISPLAY);
}
- catch(std::bad_alloc&)
+
+ EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display);
+#if !defined(ANGLE_PLATFORM_WINRT)
+ // Validate the display device context
+ if (WindowFromDC(displayId) == NULL)
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_DISPLAY);
+ return egl::success(EGL_NO_DISPLAY);
}
-}
-
-EGLBoolean __stdcall eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
-{
- EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)",
- dpy, major, minor);
+#endif
- try
+ EGLint requestedDisplayType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
+ if (attrib_list)
{
- if (dpy == EGL_NO_DISPLAY)
+ for (const EGLint *curAttrib = attrib_list; curAttrib[0] != EGL_NONE; curAttrib += 2)
{
- return egl::error(EGL_BAD_DISPLAY, EGL_FALSE);
+ switch (curAttrib[0])
+ {
+ case EGL_PLATFORM_ANGLE_TYPE_ANGLE:
+ requestedDisplayType = curAttrib[1];
+ break;
+
+ default:
+ break;
+ }
}
+ }
- egl::Display *display = static_cast<egl::Display*>(dpy);
+ switch (requestedDisplayType)
+ {
+ case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
+ break;
- if (!display->initialize())
+ case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
+ case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
+ case EGL_PLATFORM_ANGLE_TYPE_D3D11_WARP_ANGLE:
+ if (!egl::Display::supportsPlatformD3D())
{
- return egl::error(EGL_NOT_INITIALIZED, EGL_FALSE);
+ return egl::success(EGL_NO_DISPLAY);
}
+ break;
- if (major) *major = 1;
- if (minor) *minor = 4;
+ case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
+ case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
+ if (!egl::Display::supportsPlatformOpenGL())
+ {
+ return egl::success(EGL_NO_DISPLAY);
+ }
+ break;
- return egl::success(EGL_TRUE);
+ default:
+ return egl::success(EGL_NO_DISPLAY);
}
- catch(std::bad_alloc&)
+
+ return egl::Display::getDisplay(displayId, requestedDisplayType);
+}
+
+EGLBoolean __stdcall eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+ EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)",
+ dpy, major, minor);
+
+ if (dpy == EGL_NO_DISPLAY)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_DISPLAY, EGL_FALSE);
}
+
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+
+ if (!display->initialize())
+ {
+ return egl::error(EGL_NOT_INITIALIZED, EGL_FALSE);
+ }
+
+ if (major) *major = 1;
+ if (minor) *minor = 4;
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglTerminate(EGLDisplay dpy)
{
EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy);
- try
+ if (dpy == EGL_NO_DISPLAY)
{
- if (dpy == EGL_NO_DISPLAY)
- {
- return egl::error(EGL_BAD_DISPLAY, EGL_FALSE);
- }
+ return egl::error(EGL_BAD_DISPLAY, 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);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(EGL_TRUE);
}
const char *__stdcall eglQueryString(EGLDisplay dpy, EGLint name)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint name = %d)", dpy, name);
- try
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ if (!(display == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) && !validateDisplay(display))
{
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- if (!validateDisplay(display))
- {
- return NULL;
- }
-
- switch (name)
- {
- case EGL_CLIENT_APIS:
- return egl::success("OpenGL_ES");
- case EGL_EXTENSIONS:
- return egl::success(display->getExtensionString());
- case EGL_VENDOR:
- return egl::success(display->getVendorString());
- case EGL_VERSION:
- return egl::success("1.4 (ANGLE " ANGLE_VERSION_STRING ")");
- }
-
- return egl::error(EGL_BAD_PARAMETER, (const char*)NULL);
+ return NULL;
}
- catch(std::bad_alloc&)
+
+ switch (name)
{
- return egl::error(EGL_BAD_ALLOC, (const char*)NULL);
+ case EGL_CLIENT_APIS:
+ return egl::success("OpenGL_ES");
+ case EGL_EXTENSIONS:
+ return egl::success(egl::Display::getExtensionString(display));
+ case EGL_VENDOR:
+ return egl::success(display->getVendorString());
+ case EGL_VERSION:
+ return egl::success("1.4 (ANGLE " ANGLE_VERSION_STRING ")");
+ default:
+ return egl::error(EGL_BAD_PARAMETER, (const char*)NULL);
}
}
@@ -201,33 +242,26 @@ EGLBoolean __stdcall eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint co
"EGLint config_size = %d, EGLint *num_config = 0x%0.8p)",
dpy, configs, config_size, num_config);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- if (!validateDisplay(display))
- {
- return EGL_FALSE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (!num_config)
- {
- return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
- }
+ if (!validateDisplay(display))
+ {
+ return EGL_FALSE;
+ }
- const EGLint attribList[] = {EGL_NONE};
+ if (!num_config)
+ {
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
+ }
- if (!display->getConfigs(configs, attribList, config_size, num_config))
- {
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
- }
+ const EGLint attribList[] = {EGL_NONE};
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
+ if (!display->getConfigs(configs, attribList, config_size, num_config))
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
}
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)
@@ -236,35 +270,28 @@ EGLBoolean __stdcall eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
"EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)",
dpy, attrib_list, configs, config_size, num_config);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- if (!validateDisplay(display))
- {
- return EGL_FALSE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (!num_config)
- {
- return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
- }
-
- const EGLint attribList[] = {EGL_NONE};
+ if (!validateDisplay(display))
+ {
+ return EGL_FALSE;
+ }
- if (!attrib_list)
- {
- attrib_list = attribList;
- }
+ if (!num_config)
+ {
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
+ }
- display->getConfigs(configs, attrib_list, config_size, num_config);
+ const EGLint attribList[] = {EGL_NONE};
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
+ if (!attrib_list)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ attrib_list = attribList;
}
+
+ display->getConfigs(configs, attrib_list, config_size, num_config);
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)
@@ -272,26 +299,19 @@ EGLBoolean __stdcall eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
dpy, config, attribute, value);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- if (!validateConfig(display, config))
- {
- return EGL_FALSE;
- }
-
- if (!display->getConfigAttrib(config, attribute, value))
- {
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- return egl::success(EGL_TRUE);
+ if (!validateConfig(display, config))
+ {
+ return EGL_FALSE;
}
- catch(std::bad_alloc&)
+
+ if (!display->getConfigAttrib(config, attribute, value))
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
}
+
+ return egl::success(EGL_TRUE);
}
EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
@@ -299,30 +319,23 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, "
"const EGLint *attrib_list = 0x%0.8p)", dpy, config, win, attrib_list);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (!validateConfig(display, config))
- {
- return EGL_NO_SURFACE;
- }
-
-#if !defined(ANGLE_OS_WINRT)
- HWND window = (HWND)win;
+ if (!validateConfig(display, config))
+ {
+ return EGL_NO_SURFACE;
+ }
- if (!IsWindow(window))
- {
- return egl::error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
- }
-#endif
+#if !defined(ANGLE_PLATFORM_WINRT)
+ HWND window = (HWND)win;
- return display->createWindowSurface(win, config, attrib_list);
- }
- catch(std::bad_alloc&)
+ if (!IsWindow(window))
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+ return egl::error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
}
+#endif
+
+ return display->createWindowSurface(win, config, attrib_list);
}
EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
@@ -330,21 +343,14 @@ EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, c
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
dpy, config, attrib_list);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- if (!validateConfig(display, config))
- {
- return EGL_NO_SURFACE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- return display->createOffscreenSurface(config, NULL, attrib_list);
- }
- catch(std::bad_alloc&)
+ if (!validateConfig(display, config))
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+ return EGL_NO_SURFACE;
}
+
+ return display->createOffscreenSurface(config, NULL, attrib_list);
}
EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
@@ -352,52 +358,38 @@ EGLSurface __stdcall eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EG
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativePixmapType pixmap = 0x%0.8p, "
"const EGLint *attrib_list = 0x%0.8p)", dpy, config, pixmap, attrib_list);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (!validateConfig(display, config))
- {
- return EGL_NO_SURFACE;
- }
-
- UNIMPLEMENTED(); // FIXME
-
- return egl::success(EGL_NO_SURFACE);
- }
- catch(std::bad_alloc&)
+ if (!validateConfig(display, config))
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+ return EGL_NO_SURFACE;
}
+
+ UNIMPLEMENTED(); // FIXME
+
+ return egl::success(EGL_NO_SURFACE);
}
EGLBoolean __stdcall eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
-
- if (surface == EGL_NO_SURFACE)
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
-
- display->destroySurface((egl::Surface*)surface);
-
- return egl::success(EGL_TRUE);
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
}
- catch(std::bad_alloc&)
+
+ if (surface == EGL_NO_SURFACE)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
}
+
+ display->destroySurface((egl::Surface*)surface);
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
@@ -405,84 +397,80 @@ EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
dpy, surface, attribute, value);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = (egl::Surface*)surface;
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = (egl::Surface*)surface;
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
-
- if (surface == EGL_NO_SURFACE)
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
-
- switch (attribute)
- {
- case EGL_VG_ALPHA_FORMAT:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_VG_COLORSPACE:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_CONFIG_ID:
- UNIMPLEMENTED(); // FIXME
- 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:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_RENDER_BUFFER:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_SWAP_BEHAVIOR:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_TEXTURE_FORMAT:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_TEXTURE_TARGET:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_VERTICAL_RESOLUTION:
- UNIMPLEMENTED(); // FIXME
- break;
- case EGL_WIDTH:
- *value = eglSurface->getWidth();
- break;
- case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
- *value = eglSurface->isPostSubBufferSupported();
- break;
- default:
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
- }
-
- return egl::success(EGL_TRUE);
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
}
- catch(std::bad_alloc&)
+
+ if (surface == EGL_NO_SURFACE)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_SURFACE, 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->getConfigID();
+ 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:
+ *value = eglSurface->isPostSubBufferSupported();
+ break;
+ case EGL_FIXED_SIZE_ANGLE:
+ *value = eglSurface->isFixedSize();
+ break;
+ default:
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+ }
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value)
@@ -490,114 +478,79 @@ EGLBoolean __stdcall eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surf
TRACE("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)",
dpy, surface, attribute, value);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = (egl::Surface*)surface;
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = (egl::Surface*)surface;
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
+ }
- if (surface == EGL_NO_SURFACE)
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
+ if (surface == EGL_NO_SURFACE)
+ {
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
+ }
- switch (attribute)
+ switch (attribute)
+ {
+ case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
{
- case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
- {
- rx::SwapChain *swapchain = eglSurface->getSwapChain();
- *value = (void*) (swapchain ? swapchain->getShareHandle() : NULL);
- }
- break;
- default:
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
+ rx::SwapChain *swapchain = eglSurface->getSwapChain();
+ *value = (void*) (swapchain ? swapchain->getShareHandle() : NULL);
}
-
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ break;
+ default:
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
}
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglBindAPI(EGLenum api)
{
EVENT("(EGLenum api = 0x%X)", api);
- try
+ switch (api)
{
- switch (api)
- {
- case EGL_OPENGL_API:
- case EGL_OPENVG_API:
- return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); // Not supported by this implementation
- case EGL_OPENGL_ES_API:
- break;
- default:
- return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
- }
+ case EGL_OPENGL_API:
+ case EGL_OPENVG_API:
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE); // Not supported by this implementation
+ case EGL_OPENGL_ES_API:
+ break;
+ default:
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
+ }
- egl::setCurrentAPI(api);
+ egl::setCurrentAPI(api);
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(EGL_TRUE);
}
EGLenum __stdcall eglQueryAPI(void)
{
EVENT("()");
- try
- {
- EGLenum API = egl::getCurrentAPI();
+ EGLenum API = egl::getCurrentAPI();
- return egl::success(API);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(API);
}
EGLBoolean __stdcall eglWaitClient(void)
{
EVENT("()");
- try
- {
- UNIMPLEMENTED(); // FIXME
+ UNIMPLEMENTED(); // FIXME
- return egl::success(0);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(0);
}
EGLBoolean __stdcall eglReleaseThread(void)
{
EVENT("()");
- try
- {
- 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);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(EGL_TRUE);
}
EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list)
@@ -606,26 +559,19 @@ EGLSurface __stdcall eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum bu
"EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
dpy, buftype, buffer, config, attrib_list);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- if (!validateConfig(display, config))
- {
- return EGL_NO_SURFACE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE || !buffer)
- {
- return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
- }
-
- return display->createOffscreenSurface(config, (HANDLE)buffer, attrib_list);
+ if (!validateConfig(display, config))
+ {
+ return EGL_NO_SURFACE;
}
- catch(std::bad_alloc&)
+
+ if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE || !buffer)
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+ return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
}
+
+ return display->createOffscreenSurface(config, (HANDLE)buffer, attrib_list);
}
EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value)
@@ -633,145 +579,117 @@ EGLBoolean __stdcall eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint value = %d)",
dpy, surface, attribute, value);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
-
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
-
- UNIMPLEMENTED(); // FIXME
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
+ if (!validateSurface(display, eglSurface))
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return EGL_FALSE;
}
+
+ UNIMPLEMENTED(); // FIXME
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
-
- if (buffer != EGL_BACK_BUFFER)
- {
- return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
- }
-
- if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
+ }
- if (eglSurface->getBoundTexture())
- {
- return egl::error(EGL_BAD_ACCESS, EGL_FALSE);
- }
+ if (buffer != EGL_BACK_BUFFER)
+ {
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
+ }
- if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
- {
- return egl::error(EGL_BAD_MATCH, EGL_FALSE);
- }
+ if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
+ {
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
+ }
- if (!glBindTexImage(eglSurface))
- {
- return egl::error(EGL_BAD_MATCH, EGL_FALSE);
- }
+ if (eglSurface->getBoundTexture())
+ {
+ return egl::error(EGL_BAD_ACCESS, EGL_FALSE);
+ }
- return egl::success(EGL_TRUE);
+ if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
+ {
+ return egl::error(EGL_BAD_MATCH, EGL_FALSE);
}
- catch(std::bad_alloc&)
+
+ if (!glBindTexImage(eglSurface))
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_MATCH, EGL_FALSE);
}
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
-
- if (buffer != EGL_BACK_BUFFER)
- {
- return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
- }
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
+ }
- if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
+ if (buffer != EGL_BACK_BUFFER)
+ {
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
+ }
- if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
- {
- return egl::error(EGL_BAD_MATCH, EGL_FALSE);
- }
+ if (surface == EGL_NO_SURFACE || eglSurface->getWindowHandle())
+ {
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
+ }
- gl::Texture2D *texture = eglSurface->getBoundTexture();
+ if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
+ {
+ return egl::error(EGL_BAD_MATCH, EGL_FALSE);
+ }
- if (texture)
- {
- texture->releaseTexImage();
- }
+ gl::Texture2D *texture = eglSurface->getBoundTexture();
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
+ if (texture)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ texture->releaseTexImage();
}
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglSwapInterval(EGLDisplay dpy, EGLint interval)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint interval = %d)", dpy, interval);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (!validateDisplay(display))
- {
- return EGL_FALSE;
- }
-
- egl::Surface *draw_surface = static_cast<egl::Surface*>(egl::getCurrentDrawSurface());
+ if (!validateDisplay(display))
+ {
+ return EGL_FALSE;
+ }
- if (draw_surface == NULL)
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
-
- draw_surface->setSwapInterval(interval);
+ egl::Surface *draw_surface = static_cast<egl::Surface*>(egl::getCurrentDrawSurface());
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
+ if (draw_surface == NULL)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
}
+
+ draw_surface->setSwapInterval(interval);
+
+ return egl::success(EGL_TRUE);
}
EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
@@ -779,108 +697,97 @@ EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLConte
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, "
"const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list);
- try
- {
- // Get the requested client version (default is 1) and check it is two.
- EGLint client_version = 1;
- bool reset_notification = false;
- bool robust_access = false;
+ // Get the requested client version (default is 1) and check it is 2 or 3.
+ EGLint client_version = 1;
+ bool reset_notification = false;
+ bool robust_access = false;
- if (attrib_list)
+ if (attrib_list)
+ {
+ for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2)
{
- for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2)
+ switch (attribute[0])
{
- switch (attribute[0])
+ case EGL_CONTEXT_CLIENT_VERSION:
+ client_version = attribute[1];
+ break;
+ case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
+ if (attribute[1] == EGL_TRUE)
{
- case EGL_CONTEXT_CLIENT_VERSION:
- client_version = attribute[1];
- break;
- case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
- if (attribute[1] == EGL_TRUE)
- {
- return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); // Unimplemented
- // robust_access = true;
- }
- else if (attribute[1] != EGL_FALSE)
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
- break;
- case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
- if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT)
- reset_notification = true;
- else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT)
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
- break;
- default:
- return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
+ return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT); // Unimplemented
+ // robust_access = true;
}
+ else if (attribute[1] != EGL_FALSE)
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
+ break;
+ case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
+ if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT)
+ reset_notification = true;
+ else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT)
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
+ break;
+ default:
+ return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
}
}
+ }
- if (client_version != 2)
- {
- return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
- }
+ if (client_version != 2 && client_version != 3)
+ {
+ return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
+ }
- gl::Context *sharedContextPtr = (share_context != EGL_NO_CONTEXT ? static_cast<gl::Context*>(share_context) : NULL);
+ egl::Display *display = static_cast<egl::Display*>(dpy);
- if (sharedContextPtr != NULL && sharedContextPtr->isResetNotificationEnabled() != reset_notification)
+ if (share_context)
+ {
+ gl::Context* sharedGLContext = static_cast<gl::Context*>(share_context);
+
+ if (sharedGLContext->isResetNotificationEnabled() != reset_notification)
{
return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
}
- egl::Display *display = static_cast<egl::Display*>(dpy);
-
- // Can not share contexts between displays
- if (sharedContextPtr != NULL && sharedContextPtr->getRenderer() != display->getRenderer())
+ if (sharedGLContext->getClientVersion() != client_version)
{
- return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
+ return egl::error(EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
}
- if (!validateConfig(display, config))
+ // Can not share contexts between displays
+ if (sharedGLContext->getRenderer() != display->getRenderer())
{
- return EGL_NO_CONTEXT;
+ return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
}
-
- EGLContext context = display->createContext(config, static_cast<gl::Context*>(share_context), reset_notification, robust_access);
-
- if (context)
- return egl::success(context);
- else
- return egl::error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT);
}
- catch(std::bad_alloc&)
+
+ if (!validateConfig(display, config))
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
+ return EGL_NO_CONTEXT;
}
+
+ return display->createContext(config, client_version, static_cast<gl::Context*>(share_context), reset_notification, robust_access);
}
EGLBoolean __stdcall eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p)", dpy, ctx);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- gl::Context *context = static_cast<gl::Context*>(ctx);
-
- if (!validateContext(display, context))
- {
- return EGL_FALSE;
- }
-
- if (ctx == EGL_NO_CONTEXT)
- {
- return egl::error(EGL_BAD_CONTEXT, EGL_FALSE);
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ gl::Context *context = static_cast<gl::Context*>(ctx);
- display->destroyContext(context);
-
- return egl::success(EGL_TRUE);
+ if (!validateContext(display, context))
+ {
+ return EGL_FALSE;
}
- catch(std::bad_alloc&)
+
+ if (ctx == EGL_NO_CONTEXT)
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_BAD_CONTEXT, EGL_FALSE);
}
+
+ display->destroyContext(context);
+
+ return egl::success(EGL_TRUE);
}
EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
@@ -888,95 +795,74 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)",
dpy, draw, read, ctx);
- try
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ gl::Context *context = static_cast<gl::Context*>(ctx);
+
+ if (ctx != EGL_NO_CONTEXT && !validateContext(display, context))
{
- egl::Display *display = static_cast<egl::Display*>(dpy);
- gl::Context *context = static_cast<gl::Context*>(ctx);
+ return EGL_FALSE;
+ }
- if (ctx != EGL_NO_CONTEXT && !validateContext(display, context))
+ if (dpy != EGL_NO_DISPLAY)
+ {
+ rx::Renderer *renderer = display->getRenderer();
+ if (renderer->testDeviceLost(true))
{
return EGL_FALSE;
}
- if (dpy != EGL_NO_DISPLAY)
+ if (renderer->isDeviceLost())
{
- rx::Renderer *renderer = display->getRenderer();
- if (renderer->testDeviceLost(true))
- {
- return EGL_FALSE;
- }
-
- if (renderer->isDeviceLost())
- {
- return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
- }
+ return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
}
+ }
- if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) ||
- (read != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(read))))
- {
- return EGL_FALSE;
- }
+ if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) ||
+ (read != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(read))))
+ {
+ return EGL_FALSE;
+ }
- if (draw != read)
- {
- UNIMPLEMENTED(); // FIXME
- }
+ if (draw != read)
+ {
+ UNIMPLEMENTED(); // FIXME
+ }
- egl::setCurrentDisplay(dpy);
- egl::setCurrentDrawSurface(draw);
- egl::setCurrentReadSurface(read);
+ egl::setCurrentDisplay(dpy);
+ egl::setCurrentDrawSurface(draw);
+ egl::setCurrentReadSurface(read);
- glMakeCurrent(context, display, static_cast<egl::Surface*>(draw));
+ glMakeCurrent(context, display, static_cast<egl::Surface*>(draw));
- return egl::success(EGL_TRUE);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(EGL_TRUE);
}
EGLContext __stdcall eglGetCurrentContext(void)
{
EVENT("()");
- try
- {
- EGLContext context = glGetCurrentContext();
+ EGLContext context = glGetCurrentContext();
- return egl::success(context);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
- }
+ return egl::success(context);
}
EGLSurface __stdcall eglGetCurrentSurface(EGLint readdraw)
{
EVENT("(EGLint readdraw = %d)", readdraw);
- try
+ if (readdraw == EGL_READ)
{
- if (readdraw == EGL_READ)
- {
- EGLSurface read = egl::getCurrentReadSurface();
- return egl::success(read);
- }
- else if (readdraw == EGL_DRAW)
- {
- EGLSurface draw = egl::getCurrentDrawSurface();
- return egl::success(draw);
- }
- else
- {
- return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
- }
+ EGLSurface read = egl::getCurrentReadSurface();
+ return egl::success(read);
}
- catch(std::bad_alloc&)
+ else if (readdraw == EGL_DRAW)
{
- return egl::error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
+ EGLSurface draw = egl::getCurrentDrawSurface();
+ return egl::success(draw);
+ }
+ else
+ {
+ return egl::error(EGL_BAD_PARAMETER, EGL_NO_SURFACE);
}
}
@@ -984,16 +870,9 @@ EGLDisplay __stdcall eglGetCurrentDisplay(void)
{
EVENT("()");
- try
- {
- EGLDisplay dpy = egl::getCurrentDisplay();
+ EGLDisplay dpy = egl::getCurrentDisplay();
- return egl::success(dpy);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_NO_DISPLAY);
- }
+ return egl::success(dpy);
}
EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
@@ -1001,90 +880,62 @@ EGLBoolean __stdcall eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attr
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
dpy, ctx, attribute, value);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- gl::Context *context = static_cast<gl::Context*>(ctx);
-
- if (!validateContext(display, context))
- {
- return EGL_FALSE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ gl::Context *context = static_cast<gl::Context*>(ctx);
- UNIMPLEMENTED(); // FIXME
-
- return egl::success(0);
- }
- catch(std::bad_alloc&)
+ if (!validateContext(display, context))
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return EGL_FALSE;
}
+
+ UNIMPLEMENTED(); // FIXME
+
+ return egl::success(0);
}
EGLBoolean __stdcall eglWaitGL(void)
{
EVENT("()");
- try
- {
- UNIMPLEMENTED(); // FIXME
+ UNIMPLEMENTED(); // FIXME
- return egl::success(0);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(0);
}
EGLBoolean __stdcall eglWaitNative(EGLint engine)
{
EVENT("(EGLint engine = %d)", engine);
- try
- {
- UNIMPLEMENTED(); // FIXME
+ UNIMPLEMENTED(); // FIXME
- return egl::success(0);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
- }
+ return egl::success(0);
}
EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = (egl::Surface*)surface;
-
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = (egl::Surface*)surface;
- if (display->getRenderer()->isDeviceLost())
- {
- return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
- }
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
+ }
- if (surface == EGL_NO_SURFACE)
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
+ if (display->getRenderer()->isDeviceLost())
+ {
+ return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
+ }
- if (eglSurface->swap())
- {
- return egl::success(EGL_TRUE);
- }
+ if (surface == EGL_NO_SURFACE)
+ {
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
}
- catch(std::bad_alloc&)
+
+ if (eglSurface->swap())
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::success(EGL_TRUE);
}
return EGL_FALSE;
@@ -1094,68 +945,54 @@ EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativ
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = 0x%0.8p)", dpy, surface, target);
- try
- {
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
-
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
-
- if (display->getRenderer()->isDeviceLost())
- {
- return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
- }
-
- UNIMPLEMENTED(); // FIXME
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
- return egl::success(0);
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
}
- catch(std::bad_alloc&)
+
+ if (display->getRenderer()->isDeviceLost())
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
}
+
+ UNIMPLEMENTED(); // FIXME
+
+ return egl::success(0);
}
EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height)
{
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint x = %d, EGLint y = %d, EGLint width = %d, EGLint height = %d)", dpy, surface, x, y, width, height);
- try
+ 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);
- }
-
- egl::Display *display = static_cast<egl::Display*>(dpy);
- egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
+ return egl::error(EGL_BAD_PARAMETER, EGL_FALSE);
+ }
- if (!validateSurface(display, eglSurface))
- {
- return EGL_FALSE;
- }
+ egl::Display *display = static_cast<egl::Display*>(dpy);
+ egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
- if (display->getRenderer()->isDeviceLost())
- {
- return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
- }
+ if (!validateSurface(display, eglSurface))
+ {
+ return EGL_FALSE;
+ }
- if (surface == EGL_NO_SURFACE)
- {
- return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
- }
+ if (display->getRenderer()->isDeviceLost())
+ {
+ return egl::error(EGL_CONTEXT_LOST, EGL_FALSE);
+ }
- if (eglSurface->postSubBuffer(x, y, width, height))
- {
- return egl::success(EGL_TRUE);
- }
+ if (surface == EGL_NO_SURFACE)
+ {
+ return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
}
- catch(std::bad_alloc&)
+
+ if (eglSurface->postSubBuffer(x, y, width, height))
{
- return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
+ return egl::success(EGL_TRUE);
}
return EGL_FALSE;
@@ -1165,34 +1002,28 @@ __eglMustCastToProperFunctionPointerType __stdcall eglGetProcAddress(const char
{
EVENT("(const char *procname = \"%s\")", procname);
- try
+ struct Extension
{
- struct Extension
- {
- const char *name;
- __eglMustCastToProperFunctionPointerType address;
- };
+ const char *name;
+ __eglMustCastToProperFunctionPointerType address;
+ };
- static const Extension eglExtensions[] =
- {
- {"eglQuerySurfacePointerANGLE", (__eglMustCastToProperFunctionPointerType)eglQuerySurfacePointerANGLE},
- {"eglPostSubBufferNV", (__eglMustCastToProperFunctionPointerType)eglPostSubBufferNV},
- {"", NULL},
- };
+ static const Extension eglExtensions[] =
+ {
+ { "eglQuerySurfacePointerANGLE", (__eglMustCastToProperFunctionPointerType)eglQuerySurfacePointerANGLE },
+ { "eglPostSubBufferNV", (__eglMustCastToProperFunctionPointerType)eglPostSubBufferNV },
+ { "eglGetPlatformDisplayEXT", (__eglMustCastToProperFunctionPointerType)eglGetPlatformDisplayEXT },
+ { "", NULL },
+ };
- for (unsigned int ext = 0; ext < ArraySize(eglExtensions); ext++)
+ for (unsigned int ext = 0; ext < ArraySize(eglExtensions); ext++)
+ {
+ if (strcmp(procname, eglExtensions[ext].name) == 0)
{
- if (strcmp(procname, eglExtensions[ext].name) == 0)
- {
- return (__eglMustCastToProperFunctionPointerType)eglExtensions[ext].address;
- }
+ return (__eglMustCastToProperFunctionPointerType)eglExtensions[ext].address;
}
-
- return glGetProcAddress(procname);
- }
- catch(std::bad_alloc&)
- {
- return egl::error(EGL_BAD_ALLOC, (__eglMustCastToProperFunctionPointerType)NULL);
}
+
+ return glGetProcAddress(procname);
}
}
diff --git a/src/3rdparty/angle/src/libEGL/libEGL.def b/src/3rdparty/angle/src/libEGL/libEGL.def
index 71a5e67977..d7949d0354 100644
--- a/src/3rdparty/angle/src/libEGL/libEGL.def
+++ b/src/3rdparty/angle/src/libEGL/libEGL.def
@@ -1,36 +1,41 @@
-LIBRARY libEGL
+LIBRARY libEGL
EXPORTS
- eglBindAPI @14
- eglBindTexImage @20
- eglChooseConfig @7
- eglCopyBuffers @33
- eglCreateContext @23
- eglCreatePbufferFromClientBuffer @18
- eglCreatePbufferSurface @10
- eglCreatePixmapSurface @11
- eglCreateWindowSurface @9
- eglDestroyContext @24
- eglDestroySurface @12
- eglGetConfigAttrib @8
- eglGetConfigs @6
- eglGetCurrentContext @26
- eglGetCurrentDisplay @28
- eglGetCurrentSurface @27
- eglGetDisplay @2
- eglGetError @1
- eglGetProcAddress @34
- eglInitialize @3
- eglMakeCurrent @25
- eglQueryAPI @15
- eglQueryContext @29
- eglQueryString @5
- eglQuerySurface @13
- eglReleaseTexImage @21
- eglReleaseThread @17
- eglSurfaceAttrib @19
- eglSwapBuffers @32
- eglSwapInterval @22
- eglTerminate @4
- eglWaitClient @16
- eglWaitGL @30
- eglWaitNative @31 \ No newline at end of file
+ eglBindAPI @14
+ eglBindTexImage @20
+ eglChooseConfig @7
+ eglCopyBuffers @33
+ eglCreateContext @23
+ eglCreatePbufferFromClientBuffer @18
+ eglCreatePbufferSurface @10
+ eglCreatePixmapSurface @11
+ eglCreateWindowSurface @9
+ eglDestroyContext @24
+ eglDestroySurface @12
+ eglGetConfigAttrib @8
+ eglGetConfigs @6
+ eglGetCurrentContext @26
+ eglGetCurrentDisplay @28
+ eglGetCurrentSurface @27
+ eglGetDisplay @2
+ eglGetError @1
+ eglGetProcAddress @34
+ eglInitialize @3
+ eglMakeCurrent @25
+ eglQueryAPI @15
+ eglQueryContext @29
+ eglQueryString @5
+ eglQuerySurface @13
+ eglReleaseTexImage @21
+ eglReleaseThread @17
+ eglSurfaceAttrib @19
+ eglSwapBuffers @32
+ eglSwapInterval @22
+ eglTerminate @4
+ eglWaitClient @16
+ eglWaitGL @30
+ eglWaitNative @31
+
+ ; Extensions
+ eglGetPlatformDisplayEXT @35
+ eglQuerySurfacePointerANGLE @36
+ eglPostSubBufferNV @37
diff --git a/src/3rdparty/angle/src/libEGL/libEGL_mingw32.def b/src/3rdparty/angle/src/libEGL/libEGL_mingw32.def
index 8128e7c4f0..492ad4d0cf 100644
--- a/src/3rdparty/angle/src/libEGL/libEGL_mingw32.def
+++ b/src/3rdparty/angle/src/libEGL/libEGL_mingw32.def
@@ -1,36 +1,41 @@
LIBRARY libEGL
EXPORTS
- eglBindAPI@4 @14
- eglBindTexImage@12 @20
- eglChooseConfig@20 @7
- eglCopyBuffers@12 @33
- eglCreateContext@16 @23
- eglCreatePbufferFromClientBuffer@20 @18
- eglCreatePbufferSurface@12 @10
- eglCreatePixmapSurface@16 @11
- eglCreateWindowSurface@16 @9
- eglDestroyContext@8 @24
- eglDestroySurface@8 @12
- eglGetConfigAttrib@16 @8
- eglGetConfigs@16 @6
- eglGetCurrentContext@0 @26
- eglGetCurrentDisplay@0 @28
- eglGetCurrentSurface@4 @27
- eglGetDisplay@4 @2
- eglGetError@0 @1
- eglGetProcAddress@4 @34
- eglInitialize@12 @3
- eglMakeCurrent@16 @25
- eglQueryAPI@0 @15
- eglQueryContext@16 @29
- eglQueryString@8 @5
- eglQuerySurface@16 @13
- eglReleaseTexImage@12 @21
- eglReleaseThread@0 @17
- eglSurfaceAttrib@16 @19
- eglSwapBuffers@8 @32
- eglSwapInterval@8 @22
- eglTerminate@4 @4
- eglWaitClient@0 @16
- eglWaitGL@0 @30
- eglWaitNative@4 @31
+ eglBindAPI@4 @14
+ eglBindTexImage@12 @20
+ eglChooseConfig@20 @7
+ eglCopyBuffers@12 @33
+ eglCreateContext@16 @23
+ eglCreatePbufferFromClientBuffer@20 @18
+ eglCreatePbufferSurface@12 @10
+ eglCreatePixmapSurface@16 @11
+ eglCreateWindowSurface@16 @9
+ eglDestroyContext@8 @24
+ eglDestroySurface@8 @12
+ eglGetConfigAttrib@16 @8
+ eglGetConfigs@16 @6
+ eglGetCurrentContext@0 @26
+ eglGetCurrentDisplay@0 @28
+ eglGetCurrentSurface@4 @27
+ eglGetDisplay@4 @2
+ eglGetError@0 @1
+ eglGetProcAddress@4 @34
+ eglInitialize@12 @3
+ eglMakeCurrent@16 @25
+ eglQueryAPI@0 @15
+ eglQueryContext@16 @29
+ eglQueryString@8 @5
+ eglQuerySurface@16 @13
+ eglReleaseTexImage@12 @21
+ eglReleaseThread@0 @17
+ eglSurfaceAttrib@16 @19
+ eglSwapBuffers@8 @32
+ eglSwapInterval@8 @22
+ eglTerminate@4 @4
+ eglWaitClient@0 @16
+ eglWaitGL@0 @30
+ eglWaitNative@4 @31
+
+ ; Extensions
+ eglGetPlatformDisplayEXT@12 @35
+ eglQuerySurfacePointerANGLE@16 @36
+ eglPostSubBufferNV@24 @37
diff --git a/src/3rdparty/angle/src/libEGL/libEGLd.def b/src/3rdparty/angle/src/libEGL/libEGLd.def
index 9317fce7de..0ebd27d0e1 100644
--- a/src/3rdparty/angle/src/libEGL/libEGLd.def
+++ b/src/3rdparty/angle/src/libEGL/libEGLd.def
@@ -1,36 +1,41 @@
-LIBRARY libEGLd
+LIBRARY libEGLd
EXPORTS
- eglBindAPI @14
- eglBindTexImage @20
- eglChooseConfig @7
- eglCopyBuffers @33
- eglCreateContext @23
- eglCreatePbufferFromClientBuffer @18
- eglCreatePbufferSurface @10
- eglCreatePixmapSurface @11
- eglCreateWindowSurface @9
- eglDestroyContext @24
- eglDestroySurface @12
- eglGetConfigAttrib @8
- eglGetConfigs @6
- eglGetCurrentContext @26
- eglGetCurrentDisplay @28
- eglGetCurrentSurface @27
- eglGetDisplay @2
- eglGetError @1
- eglGetProcAddress @34
- eglInitialize @3
- eglMakeCurrent @25
- eglQueryAPI @15
- eglQueryContext @29
- eglQueryString @5
- eglQuerySurface @13
- eglReleaseTexImage @21
- eglReleaseThread @17
- eglSurfaceAttrib @19
- eglSwapBuffers @32
- eglSwapInterval @22
- eglTerminate @4
- eglWaitClient @16
- eglWaitGL @30
- eglWaitNative @31
+ eglBindAPI @14
+ eglBindTexImage @20
+ eglChooseConfig @7
+ eglCopyBuffers @33
+ eglCreateContext @23
+ eglCreatePbufferFromClientBuffer @18
+ eglCreatePbufferSurface @10
+ eglCreatePixmapSurface @11
+ eglCreateWindowSurface @9
+ eglDestroyContext @24
+ eglDestroySurface @12
+ eglGetConfigAttrib @8
+ eglGetConfigs @6
+ eglGetCurrentContext @26
+ eglGetCurrentDisplay @28
+ eglGetCurrentSurface @27
+ eglGetDisplay @2
+ eglGetError @1
+ eglGetProcAddress @34
+ eglInitialize @3
+ eglMakeCurrent @25
+ eglQueryAPI @15
+ eglQueryContext @29
+ eglQueryString @5
+ eglQuerySurface @13
+ eglReleaseTexImage @21
+ eglReleaseThread @17
+ eglSurfaceAttrib @19
+ eglSwapBuffers @32
+ eglSwapInterval @22
+ eglTerminate @4
+ eglWaitClient @16
+ eglWaitGL @30
+ eglWaitNative @31
+
+ ; Extensions
+ eglGetPlatformDisplayEXT @35
+ eglQuerySurfacePointerANGLE @36
+ eglPostSubBufferNV @37
diff --git a/src/3rdparty/angle/src/libEGL/libEGLd_mingw32.def b/src/3rdparty/angle/src/libEGL/libEGLd_mingw32.def
index 1c72413f89..ab0320dc0d 100644
--- a/src/3rdparty/angle/src/libEGL/libEGLd_mingw32.def
+++ b/src/3rdparty/angle/src/libEGL/libEGLd_mingw32.def
@@ -1,36 +1,41 @@
LIBRARY libEGLd
EXPORTS
- eglBindAPI@4 @14
- eglBindTexImage@12 @20
- eglChooseConfig@20 @7
- eglCopyBuffers@12 @33
- eglCreateContext@16 @23
- eglCreatePbufferFromClientBuffer@20 @18
- eglCreatePbufferSurface@12 @10
- eglCreatePixmapSurface@16 @11
- eglCreateWindowSurface@16 @9
- eglDestroyContext@8 @24
- eglDestroySurface@8 @12
- eglGetConfigAttrib@16 @8
- eglGetConfigs@16 @6
- eglGetCurrentContext@0 @26
- eglGetCurrentDisplay@0 @28
- eglGetCurrentSurface@4 @27
- eglGetDisplay@4 @2
- eglGetError@0 @1
- eglGetProcAddress@4 @34
- eglInitialize@12 @3
- eglMakeCurrent@16 @25
- eglQueryAPI@0 @15
- eglQueryContext@16 @29
- eglQueryString@8 @5
- eglQuerySurface@16 @13
- eglReleaseTexImage@12 @21
- eglReleaseThread@0 @17
- eglSurfaceAttrib@16 @19
- eglSwapBuffers@8 @32
- eglSwapInterval@8 @22
- eglTerminate@4 @4
- eglWaitClient@0 @16
- eglWaitGL@0 @30
- eglWaitNative@4 @31
+ eglBindAPI@4 @14
+ eglBindTexImage@12 @20
+ eglChooseConfig@20 @7
+ eglCopyBuffers@12 @33
+ eglCreateContext@16 @23
+ eglCreatePbufferFromClientBuffer@20 @18
+ eglCreatePbufferSurface@12 @10
+ eglCreatePixmapSurface@16 @11
+ eglCreateWindowSurface@16 @9
+ eglDestroyContext@8 @24
+ eglDestroySurface@8 @12
+ eglGetConfigAttrib@16 @8
+ eglGetConfigs@16 @6
+ eglGetCurrentContext@0 @26
+ eglGetCurrentDisplay@0 @28
+ eglGetCurrentSurface@4 @27
+ eglGetDisplay@4 @2
+ eglGetError@0 @1
+ eglGetProcAddress@4 @34
+ eglInitialize@12 @3
+ eglMakeCurrent@16 @25
+ eglQueryAPI@0 @15
+ eglQueryContext@16 @29
+ eglQueryString@8 @5
+ eglQuerySurface@16 @13
+ eglReleaseTexImage@12 @21
+ eglReleaseThread@0 @17
+ eglSurfaceAttrib@16 @19
+ eglSwapBuffers@8 @32
+ eglSwapInterval@8 @22
+ eglTerminate@4 @4
+ eglWaitClient@0 @16
+ eglWaitGL@0 @30
+ eglWaitNative@4 @31
+
+ ; Extensions
+ eglGetPlatformDisplayEXT@12 @35
+ eglQuerySurfacePointerANGLE@16 @36
+ eglPostSubBufferNV@24 @37
diff --git a/src/3rdparty/angle/src/libEGL/main.cpp b/src/3rdparty/angle/src/libEGL/main.cpp
index 4cdf5f0362..5788af7827 100644
--- a/src/3rdparty/angle/src/libEGL/main.cpp
+++ b/src/3rdparty/angle/src/libEGL/main.cpp
@@ -1,4 +1,3 @@
-#include "../libGLESv2/precompiled.h"
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -10,61 +9,57 @@
#include "libEGL/main.h"
#include "common/debug.h"
+#include "common/tls.h"
-#if !defined(ANGLE_OS_WINRT)
-static DWORD currentTLS = TLS_OUT_OF_INDEXES;
-#else
-static __declspec(thread) void *currentTLS = 0;
+#if defined(ANGLE_PLATFORM_WINRT)
+__declspec(thread)
#endif
+static TLSIndex currentTLS = TLS_OUT_OF_INDEXES;
namespace egl
{
Current *AllocateCurrent()
{
-#if !defined(ANGLE_OS_WINRT)
- Current *current = (egl::Current*)LocalAlloc(LPTR, sizeof(egl::Current));
-#else
- currentTLS = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Current));
- Current *current = (egl::Current*)currentTLS;
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (currentTLS == TLS_OUT_OF_INDEXES)
+ {
+ currentTLS = CreateTLSIndex();
+ }
#endif
-
- if (!current)
+ ASSERT(currentTLS != TLS_OUT_OF_INDEXES);
+ if (currentTLS == TLS_OUT_OF_INDEXES)
{
- ERR("Could not allocate thread local storage.");
return NULL;
}
-#if !defined(ANGLE_OS_WINRT)
- ASSERT(currentTLS != TLS_OUT_OF_INDEXES);
- TlsSetValue(currentTLS, current);
-#endif
-
+ Current *current = new Current();
current->error = EGL_SUCCESS;
current->API = EGL_OPENGL_ES_API;
current->display = EGL_NO_DISPLAY;
current->drawSurface = EGL_NO_SURFACE;
current->readSurface = EGL_NO_SURFACE;
+ if (!SetTLSValue(currentTLS, current))
+ {
+ ERR("Could not set thread local storage.");
+ return NULL;
+ }
+
return current;
}
void DeallocateCurrent()
{
-#if !defined(ANGLE_OS_WINRT)
- void *current = TlsGetValue(currentTLS);
-
- if (current)
+#if defined(ANGLE_PLATFORM_WINRT)
+ if (currentTLS == TLS_OUT_OF_INDEXES)
{
- LocalFree((HLOCAL)current);
- }
-#else
- if (currentTLS)
- {
- HeapFree(GetProcessHeap(), 0, currentTLS);
- currentTLS = 0;
+ return;
}
#endif
+ Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
+ SafeDelete(current);
+ SetTLSValue(currentTLS, NULL);
}
}
@@ -91,16 +86,18 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
}
}
#endif
-#if !defined(ANGLE_OS_WINRT)
- currentTLS = TlsAlloc();
+#if defined(ANGLE_PLATFORM_WINRT) // On WinRT, don't handle TLS from DllMain
+ return DisableThreadLibraryCalls(instance);
+#endif
+
+ currentTLS = CreateTLSIndex();
if (currentTLS == TLS_OUT_OF_INDEXES)
{
return FALSE;
}
-#endif
}
- // Fall throught to initialize index
+ // Fall through to initialize index
case DLL_THREAD_ATTACH:
{
egl::AllocateCurrent();
@@ -113,9 +110,9 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
break;
case DLL_PROCESS_DETACH:
{
+#if !defined(ANGLE_PLATFORM_WINRT)
egl::DeallocateCurrent();
-#if !defined(ANGLE_OS_WINRT)
- TlsFree(currentTLS);
+ DestroyTLSIndex(currentTLS);
#endif
}
break;
@@ -134,20 +131,16 @@ namespace egl
Current *GetCurrentData()
{
#ifndef QT_OPENGL_ES_2_ANGLE_STATIC
-#if !defined(ANGLE_OS_WINRT)
- Current *current = (Current*)TlsGetValue(currentTLS);
-#else
- Current *current = (Current*)currentTLS;
-#endif
-#else
- // No precautions for thread safety taken as ANGLE is used single-threaded in Qt.
- static Current s_current = { EGL_SUCCESS, EGL_OPENGL_ES_API, EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE };
- Current *current = &s_current;
-#endif
+ Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
// ANGLE issue 488: when the dll is loaded after thread initialization,
// thread local storage (current) might not exist yet.
return (current ? current : AllocateCurrent());
+#else
+ // No precautions for thread safety taken as ANGLE is used single-threaded in Qt.
+ static Current current = { EGL_SUCCESS, EGL_OPENGL_ES_API, EGL_NO_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE };
+ return &current;
+#endif
}
void setCurrentError(EGLint error)
diff --git a/src/3rdparty/angle/src/libEGL/main.h b/src/3rdparty/angle/src/libEGL/main.h
index 77da8f0f8e..6030fb6ad9 100644
--- a/src/3rdparty/angle/src/libEGL/main.h
+++ b/src/3rdparty/angle/src/libEGL/main.h
@@ -9,6 +9,7 @@
#ifndef LIBEGL_MAIN_H_
#define LIBEGL_MAIN_H_
+#undef EGLAPI
#define EGLAPI
#include <EGL/egl.h>
#include <EGL/eglext.h>