Skip to content
This repository
Browse code

Merge pull request #3091 from stupid-boy/GUIControl

Small CGUIControl optimization
  • Loading branch information...
commit 6b3ff42a52c241caaaf0596ab0a3417bf1f04c7a 2 parents 602e9f2 + 7e37c96
Martijn Kaijser authored August 19, 2013

Showing 1 changed file with 31 additions and 21 deletions. Show diff stats Hide diff stats

  1. 52  xbmc/guilib/GUIControl.cpp
52  xbmc/guilib/GUIControl.cpp
@@ -133,29 +133,34 @@ void CGUIControl::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyreg
133 133
 
134 134
   changed |= Animate(currentTime);
135 135
 
136  
-  m_cachedTransform = g_graphicsContext.AddTransform(m_transform);
137  
-  if (m_hasCamera)
138  
-    g_graphicsContext.SetCameraPosition(m_camera);
139  
-
140 136
   if (IsVisible())
141 137
   {
  138
+    m_cachedTransform = g_graphicsContext.AddTransform(m_transform);
  139
+    if (m_hasCamera)
  140
+      g_graphicsContext.SetCameraPosition(m_camera);
  141
+
142 142
     Process(currentTime, dirtyregions);
143 143
     m_bInvalidated = false;
144  
-  }
145 144
 
146  
-  changed |=  m_controlIsDirty;
  145
+    if (dirtyRegion != m_renderRegion)
  146
+    {
  147
+      dirtyRegion.Union(m_renderRegion);
  148
+      changed = true;
  149
+    }
147 150
 
148  
-  if (changed || dirtyRegion != m_renderRegion)
149  
-  {
150  
-    dirtyRegion.Union(m_renderRegion);
151  
-    dirtyregions.push_back(dirtyRegion);
  151
+    if (m_hasCamera)
  152
+      g_graphicsContext.RestoreCameraPosition();
  153
+    g_graphicsContext.RemoveTransform();
152 154
   }
153 155
 
154  
-  if (m_hasCamera)
155  
-    g_graphicsContext.RestoreCameraPosition();
156  
-  g_graphicsContext.RemoveTransform();
  156
+  changed |= m_controlIsDirty;
157 157
 
158 158
   m_controlIsDirty = false;
  159
+
  160
+  if (changed)
  161
+  {
  162
+    dirtyregions.push_back(dirtyRegion);
  163
+  }
159 164
 }
160 165
 
161 166
 void CGUIControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
@@ -171,18 +176,20 @@ void CGUIControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregio
171 176
 // 3. reset the animation transform
172 177
 void CGUIControl::DoRender()
173 178
 {
174  
-  g_graphicsContext.SetTransform(m_cachedTransform);
175  
-  if (m_hasCamera)
176  
-    g_graphicsContext.SetCameraPosition(m_camera);
177 179
   if (IsVisible())
178 180
   {
  181
+    g_graphicsContext.SetTransform(m_cachedTransform);
  182
+    if (m_hasCamera)
  183
+      g_graphicsContext.SetCameraPosition(m_camera);
  184
+
179 185
     GUIPROFILER_RENDER_BEGIN(this);
180 186
     Render();
181 187
     GUIPROFILER_RENDER_END(this);
  188
+
  189
+    if (m_hasCamera)
  190
+      g_graphicsContext.RestoreCameraPosition();
  191
+    g_graphicsContext.RemoveTransform();
182 192
   }
183  
-  if (m_hasCamera)
184  
-    g_graphicsContext.RestoreCameraPosition();
185  
-  g_graphicsContext.RemoveTransform();
186 193
 }
187 194
 
188 195
 bool CGUIControl::OnAction(const CAction &action)
@@ -586,8 +593,11 @@ bool CGUIControl::OnMouseOver(const CPoint &point)
586 593
   if (g_Mouse.GetState() != MOUSE_STATE_DRAG)
587 594
     g_Mouse.SetState(MOUSE_STATE_FOCUS);
588 595
   if (!CanFocus()) return false;
589  
-  CGUIMessage msg(GUI_MSG_SETFOCUS, GetParentID(), GetID());
590  
-  OnMessage(msg);
  596
+  if (!HasFocus())
  597
+  {
  598
+    CGUIMessage msg(GUI_MSG_SETFOCUS, GetParentID(), GetID());
  599
+    OnMessage(msg);
  600
+  }
591 601
   return true;
592 602
 }
593 603
 

0 notes on commit 6b3ff42

Please sign in to comment.
Something went wrong with that request. Please try again.