aboutsummaryrefslogtreecommitdiff
path: root/src/win/native/window_painter.cpp
blob: 463be12887ff9bfc3cd0b052fa84064cae03eadb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "window_painter.hpp"

#include "cru/win/exception.hpp"
#include "cru/win/graph/win_native_factory.hpp"
#include "cru/win/native/window_render_target.hpp"

#include <cassert>

namespace cru::win::native {
WindowPainter::WindowPainter(WinNativeWindow* window)
    : WinPainter(window->GetWindowRenderTarget()
                     ->GetWinNativeFactory()
                     ->GetD2D1DeviceContext()),
      window_(window) {
  window->GetWindowRenderTarget()->SetAsTarget();
  window->GetWindowRenderTarget()
      ->GetWinNativeFactory()
      ->GetD2D1DeviceContext()
      ->BeginDraw();
}

WindowPainter::~WindowPainter() { End(); }

void WindowPainter::DoEndDraw() {
  ThrowIfFailed(window_->GetWindowRenderTarget()
                    ->GetWinNativeFactory()
                    ->GetD2D1DeviceContext()
                    ->EndDraw());
  window_->GetWindowRenderTarget()->Present();
}
}  // namespace cru::win::native