Commit 980eb8f3 by Cooper Partin Committed by Geoff Lang

Added ISwapChainPanel support

Change-Id: I26faa32804ee47cb6ad8458c90abeb93a01dfbdf Reviewed-on: https://chromium-review.googlesource.com/224991Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 45b474d8
......@@ -509,8 +509,9 @@
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\TextureStorage11.h"/>
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexArray11.h"/>
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\src\common\RefCountObject.cpp"/>
......@@ -592,8 +593,9 @@
<ClCompile Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\SwapChain11.cpp"/>
<ClCompile Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\TextureStorage11.cpp"/>
<ClCompile Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="commit_id.vcxproj">
......
......@@ -2914,6 +2914,24 @@
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src\common">
<UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
</Filter>
<Filter Include="src\common\winrt">
<UniqueIdentifier>{8C13C927-D4CA-F91A-E2C8-EF73D673852B}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src\common">
<UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
</Filter>
<Filter Include="src\common\winrt">
<UniqueIdentifier>{8C13C927-D4CA-F91A-E2C8-EF73D673852B}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\include\EGL\egl.h">
......@@ -3660,16 +3678,22 @@
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.h">
<Filter>src\libGLESv2\renderer\d3d\d3d11</Filter>
</ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.cpp">
<Filter>src\common\winrt</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.h">
<Filter>src\common\winrt</Filter>
</ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.cpp">
<Filter>src\common\winrt</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h">
<Filter>src\common\winrt</Filter>
</ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp">
<ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp">
<Filter>src\common\winrt</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h">
<ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h">
<Filter>src\common\winrt</Filter>
</ClInclude>
<None Include="..\..\..\..\src\angle.gyp">
......
......@@ -377,8 +377,9 @@
<ClInclude Include="..\..\..\..\src\libEGL\Surface.h"/>
<ClInclude Include="..\..\..\..\src\libEGL\main.h"/>
<ClInclude Include="..\..\..\..\src\libEGL\resource.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\src\common\RefCountObject.cpp"/>
......@@ -395,8 +396,9 @@
<ClCompile Include="..\..\..\..\src\libEGL\Surface.cpp"/>
<ClCompile Include="..\..\..\..\src\libEGL\libEGL.cpp"/>
<ClCompile Include="..\..\..\..\src\libEGL\main.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp"/>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\..\src\libEGL\libEGL.rc"/>
......
......@@ -313,6 +313,24 @@
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src\common">
<UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
</Filter>
<Filter Include="src\common\winrt">
<UniqueIdentifier>{8C13C927-D4CA-F91A-E2C8-EF73D673852B}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src\common">
<UniqueIdentifier>{2F5FD094-EF52-77F7-7AA8-4327A01BF747}</UniqueIdentifier>
</Filter>
<Filter Include="src\common\winrt">
<UniqueIdentifier>{8C13C927-D4CA-F91A-E2C8-EF73D673852B}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\include\EGL\egl.h">
......@@ -453,16 +471,22 @@
<ClInclude Include="..\..\..\..\src\libEGL\resource.h">
<Filter>src\libEGL</Filter>
</ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.cpp">
<Filter>src\common\winrt</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\SwapChainPanelNativeWindow.h">
<Filter>src\common\winrt</Filter>
</ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.cpp">
<Filter>src\common\winrt</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h">
<Filter>src\common\winrt</Filter>
</ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp">
<ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp">
<Filter>src\common\winrt</Filter>
</ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h">
<ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h">
<Filter>src\common\winrt</Filter>
</ClInclude>
<None Include="..\..\..\..\src\angle.gyp">
......
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 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.
//
......@@ -29,7 +29,10 @@ typedef IDXGIFactory2 DXGIFactory;
#include <windows.applicationmodel.core.h>
#include <memory>
class IInspectableNativeWindow;
namespace rx
{
class InspectableNativeWindow;
}
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
......@@ -43,7 +46,7 @@ namespace rx
{
class NativeWindow
{
public:
public:
explicit NativeWindow(EGLNativeWindowType window);
bool initialize();
......@@ -56,16 +59,16 @@ public:
inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
private:
private:
EGLNativeWindowType mWindow;
#if defined(ANGLE_ENABLE_WINDOWS_STORE)
std::shared_ptr<IInspectableNativeWindow> mImpl;
std::shared_ptr<InspectableNativeWindow> mImpl;
#endif
};
}
bool isValidEGLNativeWindowType(EGLNativeWindowType window);
bool IsValidEGLNativeWindowType(EGLNativeWindowType window);
}
#endif // COMMON_NATIVEWINDOW_H_
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 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.
//
......@@ -9,13 +9,13 @@
#include "common/NativeWindow.h"
#include "common/debug.h"
bool isValidEGLNativeWindowType(EGLNativeWindowType window)
namespace rx
{
bool IsValidEGLNativeWindowType(EGLNativeWindowType window)
{
return (IsWindow(window) == TRUE);
}
namespace rx
{
NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
{
}
......@@ -63,4 +63,4 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
}
};
\ No newline at end of file
}
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 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.
//
......@@ -10,6 +10,8 @@
#include "common/winrt/CoreWindowNativeWindow.h"
using namespace ABI::Windows::Foundation::Collections;
namespace rx
{
CoreWindowNativeWindow::~CoreWindowNativeWindow()
{
unregisterForSizeChangeEvents();
......@@ -23,7 +25,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
bool swapChainSizeSpecified = false;
HRESULT result = S_OK;
// IPropertySet is an optional parameter and can null.
// IPropertySet is an optional parameter and can be null.
// If one is specified, cache as an IMap and read the properties
// used for initial host initialization.
if (propertySet)
......@@ -34,7 +36,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
// The EGLRenderSurfaceSizeProperty is optional and may be missing. The IPropertySet
// was prevalidated to contain the EGLNativeWindowType before being passed to
// this host.
result = getOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified);
result = GetOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified);
}
}
......@@ -58,7 +60,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
}
else
{
result = getCoreWindowSizeInPixels(mCoreWindow, &mClientRect);
result = GetCoreWindowSizeInPixels(mCoreWindow, &mClientRect);
}
}
......@@ -150,7 +152,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor
return result;
}
HRESULT getCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, RECT *windowSize)
HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, RECT *windowSize)
{
ABI::Windows::Foundation::Rect bounds;
HRESULT result = coreWindow->get_Bounds(&bounds);
......@@ -181,4 +183,5 @@ long ConvertDipsToPixels(float dips)
{
static const float dipsPerInch = 96.0f;
return lround((dips * GetLogicalDpi() / dipsPerInch));
}
}
\ No newline at end of file
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 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.
//
// CoreWindowNativeWindow.h: NativeWindow for managing ICoreWindow native window types.
#ifndef COMMON_COREWINDOWNATIVEWINDOW_H_
#define COMMON_COREWINDOWNATIVEWINDOW_H_
#ifndef COMMON_WINRT_COREWINDOWNATIVEWINDOW_H_
#define COMMON_WINRT_COREWINDOWNATIVEWINDOW_H_
#include "common/winrt/IInspectableNativeWindow.h"
#include "common/winrt/InspectableNativeWindow.h"
#include <memory>
typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler;
namespace rx
{
long ConvertDipsToPixels(float dips);
class CoreWindowNativeWindow : public IInspectableNativeWindow, public std::enable_shared_from_this<CoreWindowNativeWindow>
class CoreWindowNativeWindow : public InspectableNativeWindow, public std::enable_shared_from_this<CoreWindowNativeWindow>
{
public:
~CoreWindowNativeWindow();
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet);
bool registerForSizeChangeEvents();
void unregisterForSizeChangeEvents();
HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain);
private:
ComPtr<ABI::Windows::UI::Core::ICoreWindow> mCoreWindow;
ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap;
......@@ -34,7 +39,7 @@ class CoreWindowSizeChangedHandler :
{
public:
CoreWindowSizeChangedHandler() { }
HRESULT RuntimeClassInitialize(std::shared_ptr<IInspectableNativeWindow> host)
HRESULT RuntimeClassInitialize(std::shared_ptr<InspectableNativeWindow> host)
{
if (!host)
{
......@@ -46,13 +51,13 @@ class CoreWindowSizeChangedHandler :
}
// IWindowSizeChangedEventHandler
IFACEMETHOD(Invoke)(ABI::Windows::UI::Core::ICoreWindow *sender, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *e)
IFACEMETHOD(Invoke)(ABI::Windows::UI::Core::ICoreWindow *sender, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *sizeChangedEventArgs)
{
std::shared_ptr<IInspectableNativeWindow> host = mHost.lock();
std::shared_ptr<InspectableNativeWindow> host = mHost.lock();
if (host)
{
ABI::Windows::Foundation::Size windowSize;
if (SUCCEEDED(e->get_Size(&windowSize)))
if (SUCCEEDED(sizeChangedEventArgs->get_Size(&windowSize)))
{
SIZE windowSizeInPixels = { ConvertDipsToPixels(windowSize.Width), ConvertDipsToPixels(windowSize.Height) };
host->setNewClientSize(windowSizeInPixels);
......@@ -63,9 +68,10 @@ class CoreWindowSizeChangedHandler :
}
private:
std::weak_ptr<IInspectableNativeWindow> mHost;
std::weak_ptr<InspectableNativeWindow> mHost;
};
HRESULT getCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, RECT *windowSize);
HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, RECT *windowSize);
}
#endif // COMMON_COREWINDOWNATIVEWINDOW_H_
#endif // COMMON_WINRT_COREWINDOWNATIVEWINDOW_H_
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 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.
//
// iinspectablehost.cpp: NativeWindow base class for managing IInspectable native window types.
// InspectableNativeWindow.cpp: NativeWindow base class for managing IInspectable native window types.
#include "common/winrt/CoreWindowNativeWindow.h"
#include "common/winrt/SwapChainPanelNativeWindow.h"
namespace rx
{
......@@ -22,7 +23,7 @@ bool NativeWindow::initialize()
// proper host with this IPropertySet.
ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet;
ComPtr<IInspectable> eglNativeWindow;
if (isEGLConfiguredPropertySet(mWindow, &propertySet, &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
......@@ -32,9 +33,9 @@ bool NativeWindow::initialize()
mWindow = eglNativeWindow.Get();
}
// If the native window is a ICoreWindow, initialize a CoreWindowNativeWindow
ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow;
if (isCoreWindow(mWindow, &coreWindow))
ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> swapChainPanel;
if (IsCoreWindow(mWindow, &coreWindow))
{
mImpl = std::make_shared<CoreWindowNativeWindow>();
if (mImpl)
......@@ -42,9 +43,17 @@ bool NativeWindow::initialize()
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 and IPropertySet");
ERR("Invalid IInspectable EGLNativeWindowType detected. Valid IInspectables include ICoreWindow, ISwapChainPanel and IPropertySet");
}
return false;
......@@ -75,9 +84,7 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory
return E_UNEXPECTED;
}
}
bool isCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow)
bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow)
{
if (!window)
{
......@@ -98,7 +105,28 @@ bool isCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICo
return false;
}
bool isEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet, IInspectable **eglNativeWindow)
bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> *swapChainPanel)
{
if (!window)
{
return false;
}
ComPtr<IInspectable> win = window;
ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> panel;
if (SUCCEEDED(win.As(&panel)))
{
if (swapChainPanel != nullptr)
{
*swapChainPanel = panel.Detach();
}
return true;
}
return false;
}
bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet, IInspectable **eglNativeWindow)
{
if (!window)
{
......@@ -167,9 +195,9 @@ bool isEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Founda
// IPropertySet
//
// Anything else will be rejected as an invalid IInspectable.
bool isValidEGLNativeWindowType(EGLNativeWindowType window)
bool IsValidEGLNativeWindowType(EGLNativeWindowType window)
{
return isCoreWindow(window) || isEGLConfiguredPropertySet(window);
return IsCoreWindow(window) || IsSwapChainPanel(window) || IsEGLConfiguredPropertySet(window);
}
// Attempts to read an optional SIZE property value that is assumed to be in the form of
......@@ -184,7 +212,7 @@ bool isValidEGLNativeWindowType(EGLNativeWindowType window)
// * Invalid property value (width/height must be > 0)
// Additional errors may be returned from IMap or IPropertyValue
//
HRESULT getOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>>& propertyMap, const wchar_t *propertyName, SIZE *value, bool *valueExists)
HRESULT GetOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>>& propertyMap, const wchar_t *propertyName, SIZE *value, bool *valueExists)
{
if (!propertyMap || !propertyName || !value || !valueExists)
{
......@@ -242,4 +270,5 @@ HRESULT getOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Coll
}
return result;
}
\ No newline at end of file
}
}
//
// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 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.
//
// IInspectableNativeWindow.h: Host specific implementation interface for
// InspectableNativeWindow.h: Host specific implementation interface for
// managing IInspectable native window types.
#ifndef COMMON_IINSPECTABLENATIVEWINDOW_H_
#define COMMON_IINSPECTABLENATIVEWINDOW_H_
#ifndef COMMON_WINRT_INSPECTABLENATIVEWINDOW_H_
#define COMMON_WINRT_INSPECTABLENATIVEWINDOW_H_
#include "common/platform.h"
#include "common/NativeWindow.h"
......@@ -22,16 +22,12 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections;
class IInspectableNativeWindow
namespace rx
{
class InspectableNativeWindow
{
public:
virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0;
virtual HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) = 0;
virtual bool registerForSizeChangeEvents() = 0;
virtual void unregisterForSizeChangeEvents() = 0;
virtual HRESULT scaleSwapChain(const SIZE& newSize) { return S_OK; }
IInspectableNativeWindow() :
InspectableNativeWindow() :
mSupportsSwapChainResize(true),
mRequiresSwapChainScaling(false),
mClientRectChanged(false),
......@@ -40,8 +36,13 @@ class IInspectableNativeWindow
{
mSizeChangedEventToken.value = 0;
}
virtual ~InspectableNativeWindow(){}
virtual ~IInspectableNativeWindow(){}
virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0;
virtual HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain) = 0;
virtual bool registerForSizeChangeEvents() = 0;
virtual void unregisterForSizeChangeEvents() = 0;
virtual HRESULT scaleSwapChain(const SIZE& newSize) { return S_OK; }
bool getClientRect(RECT *rect)
{
......@@ -79,8 +80,9 @@ protected:
EventRegistrationToken mSizeChangedEventToken;
};
bool isCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow = nullptr);
bool isEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet = nullptr, IInspectable **inspectable = nullptr);
HRESULT getOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>>& propertyMap, const wchar_t *propertyName, SIZE *value, bool *valueExists);
#endif // COMMON_IINSPECTABLENATIVEWINDOW_H_
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);
HRESULT GetOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>>& propertyMap, const wchar_t *propertyName, SIZE *value, bool *valueExists);
}
#endif // COMMON_WINRT_INSPECTABLENATIVEWINDOW_H_
//
// Copyright (c) 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.
//
// SwapChainPanelNativeWindow.cpp: NativeWindow for managing ISwapChainPanel native window types.
#include "common/winrt/SwapChainPanelNativeWindow.h"
#include <algorithm>
#include <math.h>
using namespace ABI::Windows::Foundation::Collections;
namespace rx
{
SwapChainPanelNativeWindow::~SwapChainPanelNativeWindow()
{
unregisterForSizeChangeEvents();
}
bool SwapChainPanelNativeWindow::initialize(EGLNativeWindowType window, IPropertySet *propertySet)
{
ComPtr<IPropertySet> props = propertySet;
ComPtr<IInspectable> win = window;
SIZE swapChainSize = {};
bool swapChainSizeSpecified = false;
HRESULT result = S_OK;
// IPropertySet is an optional parameter and can be null.
// If one is specified, cache as an IMap and read the properties
// used for initial host initialization.
if (propertySet)
{
result = props.As(&mPropertyMap);
if (SUCCEEDED(result))
{
// The EGLRenderSurfaceSizeProperty is optional and may be missing. The IPropertySet
// was prevalidated to contain the EGLNativeWindowType before being passed to
// this host.
result = GetOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified);
}
}
if (SUCCEEDED(result))
{
result = win.As(&mSwapChainPanel);
}
if (SUCCEEDED(result))
{
// If a swapchain size is specfied, then the automatic resize
// behaviors implemented by the host should be disabled. The swapchain
// will be still be scaled when being rendered to fit the bounds
// of the host.
// Scaling of the swapchain output needs to be handled by the
// host for swapchain panels even though the scaling mode setting
// DXGI_SCALING_STRETCH is configured on the swapchain.
if (swapChainSizeSpecified)
{
mClientRect = { 0, 0, swapChainSize.cx, swapChainSize.cy };
// Enable host swapchain scaling
mRequiresSwapChainScaling = true;
}
else
{
result = GetSwapChainPanelSize(mSwapChainPanel, &mClientRect);
}
}
if (SUCCEEDED(result))
{
mNewClientRect = mClientRect;
mClientRectChanged = false;
return registerForSizeChangeEvents();
}
return false;
}
bool SwapChainPanelNativeWindow::registerForSizeChangeEvents()
{
ComPtr<ABI::Windows::UI::Xaml::ISizeChangedEventHandler> sizeChangedHandler;
ComPtr<ABI::Windows::UI::Xaml::IFrameworkElement> frameworkElement;
HRESULT result = Microsoft::WRL::MakeAndInitialize<SwapChainPanelSizeChangedHandler>(sizeChangedHandler.ReleaseAndGetAddressOf(), this->shared_from_this());
if (SUCCEEDED(result))
{
result = mSwapChainPanel.As(&frameworkElement);
}
if (SUCCEEDED(result))
{
result = frameworkElement->add_SizeChanged(sizeChangedHandler.Get(), &mSizeChangedEventToken);
}
if (SUCCEEDED(result))
{
return true;
}
return false;
}
void SwapChainPanelNativeWindow::unregisterForSizeChangeEvents()
{
ComPtr<ABI::Windows::UI::Xaml::IFrameworkElement> frameworkElement;
if (SUCCEEDED(mSwapChainPanel.As(&frameworkElement)))
{
(void)frameworkElement->remove_SizeChanged(mSizeChangedEventToken);
}
mSizeChangedEventToken.value = 0;
}
HRESULT SwapChainPanelNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain)
{
if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
{
return E_INVALIDARG;
}
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
swapChainDesc.Width = width;
swapChainDesc.Height = height;
swapChainDesc.Format = format;
swapChainDesc.Stereo = FALSE;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER;
swapChainDesc.BufferCount = 2;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
*swapChain = nullptr;
ComPtr<IDXGISwapChain1> newSwapChain;
ComPtr<ISwapChainPanelNative> swapChainPanelNative;
RECT currentPanelSize = {};
HRESULT result = factory->CreateSwapChainForComposition(device, &swapChainDesc, nullptr, newSwapChain.ReleaseAndGetAddressOf());
if (SUCCEEDED(result))
{
result = mSwapChainPanel.As(&swapChainPanelNative);
}
if (SUCCEEDED(result))
{
result = swapChainPanelNative->SetSwapChain(newSwapChain.Get());
}
if (SUCCEEDED(result))
{
// The swapchain panel host requires an instance of the swapchain set on the SwapChainPanel
// to perform the runtime-scale behavior. This swapchain is cached here because there are
// no methods for retreiving the currently configured on from ISwapChainPanelNative.
mSwapChain = newSwapChain;
result = newSwapChain.CopyTo(swapChain);
}
// If the host is responsible for scaling the output of the swapchain, then
// scale it now before returning an instance to the caller. This is done by
// first reading the current size of the swapchain panel, then scaling
if (SUCCEEDED(result) && mRequiresSwapChainScaling)
{
result = GetSwapChainPanelSize(mSwapChainPanel, &currentPanelSize);
}
// Scale the swapchain to fit inside the contents of the panel.
if (SUCCEEDED(result) && mRequiresSwapChainScaling)
{
SIZE currentSize = { currentPanelSize.right, currentPanelSize.bottom };
result = scaleSwapChain(currentSize);
}
if (SUCCEEDED(result))
{
// If automatic swapchain resize behaviors have been disabled, then
// unregister for the resize change events.
if (mSupportsSwapChainResize == false)
{
unregisterForSizeChangeEvents();
}
}
return result;
}
HRESULT SwapChainPanelNativeWindow::scaleSwapChain(const SIZE &newSize)
{
ABI::Windows::Foundation::Size renderScale = { (float)newSize.cx/(float)mClientRect.right, (float)newSize.cy/(float)mClientRect.bottom };
// Setup a scale matrix for the swap chain
DXGI_MATRIX_3X2_F scaleMatrix = {};
scaleMatrix._11 = renderScale.Width;
scaleMatrix._22 = renderScale.Height;
ComPtr<IDXGISwapChain2> swapChain2;
HRESULT result = mSwapChain.As(&swapChain2);
if (SUCCEEDED(result))
{
result = swapChain2->SetMatrixTransform(&scaleMatrix);
}
return result;
}
HRESULT GetSwapChainPanelSize(const ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> &swapChainPanel, RECT *windowSize)
{
ComPtr<ABI::Windows::UI::Xaml::IUIElement> uiElement;
ABI::Windows::Foundation::Size renderSize = { 0, 0 };
HRESULT result = swapChainPanel.As(&uiElement);
if (SUCCEEDED(result))
{
result = uiElement->get_RenderSize(&renderSize);
}
if (SUCCEEDED(result))
{
*windowSize = { 0, 0, lround(renderSize.Width), lround(renderSize.Height) };
}
return result;
}
}
//
// Copyright (c) 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.
//
// SwapChainPanelNativeWindow.h: NativeWindow for managing ISwapChainPanel native window types.
#ifndef COMMON_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_
#define COMMON_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_
#include "common/winrt/InspectableNativeWindow.h"
namespace rx
{
class SwapChainPanelNativeWindow : public InspectableNativeWindow, public std::enable_shared_from_this<SwapChainPanelNativeWindow>
{
public:
~SwapChainPanelNativeWindow();
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet);
bool registerForSizeChangeEvents();
void unregisterForSizeChangeEvents();
HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain);
HRESULT scaleSwapChain(const SIZE &newSize);
private:
ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> mSwapChainPanel;
ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap;
ComPtr<DXGISwapChain> mSwapChain;
};
[uuid(8ACBD974-8187-4508-AD80-AEC77F93CF36)]
class SwapChainPanelSizeChangedHandler :
public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, ABI::Windows::UI::Xaml::ISizeChangedEventHandler>
{
public:
SwapChainPanelSizeChangedHandler() { }
HRESULT RuntimeClassInitialize(std::shared_ptr<InspectableNativeWindow> host)
{
if (!host)
{
return E_INVALIDARG;
}
mHost = host;
return S_OK;
}
// ISizeChangedEventHandler
IFACEMETHOD(Invoke)(IInspectable *sender, ABI::Windows::UI::Xaml::ISizeChangedEventArgs *sizeChangedEventArgs)
{
std::shared_ptr<InspectableNativeWindow> host = mHost.lock();
if (host)
{
// The size of the ISwapChainPanel control is returned in DIPs.
// We are keeping these in dips because the swapchain created for composition
// also uses dip units. This keeps dimensions, viewports, etc in the same unit.
// XAML Clients of the ISwapChainPanel are required to use dips to define their
// layout sizes as well.
ABI::Windows::Foundation::Size newSize;
HRESULT result = sizeChangedEventArgs->get_NewSize(&newSize);
if (SUCCEEDED(result))
{
SIZE windowSize = { lround(newSize.Width), lround(newSize.Height) };
host->setNewClientSize(windowSize);
}
}
return S_OK;
}
private:
std::weak_ptr<InspectableNativeWindow> mHost;
};
HRESULT GetSwapChainPanelSize(const ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> &swapChainPanel, RECT *windowSize);
}
#endif // COMMON_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_
......@@ -61,10 +61,12 @@
],
'angle_libegl_winrt_sources':
[
'common/winrt/SwapChainPanelNativeWindow.cpp',
'common/winrt/SwapChainPanelNativeWindow.h',
'common/winrt/CoreWindowNativeWindow.cpp',
'common/winrt/CoreWindowNativeWindow.h',
'common/winrt/IInspectableNativeWindow.cpp',
'common/winrt/IInspectableNativeWindow.h',
'common/winrt/InspectableNativeWindow.cpp',
'common/winrt/InspectableNativeWindow.h',
],
},
# Everything below this is duplicated in the GN build. If you change
......
......@@ -405,7 +405,7 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG
return EGL_NO_SURFACE;
}
if (!isValidEGLNativeWindowType(win))
if (!rx::IsValidEGLNativeWindowType(win))
{
recordError(egl::Error(EGL_BAD_NATIVE_WINDOW));
return EGL_NO_SURFACE;
......
......@@ -147,10 +147,12 @@
],
'angle_libangle_winrt_sources':
[
'common/winrt/SwapChainPanelNativeWindow.cpp',
'common/winrt/SwapChainPanelNativeWindow.h',
'common/winrt/CoreWindowNativeWindow.cpp',
'common/winrt/CoreWindowNativeWindow.h',
'common/winrt/IInspectableNativeWindow.cpp',
'common/winrt/IInspectableNativeWindow.h',
'common/winrt/InspectableNativeWindow.cpp',
'common/winrt/InspectableNativeWindow.h',
],
'angle_d3d_shared_sources':
[
......
......@@ -55,9 +55,9 @@ class GenericIUnknown : public RuntimeClass <
// Mock ICoreWindow
class MockCoreWindow : public ABI::Windows::UI::Core::ICoreWindow
{
public:
public:
// IUnknown
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject)
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject)
{
*ppvObject = NULL;
......
//
// Copyright (c) 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.
//
#include "gmock/gmock.h"
#include "gtest/gtest.h"
// WINAPI_FAMILY is required to be defined as WINAPI_FAMILY_PC_APP
// to ensure that the proper defines are set when including additional
// headers which rely on Windows Store specific configuration.
// This would normally be defined already but this unittest exe is compiled
// as a desktop application which results in WINAPI_FAMILY being
// set to WINAPI_FAMILY_DESKTOP_APP
#undef WINAPI_FAMILY
#define WINAPI_FAMILY WINAPI_FAMILY_PC_APP
#include "common/nativewindow.h"
#include <angle_windowsstore.h>
#include <windows.ui.xaml.h>
#include <windows.ui.xaml.media.dxinterop.h>
using namespace rx;
using namespace ABI::Windows::ApplicationModel::Core;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections;
using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::System;
using namespace ABI::Windows::UI::Xaml::Controls;
using namespace ABI::Windows::UI::Xaml::Data;
using namespace ABI::Windows::UI::Xaml::Media;
using namespace ABI::Windows::UI::Xaml::Input;
using namespace ABI::Windows::UI::Xaml;
namespace
{
// Mock ISwapChainPanel
class MockSwapChainPanel : public ISwapChainPanel,
IFrameworkElement,
IUIElement,
ISwapChainPanelNative
{
public:
// IUnknown
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject)
{
*ppvObject = NULL;
if (IsEqualIID(IID_IUnknown, riid))
{
*ppvObject = reinterpret_cast<IUnknown*>(this);
return S_OK;
}
if (IsEqualIID(IID_IInspectable, riid))
{
*ppvObject = reinterpret_cast<IInspectable*>(this);
return S_OK;
}
if (IsEqualIID(IID_ISwapChainPanel, riid))
{
*ppvObject = static_cast<ISwapChainPanel*>(this);
return S_OK;
}
if (IsEqualIID(IID_IFrameworkElement, riid))
{
*ppvObject = static_cast<IFrameworkElement*>(this);
return S_OK;
}
if (IsEqualIID(IID_IUIElement, riid))
{
*ppvObject = static_cast<IUIElement*>(this);
return S_OK;
}
if (IsEqualIID(__uuidof(ISwapChainPanelNative), riid))
{
*ppvObject = static_cast<ISwapChainPanelNative*>(this);
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHOD_(ULONG, AddRef)(){ return 1; }
STDMETHOD_(ULONG, Release)(){ return 1; }
// IInspectable
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, GetIids, HRESULT(ULONG *, IID**));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, GetRuntimeClassName, HRESULT(HSTRING *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTrustLevel, HRESULT(TrustLevel *));
// ISwapChainPanelNative
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, SetSwapChain, HRESULT(IDXGISwapChain *));
// ISwapChainPanel
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_CompositionScaleX, HRESULT(FLOAT *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_CompositionScaleY, HRESULT(FLOAT *));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_CompositionScaleChanged, HRESULT(__FITypedEventHandler_2_Windows__CUI__CXaml__CControls__CSwapChainPanel_IInspectable*, EventRegistrationToken*));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_CompositionScaleChanged, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, CreateCoreIndependentInputSource, HRESULT(CoreInputDeviceTypes, ICoreInputSourceBase**));
// IFrameworkElement
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Triggers, HRESULT(__FIVector_1_Windows__CUI__CXaml__CTriggerBase **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Resources, HRESULT(IResourceDictionary **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Resources, HRESULT(IResourceDictionary *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Tag, HRESULT(IInspectable **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Tag, HRESULT(IInspectable *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Language, HRESULT(HSTRING *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Language, HRESULT(HSTRING));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_ActualWidth, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_ActualHeight, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Width, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Width, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Height, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Height, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_MinWidth, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_MinWidth, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_MaxWidth, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_MaxWidth, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_MinHeight, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_MinHeight, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_MaxHeight, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_MaxHeight, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_HorizontalAlignment, HRESULT(HorizontalAlignment *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_HorizontalAlignment, HRESULT(HorizontalAlignment));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_VerticalAlignment, HRESULT(VerticalAlignment *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_VerticalAlignment, HRESULT(VerticalAlignment));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Margin, HRESULT(Thickness *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Margin, HRESULT(Thickness));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Name, HRESULT(HSTRING*));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Name, HRESULT(HSTRING));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_BaseUri, HRESULT(IUriRuntimeClass **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_DataContext, HRESULT(IInspectable **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_DataContext, HRESULT(IInspectable *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Style, HRESULT(IStyle **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Style, HRESULT(IStyle *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Parent, HRESULT(IDependencyObject **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_FlowDirection, HRESULT(FlowDirection *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_FlowDirection, HRESULT(FlowDirection));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_Loaded, HRESULT(IRoutedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_Loaded, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_Unloaded, HRESULT(IRoutedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_Unloaded, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_SizeChanged, HRESULT(ISizeChangedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_SizeChanged, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_LayoutUpdated, HRESULT(__FIEventHandler_1_IInspectable *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_LayoutUpdated, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, FindName, HRESULT(HSTRING, IInspectable **));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, SetBinding, HRESULT(IDependencyProperty *, IBindingBase *));
// IUIElement
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_DesiredSize, HRESULT(ABI::Windows::Foundation::Size *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_AllowDrop, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_AllowDrop, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Opacity, HRESULT(DOUBLE *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Opacity, HRESULT(DOUBLE));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Clip, HRESULT(IRectangleGeometry **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Clip, HRESULT(IRectangleGeometry *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_RenderTransform, HRESULT(ITransform **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_RenderTransform, HRESULT(ITransform *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Projection, HRESULT(IProjection **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Projection, HRESULT(IProjection *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_RenderTransformOrigin, HRESULT(Point *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_RenderTransformOrigin, HRESULT(Point));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_IsHitTestVisible, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_IsHitTestVisible, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Visibility, HRESULT(Visibility *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Visibility, HRESULT(Visibility));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_RenderSize, HRESULT(Size *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_UseLayoutRounding, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_UseLayoutRounding, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_Transitions, HRESULT(__FIVector_1_Windows__CUI__CXaml__CMedia__CAnimation__CTransition **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_Transitions, HRESULT(__FIVector_1_Windows__CUI__CXaml__CMedia__CAnimation__CTransition *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_CacheMode, HRESULT(ICacheMode **));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_CacheMode, HRESULT(ICacheMode *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_IsTapEnabled, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_IsTapEnabled, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_IsDoubleTapEnabled, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_IsDoubleTapEnabled, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_IsRightTapEnabled, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_IsRightTapEnabled, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_IsHoldingEnabled, HRESULT(boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_IsHoldingEnabled, HRESULT(boolean));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_ManipulationMode, HRESULT(ManipulationModes *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, put_ManipulationMode, HRESULT(ManipulationModes));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, get_PointerCaptures, HRESULT(__FIVectorView_1_Windows__CUI__CXaml__CInput__CPointer **));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_KeyUp, HRESULT(IKeyEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_KeyUp, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_KeyDown, HRESULT(IKeyEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_KeyDown, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_GotFocus, HRESULT(IRoutedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_GotFocus, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_LostFocus, HRESULT(IRoutedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_LostFocus, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_DragEnter, HRESULT(IDragEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_DragEnter, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_DragLeave, HRESULT(IDragEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_DragLeave, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_DragOver, HRESULT(IDragEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_DragOver, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_Drop, HRESULT(IDragEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_Drop, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerPressed, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerPressed, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerMoved, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerMoved, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerReleased, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerReleased, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerExited, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerExited, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerCaptureLost, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerCaptureLost, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerCanceled, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerCanceled, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerWheelChanged, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerWheelChanged, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_PointerEntered, HRESULT(IPointerEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_PointerEntered, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_Tapped, HRESULT(ITappedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_Tapped, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_DoubleTapped, HRESULT(IDoubleTappedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_DoubleTapped, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_Holding, HRESULT(IHoldingEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_Holding, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_RightTapped, HRESULT(IRightTappedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_RightTapped, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_ManipulationStarting, HRESULT(IManipulationStartingEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_ManipulationStarting, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_ManipulationInertiaStarting, HRESULT(IManipulationInertiaStartingEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_ManipulationInertiaStarting, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_ManipulationStarted, HRESULT(IManipulationStartedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_ManipulationStarted, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_ManipulationDelta, HRESULT(IManipulationDeltaEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_ManipulationDelta, HRESULT(EventRegistrationToken));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, add_ManipulationCompleted, HRESULT(IManipulationCompletedEventHandler *, EventRegistrationToken *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, remove_ManipulationCompleted, HRESULT(EventRegistrationToken));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Measure, HRESULT(Size));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Arrange, HRESULT(Rect));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, CapturePointer, HRESULT(IPointer *, boolean *));
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, ReleasePointerCapture, HRESULT(IPointer *));
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, ReleasePointerCaptures, HRESULT());
MOCK_METHOD3_WITH_CALLTYPE(STDMETHODCALLTYPE, AddHandler, HRESULT(IRoutedEvent *, IInspectable *, boolean));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, RemoveHandler, HRESULT(IRoutedEvent *, IInspectable *));
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, TransformToVisual, HRESULT(IUIElement *, IGeneralTransform **));
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, InvalidateMeasure, HRESULT());
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, InvalidateArrange, HRESULT());
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, UpdateLayout, HRESULT());
};
HRESULT CreatePropertyMap(IMap<HSTRING, IInspectable*>** propertyMap)
{
HRESULT result = S_OK;
ComPtr<IPropertySet> propertySet;
ComPtr<IActivationFactory> propertySetFactory;
result = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_Collections_PropertySet).Get(), &propertySetFactory);
EXPECT_HRESULT_SUCCEEDED(result);
result = propertySetFactory->ActivateInstance(&propertySet);
EXPECT_HRESULT_SUCCEEDED(result);
result = propertySet.CopyTo(propertyMap);
EXPECT_HRESULT_SUCCEEDED(result);
return result;
}
HRESULT SetInspectablePropertyValue(const ComPtr<IMap<HSTRING, IInspectable*>>& propertyMap, const wchar_t* propertyName, IInspectable* inspectable)
{
boolean propertyReplaced = false;
return propertyMap->Insert(HStringReference(propertyName).Get(), inspectable, &propertyReplaced);
}
TEST(NativeWindowTest, NativeWindowValidSwapChainPanel)
{
MockSwapChainPanel mockSwapChainPanel;
NativeWindow nativeWindow(reinterpret_cast<IInspectable*>(&mockSwapChainPanel));
EXPECT_CALL(mockSwapChainPanel, get_RenderSize(testing::_)).Times(1);
EXPECT_CALL(mockSwapChainPanel, add_SizeChanged(testing::_, testing::_)).Times(1);
EXPECT_CALL(mockSwapChainPanel, remove_SizeChanged(testing::_)).Times(1);
EXPECT_TRUE(nativeWindow.initialize());
}
TEST(NativeWindowTest, NativeWindowValidSwapChainPanelInPropertySet)
{
// COM is required to be initialized for creation of the property set
EXPECT_HRESULT_SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED));
{
MockSwapChainPanel mockSwapChainPanel;
ComPtr<IMap<HSTRING, IInspectable*>> propertySet;
EXPECT_HRESULT_SUCCEEDED(CreatePropertyMap(&propertySet));
EXPECT_HRESULT_SUCCEEDED(SetInspectablePropertyValue(propertySet, EGLNativeWindowTypeProperty, reinterpret_cast<IInspectable*>(&mockSwapChainPanel)));
NativeWindow nativeWindow(propertySet.Get());
EXPECT_CALL(mockSwapChainPanel, get_RenderSize(testing::_)).Times(1);
EXPECT_CALL(mockSwapChainPanel, add_SizeChanged(testing::_, testing::_)).Times(1);
EXPECT_CALL(mockSwapChainPanel, remove_SizeChanged(testing::_)).Times(1);
EXPECT_TRUE(nativeWindow.initialize());
}
CoUninitialize();
}
} // namespace
......@@ -242,6 +242,7 @@
'sources':
[
'angle_implementation_unit_tests/CoreWindowNativeWindow_unittest.cpp',
'angle_implementation_unit_tests/SwapChainPanelNativeWindow_unittest.cpp',
],
'defines':
[
......
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