summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-08-05 12:04:29 -0700
committerGraham Linden <graham@lindenlab.com>2019-08-05 12:04:29 -0700
commit76128c4357bc36acd54575153516c6d337fe4263 (patch)
tree7910d8415bf394fd15f5dca35dd3779b39acc15a /indra/llrender
parent9bb6da1e76efa951da7e740f80b1e4e72e67b878 (diff)
SL-10566 Use vector for some high-traffic, low-item count containers instead of list.
Provide method of storing joint indices sep from weight data for faster runtime processing.
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/CMakeLists.txt1
-rw-r--r--indra/llrender/lluiimage.cpp89
-rw-r--r--indra/llrender/lluiimage.h50
-rw-r--r--indra/llrender/lluiimage.inl77
4 files changed, 125 insertions, 92 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt
index 589cf86745..47e7ad915b 100644
--- a/indra/llrender/CMakeLists.txt
+++ b/indra/llrender/CMakeLists.txt
@@ -80,6 +80,7 @@ set(llrender_HEADER_FILES
llshadermgr.h
lltexture.h
lluiimage.h
+ lluiimage.inl
llvertexbuffer.h
llglcommonfunc.h
)
diff --git a/indra/llrender/lluiimage.cpp b/indra/llrender/lluiimage.cpp
index 5d8f92b2e6..db69806097 100644
--- a/indra/llrender/lluiimage.cpp
+++ b/indra/llrender/lluiimage.cpp
@@ -31,7 +31,6 @@
// Project includes
#include "lluiimage.h"
-#include "llrender2dutils.h"
LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
: mName(name),
@@ -39,67 +38,29 @@ LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
mScaleRegion(0.f, 1.f, 1.f, 0.f),
mClipRegion(0.f, 1.f, 1.f, 0.f),
mImageLoaded(NULL),
- mScaleStyle(SCALE_INNER)
-{}
+ mScaleStyle(SCALE_INNER),
+ mCachedW(-1),
+ mCachedH(-1)
+{
+ getTextureWidth();
+ getTextureHeight();
+}
LLUIImage::~LLUIImage()
{
delete mImageLoaded;
}
-void LLUIImage::setClipRegion(const LLRectf& region)
+S32 LLUIImage::getWidth() const
{
- mClipRegion = region;
+ // return clipped dimensions of actual image area
+ return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth());
}
-void LLUIImage::setScaleRegion(const LLRectf& region)
+S32 LLUIImage::getHeight() const
{
- mScaleRegion = region;
-}
-
-void LLUIImage::setScaleStyle(LLUIImage::EScaleStyle style)
-{
- mScaleStyle = style;
-}
-
-//TODO: move drawing implementation inside class
-void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const
-{
- draw(x, y, getWidth(), getHeight(), color);
-}
-
-void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
-{
- gl_draw_scaled_image_with_border(
- x, y,
- width, height,
- mImage,
- color,
- FALSE,
- mClipRegion,
- mScaleRegion,
- mScaleStyle == SCALE_INNER);
-}
-
-void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
-{
- gl_draw_scaled_image_with_border(
- x, y,
- width, height,
- mImage,
- color,
- TRUE,
- mClipRegion,
- mScaleRegion,
- mScaleStyle == SCALE_INNER);
-}
-
-void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
-{
- LLRect border_rect;
- border_rect.setOriginAndSize(x, y, width, height);
- border_rect.stretch(border_width, border_width);
- drawSolid(border_rect, color);
+ // return clipped dimensions of actual image area
+ return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight());
}
void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, const LLVector3& y_axis,
@@ -145,28 +106,7 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c
} LLRender2D::popMatrix();
}
-
-S32 LLUIImage::getWidth() const
-{
- // return clipped dimensions of actual image area
- return ll_round((F32)mImage->getWidth(0) * mClipRegion.getWidth());
-}
-
-S32 LLUIImage::getHeight() const
-{
- // return clipped dimensions of actual image area
- return ll_round((F32)mImage->getHeight(0) * mClipRegion.getHeight());
-}
-
-S32 LLUIImage::getTextureWidth() const
-{
- return mImage->getWidth(0);
-}
-
-S32 LLUIImage::getTextureHeight() const
-{
- return mImage->getHeight(0);
-}
+//#include "lluiimage.inl"
boost::signals2::connection LLUIImage::addLoadedCallback( const image_loaded_signal_t::slot_type& cb )
{
@@ -186,7 +126,6 @@ void LLUIImage::onImageLoaded()
}
}
-
namespace LLInitParam
{
void ParamValue<LLUIImage*>::updateValueFromBlock()
diff --git a/indra/llrender/lluiimage.h b/indra/llrender/lluiimage.h
index 6f47385eb0..e462e19004 100644
--- a/indra/llrender/lluiimage.h
+++ b/indra/llrender/lluiimage.h
@@ -36,6 +36,7 @@
#include <boost/signals2.hpp>
#include "llinitparam.h"
#include "lltexture.h"
+#include "llrender2dutils.h"
extern const LLColor4 UI_VERTEX_COLOR;
@@ -53,35 +54,46 @@ public:
LLUIImage(const std::string& name, LLPointer<LLTexture> image);
virtual ~LLUIImage();
- void setClipRegion(const LLRectf& region);
- void setScaleRegion(const LLRectf& region);
- void setScaleStyle(EScaleStyle style);
+ LL_FORCE_INLINE void setClipRegion(const LLRectf& region)
+ {
+ mClipRegion = region;
+ }
- LLPointer<LLTexture> getImage() { return mImage; }
- const LLPointer<LLTexture>& getImage() const { return mImage; }
+ LL_FORCE_INLINE void setScaleRegion(const LLRectf& region)
+ {
+ mScaleRegion = region;
+ }
- void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
- void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
- void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
+ LL_FORCE_INLINE void setScaleStyle(EScaleStyle style)
+ {
+ mScaleStyle = style;
+ }
+
+ LL_FORCE_INLINE LLPointer<LLTexture> getImage() { return mImage; }
+ LL_FORCE_INLINE const LLPointer<LLTexture>& getImage() const { return mImage; }
+
+ LL_FORCE_INLINE void draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color = UI_VERTEX_COLOR) const;
+ LL_FORCE_INLINE void draw(S32 x, S32 y, const LLColor4& color = UI_VERTEX_COLOR) const;
+ LL_FORCE_INLINE void draw(const LLRect& rect, const LLColor4& color = UI_VERTEX_COLOR) const { draw(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
- void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
- void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
- void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); }
+ LL_FORCE_INLINE void drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const;
+ LL_FORCE_INLINE void drawSolid(const LLRect& rect, const LLColor4& color) const { drawSolid(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color); }
+ LL_FORCE_INLINE void drawSolid(S32 x, S32 y, const LLColor4& color) const { drawSolid(x, y, getWidth(), getHeight(), color); }
- void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
- void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
- void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); }
+ LL_FORCE_INLINE void drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const;
+ LL_FORCE_INLINE void drawBorder(const LLRect& rect, const LLColor4& color, S32 border_width) const { drawBorder(rect.mLeft, rect.mBottom, rect.getWidth(), rect.getHeight(), color, border_width); }
+ LL_FORCE_INLINE void drawBorder(S32 x, S32 y, const LLColor4& color, S32 border_width) const { drawBorder(x, y, getWidth(), getHeight(), color, border_width); }
void draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, const LLVector3& y_axis, const LLRect& rect, const LLColor4& color);
- const std::string& getName() const { return mName; }
+ LL_FORCE_INLINE const std::string& getName() const { return mName; }
virtual S32 getWidth() const;
virtual S32 getHeight() const;
// returns dimensions of underlying textures, which might not be equal to ui image portion
- S32 getTextureWidth() const;
- S32 getTextureHeight() const;
+ LL_FORCE_INLINE S32 getTextureWidth() const;
+ LL_FORCE_INLINE S32 getTextureHeight() const;
boost::signals2::connection addLoadedCallback( const image_loaded_signal_t::slot_type& cb );
@@ -95,8 +107,12 @@ protected:
LLRectf mClipRegion;
LLPointer<LLTexture> mImage;
EScaleStyle mScaleStyle;
+ mutable S32 mCachedW;
+ mutable S32 mCachedH;
};
+#include "lluiimage.inl"
+
namespace LLInitParam
{
template<>
diff --git a/indra/llrender/lluiimage.inl b/indra/llrender/lluiimage.inl
new file mode 100644
index 0000000000..3b23d77d62
--- /dev/null
+++ b/indra/llrender/lluiimage.inl
@@ -0,0 +1,77 @@
+/**
+ * @file lluiimage.inl
+ * @brief UI inline func implementation
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+void LLUIImage::draw(S32 x, S32 y, const LLColor4& color) const
+{
+ draw(x, y, getWidth(), getHeight(), color);
+}
+
+void LLUIImage::draw(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
+{
+ gl_draw_scaled_image_with_border(
+ x, y,
+ width, height,
+ mImage,
+ color,
+ FALSE,
+ mClipRegion,
+ mScaleRegion,
+ mScaleStyle == SCALE_INNER);
+}
+
+void LLUIImage::drawSolid(S32 x, S32 y, S32 width, S32 height, const LLColor4& color) const
+{
+ gl_draw_scaled_image_with_border(
+ x, y,
+ width, height,
+ mImage,
+ color,
+ TRUE,
+ mClipRegion,
+ mScaleRegion,
+ mScaleStyle == SCALE_INNER);
+}
+
+void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& color, S32 border_width) const
+{
+ LLRect border_rect;
+ border_rect.setOriginAndSize(x, y, width, height);
+ border_rect.stretch(border_width, border_width);
+ drawSolid(border_rect, color);
+}
+
+// returns dimensions of underlying textures, which might not be equal to ui image portion
+S32 LLUIImage::getTextureWidth() const
+{
+ mCachedW = (mCachedW == -1) ? getWidth() : mCachedW;
+ return mCachedW;
+}
+
+S32 LLUIImage::getTextureHeight() const
+{
+ mCachedH = (mCachedH == -1) ? getHeight() : mCachedH;
+ return mCachedH;
+}