// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved #pragma once #include #include #include #include #include #include class Application { public: Application(HINSTANCE hInstance); ~Application(); int Run(); private: static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam); private: Application(const Application &); // not implemented Application &operator=(const Application &); // not implemented private: HRESULT BeforeEnteringMessageLoop(); int EnterMessageLoop(); void AfterLeavingMessageLoop(); HRESULT CreateMainWindow(); HRESULT ShowMainWindow(); void DestroyMainWindow(); HRESULT EnableMouseAsPointerDevice(); HRESULT CreateD3DDevice(); void DestroyD3DDevice(); HRESULT CreateD2DDevice(); void DestroyD2DDevice(); HRESULT CreateDWriteFactory(); void DestroyDWriteFactory(); HRESULT CreateDCompDevice(); void DestroyDCompDevice(); HRESULT CreateDCompVisualTree(); void DestroyDCompVisualTree(); HRESULT CreateDCompTarget(); void DestroyDCompTarget(); HRESULT CreateDCompRootVisual(); void DestroyDCompRootVisual(); HRESULT CreateDCompTextVisual(); void DestroyDCompTextVisual(); HRESULT CreateDCompTextSurface(); void DestroyDCompTextSurface(); HRESULT CreateDCompTileVisuals(); void DestroyDCompTileVisuals(); HRESULT CreateDCompTileSurfaces(); void DestroyDCompTileSurfaces(); HRESULT DrawDCompTextSurface(); HRESULT DrawDCompTileSurfaces(); HRESULT BindDCompRootVisualToTarget(); HRESULT BindDCompTextSurfaceToVisual(); HRESULT BindDCompTileSurfacesToVisuals(); HRESULT SetOffsetOnDCompTextVisual(); HRESULT SetOffsetOnDCompTileVisuals(); HRESULT SetBackfaceVisibilityOnDCompTileVisuals(); HRESULT AddDCompTextVisualToRootVisual(); HRESULT AddDCompTileVisualsToRootVisual(); HRESULT CommitDCompDevice(); LRESULT OnPointerUp(LPARAM lparam); LRESULT OnClose(); LRESULT OnDestroy(); bool HasAnyVisualBeenHit(int x, int y, int *pVisualIndex); HRESULT FlipVisual(int visualIndex); HRESULT ResetVisuals(); void ShowMessageBoxIfFailed(HRESULT hr, const wchar_t *pMessage); private: static Application *_application; private: HINSTANCE _hInstance; HWND _hWnd; UINT _hWndClientWidth; UINT _hWndClientHeight; Microsoft::WRL::ComPtr _d3dDevice; Microsoft::WRL::ComPtr _d2dDevice; Microsoft::WRL::ComPtr _dwriteFactory; Microsoft::WRL::ComPtr _dcompDevice; Microsoft::WRL::ComPtr _dcompTarget; Microsoft::WRL::ComPtr _dcompRootVisual; Microsoft::WRL::ComPtr _dcompTextVisual; Microsoft::WRL::ComPtr _dcompTextSurface; Microsoft::WRL::ComPtr _dcompTileVisuals[4]; Microsoft::WRL::ComPtr _dcompTileSurfaces[4]; };