aboutsummaryrefslogtreecommitdiff
path: root/src/win/native/window_d2d_painter.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-06-27 17:02:58 +0800
committercrupest <crupest@outlook.com>2019-06-27 17:02:58 +0800
commitb53527fbe50a953ad0e3225cc812eb76b8a1f82d (patch)
treeeb81cd14d0a165c47f841ad94835f8987109de7e /src/win/native/window_d2d_painter.cpp
parent8c5b05bcfce96495b4ffc4209ab8feda12597729 (diff)
downloadcru-b53527fbe50a953ad0e3225cc812eb76b8a1f82d.tar.gz
cru-b53527fbe50a953ad0e3225cc812eb76b8a1f82d.tar.bz2
cru-b53527fbe50a953ad0e3225cc812eb76b8a1f82d.zip
...
Diffstat (limited to 'src/win/native/window_d2d_painter.cpp')
-rw-r--r--src/win/native/window_d2d_painter.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/win/native/window_d2d_painter.cpp b/src/win/native/window_d2d_painter.cpp
new file mode 100644
index 00000000..16d276ef
--- /dev/null
+++ b/src/win/native/window_d2d_painter.cpp
@@ -0,0 +1,33 @@
+#include "window_d2d_painter.hpp"
+
+#include "cru/win/graph/direct/direct_factory.hpp"
+#include "cru/win/graph/direct/exception.hpp"
+#include "cru/win/native/window_render_target.hpp"
+
+#include <cassert>
+
+namespace cru::platform::native::win {
+using namespace cru::platform::graph::win::direct;
+
+WindowD2DPainter::WindowD2DPainter(WinNativeWindow* window)
+ : D2DPainter(window->GetWindowRenderTarget()
+ ->GetWinNativeFactory()
+ ->GetD2D1DeviceContext()),
+ window_(window) {
+ window->GetWindowRenderTarget()->SetAsTarget();
+ window->GetWindowRenderTarget()
+ ->GetWinNativeFactory()
+ ->GetD2D1DeviceContext()
+ ->BeginDraw();
+}
+
+WindowD2DPainter::~WindowD2DPainter() { EndDraw(); }
+
+void WindowD2DPainter::DoEndDraw() {
+ ThrowIfFailed(window_->GetWindowRenderTarget()
+ ->GetWinNativeFactory()
+ ->GetD2D1DeviceContext()
+ ->EndDraw());
+ window_->GetWindowRenderTarget()->Present();
+}
+} // namespace cru::platform::native::win