Commit 6bd58312 by Jamie Madill

Make Platform methods global.

This will allow them to be imported dynamically without name mangling. This is necessary because sometimes SwiftShader overrides libGLESv2 and libEGL, so we need to determine at run-time if we are running with "actual" ANGLE. BUG=466735 Change-Id: I396d717b79066feb8ed0d577ee7386b33eb1d160 Reviewed-on: https://chromium-review.googlesource.com/259954Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 1f40291c
...@@ -20,10 +20,6 @@ class Platform ...@@ -20,10 +20,6 @@ class Platform
{ {
public: public:
ANGLE_EXPORT static void initialize(Platform*);
ANGLE_EXPORT static void shutdown();
ANGLE_EXPORT static Platform *current();
// Tracing -------- // Tracing --------
typedef uint64_t TraceEventHandle; typedef uint64_t TraceEventHandle;
...@@ -104,4 +100,13 @@ class Platform ...@@ -104,4 +100,13 @@ class Platform
} }
typedef void(*ANGLEPlatformInitializeFunc)(angle::Platform*);
ANGLE_EXPORT void ANGLEPlatformInitialize(angle::Platform*);
typedef void (*ANGLEPlatformShutdownFunc)();
ANGLE_EXPORT void ANGLEPlatformShutdown();
typedef angle::Platform *(*ANGLEPlatformCurrentFunc)();
ANGLE_EXPORT angle::Platform *ANGLEPlatformCurrent();
#endif // ANGLE_PLATFORM_H #endif // ANGLE_PLATFORM_H
...@@ -55,14 +55,14 @@ DefaultPlatform *defaultPlatform = nullptr; ...@@ -55,14 +55,14 @@ DefaultPlatform *defaultPlatform = nullptr;
void InitDefaultPlatformImpl() void InitDefaultPlatformImpl()
{ {
if (angle::Platform::current() == nullptr) if (ANGLEPlatformCurrent() == nullptr)
{ {
if (defaultPlatform == nullptr) if (defaultPlatform == nullptr)
{ {
defaultPlatform = new DefaultPlatform(); defaultPlatform = new DefaultPlatform();
} }
angle::Platform::initialize(defaultPlatform); ANGLEPlatformInitialize(defaultPlatform);
} }
} }
...@@ -70,9 +70,9 @@ void DeinitDefaultPlatformImpl() ...@@ -70,9 +70,9 @@ void DeinitDefaultPlatformImpl()
{ {
if (defaultPlatform != nullptr) if (defaultPlatform != nullptr)
{ {
if (angle::Platform::current() == defaultPlatform) if (ANGLEPlatformCurrent() == defaultPlatform)
{ {
angle::Platform::shutdown(); ANGLEPlatformShutdown();
} }
SafeDelete(defaultPlatform); SafeDelete(defaultPlatform);
......
...@@ -9,33 +9,27 @@ ...@@ -9,33 +9,27 @@
#include <platform/Platform.h> #include <platform/Platform.h>
#include "common/debug.h" #include "common/debug.h"
#include "platform/Platform.h"
namespace angle
{
namespace namespace
{ {
Platform *currentPlatform = nullptr; angle::Platform *currentPlatform = nullptr;
} }
// static // static
ANGLE_EXPORT Platform *Platform::current() ANGLE_EXPORT angle::Platform *ANGLEPlatformCurrent()
{ {
return currentPlatform; return currentPlatform;
} }
// static // static
ANGLE_EXPORT void Platform::initialize(Platform *platformImpl) ANGLE_EXPORT void ANGLEPlatformInitialize(angle::Platform *platformImpl)
{ {
ASSERT(platformImpl != nullptr); ASSERT(platformImpl != nullptr);
currentPlatform = platformImpl; currentPlatform = platformImpl;
} }
// static // static
ANGLE_EXPORT void Platform::shutdown() ANGLE_EXPORT void ANGLEPlatformShutdown()
{ {
currentPlatform = nullptr; currentPlatform = nullptr;
} }
}
...@@ -109,7 +109,7 @@ egl::Error CreateRendererD3D(egl::Display *display, RendererD3D **outRenderer) ...@@ -109,7 +109,7 @@ egl::Error CreateRendererD3D(egl::Display *display, RendererD3D **outRenderer)
{ {
ASSERT(result.getID() >= 0 && result.getID() < NUM_D3D11_INIT_ERRORS); ASSERT(result.getID() >= 0 && result.getID() < NUM_D3D11_INIT_ERRORS);
angle::Platform *platform = angle::Platform::current(); angle::Platform *platform = ANGLEPlatformCurrent();
platform->histogramEnumeration("GPU.ANGLE.D3D11InitializeResult", platform->histogramEnumeration("GPU.ANGLE.D3D11InitializeResult",
result.getID(), NUM_D3D11_INIT_ERRORS); result.getID(), NUM_D3D11_INIT_ERRORS);
} }
...@@ -120,7 +120,7 @@ egl::Error CreateRendererD3D(egl::Display *display, RendererD3D **outRenderer) ...@@ -120,7 +120,7 @@ egl::Error CreateRendererD3D(egl::Display *display, RendererD3D **outRenderer)
{ {
ASSERT(result.getID() >= 0 && result.getID() < NUM_D3D9_INIT_ERRORS); ASSERT(result.getID() >= 0 && result.getID() < NUM_D3D9_INIT_ERRORS);
angle::Platform *platform = angle::Platform::current(); angle::Platform *platform = ANGLEPlatformCurrent();
platform->histogramEnumeration("GPU.ANGLE.D3D9InitializeResult", platform->histogramEnumeration("GPU.ANGLE.D3D9InitializeResult",
result.getID(), NUM_D3D9_INIT_ERRORS); result.getID(), NUM_D3D9_INIT_ERRORS);
} }
......
...@@ -286,3 +286,8 @@ EXPORTS ...@@ -286,3 +286,8 @@ EXPORTS
; Setting up TRACE macro callbacks ; Setting up TRACE macro callbacks
SetTraceFunctionPointers @284 SetTraceFunctionPointers @284
; ANGLE Platform Implementation
ANGLEPlatformCurrent @290
ANGLEPlatformInitialize @291
ANGLEPlatformShutdown @292
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment