Sfoglia il codice sorgente

If UI element does not have a gradient, only convert the color once.

Lasse Öörni 12 anni fa
parent
commit
f166775a1d
2 ha cambiato i file con 7 aggiunte e 5 eliminazioni
  1. 4 4
      Engine/UI/UIBatch.cpp
  2. 3 1
      Engine/UI/UIBatch.h

+ 4 - 4
Engine/UI/UIBatch.cpp

@@ -56,13 +56,13 @@ UIBatch::UIBatch(UIElement* element, BlendMode blendMode, const IntRect& scissor
     scissor_(scissor),
     texture_(texture),
     invTextureSize_(texture ? Vector2(1.0f / (float)texture->GetWidth(), 1.0f / (float)texture->GetHeight()) : Vector2::ONE),
+    fixedColor_(element->GetDerivedColor().ToUInt()),
     vertexData_(vertexData),
     vertexStart_(vertexData->Size()),
     vertexEnd_(vertexData->Size())
 {
 }
 
-
 void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int texOffsetY, int texWidth, int texHeight,
     Color* color)
 {
@@ -70,7 +70,7 @@ void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int t
 
     if (color || !element_->HasColorGradient())
     {
-        unsigned uintColor = (color ? *color : element_->GetDerivedColor()).ToUInt();
+        unsigned uintColor = color ? color->ToUInt() : fixedColor_;
         
         // If alpha is 0, nothing will be rendered, so do not add the quad
         if (!(uintColor & 0xff000000))
@@ -132,13 +132,13 @@ void UIBatch::AddQuad(int x, int y, int width, int height, int texOffsetX, int t
 }
 
 void UIBatch::AddQuad(const Matrix3x4& transform, int x, int y, int width, int height, int texOffsetX, int texOffsetY,
-    int texWidth, int texHeight, Color* color) 
+    int texWidth, int texHeight, Color* color)
 {
     unsigned topLeftColor, topRightColor, bottomLeftColor, bottomRightColor;
     
     if (color || !element_->HasColorGradient())
     {
-        unsigned uintColor = (color ? *color : element_->GetDerivedColor()).ToUInt();
+        unsigned uintColor = color ? color->ToUInt() : fixedColor_;
         
         // If alpha is 0, nothing will be rendered, so do not add the quad
         if (!(uintColor & 0xff000000))

+ 3 - 1
Engine/UI/UIBatch.h

@@ -71,7 +71,9 @@ public:
     Texture* texture_;
     /// Inverse texture size.
     Vector2 invTextureSize_;
-    /// Vertex data
+    /// Element color if not using a gradient.
+    unsigned fixedColor_;
+    /// Vertex data.
     PODVector<float>* vertexData_;
     /// Vertex data start index.
     unsigned vertexStart_;