mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
SpaceAnalyzer: Fix rendering bug when dealing with large file systems
This commit is contained in:
parent
c569ed7e8b
commit
5f53dc6a45
3 changed files with 18 additions and 18 deletions
|
@ -123,19 +123,19 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int total_area = node.area();
|
i64 total_area = node.area();
|
||||||
Gfx::IntRect canvas = rect;
|
Gfx::IntRect canvas = rect;
|
||||||
bool remaining_nodes_are_too_small = false;
|
bool remaining_nodes_are_too_small = false;
|
||||||
for (size_t i = 0; !remaining_nodes_are_too_small && i < node.num_children(); i++) {
|
for (size_t i = 0; !remaining_nodes_are_too_small && i < node.num_children(); i++) {
|
||||||
const int i_node_area = node.child_at(i).area();
|
const i64 i_node_area = node.child_at(i).area();
|
||||||
if (i_node_area == 0)
|
if (i_node_area == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const int long_side_size = max(canvas.width(), canvas.height());
|
const size_t long_side_size = max(canvas.width(), canvas.height());
|
||||||
const int short_side_size = min(canvas.width(), canvas.height());
|
const size_t short_side_size = min(canvas.width(), canvas.height());
|
||||||
|
|
||||||
int row_or_column_size = (long long int)long_side_size * i_node_area / total_area;
|
size_t row_or_column_size = long_side_size * i_node_area / total_area;
|
||||||
int node_area_sum = i_node_area;
|
i64 node_area_sum = i_node_area;
|
||||||
size_t k = i + 1;
|
size_t k = i + 1;
|
||||||
|
|
||||||
// Try to add nodes to this row or column so long as the worst aspect ratio of
|
// Try to add nodes to this row or column so long as the worst aspect ratio of
|
||||||
|
@ -146,14 +146,14 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
|
||||||
// Do a preliminary calculation of the worst aspect ratio of the nodes at index i and k
|
// Do a preliminary calculation of the worst aspect ratio of the nodes at index i and k
|
||||||
// if that aspect ratio is better than the 'best_worst_aspect_ratio_so_far' we keep it,
|
// if that aspect ratio is better than the 'best_worst_aspect_ratio_so_far' we keep it,
|
||||||
// otherwise it is discarded.
|
// otherwise it is discarded.
|
||||||
int k_node_area = node.child_at(k).area();
|
i64 k_node_area = node.child_at(k).area();
|
||||||
if (k_node_area == 0) {
|
if (k_node_area == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int new_node_area_sum = node_area_sum + k_node_area;
|
i64 new_node_area_sum = node_area_sum + k_node_area;
|
||||||
int new_row_or_column_size = (long long int)long_side_size * new_node_area_sum / total_area;
|
size_t new_row_or_column_size = long_side_size * new_node_area_sum / total_area;
|
||||||
int i_node_size = (long long int)short_side_size * i_node_area / new_node_area_sum;
|
size_t i_node_size = short_side_size * i_node_area / new_node_area_sum;
|
||||||
int k_node_size = (long long int)short_side_size * k_node_area / new_node_area_sum;
|
size_t k_node_size = short_side_size * k_node_area / new_node_area_sum;
|
||||||
float i_node_aspect_ratio = get_normalized_aspect_ratio(new_row_or_column_size, i_node_size);
|
float i_node_aspect_ratio = get_normalized_aspect_ratio(new_row_or_column_size, i_node_size);
|
||||||
float k_node_aspect_ratio = get_normalized_aspect_ratio(new_row_or_column_size, k_node_size);
|
float k_node_aspect_ratio = get_normalized_aspect_ratio(new_row_or_column_size, k_node_size);
|
||||||
float new_worst_aspect_ratio = min(i_node_aspect_ratio, k_node_aspect_ratio);
|
float new_worst_aspect_ratio = min(i_node_aspect_ratio, k_node_aspect_ratio);
|
||||||
|
@ -168,9 +168,9 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
|
||||||
|
|
||||||
// Paint the elements from 'i' up to and including 'k-1'.
|
// Paint the elements from 'i' up to and including 'k-1'.
|
||||||
{
|
{
|
||||||
const int fixed_side_size = row_or_column_size;
|
const size_t fixed_side_size = row_or_column_size;
|
||||||
int placement_area = node_area_sum;
|
i64 placement_area = node_area_sum;
|
||||||
int main_dim = short_side_size;
|
size_t main_dim = short_side_size;
|
||||||
|
|
||||||
// Lay out nodes in a row or column.
|
// Lay out nodes in a row or column.
|
||||||
Orientation orientation = canvas.width() > canvas.height() ? Orientation::Horizontal : Orientation::Vertical;
|
Orientation orientation = canvas.width() > canvas.height() ? Orientation::Horizontal : Orientation::Vertical;
|
||||||
|
@ -178,7 +178,7 @@ void TreeMapWidget::lay_out_children(const TreeMapNode& node, const Gfx::IntRect
|
||||||
layout_rect.set_primary_size_for_orientation(orientation, fixed_side_size);
|
layout_rect.set_primary_size_for_orientation(orientation, fixed_side_size);
|
||||||
for (size_t q = i; q < k; q++) {
|
for (size_t q = i; q < k; q++) {
|
||||||
auto& child = node.child_at(q);
|
auto& child = node.child_at(q);
|
||||||
int node_size = (long long int)main_dim * child.area() / placement_area;
|
size_t node_size = main_dim * child.area() / placement_area;
|
||||||
Gfx::IntRect cell_rect = layout_rect;
|
Gfx::IntRect cell_rect = layout_rect;
|
||||||
cell_rect.set_secondary_size_for_orientation(orientation, node_size);
|
cell_rect.set_secondary_size_for_orientation(orientation, node_size);
|
||||||
Gfx::IntRect inner_rect;
|
Gfx::IntRect inner_rect;
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace SpaceAnalyzer {
|
||||||
|
|
||||||
struct TreeMapNode {
|
struct TreeMapNode {
|
||||||
virtual String name() const = 0;
|
virtual String name() const = 0;
|
||||||
virtual int64_t area() const = 0;
|
virtual i64 area() const = 0;
|
||||||
virtual size_t num_children() const = 0;
|
virtual size_t num_children() const = 0;
|
||||||
virtual const TreeMapNode& child_at(size_t i) const = 0;
|
virtual const TreeMapNode& child_at(size_t i) const = 0;
|
||||||
virtual void sort_children_by_area() const = 0;
|
virtual void sort_children_by_area() const = 0;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct TreeNode : public SpaceAnalyzer::TreeMapNode {
|
||||||
: m_name(move(name)) {};
|
: m_name(move(name)) {};
|
||||||
|
|
||||||
virtual String name() const { return m_name; }
|
virtual String name() const { return m_name; }
|
||||||
virtual int64_t area() const { return m_area; }
|
virtual i64 area() const { return m_area; }
|
||||||
virtual size_t num_children() const
|
virtual size_t num_children() const
|
||||||
{
|
{
|
||||||
if (m_children) {
|
if (m_children) {
|
||||||
|
@ -51,7 +51,7 @@ struct TreeNode : public SpaceAnalyzer::TreeMapNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
String m_name;
|
String m_name;
|
||||||
int64_t m_area { 0 };
|
i64 m_area { 0 };
|
||||||
OwnPtr<Vector<TreeNode>> m_children;
|
OwnPtr<Vector<TreeNode>> m_children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue