From cf07d193b97168048a72793c59f096504acf78a5 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 28 Oct 2020 20:36:47 +0800 Subject: ... --- include/cru/win/graph/direct/WindowPainter.hpp | 21 ++++++ .../cru/win/graph/direct/WindowRenderTarget.hpp | 42 +++++++++++ include/cru/win/native/Base.hpp | 1 - include/cru/win/native/Window.hpp | 6 +- include/cru/win/native/WindowRenderTarget.hpp | 48 ------------- src/win/graph/direct/CMakeLists.txt | 4 ++ src/win/graph/direct/WindowPainter.cpp | 20 ++++++ src/win/graph/direct/WindowRenderTarget.cpp | 81 +++++++++++++++++++++ src/win/native/CMakeLists.txt | 5 -- src/win/native/DpiUtil.hpp | 11 --- src/win/native/InputMethod.cpp | 1 - src/win/native/Window.cpp | 22 ++++-- src/win/native/WindowD2DPainter.cpp | 22 ------ src/win/native/WindowD2DPainter.hpp | 21 ------ src/win/native/WindowRenderTarget.cpp | 83 ---------------------- 15 files changed, 188 insertions(+), 200 deletions(-) create mode 100644 include/cru/win/graph/direct/WindowPainter.hpp create mode 100644 include/cru/win/graph/direct/WindowRenderTarget.hpp delete mode 100644 include/cru/win/native/WindowRenderTarget.hpp create mode 100644 src/win/graph/direct/WindowPainter.cpp create mode 100644 src/win/graph/direct/WindowRenderTarget.cpp delete mode 100644 src/win/native/DpiUtil.hpp delete mode 100644 src/win/native/WindowD2DPainter.cpp delete mode 100644 src/win/native/WindowD2DPainter.hpp delete mode 100644 src/win/native/WindowRenderTarget.cpp diff --git a/include/cru/win/graph/direct/WindowPainter.hpp b/include/cru/win/graph/direct/WindowPainter.hpp new file mode 100644 index 00000000..53961586 --- /dev/null +++ b/include/cru/win/graph/direct/WindowPainter.hpp @@ -0,0 +1,21 @@ +#pragma once +#include "Painter.hpp" +#include "WindowRenderTarget.hpp" + +namespace cru::platform::graph::win::direct { +class D2DWindowPainter : public graph::win::direct::D2DPainter { + public: + explicit D2DWindowPainter(D2DWindowRenderTarget* window); + + CRU_DELETE_COPY(D2DWindowPainter) + CRU_DELETE_MOVE(D2DWindowPainter) + + ~D2DWindowPainter() override; + + protected: + void DoEndDraw() override; + + private: + D2DWindowRenderTarget* render_target_; +}; +} // namespace cru::platform::graph::win::direct diff --git a/include/cru/win/graph/direct/WindowRenderTarget.hpp b/include/cru/win/graph/direct/WindowRenderTarget.hpp new file mode 100644 index 00000000..c9ee098f --- /dev/null +++ b/include/cru/win/graph/direct/WindowRenderTarget.hpp @@ -0,0 +1,42 @@ +#pragma once +#include "Factory.hpp" + +namespace cru::platform::graph::win::direct { +// Represents a window render target. +class D2DWindowRenderTarget : public Object { + public: + D2DWindowRenderTarget(gsl::not_null factory, HWND hwnd); + + CRU_DELETE_COPY(D2DWindowRenderTarget) + CRU_DELETE_MOVE(D2DWindowRenderTarget) + + ~D2DWindowRenderTarget() override = default; + + public: + graph::win::direct::DirectGraphFactory* GetDirectFactory() const { + return factory_; + } + + ID2D1DeviceContext* GetD2D1DeviceContext() { + return d2d1_device_context_.Get(); + } + + void SetDpi(float x, float y); + + // Resize the underlying buffer. + void ResizeBuffer(int width, int height); + + // Present the data of the underlying buffer to the window. + void Present(); + + private: + void CreateTargetBitmap(); + + private: + DirectGraphFactory* factory_; + HWND hwnd_; + Microsoft::WRL::ComPtr d2d1_device_context_; + Microsoft::WRL::ComPtr dxgi_swap_chain_; + Microsoft::WRL::ComPtr target_bitmap_; +}; +} // namespace cru::platform::graph::win::direct diff --git a/include/cru/win/native/Base.hpp b/include/cru/win/native/Base.hpp index a50c6dd1..7ddc6b54 100644 --- a/include/cru/win/native/Base.hpp +++ b/include/cru/win/native/Base.hpp @@ -10,7 +10,6 @@ class WinCursor; class WinCursorManager; class WindowClass; class WindowManager; -class WindowRenderTarget; class WinNativeWindow; class WinNativeWindowResolver; class WinUiApplication; diff --git a/include/cru/win/native/Window.hpp b/include/cru/win/native/Window.hpp index 37df0768..ecc0dd04 100644 --- a/include/cru/win/native/Window.hpp +++ b/include/cru/win/native/Window.hpp @@ -4,6 +4,7 @@ #include "WindowNativeMessageEventArgs.hpp" #include "cru/platform/GraphBase.hpp" #include "cru/platform/native/Window.hpp" +#include "cru/win/graph/direct/WindowRenderTarget.hpp" #include @@ -86,7 +87,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { bool HandleNativeWindowMessage(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, LRESULT* result); - WindowRenderTarget* GetWindowRenderTarget() const { + graph::win::direct::D2DWindowRenderTarget* GetWindowRenderTarget() const { return window_render_target_.get(); } @@ -157,7 +158,8 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { bool has_focus_ = false; bool is_mouse_in_ = false; - std::unique_ptr window_render_target_; + std::unique_ptr + window_render_target_; std::shared_ptr cursor_; diff --git a/include/cru/win/native/WindowRenderTarget.hpp b/include/cru/win/native/WindowRenderTarget.hpp deleted file mode 100644 index 786a90a6..00000000 --- a/include/cru/win/native/WindowRenderTarget.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "Base.hpp" - -namespace cru::platform::graph::win::direct { -class DirectGraphFactory; -} - -namespace cru::platform::native::win { -// Represents a window render target. -class WindowRenderTarget : public Object { - public: - WindowRenderTarget(graph::win::direct::DirectGraphFactory* factory, - WinNativeWindow* window); - - CRU_DELETE_COPY(WindowRenderTarget) - CRU_DELETE_MOVE(WindowRenderTarget) - - ~WindowRenderTarget() override = default; - - public: - graph::win::direct::DirectGraphFactory* GetDirectFactory() const { - return factory_; - } - - ID2D1DeviceContext* GetD2D1DeviceContext() { - return d2d1_device_context_.Get(); - } - - // Resize the underlying buffer. - void ResizeBuffer(int width, int height); - - // Set this render target as the d2d device context's target. - void SetAsTarget(); - - // Present the data of the underlying buffer to the window. - void Present(); - - private: - void CreateTargetBitmap(); - - private: - WinNativeWindow* window_; - graph::win::direct::DirectGraphFactory* factory_; - Microsoft::WRL::ComPtr d2d1_device_context_; - Microsoft::WRL::ComPtr dxgi_swap_chain_; - Microsoft::WRL::ComPtr target_bitmap_; -}; -} // namespace cru::platform::native::win diff --git a/src/win/graph/direct/CMakeLists.txt b/src/win/graph/direct/CMakeLists.txt index 5505b0b5..070b7b51 100644 --- a/src/win/graph/direct/CMakeLists.txt +++ b/src/win/graph/direct/CMakeLists.txt @@ -8,6 +8,8 @@ add_library(cru_win_graph_direct STATIC Painter.cpp Resource.cpp TextLayout.cpp + WindowPainter.cpp + WindowRenderTarget.cpp ) target_sources(cru_win_graph_direct PUBLIC ${CRU_WIN_GRAPH_DIRECT_INCLUDE_DIR}/Brush.hpp @@ -20,6 +22,8 @@ target_sources(cru_win_graph_direct PUBLIC ${CRU_WIN_GRAPH_DIRECT_INCLUDE_DIR}/Painter.hpp ${CRU_WIN_GRAPH_DIRECT_INCLUDE_DIR}/Resource.hpp ${CRU_WIN_GRAPH_DIRECT_INCLUDE_DIR}/TextLayout.hpp + ${CRU_WIN_GRAPH_DIRECT_INCLUDE_DIR}/WindowPainter.hpp + ${CRU_WIN_GRAPH_DIRECT_INCLUDE_DIR}/WindowRenderTarget.hpp ) target_link_libraries(cru_win_graph_direct PUBLIC D3D11 D2d1 DWrite) target_link_libraries(cru_win_graph_direct PUBLIC cru_win_base cru_platform_graph) diff --git a/src/win/graph/direct/WindowPainter.cpp b/src/win/graph/direct/WindowPainter.cpp new file mode 100644 index 00000000..74f7da7a --- /dev/null +++ b/src/win/graph/direct/WindowPainter.cpp @@ -0,0 +1,20 @@ +#include "cru/win/graph/direct/WindowPainter.hpp" + +#include "cru/win/graph/direct/Exception.hpp" +#include "cru/win/graph/direct/Factory.hpp" +#include "cru/win/graph/direct/WindowRenderTarget.hpp" + +namespace cru::platform::graph::win::direct { +D2DWindowPainter::D2DWindowPainter(D2DWindowRenderTarget* render_target) + : D2DPainter(render_target->GetD2D1DeviceContext()), + render_target_(render_target) { + render_target_->GetD2D1DeviceContext()->BeginDraw(); +} + +D2DWindowPainter::~D2DWindowPainter() { EndDraw(); } + +void D2DWindowPainter::DoEndDraw() { + ThrowIfFailed(render_target_->GetD2D1DeviceContext()->EndDraw()); + render_target_->Present(); +} +} // namespace cru::platform::graph::win::direct diff --git a/src/win/graph/direct/WindowRenderTarget.cpp b/src/win/graph/direct/WindowRenderTarget.cpp new file mode 100644 index 00000000..d26fccf6 --- /dev/null +++ b/src/win/graph/direct/WindowRenderTarget.cpp @@ -0,0 +1,81 @@ +#include "cru/win/graph/direct/WindowRenderTarget.hpp" + +#include "cru/win/graph/direct/Exception.hpp" +#include "cru/win/graph/direct/Factory.hpp" + +namespace cru::platform::graph::win::direct { +D2DWindowRenderTarget::D2DWindowRenderTarget( + gsl::not_null factory, HWND hwnd) + : factory_(factory), hwnd_(hwnd) { + const auto d3d11_device = factory->GetD3D11Device(); + const auto dxgi_factory = factory->GetDxgiFactory(); + + d2d1_device_context_ = factory->CreateD2D1DeviceContext(); + d2d1_device_context_->SetUnitMode(D2D1_UNIT_MODE_DIPS); + + // Allocate a descriptor. + DXGI_SWAP_CHAIN_DESC1 swap_chain_desc; + swap_chain_desc.Width = 0; // use automatic sizing + swap_chain_desc.Height = 0; + swap_chain_desc.Format = + DXGI_FORMAT_B8G8R8A8_UNORM; // this is the most common swapchain format + swap_chain_desc.Stereo = false; + swap_chain_desc.SampleDesc.Count = 1; // don't use multi-sampling + swap_chain_desc.SampleDesc.Quality = 0; + swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swap_chain_desc.BufferCount = 2; // use double buffering to enable flip + swap_chain_desc.Scaling = DXGI_SCALING_NONE; + swap_chain_desc.SwapEffect = + DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // all apps must use this SwapEffect + swap_chain_desc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; + swap_chain_desc.Flags = 0; + + // Get the final swap chain for this window from the DXGI factory. + ThrowIfFailed(dxgi_factory->CreateSwapChainForHwnd( + d3d11_device, hwnd, &swap_chain_desc, nullptr, nullptr, + &dxgi_swap_chain_)); + + CreateTargetBitmap(); +} + +void D2DWindowRenderTarget::SetDpi(float x, float y) { + d2d1_device_context_->SetDpi(x, y); +} + +void D2DWindowRenderTarget::ResizeBuffer(const int width, const int height) { + // In order to resize buffer, we need to untarget the buffer first. + d2d1_device_context_->SetTarget(nullptr); + target_bitmap_ = nullptr; + ThrowIfFailed(dxgi_swap_chain_->ResizeBuffers(0, width, height, + DXGI_FORMAT_UNKNOWN, 0)); + CreateTargetBitmap(); +} + +void D2DWindowRenderTarget::Present() { + ThrowIfFailed(dxgi_swap_chain_->Present(1, 0)); +} + +void D2DWindowRenderTarget::CreateTargetBitmap() { + Expects(target_bitmap_ == nullptr); // target bitmap must not exist. + + // Direct2D needs the dxgi version of the backbuffer surface pointer. + Microsoft::WRL::ComPtr dxgi_back_buffer; + ThrowIfFailed( + dxgi_swap_chain_->GetBuffer(0, IID_PPV_ARGS(&dxgi_back_buffer))); + + float dpi_x, dpi_y; + d2d1_device_context_->GetDpi(&dpi_x, &dpi_y); + + auto bitmap_properties = D2D1::BitmapProperties1( + D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW, + D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE), + dpi_x, dpi_y); + + // Get a D2D surface from the DXGI back buffer to use as the D2D render + // target. + ThrowIfFailed(d2d1_device_context_->CreateBitmapFromDxgiSurface( + dxgi_back_buffer.Get(), &bitmap_properties, &target_bitmap_)); + + d2d1_device_context_->SetTarget(target_bitmap_.Get()); +} +} // namespace cru::platform::graph::win::direct diff --git a/src/win/native/CMakeLists.txt b/src/win/native/CMakeLists.txt index 0e8ae44f..4b84600b 100644 --- a/src/win/native/CMakeLists.txt +++ b/src/win/native/CMakeLists.txt @@ -1,9 +1,7 @@ set(CRU_WIN_NATIVE_INCLUDE_DIR ${CRU_INCLUDE_DIR}/cru/win/native) add_library(cru_win_native STATIC - DpiUtil.hpp TimerManager.hpp - WindowD2DPainter.hpp WindowManager.hpp Cursor.cpp @@ -14,9 +12,7 @@ add_library(cru_win_native STATIC UiApplication.cpp Window.cpp WindowClass.cpp - WindowD2DPainter.cpp WindowManager.cpp - WindowRenderTarget.cpp ) target_sources(cru_win_native PUBLIC ${CRU_WIN_NATIVE_INCLUDE_DIR}/Cursor.hpp @@ -30,7 +26,6 @@ target_sources(cru_win_native PUBLIC ${CRU_WIN_NATIVE_INCLUDE_DIR}/Window.hpp ${CRU_WIN_NATIVE_INCLUDE_DIR}/WindowClass.hpp ${CRU_WIN_NATIVE_INCLUDE_DIR}/WindowNativeMessageEventArgs.hpp - ${CRU_WIN_NATIVE_INCLUDE_DIR}/WindowRenderTarget.hpp ) target_link_libraries(cru_win_native PUBLIC imm32) target_link_libraries(cru_win_native PUBLIC cru_win_graph_direct cru_platform_native) diff --git a/src/win/native/DpiUtil.hpp b/src/win/native/DpiUtil.hpp deleted file mode 100644 index 8401b03f..00000000 --- a/src/win/native/DpiUtil.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "cru/platform/native/Base.hpp" - -// The dpi awareness needs to be implemented in the future. Currently we use 96 -// as default. - -namespace cru::platform::native::win { -inline platform::native::Dpi GetDpi() { - return platform::native::Dpi{96.0f, 96.0f}; -} -} // namespace cru::platform::native::win diff --git a/src/win/native/InputMethod.cpp b/src/win/native/InputMethod.cpp index 7a46bef4..d976a8ba 100644 --- a/src/win/native/InputMethod.cpp +++ b/src/win/native/InputMethod.cpp @@ -1,6 +1,5 @@ #include "cru/win/native/InputMethod.hpp" -#include "DpiUtil.hpp" #include "cru/common/Logger.hpp" #include "cru/common/StringUtil.hpp" #include "cru/platform/Check.hpp" diff --git a/src/win/native/Window.cpp b/src/win/native/Window.cpp index 7efc6160..735221ca 100644 --- a/src/win/native/Window.cpp +++ b/src/win/native/Window.cpp @@ -1,16 +1,14 @@ #include "cru/win/native/Window.hpp" -#include "DpiUtil.hpp" -#include "WindowD2DPainter.hpp" #include "WindowManager.hpp" #include "cru/common/Logger.hpp" #include "cru/platform/Check.hpp" +#include "cru/win/graph/direct/WindowPainter.hpp" #include "cru/win/native/Cursor.hpp" #include "cru/win/native/Exception.hpp" #include "cru/win/native/Keyboard.hpp" #include "cru/win/native/UiApplication.hpp" #include "cru/win/native/WindowClass.hpp" -#include "cru/win/native/WindowRenderTarget.hpp" #include #include @@ -50,8 +48,10 @@ WinNativeWindow::WinNativeWindow(WinUiApplication* application, SetCursor(application->GetCursorManager()->GetSystemCursor( cru::platform::native::SystemCursorType::Arrow)); - window_render_target_ = std::make_unique( - application->GetDirectFactory(), this); + window_render_target_ = + std::make_unique( + application->GetDirectFactory(), hwnd_); + window_render_target_->SetDpi(dpi_, dpi_); } WinNativeWindow::~WinNativeWindow() { @@ -137,7 +137,8 @@ void WinNativeWindow::RequestRepaint() { } std::unique_ptr WinNativeWindow::BeginPaint() { - return std::make_unique(window_render_target_.get()); + return std::make_unique( + window_render_target_.get()); } void WinNativeWindow::SetCursor(std::shared_ptr cursor) { @@ -334,6 +335,15 @@ bool WinNativeWindow::HandleNativeWindowMessage(HWND hwnd, UINT msg, case WM_IME_COMPOSITION: *result = 0; return true; + case WM_DPICHANGED: { + dpi_ = static_cast(LOWORD(w_param)); + const RECT* suggest_rect = reinterpret_cast(l_param); + window_render_target_->SetDpi(dpi_, dpi_); + SetWindowPos(hwnd_, NULL, suggest_rect->left, suggest_rect->top, + suggest_rect->right - suggest_rect->left, + suggest_rect->bottom - suggest_rect->top, + SWP_NOZORDER | SWP_NOACTIVATE); + } default: return false; } diff --git a/src/win/native/WindowD2DPainter.cpp b/src/win/native/WindowD2DPainter.cpp deleted file mode 100644 index 7a97480b..00000000 --- a/src/win/native/WindowD2DPainter.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "WindowD2DPainter.hpp" - -#include "cru/win/graph/direct/Exception.hpp" -#include "cru/win/graph/direct/Factory.hpp" -#include "cru/win/native/WindowRenderTarget.hpp" - -namespace cru::platform::native::win { -using namespace cru::platform::graph::win::direct; - -WindowD2DPainter::WindowD2DPainter(WindowRenderTarget* render_target) - : D2DPainter(render_target->GetD2D1DeviceContext()), - render_target_(render_target) { - render_target_->GetD2D1DeviceContext()->BeginDraw(); -} - -WindowD2DPainter::~WindowD2DPainter() { EndDraw(); } - -void WindowD2DPainter::DoEndDraw() { - ThrowIfFailed(render_target_->GetD2D1DeviceContext()->EndDraw()); - render_target_->Present(); -} -} // namespace cru::platform::native::win diff --git a/src/win/native/WindowD2DPainter.hpp b/src/win/native/WindowD2DPainter.hpp deleted file mode 100644 index a638b77a..00000000 --- a/src/win/native/WindowD2DPainter.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "cru/win/graph/direct/Painter.hpp" -#include "cru/win/native/WindowRenderTarget.hpp" - -namespace cru::platform::native::win { -class WindowD2DPainter : public graph::win::direct::D2DPainter { - public: - explicit WindowD2DPainter(WindowRenderTarget* window); - - CRU_DELETE_COPY(WindowD2DPainter) - CRU_DELETE_MOVE(WindowD2DPainter) - - ~WindowD2DPainter() override; - - protected: - void DoEndDraw() override; - - private: - WindowRenderTarget* render_target_; -}; -} // namespace cru::platform::native::win diff --git a/src/win/native/WindowRenderTarget.cpp b/src/win/native/WindowRenderTarget.cpp deleted file mode 100644 index b1f867b0..00000000 --- a/src/win/native/WindowRenderTarget.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "cru/win/native/WindowRenderTarget.hpp" - -#include "DpiUtil.hpp" -#include "cru/win/graph/direct/Exception.hpp" -#include "cru/win/graph/direct/Factory.hpp" -#include "cru/win/native/Window.hpp" - -namespace cru::platform::native::win { -using namespace cru::platform::graph::win::direct; -WindowRenderTarget::WindowRenderTarget(DirectGraphFactory* factory, - WinNativeWindow* window) - : window_(window), factory_(factory) { - Expects(factory); - - const auto d3d11_device = factory->GetD3D11Device(); - const auto dxgi_factory = factory->GetDxgiFactory(); - - d2d1_device_context_ = factory->CreateD2D1DeviceContext(); - d2d1_device_context_->SetUnitMode(D2D1_UNIT_MODE_DIPS); - auto dpi = window_->GetDpi(); - d2d1_device_context_->SetDpi(dpi, dpi); - - // Allocate a descriptor. - DXGI_SWAP_CHAIN_DESC1 swap_chain_desc; - swap_chain_desc.Width = 0; // use automatic sizing - swap_chain_desc.Height = 0; - swap_chain_desc.Format = - DXGI_FORMAT_B8G8R8A8_UNORM; // this is the most common swapchain format - swap_chain_desc.Stereo = false; - swap_chain_desc.SampleDesc.Count = 1; // don't use multi-sampling - swap_chain_desc.SampleDesc.Quality = 0; - swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swap_chain_desc.BufferCount = 2; // use double buffering to enable flip - swap_chain_desc.Scaling = DXGI_SCALING_NONE; - swap_chain_desc.SwapEffect = - DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // all apps must use this SwapEffect - swap_chain_desc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; - swap_chain_desc.Flags = 0; - - // Get the final swap chain for this window from the DXGI factory. - ThrowIfFailed(dxgi_factory->CreateSwapChainForHwnd( - d3d11_device, window->GetWindowHandle(), &swap_chain_desc, nullptr, - nullptr, &dxgi_swap_chain_)); - - CreateTargetBitmap(); -} - -void WindowRenderTarget::ResizeBuffer(const int width, const int height) { - // In order to resize buffer, we need to untarget the buffer first. - d2d1_device_context_->SetTarget(nullptr); - target_bitmap_ = nullptr; - ThrowIfFailed(dxgi_swap_chain_->ResizeBuffers(0, width, height, - DXGI_FORMAT_UNKNOWN, 0)); - CreateTargetBitmap(); -} - -void WindowRenderTarget::Present() { - ThrowIfFailed(dxgi_swap_chain_->Present(1, 0)); -} - -void WindowRenderTarget::CreateTargetBitmap() { - Expects(target_bitmap_ == nullptr); // target bitmap must not exist. - - // Direct2D needs the dxgi version of the backbuffer surface pointer. - Microsoft::WRL::ComPtr dxgi_back_buffer; - ThrowIfFailed( - dxgi_swap_chain_->GetBuffer(0, IID_PPV_ARGS(&dxgi_back_buffer))); - - auto dpi = window_->GetDpi(); - - auto bitmap_properties = D2D1::BitmapProperties1( - D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW, - D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE), - dpi, dpi); - - // Get a D2D surface from the DXGI back buffer to use as the D2D render - // target. - ThrowIfFailed(d2d1_device_context_->CreateBitmapFromDxgiSurface( - dxgi_back_buffer.Get(), &bitmap_properties, &target_bitmap_)); - - d2d1_device_context_->SetTarget(target_bitmap_.Get()); -} -} // namespace cru::platform::native::win -- cgit v1.2.3