Skip to content

Commit 446b34d

Browse files
committed
Optimization does not work.
Revert "view::refresh(element) optimization by caching the latest element bounds." This reverts commit d4e71f8.
1 parent 3641a3f commit 446b34d

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

lib/include/elements/support/context.hpp

+3-14
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,17 @@ namespace cycfi::elements
7676
context(context const& rhs, artist::rect bounds_)
7777
: basic_context(rhs.view, rhs.canvas), element(rhs.element)
7878
, parent(rhs.parent), bounds(bounds_)
79-
{
80-
update_bounds();
81-
}
79+
{}
8280

8381
context(context const& parent_, element* element_, artist::rect bounds_)
8482
: basic_context(parent_.view, parent_.canvas), element(element_)
8583
, parent(&parent_), bounds(bounds_)
86-
{
87-
update_bounds();
88-
}
84+
{}
8985

9086
context(class view& view_, class canvas& canvas_, element* element_, artist::rect bounds_)
9187
: basic_context(view_, canvas_), element(element_)
9288
, parent(nullptr), bounds(bounds_)
93-
{
94-
update_bounds();
95-
}
89+
{}
9690

9791
context(context const&) = default;
9892
context& operator=(context const&) = delete;
@@ -129,11 +123,6 @@ namespace cycfi::elements
129123

130124
private:
131125

132-
void update_bounds()
133-
{
134-
cache_element_bounds(view, element, bounds);
135-
}
136-
137126
using listener_function =
138127
std::function<
139128
void(context const& ctx, elements::element*, string_view what)

lib/include/elements/view.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ namespace cycfi { namespace elements
121121

122122
private:
123123

124-
friend void cache_element_bounds(view& v, element* e, rect const& bounds);
125-
126124
scaled_content make_scaled_content() { return elements::scale(1.0, link(_content)); }
127125

128126
layer_composite _content;
@@ -147,10 +145,6 @@ namespace cycfi { namespace elements
147145
using tracking_map = std::map<element*, time_point>;
148146

149147
tracking_map _tracking;
150-
151-
using bounds_map = std::unordered_map<element*, rect>;
152-
153-
bounds_map _bounds_map;
154148
};
155149

156150
////////////////////////////////////////////////////////////////////////////

lib/src/view.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ namespace cycfi { namespace elements
181181

182182
void view::refresh(context const& ctx, int outward)
183183
{
184-
if (auto i = _bounds_map.find(ctx.element); i != _bounds_map.end())
185-
{
186-
refresh(i->second);
187-
return;
188-
}
189-
190184
context const* ctx_ptr = &ctx;
191185
while (outward > 0 && ctx_ptr)
192186
{
@@ -198,7 +192,6 @@ namespace cycfi { namespace elements
198192
auto tl = ctx.canvas.user_to_device(ctx_ptr->bounds.top_left());
199193
auto br = ctx.canvas.user_to_device(ctx_ptr->bounds.bottom_right());
200194
refresh({tl.x, tl.y, br.x, br.y});
201-
_bounds_map[ctx_ptr->element] = rect{tl, br};
202195
}
203196
}
204197

0 commit comments

Comments
 (0)