Merge lp:~3v1n0/unity/massif-textures-sharing into lp:unity
- massif-textures-sharing
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3289 |
Proposed branch: | lp:~3v1n0/unity/massif-textures-sharing |
Merge into: | lp:unity |
Diff against target: |
672 lines (+133/-150) 12 files modified
launcher/Launcher.cpp (+2/-6) panel/PanelView.cpp (+21/-24) panel/PanelView.h (+1/-1) plugins/unityshell/src/unityshell.cpp (+32/-53) plugins/unityshell/src/unityshell.h (+2/-6) tests/test_texture_cache.cpp (+3/-3) unity-shared/DashStyle.cpp (+3/-13) unity-shared/PanelStyle.cpp (+41/-19) unity-shared/PanelStyle.h (+2/-1) unity-shared/TextureCache.cpp (+17/-18) unity-shared/TextureCache.h (+6/-4) unity-shared/WindowButtons.cpp (+3/-2) |
To merge this branch: | bzr merge lp:~3v1n0/unity/massif-textures-sharing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+157774@code.launchpad.net |
Commit message
Unity: share textures whenever possible, optimize memory usage.
And some code improvements in TextureCache, PanelStyle, PanelView and unityshell
Description of the change
I've run unity under valgrind's massif, and I've noticed (as expected) that the most of the unity memory is used by textures. However, massif also underlined that we were allocating some resources many times (especially when in multi-monitor).
So, I've moved many components to use TextureCache, including PanelView, DashStyle, WindowButtons.
Improved a little the code of TextureCache that now has a default factory function to fetch textures from the default unity location.
Improvements in the PanelView background texture (that was used also by unityshell to paint the "fake" panel under the dash, in case of maximized windows): before we were generating real-size textures (and in case of unityshell big as the entire screen, a problem especially in case of multi-monitor), now we only generate 1x24 px texture that is repeated when drawing.
A not-scientific comparison of massif: http://
In that tests I've ran unity for 5 minutes in my machine performing some basic unity operations using AP tests. It underlines ~5MB saving, it won't change the world but it's still a win! :)
Brandon Schaefer (brandontschaefer) wrote : | # |
Brandon Schaefer (brandontschaefer) wrote : | # |
Looks good to me, tests pass and I don't see any black textures anywhere :)
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'launcher/Launcher.cpp' | |||
2 | --- launcher/Launcher.cpp 2013-04-05 19:20:49 +0000 | |||
3 | +++ launcher/Launcher.cpp 2013-04-09 01:09:21 +0000 | |||
4 | @@ -198,12 +198,8 @@ | |||
5 | 198 | icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons); | 198 | icon_renderer->SetTargetSize(_icon_size, _icon_image_size, _space_between_icons); |
6 | 199 | 199 | ||
7 | 200 | TextureCache& cache = TextureCache::GetDefault(); | 200 | TextureCache& cache = TextureCache::GetDefault(); |
14 | 201 | TextureCache::CreateTextureCallback cb = [&](std::string const& name, int width, int height) { | 201 | launcher_sheen_ = cache.FindTexture("dash_sheen.png"); |
15 | 202 | return nux::CreateTexture2DFromFile((PKGDATADIR"/" + name + ".png").c_str(), -1, true); | 202 | launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect.png"); |
10 | 203 | }; | ||
11 | 204 | |||
12 | 205 | launcher_sheen_ = cache.FindTexture("dash_sheen", 0, 0, cb); | ||
13 | 206 | launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb); | ||
16 | 207 | 203 | ||
17 | 208 | options.changed.connect(sigc::mem_fun(this, &Launcher::OnOptionsChanged)); | 204 | options.changed.connect(sigc::mem_fun(this, &Launcher::OnOptionsChanged)); |
18 | 209 | monitor.changed.connect(sigc::mem_fun(this, &Launcher::OnMonitorChanged)); | 205 | monitor.changed.connect(sigc::mem_fun(this, &Launcher::OnMonitorChanged)); |
19 | 210 | 206 | ||
20 | === modified file 'panel/PanelView.cpp' | |||
21 | --- panel/PanelView.cpp 2013-03-19 18:47:01 +0000 | |||
22 | +++ panel/PanelView.cpp 2013-04-09 01:09:21 +0000 | |||
23 | @@ -25,7 +25,6 @@ | |||
24 | 25 | #include <Nux/WindowCompositor.h> | 25 | #include <Nux/WindowCompositor.h> |
25 | 26 | 26 | ||
26 | 27 | #include <NuxGraphics/CairoGraphics.h> | 27 | #include <NuxGraphics/CairoGraphics.h> |
27 | 28 | #include <NuxGraphics/ImageSurface.h> | ||
28 | 29 | #include <NuxCore/Logger.h> | 28 | #include <NuxCore/Logger.h> |
29 | 30 | #include <UnityCore/GLibWrapper.h> | 29 | #include <UnityCore/GLibWrapper.h> |
30 | 31 | 30 | ||
31 | @@ -35,6 +34,7 @@ | |||
32 | 35 | #include <glib.h> | 34 | #include <glib.h> |
33 | 36 | 35 | ||
34 | 37 | #include "unity-shared/PanelStyle.h" | 36 | #include "unity-shared/PanelStyle.h" |
35 | 37 | #include "unity-shared/TextureCache.h" | ||
36 | 38 | #include "unity-shared/WindowManager.h" | 38 | #include "unity-shared/WindowManager.h" |
37 | 39 | #include "unity-shared/UBusMessages.h" | 39 | #include "unity-shared/UBusMessages.h" |
38 | 40 | #include <UnityCore/Variant.h> | 40 | #include <UnityCore/Variant.h> |
39 | @@ -128,9 +128,10 @@ | |||
40 | 128 | bg_effect_helper_.owner = this; | 128 | bg_effect_helper_.owner = this; |
41 | 129 | 129 | ||
42 | 130 | //FIXME (gord)- replace with async loading | 130 | //FIXME (gord)- replace with async loading |
46 | 131 | panel_sheen_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/dash_sheen.png", -1, true)); | 131 | TextureCache& cache = TextureCache::GetDefault(); |
47 | 132 | bg_refine_tex_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/refine_gradient_panel.png", -1, true)); | 132 | panel_sheen_ = cache.FindTexture("dash_sheen.png"); |
48 | 133 | bg_refine_single_column_tex_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/refine_gradient_panel_single_column.png", -1, true)); | 133 | bg_refine_tex_ = cache.FindTexture("refine_gradient_panel.png"); |
49 | 134 | bg_refine_single_column_tex_ = cache.FindTexture("refine_gradient_panel_single_column.png"); | ||
50 | 134 | 135 | ||
51 | 135 | rop.Blend = true; | 136 | rop.Blend = true; |
52 | 136 | rop.SrcBlend = GL_ONE; | 137 | rop.SrcBlend = GL_ONE; |
53 | @@ -188,7 +189,8 @@ | |||
54 | 188 | bg_color_.blue = blue; | 189 | bg_color_.blue = blue; |
55 | 189 | bg_color_.alpha = alpha; | 190 | bg_color_.alpha = alpha; |
56 | 190 | 191 | ||
58 | 191 | ForceUpdateBackground(); | 192 | if (overlay_is_open_) |
59 | 193 | ForceUpdateBackground(); | ||
60 | 192 | } | 194 | } |
61 | 193 | 195 | ||
62 | 194 | void PanelView::OnOverlayHidden(GVariant* data) | 196 | void PanelView::OnOverlayHidden(GVariant* data) |
63 | @@ -267,7 +269,7 @@ | |||
64 | 267 | 269 | ||
65 | 268 | GfxContext.PushClippingRectangle(geo); | 270 | GfxContext.PushClippingRectangle(geo); |
66 | 269 | 271 | ||
68 | 270 | if ((overlay_is_open_ || (opacity_ != 1.0f && opacity_ != 0.0f))) | 272 | if (IsTransparent()) |
69 | 271 | { | 273 | { |
70 | 272 | nux::Geometry const& geo_absolute = GetAbsoluteGeometry(); | 274 | nux::Geometry const& geo_absolute = GetAbsoluteGeometry(); |
71 | 273 | nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height); | 275 | nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height); |
72 | @@ -281,7 +283,7 @@ | |||
73 | 281 | bg_blur_texture_ = bg_effect_helper_.GetRegion(blur_geo); | 283 | bg_blur_texture_ = bg_effect_helper_.GetRegion(blur_geo); |
74 | 282 | } | 284 | } |
75 | 283 | 285 | ||
77 | 284 | if (bg_blur_texture_.IsValid() && (overlay_is_open_ || opacity_ != 1.0f)) | 286 | if (bg_blur_texture_.IsValid()) |
78 | 285 | { | 287 | { |
79 | 286 | nux::TexCoordXForm texxform_blur_bg; | 288 | nux::TexCoordXForm texxform_blur_bg; |
80 | 287 | texxform_blur_bg.flip_v_coord = true; | 289 | texxform_blur_bg.flip_v_coord = true; |
81 | @@ -371,8 +373,7 @@ | |||
82 | 371 | GfxContext.GetRenderStates().SetBlend(true); | 373 | GfxContext.GetRenderStates().SetBlend(true); |
83 | 372 | GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); | 374 | GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); |
84 | 373 | 375 | ||
87 | 374 | if (bg_blur_texture_.IsValid() && | 376 | if (bg_blur_texture_.IsValid() && IsTransparent()) |
86 | 375 | (overlay_is_open_ || (opacity_ != 1.0f && opacity_ != 0.0f))) | ||
88 | 376 | { | 377 | { |
89 | 377 | nux::Geometry const& geo_absolute = GetAbsoluteGeometry(); | 378 | nux::Geometry const& geo_absolute = GetAbsoluteGeometry(); |
90 | 378 | nux::TexCoordXForm texxform_blur_bg; | 379 | nux::TexCoordXForm texxform_blur_bg; |
91 | @@ -482,12 +483,9 @@ | |||
92 | 482 | void | 483 | void |
93 | 483 | PanelView::UpdateBackground() | 484 | PanelView::UpdateBackground() |
94 | 484 | { | 485 | { |
98 | 485 | nux::Geometry const& geo = GetGeometry(); | 486 | if (!is_dirty_) |
96 | 486 | |||
97 | 487 | if (!is_dirty_ && geo == last_geo_) | ||
99 | 488 | return; | 487 | return; |
100 | 489 | 488 | ||
101 | 490 | last_geo_ = geo; | ||
102 | 491 | is_dirty_ = false; | 489 | is_dirty_ = false; |
103 | 492 | 490 | ||
104 | 493 | nux::ROPConfig rop; | 491 | nux::ROPConfig rop; |
105 | @@ -512,13 +510,13 @@ | |||
106 | 512 | opacity = 1.0f; | 510 | opacity = 1.0f; |
107 | 513 | } | 511 | } |
108 | 514 | 512 | ||
110 | 515 | auto tex = panel::Style::Instance().GetBackground(geo.width, geo.height, opacity); | 513 | auto const& tex = panel::Style::Instance().GetBackground(); |
111 | 516 | nux::TexCoordXForm texxform; | 514 | nux::TexCoordXForm texxform; |
112 | 517 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); | 515 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); |
114 | 518 | texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); | 516 | texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP); |
115 | 519 | 517 | ||
116 | 520 | bg_layer_.reset(new nux::TextureLayer(tex->GetDeviceTexture(), texxform, | 518 | bg_layer_.reset(new nux::TextureLayer(tex->GetDeviceTexture(), texxform, |
118 | 521 | nux::color::White, true, rop)); | 519 | nux::color::White * opacity, true, rop)); |
119 | 522 | } | 520 | } |
120 | 523 | } | 521 | } |
121 | 524 | 522 | ||
122 | @@ -527,12 +525,6 @@ | |||
123 | 527 | is_dirty_ = true; | 525 | is_dirty_ = true; |
124 | 528 | UpdateBackground(); | 526 | UpdateBackground(); |
125 | 529 | 527 | ||
126 | 530 | indicators_->QueueDraw(); | ||
127 | 531 | tray_->QueueDraw(); | ||
128 | 532 | |||
129 | 533 | if (!overlay_is_open_) | ||
130 | 534 | menu_view_->QueueDraw(); | ||
131 | 535 | |||
132 | 536 | QueueDraw(); | 528 | QueueDraw(); |
133 | 537 | } | 529 | } |
134 | 538 | 530 | ||
135 | @@ -703,12 +695,17 @@ | |||
136 | 703 | if (opacity_ == opacity) | 695 | if (opacity_ == opacity) |
137 | 704 | return; | 696 | return; |
138 | 705 | 697 | ||
141 | 706 | opacity_ = opacity; | 698 | opacity_ = (opacity <= 0.0f ? 0.0001f : opacity); // Not to get a black menu area |
142 | 707 | bg_effect_helper_.enabled = (opacity_ < 1.0f || overlay_is_open_); | 699 | bg_effect_helper_.enabled = IsTransparent(); |
143 | 708 | 700 | ||
144 | 709 | ForceUpdateBackground(); | 701 | ForceUpdateBackground(); |
145 | 710 | } | 702 | } |
146 | 711 | 703 | ||
147 | 704 | bool PanelView::IsTransparent() | ||
148 | 705 | { | ||
149 | 706 | return (opacity_ < 1.0f || overlay_is_open_); | ||
150 | 707 | } | ||
151 | 708 | |||
152 | 712 | void PanelView::SetMenuShowTimings(int fadein, int fadeout, int discovery, | 709 | void PanelView::SetMenuShowTimings(int fadein, int fadeout, int discovery, |
153 | 713 | int discovery_fadein, int discovery_fadeout) | 710 | int discovery_fadein, int discovery_fadeout) |
154 | 714 | { | 711 | { |
155 | 715 | 712 | ||
156 | === modified file 'panel/PanelView.h' | |||
157 | --- panel/PanelView.h 2013-03-04 23:56:40 +0000 | |||
158 | +++ panel/PanelView.h 2013-04-09 01:09:21 +0000 | |||
159 | @@ -91,6 +91,7 @@ | |||
160 | 91 | void OnOverlayShown(GVariant *data); | 91 | void OnOverlayShown(GVariant *data); |
161 | 92 | void OnOverlayHidden(GVariant *data); | 92 | void OnOverlayHidden(GVariant *data); |
162 | 93 | 93 | ||
163 | 94 | bool IsTransparent(); | ||
164 | 94 | void UpdateBackground(); | 95 | void UpdateBackground(); |
165 | 95 | void ForceUpdateBackground(); | 96 | void ForceUpdateBackground(); |
166 | 96 | bool TrackMenuPointer(); | 97 | bool TrackMenuPointer(); |
167 | @@ -116,7 +117,6 @@ | |||
168 | 116 | BaseTexturePtr bg_refine_single_column_tex_; | 117 | BaseTexturePtr bg_refine_single_column_tex_; |
169 | 117 | std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_; | 118 | std::unique_ptr<nux::AbstractPaintLayer> bg_refine_single_column_layer_; |
170 | 118 | 119 | ||
171 | 119 | nux::Geometry last_geo_; | ||
172 | 120 | nux::Color bg_color_; | 120 | nux::Color bg_color_; |
173 | 121 | std::string active_overlay_; | 121 | std::string active_overlay_; |
174 | 122 | nux::Point tracked_pointer_pos_; | 122 | nux::Point tracked_pointer_pos_; |
175 | 123 | 123 | ||
176 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
177 | --- plugins/unityshell/src/unityshell.cpp 2013-03-29 13:59:11 +0000 | |||
178 | +++ plugins/unityshell/src/unityshell.cpp 2013-04-09 01:09:21 +0000 | |||
179 | @@ -146,8 +146,7 @@ | |||
180 | 146 | , last_scroll_event_(0) | 146 | , last_scroll_event_(0) |
181 | 147 | , hud_keypress_time_(0) | 147 | , hud_keypress_time_(0) |
182 | 148 | , first_menu_keypress_time_(0) | 148 | , first_menu_keypress_time_(0) |
185 | 149 | , panel_texture_has_changed_(true) | 149 | , paint_panel_under_dash_(false) |
184 | 150 | , paint_panel_(false) | ||
186 | 151 | , scale_just_activated_(false) | 150 | , scale_just_activated_(false) |
187 | 152 | , big_tick_(0) | 151 | , big_tick_(0) |
188 | 153 | , screen_introspection_(screen) | 152 | , screen_introspection_(screen) |
189 | @@ -705,8 +704,6 @@ | |||
190 | 705 | 704 | ||
191 | 706 | void UnityScreen::OnPanelStyleChanged() | 705 | void UnityScreen::OnPanelStyleChanged() |
192 | 707 | { | 706 | { |
193 | 708 | panel_texture_has_changed_ = true; | ||
194 | 709 | |||
195 | 710 | // Reload the windows themed textures | 707 | // Reload the windows themed textures |
196 | 711 | UnityWindow::CleanupSharedTextures(); | 708 | UnityWindow::CleanupSharedTextures(); |
197 | 712 | 709 | ||
198 | @@ -723,7 +720,7 @@ | |||
199 | 723 | { | 720 | { |
200 | 724 | CompOutput *output = _last_output; | 721 | CompOutput *output = _last_output; |
201 | 725 | 722 | ||
203 | 726 | DrawTopPanelBackground(); | 723 | DrawPanelUnderDash(); |
204 | 727 | 724 | ||
205 | 728 | auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); | 725 | auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); |
206 | 729 | 726 | ||
207 | @@ -809,45 +806,29 @@ | |||
208 | 809 | didShellRepaint = true; | 806 | didShellRepaint = true; |
209 | 810 | } | 807 | } |
210 | 811 | 808 | ||
212 | 812 | void UnityScreen::DrawTopPanelBackground() | 809 | void UnityScreen::DrawPanelUnderDash() |
213 | 813 | { | 810 | { |
214 | 811 | if (!paint_panel_under_dash_ || !launcher_controller_->IsOverlayOpen()) | ||
215 | 812 | return; | ||
216 | 813 | |||
217 | 814 | if (_last_output->id() != screen->currentOutputDev().id()) | ||
218 | 815 | return; | ||
219 | 816 | |||
220 | 814 | auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); | 817 | auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); |
221 | 815 | 818 | ||
257 | 816 | if (!graphics_engine->UsingGLSLCodePath() || !launcher_controller_->IsOverlayOpen() || !paint_panel_) | 819 | if (!graphics_engine->UsingGLSLCodePath()) |
258 | 817 | return; | 820 | return; |
259 | 818 | 821 | ||
260 | 819 | if (TopPanelBackgroundTextureNeedsUpdate()) | 822 | graphics_engine->ResetModelViewMatrixStack(); |
261 | 820 | UpdateTopPanelBackgroundTexture(); | 823 | graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); |
262 | 821 | 824 | graphics_engine->ResetProjectionMatrix(); | |
263 | 822 | if (panel_texture_.IsValid()) | 825 | graphics_engine->SetOrthographicProjectionMatrix(screen->width(), screen->height()); |
264 | 823 | { | 826 | |
265 | 824 | graphics_engine->ResetModelViewMatrixStack(); | 827 | nux::TexCoordXForm texxform; |
266 | 825 | graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); | 828 | texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP); |
267 | 826 | graphics_engine->ResetProjectionMatrix(); | 829 | int panel_height = panel_style_.panel_height; |
268 | 827 | graphics_engine->SetOrthographicProjectionMatrix(screen->width (), screen->height()); | 830 | auto const& texture = panel_style_.GetBackground()->GetDeviceTexture(); |
269 | 828 | 831 | graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width(), panel_height, texture, texxform, nux::color::White); | |
235 | 829 | nux::TexCoordXForm texxform; | ||
236 | 830 | int panel_height = panel_style_.panel_height; | ||
237 | 831 | graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width (), panel_height, panel_texture_, texxform, nux::color::White); | ||
238 | 832 | } | ||
239 | 833 | } | ||
240 | 834 | |||
241 | 835 | bool UnityScreen::TopPanelBackgroundTextureNeedsUpdate() const | ||
242 | 836 | { | ||
243 | 837 | return panel_texture_has_changed_ || !panel_texture_.IsValid(); | ||
244 | 838 | } | ||
245 | 839 | |||
246 | 840 | void UnityScreen::UpdateTopPanelBackgroundTexture() | ||
247 | 841 | { | ||
248 | 842 | auto &panel_style = panel::Style::Instance(); | ||
249 | 843 | |||
250 | 844 | panel_texture_.Release(); | ||
251 | 845 | auto texture = panel_style.GetBackground(screen->width(), screen->height(), 1.0f); | ||
252 | 846 | |||
253 | 847 | if (texture) | ||
254 | 848 | panel_texture_ = texture->GetDeviceTexture(); | ||
255 | 849 | |||
256 | 850 | panel_texture_has_changed_ = false; | ||
270 | 851 | } | 832 | } |
271 | 852 | 833 | ||
272 | 853 | bool UnityScreen::forcePaintOnTop () | 834 | bool UnityScreen::forcePaintOnTop () |
273 | @@ -1256,7 +1237,7 @@ | |||
274 | 1256 | 1237 | ||
275 | 1257 | allowWindowPaint = true; | 1238 | allowWindowPaint = true; |
276 | 1258 | _last_output = output; | 1239 | _last_output = output; |
278 | 1259 | paint_panel_ = false; | 1240 | paint_panel_under_dash_ = false; |
279 | 1260 | 1241 | ||
280 | 1261 | // CompRegion has no clear() method. So this is the fastest alternative. | 1242 | // CompRegion has no clear() method. So this is the fastest alternative. |
281 | 1262 | fullscreenRegion = CompRegion(); | 1243 | fullscreenRegion = CompRegion(); |
282 | @@ -2597,19 +2578,17 @@ | |||
283 | 2597 | const CompRegion& region, | 2578 | const CompRegion& region, |
284 | 2598 | unsigned int mask) | 2579 | unsigned int mask) |
285 | 2599 | { | 2580 | { |
287 | 2600 | if (uScreen->doShellRepaint && !uScreen->paint_panel_ && window->type() == CompWindowTypeNormalMask) | 2581 | if (uScreen->doShellRepaint && !uScreen->paint_panel_under_dash_ && window->type() == CompWindowTypeNormalMask) |
288 | 2601 | { | 2582 | { |
298 | 2602 | guint32 id = window->id(); | 2583 | if ((window->state() & MAXIMIZE_STATE) && window->onCurrentDesktop() && !window->overrideRedirect() && window->managed()) |
290 | 2603 | bool maximized = WindowManager::Default().IsWindowMaximized(id); | ||
291 | 2604 | bool on_current = window->onCurrentDesktop(); | ||
292 | 2605 | bool override_redirect = window->overrideRedirect(); | ||
293 | 2606 | bool managed = window->managed(); | ||
294 | 2607 | CompPoint viewport = window->defaultViewport(); | ||
295 | 2608 | int output = window->outputDevice(); | ||
296 | 2609 | |||
297 | 2610 | if (maximized && on_current && !override_redirect && managed && viewport == uScreen->screen->vp() && output == (int)uScreen->screen->currentOutputDev().id()) | ||
299 | 2611 | { | 2584 | { |
301 | 2612 | uScreen->paint_panel_ = true; | 2585 | CompPoint const& viewport = window->defaultViewport(); |
302 | 2586 | unsigned output = window->outputDevice(); | ||
303 | 2587 | |||
304 | 2588 | if (viewport == uScreen->screen->vp() && output == uScreen->screen->currentOutputDev().id()) | ||
305 | 2589 | { | ||
306 | 2590 | uScreen->paint_panel_under_dash_ = true; | ||
307 | 2591 | } | ||
308 | 2613 | } | 2592 | } |
309 | 2614 | } | 2593 | } |
310 | 2615 | 2594 | ||
311 | 2616 | 2595 | ||
312 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
313 | --- plugins/unityshell/src/unityshell.h 2013-03-11 17:46:46 +0000 | |||
314 | +++ plugins/unityshell/src/unityshell.h 2013-04-09 01:09:21 +0000 | |||
315 | @@ -243,9 +243,7 @@ | |||
316 | 243 | 243 | ||
317 | 244 | void InitGesturesSupport(); | 244 | void InitGesturesSupport(); |
318 | 245 | 245 | ||
322 | 246 | void DrawTopPanelBackground(); | 246 | void DrawPanelUnderDash(); |
320 | 247 | bool TopPanelBackgroundTextureNeedsUpdate() const; | ||
321 | 248 | void UpdateTopPanelBackgroundTexture(); | ||
323 | 249 | 247 | ||
324 | 250 | unsigned CompizModifiersToNux(unsigned input) const; | 248 | unsigned CompizModifiersToNux(unsigned input) const; |
325 | 251 | unsigned XModifiersToNux(unsigned input) const; | 249 | unsigned XModifiersToNux(unsigned input) const; |
326 | @@ -331,9 +329,7 @@ | |||
327 | 331 | 329 | ||
328 | 332 | GLMatrix panel_shadow_matrix_; | 330 | GLMatrix panel_shadow_matrix_; |
329 | 333 | 331 | ||
333 | 334 | bool panel_texture_has_changed_; | 332 | bool paint_panel_under_dash_; |
331 | 335 | bool paint_panel_; | ||
332 | 336 | nux::ObjectPtr<nux::IOpenGLBaseTexture> panel_texture_; | ||
334 | 337 | std::set<UnityWindow*> fake_decorated_windows_; | 333 | std::set<UnityWindow*> fake_decorated_windows_; |
335 | 338 | 334 | ||
336 | 339 | bool scale_just_activated_; | 335 | bool scale_just_activated_; |
337 | 340 | 336 | ||
338 | === modified file 'tests/test_texture_cache.cpp' | |||
339 | --- tests/test_texture_cache.cpp 2011-09-02 02:24:56 +0000 | |||
340 | +++ tests/test_texture_cache.cpp 2013-04-09 01:09:21 +0000 | |||
341 | @@ -50,7 +50,7 @@ | |||
342 | 50 | } | 50 | } |
343 | 51 | }; | 51 | }; |
344 | 52 | 52 | ||
346 | 53 | TEST(TestTextureCache, DISABLED_TestCallsCreateTextureCallback) | 53 | TEST(TestTextureCache, TestCallsCreateTextureCallback) |
347 | 54 | { | 54 | { |
348 | 55 | // Another lambda issue. If the lambda takes a reference to any other | 55 | // Another lambda issue. If the lambda takes a reference to any other |
349 | 56 | // variables, it seems incapable of assigning the function to the | 56 | // variables, it seems incapable of assigning the function to the |
350 | @@ -80,7 +80,7 @@ | |||
351 | 80 | } | 80 | } |
352 | 81 | }; | 81 | }; |
353 | 82 | 82 | ||
355 | 83 | TEST(TestTextureCache, DISABLED_TestCallbackOnlyCalledOnce) | 83 | TEST(TestTextureCache, TestCallbackOnlyCalledOnce) |
356 | 84 | { | 84 | { |
357 | 85 | TextureCallbackCounter counter; | 85 | TextureCallbackCounter counter; |
358 | 86 | TextureCache::CreateTextureCallback callback(sigc::mem_fun(counter, &TextureCallbackCounter::callback)); | 86 | TextureCache::CreateTextureCallback callback(sigc::mem_fun(counter, &TextureCallbackCounter::callback)); |
359 | @@ -95,7 +95,7 @@ | |||
360 | 95 | EXPECT_TRUE(t1 == t2); | 95 | EXPECT_TRUE(t1 == t2); |
361 | 96 | } | 96 | } |
362 | 97 | 97 | ||
364 | 98 | TEST(TestTextureCache, DISABLED_TestCacheRemovesDeletedObject) | 98 | TEST(TestTextureCache, TestCacheRemovesDeletedObject) |
365 | 99 | { | 99 | { |
366 | 100 | // Note for others, if just using the lambda function, the return value is | 100 | // Note for others, if just using the lambda function, the return value is |
367 | 101 | // lost in the type deduction that sigc uses. So we have the typedef | 101 | // lost in the type deduction that sigc uses. So we have the typedef |
368 | 102 | 102 | ||
369 | === modified file 'unity-shared/DashStyle.cpp' | |||
370 | --- unity-shared/DashStyle.cpp 2013-03-11 22:18:58 +0000 | |||
371 | +++ unity-shared/DashStyle.cpp 2013-04-09 01:09:21 +0000 | |||
372 | @@ -42,6 +42,7 @@ | |||
373 | 42 | 42 | ||
374 | 43 | #include "CairoTexture.h" | 43 | #include "CairoTexture.h" |
375 | 44 | #include "JSONParser.h" | 44 | #include "JSONParser.h" |
376 | 45 | #include "TextureCache.h" | ||
377 | 45 | #include "UnitySettings.h" | 46 | #include "UnitySettings.h" |
378 | 46 | #include "config.h" | 47 | #include "config.h" |
379 | 47 | 48 | ||
380 | @@ -2547,19 +2548,8 @@ | |||
381 | 2547 | 2548 | ||
382 | 2548 | void LazyLoadTexture::LoadTexture() | 2549 | void LazyLoadTexture::LoadTexture() |
383 | 2549 | { | 2550 | { |
397 | 2550 | std::string full_path = PKGDATADIR + filename_; | 2551 | TextureCache& cache = TextureCache::GetDefault(); |
398 | 2551 | glib::Object<GdkPixbuf> pixbuf; | 2552 | texture_ = cache.FindTexture(filename_, size_, size_); |
386 | 2552 | glib::Error error; | ||
387 | 2553 | |||
388 | 2554 | pixbuf = ::gdk_pixbuf_new_from_file_at_size(full_path.c_str(), size_, size_, &error); | ||
389 | 2555 | if (error) | ||
390 | 2556 | { | ||
391 | 2557 | LOG_WARN(logger) << "Unable to texture " << full_path << ": " << error; | ||
392 | 2558 | } | ||
393 | 2559 | else | ||
394 | 2560 | { | ||
395 | 2561 | texture_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true)); | ||
396 | 2562 | } | ||
399 | 2563 | } | 2553 | } |
400 | 2564 | 2554 | ||
401 | 2565 | } // anon namespace | 2555 | } // anon namespace |
402 | 2566 | 2556 | ||
403 | === modified file 'unity-shared/PanelStyle.cpp' | |||
404 | --- unity-shared/PanelStyle.cpp 2012-12-14 15:17:24 +0000 | |||
405 | +++ unity-shared/PanelStyle.cpp 2013-04-09 01:09:21 +0000 | |||
406 | @@ -34,6 +34,7 @@ | |||
407 | 34 | #include "PanelStyle.h" | 34 | #include "PanelStyle.h" |
408 | 35 | 35 | ||
409 | 36 | #include <UnityCore/GLibWrapper.h> | 36 | #include <UnityCore/GLibWrapper.h> |
410 | 37 | #include "unity-shared/TextureCache.h" | ||
411 | 37 | #include "unity-shared/UnitySettings.h" | 38 | #include "unity-shared/UnitySettings.h" |
412 | 38 | 39 | ||
413 | 39 | namespace unity | 40 | namespace unity |
414 | @@ -138,7 +139,7 @@ | |||
415 | 138 | GdkRGBA rgba_text_color; | 139 | GdkRGBA rgba_text_color; |
416 | 139 | glib::String theme_name; | 140 | glib::String theme_name; |
417 | 140 | bool updated = false; | 141 | bool updated = false; |
419 | 141 | 142 | ||
420 | 142 | GtkSettings* settings = gtk_settings_get_default(); | 143 | GtkSettings* settings = gtk_settings_get_default(); |
421 | 143 | g_object_get(settings, "gtk-theme-name", &theme_name, nullptr); | 144 | g_object_get(settings, "gtk-theme-name", &theme_name, nullptr); |
422 | 144 | 145 | ||
423 | @@ -159,7 +160,10 @@ | |||
424 | 159 | } | 160 | } |
425 | 160 | 161 | ||
426 | 161 | if (updated) | 162 | if (updated) |
427 | 163 | { | ||
428 | 164 | _bg_texture.Release(); | ||
429 | 162 | changed.emit(); | 165 | changed.emit(); |
430 | 166 | } | ||
431 | 163 | } | 167 | } |
432 | 164 | 168 | ||
433 | 165 | GtkStyleContext* Style::GetStyleContext() | 169 | GtkStyleContext* Style::GetStyleContext() |
434 | @@ -167,8 +171,14 @@ | |||
435 | 167 | return _style_context; | 171 | return _style_context; |
436 | 168 | } | 172 | } |
437 | 169 | 173 | ||
439 | 170 | BaseTexturePtr Style::GetBackground(int width, int height, float opacity) | 174 | BaseTexturePtr Style::GetBackground() |
440 | 171 | { | 175 | { |
441 | 176 | if (_bg_texture) | ||
442 | 177 | return _bg_texture; | ||
443 | 178 | |||
444 | 179 | int width = 1; | ||
445 | 180 | int height = panel_height(); | ||
446 | 181 | |||
447 | 172 | nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, width, height); | 182 | nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, width, height); |
448 | 173 | 183 | ||
449 | 174 | // Use the internal context as we know it is good and shiny new. | 184 | // Use the internal context as we know it is good and shiny new. |
450 | @@ -177,9 +187,11 @@ | |||
451 | 177 | gtk_render_background(_style_context, cr, 0, 0, width, height); | 187 | gtk_render_background(_style_context, cr, 0, 0, width, height); |
452 | 178 | gtk_render_frame(_style_context, cr, 0, 0, width, height); | 188 | gtk_render_frame(_style_context, cr, 0, 0, width, height); |
453 | 179 | cairo_pop_group_to_source(cr); | 189 | cairo_pop_group_to_source(cr); |
457 | 180 | cairo_paint_with_alpha(cr, opacity); | 190 | cairo_paint(cr); |
458 | 181 | 191 | ||
459 | 182 | return texture_ptr_from_cairo_graphics(context); | 192 | _bg_texture = texture_ptr_from_cairo_graphics(context); |
460 | 193 | |||
461 | 194 | return _bg_texture; | ||
462 | 183 | } | 195 | } |
463 | 184 | 196 | ||
464 | 185 | /*! | 197 | /*! |
465 | @@ -222,20 +234,30 @@ | |||
466 | 222 | 234 | ||
467 | 223 | BaseTexturePtr Style::GetWindowButton(WindowButtonType type, WindowState state) | 235 | BaseTexturePtr Style::GetWindowButton(WindowButtonType type, WindowState state) |
468 | 224 | { | 236 | { |
483 | 225 | BaseTexturePtr texture; | 237 | auto texture_factory = [this, type, state] (std::string const&, int, int) { |
484 | 226 | 238 | nux::BaseTexture* texture = nullptr; | |
485 | 227 | for (auto const& file : GetWindowButtonFileNames(type, state)) | 239 | |
486 | 228 | { | 240 | for (auto const& file : GetWindowButtonFileNames(type, state)) |
487 | 229 | texture.Adopt(nux::CreateTexture2DFromFile(file.c_str(), -1, true)); | 241 | { |
488 | 230 | 242 | texture = nux::CreateTexture2DFromFile(file.c_str(), -1, true); | |
489 | 231 | if (texture) | 243 | |
490 | 232 | break; | 244 | if (texture) |
491 | 233 | } | 245 | return texture; |
492 | 234 | 246 | } | |
493 | 235 | if (!texture) | 247 | |
494 | 236 | texture = GetFallbackWindowButton(type, state); | 248 | auto const& fallback = GetFallbackWindowButton(type, state); |
495 | 237 | 249 | texture = fallback.GetPointer(); | |
496 | 238 | return texture; | 250 | texture->Reference(); |
497 | 251 | |||
498 | 252 | return texture; | ||
499 | 253 | }; | ||
500 | 254 | |||
501 | 255 | auto& cache = TextureCache::GetDefault(); | ||
502 | 256 | std::string texture_id = "window-button-"; | ||
503 | 257 | texture_id += std::to_string(static_cast<int>(type)); | ||
504 | 258 | texture_id += std::to_string(static_cast<int>(state)); | ||
505 | 259 | |||
506 | 260 | return cache.FindTexture(texture_id, 0, 0, texture_factory); | ||
507 | 239 | } | 261 | } |
508 | 240 | 262 | ||
509 | 241 | BaseTexturePtr Style::GetFallbackWindowButton(WindowButtonType type, | 263 | BaseTexturePtr Style::GetFallbackWindowButton(WindowButtonType type, |
510 | 242 | 264 | ||
511 | === modified file 'unity-shared/PanelStyle.h' | |||
512 | --- unity-shared/PanelStyle.h 2012-12-14 14:41:16 +0000 | |||
513 | +++ unity-shared/PanelStyle.h 2013-04-09 01:09:21 +0000 | |||
514 | @@ -71,7 +71,7 @@ | |||
515 | 71 | typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; | 71 | typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; |
516 | 72 | 72 | ||
517 | 73 | GtkStyleContext* GetStyleContext(); | 73 | GtkStyleContext* GetStyleContext(); |
519 | 74 | BaseTexturePtr GetBackground(int width, int height, float opacity); | 74 | BaseTexturePtr GetBackground(); |
520 | 75 | BaseTexturePtr GetWindowButton(WindowButtonType type, WindowState state); | 75 | BaseTexturePtr GetWindowButton(WindowButtonType type, WindowState state); |
521 | 76 | BaseTexturePtr GetFallbackWindowButton(WindowButtonType type, WindowState state); | 76 | BaseTexturePtr GetFallbackWindowButton(WindowButtonType type, WindowState state); |
522 | 77 | std::vector<std::string> GetWindowButtonFileNames(WindowButtonType type, WindowState state); | 77 | std::vector<std::string> GetWindowButtonFileNames(WindowButtonType type, WindowState state); |
523 | @@ -88,6 +88,7 @@ | |||
524 | 88 | 88 | ||
525 | 89 | glib::Object<GtkStyleContext> _style_context; | 89 | glib::Object<GtkStyleContext> _style_context; |
526 | 90 | glib::Object<GSettings> _gsettings; | 90 | glib::Object<GSettings> _gsettings; |
527 | 91 | BaseTexturePtr _bg_texture; | ||
528 | 91 | std::string _theme_name; | 92 | std::string _theme_name; |
529 | 92 | nux::Color _text_color; | 93 | nux::Color _text_color; |
530 | 93 | 94 | ||
531 | 94 | 95 | ||
532 | === modified file 'unity-shared/TextureCache.cpp' | |||
533 | --- unity-shared/TextureCache.cpp 2012-10-29 09:34:54 +0000 | |||
534 | +++ unity-shared/TextureCache.cpp 2013-04-09 01:09:21 +0000 | |||
535 | @@ -22,25 +22,23 @@ | |||
536 | 22 | 22 | ||
537 | 23 | #include <sstream> | 23 | #include <sstream> |
538 | 24 | #include <NuxCore/Logger.h> | 24 | #include <NuxCore/Logger.h> |
539 | 25 | #include "config.h" | ||
540 | 25 | 26 | ||
541 | 26 | namespace unity | 27 | namespace unity |
542 | 27 | { | 28 | { |
543 | 28 | DECLARE_LOGGER(logger, "unity.internal.texturecache"); | 29 | DECLARE_LOGGER(logger, "unity.internal.texturecache"); |
544 | 29 | 30 | ||
545 | 30 | TextureCache::TextureCache() | ||
546 | 31 | { | ||
547 | 32 | } | ||
548 | 33 | |||
549 | 34 | TextureCache::~TextureCache() | ||
550 | 35 | { | ||
551 | 36 | } | ||
552 | 37 | |||
553 | 38 | TextureCache& TextureCache::GetDefault() | 31 | TextureCache& TextureCache::GetDefault() |
554 | 39 | { | 32 | { |
555 | 40 | static TextureCache instance; | 33 | static TextureCache instance; |
556 | 41 | return instance; | 34 | return instance; |
557 | 42 | } | 35 | } |
558 | 43 | 36 | ||
559 | 37 | nux::BaseTexture* TextureCache::DefaultTexturesLoader(std::string const& name, int w, int h) | ||
560 | 38 | { | ||
561 | 39 | return nux::CreateTexture2DFromFile((PKGDATADIR"/" + name).c_str(), -1, true); | ||
562 | 40 | } | ||
563 | 41 | |||
564 | 44 | std::string TextureCache::Hash(std::string const& id, int width, int height) | 42 | std::string TextureCache::Hash(std::string const& id, int width, int height) |
565 | 45 | { | 43 | { |
566 | 46 | std::ostringstream sout; | 44 | std::ostringstream sout; |
567 | @@ -50,17 +48,22 @@ | |||
568 | 50 | 48 | ||
569 | 51 | TextureCache::BaseTexturePtr TextureCache::FindTexture(std::string const& texture_id, | 49 | TextureCache::BaseTexturePtr TextureCache::FindTexture(std::string const& texture_id, |
570 | 52 | int width, int height, | 50 | int width, int height, |
572 | 53 | CreateTextureCallback slot) | 51 | CreateTextureCallback factory) |
573 | 54 | { | 52 | { |
575 | 55 | if (!slot) | 53 | if (!factory) |
576 | 56 | return BaseTexturePtr(); | 54 | return BaseTexturePtr(); |
577 | 57 | 55 | ||
580 | 58 | std::string key = Hash(texture_id, width, height); | 56 | std::string const& key = Hash(texture_id, width, height); |
581 | 59 | BaseTexturePtr texture(cache_[key]); | 57 | auto texture_it = cache_.find(key); |
582 | 58 | |||
583 | 59 | BaseTexturePtr texture(texture_it != cache_.end() ? texture_it->second : nullptr); | ||
584 | 60 | 60 | ||
585 | 61 | if (!texture) | 61 | if (!texture) |
586 | 62 | { | 62 | { |
588 | 63 | texture = slot(texture_id, width, height); | 63 | texture.Adopt(factory(texture_id, width, height)); |
589 | 64 | |||
590 | 65 | if (!texture) | ||
591 | 66 | return texture; | ||
592 | 64 | 67 | ||
593 | 65 | // Now here is the magic. | 68 | // Now here is the magic. |
594 | 66 | // | 69 | // |
595 | @@ -79,10 +82,6 @@ | |||
596 | 79 | // are destroyed first, then the sigc::trackable disconnects all methods | 82 | // are destroyed first, then the sigc::trackable disconnects all methods |
597 | 80 | // created using mem_fun. | 83 | // created using mem_fun. |
598 | 81 | 84 | ||
599 | 82 | // Reduce the internal reference count of the texture, so the smart | ||
600 | 83 | // pointer is the sole owner of the object. | ||
601 | 84 | texture->UnReference(); | ||
602 | 85 | |||
603 | 86 | cache_[key] = texture.GetPointer(); | 85 | cache_[key] = texture.GetPointer(); |
604 | 87 | 86 | ||
605 | 88 | auto on_destroy = sigc::mem_fun(this, &TextureCache::OnDestroyNotify); | 87 | auto on_destroy = sigc::mem_fun(this, &TextureCache::OnDestroyNotify); |
606 | @@ -92,7 +91,7 @@ | |||
607 | 92 | return texture; | 91 | return texture; |
608 | 93 | } | 92 | } |
609 | 94 | 93 | ||
611 | 95 | void TextureCache::OnDestroyNotify(nux::Trackable* Object, std::string key) | 94 | void TextureCache::OnDestroyNotify(nux::Trackable* Object, std::string const& key) |
612 | 96 | { | 95 | { |
613 | 97 | cache_.erase(key); | 96 | cache_.erase(key); |
614 | 98 | } | 97 | } |
615 | 99 | 98 | ||
616 | === modified file 'unity-shared/TextureCache.h' | |||
617 | --- unity-shared/TextureCache.h 2012-07-16 11:03:32 +0000 | |||
618 | +++ unity-shared/TextureCache.h 2013-04-09 01:09:21 +0000 | |||
619 | @@ -40,24 +40,26 @@ | |||
620 | 40 | public: | 40 | public: |
621 | 41 | typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; | 41 | typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; |
622 | 42 | 42 | ||
623 | 43 | ~TextureCache() = default; | ||
624 | 44 | |||
625 | 43 | // id, width, height -> texture | 45 | // id, width, height -> texture |
626 | 44 | typedef std::function<nux::BaseTexture*(std::string const&, int, int)> CreateTextureCallback; | 46 | typedef std::function<nux::BaseTexture*(std::string const&, int, int)> CreateTextureCallback; |
627 | 45 | 47 | ||
628 | 46 | static TextureCache& GetDefault(); | 48 | static TextureCache& GetDefault(); |
629 | 49 | static nux::BaseTexture* DefaultTexturesLoader(std::string const&, int, int); | ||
630 | 47 | 50 | ||
632 | 48 | BaseTexturePtr FindTexture(std::string const& texture_id, int width, int height, CreateTextureCallback callback); | 51 | BaseTexturePtr FindTexture(std::string const& texture_id, int width = 0, int height = 0, CreateTextureCallback callback = DefaultTexturesLoader); |
633 | 49 | 52 | ||
634 | 50 | // Return the current size of the cache. | 53 | // Return the current size of the cache. |
635 | 51 | std::size_t Size() const; | 54 | std::size_t Size() const; |
636 | 52 | 55 | ||
637 | 53 | private: | 56 | private: |
640 | 54 | TextureCache(); | 57 | TextureCache() = default; |
639 | 55 | ~TextureCache(); | ||
641 | 56 | 58 | ||
642 | 57 | std::string Hash(std::string const& , int width, int height); | 59 | std::string Hash(std::string const& , int width, int height); |
643 | 58 | // Have the key passed by value not referece, as the key will be a bound | 60 | // Have the key passed by value not referece, as the key will be a bound |
644 | 59 | // parameter in the slot passed to the texture on_destroy signal. | 61 | // parameter in the slot passed to the texture on_destroy signal. |
646 | 60 | void OnDestroyNotify(nux::Trackable* Object, std::string key); | 62 | void OnDestroyNotify(nux::Trackable* Object, std::string const& key); |
647 | 61 | 63 | ||
648 | 62 | std::map<std::string, nux::BaseTexture*> cache_; | 64 | std::map<std::string, nux::BaseTexture*> cache_; |
649 | 63 | }; | 65 | }; |
650 | 64 | 66 | ||
651 | === modified file 'unity-shared/WindowButtons.cpp' | |||
652 | --- unity-shared/WindowButtons.cpp 2013-03-19 18:47:01 +0000 | |||
653 | +++ unity-shared/WindowButtons.cpp 2013-04-09 01:09:21 +0000 | |||
654 | @@ -29,6 +29,7 @@ | |||
655 | 29 | #include "WindowButtons.h" | 29 | #include "WindowButtons.h" |
656 | 30 | #include "WindowButtonPriv.h" | 30 | #include "WindowButtonPriv.h" |
657 | 31 | 31 | ||
658 | 32 | #include "unity-shared/TextureCache.h" | ||
659 | 32 | #include "unity-shared/UBusMessages.h" | 33 | #include "unity-shared/UBusMessages.h" |
660 | 33 | #include "unity-shared/WindowManager.h" | 34 | #include "unity-shared/WindowManager.h" |
661 | 34 | 35 | ||
662 | @@ -176,8 +177,8 @@ | |||
663 | 176 | 177 | ||
664 | 177 | std::string subpath = names[static_cast<int>(type)] + states[static_cast<int>(state)] + ".png"; | 178 | std::string subpath = names[static_cast<int>(type)] + states[static_cast<int>(state)] + ".png"; |
665 | 178 | 179 | ||
668 | 179 | glib::String filename(g_build_filename(PKGDATADIR, subpath.c_str(), NULL)); | 180 | auto& cache = TextureCache::GetDefault(); |
669 | 180 | texture.Adopt(nux::CreateTexture2DFromFile(filename, -1, true)); | 181 | texture = cache.FindTexture(subpath); |
670 | 181 | 182 | ||
671 | 182 | if (!texture) | 183 | if (!texture) |
672 | 183 | texture = panel::Style::Instance().GetFallbackWindowButton(type, state); | 184 | texture = panel::Style::Instance().GetFallbackWindowButton(type, state); |
494 glib::Object< GtkStyleContext > _style_context; GSettings> _gsettings;
495 glib::Object<
496 + BaseTexturePtr _bg_texture;
497 std::string _theme_name;
498 nux::Color _text_color;
Someday the naming of these variables will have to be fixed :)