Skip to content

Commit

Permalink
Make CompositorNativeWindow work in UWP as well as Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
James Clarke (WDG) authored and clarkezone committed Jan 19, 2020
1 parent 579c594 commit 4c8370f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
21 changes: 17 additions & 4 deletions src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

#ifdef ANGLE_ENABLE_WINDOWS_UWP
# include "libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h"
# include "libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h"
#else
# include "libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h"
# include "libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h"
Expand Down Expand Up @@ -1254,13 +1255,11 @@ void Renderer11::generateDisplayExtensions(egl::DisplayExtensions *outExtensions
// All D3D feature levels support robust resource init
outExtensions->robustResourceInitialization = true;

#if !defined(ANGLE_ENABLE_WINDOWS_UWP)
// Compositor Native Window capabilies require WinVer >= 1803
if (CompositorNativeWindow11::IsSupportedWinRelease())
{
outExtensions->windowsUIComposition = true;
}
#endif
}

angle::Result Renderer11::flush(Context11 *context11)
Expand Down Expand Up @@ -1319,7 +1318,12 @@ bool Renderer11::isValidNativeWindow(EGLNativeWindowType window) const
"Pointer size must match Window Handle size");

#if defined(ANGLE_ENABLE_WINDOWS_UWP)
return NativeWindow11WinRT::IsValidNativeWindow(window);
bool winrt = NativeWindow11WinRT::IsValidNativeWindow(window);
if (!winrt)
{
return CompositorNativeWindow11::IsValidNativeWindow(window);
}
return true;
#else
if (NativeWindow11Win32::IsValidNativeWindow(window))
{
Expand All @@ -1334,8 +1338,17 @@ NativeWindowD3D *Renderer11::createNativeWindow(EGLNativeWindowType window,
const egl::Config *config,
const egl::AttributeMap &attribs) const
{
//TODO: why does the non-winrt path not validate against compositornativewindow
#if defined(ANGLE_ENABLE_WINDOWS_UWP)
return new NativeWindow11WinRT(window, config->alphaSize > 0);
auto useWinUiComp = window != nullptr && CompositorNativeWindow11::IsValidNativeWindow(window);
if (useWinUiComp)
{
return new CompositorNativeWindow11(window, config->alphaSize > 0);
}
else
{
return new NativeWindow11WinRT(window, config->alphaSize > 0);
}
#else
auto useWinUiComp = window != nullptr && !NativeWindow11Win32::IsValidNativeWindow(window);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,21 @@ RoHelper::RoHelper()
mComBaseModule(nullptr),
mCoreMessagingModule(nullptr)
{
if (!IsWindows10OrGreater())
/*if (!IsWindows10OrGreater())
{
return;
}
}*/

#ifdef ANGLE_ENABLE_WINDOWS_UWP
mFpWindowsCreateStringReference = &::WindowsCreateStringReference;
mFpRoInitialize = &::RoInitialize;
mFpRoUninitialize = &::RoUninitialize;
mFpWindowsDeleteString = &::WindowsDeleteString;
mFpGetActivationFactory = &::RoGetActivationFactory;
mFpWindowsCompareStringOrdinal = &::WindowsCompareStringOrdinal;
mFpCreateDispatcherQueueController = &::CreateDispatcherQueueController;

#else

mComBaseModule = LoadLibraryA("ComBase.dll");

Expand All @@ -255,6 +266,7 @@ RoHelper::RoHelper()
return;
}


if (!AssignProcAddress(mComBaseModule, "RoGetActivationFactory", mFpGetActivationFactory))
{
return;
Expand Down Expand Up @@ -294,17 +306,23 @@ RoHelper::RoHelper()
return;
}

if (SUCCEEDED(RoInitialize(RO_INIT_MULTITHREADED)))
auto result = RoInitialize(RO_INIT_SINGLETHREADED);

if (SUCCEEDED(result))
{
mWinRtAvailable = true;
//TODO
}
#endif

mWinRtAvailable = true;
}

RoHelper::~RoHelper()
{
if (mWinRtAvailable)
{
RoUninitialize();
//TODO
//RoUninitialize();
}

if (mCoreMessagingModule != nullptr)
Expand All @@ -327,7 +345,8 @@ bool RoHelper::WinRtAvailable() const

bool RoHelper::SupportedWindowsRelease()
{
if (!IsWindows10OrGreater() || !mWinRtAvailable)
//if (!IsWindows10OrGreater() || !mWinRtAvailable)
if (!mWinRtAvailable)
{
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/libGLESv2.gni
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ libangle_d3d11_winuwp_sources = [
"src/libANGLE/renderer/d3d/d3d11/winrt/NativeWindow11WinRT.h",
"src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp",
"src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h",
"src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.cpp",
"src/libANGLE/renderer/d3d/d3d11/converged/CompositorNativeWindow11.h",
]

libangle_gl_sources = [
Expand Down
7 changes: 4 additions & 3 deletions util/test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ namespace angle
{
bool CreateTemporaryFile(char *tempFileNameOut, uint32_t maxFileNameLen)
{
constexpr uint32_t kMaxPath = 1000u;
/*constexpr uint32_t kMaxPath = 1000u;
char tempPath[kMaxPath];
if (!GetTempDir(tempPath, kMaxPath))
return false;
return CreateTemporaryFileInDir(tempPath, tempFileNameOut, maxFileNameLen);
return CreateTemporaryFileInDir(tempPath, tempFileNameOut, maxFileNameLen);*/
return false;
}

bool GetFileSize(const char *filePath, uint32_t *sizeOut)
Expand Down Expand Up @@ -67,7 +68,7 @@ ProcessHandle::ProcessHandle(Process *process) : mProcess(process) {}
ProcessHandle::ProcessHandle(const std::vector<const char *> &args,
bool captureStdout,
bool captureStderr)
: mProcess(LaunchProcess(args, captureStdout, captureStderr))
//: mProcess(LaunchProcess(args, captureStdout, captureStderr))
{}

ProcessHandle::~ProcessHandle()
Expand Down

0 comments on commit 4c8370f

Please sign in to comment.