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 @@ ...@@ -509,8 +509,9 @@
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\TextureStorage11.h"/> <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\VertexArray11.h"/>
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.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\CoreWindowNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h"/> <ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\..\src\common\RefCountObject.cpp"/> <ClCompile Include="..\..\..\..\src\common\RefCountObject.cpp"/>
...@@ -592,8 +593,9 @@ ...@@ -592,8 +593,9 @@
<ClCompile Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\SwapChain11.cpp"/> <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\TextureStorage11.cpp"/>
<ClCompile Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.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\CoreWindowNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp"/> <ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="commit_id.vcxproj"> <ProjectReference Include="commit_id.vcxproj">
......
...@@ -2914,6 +2914,24 @@ ...@@ -2914,6 +2914,24 @@
<Filter Include="src"> <Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier> <UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter> </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>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\..\include\EGL\egl.h"> <ClInclude Include="..\..\..\..\include\EGL\egl.h">
...@@ -3660,16 +3678,22 @@ ...@@ -3660,16 +3678,22 @@
<ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.h"> <ClInclude Include="..\..\..\..\src\libGLESv2\renderer\d3d\d3d11\VertexBuffer11.h">
<Filter>src\libGLESv2\renderer\d3d\d3d11</Filter> <Filter>src\libGLESv2\renderer\d3d\d3d11</Filter>
</ClInclude> </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"> <ClCompile Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.cpp">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h"> <ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClInclude> </ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp"> <ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h"> <ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClInclude> </ClInclude>
<None Include="..\..\..\..\src\angle.gyp"> <None Include="..\..\..\..\src\angle.gyp">
......
...@@ -377,8 +377,9 @@ ...@@ -377,8 +377,9 @@
<ClInclude Include="..\..\..\..\src\libEGL\Surface.h"/> <ClInclude Include="..\..\..\..\src\libEGL\Surface.h"/>
<ClInclude Include="..\..\..\..\src\libEGL\main.h"/> <ClInclude Include="..\..\..\..\src\libEGL\main.h"/>
<ClInclude Include="..\..\..\..\src\libEGL\resource.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\CoreWindowNativeWindow.h"/>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h"/> <ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\..\src\common\RefCountObject.cpp"/> <ClCompile Include="..\..\..\..\src\common\RefCountObject.cpp"/>
...@@ -395,8 +396,9 @@ ...@@ -395,8 +396,9 @@
<ClCompile Include="..\..\..\..\src\libEGL\Surface.cpp"/> <ClCompile Include="..\..\..\..\src\libEGL\Surface.cpp"/>
<ClCompile Include="..\..\..\..\src\libEGL\libEGL.cpp"/> <ClCompile Include="..\..\..\..\src\libEGL\libEGL.cpp"/>
<ClCompile Include="..\..\..\..\src\libEGL\main.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\CoreWindowNativeWindow.cpp"/>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp"/> <ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\..\..\src\libEGL\libEGL.rc"/> <ResourceCompile Include="..\..\..\..\src\libEGL\libEGL.rc"/>
......
...@@ -313,6 +313,24 @@ ...@@ -313,6 +313,24 @@
<Filter Include="src"> <Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier> <UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter> </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>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\..\include\EGL\egl.h"> <ClInclude Include="..\..\..\..\include\EGL\egl.h">
...@@ -453,16 +471,22 @@ ...@@ -453,16 +471,22 @@
<ClInclude Include="..\..\..\..\src\libEGL\resource.h"> <ClInclude Include="..\..\..\..\src\libEGL\resource.h">
<Filter>src\libEGL</Filter> <Filter>src\libEGL</Filter>
</ClInclude> </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"> <ClCompile Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.cpp">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h"> <ClInclude Include="..\..\..\..\src\common\winrt\CoreWindowNativeWindow.h">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClInclude> </ClInclude>
<ClCompile Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.cpp"> <ClCompile Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.cpp">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\..\..\..\src\common\winrt\IInspectableNativeWindow.h"> <ClInclude Include="..\..\..\..\src\common\winrt\InspectableNativeWindow.h">
<Filter>src\common\winrt</Filter> <Filter>src\common\winrt</Filter>
</ClInclude> </ClInclude>
<None Include="..\..\..\..\src\angle.gyp"> <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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -29,7 +29,10 @@ typedef IDXGIFactory2 DXGIFactory; ...@@ -29,7 +29,10 @@ typedef IDXGIFactory2 DXGIFactory;
#include <windows.applicationmodel.core.h> #include <windows.applicationmodel.core.h>
#include <memory> #include <memory>
class IInspectableNativeWindow; namespace rx
{
class InspectableNativeWindow;
}
using namespace Microsoft::WRL; using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers; using namespace Microsoft::WRL::Wrappers;
...@@ -43,7 +46,7 @@ namespace rx ...@@ -43,7 +46,7 @@ namespace rx
{ {
class NativeWindow class NativeWindow
{ {
public: public:
explicit NativeWindow(EGLNativeWindowType window); explicit NativeWindow(EGLNativeWindowType window);
bool initialize(); bool initialize();
...@@ -56,16 +59,16 @@ public: ...@@ -56,16 +59,16 @@ public:
inline EGLNativeWindowType getNativeWindow() const { return mWindow; } inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
private: private:
EGLNativeWindowType mWindow; EGLNativeWindowType mWindow;
#if defined(ANGLE_ENABLE_WINDOWS_STORE) #if defined(ANGLE_ENABLE_WINDOWS_STORE)
std::shared_ptr<IInspectableNativeWindow> mImpl; std::shared_ptr<InspectableNativeWindow> mImpl;
#endif #endif
}; };
}
bool isValidEGLNativeWindowType(EGLNativeWindowType window); bool IsValidEGLNativeWindowType(EGLNativeWindowType window);
}
#endif // COMMON_NATIVEWINDOW_H_ #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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include "common/NativeWindow.h" #include "common/NativeWindow.h"
#include "common/debug.h" #include "common/debug.h"
bool isValidEGLNativeWindowType(EGLNativeWindowType window) namespace rx
{
bool IsValidEGLNativeWindowType(EGLNativeWindowType window)
{ {
return (IsWindow(window) == TRUE); return (IsWindow(window) == TRUE);
} }
namespace rx
{
NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window) NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
{ {
} }
...@@ -63,4 +63,4 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory ...@@ -63,4 +63,4 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory
return factory->CreateSwapChain(device, &swapChainDesc, swapChain); 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "common/winrt/CoreWindowNativeWindow.h" #include "common/winrt/CoreWindowNativeWindow.h"
using namespace ABI::Windows::Foundation::Collections; using namespace ABI::Windows::Foundation::Collections;
namespace rx
{
CoreWindowNativeWindow::~CoreWindowNativeWindow() CoreWindowNativeWindow::~CoreWindowNativeWindow()
{ {
unregisterForSizeChangeEvents(); unregisterForSizeChangeEvents();
...@@ -23,7 +25,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet ...@@ -23,7 +25,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
bool swapChainSizeSpecified = false; bool swapChainSizeSpecified = false;
HRESULT result = S_OK; 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 // If one is specified, cache as an IMap and read the properties
// used for initial host initialization. // used for initial host initialization.
if (propertySet) if (propertySet)
...@@ -34,7 +36,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet ...@@ -34,7 +36,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
// The EGLRenderSurfaceSizeProperty is optional and may be missing. The IPropertySet // The EGLRenderSurfaceSizeProperty is optional and may be missing. The IPropertySet
// was prevalidated to contain the EGLNativeWindowType before being passed to // was prevalidated to contain the EGLNativeWindowType before being passed to
// this host. // this host.
result = getOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified); result = GetOptionalSizePropertyValue(mPropertyMap, EGLRenderSurfaceSizeProperty, &swapChainSize, &swapChainSizeSpecified);
} }
} }
...@@ -58,7 +60,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet ...@@ -58,7 +60,7 @@ bool CoreWindowNativeWindow::initialize(EGLNativeWindowType window, IPropertySet
} }
else else
{ {
result = getCoreWindowSizeInPixels(mCoreWindow, &mClientRect); result = GetCoreWindowSizeInPixels(mCoreWindow, &mClientRect);
} }
} }
...@@ -150,7 +152,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor ...@@ -150,7 +152,7 @@ HRESULT CoreWindowNativeWindow::createSwapChain(ID3D11Device *device, DXGIFactor
return result; 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; ABI::Windows::Foundation::Rect bounds;
HRESULT result = coreWindow->get_Bounds(&bounds); HRESULT result = coreWindow->get_Bounds(&bounds);
...@@ -181,4 +183,5 @@ long ConvertDipsToPixels(float dips) ...@@ -181,4 +183,5 @@ long ConvertDipsToPixels(float dips)
{ {
static const float dipsPerInch = 96.0f; static const float dipsPerInch = 96.0f;
return lround((dips * GetLogicalDpi() / dipsPerInch)); 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// CoreWindowNativeWindow.h: NativeWindow for managing ICoreWindow native window types. // CoreWindowNativeWindow.h: NativeWindow for managing ICoreWindow native window types.
#ifndef COMMON_COREWINDOWNATIVEWINDOW_H_ #ifndef COMMON_WINRT_COREWINDOWNATIVEWINDOW_H_
#define COMMON_COREWINDOWNATIVEWINDOW_H_ #define COMMON_WINRT_COREWINDOWNATIVEWINDOW_H_
#include "common/winrt/IInspectableNativeWindow.h" #include "common/winrt/InspectableNativeWindow.h"
#include <memory> #include <memory>
typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler; typedef ABI::Windows::Foundation::__FITypedEventHandler_2_Windows__CUI__CCore__CCoreWindow_Windows__CUI__CCore__CWindowSizeChangedEventArgs_t IWindowSizeChangedEventHandler;
namespace rx
{
long ConvertDipsToPixels(float dips); 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: public:
~CoreWindowNativeWindow(); ~CoreWindowNativeWindow();
bool initialize(EGLNativeWindowType window, IPropertySet *propertySet); bool initialize(EGLNativeWindowType window, IPropertySet *propertySet);
bool registerForSizeChangeEvents(); bool registerForSizeChangeEvents();
void unregisterForSizeChangeEvents(); void unregisterForSizeChangeEvents();
HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain); HRESULT createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain);
private: private:
ComPtr<ABI::Windows::UI::Core::ICoreWindow> mCoreWindow; ComPtr<ABI::Windows::UI::Core::ICoreWindow> mCoreWindow;
ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap; ComPtr<IMap<HSTRING, IInspectable*>> mPropertyMap;
...@@ -34,7 +39,7 @@ class CoreWindowSizeChangedHandler : ...@@ -34,7 +39,7 @@ class CoreWindowSizeChangedHandler :
{ {
public: public:
CoreWindowSizeChangedHandler() { } CoreWindowSizeChangedHandler() { }
HRESULT RuntimeClassInitialize(std::shared_ptr<IInspectableNativeWindow> host) HRESULT RuntimeClassInitialize(std::shared_ptr<InspectableNativeWindow> host)
{ {
if (!host) if (!host)
{ {
...@@ -46,13 +51,13 @@ class CoreWindowSizeChangedHandler : ...@@ -46,13 +51,13 @@ class CoreWindowSizeChangedHandler :
} }
// IWindowSizeChangedEventHandler // 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) if (host)
{ {
ABI::Windows::Foundation::Size windowSize; 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) }; SIZE windowSizeInPixels = { ConvertDipsToPixels(windowSize.Width), ConvertDipsToPixels(windowSize.Height) };
host->setNewClientSize(windowSizeInPixels); host->setNewClientSize(windowSizeInPixels);
...@@ -63,9 +68,10 @@ class CoreWindowSizeChangedHandler : ...@@ -63,9 +68,10 @@ class CoreWindowSizeChangedHandler :
} }
private: 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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/CoreWindowNativeWindow.h"
#include "common/winrt/SwapChainPanelNativeWindow.h"
namespace rx namespace rx
{ {
...@@ -22,7 +23,7 @@ bool NativeWindow::initialize() ...@@ -22,7 +23,7 @@ bool NativeWindow::initialize()
// proper host with this IPropertySet. // proper host with this IPropertySet.
ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet; ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet;
ComPtr<IInspectable> eglNativeWindow; ComPtr<IInspectable> eglNativeWindow;
if (isEGLConfiguredPropertySet(mWindow, &propertySet, &eglNativeWindow)) if (IsEGLConfiguredPropertySet(mWindow, &propertySet, &eglNativeWindow))
{ {
// A property set was found and the EGLNativeWindowType was // A property set was found and the EGLNativeWindowType was
// retrieved. The mWindow member of the host to must be updated // retrieved. The mWindow member of the host to must be updated
...@@ -32,9 +33,9 @@ bool NativeWindow::initialize() ...@@ -32,9 +33,9 @@ bool NativeWindow::initialize()
mWindow = eglNativeWindow.Get(); mWindow = eglNativeWindow.Get();
} }
// If the native window is a ICoreWindow, initialize a CoreWindowNativeWindow
ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow; 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>(); mImpl = std::make_shared<CoreWindowNativeWindow>();
if (mImpl) if (mImpl)
...@@ -42,9 +43,17 @@ bool NativeWindow::initialize() ...@@ -42,9 +43,17 @@ bool NativeWindow::initialize()
return mImpl->initialize(mWindow, propertySet.Get()); 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 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; return false;
...@@ -75,9 +84,7 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory ...@@ -75,9 +84,7 @@ HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory
return E_UNEXPECTED; 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) if (!window)
{ {
...@@ -98,7 +105,28 @@ bool isCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICo ...@@ -98,7 +105,28 @@ bool isCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICo
return false; 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) if (!window)
{ {
...@@ -167,9 +195,9 @@ bool isEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Founda ...@@ -167,9 +195,9 @@ bool isEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Founda
// IPropertySet // IPropertySet
// //
// Anything else will be rejected as an invalid IInspectable. // 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 // 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) ...@@ -184,7 +212,7 @@ bool isValidEGLNativeWindowType(EGLNativeWindowType window)
// * Invalid property value (width/height must be > 0) // * Invalid property value (width/height must be > 0)
// Additional errors may be returned from IMap or IPropertyValue // 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) if (!propertyMap || !propertyName || !value || !valueExists)
{ {
...@@ -242,4 +270,5 @@ HRESULT getOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Coll ...@@ -242,4 +270,5 @@ HRESULT getOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Coll
} }
return result; 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// IInspectableNativeWindow.h: Host specific implementation interface for // InspectableNativeWindow.h: Host specific implementation interface for
// managing IInspectable native window types. // managing IInspectable native window types.
#ifndef COMMON_IINSPECTABLENATIVEWINDOW_H_ #ifndef COMMON_WINRT_INSPECTABLENATIVEWINDOW_H_
#define COMMON_IINSPECTABLENATIVEWINDOW_H_ #define COMMON_WINRT_INSPECTABLENATIVEWINDOW_H_
#include "common/platform.h" #include "common/platform.h"
#include "common/NativeWindow.h" #include "common/NativeWindow.h"
...@@ -22,16 +22,12 @@ using namespace Microsoft::WRL::Wrappers; ...@@ -22,16 +22,12 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections; using namespace ABI::Windows::Foundation::Collections;
class IInspectableNativeWindow namespace rx
{
class InspectableNativeWindow
{ {
public: public:
virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0; InspectableNativeWindow() :
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() :
mSupportsSwapChainResize(true), mSupportsSwapChainResize(true),
mRequiresSwapChainScaling(false), mRequiresSwapChainScaling(false),
mClientRectChanged(false), mClientRectChanged(false),
...@@ -40,8 +36,13 @@ class IInspectableNativeWindow ...@@ -40,8 +36,13 @@ class IInspectableNativeWindow
{ {
mSizeChangedEventToken.value = 0; 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) bool getClientRect(RECT *rect)
{ {
...@@ -79,8 +80,9 @@ protected: ...@@ -79,8 +80,9 @@ protected:
EventRegistrationToken mSizeChangedEventToken; EventRegistrationToken mSizeChangedEventToken;
}; };
bool isCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow = nullptr); 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); bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> *swapChainPanel = nullptr);
HRESULT getOptionalSizePropertyValue(const ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>>& propertyMap, const wchar_t *propertyName, SIZE *value, bool *valueExists); 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_ }
#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 @@ ...@@ -61,10 +61,12 @@
], ],
'angle_libegl_winrt_sources': 'angle_libegl_winrt_sources':
[ [
'common/winrt/SwapChainPanelNativeWindow.cpp',
'common/winrt/SwapChainPanelNativeWindow.h',
'common/winrt/CoreWindowNativeWindow.cpp', 'common/winrt/CoreWindowNativeWindow.cpp',
'common/winrt/CoreWindowNativeWindow.h', 'common/winrt/CoreWindowNativeWindow.h',
'common/winrt/IInspectableNativeWindow.cpp', 'common/winrt/InspectableNativeWindow.cpp',
'common/winrt/IInspectableNativeWindow.h', 'common/winrt/InspectableNativeWindow.h',
], ],
}, },
# Everything below this is duplicated in the GN build. If you change # Everything below this is duplicated in the GN build. If you change
......
...@@ -405,7 +405,7 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG ...@@ -405,7 +405,7 @@ EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EG
return EGL_NO_SURFACE; return EGL_NO_SURFACE;
} }
if (!isValidEGLNativeWindowType(win)) if (!rx::IsValidEGLNativeWindowType(win))
{ {
recordError(egl::Error(EGL_BAD_NATIVE_WINDOW)); recordError(egl::Error(EGL_BAD_NATIVE_WINDOW));
return EGL_NO_SURFACE; return EGL_NO_SURFACE;
......
...@@ -147,10 +147,12 @@ ...@@ -147,10 +147,12 @@
], ],
'angle_libangle_winrt_sources': 'angle_libangle_winrt_sources':
[ [
'common/winrt/SwapChainPanelNativeWindow.cpp',
'common/winrt/SwapChainPanelNativeWindow.h',
'common/winrt/CoreWindowNativeWindow.cpp', 'common/winrt/CoreWindowNativeWindow.cpp',
'common/winrt/CoreWindowNativeWindow.h', 'common/winrt/CoreWindowNativeWindow.h',
'common/winrt/IInspectableNativeWindow.cpp', 'common/winrt/InspectableNativeWindow.cpp',
'common/winrt/IInspectableNativeWindow.h', 'common/winrt/InspectableNativeWindow.h',
], ],
'angle_d3d_shared_sources': 'angle_d3d_shared_sources':
[ [
......
...@@ -55,9 +55,9 @@ class GenericIUnknown : public RuntimeClass < ...@@ -55,9 +55,9 @@ class GenericIUnknown : public RuntimeClass <
// Mock ICoreWindow // Mock ICoreWindow
class MockCoreWindow : public ABI::Windows::UI::Core::ICoreWindow class MockCoreWindow : public ABI::Windows::UI::Core::ICoreWindow
{ {
public: public:
// IUnknown // IUnknown
STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject)
{ {
*ppvObject = NULL; *ppvObject = NULL;
......
...@@ -242,6 +242,7 @@ ...@@ -242,6 +242,7 @@
'sources': 'sources':
[ [
'angle_implementation_unit_tests/CoreWindowNativeWindow_unittest.cpp', 'angle_implementation_unit_tests/CoreWindowNativeWindow_unittest.cpp',
'angle_implementation_unit_tests/SwapChainPanelNativeWindow_unittest.cpp',
], ],
'defines': '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