// // 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 #include using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Foundation::Collections; namespace rx { long ConvertDipsToPixels(float dips); class InspectableNativeWindow { public: InspectableNativeWindow() : mSupportsSwapChainResize(true), mRequiresSwapChainScaling(false), mClientRectChanged(false), mClientRect({0,0,0,0}), mNewClientRect({0,0,0,0}), mRotationFlags(NativeWindow::RotateNone) { 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) { mNewClientRect = { 0, 0, ConvertDipsToPixels(newSize.Width), ConvertDipsToPixels(newSize.Height) }; mClientRectChanged = true; } if (mRequiresSwapChainScaling) { scaleSwapChain(newSize); } } NativeWindow::RotationFlags rotationFlags() const { return mRotationFlags; } void setRotationFlags(NativeWindow::RotationFlags flags) { mRotationFlags = flags; } protected: bool mSupportsSwapChainResize; bool mRequiresSwapChainScaling; RECT mClientRect; RECT mNewClientRect; bool mClientRectChanged; NativeWindow::RotationFlags mRotationFlags; EventRegistrationToken mSizeChangedEventToken; }; bool IsValidEGLNativeWindowType(EGLNativeWindowType window); bool IsCoreWindow(EGLNativeWindowType window, ComPtr *coreWindow = nullptr); bool IsSwapChainPanel(EGLNativeWindowType window, ComPtr *swapChainPanel = nullptr); bool IsEGLConfiguredPropertySet(EGLNativeWindowType window, ABI::Windows::Foundation::Collections::IPropertySet **propertySet = nullptr, IInspectable **inspectable = nullptr); HRESULT GetOptionalSizePropertyValue(const ComPtr>& propertyMap, const wchar_t *propertyName, SIZE *value, bool *valueExists); } #endif // LIBANGLE_RENDERER_D3D_D3D11_WINRT_INSPECTABLENATIVEWINDOW_H_