summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt')
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp67
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h48
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp131
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h38
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp126
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h51
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp63
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h10
8 files changed, 261 insertions, 273 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
index f401db614b..1ef90e7b09 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
@@ -8,6 +8,8 @@
#include "libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h"
+#include <windows.graphics.display.h>
+
using namespace ABI::Windows::Foundation::Collections;
namespace rx
@@ -19,7 +21,6 @@ CoreWindowNativeWindow::~CoreWindowNativeWindow()
bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet *propertySet)
{
- mOrientationChangedEventToken.value = 0;
ComPtr<IPropertySet> props = propertySet;
ComPtr<IInspectable> win = window;
SIZE swapChainSize = {};
@@ -63,7 +64,8 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
// A EGLRenderSurfaceSizeProperty and a EGLRenderResolutionScaleProperty can't both be specified
if (mSwapChainScaleSpecified && mSwapChainSizeSpecified)
{
- ERR("It is invalid to specify both an EGLRenderSurfaceSizeProperty and a EGLRenderResolutionScaleProperty.");
+ ERR() << "It is invalid to specify both an EGLRenderSurfaceSizeProperty and a "
+ "EGLRenderResolutionScaleProperty.";
return false;
}
}
@@ -87,28 +89,18 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
}
else
{
- SIZE coreWindowSize;
+ Size coreWindowSize;
result = GetCoreWindowSizeInPixels(mCoreWindow, &coreWindowSize);
if (SUCCEEDED(result))
{
- mClientRect = { 0, 0, static_cast<long>(coreWindowSize.cx * mSwapChainScale), static_cast<long>(coreWindowSize.cy * mSwapChainScale) };
+ mClientRect = clientRect(coreWindowSize);
}
}
}
if (SUCCEEDED(result))
{
- ComPtr<ABI::Windows::Graphics::Display::IDisplayInformationStatics> displayInformation;
- result = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayInformation).Get(), &displayInformation);
- if (SUCCEEDED(result))
- {
- result = displayInformation->GetForCurrentView(&mDisplayInformation);
- }
- }
-
- if (SUCCEEDED(result))
- {
mNewClientRect = mClientRect;
mClientRectChanged = false;
return registerForSizeChangeEvents();
@@ -126,16 +118,6 @@ bool CoreWindowNativeWindow::registerForSizeChangeEvents()
result = mCoreWindow->add_SizeChanged(sizeChangedHandler.Get(), &mSizeChangedEventToken);
}
-#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- ComPtr<IDisplayOrientationEventHandler> orientationChangedHandler;
- result = sizeChangedHandler.As(&orientationChangedHandler);
- if (SUCCEEDED(result))
- {
- result = mDisplayInformation->add_OrientationChanged(orientationChangedHandler.Get(), &mOrientationChangedEventToken);
- orientationChangedHandler->Invoke(mDisplayInformation.Get(), nullptr);
- }
-#endif
-
if (SUCCEEDED(result))
{
return true;
@@ -150,34 +132,26 @@ void CoreWindowNativeWindow::unregisterForSizeChangeEvents()
{
(void)mCoreWindow->remove_SizeChanged(mSizeChangedEventToken);
}
-
-#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- if (mDisplayInformation)
- {
- (void)mDisplayInformation->remove_OrientationChanged(mOrientationChangedEventToken);
- }
-#endif
-
mSizeChangedEventToken.value = 0;
- mOrientationChangedEventToken.value = 0;
}
HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
- DXGIFactory *factory,
+ IDXGIFactory2 *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
- DXGISwapChain **swapChain)
+ IDXGISwapChain1 **swapChain)
{
- if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
+ if (device == nullptr || factory == nullptr || swapChain == nullptr || width == 0 ||
+ height == 0)
{
return E_INVALIDARG;
}
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
- swapChainDesc.Width = mRotationFlags ? height : width;
- swapChainDesc.Height = mRotationFlags ? width : height;
+ swapChainDesc.Width = width;
+ swapChainDesc.Height = height;
swapChainDesc.Format = format;
swapChainDesc.Stereo = FALSE;
swapChainDesc.SampleDesc.Count = 1;
@@ -195,17 +169,6 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
HRESULT result = factory->CreateSwapChainForCoreWindow(device, mCoreWindow.Get(), &swapChainDesc, nullptr, newSwapChain.ReleaseAndGetAddressOf());
if (SUCCEEDED(result))
{
-
-#if 0 //(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) // Qt: allow Windows Phone to resize, but don't modify the backing texture in the swap chain.
- // Test if swapchain supports resize. On Windows Phone devices, this will return DXGI_ERROR_UNSUPPORTED. On
- // other devices DXGI_ERROR_INVALID_CALL should be returned because the combination of flags passed
- // (DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE) are invalid flag combinations.
- if (newSwapChain->ResizeBuffers(swapChainDesc.BufferCount, swapChainDesc.Width, swapChainDesc.Height, swapChainDesc.Format, DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE) == DXGI_ERROR_UNSUPPORTED)
- {
- mSupportsSwapChainResize = false;
- }
-#endif // (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
-
result = newSwapChain.CopyTo(swapChain);
}
@@ -222,14 +185,16 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device,
return result;
}
-inline HRESULT CoreWindowNativeWindow::scaleSwapChain(const Size &windowSize, const RECT &clientRect)
+inline HRESULT CoreWindowNativeWindow::scaleSwapChain(const Size &windowSize,
+ const RECT &clientRect)
{
// We don't need to do any additional work to scale CoreWindow swapchains.
// Using DXGI_SCALING_STRETCH to create the swapchain above does all the necessary work.
return S_OK;
}
-HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, SIZE *windowSize)
+HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow> &coreWindow,
+ Size *windowSize)
{
ABI::Windows::Foundation::Rect bounds;
HRESULT result = coreWindow->get_Bounds(&bounds);
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
index fc1cd124a1..21855c2c3b 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
@@ -12,10 +12,10 @@
#include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h"
#include <memory>
-#include <windows.graphics.display.h>
+
+#include <EGL/eglplatform.h>
typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler;
-typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CGraphics__CDisplay__CDisplayInformation_IInspectable_t IDisplayOrientationEventHandler;
namespace rx
{
@@ -26,12 +26,12 @@ class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enabl
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override;
HRESULT createSwapChain(ID3D11Device *device,
- DXGIFactory *factory,
+ IDXGIFactory2 *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
- DXGISwapChain **swapChain) override;
+ IDXGISwapChain1 **swapChain) override;
protected:
HRESULT scaleSwapChain(const Size &windowSize, const RECT &clientRect) override;
@@ -42,13 +42,11 @@ class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enabl
private:
ComPtr<ABI::Windows::UI::Core::ICoreWindow> mCoreWindow;
ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap;
- ComPtr<ABI::Windows::Graphics::Display::IDisplayInformation> mDisplayInformation;
- EventRegistrationToken mOrientationChangedEventToken;
};
[uuid(7F924F66-EBAE-40E5-A10B-B8F35E245190)]
class CoreWindowSizeChangedHandler :
- public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, IWindowSizeChangedEventHandler, IDisplayOrientationEventHandler>
+ public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, IWindowSizeChangedEventHandler>
{
public:
CoreWindowSizeChangedHandler() { }
@@ -72,47 +70,21 @@ class CoreWindowSizeChangedHandler :
ABI::Windows::Foundation::Size windowSize;
if (SUCCEEDED(sizeChangedEventArgs->get_Size(&windowSize)))
{
- host->setNewClientSize(windowSize);
+ Size windowSizeInPixels = {ConvertDipsToPixels(windowSize.Width),
+ ConvertDipsToPixels(windowSize.Height)};
+ host->setNewClientSize(windowSizeInPixels);
}
}
return S_OK;
}
- IFACEMETHOD(Invoke)(ABI::Windows::Graphics::Display::IDisplayInformation *displayInformation, IInspectable *)
- {
- #if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
- NativeWindow::RotationFlags flags = NativeWindow::RotateNone;
- ABI::Windows::Graphics::Display::DisplayOrientations orientation;
- if (SUCCEEDED(displayInformation->get_CurrentOrientation(&orientation)))
- {
- switch (orientation)
- {
- case ABI::Windows::Graphics::Display::DisplayOrientations_Landscape:
- flags = NativeWindow::RotateLeft;
- break;
- case ABI::Windows::Graphics::Display::DisplayOrientations_LandscapeFlipped:
- flags = NativeWindow::RotateRight;
- break;
- default:
- break;
- }
- }
- std::shared_ptr<InspectableNativeWindow> host = mHost.lock();
- if (host)
- {
- host->setRotationFlags(flags);
- }
- #endif
- return S_OK;
- }
-
-
private:
std::weak_ptr<InspectableNativeWindow> mHost;
};
-HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, SIZE *windowSize);
+HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow> &coreWindow,
+ Size *windowSize);
}
#endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_COREWINDOWNATIVEWINDOW_H_
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
index aacfadd2f0..1bd796e58f 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
@@ -11,108 +11,6 @@
namespace rx
{
-NativeWindow::NativeWindow(EGLNativeWindowType window,
- const egl::Config *config,
- bool directComposition)
-{
- mWindow = window;
- mConfig = config;
-}
-
-NativeWindow::~NativeWindow()
-{
-}
-
-void NativeWindow::commitChange()
-{
-}
-
-bool NativeWindow::initialize()
-{
- // If the native window type is a IPropertySet, extract the
- // EGLNativeWindowType (IInspectable) and initialize the
- // proper host with this IPropertySet.
- ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet;
- ComPtr<IInspectable> eglNativeWindow;
- if (IsEGLConfiguredPropertySet(mWindow, &propertySet, &eglNativeWindow))
- {
- // A property set was found and the EGLNativeWindowType was
- // retrieved. The mWindow member of the host to must be updated
- // to use the EGLNativeWindowType specified in the property set.
- // mWindow is treated as a raw pointer not an AddRef'd interface, so
- // the old mWindow does not need a Release() before this assignment.
- mWindow = eglNativeWindow.Get();
- }
-
- ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow;
- ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> swapChainPanel;
- if (IsCoreWindow(mWindow, &coreWindow))
- {
- mImpl = std::make_shared<CoreWindowNativeWindow>();
- if (mImpl)
- {
- return mImpl->initialize(mWindow, propertySet.Get());
- }
- }
- else if (IsSwapChainPanel(mWindow, &swapChainPanel))
- {
- mImpl = std::make_shared<SwapChainPanelNativeWindow>();
- if (mImpl)
- {
- return mImpl->initialize(mWindow, propertySet.Get());
- }
- }
- else
- {
- ERR("Invalid IInspectable EGLNativeWindowType detected. Valid IInspectables include ICoreWindow, ISwapChainPanel and IPropertySet");
- }
-
- return false;
-}
-
-bool NativeWindow::getClientRect(RECT *rect)
-{
- if (mImpl)
- {
- return mImpl->getClientRect(rect);
- }
-
- return false;
-}
-
-#if defined(ANGLE_ENABLE_WINDOWS_STORE) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
-NativeWindow::RotationFlags NativeWindow::rotationFlags() const
-{
- if (mImpl)
- {
- return mImpl->rotationFlags();
- }
-
- return NativeWindow::RotateNone;
-}
-#endif
-
-bool NativeWindow::isIconic()
-{
- return false;
-}
-
-bool NativeWindow::isValidNativeWindow(EGLNativeWindowType window)
-{
- return IsValidEGLNativeWindowType(window);
-}
-
-HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain)
-{
- if (mImpl)
- {
- bool containsAlpha = (mConfig->alphaSize > 0);
- return mImpl->createSwapChain(device, factory, format, width, height, containsAlpha,
- swapChain);
- }
-
- return E_UNEXPECTED;
-}
bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow)
{
@@ -127,7 +25,7 @@ bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICo
{
if (coreWindow != nullptr)
{
- *coreWindow = coreWin.Detach();
+ *coreWindow = coreWin;
}
return true;
}
@@ -148,7 +46,7 @@ bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Xaml:
{
if (swapChainPanel != nullptr)
{
- *swapChainPanel = panel.Detach();
+ *swapChainPanel = panel;
}
return true;
}
@@ -185,7 +83,8 @@ bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Founda
// considered invalid.
if (SUCCEEDED(result) && !hasEglNativeWindowPropertyKey)
{
- ERR("Could not find EGLNativeWindowTypeProperty in IPropertySet. Valid EGLNativeWindowTypeProperty values include ICoreWindow");
+ ERR() << "Could not find EGLNativeWindowTypeProperty in IPropertySet. Valid "
+ "EGLNativeWindowTypeProperty values include ICoreWindow";
return false;
}
@@ -219,18 +118,6 @@ bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Founda
return false;
}
-// A Valid EGLNativeWindowType IInspectable can only be:
-//
-// ICoreWindow
-// ISwapChainPanel
-// IPropertySet
-//
-// Anything else will be rejected as an invalid IInspectable.
-bool IsValidEGLNativeWindowType(EGLNativeWindowType window)
-{
- return IsCoreWindow(window) || IsSwapChainPanel(window) || IsEGLConfiguredPropertySet(window);
-}
-
// Retrieve an optional property from a property set
HRESULT GetOptionalPropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>> &propertyMap,
const wchar_t *propertyName,
@@ -381,7 +268,13 @@ HRESULT GetOptionalSinglePropertyValue(const ComPtr<ABI::Windows::Foundation::Co
return result;
}
-static float GetLogicalDpi()
+RECT InspectableNativeWindow::clientRect(const Size &size)
+{
+ return {0, 0, static_cast<long>(ConvertDipsToPixels(size.Width)),
+ static_cast<long>(ConvertDipsToPixels(size.Height))};
+}
+
+float GetLogicalDpi()
{
ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> displayProperties;
float dpi = 96.0f;
@@ -396,7 +289,7 @@ static float GetLogicalDpi()
return dpi;
}
-long ConvertDipsToPixels(float dips)
+float ConvertDipsToPixels(float dips)
{
static const float dipsPerInch = 96.0f;
return lround((dips * GetLogicalDpi() / dipsPerInch));
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
index 2d58f1c00a..d81c3e5fb9 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
@@ -10,14 +10,18 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
-#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
-
+#include "common/debug.h"
#include "common/platform.h"
#include "angle_windowsstore.h"
+#include <EGL/eglplatform.h>
+
+#include <windows.applicationmodel.core.h>
#include <windows.ui.xaml.h>
#include <windows.ui.xaml.media.dxinterop.h>
+#include <wrl.h>
+#include <wrl/wrappers/corewrappers.h>
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
@@ -26,7 +30,8 @@ using namespace ABI::Windows::Foundation::Collections;
namespace rx
{
-long ConvertDipsToPixels(float dips);
+float ConvertDipsToPixels(float dips);
+float GetLogicalDpi();
class InspectableNativeWindow
{
@@ -35,24 +40,25 @@ class InspectableNativeWindow
mSupportsSwapChainResize(true),
mSwapChainSizeSpecified(false),
mSwapChainScaleSpecified(false),
- mSwapChainScale(1.0f),
mClientRectChanged(false),
mClientRect({0,0,0,0}),
- mNewClientRect({0,0,0,0}),
- mRotationFlags(NativeWindow::RotateNone)
+ mNewClientRect({0,0,0,0})
{
mSizeChangedEventToken.value = 0;
+ mSwapChainScale = 96.0f / GetLogicalDpi();
+ if (mSwapChainScale != 1.0f)
+ mSwapChainScaleSpecified = true;
}
virtual ~InspectableNativeWindow(){}
virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0;
virtual HRESULT createSwapChain(ID3D11Device *device,
- DXGIFactory *factory,
+ IDXGIFactory2 *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
- DXGISwapChain **swapChain) = 0;
+ IDXGISwapChain1 **swapChain) = 0;
bool getClientRect(RECT *rect)
{
@@ -77,8 +83,7 @@ class InspectableNativeWindow
// If the swapchain size was specified then we should ignore this call too
if (!mSwapChainSizeSpecified)
{
- // We don't have to check if a swapchain scale was specified here; the default value is 1.0f which will have no effect.
- mNewClientRect = { 0, 0, ConvertDipsToPixels(newWindowSize.Width), ConvertDipsToPixels(newWindowSize.Height) };
+ mNewClientRect = clientRect(newWindowSize);
mClientRectChanged = true;
// If a scale was specified, then now is the time to apply the scale matrix for the new swapchain size and window size
@@ -97,18 +102,9 @@ class InspectableNativeWindow
}
}
- NativeWindow::RotationFlags rotationFlags() const
- {
- return mRotationFlags;
- }
-
- void setRotationFlags(NativeWindow::RotationFlags flags)
- {
- mRotationFlags = flags;
- }
-
protected:
virtual HRESULT scaleSwapChain(const Size &windowSize, const RECT &clientRect) = 0;
+ RECT clientRect(const Size &size);
bool mSupportsSwapChainResize; // Support for IDXGISwapChain::ResizeBuffers method
bool mSwapChainSizeSpecified; // If an EGLRenderSurfaceSizeProperty was specified
@@ -117,12 +113,10 @@ class InspectableNativeWindow
RECT mClientRect;
RECT mNewClientRect;
bool mClientRectChanged;
- NativeWindow::RotationFlags mRotationFlags;
EventRegistrationToken mSizeChangedEventToken;
};
-bool IsValidEGLNativeWindowType(EGLNativeWindowType window);
bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow = nullptr);
bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> *swapChainPanel = nullptr);
bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet = nullptr, IInspectable **inspectable = nullptr);
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
new file mode 100644
index 0000000000..655b23be83
--- /dev/null
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.cpp
@@ -0,0 +1,126 @@
+//
+// 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.
+//
+
+// NativeWindow11WinRT.cpp: NativeWindow base class for managing IInspectable native window types.
+
+#include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h"
+
+#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
+#include "libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h"
+#include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h"
+#include "libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h"
+
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+
+namespace rx
+{
+NativeWindow11WinRT::NativeWindow11WinRT(EGLNativeWindowType window, bool hasAlpha)
+ : NativeWindow11(window), mHasAlpha(hasAlpha)
+{
+}
+
+bool NativeWindow11WinRT::initialize()
+{
+ EGLNativeWindowType window = getNativeWindow();
+
+ // If the native window type is a IPropertySet, extract the
+ // EGLNativeWindowType (IInspectable) and initialize the
+ // proper host with this IPropertySet.
+ ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet;
+ ComPtr<IInspectable> eglNativeWindow;
+ if (IsEGLConfiguredPropertySet(window, &propertySet, &eglNativeWindow))
+ {
+ // A property set was found and the EGLNativeWindowType was
+ // retrieved. The mWindow member of the host to must be updated
+ // to use the EGLNativeWindowType specified in the property set.
+ // mWindow is treated as a raw pointer not an AddRef'd interface, so
+ // the old mWindow does not need a Release() before this assignment.
+ window = eglNativeWindow.Get();
+ }
+
+ ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow;
+ ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> swapChainPanel;
+ if (IsCoreWindow(window, &coreWindow))
+ {
+ mImpl = std::make_shared<CoreWindowNativeWindow>();
+ if (mImpl)
+ {
+ return mImpl->initialize(window, propertySet.Get());
+ }
+ }
+ else if (IsSwapChainPanel(window, &swapChainPanel))
+ {
+ mImpl = std::make_shared<SwapChainPanelNativeWindow>();
+ if (mImpl)
+ {
+ return mImpl->initialize(window, propertySet.Get());
+ }
+ }
+ else
+ {
+ ERR() << "Invalid IInspectable EGLNativeWindowType detected. Valid IInspectables include "
+ "ICoreWindow, ISwapChainPanel and IPropertySet";
+ }
+
+ return false;
+}
+
+bool NativeWindow11WinRT::getClientRect(LPRECT rect) const
+{
+ if (mImpl)
+ {
+ return mImpl->getClientRect(rect);
+ }
+
+ return false;
+}
+
+bool NativeWindow11WinRT::isIconic() const
+{
+ return false;
+}
+
+HRESULT NativeWindow11WinRT::createSwapChain(ID3D11Device *device,
+ IDXGIFactory *factory,
+ DXGI_FORMAT format,
+ UINT width,
+ UINT height,
+ UINT samples,
+ IDXGISwapChain **swapChain)
+{
+ if (mImpl)
+ {
+ IDXGIFactory2 *factory2 = d3d11::DynamicCastComObject<IDXGIFactory2>(factory);
+ IDXGISwapChain1 *swapChain1 = nullptr;
+ HRESULT result =
+ mImpl->createSwapChain(device, factory2, format, width, height, mHasAlpha, &swapChain1);
+ SafeRelease(factory2);
+ *swapChain = static_cast<IDXGISwapChain *>(swapChain1);
+ return result;
+ }
+
+ return E_UNEXPECTED;
+}
+
+void NativeWindow11WinRT::commitChange()
+{
+}
+
+// static
+bool NativeWindow11WinRT::IsValidNativeWindow(EGLNativeWindowType window)
+{
+ // A Valid EGLNativeWindowType IInspectable can only be:
+ //
+ // ICoreWindow
+ // ISwapChainPanel
+ // IPropertySet
+ //
+ // Anything else will be rejected as an invalid IInspectable.
+ return IsCoreWindow(window) || IsSwapChainPanel(window) || IsEGLConfiguredPropertySet(window);
+}
+
+} // namespace rx
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
new file mode 100644
index 0000000000..c4ac997a55
--- /dev/null
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h
@@ -0,0 +1,51 @@
+//
+// 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.
+//
+
+// NativeWindow11WinRT.h: NativeWindow base class for managing IInspectable native window types.
+
+#ifndef LIBANGLE_RENDERER_D3D_D3D11_WINRT_NATIVEWINDOW11WINRT_H_
+#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_NATIVEWINDOW11WINRT_H_
+
+#include "libANGLE/renderer/d3d/d3d11/NativeWindow11.h"
+
+#include <memory>
+#include <windows.applicationmodel.core.h>
+#include <wrl.h>
+#include <wrl/wrappers/corewrappers.h>
+
+namespace rx
+{
+class InspectableNativeWindow;
+
+class NativeWindow11WinRT : public NativeWindow11
+{
+ public:
+ NativeWindow11WinRT(EGLNativeWindowType window, bool hasAlpha);
+
+ bool initialize() override;
+ bool getClientRect(LPRECT rect) const override;
+ bool isIconic() const override;
+
+ HRESULT createSwapChain(ID3D11Device *device,
+ IDXGIFactory *factory,
+ DXGI_FORMAT format,
+ UINT width,
+ UINT height,
+ UINT samples,
+ IDXGISwapChain **swapChain) override;
+
+ void commitChange() override;
+
+ static bool IsValidNativeWindow(EGLNativeWindowType window);
+
+ private:
+ bool mHasAlpha;
+ std::shared_ptr<InspectableNativeWindow> mImpl;
+};
+
+} // namespace rx
+
+#endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_NATIVEWINDOW11WINRT_H_
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
index 548b4602fd..3425fad95d 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
@@ -49,7 +49,8 @@ HRESULT RunOnUIThread(CODE &&code, const ComPtr<ICoreDispatcher> &dispatcher)
}
else
{
- Event waitEvent(CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS));
+ Event waitEvent(
+ CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS));
if (!waitEvent.IsValid())
{
return E_FAIL;
@@ -78,7 +79,8 @@ HRESULT RunOnUIThread(CODE &&code, const ComPtr<ICoreDispatcher> &dispatcher)
// unrecoverable state (probably deadlocked). We therefore terminate the application
// entirely. This also prevents stack corruption if the async operation is eventually
// run.
- ERR("Timeout waiting for async action on UI thread. The UI thread might be blocked.");
+ ERR()
+ << "Timeout waiting for async action on UI thread. The UI thread might be blocked.";
std::terminate();
return E_FAIL;
}
@@ -132,7 +134,8 @@ bool SwapChainPanelNativeWindow::initialize(EGLNativeWindowType window, IPropert
// A EGLRenderSurfaceSizeProperty and a EGLRenderResolutionScaleProperty can't both be specified
if (mSwapChainScaleSpecified && mSwapChainSizeSpecified)
{
- ERR("It is invalid to specify both an EGLRenderSurfaceSizeProperty and a EGLRenderResolutionScaleProperty.");
+ ERR() << "It is invalid to specify both an EGLRenderSurfaceSizeProperty and a "
+ "EGLRenderResolutionScaleProperty.";
return false;
}
}
@@ -169,17 +172,14 @@ bool SwapChainPanelNativeWindow::initialize(EGLNativeWindowType window, IPropert
}
else
{
- SIZE swapChainPanelSize;
+ Size swapChainPanelSize;
result = GetSwapChainPanelSize(mSwapChainPanel, mSwapChainPanelDispatcher,
- &swapChainPanelSize, &mSwapChainScale);
- if (mSwapChainScale != 1.0f)
- mSwapChainScaleSpecified = true;
+ &swapChainPanelSize);
if (SUCCEEDED(result))
{
// Update the client rect to account for any swapchain scale factor
- mClientRect = { 0, 0, static_cast<long>(ConvertDipsToPixels(swapChainPanelSize.cx * mSwapChainScale)),
- static_cast<long>(ConvertDipsToPixels(swapChainPanelSize.cy * mSwapChainScale)) };
+ mClientRect = clientRect(swapChainPanelSize);
}
}
}
@@ -241,14 +241,15 @@ void SwapChainPanelNativeWindow::unregisterForSizeChangeEvents()
}
HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device,
- DXGIFactory *factory,
+ IDXGIFactory2 *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
- DXGISwapChain **swapChain)
+ IDXGISwapChain1 **swapChain)
{
- if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
+ if (device == nullptr || factory == nullptr || swapChain == nullptr || width == 0 ||
+ height == 0)
{
return E_INVALIDARG;
}
@@ -272,6 +273,7 @@ HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device,
ComPtr<IDXGISwapChain1> newSwapChain;
ComPtr<ISwapChainPanelNative> swapChainPanelNative;
+ Size currentPanelSize = {};
HRESULT result = factory->CreateSwapChainForComposition(device, &swapChainDesc, nullptr, newSwapChain.ReleaseAndGetAddressOf());
@@ -306,14 +308,14 @@ HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device,
{
if (mSwapChainSizeSpecified || mSwapChainScaleSpecified)
{
- ComPtr<ABI::Windows::UI::Xaml::IUIElement> uiElement;
- result = mSwapChainPanel.As(&uiElement);
- ASSERT(SUCCEEDED(result));
-
- Size currentSize;
- result = uiElement->get_RenderSize(&currentSize);
- ASSERT(SUCCEEDED(result));
- result = scaleSwapChain(currentSize, mClientRect);
+ result = GetSwapChainPanelSize(mSwapChainPanel, mSwapChainPanelDispatcher,
+ &currentPanelSize);
+
+ // Scale the swapchain to fit inside the contents of the panel.
+ if (SUCCEEDED(result))
+ {
+ result = scaleSwapChain(currentPanelSize, mClientRect);
+ }
}
}
@@ -342,31 +344,14 @@ HRESULT SwapChainPanelNativeWindow::scaleSwapChain(const Size &windowSize, const
HRESULT GetSwapChainPanelSize(
const ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> &swapChainPanel,
const ComPtr<ICoreDispatcher> &dispatcher,
- SIZE *windowSize, float *scaleFactor)
+ Size *windowSize)
{
ComPtr<IUIElement> uiElement;
- Size renderSize = {0, 0};
HRESULT result = swapChainPanel.As(&uiElement);
if (SUCCEEDED(result))
{
result = RunOnUIThread(
- [uiElement, &renderSize]
- {
- return uiElement->get_RenderSize(&renderSize);
- },
- dispatcher);
- }
-
- if (SUCCEEDED(result))
- {
- long width = ConvertDipsToPixels(renderSize.Width);
- long height = ConvertDipsToPixels(renderSize.Height);
- *windowSize = { width, height };
-
- if (scaleFactor)
- {
- *scaleFactor = renderSize.Width / width;
- }
+ [uiElement, windowSize] { return uiElement->get_RenderSize(windowSize); }, dispatcher);
}
return result;
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
index 09d87ad523..f9a2fc0e4b 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
@@ -11,6 +11,8 @@
#include "libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h"
+#include <memory>
+
namespace rx
{
class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::enable_shared_from_this<SwapChainPanelNativeWindow>
@@ -20,12 +22,12 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::e
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) override;
HRESULT createSwapChain(ID3D11Device *device,
- DXGIFactory *factory,
+ IDXGIFactory2 *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
- DXGISwapChain **swapChain) override;
+ IDXGISwapChain1 **swapChain) override;
protected:
HRESULT scaleSwapChain(const Size &windowSize, const RECT &clientRect) override;
@@ -37,7 +39,7 @@ class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::e
ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> mSwapChainPanel;
ComPtr<ABI::Windows::UI::Core::ICoreDispatcher> mSwapChainPanelDispatcher;
ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap;
- ComPtr<DXGISwapChain> mSwapChain;
+ ComPtr<IDXGISwapChain1> mSwapChain;
};
[uuid(8ACBD974-8187-4508-AD80-AEC77F93CF36)]
@@ -86,6 +88,6 @@ class SwapChainPanelSizeChangedHandler :
HRESULT GetSwapChainPanelSize(
const ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> &swapChainPanel,
const ComPtr<ABI::Windows::UI::Core::ICoreDispatcher> &dispatcher,
- SIZE *windowSize, float *scaleFactor);
+ Size *windowSize);
}
#endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_