Hash :
a70b6f56
Author :
Date :
2024-01-26T20:37:07
Add support for WinUI3/Windows App SDK Adds the necessary build args and code changes to support building ANGLE for WinUI 3 (aka Windows App SDK). To reduce the set of changes, and because it is functionally the same, a Windows App SDK build is basically a UWP build, but with an extra define so that the code can make a few changes to the namespaces and includes used. The main changes to the code are: - ICoreWindow is no longer used - Dispatcher has a few changes in naming and args - ISwapChainPanel is now in a different namespace Bug: angleproject:8490 Change-Id: Ibb298e3e86e8298dac12c2019eac7996a8185c51 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5230637 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
//
// Copyright 2014 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.
//
// InspectableNativeWindow.h: Host specific implementation interface for
// managing IInspectable native window types.
#ifndef LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
#include "common/debug.h"
#include "common/platform.h"
#include "angle_windowsstore.h"
#include <EGL/eglplatform.h>
#include <windows.applicationmodel.core.h>
#undef GetCurrentTime
#if defined(ANGLE_ENABLE_WINDOWS_APP_SDK)
# include <microsoft.ui.dispatching.h>
# include <microsoft.ui.xaml.h>
# include <microsoft.ui.xaml.media.dxinterop.h>
#else
# include <windows.ui.xaml.h>
# include <windows.ui.xaml.media.dxinterop.h>
#endif
#include <wrl.h>
#include <wrl/wrappers/corewrappers.h>
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections;
#if defined(ANGLE_ENABLE_WINDOWS_APP_SDK)
using ISwapChainPanel = ABI::Microsoft::UI::Xaml::Controls::ISwapChainPanel;
#else
using ISwapChainPanel = ABI::Windows::UI::Xaml::Controls::ISwapChainPanel;
#endif
namespace rx
{
class InspectableNativeWindow
{
public:
InspectableNativeWindow()
: mSupportsSwapChainResize(true),
mSwapChainSizeSpecified(false),
mSwapChainScaleSpecified(false),
mSwapChainScale(1.0f),
mClientRectChanged(false),
mClientRect({0, 0, 0, 0}),
mNewClientRect({0, 0, 0, 0})
{
mSizeChangedEventToken.value = 0;
}
virtual ~InspectableNativeWindow() {}
virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0;
virtual HRESULT createSwapChain(ID3D11Device *device,
IDXGIFactory2 *factory,
DXGI_FORMAT format,
unsigned int width,
unsigned int height,
bool containsAlpha,
IDXGISwapChain1 **swapChain) = 0;
bool getClientRect(RECT *rect)
{
if (mClientRectChanged)
{
mClientRect = mNewClientRect;
}
*rect = mClientRect;
return true;
}
// setNewClientSize is used by the WinRT size change handler. It isn't used by the rest of
// ANGLE.
void setNewClientSize(const Size &newWindowSize)
{
// If the client doesn't support swapchain resizing then we should have already unregistered
// from size change handler
ASSERT(mSupportsSwapChainResize);
if (mSupportsSwapChainResize)
{
// If the swapchain size was specified then we should ignore this call too
if (!mSwapChainSizeSpecified)
{
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
if (mSwapChainScaleSpecified)
{
scaleSwapChain(newWindowSize, mNewClientRect);
}
}
// Even if the swapchain size was fixed, the window might have changed size.
// In this case, we should recalculate the scale matrix to account for the new window
// size
if (mSwapChainSizeSpecified)
{
scaleSwapChain(newWindowSize, mClientRect);
}
}
}
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
bool mSwapChainScaleSpecified; // If an EGLRenderResolutionScaleProperty was specified
float mSwapChainScale; // The scale value specified by the EGLRenderResolutionScaleProperty
// property
RECT mClientRect;
RECT mNewClientRect;
bool mClientRectChanged;
EventRegistrationToken mSizeChangedEventToken;
};
bool IsCoreWindow(EGLNativeWindowType window,
ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow = nullptr);
bool IsSwapChainPanel(EGLNativeWindowType window,
ComPtr<ISwapChainPanel> *swapChainPanel = nullptr);
bool IsEGLConfiguredPropertySet(
EGLNativeWindowType window,
ABI::Windows::Foundation::Collections::IPropertySet **propertySet = nullptr,
IInspectable **inspectable = nullptr);
HRESULT GetOptionalPropertyValue(
const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable *>> &propertyMap,
const wchar_t *propertyName,
boolean *hasKey,
ComPtr<ABI::Windows::Foundation::IPropertyValue> &propertyValue);
HRESULT GetOptionalSizePropertyValue(
const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable *>> &propertyMap,
const wchar_t *propertyName,
SIZE *value,
bool *valueExists);
HRESULT GetOptionalSinglePropertyValue(
const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable *>> &propertyMap,
const wchar_t *propertyName,
float *value,
bool *valueExists);
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_