Commit 06d194e2 by James Clarke Committed by Commit Bot

Reland "Add support for building in Flutter Windows UWP configuration"

This is a reland of 68ac4e43 Original change's description: > Add support for building in Flutter Windows UWP configuration > > Bug: angleproject:5527 > Change-Id: Idf5a4cbb6f84b24fa2448157cab1b6a3bce4d8be > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2620580 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Jamie Madill <jmadill@chromium.org> Bug: angleproject:5527 Change-Id: I3d5c3a35d73e3946ae40c779e76e0343039bf660 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2693639Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarAustin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
parent a11d65a1
...@@ -260,6 +260,12 @@ config("includes_config") { ...@@ -260,6 +260,12 @@ config("includes_config") {
include_dirs = [ "include" ] include_dirs = [ "include" ]
} }
config("angle_uwp_env") {
if (angle_is_winuwp) {
defines = [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ]
}
}
angle_source_set("includes") { angle_source_set("includes") {
sources = libangle_includes sources = libangle_includes
public_configs = [ ":includes_config" ] public_configs = [ ":includes_config" ]
...@@ -650,6 +656,10 @@ config("angle_backend_config") { ...@@ -650,6 +656,10 @@ config("angle_backend_config") {
if (angle_enable_vulkan) { if (angle_enable_vulkan) {
configs += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ] configs += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend_config" ]
} }
if (angle_is_winuwp) {
configs += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp_config" ]
}
} }
config("libANGLE_config") { config("libANGLE_config") {
...@@ -759,7 +769,7 @@ angle_source_set("libANGLE_base") { ...@@ -759,7 +769,7 @@ angle_source_set("libANGLE_base") {
":includes", ":includes",
] ]
if (is_win) { if (is_win && !angle_is_winuwp) {
libs += [ libs += [
"gdi32.lib", "gdi32.lib",
"user32.lib", "user32.lib",
...@@ -786,6 +796,14 @@ angle_source_set("libANGLE_base") { ...@@ -786,6 +796,14 @@ angle_source_set("libANGLE_base") {
public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ] public_deps += [ "src/libANGLE/renderer/vulkan:angle_vulkan_backend" ]
} }
if (angle_is_winuwp) {
public_deps += [ "src/libANGLE/renderer/d3d:angle_enable_winuwp" ]
}
if (angle_enable_d3d11) {
libs += [ "dxguid.lib" ]
}
if (angle_enable_metal) { if (angle_enable_metal) {
public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ] public_deps += [ "src/libANGLE/renderer/metal:angle_metal_backend" ]
} }
...@@ -1028,6 +1046,7 @@ if (is_win && !angle_is_winuwp) { ...@@ -1028,6 +1046,7 @@ if (is_win && !angle_is_winuwp) {
angle_static_library("libGLESv2_static") { angle_static_library("libGLESv2_static") {
sources = libglesv2_sources sources = libglesv2_sources
configs += [ ":debug_annotations_config" ] configs += [ ":debug_annotations_config" ]
public_configs += [ ":angle_static" ] public_configs += [ ":angle_static" ]
deps = [ ":includes" ] deps = [ ":includes" ]
public_deps = [ ":libANGLE" ] public_deps = [ ":libANGLE" ]
......
...@@ -82,7 +82,7 @@ declare_args() { ...@@ -82,7 +82,7 @@ declare_args() {
angle_shared_libvulkan = !is_mac angle_shared_libvulkan = !is_mac
# There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves # There's no "is_winuwp" helper in BUILDCONFIG.gn, so we define one ourselves
angle_is_winuwp = is_win && current_os == "winuwp" angle_is_winuwp = is_win && target_os == "winuwp"
# Default to using "_angle" suffix on Android # Default to using "_angle" suffix on Android
if (is_android) { if (is_android) {
...@@ -184,6 +184,7 @@ angle_common_configs = [ ...@@ -184,6 +184,7 @@ angle_common_configs = [
angle_root + ":constructor_and_destructor_warnings", angle_root + ":constructor_and_destructor_warnings",
angle_root + ":extra_warnings", angle_root + ":extra_warnings",
angle_root + ":internal_config", angle_root + ":internal_config",
angle_root + ":angle_uwp_env",
] ]
angle_remove_configs = [] angle_remove_configs = []
......
...@@ -256,6 +256,8 @@ if (angle_enable_d3d11) { ...@@ -256,6 +256,8 @@ if (angle_enable_d3d11) {
if (angle_is_winuwp) { if (angle_is_winuwp) {
_d3d11_backend_sources += [ _d3d11_backend_sources += [
"d3d11/converged/CompositorNativeWindow11.cpp",
"d3d11/converged/CompositorNativeWindow11.h",
"d3d11/winrt/CoreWindowNativeWindow.cpp", "d3d11/winrt/CoreWindowNativeWindow.cpp",
"d3d11/winrt/CoreWindowNativeWindow.h", "d3d11/winrt/CoreWindowNativeWindow.h",
"d3d11/winrt/InspectableNativeWindow.cpp", "d3d11/winrt/InspectableNativeWindow.cpp",
...@@ -323,4 +325,12 @@ if (angle_enable_d3d11) { ...@@ -323,4 +325,12 @@ if (angle_enable_d3d11) {
public_deps = [ ":angle_d3d_shared" ] public_deps = [ ":angle_d3d_shared" ]
public_configs = [ ":angle_d3d11_backend_config" ] public_configs = [ ":angle_d3d11_backend_config" ]
} }
config("angle_enable_winuwp_config") {
defines = [ "ANGLE_ENABLE_WINDOWS_UWP 1" ]
}
angle_source_set("angle_enable_winuwp") {
public_configs = [ ":angle_enable_winuwp_config" ]
}
} }
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include "libANGLE/trace.h" #include "libANGLE/trace.h"
#ifdef ANGLE_ENABLE_WINDOWS_UWP #ifdef ANGLE_ENABLE_WINDOWS_UWP
# include "libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h"
# include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h" # include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h"
#else #else
# include "libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h" # include "libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h"
...@@ -1316,13 +1317,11 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions ...@@ -1316,13 +1317,11 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions
// All D3D feature levels support robust resource init // All D3D feature levels support robust resource init
outExtensions->robustResourceInitialization = true; outExtensions->robustResourceInitialization = true;
#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
// Compositor Native Window capabilies require WinVer >= 1803 // Compositor Native Window capabilies require WinVer >= 1803
if (CompositorNativeWindow11::IsSupportedWinRelease()) if (CompositorNativeWindow11::IsSupportedWinRelease())
{ {
outExtensions->windowsUIComposition = true; outExtensions->windowsUIComposition = true;
} }
#endif
} }
angle::Result Renderer11::flush(Context11 *context11) angle::Result Renderer11::flush(Context11 *context11)
...@@ -1381,7 +1380,12 @@ bool Renderer11::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -1381,7 +1380,12 @@ bool Renderer11::isValidNativeWindow(EGLNativeWindowType window) const
"Pointer size must match Window Handle size"); "Pointer size must match Window Handle size");
#if defined(ANGLE_ENABLE_WINDOWS_UWP) #if defined(ANGLE_ENABLE_WINDOWS_UWP)
return NativeWindow11WinRT::IsValidNativeWindow(window); bool winrt = NativeWindow11WinRT::IsValidNativeWindow(window);
if (!winrt)
{
return CompositorNativeWindow11::IsValidNativeWindow(window);
}
return true;
#else #else
if (NativeWindow11Win32::IsValidNativeWindow(window)) if (NativeWindow11Win32::IsValidNativeWindow(window))
{ {
...@@ -1397,9 +1401,19 @@ NativeWindowD3D *Renderer11::createNativeWindow(EGLNativeWindowType window, ...@@ -1397,9 +1401,19 @@ NativeWindowD3D *Renderer11::createNativeWindow(EGLNativeWindowType window,
const egl::AttributeMap &attribs) const const egl::AttributeMap &attribs) const
{ {
#if defined(ANGLE_ENABLE_WINDOWS_UWP) #if defined(ANGLE_ENABLE_WINDOWS_UWP)
auto useWinUiComp = window != nullptr && CompositorNativeWindow11::IsValidNativeWindow(window);
if (useWinUiComp)
{
return new CompositorNativeWindow11(window, config->alphaSize > 0);
}
else
{
return new NativeWindow11WinRT(window, config->alphaSize > 0); return new NativeWindow11WinRT(window, config->alphaSize > 0);
}
return nullptr;
#else #else
auto useWinUiComp = window != nullptr && !NativeWindow11Win32::IsValidNativeWindow(window); auto useWinUiComp = window != nullptr && !NativeWindow11Win32::IsValidNativeWindow(window) &&
CompositorNativeWindow11::IsValidNativeWindow(window);
if (useWinUiComp) if (useWinUiComp)
{ {
......
...@@ -118,7 +118,9 @@ HRESULT CompositorNativeWindow11::createSwapChain(ID3D11Device *device, ...@@ -118,7 +118,9 @@ HRESULT CompositorNativeWindow11::createSwapChain(ID3D11Device *device,
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.AlphaMode = mHasAlpha ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE; swapChainDesc.AlphaMode = mHasAlpha ? DXGI_ALPHA_MODE_PREMULTIPLIED : DXGI_ALPHA_MODE_IGNORE;
#ifndef ANGLE_ENABLE_WINDOWS_UWP
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG::DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG::DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
#endif
Microsoft::WRL::ComPtr<IDXGISwapChain1> swapChain1; Microsoft::WRL::ComPtr<IDXGISwapChain1> swapChain1;
hr = factory2->CreateSwapChainForComposition(device, &swapChainDesc, nullptr, &swapChain1); hr = factory2->CreateSwapChainForComposition(device, &swapChainDesc, nullptr, &swapChain1);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
...@@ -237,10 +239,17 @@ RoHelper::RoHelper() ...@@ -237,10 +239,17 @@ RoHelper::RoHelper()
mComBaseModule(nullptr), mComBaseModule(nullptr),
mCoreMessagingModule(nullptr) mCoreMessagingModule(nullptr)
{ {
if (!IsWindows10OrGreater())
{ #ifdef ANGLE_ENABLE_WINDOWS_UWP
return; mFpWindowsCreateStringReference = &::WindowsCreateStringReference;
} mFpRoInitialize = &::RoInitialize;
mFpRoUninitialize = &::RoUninitialize;
mFpWindowsDeleteString = &::WindowsDeleteString;
mFpGetActivationFactory = &::RoGetActivationFactory;
mFpWindowsCompareStringOrdinal = &::WindowsCompareStringOrdinal;
mFpCreateDispatcherQueueController = &::CreateDispatcherQueueController;
mWinRtAvailable = true;
#else
mComBaseModule = LoadLibraryA("ComBase.dll"); mComBaseModule = LoadLibraryA("ComBase.dll");
...@@ -294,14 +303,18 @@ RoHelper::RoHelper() ...@@ -294,14 +303,18 @@ RoHelper::RoHelper()
return; return;
} }
if (SUCCEEDED(RoInitialize(RO_INIT_MULTITHREADED))) auto result = RoInitialize(RO_INIT_MULTITHREADED);
if (SUCCEEDED(result) || result == S_FALSE || result == RPC_E_CHANGED_MODE)
{ {
mWinRtAvailable = true; mWinRtAvailable = true;
} }
#endif
} }
RoHelper::~RoHelper() RoHelper::~RoHelper()
{ {
#ifndef ANGLE_ENABLE_WINDOWS_UWP
if (mWinRtAvailable) if (mWinRtAvailable)
{ {
RoUninitialize(); RoUninitialize();
...@@ -318,6 +331,7 @@ RoHelper::~RoHelper() ...@@ -318,6 +331,7 @@ RoHelper::~RoHelper()
FreeLibrary(mComBaseModule); FreeLibrary(mComBaseModule);
mComBaseModule = nullptr; mComBaseModule = nullptr;
} }
#endif
} }
bool RoHelper::WinRtAvailable() const bool RoHelper::WinRtAvailable() const
...@@ -327,7 +341,7 @@ bool RoHelper::WinRtAvailable() const ...@@ -327,7 +341,7 @@ bool RoHelper::WinRtAvailable() const
bool RoHelper::SupportedWindowsRelease() bool RoHelper::SupportedWindowsRelease()
{ {
if (!IsWindows10OrGreater() || !mWinRtAvailable) if (!mWinRtAvailable)
{ {
return false; return false;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <EGL/eglplatform.h> #include <EGL/eglplatform.h>
#include <windows.applicationmodel.core.h> #include <windows.applicationmodel.core.h>
#undef GetCurrentTime
#include <windows.ui.xaml.h> #include <windows.ui.xaml.h>
#include <windows.ui.xaml.media.dxinterop.h> #include <windows.ui.xaml.media.dxinterop.h>
#include <wrl.h> #include <wrl.h>
......
...@@ -95,7 +95,7 @@ if (is_apple) { ...@@ -95,7 +95,7 @@ if (is_apple) {
if (is_win) { if (is_win) {
libangle_common_sources += [ "src/common/system_utils_win.cpp" ] libangle_common_sources += [ "src/common/system_utils_win.cpp" ]
if (current_os == "winuwp") { if (target_os == "winuwp") {
libangle_common_sources += [ "src/common/system_utils_winuwp.cpp" ] libangle_common_sources += [ "src/common/system_utils_winuwp.cpp" ]
} else { } else {
libangle_common_sources += [ "src/common/system_utils_win32.cpp" ] libangle_common_sources += [ "src/common/system_utils_win32.cpp" ]
......
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