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