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
=== modified file 'Nux/View.cpp'
--- Nux/View.cpp 2012-01-24 23:16:53 +0000
+++ Nux/View.cpp 2012-02-09 06:06:19 +0000
@@ -33,7 +33,6 @@
33 View::View(NUX_FILE_LINE_DECL)33 View::View(NUX_FILE_LINE_DECL)
34 : InputArea(NUX_FILE_LINE_PARAM)34 : InputArea(NUX_FILE_LINE_PARAM)
35 {35 {
36 _font = GetSysFont();
37 view_layout_ = NULL;36 view_layout_ = NULL;
38 draw_cmd_queued_ = false;37 draw_cmd_queued_ = false;
39 m_TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f);38 m_TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f);
@@ -369,6 +368,8 @@
369368
370 ObjectPtr<FontTexture> View::GetFont()369 ObjectPtr<FontTexture> View::GetFont()
371 {370 {
371 if (!_font.IsValid())
372 _font = GetSysFont();
372 return _font;373 return _font;
373 }374 }
374375
375376
=== modified file 'Nux/View.h'
--- Nux/View.h 2012-01-02 21:43:19 +0000
+++ Nux/View.h 2012-02-09 06:06:19 +0000
@@ -166,7 +166,6 @@
166 void InitializeLayout();166 void InitializeLayout();
167167
168 Color m_TextColor;168 Color m_TextColor;
169 ObjectPtr<FontTexture> _font;
170169
171 //! Deprecated. Use GetLayout();170 //! Deprecated. Use GetLayout();
172 virtual Layout* GetCompositionLayout();171 virtual Layout* GetCompositionLayout();
@@ -201,6 +200,7 @@
201 bool full_view_draw_cmd_; //<! True if Draw is called before ContentDraw. It is read-only and can be accessed by calling IsFullRedraw();200 bool full_view_draw_cmd_; //<! True if Draw is called before ContentDraw. It is read-only and can be accessed by calling IsFullRedraw();
202201
203 private:202 private:
203 ObjectPtr<FontTexture> _font;
204204
205 friend class WindowCompositor;205 friend class WindowCompositor;
206 friend class Layout;206 friend class Layout;
207207
=== modified file 'NuxGraphics/GraphicsEngine.cpp'
--- NuxGraphics/GraphicsEngine.cpp 2012-01-23 01:02:28 +0000
+++ NuxGraphics/GraphicsEngine.cpp 2012-02-09 06:06:19 +0000
@@ -196,31 +196,7 @@
196 if (create_rendering_data)196 if (create_rendering_data)
197 {197 {
198#ifndef NUX_OPENGLES_20198#ifndef NUX_OPENGLES_20
199 if (UsingGLSLCodePath() &&199 if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
200 _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
201 _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Shader() &&
202 opengl_14_support)
203 {
204 InitSlColorShader();
205 InitSlTextureShader();
206 InitSlPixelateShader();
207 InitSlColorModTexMaskAlpha();
208 InitSl2TextureAdd();
209 InitSl2TextureMod();
210 InitSl4TextureAdd();
211
212 InitSLPower();
213 InitSLAlphaReplicate();
214 InitSLHorizontalGaussFilter();
215 InitSLVerticalGaussFilter();
216 InitSLColorMatrixFilter();
217
218 InitSl2TextureDepRead();
219
220 InitSLHorizontalHQGaussFilter(1);
221 InitSLVerticalHQGaussFilter(1);
222 }
223 else if (_graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Fragment_Shader() &&
224 _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Program() &&200 _graphics_display.GetGpuDevice()->GetGpuInfo().Support_ARB_Vertex_Program() &&
225 opengl_14_support)201 opengl_14_support)
226 {202 {
@@ -240,50 +216,6 @@
240216
241 //InitAsm2TextureDepRead(); // NUXTODO: fix the shader217 //InitAsm2TextureDepRead(); // NUXTODO: fix the shader
242 }218 }
243#else
244 InitSlColorShader();
245 InitSlTextureShader();
246 InitSlPixelateShader();
247 InitSlColorModTexMaskAlpha();
248 InitSl2TextureAdd();
249 InitSl2TextureMod();
250 InitSl4TextureAdd();
251
252 InitSLPower();
253 InitSLAlphaReplicate();
254 InitSLHorizontalGaussFilter();
255 InitSLVerticalGaussFilter();
256 InitSLColorMatrixFilter();
257#endif
258
259#if defined(NUX_OS_WINDOWS)
260 if (_normal_font.IsNull())
261 {
262 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
263 _normal_font = ObjectPtr<FontTexture> (fnt);
264 fnt->UnReference();
265 }
266
267 if (_bold_font.IsNull())
268 {
269 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
270 _bold_font = ObjectPtr<FontTexture> (fnt);
271 fnt->UnReference();
272 }
273#else
274 if (_normal_font.IsNull())
275 {
276 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
277 _normal_font = ObjectPtr<FontTexture> (fnt);
278 fnt->UnReference();
279 }
280
281 if (_bold_font.IsNull())
282 {
283 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
284 _bold_font = ObjectPtr<FontTexture> (fnt);
285 fnt->UnReference();
286 }
287#endif219#endif
288220
289 GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo();221 GpuInfo& gpu_info = _graphics_display.GetGpuDevice()->GetGpuInfo();
@@ -364,11 +296,41 @@
364296
365 ObjectPtr<FontTexture> GraphicsEngine::GetFont()297 ObjectPtr<FontTexture> GraphicsEngine::GetFont()
366 {298 {
299#if defined(NUX_OS_WINDOWS)
300 if (_normal_font.IsNull())
301 {
302 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
303 _normal_font = ObjectPtr<FontTexture> (fnt);
304 fnt->UnReference();
305 }
306#else
307 if (_normal_font.IsNull())
308 {
309 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
310 _normal_font = ObjectPtr<FontTexture> (fnt);
311 fnt->UnReference();
312 }
313#endif
367 return _normal_font;314 return _normal_font;
368 }315 }
369316
370 ObjectPtr<FontTexture> GraphicsEngine::GetBoldFont()317 ObjectPtr<FontTexture> GraphicsEngine::GetBoldFont()
371 {318 {
319 #if defined(NUX_OS_WINDOWS)
320 if (_bold_font.IsNull())
321 {
322 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/Tahoma_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
323 _bold_font = ObjectPtr<FontTexture> (fnt);
324 fnt->UnReference();
325 }
326#else
327 if (_bold_font.IsNull())
328 {
329 FontTexture* fnt = new FontTexture(GNuxGraphicsResources.FindResourceLocation("Fonts/nuxfont_size_8_bold.txt", true).GetTCharPtr(), NUX_TRACKER_LOCATION);
330 _bold_font = ObjectPtr<FontTexture> (fnt);
331 fnt->UnReference();
332 }
333#endif
372 return _bold_font;334 return _bold_font;
373 }335 }
374336
375337
=== modified file 'NuxGraphics/RenderingPipeGLSL.cpp'
--- NuxGraphics/RenderingPipeGLSL.cpp 2012-01-15 21:45:36 +0000
+++ NuxGraphics/RenderingPipeGLSL.cpp 2012-02-09 06:06:19 +0000
@@ -875,7 +875,8 @@
875875
876 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)876 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)
877 {877 {
878 NUX_RETURN_IF_FALSE(m_SlColor.IsValid());878 if (!m_SlColor.IsValid())
879 InitSlColorShader();
879880
880 m_quad_tex_stats++;881 m_quad_tex_stats++;
881882
@@ -922,7 +923,8 @@
922923
923 void GraphicsEngine::QRP_GLSL_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0)924 void GraphicsEngine::QRP_GLSL_1Tex(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0)
924 {925 {
925 NUX_RETURN_IF_FALSE(m_SlTextureModColor.IsValid());926 if (!m_SlTextureModColor.IsValid())
927 InitSlTextureShader();
926928
927 m_quad_tex_stats++;929 m_quad_tex_stats++;
928 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);930 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);
@@ -996,7 +998,8 @@
996 void GraphicsEngine::QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height,998 void GraphicsEngine::QRP_GLSL_ColorModTexAlpha(int x, int y, int width, int height,
997 ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color)999 ObjectPtr< IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform, const Color &color)
998 {1000 {
999 NUX_RETURN_IF_FALSE(m_SlColorModTexMaskAlpha.IsValid());1001 if (!m_SlColorModTexMaskAlpha.IsValid())
1002 InitSlColorModTexMaskAlpha();
10001003
1001 m_quad_tex_stats++;1004 m_quad_tex_stats++;
1002 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform);1005 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform);
@@ -1083,7 +1086,8 @@
1083 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,1086 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
1084 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)1087 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)
1085 {1088 {
1086 NUX_RETURN_IF_FALSE(m_Sl2TextureAdd.IsValid());1089 if (!m_Sl2TextureAdd.IsValid())
1090 InitSl2TextureAdd();
10871091
1088 ObjectPtr<IOpenGLShaderProgram> ShaderProg;1092 ObjectPtr<IOpenGLShaderProgram> ShaderProg;
1089 ShaderProg = m_Sl2TextureAdd;1093 ShaderProg = m_Sl2TextureAdd;
@@ -1160,7 +1164,8 @@
1160 ObjectPtr<IOpenGLBaseTexture> distorsion_texture, TexCoordXForm &texxform0, const Color& c0,1164 ObjectPtr<IOpenGLBaseTexture> distorsion_texture, TexCoordXForm &texxform0, const Color& c0,
1161 ObjectPtr<IOpenGLBaseTexture> src_device_texture, TexCoordXForm &texxform1, const Color& c1)1165 ObjectPtr<IOpenGLBaseTexture> src_device_texture, TexCoordXForm &texxform1, const Color& c1)
1162 {1166 {
1163 NUX_RETURN_IF_FALSE(m_Sl2TextureDepRead.IsValid());1167 if (!m_Sl2TextureDepRead.IsValid())
1168 InitSl2TextureDepRead();
11641169
1165 ObjectPtr<IOpenGLShaderProgram> ShaderProg = m_Sl2TextureDepRead;1170 ObjectPtr<IOpenGLShaderProgram> ShaderProg = m_Sl2TextureDepRead;
11661171
@@ -1235,7 +1240,8 @@
1235 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,1240 ObjectPtr<IOpenGLBaseTexture> DeviceTexture0, TexCoordXForm &texxform0, const Color &color0,
1236 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)1241 ObjectPtr<IOpenGLBaseTexture> DeviceTexture1, TexCoordXForm &texxform1, const Color &color1)
1237 {1242 {
1238 NUX_RETURN_IF_FALSE(m_Sl2TextureMod.IsValid());1243 if (!m_Sl2TextureMod.IsValid())
1244 InitSl2TextureMod();
12391245
1240 ObjectPtr<IOpenGLShaderProgram> ShaderProg;1246 ObjectPtr<IOpenGLShaderProgram> ShaderProg;
1241 {1247 {
@@ -1315,7 +1321,8 @@
1315 ObjectPtr<IOpenGLBaseTexture> DeviceTexture2, TexCoordXForm &texxform2, const Color &color2,1321 ObjectPtr<IOpenGLBaseTexture> DeviceTexture2, TexCoordXForm &texxform2, const Color &color2,
1316 ObjectPtr<IOpenGLBaseTexture> DeviceTexture3, TexCoordXForm &texxform3, const Color &color3)1322 ObjectPtr<IOpenGLBaseTexture> DeviceTexture3, TexCoordXForm &texxform3, const Color &color3)
1317 {1323 {
1318 NUX_RETURN_IF_FALSE(m_Sl4TextureAdd.IsValid());1324 if (!m_Sl4TextureAdd.IsValid())
1325 InitSl4TextureAdd();
13191326
1320 QRP_Compute_Texture_Coord(width, height, DeviceTexture0, texxform0);1327 QRP_Compute_Texture_Coord(width, height, DeviceTexture0, texxform0);
1321 QRP_Compute_Texture_Coord(width, height, DeviceTexture1, texxform1);1328 QRP_Compute_Texture_Coord(width, height, DeviceTexture1, texxform1);
@@ -1431,7 +1438,8 @@
1431 int x2, int y2,1438 int x2, int y2,
1432 Color c0, Color c1, Color c2)1439 Color c0, Color c1, Color c2)
1433 {1440 {
1434 NUX_RETURN_IF_FALSE(m_SlColor.IsValid());1441 if (!m_SlColor.IsValid())
1442 InitSlColorShader();
14351443
1436 float VtxBuffer[] =1444 float VtxBuffer[] =
1437 {1445 {
@@ -1479,7 +1487,8 @@
1479 void GraphicsEngine::QRP_GLSL_Line(int x0, int y0,1487 void GraphicsEngine::QRP_GLSL_Line(int x0, int y0,
1480 int x1, int y1, Color c0, Color c1)1488 int x1, int y1, Color c0, Color c1)
1481 {1489 {
1482 NUX_RETURN_IF_FALSE(m_SlColor.IsValid());1490 if (!m_SlColor.IsValid())
1491 InitSlColorShader();
14831492
1484 float VtxBuffer[] =1493 float VtxBuffer[] =
1485 {1494 {
@@ -1542,7 +1551,8 @@
1542 Color c2,1551 Color c2,
1543 Color c3)1552 Color c3)
1544 {1553 {
1545 NUX_RETURN_IF_FALSE(m_SlColor.IsValid());1554 if (!m_SlColor.IsValid())
1555 InitSlColorShader();
15461556
1547 float fx0 = x0, fy0 = y0;1557 float fx0 = x0, fy0 = y0;
1548 float VtxBuffer[] =1558 float VtxBuffer[] =
@@ -1605,7 +1615,8 @@
16051615
1606 void GraphicsEngine::QRP_GLSL_Power(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, Vector4 exponent)1616 void GraphicsEngine::QRP_GLSL_Power(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, Vector4 exponent)
1607 {1617 {
1608 NUX_RETURN_IF_FALSE(_component_exponentiation_prog.IsValid());1618 if (!_component_exponentiation_prog.IsValid())
1619 InitSLPower();
16091620
1610 m_quad_tex_stats++;1621 m_quad_tex_stats++;
1611 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);1622 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
@@ -1671,7 +1682,8 @@
16711682
1672 void GraphicsEngine::QRP_GLSL_AlphaReplicate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0)1683 void GraphicsEngine::QRP_GLSL_AlphaReplicate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0)
1673 {1684 {
1674 NUX_RETURN_IF_FALSE(_alpha_replicate_prog.IsValid());1685 if (!_alpha_replicate_prog.IsValid())
1686 InitSLAlphaReplicate();
16751687
1676 m_quad_tex_stats++;1688 m_quad_tex_stats++;
1677 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);1689 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
@@ -1734,7 +1746,8 @@
17341746
1735 void GraphicsEngine::QRP_GLSL_HorizontalGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, float sigma)1747 void GraphicsEngine::QRP_GLSL_HorizontalGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, float sigma)
1736 {1748 {
1737 NUX_RETURN_IF_FALSE(_horizontal_gauss_filter_prog.IsValid());1749 if (!_horizontal_gauss_filter_prog.IsValid())
1750 InitSLHorizontalGaussFilter();
17381751
1739 m_quad_tex_stats++;1752 m_quad_tex_stats++;
1740 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);1753 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
@@ -1805,7 +1818,8 @@
18051818
1806 void GraphicsEngine::QRP_GLSL_VerticalGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, float sigma)1819 void GraphicsEngine::QRP_GLSL_VerticalGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color &c0, float sigma)
1807 {1820 {
1808 NUX_RETURN_IF_FALSE(_vertical_gauss_filter_prog.IsValid());1821 if (!_vertical_gauss_filter_prog.IsValid())
1822 InitSLVerticalGaussFilter();
18091823
1810 m_quad_tex_stats++;1824 m_quad_tex_stats++;
1811 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);1825 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
@@ -2035,7 +2049,8 @@
2035 Matrix4 color_matrix,2049 Matrix4 color_matrix,
2036 Vector4 offset)2050 Vector4 offset)
2037 {2051 {
2038 NUX_RETURN_IF_FALSE(_color_matrix_filter_prog.IsValid());2052 if (!_color_matrix_filter_prog.IsValid())
2053 InitSLColorMatrixFilter();
20392054
2040 m_quad_tex_stats++;2055 m_quad_tex_stats++;
2041 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);2056 QRP_Compute_Texture_Coord(width, height, device_texture, texxform0);
@@ -2673,7 +2688,8 @@
26732688
2674 void GraphicsEngine::QRP_GLSL_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0, int pixel_size)2689 void GraphicsEngine::QRP_GLSL_Pixelate(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> DeviceTexture, TexCoordXForm &texxform0, const Color &color0, int pixel_size)
2675 {2690 {
2676 NUX_RETURN_IF_FALSE(m_SLPixelate.IsValid());2691 if (!m_SLPixelate.IsValid())
2692 InitSlPixelateShader();
26772693
2678 m_quad_tex_stats++;2694 m_quad_tex_stats++;
2679 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);2695 QRP_Compute_Texture_Coord(width, height, DeviceTexture, texxform0);

Subscribers

People subscribed via source and target branches

to all changes: