some optimization
This commit is contained in:
parent
be3a8602c5
commit
22d0fd4e2a
|
|
@ -60,11 +60,12 @@ namespace kiwano
|
||||||
|
|
||||||
void DebugNode::OnRender()
|
void DebugNode::OnRender()
|
||||||
{
|
{
|
||||||
Renderer::Instance()->GetSolidColorBrush()->SetColor(DX::ConvertToColorF(background_color_));
|
auto renderer = Renderer::Instance();
|
||||||
|
|
||||||
Renderer::Instance()->GetD2DDeviceResources()->GetDeviceContext()->FillRoundedRectangle(
|
renderer->GetSolidColorBrush()->SetColor(DX::ConvertToColorF(background_color_));
|
||||||
|
renderer->GetD2DDeviceResources()->GetDeviceContext()->FillRoundedRectangle(
|
||||||
D2D1::RoundedRect(DX::ConvertToRectF(GetBounds()), 5.f, 5.f),
|
D2D1::RoundedRect(DX::ConvertToRectF(GetBounds()), 5.f, 5.f),
|
||||||
Renderer::Instance()->GetSolidColorBrush()
|
renderer->GetSolidColorBrush()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,10 +123,12 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
if (show_border_)
|
if (show_border_)
|
||||||
{
|
{
|
||||||
Rect bounds = GetBounds();
|
Rect bounds = GetBounds();
|
||||||
Renderer::Instance()->SetTransform(transform_matrix_);
|
|
||||||
Renderer::Instance()->FillRectangle(bounds, Color(Color::Red, .4f));
|
auto renderer = Renderer::Instance();
|
||||||
Renderer::Instance()->DrawRectangle(bounds, Color(Color::Red, .8f), 4.f);
|
renderer->SetTransform(transform_matrix_);
|
||||||
|
renderer->FillRectangle(bounds, Color(Color::Red, .4f));
|
||||||
|
renderer->DrawRectangle(bounds, Color(Color::Red, .8f), 4.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto child = children_.First(); child; child = child->NextItem())
|
for (auto child = children_.First(); child; child = child->NextItem())
|
||||||
|
|
@ -228,10 +230,12 @@ namespace kiwano
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// matrix multiplication is optimized by expression template
|
// matrix multiplication is optimized by expression template
|
||||||
transform_matrix_ = Matrix::Scaling(transform_.scale)
|
transform_matrix_ = Matrix::SRT(transform_.position, transform_.scale, transform_.rotation);
|
||||||
* Matrix::Skewing(transform_.skew)
|
|
||||||
* Matrix::Rotation(transform_.rotation)
|
if (!transform_.skew.IsOrigin())
|
||||||
* Matrix::Translation(transform_.position);
|
{
|
||||||
|
transform_matrix_ = Matrix::Skewing(transform_.skew) * transform_matrix_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transform_matrix_.Translate(Point{ -size_.x * anchor_.x, -size_.y * anchor_.y });
|
transform_matrix_.Translate(Point{ -size_.x * anchor_.x, -size_.y * anchor_.y });
|
||||||
|
|
@ -656,8 +660,9 @@ namespace kiwano
|
||||||
|
|
||||||
void VisualNode::PrepareRender()
|
void VisualNode::PrepareRender()
|
||||||
{
|
{
|
||||||
Renderer::Instance()->SetTransform(transform_matrix_);
|
auto renderer = Renderer::Instance();
|
||||||
Renderer::Instance()->SetOpacity(displayed_opacity_);
|
renderer->SetTransform(transform_matrix_);
|
||||||
|
renderer->SetOpacity(displayed_opacity_);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,8 @@ namespace kiwano
|
||||||
|
|
||||||
if (text_layout_)
|
if (text_layout_)
|
||||||
{
|
{
|
||||||
Renderer::Instance()->SetTextStyle(
|
auto renderer = Renderer::Instance();
|
||||||
|
renderer->SetTextStyle(
|
||||||
GetDisplayedOpacity(),
|
GetDisplayedOpacity(),
|
||||||
style_.color,
|
style_.color,
|
||||||
style_.outline,
|
style_.outline,
|
||||||
|
|
@ -311,7 +312,7 @@ namespace kiwano
|
||||||
style_.outline_width,
|
style_.outline_width,
|
||||||
style_.outline_stroke
|
style_.outline_stroke
|
||||||
);
|
);
|
||||||
Renderer::Instance()->DrawTextLayout(text_layout_);
|
renderer->DrawTextLayout(text_layout_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,8 +328,10 @@ namespace kiwano
|
||||||
if (text_.empty())
|
if (text_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto renderer = Renderer::Instance();
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
Renderer::Instance()->GetD2DDeviceResources()->CreateTextFormat(
|
renderer->GetD2DDeviceResources()->CreateTextFormat(
|
||||||
text_format_,
|
text_format_,
|
||||||
font_,
|
font_,
|
||||||
style_
|
style_
|
||||||
|
|
@ -336,7 +339,7 @@ namespace kiwano
|
||||||
);
|
);
|
||||||
|
|
||||||
ThrowIfFailed(
|
ThrowIfFailed(
|
||||||
Renderer::Instance()->GetD2DDeviceResources()->CreateTextLayout(
|
renderer->GetD2DDeviceResources()->CreateTextLayout(
|
||||||
text_layout_,
|
text_layout_,
|
||||||
layout_size_,
|
layout_size_,
|
||||||
text_,
|
text_,
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,17 @@ namespace kiwano
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline MatrixT SRT(const vec2_type& trans, const vec2_type& scale, value_type angle)
|
||||||
|
{
|
||||||
|
value_type s = math::Sin(angle);
|
||||||
|
value_type c = math::Cos(angle);
|
||||||
|
return MatrixT(
|
||||||
|
c * scale.x, s * scale.x,
|
||||||
|
-s * scale.y, c * scale.y,
|
||||||
|
trans.x, trans.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static inline MatrixT Skewing(const vec2_type& angle)
|
static inline MatrixT Skewing(const vec2_type& angle)
|
||||||
{
|
{
|
||||||
value_type tx = math::Tan(angle.x);
|
value_type tx = math::Tan(angle.x);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue