зеркало из https://github.com/AvaloniaUI/angle.git
Encapsulate the thread local storage into an egl::Thread class.
Instead of having separate GetGlobal* functions, interact with the global objects through a single Thread object. This reduces the number of TLS lookups in many EGL functions and allows the Thread object to be passed down to other objects if needed. BUG=angleproject:1618 Change-Id: I1f9a89e8899d637633f4e91fda0e38ac308dd020 Reviewed-on: https://chromium-review.googlesource.com/409637 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Родитель
d7490967e1
Коммит
7b8f3c9bb5
|
@ -0,0 +1,88 @@
|
|||
//
|
||||
// Copyright(c) 2016 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.
|
||||
//
|
||||
|
||||
// Thread.cpp : Defines the Thread class which represents a global EGL thread.
|
||||
|
||||
#include "libANGLE/Thread.h"
|
||||
|
||||
#include "libANGLE/Context.h"
|
||||
#include "libANGLE/Error.h"
|
||||
|
||||
namespace egl
|
||||
{
|
||||
Thread::Thread()
|
||||
: mError(EGL_SUCCESS),
|
||||
mAPI(EGL_OPENGL_ES_API),
|
||||
mDisplay(static_cast<egl::Display *>(EGL_NO_DISPLAY)),
|
||||
mDrawSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
|
||||
mReadSurface(static_cast<egl::Surface *>(EGL_NO_SURFACE)),
|
||||
mContext(static_cast<gl::Context *>(EGL_NO_CONTEXT))
|
||||
{
|
||||
}
|
||||
|
||||
void Thread::setError(const Error &error)
|
||||
{
|
||||
mError = error.getCode();
|
||||
}
|
||||
|
||||
EGLint Thread::getError() const
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
|
||||
void Thread::setAPI(EGLenum api)
|
||||
{
|
||||
mAPI = api;
|
||||
}
|
||||
|
||||
EGLenum Thread::getAPI() const
|
||||
{
|
||||
return mAPI;
|
||||
}
|
||||
|
||||
void Thread::setCurrent(Display *display,
|
||||
Surface *drawSurface,
|
||||
Surface *readSurface,
|
||||
gl::Context *context)
|
||||
{
|
||||
mDisplay = display;
|
||||
mDrawSurface = drawSurface;
|
||||
mReadSurface = readSurface;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
Display *Thread::getDisplay() const
|
||||
{
|
||||
return mDisplay;
|
||||
}
|
||||
|
||||
Surface *Thread::getDrawSurface() const
|
||||
{
|
||||
return mDrawSurface;
|
||||
}
|
||||
|
||||
Surface *Thread::getReadSurface() const
|
||||
{
|
||||
return mReadSurface;
|
||||
}
|
||||
|
||||
gl::Context *Thread::getContext() const
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
gl::Context *Thread::getValidContext() const
|
||||
{
|
||||
if (mContext && mContext->isContextLost())
|
||||
{
|
||||
mContext->handleError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost."));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mContext;
|
||||
}
|
||||
|
||||
} // namespace egl
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Copyright(c) 2016 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.
|
||||
//
|
||||
|
||||
// Thread.h : Defines the Thread class which represents a global EGL thread.
|
||||
|
||||
#ifndef LIBANGLE_THREAD_H_
|
||||
#define LIBANGLE_THREAD_H_
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class Context;
|
||||
} // namespace gl
|
||||
|
||||
namespace egl
|
||||
{
|
||||
class Error;
|
||||
class Display;
|
||||
class Surface;
|
||||
|
||||
class Thread
|
||||
{
|
||||
public:
|
||||
Thread();
|
||||
|
||||
void setError(const Error &error);
|
||||
EGLint getError() const;
|
||||
|
||||
void setAPI(EGLenum api);
|
||||
EGLenum getAPI() const;
|
||||
|
||||
void setCurrent(Display *display,
|
||||
Surface *drawSurface,
|
||||
Surface *readSurface,
|
||||
gl::Context *context);
|
||||
Display *getDisplay() const;
|
||||
Surface *getDrawSurface() const;
|
||||
Surface *getReadSurface() const;
|
||||
gl::Context *getContext() const;
|
||||
gl::Context *getValidContext() const;
|
||||
|
||||
private:
|
||||
EGLint mError;
|
||||
EGLenum mAPI;
|
||||
egl::Display *mDisplay;
|
||||
egl::Surface *mDrawSurface;
|
||||
egl::Surface *mReadSurface;
|
||||
gl::Context *mContext;
|
||||
};
|
||||
|
||||
} // namespace egl
|
||||
|
||||
#endif // LIBANGLE_THREAD_H_
|
|
@ -138,6 +138,8 @@
|
|||
'libANGLE/Surface.h',
|
||||
'libANGLE/Texture.cpp',
|
||||
'libANGLE/Texture.h',
|
||||
'libANGLE/Thread.cpp',
|
||||
'libANGLE/Thread.h',
|
||||
'libANGLE/TransformFeedback.cpp',
|
||||
'libANGLE/TransformFeedback.h',
|
||||
'libANGLE/Uniform.cpp',
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -14,6 +14,7 @@
|
|||
#include "libANGLE/Device.h"
|
||||
#include "libANGLE/Surface.h"
|
||||
#include "libANGLE/Stream.h"
|
||||
#include "libANGLE/Thread.h"
|
||||
#include "libANGLE/validationEGL.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
|
@ -26,6 +27,7 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
|
|||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, void **value = 0x%0.8p)",
|
||||
dpy, surface, attribute, value);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display*>(dpy);
|
||||
Surface *eglSurface = static_cast<Surface*>(surface);
|
||||
|
@ -33,19 +35,19 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
|
|||
Error error = ValidateSurface(display, eglSurface);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (!display->getExtensions().querySurfacePointer)
|
||||
{
|
||||
SetGlobalError(Error(EGL_SUCCESS));
|
||||
thread->setError(Error(EGL_SUCCESS));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (surface == EGL_NO_SURFACE)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_SURFACE));
|
||||
thread->setError(Error(EGL_BAD_SURFACE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -55,24 +57,24 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
|
|||
case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE:
|
||||
if (!display->getExtensions().surfaceD3DTexture2DShareHandle)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
break;
|
||||
case EGL_DXGI_KEYED_MUTEX_ANGLE:
|
||||
if (!display->getExtensions().keyedMutex)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = eglSurface->querySurfacePointerANGLE(attribute, value);
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return (error.isError() ? EGL_FALSE : EGL_TRUE);
|
||||
}
|
||||
|
||||
|
@ -81,10 +83,11 @@ EGLBoolean EGLAPIENTRY QuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surfa
|
|||
EGLBoolean EGLAPIENTRY PostSubBufferNV(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);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
if (x < 0 || y < 0 || width < 0 || height < 0)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_PARAMETER));
|
||||
thread->setError(Error(EGL_BAD_PARAMETER));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -94,37 +97,37 @@ EGLBoolean EGLAPIENTRY PostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLin
|
|||
Error error = ValidateSurface(display, eglSurface);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (display->testDeviceLost())
|
||||
{
|
||||
SetGlobalError(Error(EGL_CONTEXT_LOST));
|
||||
thread->setError(Error(EGL_CONTEXT_LOST));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (surface == EGL_NO_SURFACE)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_SURFACE));
|
||||
thread->setError(Error(EGL_BAD_SURFACE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (!display->getExtensions().postSubBuffer)
|
||||
{
|
||||
// Spec is not clear about how this should be handled.
|
||||
SetGlobalError(Error(EGL_SUCCESS));
|
||||
thread->setError(Error(EGL_SUCCESS));
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
error = eglSurface->postSubBuffer(x, y, width, height);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(Error(EGL_SUCCESS));
|
||||
thread->setError(Error(EGL_SUCCESS));
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -133,6 +136,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
{
|
||||
EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
|
||||
platform, native_display, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
const ClientExtensions &clientExtensions = Display::getClientExtensions();
|
||||
|
||||
|
@ -141,20 +145,20 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_PLATFORM_ANGLE_ANGLE:
|
||||
if (!clientExtensions.platformANGLE)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_PARAMETER));
|
||||
thread->setError(Error(EGL_BAD_PARAMETER));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
break;
|
||||
case EGL_PLATFORM_DEVICE_EXT:
|
||||
if (!clientExtensions.platformDevice)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_PARAMETER, "Platform Device extension is not active"));
|
||||
thread->setError(Error(EGL_BAD_PARAMETER, "Platform Device extension is not active"));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_CONFIG));
|
||||
return EGL_NO_DISPLAY;
|
||||
thread->setError(Error(EGL_BAD_CONFIG));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
if (platform == EGL_PLATFORM_ANGLE_ANGLE)
|
||||
|
@ -183,7 +187,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
|
||||
if (!clientExtensions.platformANGLED3D)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
break;
|
||||
|
@ -192,7 +196,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
|
||||
if (!clientExtensions.platformANGLEOpenGL)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
break;
|
||||
|
@ -200,17 +204,17 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE:
|
||||
if (!clientExtensions.platformANGLENULL)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"Display type "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE "
|
||||
"requires EGL_ANGLE_platform_angle_null."));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"Display type "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE "
|
||||
"requires EGL_ANGLE_platform_angle_null."));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
platformType = curAttrib[1];
|
||||
break;
|
||||
|
@ -236,8 +240,8 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_FALSE:
|
||||
break;
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
enableAutoTrimSpecified = true;
|
||||
break;
|
||||
|
@ -245,7 +249,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE:
|
||||
if (!clientExtensions.experimentalPresentPath)
|
||||
{
|
||||
SetGlobalError(
|
||||
thread->setError(
|
||||
Error(EGL_BAD_ATTRIBUTE,
|
||||
"EGL_ANGLE_experimental_present_path extension not active"));
|
||||
return EGL_NO_DISPLAY;
|
||||
|
@ -257,7 +261,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
case EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE:
|
||||
break;
|
||||
default:
|
||||
SetGlobalError(
|
||||
thread->setError(
|
||||
Error(EGL_BAD_ATTRIBUTE,
|
||||
"Invalid value for EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE"));
|
||||
return EGL_NO_DISPLAY;
|
||||
|
@ -279,10 +283,10 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
break;
|
||||
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"Invalid value for "
|
||||
"EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE "
|
||||
"attrib"));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"Invalid value for "
|
||||
"EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE "
|
||||
"attrib"));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
deviceType = curAttrib[1];
|
||||
|
@ -296,14 +300,14 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
|
||||
if (!majorVersionSpecified && minorVersionSpecified)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE &&
|
||||
platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
|
||||
{
|
||||
SetGlobalError(
|
||||
thread->setError(
|
||||
Error(EGL_BAD_ATTRIBUTE,
|
||||
"EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE requires a device type of "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
|
||||
|
@ -312,7 +316,7 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
|
||||
if (enableAutoTrimSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
|
||||
{
|
||||
SetGlobalError(
|
||||
thread->setError(
|
||||
Error(EGL_BAD_ATTRIBUTE,
|
||||
"EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE requires a device type of "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
|
||||
|
@ -321,23 +325,23 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
|
||||
if (presentPathSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE requires a device type of "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE requires a device type of "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
if (deviceTypeSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE &&
|
||||
platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
|
||||
{
|
||||
SetGlobalError(
|
||||
thread->setError(
|
||||
Error(EGL_BAD_ATTRIBUTE,
|
||||
"EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE requires a device type of "
|
||||
"EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE or EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE."));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
SetGlobalError(Error(EGL_SUCCESS));
|
||||
thread->setError(Error(EGL_SUCCESS));
|
||||
return Display::GetDisplayFromAttribs(native_display,
|
||||
AttributeMap::CreateFromIntArray(attrib_list));
|
||||
}
|
||||
|
@ -346,13 +350,13 @@ EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_disp
|
|||
Device *eglDevice = reinterpret_cast<Device *>(native_display);
|
||||
if (eglDevice == nullptr || !Device::IsValidDevice(eglDevice))
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"native_display should be a valid EGL device if platform equals "
|
||||
"EGL_PLATFORM_DEVICE_EXT"));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE,
|
||||
"native_display should be a valid EGL device if platform equals "
|
||||
"EGL_PLATFORM_DEVICE_EXT"));
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
SetGlobalError(Error(EGL_SUCCESS));
|
||||
thread->setError(Error(EGL_SUCCESS));
|
||||
return Display::GetDisplayFromDevice(native_display);
|
||||
}
|
||||
else
|
||||
|
@ -367,11 +371,12 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut
|
|||
{
|
||||
EVENT("(EGLDeviceEXT device = 0x%0.8p, EGLint attribute = %d, EGLAttrib *value = 0x%0.8p)",
|
||||
device, attribute, value);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Device *dev = static_cast<Device*>(device);
|
||||
if (dev == EGL_NO_DEVICE_EXT || !Device::IsValidDevice(dev))
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ACCESS));
|
||||
thread->setError(Error(EGL_BAD_ACCESS));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -380,9 +385,9 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut
|
|||
Display *owningDisplay = dev->getOwningDisplay();
|
||||
if (owningDisplay != nullptr && !owningDisplay->getExtensions().deviceQuery)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ACCESS,
|
||||
"Device wasn't created using eglCreateDeviceANGLE, and the Display "
|
||||
"that created it doesn't support device querying"));
|
||||
thread->setError(Error(EGL_BAD_ACCESS,
|
||||
"Device wasn't created using eglCreateDeviceANGLE, and the Display "
|
||||
"that created it doesn't support device querying"));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -395,17 +400,17 @@ EGLBoolean EGLAPIENTRY QueryDeviceAttribEXT(EGLDeviceEXT device, EGLint attribut
|
|||
case EGL_D3D9_DEVICE_ANGLE:
|
||||
if (!dev->getExtensions().deviceD3D || dev->getType() != attribute)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
error = dev->getDevice(value);
|
||||
break;
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return (error.isError() ? EGL_FALSE : EGL_TRUE);
|
||||
}
|
||||
|
||||
|
@ -414,11 +419,12 @@ const char * EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name)
|
|||
{
|
||||
EVENT("(EGLDeviceEXT device = 0x%0.8p, EGLint name = %d)",
|
||||
device, name);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Device *dev = static_cast<Device*>(device);
|
||||
if (dev == EGL_NO_DEVICE_EXT || !Device::IsValidDevice(dev))
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_DEVICE_EXT));
|
||||
thread->setError(Error(EGL_BAD_DEVICE_EXT));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -429,11 +435,11 @@ const char * EGLAPIENTRY QueryDeviceStringEXT(EGLDeviceEXT device, EGLint name)
|
|||
result = dev->getExtensionString().c_str();
|
||||
break;
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_DEVICE_EXT));
|
||||
return nullptr;
|
||||
thread->setError(Error(EGL_BAD_DEVICE_EXT));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SetGlobalError(Error(EGL_SUCCESS));
|
||||
thread->setError(Error(EGL_SUCCESS));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -442,19 +448,20 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E
|
|||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint attribute = %d, EGLAttrib *value = 0x%0.8p)",
|
||||
dpy, attribute, value);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display*>(dpy);
|
||||
|
||||
Error error = ValidateDisplay(display);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (!display->getExtensions().deviceQuery)
|
||||
{
|
||||
SetGlobalError(Error(EGL_BAD_ACCESS));
|
||||
thread->setError(Error(EGL_BAD_ACCESS));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -466,11 +473,11 @@ EGLBoolean EGLAPIENTRY QueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, E
|
|||
break;
|
||||
|
||||
default:
|
||||
SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
thread->setError(Error(EGL_BAD_ATTRIBUTE));
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return (error.isError() ? EGL_FALSE : EGL_TRUE);
|
||||
}
|
||||
|
||||
|
@ -484,6 +491,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
|
|||
"(EGLDisplay dpy = 0x%0.8p, EGLContext ctx = 0x%0.8p, EGLenum target = 0x%X, "
|
||||
"EGLClientBuffer buffer = 0x%0.8p, const EGLAttrib *attrib_list = 0x%0.8p)",
|
||||
dpy, ctx, target, buffer, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
gl::Context *context = static_cast<gl::Context *>(ctx);
|
||||
|
@ -492,7 +500,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
|
|||
Error error = ValidateCreateImageKHR(display, context, target, buffer, attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_NO_IMAGE;
|
||||
}
|
||||
|
||||
|
@ -500,7 +508,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
|
|||
error = display->createImage(context, target, buffer, attributes, &image);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_NO_IMAGE;
|
||||
}
|
||||
|
||||
|
@ -510,6 +518,7 @@ ANGLE_EXPORT EGLImageKHR EGLAPIENTRY CreateImageKHR(EGLDisplay dpy,
|
|||
ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
|
||||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLImage image = 0x%0.8p)", dpy, image);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Image *img = static_cast<Image *>(image);
|
||||
|
@ -517,7 +526,7 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY DestroyImageKHR(EGLDisplay dpy, EGLImageKHR
|
|||
Error error = ValidateDestroyImageKHR(display, img);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -534,11 +543,12 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
|
|||
"(EGLint device_type = %d, void* native_device = 0x%0.8p, const EGLAttrib* attrib_list = "
|
||||
"0x%0.8p)",
|
||||
device_type, native_device, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Error error = ValidateCreateDeviceANGLE(device_type, native_device, attrib_list);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_NO_DEVICE_EXT;
|
||||
}
|
||||
|
||||
|
@ -547,7 +557,7 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
|
|||
if (error.isError())
|
||||
{
|
||||
ASSERT(device == nullptr);
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_NO_DEVICE_EXT;
|
||||
}
|
||||
|
||||
|
@ -557,13 +567,14 @@ ANGLE_EXPORT EGLDeviceEXT EGLAPIENTRY CreateDeviceANGLE(EGLint device_type,
|
|||
ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device)
|
||||
{
|
||||
EVENT("(EGLDeviceEXT device = 0x%0.8p)", device);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Device *dev = static_cast<Device *>(device);
|
||||
|
||||
Error error = ValidateReleaseDeviceANGLE(dev);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -576,6 +587,7 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY ReleaseDeviceANGLE(EGLDeviceEXT device)
|
|||
EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list)
|
||||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, const EGLAttrib* attrib_list = 0x%0.8p)", dpy, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list);
|
||||
|
@ -583,7 +595,7 @@ EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_li
|
|||
Error error = ValidateCreateStreamKHR(display, attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_NO_STREAM_KHR;
|
||||
}
|
||||
|
||||
|
@ -591,17 +603,18 @@ EGLStreamKHR EGLAPIENTRY CreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_li
|
|||
error = display->createStream(attributes, &stream);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_NO_STREAM_KHR;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return static_cast<EGLStreamKHR>(stream);
|
||||
}
|
||||
|
||||
EGLBoolean EGLAPIENTRY DestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream)
|
||||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
|
@ -609,12 +622,12 @@ EGLBoolean EGLAPIENTRY DestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream)
|
|||
Error error = ValidateDestroyStreamKHR(display, streamObject);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
display->destroyStream(streamObject);
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -627,6 +640,7 @@ EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy,
|
|||
"(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, "
|
||||
"EGLint value = 0x%X)",
|
||||
dpy, stream, attribute, value);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
|
@ -634,7 +648,7 @@ EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy,
|
|||
Error error = ValidateStreamAttribKHR(display, streamObject, attribute, value);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -650,7 +664,7 @@ EGLBoolean EGLAPIENTRY StreamAttribKHR(EGLDisplay dpy,
|
|||
UNREACHABLE();
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -663,6 +677,7 @@ EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy,
|
|||
"(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, "
|
||||
"EGLint value = 0x%0.8p)",
|
||||
dpy, stream, attribute, value);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
|
@ -670,7 +685,7 @@ EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy,
|
|||
Error error = ValidateQueryStreamKHR(display, streamObject, attribute, value);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -689,7 +704,7 @@ EGLBoolean EGLAPIENTRY QueryStreamKHR(EGLDisplay dpy,
|
|||
UNREACHABLE();
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -702,6 +717,7 @@ EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy,
|
|||
"(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLenum attribute = 0x%X, "
|
||||
"EGLuint64KHR value = 0x%0.8p)",
|
||||
dpy, stream, attribute, value);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
|
@ -709,7 +725,7 @@ EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy,
|
|||
Error error = ValidateQueryStreamu64KHR(display, streamObject, attribute, value);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -725,13 +741,15 @@ EGLBoolean EGLAPIENTRY QueryStreamu64KHR(EGLDisplay dpy,
|
|||
UNREACHABLE();
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream)
|
||||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
gl::Context *context = gl::GetValidGlobalContext();
|
||||
|
@ -739,24 +757,26 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStr
|
|||
Error error = ValidateStreamConsumerGLTextureExternalKHR(display, context, streamObject);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = streamObject->createConsumerGLTextureExternal(AttributeMap(), context);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream)
|
||||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
gl::Context *context = gl::GetValidGlobalContext();
|
||||
|
@ -764,24 +784,26 @@ EGLBoolean EGLAPIENTRY StreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR str
|
|||
Error error = ValidateStreamConsumerAcquireKHR(display, context, streamObject);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = streamObject->consumerAcquire();
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream)
|
||||
{
|
||||
EVENT("(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR = 0x%0.8p)", dpy, stream);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
gl::Context *context = gl::GetValidGlobalContext();
|
||||
|
@ -789,18 +811,18 @@ EGLBoolean EGLAPIENTRY StreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR str
|
|||
Error error = ValidateStreamConsumerReleaseKHR(display, context, streamObject);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = streamObject->consumerRelease();
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -811,6 +833,8 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy,
|
|||
EVENT(
|
||||
"(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p",
|
||||
dpy, stream, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
gl::Context *context = gl::GetValidGlobalContext();
|
||||
|
@ -820,18 +844,18 @@ EGLBoolean EGLAPIENTRY StreamConsumerGLTextureExternalAttribsNV(EGLDisplay dpy,
|
|||
attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = streamObject->createConsumerGLTextureExternal(attributes, context);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -842,6 +866,8 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy,
|
|||
EVENT(
|
||||
"(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, EGLAttrib attrib_list = 0x%0.8p",
|
||||
dpy, stream, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
|
||||
|
@ -850,18 +876,18 @@ EGLBoolean EGLAPIENTRY CreateStreamProducerD3DTextureNV12ANGLE(EGLDisplay dpy,
|
|||
ValidateCreateStreamProducerD3DTextureNV12ANGLE(display, streamObject, attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = streamObject->createProducerD3D11TextureNV12(attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -874,6 +900,8 @@ EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy,
|
|||
"(EGLDisplay dpy = 0x%0.8p, EGLStreamKHR stream = 0x%0.8p, void* texture = 0x%0.8p, "
|
||||
"EGLAttrib attrib_list = 0x%0.8p",
|
||||
dpy, stream, texture, attrib_list);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Stream *streamObject = static_cast<Stream *>(stream);
|
||||
AttributeMap attributes = AttributeMap::CreateFromAttribArray(attrib_list);
|
||||
|
@ -881,18 +909,18 @@ EGLBoolean EGLAPIENTRY StreamPostD3DTextureNV12ANGLE(EGLDisplay dpy,
|
|||
Error error = ValidateStreamPostD3DTextureNV12ANGLE(display, streamObject, texture, attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = streamObject->postD3D11NV12Texture(texture, attributes);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -905,6 +933,7 @@ ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy,
|
|||
"(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint *rects = 0x%0.8p, EGLint "
|
||||
"n_rects = %d)",
|
||||
dpy, surface, rects, n_rects);
|
||||
Thread *thread = GetCurrentThread();
|
||||
|
||||
Display *display = static_cast<Display *>(dpy);
|
||||
Surface *eglSurface = static_cast<Surface *>(surface);
|
||||
|
@ -912,14 +941,14 @@ ANGLE_EXPORT EGLBoolean SwapBuffersWithDamageEXT(EGLDisplay dpy,
|
|||
Error error = ValidateSwapBuffersWithDamageEXT(display, eglSurface, rects, n_rects);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
error = eglSurface->swapWithDamage(rects, n_rects);
|
||||
if (error.isError())
|
||||
{
|
||||
SetGlobalError(error);
|
||||
thread->setError(error);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "libANGLE/Query.h"
|
||||
#include "libANGLE/queryconversions.h"
|
||||
#include "libANGLE/queryutils.h"
|
||||
#include "libANGLE/Thread.h"
|
||||
#include "libANGLE/VertexArray.h"
|
||||
|
||||
#include "libANGLE/validationES.h"
|
||||
|
@ -990,10 +991,11 @@ ANGLE_EXPORT void GL_APIENTRY EGLImageTargetTexture2DOES(GLenum target, GLeglIma
|
|||
{
|
||||
EVENT("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image);
|
||||
|
||||
Context *context = GetValidGlobalContext();
|
||||
egl::Thread *thread = egl::GetCurrentThread();
|
||||
Context *context = thread->getValidContext();
|
||||
if (context)
|
||||
{
|
||||
egl::Display *display = egl::GetGlobalDisplay();
|
||||
egl::Display *display = thread->getDisplay();
|
||||
egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
|
||||
if (!ValidateEGLImageTargetTexture2DOES(context, display, target, imageObject))
|
||||
{
|
||||
|
@ -1015,10 +1017,11 @@ ANGLE_EXPORT void GL_APIENTRY EGLImageTargetRenderbufferStorageOES(GLenum target
|
|||
{
|
||||
EVENT("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image);
|
||||
|
||||
Context *context = GetValidGlobalContext();
|
||||
egl::Thread *thread = egl::GetCurrentThread();
|
||||
Context *context = thread->getValidContext();
|
||||
if (context)
|
||||
{
|
||||
egl::Display *display = egl::GetGlobalDisplay();
|
||||
egl::Display *display = thread->getDisplay();
|
||||
egl::Image *imageObject = reinterpret_cast<egl::Image *>(image);
|
||||
if (!ValidateEGLImageTargetRenderbufferStorageOES(context, display, target, imageObject))
|
||||
{
|
||||
|
|
|
@ -8,229 +8,141 @@
|
|||
|
||||
#include "libGLESv2/global_state.h"
|
||||
|
||||
#include "libANGLE/Context.h"
|
||||
#include "libANGLE/Error.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/platform.h"
|
||||
#include "common/tls.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
static TLSIndex currentTLS = TLS_INVALID_INDEX;
|
||||
|
||||
struct Current
|
||||
{
|
||||
EGLint error;
|
||||
EGLenum API;
|
||||
egl::Display *display;
|
||||
egl::Surface *drawSurface;
|
||||
egl::Surface *readSurface;
|
||||
gl::Context *context;
|
||||
};
|
||||
|
||||
Current *AllocateCurrent()
|
||||
{
|
||||
ASSERT(currentTLS != TLS_INVALID_INDEX);
|
||||
if (currentTLS == TLS_INVALID_INDEX)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Current *current = new Current();
|
||||
current->error = EGL_SUCCESS;
|
||||
current->API = EGL_OPENGL_ES_API;
|
||||
current->display = reinterpret_cast<egl::Display*>(EGL_NO_DISPLAY);
|
||||
current->drawSurface = reinterpret_cast<egl::Surface*>(EGL_NO_SURFACE);
|
||||
current->readSurface = reinterpret_cast<egl::Surface*>(EGL_NO_SURFACE);
|
||||
current->context = reinterpret_cast<gl::Context*>(EGL_NO_CONTEXT);
|
||||
|
||||
if (!SetTLSValue(currentTLS, current))
|
||||
{
|
||||
ERR("Could not set thread local storage.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
Current *GetCurrentData()
|
||||
{
|
||||
// Create a TLS index if one has not been created for this DLL
|
||||
if (currentTLS == TLS_INVALID_INDEX)
|
||||
{
|
||||
currentTLS = CreateTLSIndex();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
#ifdef ANGLE_PLATFORM_WINDOWS
|
||||
|
||||
void DeallocateCurrent()
|
||||
{
|
||||
Current *current = reinterpret_cast<Current*>(GetTLSValue(currentTLS));
|
||||
SafeDelete(current);
|
||||
SetTLSValue(currentTLS, NULL);
|
||||
}
|
||||
|
||||
extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
currentTLS = CreateTLSIndex();
|
||||
if (currentTLS == TLS_INVALID_INDEX)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
AllocateCurrent();
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
AllocateCurrent();
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
DeallocateCurrent();
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
DeallocateCurrent();
|
||||
if (currentTLS != TLS_INVALID_INDEX)
|
||||
{
|
||||
DestroyTLSIndex(currentTLS);
|
||||
currentTLS = TLS_INVALID_INDEX;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#include "libANGLE/Thread.h"
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
Context *GetGlobalContext()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
return current->context;
|
||||
egl::Thread *thread = egl::GetCurrentThread();
|
||||
return thread->getContext();
|
||||
}
|
||||
|
||||
Context *GetValidGlobalContext()
|
||||
{
|
||||
gl::Context *context = GetGlobalContext();
|
||||
if (context)
|
||||
{
|
||||
if (context->isContextLost())
|
||||
{
|
||||
context->handleError(gl::Error(GL_OUT_OF_MEMORY, "Context has been lost."));
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
return context;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
egl::Thread *thread = egl::GetCurrentThread();
|
||||
return thread->getValidContext();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gl
|
||||
|
||||
namespace egl
|
||||
{
|
||||
|
||||
void SetGlobalError(const Error &error)
|
||||
namespace
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
current->error = error.getCode();
|
||||
}
|
||||
static TLSIndex threadTLS = TLS_INVALID_INDEX;
|
||||
|
||||
EGLint GetGlobalError()
|
||||
Thread *AllocateCurrentThread()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
ASSERT(threadTLS != TLS_INVALID_INDEX);
|
||||
if (threadTLS == TLS_INVALID_INDEX)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return current->error;
|
||||
Thread *thread = new Thread();
|
||||
if (!SetTLSValue(threadTLS, thread))
|
||||
{
|
||||
ERR("Could not set thread local storage.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
EGLenum GetGlobalAPI()
|
||||
} // anonymous namespace
|
||||
|
||||
Thread *GetCurrentThread()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
// Create a TLS index if one has not been created for this DLL
|
||||
if (threadTLS == TLS_INVALID_INDEX)
|
||||
{
|
||||
threadTLS = CreateTLSIndex();
|
||||
}
|
||||
|
||||
return current->API;
|
||||
Thread *current = static_cast<Thread *>(GetTLSValue(threadTLS));
|
||||
|
||||
// ANGLE issue 488: when the dll is loaded after thread initialization,
|
||||
// thread local storage (current) might not exist yet.
|
||||
return (current ? current : AllocateCurrentThread());
|
||||
}
|
||||
|
||||
void SetGlobalAPI(EGLenum API)
|
||||
} // namespace egl
|
||||
|
||||
#ifdef ANGLE_PLATFORM_WINDOWS
|
||||
namespace egl
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
current->API = API;
|
||||
}
|
||||
|
||||
void SetGlobalDisplay(Display *dpy)
|
||||
namespace
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
current->display = dpy;
|
||||
}
|
||||
|
||||
Display *GetGlobalDisplay()
|
||||
bool DeallocateCurrentThread()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
return current->display;
|
||||
Thread *thread = static_cast<Thread *>(GetTLSValue(threadTLS));
|
||||
SafeDelete(thread);
|
||||
return SetTLSValue(threadTLS, nullptr);
|
||||
}
|
||||
|
||||
void SetGlobalDrawSurface(Surface *surface)
|
||||
bool InitializeProcess()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
threadTLS = CreateTLSIndex();
|
||||
if (threadTLS == TLS_INVALID_INDEX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
current->drawSurface = surface;
|
||||
return AllocateCurrentThread() != nullptr;
|
||||
}
|
||||
|
||||
Surface *GetGlobalDrawSurface()
|
||||
bool TerminateProcess()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
if (!DeallocateCurrentThread())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return current->drawSurface;
|
||||
if (threadTLS != TLS_INVALID_INDEX)
|
||||
{
|
||||
TLSIndex tlsCopy = threadTLS;
|
||||
threadTLS = TLS_INVALID_INDEX;
|
||||
|
||||
if (!DestroyTLSIndex(tlsCopy))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetGlobalReadSurface(Surface *surface)
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace egl
|
||||
|
||||
extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID)
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
current->readSurface = surface;
|
||||
}
|
||||
|
||||
Surface *GetGlobalReadSurface()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
return current->readSurface;
|
||||
}
|
||||
|
||||
void SetGlobalContext(gl::Context *context)
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
current->context = context;
|
||||
}
|
||||
|
||||
gl::Context *GetGlobalContext()
|
||||
{
|
||||
Current *current = GetCurrentData();
|
||||
|
||||
return current->context;
|
||||
}
|
||||
switch (reason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
return static_cast<BOOL>(egl::InitializeProcess());
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
return static_cast<BOOL>(egl::AllocateCurrentThread() != nullptr);
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
return static_cast<BOOL>(egl::DeallocateCurrentThread());
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
return static_cast<BOOL>(egl::TerminateProcess());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif // ANGLE_PLATFORM_WINDOWS
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#ifndef LIBGLESV2_GLOBALSTATE_H_
|
||||
#define LIBGLESV2_GLOBALSTATE_H_
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class Context;
|
||||
|
@ -18,32 +16,14 @@ class Context;
|
|||
Context *GetGlobalContext();
|
||||
Context *GetValidGlobalContext();
|
||||
|
||||
}
|
||||
} // namespace gl
|
||||
|
||||
namespace egl
|
||||
{
|
||||
class Error;
|
||||
class Display;
|
||||
class Surface;
|
||||
class Thread;
|
||||
|
||||
void SetGlobalError(const Error &error);
|
||||
EGLint GetGlobalError();
|
||||
Thread *GetCurrentThread();
|
||||
|
||||
void SetGlobalAPI(EGLenum API);
|
||||
EGLenum GetGlobalAPI();
|
||||
|
||||
void SetGlobalDisplay(Display *dpy);
|
||||
Display *GetGlobalDisplay();
|
||||
|
||||
void SetGlobalDrawSurface(Surface *surface);
|
||||
Surface *GetGlobalDrawSurface();
|
||||
|
||||
void SetGlobalReadSurface(Surface *surface);
|
||||
Surface *GetGlobalReadSurface();
|
||||
|
||||
void SetGlobalContext(gl::Context *context);
|
||||
gl::Context *GetGlobalContext();
|
||||
|
||||
}
|
||||
} // namespace egl
|
||||
|
||||
#endif // LIBGLESV2_GLOBALSTATE_H_
|
||||
|
|
Загрузка…
Ссылка в новой задаче