Hash :
36013d99
Author :
Date :
2024-01-24T01:21:10
Improve build for UWP/Windows 10 These changes update the code for more modern compilers. The changes include: A) Not using deprecated APIs When Windows 8.1 was removed in commit 39b110184e2675afbfda1fd70b10ca112127ae74 the code was not updated to use the new APIs and still use the things that should not be used: > DisplayProperties may be altered or unavailable > for releases after Windows 8.1. Instead, use > DisplayInformation. B) Use correct casting There was also some changes in commit 5eadaf85b42ab1cbb1efcda558db58a3fe5a446a to properly cast from EGLNativeWindowType to IInspectable*, but this was not all of the cases. C) Prepare for WinUI3 There is another change that moves types into a using to reduce verbosity as well as make it easier/cleaner to build for WinUI/Windows App SDK. Bug: angleproject:8496 Change-Id: Ia11b7f92cb4abc524ab8316125e80a22898a8f6b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5232157 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
//
// Copyright 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 = reinterpret_cast<EGLNativeWindowType>(eglNativeWindow.Get());
}
ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow;
ComPtr<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 (samples > 1)
{
// Multisample not implemented for WinRT window types
return E_NOTIMPL;
}
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