Move as many files as possible from common to libANGLE.

BUG=angle:733

Change-Id: I40cee6e2e305ac493acbc8649f858785c0569aed
Reviewed-on: https://chromium-review.googlesource.com/231051
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
index 0a5ae5b..c22ae89 100644
--- a/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
+++ b/src/libANGLE/renderer/d3d/HLSLCompiler.cpp
@@ -6,8 +6,8 @@
 
 #include "libANGLE/renderer/d3d/HLSLCompiler.h"
 #include "libANGLE/Program.h"
+#include "libANGLE/features.h"
 
-#include "common/features.h"
 #include "common/utilities.h"
 
 #include "third_party/trace_event/trace_event.h"
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
index ef7e11c..05707a8 100644
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
@@ -7,9 +7,7 @@
 // ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
 
 #include "libANGLE/renderer/d3d/ProgramD3D.h"
-
-#include "common/features.h"
-#include "common/utilities.h"
+#include "libANGLE/features.h"
 #include "libANGLE/Framebuffer.h"
 #include "libANGLE/FramebufferAttachment.h"
 #include "libANGLE/Program.h"
@@ -19,6 +17,8 @@
 #include "libANGLE/renderer/d3d/RendererD3D.h"
 #include "libANGLE/renderer/d3d/ShaderD3D.h"
 
