Nux

Merge lp:~unity-team/nux/nux.fix-pango-abuse into lp:nux/2.0

Proposed by Jason Smith
Status: Merged
Approved by: Jason Smith
Approved revision: 553
Merged at revision: 552
Proposed branch: lp:~unity-team/nux/nux.fix-pango-abuse
Merge into: lp:nux/2.0
Diff against target: 58 lines (+15/-1)
2 files modified
Nux/StaticText.cpp (+14/-1)
Nux/StaticText.h (+1/-0)
To merge this branch: bzr merge lp:~unity-team/nux/nux.fix-pango-abuse
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Jay Taoko (community) Approve
Review via email: mp+91315@code.launchpad.net

Description of the change

UNBLOCK

Fixes severe slowness when laying lots of these bad boys out

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Please add a comment about what no_clip_size_ does in the .h. This will help preserve it in the future.
+1

review: Approve
Revision history for this message
Gord Allott (gordallott) wrote :

looks sane to me

review: Approve
553. By Jason Smith

add comment to explain stuff

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/StaticText.cpp'
2--- Nux/StaticText.cpp 2012-01-17 04:34:19 +0000
3+++ Nux/StaticText.cpp 2012-02-02 17:16:19 +0000
4@@ -267,6 +267,9 @@
5 pango_font_name_ = std::string(os.str());
6 #endif
7
8+ // reset cache
9+ no_clip_size_.width = 0;
10+ no_clip_size_.height = 0;
11 // Changing the font can cause the StaticView to resize itself.
12 Size sz = GetTextSizeNoClip();
13 // Calling SetBaseSize will trigger a layout request of this view and all of its parents.
14@@ -295,6 +298,10 @@
15
16 text_ = text;
17
18+ // reset cache
19+ no_clip_size_.width = 0;
20+ no_clip_size_.height = 0;
21+
22 // Changing the font can cause the StaticView to resize itself.
23 Size sz = GetTextSizeNoClip();
24 // Calling SetBaseSize will trigger a layout request of this view and all of its parents.
25@@ -332,6 +339,10 @@
26 os << font_name_ << " " << font_size_;
27 pango_font_name_ = std::string(os.str());
28 #endif
29+
30+ // reset cache
31+ no_clip_size_.width = 0;
32+ no_clip_size_.height = 0;
33
34 // Changing the font can cause the StaticView to resize itself.
35 Size sz = GetTextSizeNoClip();
36@@ -377,7 +388,9 @@
37
38 Size StaticText::GetTextSizeNoClip()
39 {
40- return ComputeTextSize(false, false);
41+ if (no_clip_size_.width == 0)
42+ no_clip_size_ = ComputeTextSize(false, false);
43+ return no_clip_size_;
44 }
45
46 #if defined(NUX_STATIC_TEXT_USE_DIRECT_WRITE)
47
48=== modified file 'Nux/StaticText.h'
49--- Nux/StaticText.h 2012-01-17 04:34:19 +0000
50+++ Nux/StaticText.h 2012-02-02 17:16:19 +0000
51@@ -192,6 +192,7 @@
52 Size GetTextSizeNoClip();
53 float padding_x_; //!< Adds a padding around the entire text box.
54 float padding_y_; //!< Adds a padding around the entire text box.
55+ Size no_clip_size_; //! Cacne of the GetTextSizeNoClip results so we don't recompute them constantly.
56 };
57
58 }

Subscribers

People subscribed via source and target branches

to all changes: