From 3e89aa733587043645f5fda72596e4ff3cd21d2a Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 1 Apr 2019 15:28:07 +0800 Subject: ... --- src/graph/graph_util.hpp | 63 ------------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 src/graph/graph_util.hpp (limited to 'src/graph/graph_util.hpp') diff --git a/src/graph/graph_util.hpp b/src/graph/graph_util.hpp deleted file mode 100644 index 2d5be5f3..00000000 --- a/src/graph/graph_util.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once -#include "pre.hpp" - -#include -#include - -#include "exception.hpp" -#include "graph_manager.hpp" - -namespace cru::graph { -struct Dpi { - float x; - float y; -}; - -inline Dpi GetDpi() { - Dpi dpi; - GraphManager::GetInstance()->GetD2D1Factory()->GetDesktopDpi(&dpi.x, &dpi.y); - return dpi; -} - -inline int DipToPixelInternal(const float dip, const float dpi) { - return static_cast(dip * dpi / 96.0f); -} - -inline int DipToPixelX(const float dip_x) { - return DipToPixelInternal(dip_x, GetDpi().x); -} - -inline int DipToPixelY(const float dip_y) { - return DipToPixelInternal(dip_y, GetDpi().y); -} - -inline float DipToPixelInternal(const int pixel, const float dpi) { - return static_cast(pixel) * 96.0f / dpi; -} - -inline float PixelToDipX(const int pixel_x) { - return DipToPixelInternal(pixel_x, GetDpi().x); -} - -inline float PixelToDipY(const int pixel_y) { - return DipToPixelInternal(pixel_y, GetDpi().y); -} - -inline void WithTransform( - ID2D1RenderTarget* render_target, const D2D1_MATRIX_3X2_F matrix, - const std::function& action) { - D2D1_MATRIX_3X2_F old_transform; - render_target->GetTransform(&old_transform); - render_target->SetTransform(old_transform * matrix); - action(render_target); - render_target->SetTransform(old_transform); -} - -inline ID2D1SolidColorBrush* CreateSolidColorBrush(const D2D1_COLOR_F& color) { - ID2D1SolidColorBrush* brush; - ThrowIfFailed(GraphManager::GetInstance() - ->GetD2D1DeviceContext() - ->CreateSolidColorBrush(color, &brush)); - return brush; -} -} // namespace cru::graph -- cgit v1.2.3