Merge lp:~3v1n0/unity/callgrind-improvements into lp:unity
- callgrind-improvements
- Merge into trunk
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Andrea Azzarone | ||||||||||||||||
Approved revision: | no longer in the source branch. | ||||||||||||||||
Merged at revision: | 3300 | ||||||||||||||||
Proposed branch: | lp:~3v1n0/unity/callgrind-improvements | ||||||||||||||||
Merge into: | lp:unity | ||||||||||||||||
Diff against target: |
785 lines (+168/-112) 15 files modified
dash/LensView.cpp (+9/-15) dash/LensView.h (+1/-1) debian/control (+1/-1) launcher/Launcher.cpp (+5/-8) launcher/SwitcherView.cpp (+10/-8) panel/PanelController.cpp (+14/-24) panel/PanelController.h (+1/-1) panel/PanelTray.cpp (+1/-1) plugins/unityshell/src/unityshell.cpp (+1/-5) unity-shared/AbstractIconRenderer.h (+1/-6) unity-shared/FileManager.h (+1/-0) unity-shared/IconRenderer.cpp (+59/-27) unity-shared/IconRenderer.h (+0/-1) unity-shared/IconTextureSource.cpp (+48/-11) unity-shared/IconTextureSource.h (+16/-3) |
||||||||||||||||
To merge this branch: | bzr merge lp:~3v1n0/unity/callgrind-improvements | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Andrea Azzarone (community) | Approve | ||
Brandon Schaefer (community) | Approve | ||
Review via email: mp+158725@code.launchpad.net |
Commit message
Unity: reduce a lot the cost of some many-often called functions, thanks to callgrind
UnityScreen:
IconRenderer:
Launcher:
panel::
UnityScreen:
IconRenderer:
UnityScreen:
IconRenderer:
UnityScreen:
dash::LensView:
IconTexture:
See more at http://
Description of the change
Comparing these Callgrind results http://
UnityScreen:
IconRenderer:
Launcher:
panel::
UnityScreen:
IconRenderer:
UnityScreen:
IconRenderer:
UnityScreen:
dash::LensView:
IconTexture:
Plus other more generic operations such as vectors allocations or matrix operations.
All these are possible in combination with lp:~3v1n0/nux/callgrind-improvements
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
> + nux::Point3 rotation;
>
> Why did you do it?
We had 3 floats instead that needed manual initialization (both in renderer and in Launcher), and that didn't allow to do equality check easily (in PreprocessIcon).
Using a nux::Point3 is just smarter and allows to do the same things better.
Brandon Schaefer (brandontschaefer) wrote : | # |
LGTM.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Andrea Azzarone (azzar1) wrote : | # |
> > + nux::Point3 rotation;
> >
> > Why did you do it?
>
> We had 3 floats instead that needed manual initialization (both in renderer
> and in Launcher), and that didn't allow to do equality check easily (in
> PreprocessIcon).
> Using a nux::Point3 is just smarter and allows to do the same things better.
What about a nux::Vector3(?) rotation?
Andrea Azzarone (azzar1) wrote : | # |
LGTM now. Thanks!!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Adrian Wechner (adrian-wechner) wrote : | # |
197 + result.rotation.x = start.rotation.x + (end.rotation.x - start.rotation.x) * progress;
198 + result.rotation.y = start.rotation.y + (end.rotation.y - start.rotation.y) * progress;
199 + result.rotation.z = start.rotation.z + (end.rotation.z - start.rotation.z) * progress;
This could be shorten by:
basically what you do is +val1 + val2 - val1 => well val1 would then be 0
(maybe the compiler would optimize that anyway)
result.rotation.x = end.rotation.x * progress;
result.rotation.y = end.rotation.y * progress;
result.rotation.z = end.rotation.z * progress;
doesn't it?
Adrian Wechner (adrian-wechner) wrote : | # |
if you use 2 * M_PI a lot (i don't know if you do) and if M_PI is a constant, then I'd add another constant M2_PI (or something like that). then you would save a float operation :)
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Adrian, thanks for pointing that out... I didn't change a lot that part of code as I focused on things that were stealing more cycles (also, thankfully g++ is quite good at optimizing).
Anyway, it would be nice to improve these things too (old code)... Would you be so kind to do a merge proposal? :)
Adrian Wechner (adrian-wechner) wrote : | # |
what you mean with a merge proposal? to create a branch, change what I meant and then to propose to merge into this branch? if it is, then tomorrow i'll do that with pleasure.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3307
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Adrian Wechner (adrian-wechner) wrote : | # |
forget about what I said. the shorten does not work... sorry, it's just too late to think clear :) we add start after we multiplied, so that just works how it is. and i checked the M_PI constant. you don't use it that often and only once multiplied by 2.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
No need to retry this branch, it won't merge until the nux queue is cleared (and the merger seems to have some issues with that) as for the version bump there.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:3307
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'dash/LensView.cpp' |
2 | --- dash/LensView.cpp 2013-01-15 21:53:55 +0000 |
3 | +++ dash/LensView.cpp 2013-04-12 23:35:32 +0000 |
4 | @@ -225,11 +225,6 @@ |
5 | scroll_view_->EnableHorizontalScrollBar(false); |
6 | layout_->AddView(scroll_view_); |
7 | |
8 | - scroll_view_->geometry_changed.connect([this] (nux::Area *area, nux::Geometry& geo) |
9 | - { |
10 | - CheckScrollBarState(); |
11 | - }); |
12 | - |
13 | scroll_layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); |
14 | scroll_view_->SetLayout(scroll_layout_); |
15 | scroll_view_->SetRightArea(show_filters); |
16 | @@ -510,8 +505,7 @@ |
17 | std::string uri = result.uri; |
18 | LOG_TRACE(logger) << "Result added: " << uri; |
19 | |
20 | - counts_[group]++; |
21 | - UpdateCounts(group); |
22 | + UpdateCounts(group, ++counts_[group]); |
23 | // make sure we don't display the no-results-hint if we do have results |
24 | if (G_UNLIKELY (no_results_active_)) |
25 | { |
26 | @@ -543,8 +537,7 @@ |
27 | std::string uri = result.uri; |
28 | LOG_TRACE(logger) << "Result removed: " << uri; |
29 | |
30 | - counts_[group]--; |
31 | - UpdateCounts(group); |
32 | + UpdateCounts(group, --counts_[group]); |
33 | } catch (std::out_of_range& oor) { |
34 | LOG_WARN(logger) << "Result does not have a valid category index: " |
35 | << boost::lexical_cast<unsigned int>(result.category_index) |
36 | @@ -552,13 +545,13 @@ |
37 | } |
38 | } |
39 | |
40 | -void LensView::UpdateCounts(PlacesGroup* group) |
41 | +void LensView::UpdateCounts(PlacesGroup* group, unsigned int new_counts) |
42 | { |
43 | unsigned int columns = dash::Style::Instance().GetDefaultNColumns(); |
44 | columns -= filters_expanded ? 2 : 0; |
45 | |
46 | - group->SetCounts(columns, counts_[group]); |
47 | - group->SetVisible(counts_[group]); |
48 | + group->SetCounts(columns, new_counts); |
49 | + group->SetVisible(new_counts); |
50 | } |
51 | |
52 | void LensView::CheckNoResults(Lens::Hints const& hints) |
53 | @@ -663,13 +656,13 @@ |
54 | |
55 | void LensView::CheckScrollBarState() |
56 | { |
57 | - if (scroll_layout_->GetGeometry().height > scroll_view_->GetGeometry().height) |
58 | + if (scroll_layout_->GetHeight() > scroll_view_->GetHeight()) |
59 | { |
60 | - scroll_view_->EnableVerticalScrollBar(true); |
61 | + scroll_view_->EnableVerticalScrollBar(true); |
62 | } |
63 | else |
64 | { |
65 | - scroll_view_->EnableVerticalScrollBar(false); |
66 | + scroll_view_->EnableVerticalScrollBar(false); |
67 | } |
68 | } |
69 | |
70 | @@ -735,6 +728,7 @@ |
71 | { |
72 | nux::Geometry const& geo(GetGeometry()); |
73 | graphics_engine.PushClippingRectangle(geo); |
74 | + CheckScrollBarState(); |
75 | |
76 | if (!IsFullRedraw() && RedirectedAncestor()) |
77 | { |
78 | |
79 | === modified file 'dash/LensView.h' |
80 | --- dash/LensView.h 2012-12-17 21:30:27 +0000 |
81 | +++ dash/LensView.h 2013-04-12 23:35:32 +0000 |
82 | @@ -97,7 +97,7 @@ |
83 | void OnCategoryOrderChanged(); |
84 | void OnResultAdded(Result const& result); |
85 | void OnResultRemoved(Result const& result); |
86 | - void UpdateCounts(PlacesGroup* group); |
87 | + void UpdateCounts(PlacesGroup* group, unsigned int); |
88 | void OnGroupExpanded(PlacesGroup* group); |
89 | void CheckScrollBarState(); |
90 | void OnColumnsChanged(); |
91 | |
92 | === modified file 'debian/control' |
93 | --- debian/control 2013-03-06 10:42:08 +0000 |
94 | +++ debian/control 2013-04-12 23:35:32 +0000 |
95 | @@ -28,7 +28,7 @@ |
96 | libunity-misc-dev (>= 4.0.4), |
97 | libgrail-dev (>= 1.0.20), |
98 | libxcb-icccm4-dev, |
99 | - libnux-4.0-dev (>= 4.0.0daily13.01.18bzr752), |
100 | + libnux-4.0-dev (>= 4.0.1), |
101 | compiz-dev (>= 1:0.9.9~daily13.01.25bzr3586), |
102 | libcompizconfig0-dev (>= 1:0.9.9~daily12.12.05-0ubuntu2), |
103 | xsltproc, |
104 | |
105 | === modified file 'launcher/Launcher.cpp' |
106 | --- launcher/Launcher.cpp 2013-04-09 02:18:08 +0000 |
107 | +++ launcher/Launcher.cpp 2013-04-12 23:35:32 +0000 |
108 | @@ -150,6 +150,7 @@ |
109 | , icon_renderer(std::make_shared<ui::IconRenderer>()) |
110 | { |
111 | m_Layout = new nux::HLayout(NUX_TRACKER_LOCATION); |
112 | + icon_renderer->monitor = monitor(); |
113 | |
114 | bg_effect_helper_.owner = this; |
115 | bg_effect_helper_.enabled = false; |
116 | @@ -783,9 +784,6 @@ |
117 | arg.running_colored = icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT); |
118 | arg.draw_edge_only = IconDrawEdgeOnly(icon); |
119 | arg.active_colored = false; |
120 | - arg.x_rotation = 0.0f; |
121 | - arg.y_rotation = 0.0f; |
122 | - arg.z_rotation = 0.0f; |
123 | arg.skip = false; |
124 | arg.stick_thingy = false; |
125 | arg.keyboard_nav_hl = false; |
126 | @@ -863,7 +861,7 @@ |
127 | |
128 | if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT) && options()->urgent_animation() == URGENT_ANIMATION_WIGGLE) |
129 | { |
130 | - arg.z_rotation = IconUrgentWiggleValue(icon, current); |
131 | + arg.rotation.z = IconUrgentWiggleValue(icon, current); |
132 | } |
133 | |
134 | if (IsInKeyNavMode()) |
135 | @@ -941,7 +939,7 @@ |
136 | |
137 | // icon is crossing threshold, start folding |
138 | center.z += folded_z_distance * folding_progress; |
139 | - arg.x_rotation = animation_neg_rads * folding_progress; |
140 | + arg.rotation.x = animation_neg_rads * folding_progress; |
141 | |
142 | float spacing_overlap = CLAMP((float)(center.y + (2.0f * half_size * size_modifier) + (_space_between_icons * size_modifier) - folding_threshold) / (float) _icon_size, 0.0f, 1.0f); |
143 | float spacing = (_space_between_icons * (1.0f - spacing_overlap) + folded_spacing * spacing_overlap) * size_modifier; |
144 | @@ -1399,6 +1397,7 @@ |
145 | unity::panel::Style &panel_style = panel::Style::Instance(); |
146 | Resize(nux::Point(monitor_geo.x, monitor_geo.y + panel_style.panel_height), |
147 | monitor_geo.height - panel_style.panel_height); |
148 | + icon_renderer->monitor = new_monitor; |
149 | } |
150 | |
151 | void Launcher::UpdateOptions(Options::Ptr options) |
152 | @@ -1688,8 +1687,6 @@ |
153 | |
154 | void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) |
155 | { |
156 | - icon_renderer->monitor = monitor(); |
157 | - |
158 | nux::Geometry const& base = GetGeometry(); |
159 | nux::Geometry bkg_box; |
160 | std::list<RenderArg> args; |
161 | @@ -2458,7 +2455,7 @@ |
162 | SetupRenderArg(icon, current, arg); |
163 | arg.render_center = nux::Point3(roundf(texture->GetWidth() / 2.0f), roundf(texture->GetHeight() / 2.0f), 0.0f); |
164 | arg.logical_center = arg.render_center; |
165 | - arg.x_rotation = 0.0f; |
166 | + arg.rotation.x = 0.0f; |
167 | arg.running_arrow = false; |
168 | arg.active_arrow = false; |
169 | arg.skip = false; |
170 | |
171 | === modified file 'launcher/SwitcherView.cpp' |
172 | --- launcher/SwitcherView.cpp 2013-02-13 01:45:00 +0000 |
173 | +++ launcher/SwitcherView.cpp 2013-04-12 23:35:32 +0000 |
174 | @@ -17,6 +17,7 @@ |
175 | */ |
176 | |
177 | #include "config.h" |
178 | +#include "MultiMonitor.h" |
179 | #include "SwitcherView.h" |
180 | #include "unity-shared/IconRenderer.h" |
181 | #include "unity-shared/TimeUtil.h" |
182 | @@ -57,6 +58,7 @@ |
183 | , target_sizes_set_(false) |
184 | { |
185 | icon_renderer_->pip_style = OVER_TILE; |
186 | + icon_renderer_->monitor = max_num_monitors; |
187 | |
188 | text_view_->SetMaximumWidth(tile_size * spread_size); |
189 | text_view_->SetLines(1); |
190 | @@ -224,9 +226,9 @@ |
191 | |
192 | RenderArg result = end; |
193 | |
194 | - result.x_rotation = start.x_rotation + (end.x_rotation - start.x_rotation) * progress; |
195 | - result.y_rotation = start.y_rotation + (end.y_rotation - start.y_rotation) * progress; |
196 | - result.z_rotation = start.z_rotation + (end.z_rotation - start.z_rotation) * progress; |
197 | + result.rotation.x = start.rotation.x + (end.rotation.x - start.rotation.x) * progress; |
198 | + result.rotation.y = start.rotation.y + (end.rotation.y - start.rotation.y) * progress; |
199 | + result.rotation.z = start.rotation.z + (end.rotation.z - start.rotation.z) * progress; |
200 | |
201 | result.render_center.x = start.render_center.x + (end.render_center.x - start.render_center.x) * progress; |
202 | result.render_center.y = start.render_center.y + (end.render_center.y - start.render_center.y) * progress; |
203 | @@ -489,7 +491,7 @@ |
204 | |
205 | x += (half_size + flat_spacing) * scalar; |
206 | |
207 | - arg.y_rotation = (1.0f - MIN (1.0f, scalar)); |
208 | + arg.rotation.y = (1.0f - std::min<float>(1.0f, scalar)); |
209 | |
210 | if (!should_flat && overflow > 0 && i != selection) |
211 | { |
212 | @@ -500,11 +502,11 @@ |
213 | else |
214 | { |
215 | arg.render_center.x += 20; |
216 | - arg.y_rotation = -arg.y_rotation; |
217 | + arg.rotation.y = -arg.rotation.y; |
218 | } |
219 | } |
220 | |
221 | - arg.render_center.z = abs(80.0f * arg.y_rotation); |
222 | + arg.render_center.z = abs(80.0f * arg.rotation.y); |
223 | arg.logical_center = arg.render_center; |
224 | |
225 | if (i == selection && detail_selection) |
226 | @@ -588,13 +590,13 @@ |
227 | text_view_->SetBaseX(start_x); |
228 | } |
229 | |
230 | - if (arg.y_rotation < 0) |
231 | + if (arg.rotation.y < 0) |
232 | icon_renderer_->RenderIcon(GfxContext, arg, base, base); |
233 | } |
234 | |
235 | for (auto rit = last_args_.rbegin(); rit != last_args_.rend(); ++rit) |
236 | { |
237 | - if (rit->y_rotation >= 0) |
238 | + if (rit->rotation.y >= 0) |
239 | icon_renderer_->RenderIcon(GfxContext, *rit, base, base); |
240 | } |
241 | |
242 | |
243 | === modified file 'panel/PanelController.cpp' |
244 | --- panel/PanelController.cpp 2013-04-09 01:35:49 +0000 |
245 | +++ panel/PanelController.cpp 2013-04-12 23:35:32 +0000 |
246 | @@ -44,7 +44,6 @@ |
247 | void FirstMenuShow(); |
248 | void QueueRedraw(); |
249 | |
250 | - std::vector<Window> GetTrayXids() const; |
251 | std::vector<nux::View*> GetPanelViews() const; |
252 | std::vector<nux::Geometry> GetGeometries() const; |
253 | |
254 | @@ -60,7 +59,6 @@ |
255 | |
256 | void OnScreenChanged(unsigned int primary_monitor, std::vector<nux::Geometry>& monitors, Introspectable *iobj); |
257 | |
258 | -private: |
259 | typedef nux::ObjectPtr<nux::BaseWindow> BaseWindowPtr; |
260 | |
261 | unity::PanelView* ViewForWindow(BaseWindowPtr const& window) const; |
262 | @@ -70,8 +68,8 @@ |
263 | nux::Geometry& geo, |
264 | void* user_data); |
265 | |
266 | -private: |
267 | std::vector<BaseWindowPtr> windows_; |
268 | + std::vector<Window> tray_xids_; |
269 | float opacity_; |
270 | bool opacity_maximized_toggle_; |
271 | int menus_fadein_; |
272 | @@ -94,23 +92,11 @@ |
273 | , dbus_indicators_(std::make_shared<indicator::DBusIndicators>()) |
274 | {} |
275 | |
276 | -std::vector<Window> Controller::Impl::GetTrayXids() const |
277 | -{ |
278 | - std::vector<Window> xids; |
279 | - |
280 | - for (auto window: windows_) |
281 | - { |
282 | - xids.push_back(ViewForWindow(window)->GetTrayXid()); |
283 | - } |
284 | - |
285 | - return xids; |
286 | -} |
287 | - |
288 | std::vector<nux::View*> Controller::Impl::GetPanelViews() const |
289 | { |
290 | std::vector<nux::View*> views; |
291 | views.reserve(windows_.size()); |
292 | - for (auto window: windows_) |
293 | + for (auto const& window: windows_) |
294 | views.push_back(ViewForWindow(window)); |
295 | return views; |
296 | } |
297 | @@ -119,7 +105,7 @@ |
298 | { |
299 | std::vector<nux::Geometry> geometries; |
300 | |
301 | - for (auto window : windows_) |
302 | + for (auto const& window : windows_) |
303 | { |
304 | geometries.push_back(window->GetAbsoluteGeometry()); |
305 | } |
306 | @@ -129,7 +115,7 @@ |
307 | |
308 | void Controller::Impl::FirstMenuShow() |
309 | { |
310 | - for (auto window: windows_) |
311 | + for (auto const& window: windows_) |
312 | { |
313 | if (ViewForWindow(window)->FirstMenuShow()) |
314 | break; |
315 | @@ -140,7 +126,7 @@ |
316 | { |
317 | opacity_ = opacity; |
318 | |
319 | - for (auto window: windows_) |
320 | + for (auto const& window: windows_) |
321 | { |
322 | ViewForWindow(window)->SetOpacity(opacity_); |
323 | } |
324 | @@ -158,7 +144,7 @@ |
325 | { |
326 | opacity_maximized_toggle_ = enabled; |
327 | |
328 | - for (auto window: windows_) |
329 | + for (auto const& window: windows_) |
330 | { |
331 | ViewForWindow(window)->SetOpacityMaximizedToggle(opacity_maximized_toggle_); |
332 | } |
333 | @@ -173,7 +159,7 @@ |
334 | menus_discovery_fadein_ = discovery_fadein; |
335 | menus_discovery_fadeout_ = discovery_fadeout; |
336 | |
337 | - for (auto window: windows_) |
338 | + for (auto const& window: windows_) |
339 | { |
340 | ViewForWindow(window)->SetMenuShowTimings(fadein, fadeout, discovery, |
341 | discovery_fadein, discovery_fadeout); |
342 | @@ -182,7 +168,7 @@ |
343 | |
344 | void Controller::Impl::QueueRedraw() |
345 | { |
346 | - for (auto window: windows_) |
347 | + for (auto const& window: windows_) |
348 | { |
349 | window->QueueDraw(); |
350 | } |
351 | @@ -205,6 +191,8 @@ |
352 | unsigned n_monitors = monitors.size(); |
353 | unsigned int i = 0; |
354 | |
355 | + tray_xids_.resize(n_monitors); |
356 | + |
357 | for (it = windows_.begin(); it != windows_.end(); ++it) |
358 | { |
359 | if (i < n_monitors) |
360 | @@ -222,6 +210,7 @@ |
361 | view = ViewForWindow(*it); |
362 | view->SetPrimary(i == primary_monitor); |
363 | view->SetMonitor(i); |
364 | + tray_xids_[i] = view->GetTrayXid(); |
365 | |
366 | if (nux::GetWindowThread()->IsEmbeddedWindow()) |
367 | { |
368 | @@ -252,6 +241,7 @@ |
369 | menus_discovery_fadein_, menus_discovery_fadeout_); |
370 | view->SetPrimary(i == primary_monitor); |
371 | view->SetMonitor(i); |
372 | + tray_xids_[i] = view->GetTrayXid(); |
373 | |
374 | layout->AddView(view, 1); |
375 | layout->SetContentDistribution(nux::MAJOR_POSITION_START); |
376 | @@ -362,9 +352,9 @@ |
377 | pimpl->QueueRedraw(); |
378 | } |
379 | |
380 | -std::vector<Window> Controller::GetTrayXids() const |
381 | +std::vector<Window> const& Controller::GetTrayXids() const |
382 | { |
383 | - return pimpl->GetTrayXids(); |
384 | + return pimpl->tray_xids_; |
385 | } |
386 | |
387 | std::vector<nux::View*> Controller::GetPanelViews() const |
388 | |
389 | === modified file 'panel/PanelController.h' |
390 | --- panel/PanelController.h 2013-01-30 19:00:01 +0000 |
391 | +++ panel/PanelController.h 2013-04-12 23:35:32 +0000 |
392 | @@ -40,7 +40,7 @@ |
393 | void FirstMenuShow(); |
394 | void QueueRedraw(); |
395 | |
396 | - std::vector<Window> GetTrayXids() const; |
397 | + std::vector<Window> const& GetTrayXids() const; |
398 | std::vector<nux::View*> GetPanelViews() const; |
399 | std::vector<nux::Geometry> GetGeometries() const; |
400 | |
401 | |
402 | === modified file 'panel/PanelTray.cpp' |
403 | --- panel/PanelTray.cpp 2013-02-06 12:32:28 +0000 |
404 | +++ panel/PanelTray.cpp 2013-04-12 23:35:32 +0000 |
405 | @@ -89,7 +89,7 @@ |
406 | |
407 | Window PanelTray::xid() |
408 | { |
409 | - if (!window_) |
410 | + if (!window_ || !gtk_widget_get_realized(window_)) |
411 | return 0; |
412 | |
413 | return gdk_x11_window_get_xid(gtk_widget_get_window(window_)); |
414 | |
415 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
416 | --- plugins/unityshell/src/unityshell.cpp 2013-04-11 05:53:30 +0000 |
417 | +++ plugins/unityshell/src/unityshell.cpp 2013-04-12 23:35:32 +0000 |
418 | @@ -621,8 +621,6 @@ |
419 | |
420 | panelShadowPainted |= redraw; |
421 | |
422 | - nuxPrologue(); |
423 | - |
424 | for (auto const& r : redraw.rects()) |
425 | { |
426 | for (GLTexture* tex : _shadow_texture) |
427 | @@ -685,7 +683,6 @@ |
428 | glDisable(GL_BLEND); |
429 | } |
430 | } |
431 | - nuxEpilogue(); |
432 | } |
433 | |
434 | void |
435 | @@ -1434,8 +1431,7 @@ |
436 | * redraw even though the launcher's geometry is not in DrawList, and |
437 | * stop it. Then maybe we can revert back to the old code below #else. |
438 | */ |
439 | - std::vector<nux::Geometry> const& dirty = wt->GetDrawList(); |
440 | - if (!dirty.empty() || animation_controller_->HasRunningAnimations()) |
441 | + if (!wt->GetDrawList().empty() || animation_controller_->HasRunningAnimations()) |
442 | { |
443 | cScreen->damageRegionSetEnabled(this, false); |
444 | cScreen->damageScreen(); |
445 | |
446 | === modified file 'unity-shared/AbstractIconRenderer.h' |
447 | --- unity-shared/AbstractIconRenderer.h 2012-10-17 22:42:12 +0000 |
448 | +++ unity-shared/AbstractIconRenderer.h 2013-04-12 23:35:32 +0000 |
449 | @@ -41,9 +41,6 @@ |
450 | RenderArg() |
451 | : icon(0) |
452 | , colorify(nux::color::White) |
453 | - , x_rotation(0) |
454 | - , y_rotation(0) |
455 | - , z_rotation(0) |
456 | , alpha(1.0f) |
457 | , saturation(1.0f) |
458 | , backlight_intensity(0.0f) |
459 | @@ -71,10 +68,8 @@ |
460 | IconTextureSource* icon; |
461 | nux::Point3 render_center; |
462 | nux::Point3 logical_center; |
463 | + nux::Vector3 rotation; |
464 | nux::Color colorify; |
465 | - float x_rotation; |
466 | - float y_rotation; |
467 | - float z_rotation; |
468 | float alpha; |
469 | float saturation; |
470 | float backlight_intensity; |
471 | |
472 | === modified file 'unity-shared/FileManager.h' |
473 | --- unity-shared/FileManager.h 2013-03-29 17:44:12 +0000 |
474 | +++ unity-shared/FileManager.h 2013-04-12 23:35:32 +0000 |
475 | @@ -22,6 +22,7 @@ |
476 | #define UNITYSHELL_FILEMANAGER_H |
477 | |
478 | #include <memory> |
479 | +#include <vector> |
480 | #include <string> |
481 | #include <sigc++/sigc++.h> |
482 | |
483 | |
484 | === modified file 'unity-shared/IconRenderer.cpp' |
485 | --- unity-shared/IconRenderer.cpp 2013-04-08 14:35:06 +0000 |
486 | +++ unity-shared/IconRenderer.cpp 2013-04-12 23:35:32 +0000 |
487 | @@ -235,6 +235,13 @@ |
488 | nux::ObjectPtr<nux::IOpenGLAsmShaderProgram> asm_shader; |
489 | #endif |
490 | |
491 | + int VertexLocation; |
492 | + int VPMatrixLocation; |
493 | + int TextureCoord0Location; |
494 | + int FragmentColor; |
495 | + int ColorifyColor; |
496 | + int DesatFactor; |
497 | + |
498 | std::map<char, BaseTexturePtr> labels; |
499 | |
500 | private: |
501 | @@ -264,9 +271,6 @@ |
502 | pip_style = OUTSIDE_TILE; |
503 | } |
504 | |
505 | -IconRenderer::~IconRenderer() |
506 | -{} |
507 | - |
508 | void IconRenderer::SetTargetSize(int tile_size, int image_size_, int spacing_) |
509 | { |
510 | icon_size = tile_size; |
511 | @@ -291,9 +295,20 @@ |
512 | int i; |
513 | for (it = args.begin(), i = 0; it != args.end(); ++it, ++i) |
514 | { |
515 | - |
516 | IconTextureSource* launcher_icon = it->icon; |
517 | |
518 | + if (it->render_center == launcher_icon->LastRenderCenter(monitor) && |
519 | + it->logical_center == launcher_icon->LastLogicalCenter(monitor) && |
520 | + it->rotation == launcher_icon->LastRotation(monitor) && |
521 | + it->skip == launcher_icon->WasSkipping(monitor)) |
522 | + { |
523 | + continue; |
524 | + } |
525 | + |
526 | + launcher_icon->RememberCenters(monitor, it->render_center, it->logical_center); |
527 | + launcher_icon->RememberRotation(monitor, it->rotation); |
528 | + launcher_icon->RememberSkip(monitor, it->skip); |
529 | + |
530 | float w = icon_size; |
531 | float h = icon_size; |
532 | float x = it->render_center.x - w / 2.0f; // x: top left corner |
533 | @@ -309,9 +324,9 @@ |
534 | } |
535 | |
536 | ObjectMatrix = nux::Matrix4::TRANSLATE(geo.width / 2.0f, geo.height / 2.0f, z) * // Translate the icon to the center of the viewport |
537 | - nux::Matrix4::ROTATEX(it->x_rotation) * // rotate the icon |
538 | - nux::Matrix4::ROTATEY(it->y_rotation) * |
539 | - nux::Matrix4::ROTATEZ(it->z_rotation) * |
540 | + nux::Matrix4::ROTATEX(it->rotation.x) * // rotate the icon |
541 | + nux::Matrix4::ROTATEY(it->rotation.y) * |
542 | + nux::Matrix4::ROTATEZ(it->rotation.z) * |
543 | nux::Matrix4::TRANSLATE(-x - w / 2.0f, -y - h / 2.0f, -z); // Put the center the icon to (0, 0) |
544 | |
545 | ViewProjectionMatrix = PremultMatrix * ObjectMatrix; |
546 | @@ -369,9 +384,9 @@ |
547 | z = it->render_center.z; |
548 | |
549 | ObjectMatrix = nux::Matrix4::TRANSLATE(geo.width / 2.0f, geo.height / 2.0f, z) * // Translate the icon to the center of the viewport |
550 | - nux::Matrix4::ROTATEX(it->x_rotation) * // rotate the icon |
551 | - nux::Matrix4::ROTATEY(it->y_rotation) * |
552 | - nux::Matrix4::ROTATEZ(it->z_rotation) * |
553 | + nux::Matrix4::ROTATEX(it->rotation.x) * // rotate the icon |
554 | + nux::Matrix4::ROTATEY(it->rotation.y) * |
555 | + nux::Matrix4::ROTATEZ(it->rotation.z) * |
556 | nux::Matrix4::TRANSLATE(-(it->render_center.x - w / 2.0f) - w / 2.0f, -(it->render_center.y - h / 2.0f) - h / 2.0f, -z); // Put the center the icon to (0, 0) |
557 | |
558 | ViewProjectionMatrix = PremultMatrix * ObjectMatrix; |
559 | @@ -754,9 +769,9 @@ |
560 | if (icon.IsNull()) |
561 | return; |
562 | |
563 | - if (std::abs(arg.x_rotation) < 0.01f && |
564 | - std::abs(arg.y_rotation) < 0.01f && |
565 | - std::abs(arg.z_rotation) < 0.01f && |
566 | + if (std::abs(arg.rotation.x) < 0.01f && |
567 | + std::abs(arg.rotation.y) < 0.01f && |
568 | + std::abs(arg.rotation.z) < 0.01f && |
569 | !force_filter) |
570 | { |
571 | icon->SetFiltering(GL_NEAREST, GL_NEAREST); |
572 | @@ -823,20 +838,15 @@ |
573 | { |
574 | textures_->shader_program_uv_persp_correction->Begin(); |
575 | |
576 | - int TextureObjectLocation = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0"); |
577 | - VertexLocation = textures_->shader_program_uv_persp_correction->GetAttributeLocation("iVertex"); |
578 | - TextureCoord0Location = textures_->shader_program_uv_persp_correction->GetAttributeLocation("iTexCoord0"); |
579 | - FragmentColor = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("color0"); |
580 | - ColorifyColor = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("colorify_color"); |
581 | - DesatFactor = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("desat_factor"); |
582 | - |
583 | - if (TextureObjectLocation != -1) |
584 | - CHECKGL(glUniform1iARB(TextureObjectLocation, 0)); |
585 | - |
586 | - int VPMatrixLocation = textures_->shader_program_uv_persp_correction->GetUniformLocationARB("ViewProjectionMatrix"); |
587 | - if (VPMatrixLocation != -1) |
588 | + VertexLocation = textures_->VertexLocation; |
589 | + TextureCoord0Location = textures_->TextureCoord0Location; |
590 | + FragmentColor = textures_->FragmentColor; |
591 | + ColorifyColor = textures_->ColorifyColor; |
592 | + DesatFactor = textures_->DesatFactor; |
593 | + |
594 | + if (textures_->VPMatrixLocation != -1) |
595 | { |
596 | - textures_->shader_program_uv_persp_correction->SetUniformLocMatrix4fv((GLint)VPMatrixLocation, 1, false, (GLfloat*) & (stored_projection_matrix_.m)); |
597 | + textures_->shader_program_uv_persp_correction->SetUniformLocMatrix4fv((GLint)textures_->VPMatrixLocation, 1, false, (GLfloat*) & (stored_projection_matrix_.m)); |
598 | } |
599 | } |
600 | #ifndef USE_GLES |
601 | @@ -922,7 +932,7 @@ |
602 | nux::Geometry const& geo) |
603 | { |
604 | int markerCenter = (int) arg.render_center.y; |
605 | - markerCenter -= (int)(arg.x_rotation / (2 * M_PI) * icon_size); |
606 | + markerCenter -= (int)(arg.rotation.x / (2 * M_PI) * icon_size); |
607 | |
608 | |
609 | if (running > 0) |
610 | @@ -1194,6 +1204,12 @@ |
611 | |
612 | IconRenderer::TexturesPool::TexturesPool() |
613 | : offscreen_progress_texture(nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8)) |
614 | + , VertexLocation(-1) |
615 | + , VPMatrixLocation(0) |
616 | + , TextureCoord0Location(-1) |
617 | + , FragmentColor(0) |
618 | + , ColorifyColor(0) |
619 | + , DesatFactor(0) |
620 | { |
621 | LoadTexture(progress_bar_trough, PKGDATADIR"/progress_bar_trough.png"); |
622 | LoadTexture(progress_bar_fill, PKGDATADIR"/progress_bar_fill.png"); |
623 | @@ -1249,6 +1265,22 @@ |
624 | shader_program_uv_persp_correction = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateShaderProgram(); |
625 | shader_program_uv_persp_correction->LoadIShader(gPerspectiveCorrectShader.c_str()); |
626 | shader_program_uv_persp_correction->Link(); |
627 | + |
628 | + shader_program_uv_persp_correction->Begin(); |
629 | + |
630 | + int TextureObjectLocation = shader_program_uv_persp_correction->GetUniformLocationARB("TextureObject0"); |
631 | + VertexLocation = shader_program_uv_persp_correction->GetAttributeLocation("iVertex"); |
632 | + TextureCoord0Location = shader_program_uv_persp_correction->GetAttributeLocation("iTexCoord0"); |
633 | + FragmentColor = shader_program_uv_persp_correction->GetUniformLocationARB("color0"); |
634 | + ColorifyColor = shader_program_uv_persp_correction->GetUniformLocationARB("colorify_color"); |
635 | + DesatFactor = shader_program_uv_persp_correction->GetUniformLocationARB("desat_factor"); |
636 | + |
637 | + if (TextureObjectLocation != -1) |
638 | + CHECKGL(glUniform1iARB(TextureObjectLocation, 0)); |
639 | + |
640 | + VPMatrixLocation = shader_program_uv_persp_correction->GetUniformLocationARB("ViewProjectionMatrix"); |
641 | + |
642 | + shader_program_uv_persp_correction->End(); |
643 | } |
644 | else |
645 | { |
646 | |
647 | === modified file 'unity-shared/IconRenderer.h' |
648 | --- unity-shared/IconRenderer.h 2013-03-19 13:24:45 +0000 |
649 | +++ unity-shared/IconRenderer.h 2013-04-12 23:35:32 +0000 |
650 | @@ -37,7 +37,6 @@ |
651 | { |
652 | public: |
653 | IconRenderer(); |
654 | - virtual ~IconRenderer(); |
655 | |
656 | void PreprocessIcons(std::list<RenderArg>& args, nux::Geometry const& target_window); |
657 | |
658 | |
659 | === modified file 'unity-shared/IconTextureSource.cpp' |
660 | --- unity-shared/IconTextureSource.cpp 2012-05-07 00:49:31 +0000 |
661 | +++ unity-shared/IconTextureSource.cpp 2013-04-12 23:35:32 +0000 |
662 | @@ -26,21 +26,58 @@ |
663 | { |
664 | NUX_IMPLEMENT_OBJECT_TYPE(IconTextureSource); |
665 | |
666 | +namespace |
667 | +{ |
668 | + const unsigned RENDERERS_SIZE = max_num_monitors + 1; // +1 for the switcher |
669 | +} |
670 | + |
671 | IconTextureSource::IconTextureSource() |
672 | -{ |
673 | - transform_map.resize(max_num_monitors); |
674 | -} |
675 | + : skip_(RENDERERS_SIZE, false) |
676 | + , last_render_center_(RENDERERS_SIZE) |
677 | + , last_logical_center_(RENDERERS_SIZE) |
678 | + , last_rotation_(RENDERERS_SIZE) |
679 | + , transformations_(RENDERERS_SIZE, decltype(transformations_)::value_type(TRANSFORM_SIZE, std::vector<nux::Vector4>(4))) |
680 | +{} |
681 | |
682 | std::vector<nux::Vector4> & IconTextureSource::GetTransform(TransformIndex index, int monitor) |
683 | { |
684 | - auto iter = transform_map[monitor].find(index); |
685 | - if (iter == transform_map[monitor].end()) |
686 | - { |
687 | - auto iter2 = transform_map[monitor].insert(std::map<TransformIndex, std::vector<nux::Vector4> >::value_type(index, std::vector<nux::Vector4>(4))); |
688 | - return iter2.first->second; |
689 | - } |
690 | - |
691 | - return iter->second; |
692 | + return transformations_[monitor][index]; |
693 | +} |
694 | + |
695 | +void IconTextureSource::RememberCenters(int monitor, nux::Point3 const& render, nux::Point3 const& logical) |
696 | +{ |
697 | + last_render_center_[monitor] = render; |
698 | + last_logical_center_[monitor] = logical; |
699 | +} |
700 | + |
701 | +void IconTextureSource::RememberRotation(int monitor, nux::Vector3 const& rotation) |
702 | +{ |
703 | + last_rotation_[monitor] = rotation; |
704 | +} |
705 | + |
706 | +nux::Point3 const& IconTextureSource::LastRenderCenter(int monitor) const |
707 | +{ |
708 | + return last_render_center_[monitor]; |
709 | +} |
710 | + |
711 | +nux::Point3 const& IconTextureSource::LastLogicalCenter(int monitor) const |
712 | +{ |
713 | + return last_logical_center_[monitor]; |
714 | +} |
715 | + |
716 | +nux::Vector3 const& IconTextureSource::LastRotation(int monitor) const |
717 | +{ |
718 | + return last_rotation_[monitor]; |
719 | +} |
720 | + |
721 | +void IconTextureSource::RememberSkip(int monitor, bool skip) |
722 | +{ |
723 | + skip_[monitor] = skip; |
724 | +} |
725 | + |
726 | +bool IconTextureSource::WasSkipping(int monitor) const |
727 | +{ |
728 | + return skip_[monitor]; |
729 | } |
730 | |
731 | } |
732 | |
733 | === modified file 'unity-shared/IconTextureSource.h' |
734 | --- unity-shared/IconTextureSource.h 2012-05-28 16:16:06 +0000 |
735 | +++ unity-shared/IconTextureSource.h 2013-04-12 23:35:32 +0000 |
736 | @@ -22,7 +22,6 @@ |
737 | #define ICONTEXTURESOURCE_H |
738 | |
739 | #include <Nux/Nux.h> |
740 | -#include <NuxCore/Property.h> |
741 | #include <NuxCore/Math/MathInc.h> |
742 | |
743 | namespace unity |
744 | @@ -38,17 +37,27 @@ |
745 | |
746 | enum TransformIndex |
747 | { |
748 | - TRANSFORM_TILE, |
749 | + TRANSFORM_TILE = 0, |
750 | TRANSFORM_IMAGE, |
751 | TRANSFORM_HIT_AREA, |
752 | TRANSFORM_GLOW, |
753 | TRANSFORM_EMBLEM, |
754 | + TRANSFORM_SIZE |
755 | }; |
756 | |
757 | IconTextureSource(); |
758 | |
759 | std::vector<nux::Vector4> & GetTransform(TransformIndex index, int monitor); |
760 | |
761 | + nux::Point3 const& LastRenderCenter(int monitor) const; |
762 | + nux::Point3 const& LastLogicalCenter(int monitor) const; |
763 | + nux::Vector3 const& LastRotation(int monitor) const; |
764 | + void RememberCenters(int monitor, nux::Point3 const& render, nux::Point3 const& logical); |
765 | + void RememberRotation(int monitor, nux::Vector3 const& rotation); |
766 | + |
767 | + void RememberSkip(int monitor, bool skip); |
768 | + bool WasSkipping(int monitor) const; |
769 | + |
770 | virtual nux::Color BackgroundColor() const = 0; |
771 | |
772 | virtual nux::Color GlowColor() = 0; |
773 | @@ -58,7 +67,11 @@ |
774 | virtual nux::BaseTexture* Emblem() = 0; |
775 | |
776 | private: |
777 | - std::vector<std::map<TransformIndex, std::vector<nux::Vector4> > > transform_map; |
778 | + std::vector<bool> skip_; |
779 | + std::vector<nux::Point3> last_render_center_; |
780 | + std::vector<nux::Point3> last_logical_center_; |
781 | + std::vector<nux::Vector3> last_rotation_; |
782 | + std::vector<std::vector<std::vector<nux::Vector4>>> transformations_; |
783 | }; |
784 | |
785 | } |
+ nux::Point3 rotation;
Why did you do it?