diff options
author | Richard Linden <none@none> | 2010-07-23 22:07:15 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2010-07-23 22:07:15 -0700 |
commit | 6cc6f816780e64c5fb1e17a22fb5e473e75efe69 (patch) | |
tree | 0fb764971547fc3e8e8fad3ec7a1856b77fb1ac9 /indra/llui | |
parent | 4d2daeed21dfba9d6a40e88ecd92aaaa6df92ae1 (diff) |
first pass ui rendering performance improvements
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lllocalcliprect.cpp | 42 | ||||
-rw-r--r-- | indra/llui/lllocalcliprect.h | 26 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 15 |
3 files changed, 37 insertions, 46 deletions
diff --git a/indra/llui/lllocalcliprect.cpp b/indra/llui/lllocalcliprect.cpp index 43c21e250c..55329f64e4 100644 --- a/indra/llui/lllocalcliprect.cpp +++ b/indra/llui/lllocalcliprect.cpp @@ -33,33 +33,8 @@ #include "lllocalcliprect.h" #include "llfontgl.h" -#include "llgl.h" #include "llui.h" -#include <stack> - -//--------------------------------------------------------------------------- -// LLScreenClipRect -// implementation class in screen space -//--------------------------------------------------------------------------- -class LLScreenClipRect -{ -public: - LLScreenClipRect(const LLRect& rect, BOOL enabled = TRUE); - virtual ~LLScreenClipRect(); - -private: - static void pushClipRect(const LLRect& rect); - static void popClipRect(); - static void updateScissorRegion(); - -private: - LLGLState mScissorState; - BOOL mEnabled; - - static std::stack<LLRect> sClipRectStack; -}; - /*static*/ std::stack<LLRect> LLScreenClipRect::sClipRectStack; @@ -131,16 +106,11 @@ void LLScreenClipRect::updateScissorRegion() // LLLocalClipRect //--------------------------------------------------------------------------- LLLocalClipRect::LLLocalClipRect(const LLRect& rect, BOOL enabled /* = TRUE */) -{ - LLRect screen(rect.mLeft + LLFontGL::sCurOrigin.mX, - rect.mTop + LLFontGL::sCurOrigin.mY, - rect.mRight + LLFontGL::sCurOrigin.mX, - rect.mBottom + LLFontGL::sCurOrigin.mY); - mScreenClipRect = new LLScreenClipRect(screen, enabled); -} +: LLScreenClipRect(LLRect(rect.mLeft + LLFontGL::sCurOrigin.mX, + rect.mTop + LLFontGL::sCurOrigin.mY, + rect.mRight + LLFontGL::sCurOrigin.mX, + rect.mBottom + LLFontGL::sCurOrigin.mY), enabled) +{} LLLocalClipRect::~LLLocalClipRect() -{ - delete mScreenClipRect; - mScreenClipRect = NULL; -} +{} diff --git a/indra/llui/lllocalcliprect.h b/indra/llui/lllocalcliprect.h index cd0c55ca72..36413f1496 100644 --- a/indra/llui/lllocalcliprect.h +++ b/indra/llui/lllocalcliprect.h @@ -31,7 +31,9 @@ #ifndef LLLOCALCLIPRECT_H #define LLLOCALCLIPRECT_H +#include "llgl.h" #include "llrect.h" // can't forward declare, it's templated +#include <stack> // Clip rendering to a specific rectangle using GL scissor // Just create one of these on the stack: @@ -39,15 +41,29 @@ // LLLocalClipRect(rect); // draw(); // } -class LLLocalClipRect +class LLScreenClipRect { public: - LLLocalClipRect(const LLRect& rect, BOOL enabled = TRUE); - ~LLLocalClipRect(); + LLScreenClipRect(const LLRect& rect, BOOL enabled = TRUE); + virtual ~LLScreenClipRect(); + +private: + static void pushClipRect(const LLRect& rect); + static void popClipRect(); + static void updateScissorRegion(); private: - // implementation class - class LLScreenClipRect* mScreenClipRect; + LLGLState mScissorState; + BOOL mEnabled; + + static std::stack<LLRect> sClipRectStack; +}; + +class LLLocalClipRect : public LLScreenClipRect +{ +public: + LLLocalClipRect(const LLRect& rect, BOOL enabled = TRUE); + ~LLLocalClipRect(); }; #endif diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 617c496d6a..0587b3f48d 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1012,22 +1012,25 @@ void LLTextBase::draw() if (mBGVisible) { // clip background rect against extents, if we support scrolling - LLLocalClipRect clip(doc_rect, mScroller != NULL); - + LLRect bg_rect = mVisibleTextRect; + if (mScroller) + { + bg_rect.intersectWith(doc_rect); + } LLColor4 bg_color = mReadOnly ? mReadOnlyBgColor.get() : hasFocus() ? mFocusBgColor.get() : mWriteableBgColor.get(); - gl_rect_2d(mVisibleTextRect, bg_color, TRUE); + gl_rect_2d(doc_rect, bg_color, TRUE); } // draw document view LLUICtrl::draw(); { - // only clip if we support scrolling (mScroller != NULL) - LLLocalClipRect clip(doc_rect, mScroller != NULL); + // only clip if we support scrolling or have word wrap turned off + LLLocalClipRect clip(doc_rect, !getWordWrap() || mScroller != NULL); drawSelectionBackground(); drawText(); drawCursor(); @@ -1495,6 +1498,7 @@ LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index) // when there are no segments, we return the end iterator, which must be checked by caller if (mSegments.size() <= 1) { return mSegments.begin(); } + //FIXME: avoid operator new somehow (without running into refcount problems) segment_set_t::iterator it = mSegments.upper_bound(new LLIndexSegment(index)); return it; } @@ -2269,6 +2273,7 @@ void LLTextBase::updateRects() // allow horizontal scrolling? // if so, use entire width of text contents // otherwise, stop at width of mVisibleTextRect + //FIXME: consider use of getWordWrap() instead doc_rect.mRight = mScroller ? llmax(mVisibleTextRect.getWidth(), mTextBoundingRect.mRight) : mVisibleTextRect.getWidth(); |