Nux

Merge lp:~unity-team/nux/nux.lazy-load-graphics into lp:nux/2.0

Proposed by Jason Smith
Status: Merged
Approved by: Jason Smith
Approved revision: 562
Merged at revision: 560
Proposed branch: lp:~unity-team/nux/nux.lazy-load-graphics
Merge into: lp:nux/2.0
Diff against target: 334 lines (+66/-87)
4 files modified
Nux/View.cpp (+2/-1)
Nux/View.h (+1/-1)
NuxGraphics/GraphicsEngine.cpp (+31/-69)
NuxGraphics/RenderingPipeGLSL.cpp (+32/-16)
To merge this branch: bzr merge lp:~unity-team/nux/nux.lazy-load-graphics
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Thomi Richards (community) Approve
Review via email: mp+92211@code.launchpad.net

Description of the change

Makes nux lazy load some of its less frequently use, yet more expensive objects

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

This looks fine to me, but someone who knows nux should look over it as well.

review: Approve
Revision history for this message
Jay Taoko (jaytaoko) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/View.cpp'
2--- Nux/View.cpp 2012-01-24 23:16:53 +0000
3+++ Nux/View.cpp 2012-02-09 06:06:19 +0000
4@@ -33,7 +33,6 @@
5 View::View(NUX_FILE_LINE_DECL)
6 : InputArea(NUX_FILE_LINE_PARAM)
7 {
8- _font = GetSysFont();
9 view_layout_ = NULL;
10 draw_cmd_queued_ = false;
11 m_TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f);
12@@ -369,6 +368,8 @@
13
14 ObjectPtr<FontTexture> View::GetFont()
15 {
16+ if (!_font.IsValid())
17+ _font = GetSysFont();
18 return _font;
19 }
20
21
22=== modified file 'Nux/View.h'
23--- Nux/View.h 2012-01-02 21:43:19 +0000
24+++ Nux/View.h 2012-02-09 06:06:19 +0000
25@@ -166,7 +166,6 @@
26 void InitializeLayout();
27
28 Color m_TextColor;
29- ObjectPtr<FontTexture> _font;
30
31 //! Deprecated. Use GetLayout();
32 virtual Layout* GetCompositionLayout();
33@@ -201,6 +200,7 @@
34 bool full_view_draw_cmd_; //<! True if Draw is called before ContentDraw. It is read-only and can be accessed by calling IsFullRedraw();
35
36 private:
37+ ObjectPtr<FontTexture> _font;
38
39 friend class WindowCompositor;
40 friend class Layout;
41
42=== modified file 'NuxGraphics/GraphicsEngine.cpp'
43--- NuxGraphics/GraphicsEngine.cpp 2012-01-23 01:02:28 +0000
44+++ NuxGraphics/GraphicsEngine.cpp 2012-02-09 06:06:19 +0000
45@@ -196,31 +196,7 @@
46 if (create_rendering_data)
47 {
48 #ifndef NUX_OPENGLES_20
49- if (UsingGLSLCodePath() &&
50- _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
51- _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Shader() &&
52- opengl_14_support)
53- {
54- InitSlColorShader();
55- InitSlTextureShader();
56- InitSlPixelateShader();
57- InitSlColorModTexMaskAlpha();
58- InitSl2TextureAdd();
59- InitSl2TextureMod();
60- InitSl4TextureAdd();
61-
62- InitSLPower();
63- InitSLAlphaReplicate();
64- InitSLHorizontalGaussFilter();
65- InitSLVerticalGaussFilter();
66- InitSLColorMatrixFilter();
67-
68- InitSl2TextureDepRead();
69-
70- InitSLHorizontalHQGaussFilter(1);
71- InitSLVerticalHQGaussFilter(1);
72- }
73- else if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
74+ if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
75 _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Program() &&
76 opengl_14_support)
77 {
78@@ -240,50 +216,6 @@
79
80 //InitAsm2TextureDepRead(); // NUXTODO: fix the shader
81 }
82-#else
83- InitSlColorShader();
84- InitSlTextureShader();
85- InitSlPixelateShader();
86- InitSlColorModTexMaskAlpha();
87- InitSl2TextureAdd();
88- InitSl2TextureMod();
89- InitSl4TextureAdd();
90-
91- InitSLPower();
92- InitSLAlphaReplicate();
93- InitSLHorizontalGaussFilter();
94- InitSLVerticalGaussFilter();
95- InitSLColorMatrixFilter();
96-#endif
97-
98-#if defined(NUX_OS_WINDOWS)
99- if (_normal_font.IsNull())
100- {
101- FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
102- _normal_font = ObjectPtr<FontTexture> (fnt);
103- fnt->UnReference();
104- }
105-
106- if (_bold_font.IsNull())
107- {
108- FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
109- _bold_font = ObjectPtr<FontTexture> (fnt);
110- fnt->UnReference();
111- }
112-#else
113- if (_normal_font.IsNull())
114- {
115- FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
116- _normal_font = ObjectPtr<FontTexture> (fnt);
117- fnt->UnReference();
118- }
119-
120- if (_bold_font.IsNull())
121- {
122- FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
123- _bold_font = ObjectPtr<FontTexture> (fnt);
124- fnt->UnReference();
125- }
126 #endif
127
128 GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo();
129@@ -364,11 +296,41 @@
130
131 ObjectPtr<FontTexture> GraphicsEngine::GetFont()
132 {
133+#if defined(NUX_OS_WINDOWS)
134+ if (_normal_font.IsNull())
135+ {
136+ FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
137+ _normal_font = ObjectPtr<FontTexture> (fnt);
138+ fnt->UnReference();
139+ }
140+#else
141+ if (_normal_font.IsNull())
142+ {
143+ FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
144+ _normal_font = ObjectPtr<FontTexture> (fnt);
145+ fnt->UnReference();
146+ }
147+#endif
148 return _normal_font;
149 }
150
151 ObjectPtr<FontTexture> GraphicsEngine::GetBoldFont()
152 {
153+ #if defined(NUX_OS_WINDOWS)
154+ if (_bold_font.IsNull())
155+ {
156+ FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
157+ _bold_font = ObjectPtr<FontTexture> (fnt);
158+ fnt->UnReference();
159+ }
160+#else
161+ if (_bold_font.IsNull())
162+ {
163+ FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
164+ _bold_font = ObjectPtr<FontTexture> (fnt);
165+ fnt->UnReference();
166+ }
167+#endif
168 return _bold_font;
169 }
170
171
172=== modified file 'NuxGraphics/RenderingPipeGLSL.cpp'
173--- NuxGraphics/RenderingPipeGLSL.cpp 2012-01-15 21:45:36 +0000
174+++ NuxGraphics/RenderingPipeGLSL.cpp 2012-02-09 06:06:19 +0000
175@@ -875,7 +875,8 @@
176
177 void GraphicsEngine::QRP_GLSL_Color(int x, int y, int width, int height, const Color &c0, const Color &c1, const Color &c2, const Color &c3)
178 {
179- NUX_RETURN_IF_FALSE(m_SlColor.IsValid());
180+ if (!m_SlColor.IsValid())
181+ InitSlColorShader();
182
183 m_quad_tex_stats++;
184
185@@ -922,7 +923,8 @@
186
187 void GraphicsEngine::QRP_GLSL_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0)
188 {
189- NUX_RETURN_IF_FALSE(m_SlTextureModColor.IsValid());
190+ if (!m_SlTextureModColor.IsValid())
191+ InitSlTextureShader();
192
193 m_quad_tex_stats++;
194 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);
195@@ -996,7 +998,8 @@
196 void GraphicsEngine::QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height,
197 ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color)
198 {
199- NUX_RETURN_IF_FALSE(m_SlColorModTexMaskAlpha.IsValid());
200+ if (!m_SlColorModTexMaskAlpha.IsValid())
201+ InitSlColorModTexMaskAlpha();
202
203 m_quad_tex_stats++;
204 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform);
205@@ -1083,7 +1086,8 @@
206 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
207 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)
208 {
209- NUX_RETURN_IF_FALSE(m_Sl2TextureAdd.IsValid());
210+ if (!m_Sl2TextureAdd.IsValid())
211+ InitSl2TextureAdd();
212
213 ObjectPtr<IOpenGLShaderProgram> ShaderProg;
214 ShaderProg = m_Sl2TextureAdd;
215@@ -1160,7 +1164,8 @@
216 ObjectPtr<IOpenGLBaseTexture> distorsion_texture, TexCoordXForm &texxform0, const Color& c0,
217 ObjectPtr<IOpenGLBaseTexture> src_device_texture, TexCoordXForm &texxform1, const Color& c1)
218 {
219- NUX_RETURN_IF_FALSE(m_Sl2TextureDepRead.IsValid());
220+ if (!m_Sl2TextureDepRead.IsValid())
221+ InitSl2TextureDepRead();
222
223 ObjectPtr<IOpenGLShaderProgram> ShaderProg = m_Sl2TextureDepRead;
224
225@@ -1235,7 +1240,8 @@
226 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
227 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)
228 {
229- NUX_RETURN_IF_FALSE(m_Sl2TextureMod.IsValid());
230+ if (!m_Sl2TextureMod.IsValid())
231+ InitSl2TextureMod();
232
233 ObjectPtr<IOpenGLShaderProgram> ShaderProg;
234 {
235@@ -1315,7 +1321,8 @@
236 ObjectPtr<IOpenGLBaseTexture> DeviceTexture2, TexCoordXForm &texxform2, const Color &color2,
237 ObjectPtr<IOpenGLBaseTexture> DeviceTexture3, TexCoordXForm &texxform3, const Color &color3)
238 {
239- NUX_RETURN_IF_FALSE(m_Sl4TextureAdd.IsValid());
240+ if (!m_Sl4TextureAdd.IsValid())
241+ InitSl4TextureAdd();
242
243 QRP_Compute_Texture_Coord(width, height, DeviceTexture0, texxform0);
244 QRP_Compute_Texture_Coord(width, height, DeviceTexture1, texxform1);
245@@ -1431,7 +1438,8 @@
246 int x2, int y2,
247 Color c0, Color c1, Color c2)
248 {
249- NUX_RETURN_IF_FALSE(m_SlColor.IsValid());
250+ if (!m_SlColor.IsValid())
251+ InitSlColorShader();
252
253 float VtxBuffer[] =
254 {
255@@ -1479,7 +1487,8 @@
256 void GraphicsEngine::QRP_GLSL_Line(int x0, int y0,
257 int x1, int y1, Color c0, Color c1)
258 {
259- NUX_RETURN_IF_FALSE(m_SlColor.IsValid());
260+ if (!m_SlColor.IsValid())
261+ InitSlColorShader();
262
263 float VtxBuffer[] =
264 {
265@@ -1542,7 +1551,8 @@
266 Color c2,
267 Color c3)
268 {
269- NUX_RETURN_IF_FALSE(m_SlColor.IsValid());
270+ if (!m_SlColor.IsValid())
271+ InitSlColorShader();
272
273 float fx0 = x0, fy0 = y0;
274 float VtxBuffer[] =
275@@ -1605,7 +1615,8 @@
276
277 void GraphicsEngine::QRP_GLSL_Power(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, Vector4 exponent)
278 {
279- NUX_RETURN_IF_FALSE(_component_exponentiation_prog.IsValid());
280+ if (!_component_exponentiation_prog.IsValid())
281+ InitSLPower();
282
283 m_quad_tex_stats++;
284 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
285@@ -1671,7 +1682,8 @@
286
287 void GraphicsEngine::QRP_GLSL_AlphaReplicate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0)
288 {
289- NUX_RETURN_IF_FALSE(_alpha_replicate_prog.IsValid());
290+ if (!_alpha_replicate_prog.IsValid())
291+ InitSLAlphaReplicate();
292
293 m_quad_tex_stats++;
294 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
295@@ -1734,7 +1746,8 @@
296
297 void GraphicsEngine::QRP_GLSL_HorizontalGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, float sigma)
298 {
299- NUX_RETURN_IF_FALSE(_horizontal_gauss_filter_prog.IsValid());
300+ if (!_horizontal_gauss_filter_prog.IsValid())
301+ InitSLHorizontalGaussFilter();
302
303 m_quad_tex_stats++;
304 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
305@@ -1805,7 +1818,8 @@
306
307 void GraphicsEngine::QRP_GLSL_VerticalGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, float sigma)
308 {
309- NUX_RETURN_IF_FALSE(_vertical_gauss_filter_prog.IsValid());
310+ if (!_vertical_gauss_filter_prog.IsValid())
311+ InitSLVerticalGaussFilter();
312
313 m_quad_tex_stats++;
314 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
315@@ -2035,7 +2049,8 @@
316 Matrix4 color_matrix,
317 Vector4 offset)
318 {
319- NUX_RETURN_IF_FALSE(_color_matrix_filter_prog.IsValid());
320+ if (!_color_matrix_filter_prog.IsValid())
321+ InitSLColorMatrixFilter();
322
323 m_quad_tex_stats++;
324 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
325@@ -2673,7 +2688,8 @@
326
327 void GraphicsEngine::QRP_GLSL_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0, int pixel_size)
328 {
329- NUX_RETURN_IF_FALSE(m_SLPixelate.IsValid());
330+ if (!m_SLPixelate.IsValid())
331+ InitSlPixelateShader();
332
333 m_quad_tex_stats++;
334 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);

Subscribers

People subscribed via source and target branches

to all changes: