Commit 38832d17 by Jamie Madill

Add Display getters for native display and attribs.

This simplifies the logic in the Renderer init. BUG=angle:905 Change-Id: I01bf3701dd85f50e369e2c11e0e2a7cb638ccf00 Reviewed-on: https://chromium-review.googlesource.com/247650Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b0eecdfd
...@@ -139,7 +139,7 @@ Error Display::initialize() ...@@ -139,7 +139,7 @@ Error Display::initialize()
return Error(EGL_SUCCESS); return Error(EGL_SUCCESS);
} }
Error error = mImplementation->initialize(this, mDisplayId, mAttributeMap); Error error = mImplementation->initialize(this);
if (error.isError()) if (error.isError())
{ {
return error; return error;
......
...@@ -79,6 +79,9 @@ class Display final ...@@ -79,6 +79,9 @@ class Display final
const std::string &getExtensionString() const; const std::string &getExtensionString() const;
const std::string &getVendorString() const; const std::string &getVendorString() const;
const AttributeMap &getAttributeMap() const { return mAttributeMap; }
EGLNativeDisplayType getNativeDisplayId() const { return mDisplayId; }
private: private:
DISALLOW_COPY_AND_ASSIGN(Display); DISALLOW_COPY_AND_ASSIGN(Display);
......
...@@ -42,7 +42,7 @@ class DisplayImpl ...@@ -42,7 +42,7 @@ class DisplayImpl
DisplayImpl(); DisplayImpl();
virtual ~DisplayImpl(); virtual ~DisplayImpl();
virtual egl::Error initialize(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attribMap) = 0; virtual egl::Error initialize(egl::Display *display) = 0;
virtual void terminate() = 0; virtual void terminate() = 0;
virtual SurfaceImpl *createWindowSurface(egl::Display *display, const egl::Config *config, virtual SurfaceImpl *createWindowSurface(egl::Display *display, const egl::Config *config,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/SurfaceD3D.h" #include "libANGLE/renderer/d3d/SurfaceD3D.h"
...@@ -37,20 +38,23 @@ ...@@ -37,20 +38,23 @@
namespace rx namespace rx
{ {
typedef RendererD3D *(*CreateRendererD3DFunction)(egl::Display*, EGLNativeDisplayType, const egl::AttributeMap &); typedef RendererD3D *(*CreateRendererD3DFunction)(egl::Display*);
template <typename RendererType> template <typename RendererType>
static RendererD3D *CreateTypedRendererD3D(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attributes) static RendererD3D *CreateTypedRendererD3D(egl::Display *display)
{ {
return new RendererType(display, nativeDisplay, attributes); return new RendererType(display);
} }
egl::Error CreateRendererD3D(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attribMap, RendererD3D **outRenderer) egl::Error CreateRendererD3D(egl::Display *display, RendererD3D **outRenderer)
{ {
ASSERT(outRenderer != nullptr); ASSERT(outRenderer != nullptr);
std::vector<CreateRendererD3DFunction> rendererCreationFunctions; std::vector<CreateRendererD3DFunction> rendererCreationFunctions;
const auto &attribMap = display->getAttributeMap();
EGLNativeDisplayType nativeDisplay = display->getNativeDisplayId();
EGLint requestedDisplayType = attribMap.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE); EGLint requestedDisplayType = attribMap.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
# if defined(ANGLE_ENABLE_D3D11) # if defined(ANGLE_ENABLE_D3D11)
...@@ -96,7 +100,7 @@ egl::Error CreateRendererD3D(egl::Display *display, EGLNativeDisplayType nativeD ...@@ -96,7 +100,7 @@ egl::Error CreateRendererD3D(egl::Display *display, EGLNativeDisplayType nativeD
EGLint result = EGL_NOT_INITIALIZED; EGLint result = EGL_NOT_INITIALIZED;
for (size_t i = 0; i < rendererCreationFunctions.size(); i++) for (size_t i = 0; i < rendererCreationFunctions.size(); i++)
{ {
RendererD3D *renderer = rendererCreationFunctions[i](display, nativeDisplay, attribMap); RendererD3D *renderer = rendererCreationFunctions[i](display);
result = renderer->initialize(); result = renderer->initialize();
if (result == EGL_SUCCESS) if (result == EGL_SUCCESS)
{ {
...@@ -156,10 +160,10 @@ egl::Error DisplayD3D::makeCurrent(egl::Surface *drawSurface, egl::Surface *read ...@@ -156,10 +160,10 @@ egl::Error DisplayD3D::makeCurrent(egl::Surface *drawSurface, egl::Surface *read
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
} }
egl::Error DisplayD3D::initialize(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attribMap) egl::Error DisplayD3D::initialize(egl::Display *display)
{ {
ASSERT(mRenderer == nullptr); ASSERT(mRenderer == nullptr && display != nullptr);
return CreateRendererD3D(display, nativeDisplay, attribMap, &mRenderer); return CreateRendererD3D(display, &mRenderer);
} }
void DisplayD3D::terminate() void DisplayD3D::terminate()
......
...@@ -20,7 +20,7 @@ class DisplayD3D : public DisplayImpl ...@@ -20,7 +20,7 @@ class DisplayD3D : public DisplayImpl
public: public:
DisplayD3D(); DisplayD3D();
egl::Error initialize(egl::Display *display, EGLNativeDisplayType nativeDisplay, const egl::AttributeMap &attribMap) override; egl::Error initialize(egl::Display *display) override;
virtual void terminate() override; virtual void terminate() override;
SurfaceImpl *createWindowSurface(egl::Display *display, const egl::Config *config, SurfaceImpl *createWindowSurface(egl::Display *display, const egl::Config *config,
......
...@@ -145,9 +145,8 @@ ID3D11Resource *GetViewResource(ID3D11View *view) ...@@ -145,9 +145,8 @@ ID3D11Resource *GetViewResource(ID3D11View *view)
} }
Renderer11::Renderer11(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes) Renderer11::Renderer11(egl::Display *display)
: RendererD3D(display), : RendererD3D(display),
mDc(hDc),
mStateCache(this) mStateCache(this)
{ {
mVertexDataManager = NULL; mVertexDataManager = NULL;
...@@ -181,6 +180,8 @@ Renderer11::Renderer11(egl::Display *display, EGLNativeDisplayType hDc, const eg ...@@ -181,6 +180,8 @@ Renderer11::Renderer11(egl::Display *display, EGLNativeDisplayType hDc, const eg
mAppliedGeometryShader = NULL; mAppliedGeometryShader = NULL;
mAppliedPixelShader = NULL; mAppliedPixelShader = NULL;
const auto &attributes = mDisplay->getAttributeMap();
EGLint requestedMajorVersion = attributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE); EGLint requestedMajorVersion = attributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE);
EGLint requestedMinorVersion = attributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE); EGLint requestedMinorVersion = attributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE);
...@@ -300,7 +301,7 @@ EGLint Renderer11::initialize() ...@@ -300,7 +301,7 @@ EGLint Renderer11::initialize()
// In order to create a swap chain for an HWND owned by another process, DXGI 1.2 is required. // In order to create a swap chain for an HWND owned by another process, DXGI 1.2 is required.
// The easiest way to check is to query for a IDXGIDevice2. // The easiest way to check is to query for a IDXGIDevice2.
bool requireDXGI1_2 = false; bool requireDXGI1_2 = false;
HWND hwnd = WindowFromDC(mDc); HWND hwnd = WindowFromDC(mDisplay->getNativeDisplayId());
if (hwnd) if (hwnd)
{ {
DWORD currentProcessId = GetCurrentProcessId(); DWORD currentProcessId = GetCurrentProcessId();
......
...@@ -49,7 +49,7 @@ enum ...@@ -49,7 +49,7 @@ enum
class Renderer11 : public RendererD3D class Renderer11 : public RendererD3D
{ {
public: public:
Renderer11(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes); explicit Renderer11(egl::Display *display);
virtual ~Renderer11(); virtual ~Renderer11();
static Renderer11 *makeRenderer11(Renderer *renderer); static Renderer11 *makeRenderer11(Renderer *renderer);
...@@ -226,7 +226,6 @@ class Renderer11 : public RendererD3D ...@@ -226,7 +226,6 @@ class Renderer11 : public RendererD3D
HMODULE mD3d11Module; HMODULE mD3d11Module;
HMODULE mDxgiModule; HMODULE mDxgiModule;
HDC mDc;
std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels; std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels;
D3D_DRIVER_TYPE mDriverType; D3D_DRIVER_TYPE mDriverType;
......
...@@ -77,9 +77,8 @@ enum ...@@ -77,9 +77,8 @@ enum
MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 = 4 MAX_TEXTURE_IMAGE_UNITS_VTF_SM3 = 4
}; };
Renderer9::Renderer9(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes) Renderer9::Renderer9(egl::Display *display)
: RendererD3D(display), : RendererD3D(display)
mDc(hDc)
{ {
mD3d9Module = NULL; mD3d9Module = NULL;
...@@ -202,7 +201,7 @@ EGLint Renderer9::initialize() ...@@ -202,7 +201,7 @@ EGLint Renderer9::initialize()
return EGL_NOT_INITIALIZED; return EGL_NOT_INITIALIZED;
} }
if (mDc != NULL) if (mDisplay->getNativeDisplayId() != nullptr)
{ {
// UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to // UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to
} }
......
...@@ -39,7 +39,7 @@ class Blit9; ...@@ -39,7 +39,7 @@ class Blit9;
class Renderer9 : public RendererD3D class Renderer9 : public RendererD3D
{ {
public: public:
Renderer9(egl::Display *display, EGLNativeDisplayType hDc, const egl::AttributeMap &attributes); explicit Renderer9(egl::Display *display);
virtual ~Renderer9(); virtual ~Renderer9();
static Renderer9 *makeRenderer9(Renderer *renderer); static Renderer9 *makeRenderer9(Renderer *renderer);
...@@ -225,7 +225,6 @@ class Renderer9 : public RendererD3D ...@@ -225,7 +225,6 @@ class Renderer9 : public RendererD3D
D3DPOOL getBufferPool(DWORD usage) const; D3DPOOL getBufferPool(DWORD usage) const;
HMODULE mD3d9Module; HMODULE mD3d9Module;
HDC mDc;
void initializeDevice(); void initializeDevice();
D3DPRESENT_PARAMETERS getDefaultPresentParameters(); D3DPRESENT_PARAMETERS getDefaultPresentParameters();
......
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