minor
This commit is contained in:
parent
46f9dae888
commit
9bc195781d
|
|
@ -19,6 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../base/ObjectBase.h"
|
||||
#include "../renderer/Texture.h"
|
||||
|
||||
namespace kiwano
|
||||
|
|
|
|||
|
|
@ -123,18 +123,23 @@ namespace kiwano
|
|||
{
|
||||
}
|
||||
|
||||
LineActor::LineActor(Point const& point)
|
||||
LineActor::LineActor(Point const& begin, Point const& end)
|
||||
{
|
||||
SetPoint(point);
|
||||
SetLine(begin, end);
|
||||
}
|
||||
|
||||
LineActor::~LineActor()
|
||||
{
|
||||
}
|
||||
|
||||
void LineActor::SetPoint(Point const& point)
|
||||
void LineActor::SetLine(Point const& begin, Point const& end)
|
||||
{
|
||||
SetGeometry(Geometry::CreateLine(Point{}, point));
|
||||
if (begin_ != begin || end_ != end)
|
||||
{
|
||||
begin_ = begin;
|
||||
end_ = end;
|
||||
SetGeometry(Geometry::CreateLine(begin, end));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -157,7 +162,11 @@ namespace kiwano
|
|||
|
||||
void RectActor::SetRectSize(Size const& size)
|
||||
{
|
||||
SetGeometry(Geometry::CreateRect(Rect{ Point{}, size }));
|
||||
if (size != rect_size_)
|
||||
{
|
||||
rect_size_ = size;
|
||||
SetGeometry(Geometry::CreateRect(Rect{ Point{}, size }));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -190,7 +199,12 @@ namespace kiwano
|
|||
|
||||
void RoundRectActor::SetRoundedRect(Size const& size, Vec2 const& radius)
|
||||
{
|
||||
SetGeometry(Geometry::CreateRoundedRect(Rect{ Point{}, size }, radius));
|
||||
if (rect_size_ != size || radius_ != radius)
|
||||
{
|
||||
rect_size_ = size;
|
||||
radius_ = radius;
|
||||
SetGeometry(Geometry::CreateRoundedRect(Rect{ Point{}, size }, radius));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -214,7 +228,11 @@ namespace kiwano
|
|||
|
||||
void CircleActor::SetRadius(Float32 radius)
|
||||
{
|
||||
SetGeometry(Geometry::CreateCircle(Point{ radius, radius }, radius));
|
||||
if (radius_ != radius)
|
||||
{
|
||||
radius_ = radius;
|
||||
SetGeometry(Geometry::CreateCircle(Point{ radius, radius }, radius));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -237,7 +255,11 @@ namespace kiwano
|
|||
|
||||
void EllipseActor::SetRadius(Vec2 const& radius)
|
||||
{
|
||||
SetGeometry(Geometry::CreateEllipse(radius, radius));
|
||||
if (radius_ != radius)
|
||||
{
|
||||
radius_ = radius;
|
||||
SetGeometry(Geometry::CreateEllipse(radius, radius));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -97,19 +97,34 @@ namespace kiwano
|
|||
LineActor();
|
||||
|
||||
LineActor(
|
||||
Point const& point
|
||||
Point const& begin,
|
||||
Point const& end
|
||||
);
|
||||
|
||||
virtual ~LineActor();
|
||||
|
||||
Point const& GetPoint() const { return point_; }
|
||||
inline Point const& GetBeginPoint() const { return begin_; }
|
||||
|
||||
inline Point const& GetEndPoint() const { return end_; }
|
||||
|
||||
void SetPoint(
|
||||
Point const& point
|
||||
inline void SetBeginPoint(Point const& begin)
|
||||
{
|
||||
SetLine(begin, end_);
|
||||
}
|
||||
|
||||
inline void SetEndPoint(Point const& end)
|
||||
{
|
||||
SetLine(begin_, end);
|
||||
}
|
||||
|
||||
void SetLine(
|
||||
Point const& begin,
|
||||
Point const& end
|
||||
);
|
||||
|
||||
protected:
|
||||
Point point_;
|
||||
Point begin_;
|
||||
Point end_;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -126,10 +141,10 @@ namespace kiwano
|
|||
|
||||
virtual ~RectActor();
|
||||
|
||||
void SetRectSize(Size const& size);
|
||||
|
||||
inline Size const& GetRectSize() const { return rect_size_; }
|
||||
|
||||
void SetRectSize(Size const& size);
|
||||
|
||||
protected:
|
||||
Size rect_size_;
|
||||
};
|
||||
|
|
@ -149,6 +164,10 @@ namespace kiwano
|
|||
|
||||
virtual ~RoundRectActor();
|
||||
|
||||
inline Vec2 GetRadius() const { return radius_; }
|
||||
|
||||
inline Size GetRectSize() const { return size_; }
|
||||
|
||||
void SetRadius(
|
||||
Vec2 const& radius
|
||||
);
|
||||
|
|
@ -162,10 +181,6 @@ namespace kiwano
|
|||
Vec2 const& radius
|
||||
);
|
||||
|
||||
inline Vec2 GetRadius() const { return radius_; }
|
||||
|
||||
inline Size GetRectSize() const { return size_; }
|
||||
|
||||
protected:
|
||||
Size rect_size_;
|
||||
Vec2 radius_;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Texture.h"
|
||||
#include "../base/time.h"
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
|
|||
|
|
@ -190,16 +190,16 @@ namespace kiwano
|
|||
imaging_factory_.reset();
|
||||
dwrite_factory_.reset();
|
||||
|
||||
d2d_miter_stroke_style_.reset();
|
||||
d2d_bevel_stroke_style_.reset();
|
||||
d2d_round_stroke_style_.reset();
|
||||
miter_stroke_style_.reset();
|
||||
bevel_stroke_style_.reset();
|
||||
round_stroke_style_.reset();
|
||||
}
|
||||
|
||||
HRESULT D2DDeviceResources::CreateDeviceIndependentResources()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
ComPtr<ID2D1Factory1> d2d_factory;
|
||||
ComPtr<ID2D1Factory1> factory;
|
||||
ComPtr<IWICImagingFactory> imaging_factory;
|
||||
ComPtr<IDWriteFactory> dwrite_factory;
|
||||
|
||||
|
|
@ -213,12 +213,12 @@ namespace kiwano
|
|||
D2D1_FACTORY_TYPE_SINGLE_THREADED,
|
||||
__uuidof(ID2D1Factory1),
|
||||
&config,
|
||||
reinterpret_cast<void**>(&d2d_factory)
|
||||
reinterpret_cast<void**>(&factory)
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
factory_ = d2d_factory;
|
||||
factory_ = factory;
|
||||
|
||||
hr = CoCreateInstance(
|
||||
CLSID_WICImagingFactory,
|
||||
|
|
@ -244,9 +244,9 @@ namespace kiwano
|
|||
{
|
||||
dwrite_factory_ = dwrite_factory;
|
||||
|
||||
ComPtr<ID2D1StrokeStyle> d2d_miter_stroke_style;
|
||||
ComPtr<ID2D1StrokeStyle> d2d_bevel_stroke_style;
|
||||
ComPtr<ID2D1StrokeStyle> d2d_round_stroke_style;
|
||||
ComPtr<ID2D1StrokeStyle> miter_stroke_style;
|
||||
ComPtr<ID2D1StrokeStyle> bevel_stroke_style;
|
||||
ComPtr<ID2D1StrokeStyle> round_stroke_style;
|
||||
|
||||
D2D1_STROKE_STYLE_PROPERTIES stroke_style = D2D1::StrokeStyleProperties(
|
||||
D2D1_CAP_STYLE_FLAT,
|
||||
|
|
@ -262,7 +262,7 @@ namespace kiwano
|
|||
stroke_style,
|
||||
nullptr,
|
||||
0,
|
||||
&d2d_miter_stroke_style
|
||||
&miter_stroke_style
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
|
|
@ -272,7 +272,7 @@ namespace kiwano
|
|||
stroke_style,
|
||||
nullptr,
|
||||
0,
|
||||
&d2d_bevel_stroke_style
|
||||
&bevel_stroke_style
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -283,15 +283,15 @@ namespace kiwano
|
|||
stroke_style,
|
||||
nullptr,
|
||||
0,
|
||||
&d2d_round_stroke_style
|
||||
&round_stroke_style
|
||||
);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
d2d_miter_stroke_style_ = d2d_miter_stroke_style;
|
||||
d2d_bevel_stroke_style_ = d2d_bevel_stroke_style;
|
||||
d2d_round_stroke_style_ = d2d_round_stroke_style;
|
||||
miter_stroke_style_ = miter_stroke_style;
|
||||
bevel_stroke_style_ = bevel_stroke_style;
|
||||
round_stroke_style_ = round_stroke_style;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -300,17 +300,17 @@ namespace kiwano
|
|||
|
||||
HRESULT D2DDeviceResources::SetD2DDevice(_In_ ComPtr<ID2D1Device> const& device)
|
||||
{
|
||||
ComPtr<ID2D1DeviceContext> d2d_device_ctx;
|
||||
ComPtr<ID2D1DeviceContext> device_ctx;
|
||||
|
||||
HRESULT hr = device->CreateDeviceContext(
|
||||
D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
|
||||
&d2d_device_ctx
|
||||
&device_ctx
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
device_ = device;
|
||||
device_context_ = d2d_device_ctx;
|
||||
device_context_ = device_ctx;
|
||||
device_context_->SetDpi(dpi_, dpi_);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include "../Color.h"
|
||||
#include "../../math/math.h"
|
||||
#include "../../base/Resource.h"
|
||||
#include "../../2d/TextStyle.hpp"
|
||||
#include <dwrite.h>
|
||||
#include <d2d1.h>
|
||||
#include <d2d1_1.h>
|
||||
|
|
@ -243,9 +242,9 @@ namespace kiwano
|
|||
inline ID2D1DeviceContext* GetDeviceContext() const { KGE_ASSERT(device_context_); return device_context_.get(); }
|
||||
inline ID2D1Bitmap1* GetTargetBitmap() const { KGE_ASSERT(target_bitmap_); return target_bitmap_.get(); }
|
||||
|
||||
inline ID2D1StrokeStyle* GetMiterStrokeStyle() const { KGE_ASSERT(d2d_miter_stroke_style_); return d2d_miter_stroke_style_.get(); }
|
||||
inline ID2D1StrokeStyle* GetBevelStrokeStyle() const { KGE_ASSERT(d2d_bevel_stroke_style_); return d2d_bevel_stroke_style_.get(); }
|
||||
inline ID2D1StrokeStyle* GetRoundStrokeStyle() const { KGE_ASSERT(d2d_round_stroke_style_); return d2d_round_stroke_style_.get(); }
|
||||
inline ID2D1StrokeStyle* GetMiterStrokeStyle() const { KGE_ASSERT(miter_stroke_style_); return miter_stroke_style_.get(); }
|
||||
inline ID2D1StrokeStyle* GetBevelStrokeStyle() const { KGE_ASSERT(bevel_stroke_style_); return bevel_stroke_style_.get(); }
|
||||
inline ID2D1StrokeStyle* GetRoundStrokeStyle() const { KGE_ASSERT(round_stroke_style_); return round_stroke_style_.get(); }
|
||||
|
||||
protected:
|
||||
ComPtr<ID2D1Factory1> factory_;
|
||||
|
|
@ -256,9 +255,9 @@ namespace kiwano
|
|||
ComPtr<IWICImagingFactory> imaging_factory_;
|
||||
ComPtr<IDWriteFactory> dwrite_factory_;
|
||||
|
||||
ComPtr<ID2D1StrokeStyle> d2d_miter_stroke_style_;
|
||||
ComPtr<ID2D1StrokeStyle> d2d_bevel_stroke_style_;
|
||||
ComPtr<ID2D1StrokeStyle> d2d_round_stroke_style_;
|
||||
ComPtr<ID2D1StrokeStyle> miter_stroke_style_;
|
||||
ComPtr<ID2D1StrokeStyle> bevel_stroke_style_;
|
||||
ComPtr<ID2D1StrokeStyle> round_stroke_style_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue