22#include <kiwano/math/Math.h>
23#include <kiwano/utils/Logger.h>
24#include <kiwano/render/Color.h>
25#include <kiwano/platform/win32/ComPtr.hpp>
35inline void SafeRelease(T*& ptr)
45inline T* SafeAcquire(T* ptr)
58inline const D2D1_POINT_2F& ConvertToPoint2F(
const Vec2& vec2)
60 return reinterpret_cast<const D2D1_POINT_2F&
>(vec2);
63inline D2D1_POINT_2F& ConvertToPoint2F(Vec2& vec2)
65 return reinterpret_cast<D2D1_POINT_2F&
>(vec2);
68inline const D2D1_POINT_2F* ConvertToPoint2F(
const Vec2* vec2)
70 return reinterpret_cast<const D2D1_POINT_2F*
>(vec2);
73inline D2D1_POINT_2F* ConvertToPoint2F(Vec2* vec2)
75 return reinterpret_cast<D2D1_POINT_2F*
>(vec2);
82inline const D2D1_SIZE_F& ConvertToSizeF(
const Vec2& vec2)
84 return reinterpret_cast<const D2D1_SIZE_F&
>(vec2);
87inline D2D1_SIZE_F& ConvertToSizeF(Vec2& vec2)
89 return reinterpret_cast<D2D1_SIZE_F&
>(vec2);
92inline const D2D1_SIZE_F* ConvertToSizeF(
const Vec2* vec2)
94 return reinterpret_cast<const D2D1_SIZE_F*
>(vec2);
97inline D2D1_SIZE_F* ConvertToSizeF(Vec2* vec2)
99 return reinterpret_cast<D2D1_SIZE_F*
>(vec2);
102inline const D2D1_SIZE_U& ConvertToSizeU(
const math::Vec2T<uint32_t>& vec2)
104 return reinterpret_cast<const D2D1_SIZE_U&
>(vec2);
107inline D2D1_SIZE_U& ConvertToSizeU(math::Vec2T<uint32_t>& vec2)
109 return reinterpret_cast<D2D1_SIZE_U&
>(vec2);
112inline const D2D1_SIZE_U* ConvertToSizeU(
const math::Vec2T<uint32_t>* vec2)
114 return reinterpret_cast<const D2D1_SIZE_U*
>(vec2);
117inline D2D1_SIZE_U* ConvertToSizeU(math::Vec2T<uint32_t>* vec2)
119 return reinterpret_cast<D2D1_SIZE_U*
>(vec2);
126inline const D2D1_RECT_F& ConvertToRectF(
const Rect& rect)
128 return reinterpret_cast<const D2D1_RECT_F&
>(rect);
131inline D2D1_RECT_F& ConvertToRectF(Rect& rect)
133 return reinterpret_cast<D2D1_RECT_F&
>(rect);
136inline const D2D1_RECT_F* ConvertToRectF(
const Rect* rect)
138 return reinterpret_cast<const D2D1_RECT_F*
>(rect);
141inline D2D1_RECT_F* ConvertToRectF(Rect* rect)
143 return reinterpret_cast<D2D1_RECT_F*
>(rect);
149inline const D2D1_COLOR_F& ConvertToColorF(
const Color& color)
151 return reinterpret_cast<const D2D1_COLOR_F&
>(color);
154inline D2D1_COLOR_F& ConvertToColorF(Color& color)
156 return reinterpret_cast<D2D1_COLOR_F&
>(color);
159inline const D2D1_COLOR_F* ConvertToColorF(
const Color* color)
161 return reinterpret_cast<const D2D1_COLOR_F*
>(color);
164inline D2D1_COLOR_F* ConvertToColorF(Color* color)
166 return reinterpret_cast<D2D1_COLOR_F*
>(color);
173inline const D2D1_MATRIX_3X2_F& ConvertToMatrix3x2F(
const Matrix3x2& matrix)
175 return reinterpret_cast<const D2D1_MATRIX_3X2_F&
>(matrix);
178inline D2D1_MATRIX_3X2_F& ConvertToMatrix3x2F(Matrix3x2& matrix)
180 return reinterpret_cast<D2D1_MATRIX_3X2_F&
>(matrix);
183inline const D2D1_MATRIX_3X2_F* ConvertToMatrix3x2F(
const Matrix3x2* matrix)
185 return reinterpret_cast<const D2D1_MATRIX_3X2_F*
>(matrix);
188inline D2D1_MATRIX_3X2_F* ConvertToMatrix3x2F(Matrix3x2* matrix)
190 return reinterpret_cast<D2D1_MATRIX_3X2_F*
>(matrix);
194inline float ConvertDipsToPixels(
float dips,
float dpi)
196 static const float dips_per_inch = 96.0f;
197 return math::Floor(dips * dpi / dips_per_inch + 0.5f);