+#include "common/utilities.h"
+
 namespace rx
 {
 
diff --git a/src/libANGLE/renderer/d3d/RendererD3D.h b/src/libANGLE/renderer/d3d/RendererD3D.h
index d2fa4c7..135a83b 100644
--- a/src/libANGLE/renderer/d3d/RendererD3D.h
+++ b/src/libANGLE/renderer/d3d/RendererD3D.h
@@ -10,6 +10,7 @@
 #define LIBANGLE_RENDERER_D3D_RENDERERD3D_H_
 
 #include "libANGLE/renderer/Renderer.h"
+#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
 #include "libANGLE/Data.h"
 
 //FIXME(jmadill): std::array is currently prohibited by Chromium style guide
diff --git a/src/libANGLE/renderer/d3d/ShaderD3D.cpp b/src/libANGLE/renderer/d3d/ShaderD3D.cpp
index b0fbdc7..116c683 100644
--- a/src/libANGLE/renderer/d3d/ShaderD3D.cpp
+++ b/src/libANGLE/renderer/d3d/ShaderD3D.cpp
@@ -9,8 +9,8 @@
 #include "libANGLE/Shader.h"
 #include "libANGLE/renderer/d3d/RendererD3D.h"
 #include "libANGLE/renderer/d3d/ShaderD3D.h"
+#include "libANGLE/features.h"
 
-#include "common/features.h"
 #include "common/utilities.h"
 
 // Definitions local to the translation unit
diff --git a/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
new file mode 100644
index 0000000..95a5140
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/NativeWindow.h
@@ -0,0 +1,74 @@
+//
+// 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.
+//
+
+// NativeWindow.h: Defines NativeWindow, a class for managing and
+// performing operations on an EGLNativeWindowType.
+// It is used for HWND (Desktop Windows) and IInspectable objects
+//(Windows Store Applications).
+
+#ifndef LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW_H_
+#define LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW_H_
+
+#include <EGL/eglplatform.h>
+#include "common/debug.h"
+#include "common/platform.h"
+
+// DXGISwapChain and DXGIFactory are typedef'd to specific required
+// types. The HWND NativeWindow implementation requires IDXGISwapChain
+// and IDXGIFactory and the Windows Store NativeWindow
+// implementation requires IDXGISwapChain1 and IDXGIFactory2.
+#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+typedef IDXGISwapChain1 DXGISwapChain;
+typedef IDXGIFactory2 DXGIFactory;
+
+#include <wrl.h>
+#include <wrl/wrappers/corewrappers.h>
+#include <windows.applicationmodel.core.h>
+#include <memory>
+
+namespace rx
+{
+class InspectableNativeWindow;
+}
+
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+
+#else
+typedef IDXGISwapChain DXGISwapChain;
+typedef IDXGIFactory DXGIFactory;
+#endif
+
+namespace rx
+{
+class NativeWindow
+{
+  public:
+    explicit NativeWindow(EGLNativeWindowType window);
+
+    bool initialize();
+    bool getClientRect(LPRECT rect);
+    bool isIconic();
+
+    HRESULT createSwapChain(ID3D11Device* device, DXGIFactory* factory,
+                            DXGI_FORMAT format, UINT width, UINT height,
+                            DXGISwapChain** swapChain);
+
+    inline EGLNativeWindowType getNativeWindow() const { return mWindow; }
+
+  private:
+    EGLNativeWindowType mWindow;
+
+#if defined(ANGLE_ENABLE_WINDOWS_STORE)
+    std::shared_ptr<InspectableNativeWindow> mImpl;
+#endif
+
+};
+
+bool IsValidEGLNativeWindowType(EGLNativeWindowType window);
+}
+
+#endif // LIBANGLE_RENDERER_D3D_D3D11_NATIVEWINDOW_H_
diff --git a/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
index cb4f97c..079f811 100644
--- a/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
@@ -10,13 +10,13 @@
 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
 #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
 #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
+#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
+#include "libANGLE/features.h"
 
 // Precompiled shaders
 #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h"
 #include "libANGLE/renderer/d3d/d3d11/shaders/compiled/passthroughrgba2d11ps.h"
 
-#include "common/features.h"
-#include "common/NativeWindow.h"
 
 namespace rx
 {
diff --git a/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp b/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
new file mode 100644
index 0000000..32e92d1
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow.cpp
@@ -0,0 +1,67 @@
+//
+// 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.
+//
+
+// NativeWindow.cpp: Handler for managing HWND native window types.
+
+#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
+
+#include "common/debug.h"
+
+namespace rx
+{
+bool IsValidEGLNativeWindowType(EGLNativeWindowType window)
+{
+    return (IsWindow(window) == TRUE);
+}
+
+NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
+{
+}
+
+bool NativeWindow::initialize()
+{ 
+    return true; 
+}
+
+bool NativeWindow::getClientRect(LPRECT rect)
+{
+    return GetClientRect(mWindow, rect) == TRUE;
+}
+
+bool NativeWindow::isIconic()
+{
+    return IsIconic(mWindow) == TRUE;
+}
+
+HRESULT NativeWindow::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_DESC swapChainDesc = { 0 };
+    swapChainDesc.BufferCount = 1;
+    swapChainDesc.BufferDesc.Format = format;
+    swapChainDesc.BufferDesc.Width = width;
+    swapChainDesc.BufferDesc.Height = height;
+    swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
+    swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
+    swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
+    swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
+    swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER;
+    swapChainDesc.Flags = 0;
+    swapChainDesc.OutputWindow = mWindow;
+    swapChainDesc.SampleDesc.Count = 1;
+    swapChainDesc.SampleDesc.Quality = 0;
+    swapChainDesc.Windowed = TRUE;
+    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
+
+    return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
+}
+}
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
new file mode 100644
index 0000000..e2340c2
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.cpp
@@ -0,0 +1,189 @@
+//
+// 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.cpp: NativeWindow for managing ICoreWindow native window types.
+
+#include "libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h"
+
+#include <windows.graphics.display.h>
+
+using namespace ABI::Windows::Foundation::Collections;
+
+namespace rx
+{
+CoreWindowNativeWindow::~CoreWindowNativeWindow()
+{
+    unregisterForSizeChangeEvents();
+}
+
+bool CoreWindowNativeWindow::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(&mCoreWindow);
+    }
+
+    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 occurs automatically because if
+        // the scaling mode setting DXGI_SCALING_STRETCH on the swapchain.
+        if (swapChainSizeSpecified)
+        {
+            mClientRect = { 0, 0, swapChainSize.cx, swapChainSize.cy };
+            mSupportsSwapChainResize = false;
+        }
+        else
+        {
+            result = GetCoreWindowSizeInPixels(mCoreWindow, &mClientRect);
+        }
+    }
+
+    if (SUCCEEDED(result))
+    {
+        mNewClientRect = mClientRect;
+        mClientRectChanged = false;
+        return registerForSizeChangeEvents();
+    }
+
+    return false;
+}
+
+bool CoreWindowNativeWindow::registerForSizeChangeEvents()
+{
+    ComPtr<IWindowSizeChangedEventHandler> sizeChangedHandler;
+    HRESULT result = Microsoft::WRL::MakeAndInitialize<CoreWindowSizeChangedHandler>(sizeChangedHandler.ReleaseAndGetAddressOf(), this->shared_from_this());
+    if (SUCCEEDED(result))
+    {
+        result = mCoreWindow->add_SizeChanged(sizeChangedHandler.Get(), &mSizeChangedEventToken);
+    }
+
+    if (SUCCEEDED(result))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+void CoreWindowNativeWindow::unregisterForSizeChangeEvents()
+{
+    if (mCoreWindow)
+    {
+        (void)mCoreWindow->remove_SizeChanged(mSizeChangedEventToken);
+    }
+    mSizeChangedEventToken.value = 0;
+}
+
+HRESULT CoreWindowNativeWindow::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;
+
+    *swapChain = nullptr;
+
+    ComPtr<IDXGISwapChain1> newSwapChain;
+    HRESULT result = factory->CreateSwapChainForCoreWindow(device, mCoreWindow.Get(), &swapChainDesc, nullptr, newSwapChain.ReleaseAndGetAddressOf());
+    if (SUCCEEDED(result))
+    {
+
+#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+        // Test if swapchain supports resize.  On Windows Phone devices, this will return DXGI_ERROR_UNSUPPORTED.  On
+        // other devices DXGI_ERROR_INVALID_CALL should be returned because the combination of flags passed
+        // (DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE) are invalid flag combinations.
+        if (newSwapChain->ResizeBuffers(swapChainDesc.BufferCount, swapChainDesc.Width, swapChainDesc.Height, swapChainDesc.Format, DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE) == DXGI_ERROR_UNSUPPORTED)
+        {
+            mSupportsSwapChainResize = false;
+        }
+#endif // (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
+
+        result = newSwapChain.CopyTo(swapChain);
+    }
+
+    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 GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, RECT *windowSize)
+{
+    ABI::Windows::Foundation::Rect bounds;
+    HRESULT result = coreWindow->get_Bounds(&bounds);
+    if (SUCCEEDED(result))
+    {
+        *windowSize = { 0, 0, ConvertDipsToPixels(bounds.Width), ConvertDipsToPixels(bounds.Height) };
+    }
+
+    return result;
+}
+
+static float GetLogicalDpi()
+{
+    ComPtr<ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> displayProperties;
+    float dpi = 96.0f;
+
+    if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), displayProperties.GetAddressOf())))
+    {
+        if (SUCCEEDED(displayProperties->get_LogicalDpi(&dpi)))
+        {
+            return dpi;
+        }
+    }
+    return dpi;
+}
+
+long ConvertDipsToPixels(float dips)
+{
+    static const float dipsPerInch = 96.0f;
+    return lround((dips * GetLogicalDpi() / dipsPerInch));
+}
+}
\ No newline at end of file
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
new file mode 100644
index 0000000..c230c84
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h
@@ -0,0 +1,78 @@
+//
+// 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 LIBANGLE_RENDERER_D3D_D3D11_WINRT_COREWINDOWNATIVEWINDOW_H_
+#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_COREWINDOWNATIVEWINDOW_H_
+
+#include "libANGLE/renderer/d3d/d3d11/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 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;
+};
+
+[uuid(7F924F66-EBAE-40E5-A10B-B8F35E245190)]
+class CoreWindowSizeChangedHandler :
+    public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, IWindowSizeChangedEventHandler>
+{
+  public:
+    CoreWindowSizeChangedHandler() { }
+    HRESULT RuntimeClassInitialize(std::shared_ptr<InspectableNativeWindow> host)
+    {
+        if (!host)
+        {
+            return E_INVALIDARG;
+        }
+
+        mHost = host;
+        return S_OK;
+    }
+
+    // IWindowSizeChangedEventHandler
+    IFACEMETHOD(Invoke)(ABI::Windows::UI::Core::ICoreWindow *sender, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *sizeChangedEventArgs)
+    {
+        std::shared_ptr<InspectableNativeWindow> host = mHost.lock();
+        if (host)
+        {
+            ABI::Windows::Foundation::Size windowSize;
+            if (SUCCEEDED(sizeChangedEventArgs->get_Size(&windowSize)))
+            {
+                SIZE windowSizeInPixels = { ConvertDipsToPixels(windowSize.Width), ConvertDipsToPixels(windowSize.Height) };
+                host->setNewClientSize(windowSizeInPixels);
+            }
+        }
+
+        return S_OK;
+    }
+
+  private:
+    std::weak_ptr<InspectableNativeWindow> mHost;
+};
+
+HRESULT GetCoreWindowSizeInPixels(const ComPtr<ABI::Windows::UI::Core::ICoreWindow>& coreWindow, RECT *windowSize);
+}
+
+#endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_COREWINDOWNATIVEWINDOW_H_
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
new file mode 100644
index 0000000..cb0b939
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp
@@ -0,0 +1,274 @@
+//
+// 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.
+//
+
+// InspectableNativeWindow.cpp: NativeWindow base class for managing IInspectable native window types.
+
+#include "libANGLE/renderer/d3d/d3d11/winrt/CoreWindowNativeWindow.h"
+#include "libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h"
+
+namespace rx
+{
+NativeWindow::NativeWindow(EGLNativeWindowType window)
+{
+    mWindow = window;
+}
+
+bool NativeWindow::initialize()
+{
+    // If the native window type is a IPropertySet, extract the
+    // EGLNativeWindowType (IInspectable) and initialize the
+    // proper host with this IPropertySet.
+    ComPtr<ABI::Windows::Foundation::Collections::IPropertySet> propertySet;
+    ComPtr<IInspectable> 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
+        // to use the EGLNativeWindowType specified in the property set.
+        // mWindow is treated as a raw pointer not an AddRef'd interface, so
+        // the old mWindow does not need a Release() before this assignment.
+        mWindow = eglNativeWindow.Get();
+    }
+
+    ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWindow;
+    ComPtr<ABI::Windows::UI::Xaml::Controls::ISwapChainPanel> swapChainPanel;
+    if (IsCoreWindow(mWindow, &coreWindow))
+    {
+        mImpl = std::make_shared<CoreWindowNativeWindow>();
+        if (mImpl)
+        {
+            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, ISwapChainPanel and IPropertySet");
+    }
+
+    return false;
+}
+
+bool NativeWindow::getClientRect(RECT *rect)
+{
+    if (mImpl)
+    {
+        return mImpl->getClientRect(rect);
+    }
+
+    return false;
+}
+
+bool NativeWindow::isIconic()
+{
+    return false;
+}
+
+HRESULT NativeWindow::createSwapChain(ID3D11Device *device, DXGIFactory *factory, DXGI_FORMAT format, unsigned int width, unsigned int height, DXGISwapChain **swapChain)
+{
+    if (mImpl)
+    {
+        return mImpl->createSwapChain(device, factory, format, width, height, swapChain);
+    }
+
+    return E_UNEXPECTED;
+}
+
+bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow)
+{
+    if (!window)
+    {
+        return false;
+    }
+
+    ComPtr<IInspectable> win = window;
+    ComPtr<ABI::Windows::UI::Core::ICoreWindow> coreWin;
+    if (SUCCEEDED(win.As(&coreWin)))
+    {
+        if (coreWindow != nullptr)
+        {
+            *coreWindow = coreWin.Detach();
+        }
+        return true;
+    }
+
+    return false;
+}
+
+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)
+    {
+        return false;
+    }
+
+    ComPtr<IInspectable> props = window;
+    ComPtr<IPropertySet> propSet;
+    ComPtr<IInspectable> nativeWindow;
+    ComPtr<ABI::Windows::Foundation::Collections::IMap<HSTRING, IInspectable*>> propMap;
+    boolean hasEglNativeWindowPropertyKey = false;
+
+    HRESULT result = props.As(&propSet);
+    if (SUCCEEDED(result))
+    {
+        result = propSet.As(&propMap);
+    }
+
+    // Look for the presence of the EGLNativeWindowType in the property set
+    if (SUCCEEDED(result))
+    {
+        result = propMap->HasKey(HStringReference(EGLNativeWindowTypeProperty).Get(), &hasEglNativeWindowPropertyKey);
+    }
+
+    // If the IPropertySet does not contain the required EglNativeWindowType key, the property set is
+    // considered invalid.
+    if (SUCCEEDED(result) && !hasEglNativeWindowPropertyKey)
+    {
+        ERR("Could not find EGLNativeWindowTypeProperty in IPropertySet. Valid EGLNativeWindowTypeProperty values include ICoreWindow");
+        return false;
+    }
+
+    // The EglNativeWindowType property exists, so retreive the IInspectable that represents the EGLNativeWindowType
+    if (SUCCEEDED(result) && hasEglNativeWindowPropertyKey)
+    {
+        result = propMap->Lookup(HStringReference(EGLNativeWindowTypeProperty).Get(), &nativeWindow);
+    }
+
+    if (SUCCEEDED(result))
+    {
+        if (propertySet != nullptr)
+        {
+            result = propSet.CopyTo(propertySet);
+        }
+    }
+
+    if (SUCCEEDED(result))
+    {
+        if (eglNativeWindow != nullptr)
+        {
+            result = nativeWindow.CopyTo(eglNativeWindow);
+        }
+    }
+
+    if (SUCCEEDED(result))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+// A Valid EGLNativeWindowType IInspectable can only be:
+//
+// ICoreWindow
+// IPropertySet
+// 
+// Anything else will be rejected as an invalid IInspectable.
+bool IsValidEGLNativeWindowType(EGLNativeWindowType 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
+// an ABI::Windows::Foundation::Size.  This function validates the Size value before returning 
+// it to the caller.
+//
+// Possible return values are:
+// S_OK, valueExists == true - optional SIZE value was successfully retrieved and validated
+// S_OK, valueExists == false - optional SIZE value was not found
+// E_INVALIDARG, valueExists = false - optional SIZE value was malformed in the property set.
+//    * Incorrect property type ( must be PropertyType_Size)
+//    * 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)
+{
+    if (!propertyMap || !propertyName || !value || !valueExists)
+    {
+        return false;
+    }
+
+    // Assume that the value does not exist
+    *valueExists = false;
+    *value = { 0, 0 };
+
+    ComPtr<ABI::Windows::Foundation::IPropertyValue> propertyValue;
+    ABI::Windows::Foundation::PropertyType propertyType = ABI::Windows::Foundation::PropertyType::PropertyType_Empty;
+    Size sizeValue = { 0, 0 };
+    boolean hasKey = false;
+
+    HRESULT result = propertyMap->HasKey(HStringReference(propertyName).Get(), &hasKey);
+    if (SUCCEEDED(result) && !hasKey)
+    {
+        // Value does not exist, so return S_OK and set the exists parameter to false to indicate
+        // that a the optional property does not exist.
+        *valueExists = false;
+        return S_OK;
+    }
+
+    if (SUCCEEDED(result))
+    {
+        result = propertyMap->Lookup(HStringReference(propertyName).Get(), &propertyValue);
+    }
+
+    if (SUCCEEDED(result))
+    {
+        result = propertyValue->get_Type(&propertyType);
+    }
+
+    // Check if the expected Size property is of PropertyType_Size type.
+    if (SUCCEEDED(result) && propertyType == ABI::Windows::Foundation::PropertyType::PropertyType_Size)
+    {
+        if (SUCCEEDED(propertyValue->GetSize(&sizeValue)) && (sizeValue.Width > 0 && sizeValue.Height > 0))
+        {
+            // A valid property value exists
+            *value = { static_cast<long>(sizeValue.Width), static_cast<long>(sizeValue.Height) };
+            *valueExists = true;
+            result = S_OK;
+        }
+        else
+        {
+            // An invalid Size property was detected. Width/Height values must > 0
+            result = E_INVALIDARG;
+        }
+    }
+    else
+    {
+        // An invalid property type was detected. Size property must be of PropertyType_Size
+        result = E_INVALIDARG;
+    }
+
+    return result;
+}
+}
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
new file mode 100644
index 0000000..b420352
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.h
@@ -0,0 +1,92 @@
+//
+// 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.
+//
+
+// InspectableNativeWindow.h: Host specific implementation interface for
+// managing IInspectable native window types.
+
+#ifndef LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
+#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
+
+#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
+
+#include "common/platform.h"
+
+#include "angle_windowsstore.h"
+
+#include <windows.ui.xaml.h>
+#include <windows.ui.xaml.media.dxinterop.h>
+
+using namespace Microsoft::WRL;
+using namespace Microsoft::WRL::Wrappers;
+using namespace ABI::Windows::Foundation;
+using namespace ABI::Windows::Foundation::Collections;
+
+namespace rx
+{
+class InspectableNativeWindow
+{
+  public:
+    InspectableNativeWindow() :
+        mSupportsSwapChainResize(true),
+        mRequiresSwapChainScaling(false),
+        mClientRectChanged(false),
+        mClientRect({0,0,0,0}),
+        mNewClientRect({0,0,0,0})
+    {
+        mSizeChangedEventToken.value = 0;
+    }
+    virtual ~InspectableNativeWindow(){}
+
+    virtual bool initialize(EGLNativeWindowType window, IPropertySet *propertySet) = 0;
+    virtual HRESULT createSwapChain(ID3D11Device *device, 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)
+    {
+        if (mClientRectChanged && mSupportsSwapChainResize)
+        {
+            mClientRect = mNewClientRect;
+        }
+
+        *rect = mClientRect;
+
+        return true;
+    }
+
+    void setNewClientSize(const SIZE &newSize)
+    {
+        if (mSupportsSwapChainResize && !mRequiresSwapChainScaling)
+        {
+            mNewClientRect = { 0, 0, newSize.cx, newSize.cy };
+            mClientRectChanged = true;
+        }
+
+        if (mRequiresSwapChainScaling)
+        {
+            scaleSwapChain(newSize);
+        }
+    }
+
+protected:
+    bool mSupportsSwapChainResize;
+    bool mRequiresSwapChainScaling;
+    RECT mClientRect;
+    RECT mNewClientRect;
+    bool mClientRectChanged;
+
+    EventRegistrationToken mSizeChangedEventToken;
+};
+
+bool IsCoreWindow(EGLNativeWindowType window, ComPtr<ABI::Windows::UI::Core::ICoreWindow> *coreWindow = nullptr);
+bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr<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 // LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
new file mode 100644
index 0000000..53899db
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.cpp
@@ -0,0 +1,228 @@
+//
+// 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 "libANGLE/renderer/d3d/d3d11/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;
+}
+}
diff --git a/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
new file mode 100644
index 0000000..caf327d
--- /dev/null
+++ b/src/libANGLE/renderer/d3d/d3d11/winrt/SwapChainPanelNativeWindow.h
@@ -0,0 +1,79 @@
+//
+// 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 LIBANGLE_RENDERER_D3D_D3D11_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_
+#define LIBANGLE_RENDERER_D3D_D3D11_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_
+
+#include "libANGLE/renderer/d3d/d3d11/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 // LIBANGLE_RENDERER_D3D_D3D11_WINRT_SWAPCHAINPANELNATIVEWINDOW_H_
diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
index c5d621c..b403a0a 100644
--- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp
@@ -36,11 +36,10 @@
 #include "libANGLE/ProgramBinary.h"
 #include "libANGLE/State.h"
 #include "libANGLE/angletypes.h"
-
 #include "libANGLE/Display.h"
 #include "libANGLE/Surface.h"
+#include "libANGLE/features.h"
 
-#include "common/features.h"
 #include "common/utilities.h"
 
 #include "third_party/trace_event/trace_event.h"
diff --git a/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp b/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp
index 08392f8..64050af 100644
--- a/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp
+++ b/src/libANGLE/renderer/d3d/d3d9/SwapChain9.cpp
@@ -10,8 +10,7 @@
 #include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
 #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
 #include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
-
-#include "common/features.h"
+#include "libANGLE/features.h"
 
 namespace rx
 {