minor
This commit is contained in:
parent
9bc195781d
commit
33f78bb5d5
|
|
@ -39,10 +39,12 @@ namespace kiwano
|
||||||
|
|
||||||
Actor::Actor()
|
Actor::Actor()
|
||||||
: visible_(true)
|
: visible_(true)
|
||||||
|
, visible_in_rt_(true)
|
||||||
, update_pausing_(false)
|
, update_pausing_(false)
|
||||||
, hover_(false)
|
, hover_(false)
|
||||||
, pressed_(false)
|
, pressed_(false)
|
||||||
, responsible_(false)
|
, responsible_(false)
|
||||||
|
, dirty_visibility_(true)
|
||||||
, dirty_transform_(false)
|
, dirty_transform_(false)
|
||||||
, dirty_transform_inverse_(false)
|
, dirty_transform_inverse_(false)
|
||||||
, cascade_opacity_(false)
|
, cascade_opacity_(false)
|
||||||
|
|
@ -139,6 +141,16 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Actor::CheckVisibilty(RenderTarget* rt) const
|
||||||
|
{
|
||||||
|
if (dirty_visibility_)
|
||||||
|
{
|
||||||
|
dirty_visibility_ = false;
|
||||||
|
visible_in_rt_ = rt->CheckVisibility(GetBounds(), GetTransformMatrix());
|
||||||
|
}
|
||||||
|
return visible_in_rt_;
|
||||||
|
}
|
||||||
|
|
||||||
void Actor::Dispatch(Event& evt)
|
void Actor::Dispatch(Event& evt)
|
||||||
{
|
{
|
||||||
if (!visible_)
|
if (!visible_)
|
||||||
|
|
@ -224,6 +236,7 @@ namespace kiwano
|
||||||
|
|
||||||
dirty_transform_ = false;
|
dirty_transform_ = false;
|
||||||
dirty_transform_inverse_ = true;
|
dirty_transform_inverse_ = true;
|
||||||
|
dirty_visibility_ = true;
|
||||||
|
|
||||||
if (is_fast_transform_)
|
if (is_fast_transform_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -390,6 +390,8 @@ namespace kiwano
|
||||||
|
|
||||||
virtual void RenderBorder(RenderTarget* rt);
|
virtual void RenderBorder(RenderTarget* rt);
|
||||||
|
|
||||||
|
virtual bool CheckVisibilty(RenderTarget* rt) const;
|
||||||
|
|
||||||
void UpdateTransform() const;
|
void UpdateTransform() const;
|
||||||
|
|
||||||
void UpdateOpacity();
|
void UpdateOpacity();
|
||||||
|
|
@ -400,12 +402,12 @@ namespace kiwano
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool visible_;
|
bool visible_;
|
||||||
bool hover_;
|
|
||||||
bool pressed_;
|
|
||||||
bool responsible_;
|
|
||||||
bool update_pausing_;
|
bool update_pausing_;
|
||||||
bool cascade_opacity_;
|
bool cascade_opacity_;
|
||||||
bool show_border_;
|
bool show_border_;
|
||||||
|
bool hover_;
|
||||||
|
bool pressed_;
|
||||||
|
bool responsible_;
|
||||||
Int32 z_order_;
|
Int32 z_order_;
|
||||||
Float32 opacity_;
|
Float32 opacity_;
|
||||||
Float32 displayed_opacity_;
|
Float32 displayed_opacity_;
|
||||||
|
|
@ -419,6 +421,8 @@ namespace kiwano
|
||||||
Transform transform_;
|
Transform transform_;
|
||||||
|
|
||||||
bool is_fast_transform_;
|
bool is_fast_transform_;
|
||||||
|
mutable bool visible_in_rt_;
|
||||||
|
mutable bool dirty_visibility_;
|
||||||
mutable bool dirty_transform_;
|
mutable bool dirty_transform_;
|
||||||
mutable bool dirty_transform_inverse_;
|
mutable bool dirty_transform_inverse_;
|
||||||
mutable Matrix3x2 transform_matrix_;
|
mutable Matrix3x2 transform_matrix_;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ namespace kiwano
|
||||||
|
|
||||||
void GifSprite::OnRender(RenderTarget* rt)
|
void GifSprite::OnRender(RenderTarget* rt)
|
||||||
{
|
{
|
||||||
if (frame_.raw.IsValid() && rt->CheckVisibility(GetBounds(), GetTransformMatrix()))
|
if (frame_.raw.IsValid() && CheckVisibilty(rt))
|
||||||
{
|
{
|
||||||
PrepareRender(rt);
|
PrepareRender(rt);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ namespace kiwano
|
||||||
geo_ = geometry;
|
geo_ = geometry;
|
||||||
if (geo_)
|
if (geo_)
|
||||||
{
|
{
|
||||||
bounds_ = geo_.GetBoundingBox(Matrix3x2());
|
bounds_ = geo_.GetBoundingBox();
|
||||||
SetSize(bounds_.GetSize());
|
SetSize(bounds_.GetSize());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -97,21 +97,21 @@ namespace kiwano
|
||||||
|
|
||||||
void ShapeActor::OnRender(RenderTarget* rt)
|
void ShapeActor::OnRender(RenderTarget* rt)
|
||||||
{
|
{
|
||||||
if (geo_ && rt->CheckVisibility(GetBounds(), GetTransformMatrix()))
|
if (geo_ && CheckVisibilty(rt))
|
||||||
{
|
{
|
||||||
PrepareRender(rt);
|
PrepareRender(rt);
|
||||||
|
|
||||||
rt->FillGeometry(
|
|
||||||
geo_,
|
|
||||||
fill_color_
|
|
||||||
);
|
|
||||||
|
|
||||||
rt->DrawGeometry(
|
rt->DrawGeometry(
|
||||||
geo_,
|
geo_,
|
||||||
stroke_color_,
|
stroke_color_,
|
||||||
stroke_width_,
|
stroke_width_ * 2, // twice width for widening
|
||||||
stroke_style_
|
stroke_style_
|
||||||
);
|
);
|
||||||
|
|
||||||
|
rt->FillGeometry(
|
||||||
|
geo_,
|
||||||
|
fill_color_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace kiwano
|
||||||
|
|
||||||
void Sprite::OnRender(RenderTarget* rt)
|
void Sprite::OnRender(RenderTarget* rt)
|
||||||
{
|
{
|
||||||
if (frame_ && rt->CheckVisibility(GetBounds(), GetTransformMatrix()))
|
if (frame_ && CheckVisibilty(rt))
|
||||||
{
|
{
|
||||||
PrepareRender(rt);
|
PrepareRender(rt);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
|
|
||||||
if (text_layout_ && rt->CheckVisibility(GetBounds(), GetTransformMatrix()))
|
if (text_layout_ && CheckVisibilty(rt))
|
||||||
{
|
{
|
||||||
PrepareRender(rt);
|
PrepareRender(rt);
|
||||||
rt->DrawTextLayout(text_layout_);
|
rt->DrawTextLayout(text_layout_);
|
||||||
|
|
|
||||||
|
|
@ -48,29 +48,16 @@ namespace kiwano
|
||||||
StrokeStyle outline_stroke; // ĂčąßĎßĎཝŃůĘ˝
|
StrokeStyle outline_stroke; // ĂčąßĎßĎཝŃůĘ˝
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextStyle()
|
|
||||||
: color(Color::White)
|
|
||||||
, alignment(TextAlign::Left)
|
|
||||||
, wrap_width(0.f)
|
|
||||||
, line_spacing(0.f)
|
|
||||||
, underline(false)
|
|
||||||
, strikethrough(false)
|
|
||||||
, outline(true)
|
|
||||||
, outline_color(Color(Color::Black, 0.5))
|
|
||||||
, outline_width(1.f)
|
|
||||||
, outline_stroke(StrokeStyle::Round)
|
|
||||||
{}
|
|
||||||
|
|
||||||
TextStyle(
|
TextStyle(
|
||||||
Color color,
|
Color color = Color::White,
|
||||||
TextAlign alignment = TextAlign::Left,
|
TextAlign alignment = TextAlign::Left,
|
||||||
Float32 wrap_width = 0.f,
|
Float32 wrap_width = 0.f,
|
||||||
Float32 line_spacing = 0.f,
|
Float32 line_spacing = 0.f,
|
||||||
bool underline = false,
|
bool underline = false,
|
||||||
bool strikethrough = false,
|
bool strikethrough = false,
|
||||||
bool outline = true,
|
bool outline = false,
|
||||||
Color outline_color = Color(Color::Black, 0.5),
|
Color outline_color = Color(Color::Black, 0.5),
|
||||||
Float32 outline_width = 1.f,
|
Float32 outline_width = 1.f,
|
||||||
StrokeStyle outline_stroke = StrokeStyle::Round
|
StrokeStyle outline_stroke = StrokeStyle::Round
|
||||||
)
|
)
|
||||||
: color(color)
|
: color(color)
|
||||||
|
|
|
||||||
|
|
@ -78,9 +78,9 @@ public:
|
||||||
|
|
||||||
inline pointer_type get() const noexcept { return ptr_; }
|
inline pointer_type get() const noexcept { return ptr_; }
|
||||||
|
|
||||||
inline void reset() noexcept
|
inline void reset(pointer_type ptr = nullptr) noexcept
|
||||||
{
|
{
|
||||||
intrusive_ptr{}.swap(*this);
|
intrusive_ptr{ ptr }.swap(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void swap(intrusive_ptr& other) noexcept
|
inline void swap(intrusive_ptr& other) noexcept
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,9 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning (push)
|
||||||
|
#pragma warning (disable: 26495) // ignore warning "always initialize member variables"
|
||||||
|
|
||||||
template <typename _MTy>
|
template <typename _MTy>
|
||||||
Matrix3x2T(_MTy const& other)
|
Matrix3x2T(_MTy const& other)
|
||||||
{
|
{
|
||||||
|
|
@ -85,6 +88,8 @@ namespace kiwano
|
||||||
m[i] = other[i];
|
m[i] = other[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning (pop)
|
||||||
|
|
||||||
inline value_type operator [](UInt32 index) const
|
inline value_type operator [](UInt32 index) const
|
||||||
{
|
{
|
||||||
return m[index];
|
return m[index];
|
||||||
|
|
|
||||||
|
|
@ -43,15 +43,26 @@ namespace kiwano
|
||||||
return geo_ != nullptr;
|
return geo_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect Geometry::GetBoundingBox() const
|
||||||
|
{
|
||||||
|
Rect bounds;
|
||||||
|
if (geo_)
|
||||||
|
{
|
||||||
|
// no matter it failed or not
|
||||||
|
geo_->GetBounds(nullptr, DX::ConvertToRectF(&bounds));
|
||||||
|
}
|
||||||
|
return bounds;
|
||||||
|
}
|
||||||
|
|
||||||
Rect Geometry::GetBoundingBox(Matrix3x2 const& transform) const
|
Rect Geometry::GetBoundingBox(Matrix3x2 const& transform) const
|
||||||
{
|
{
|
||||||
if (!geo_)
|
Rect bounds;
|
||||||
return Rect{};
|
if (geo_)
|
||||||
|
{
|
||||||
Rect rect;
|
// no matter it failed or not
|
||||||
// no matter it failed or not
|
geo_->GetBounds(DX::ConvertToMatrix3x2F(transform), DX::ConvertToRectF(&bounds));
|
||||||
geo_->GetBounds(DX::ConvertToMatrix3x2F(transform), DX::ConvertToRectF(&rect));
|
}
|
||||||
return rect;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Float32 Geometry::GetLength() const
|
Float32 Geometry::GetLength() const
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,12 @@ namespace kiwano
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
// 삿혤棍학관鍋분
|
||||||
|
Rect GetBoundingBox() const;
|
||||||
|
|
||||||
// 삿혤棍학관鍋분
|
// 삿혤棍학관鍋분
|
||||||
Rect GetBoundingBox(
|
Rect GetBoundingBox(
|
||||||
Matrix3x2 const& transform = Matrix3x2()
|
Matrix3x2 const& transform
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// 털뙤暠近角뤠관벵듐
|
// 털뙤暠近角뤠관벵듐
|
||||||
|
|
|
||||||
|
|
@ -391,12 +391,12 @@ namespace kiwano
|
||||||
layout.GetTextStyle().outline_width,
|
layout.GetTextStyle().outline_width,
|
||||||
GetStrokeStyle(layout.GetTextStyle().outline_stroke).get()
|
GetStrokeStyle(layout.GetTextStyle().outline_stroke).get()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
hr = layout.GetTextLayout()->Draw(nullptr, text_renderer_.get(), offset.x, offset.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = layout.GetTextLayout()->Draw(nullptr, text_renderer_.get(), offset.x, offset.y);
|
|
||||||
|
|
||||||
IncreasePrimitivesCount();
|
IncreasePrimitivesCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,8 @@ namespace kiwano
|
||||||
Int32 primitives;
|
Int32 primitives;
|
||||||
Time start;
|
Time start;
|
||||||
Duration duration;
|
Duration duration;
|
||||||
|
|
||||||
|
Status() : primitives(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetCollectingStatus(bool collecting);
|
void SetCollectingStatus(bool collecting);
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ namespace kiwano
|
||||||
sFillColor_ = fillColor;
|
sFillColor_ = fillColor;
|
||||||
bShowOutline_ = outline;
|
bShowOutline_ = outline;
|
||||||
sOutlineColor_ = outlineColor;
|
sOutlineColor_ = outlineColor;
|
||||||
fOutlineWidth = 2 * outlineWidth;
|
fOutlineWidth = outlineWidth;
|
||||||
pCurrStrokeStyle_ = outlineJoin;
|
pCurrStrokeStyle_ = outlineJoin;
|
||||||
|
|
||||||
if (pBrush_) pBrush_->SetOpacity(opacity);
|
if (pBrush_) pBrush_->SetOpacity(opacity);
|
||||||
|
|
@ -220,80 +220,87 @@ namespace kiwano
|
||||||
|
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
ID2D1PathGeometry* pPathGeometry = NULL;
|
if (bShowOutline_)
|
||||||
hr = pFactory_->CreatePathGeometry(
|
|
||||||
&pPathGeometry
|
|
||||||
);
|
|
||||||
|
|
||||||
ID2D1GeometrySink* pSink = NULL;
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
{
|
||||||
hr = pPathGeometry->Open(
|
ID2D1GeometrySink* pSink = NULL;
|
||||||
&pSink
|
ID2D1PathGeometry* pPathGeometry = NULL;
|
||||||
|
ID2D1TransformedGeometry* pTransformedGeometry = NULL;
|
||||||
|
|
||||||
|
hr = pFactory_->CreatePathGeometry(
|
||||||
|
&pPathGeometry
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = glyphRun->fontFace->GetGlyphRunOutline(
|
hr = pPathGeometry->Open(
|
||||||
glyphRun->fontEmSize,
|
&pSink
|
||||||
glyphRun->glyphIndices,
|
);
|
||||||
glyphRun->glyphAdvances,
|
|
||||||
glyphRun->glyphOffsets,
|
|
||||||
glyphRun->glyphCount,
|
|
||||||
glyphRun->isSideways,
|
|
||||||
glyphRun->bidiLevel % 2,
|
|
||||||
pSink
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
hr = pSink->Close();
|
hr = glyphRun->fontFace->GetGlyphRunOutline(
|
||||||
}
|
glyphRun->fontEmSize,
|
||||||
|
glyphRun->glyphIndices,
|
||||||
|
glyphRun->glyphAdvances,
|
||||||
|
glyphRun->glyphOffsets,
|
||||||
|
glyphRun->glyphCount,
|
||||||
|
glyphRun->isSideways,
|
||||||
|
glyphRun->bidiLevel % 2,
|
||||||
|
pSink
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
D2D1::Matrix3x2F const matrix = D2D1::Matrix3x2F(
|
if (SUCCEEDED(hr))
|
||||||
1.0f, 0.0f,
|
{
|
||||||
0.0f, 1.0f,
|
hr = pSink->Close();
|
||||||
baselineOriginX, baselineOriginY
|
}
|
||||||
);
|
|
||||||
|
|
||||||
ID2D1TransformedGeometry* pTransformedGeometry = NULL;
|
if (SUCCEEDED(hr))
|
||||||
if (SUCCEEDED(hr))
|
{
|
||||||
{
|
D2D1::Matrix3x2F const matrix = D2D1::Matrix3x2F(
|
||||||
hr = pFactory_->CreateTransformedGeometry(
|
1.0f, 0.0f,
|
||||||
pPathGeometry,
|
0.0f, 1.0f,
|
||||||
&matrix,
|
baselineOriginX, baselineOriginY
|
||||||
&pTransformedGeometry
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr) && bShowOutline_)
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
pBrush_->SetColor(sOutlineColor_);
|
hr = pFactory_->CreateTransformedGeometry(
|
||||||
|
pPathGeometry,
|
||||||
|
&matrix,
|
||||||
|
&pTransformedGeometry
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pRT_->DrawGeometry(
|
if (SUCCEEDED(hr))
|
||||||
pTransformedGeometry,
|
{
|
||||||
pBrush_,
|
pBrush_->SetColor(sOutlineColor_);
|
||||||
fOutlineWidth,
|
|
||||||
pCurrStrokeStyle_
|
pRT_->DrawGeometry(
|
||||||
);
|
pTransformedGeometry,
|
||||||
|
pBrush_,
|
||||||
|
fOutlineWidth * 2, // twice width for widening
|
||||||
|
pCurrStrokeStyle_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DX::SafeRelease(pPathGeometry);
|
||||||
|
DX::SafeRelease(pSink);
|
||||||
|
DX::SafeRelease(pTransformedGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
pBrush_->SetColor(sFillColor_);
|
pBrush_->SetColor(sFillColor_);
|
||||||
|
|
||||||
pRT_->FillGeometry(
|
pRT_->DrawGlyphRun(
|
||||||
pTransformedGeometry,
|
D2D1::Point2F(baselineOriginX, baselineOriginY),
|
||||||
|
glyphRun,
|
||||||
pBrush_
|
pBrush_
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
DX::SafeRelease(pPathGeometry);
|
|
||||||
DX::SafeRelease(pSink);
|
|
||||||
DX::SafeRelease(pTransformedGeometry);
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue