mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Issue found with PVS-Studio:
Many instances of a function or expression being used repeatedly, which can lower performance. Fixed it in these cases by creating on local var, reference or pointer that's used instead.
This commit is contained in:
parent
ec63398042
commit
2002d74b78
38 changed files with 465 additions and 371 deletions
|
|
@ -852,6 +852,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
if ( mScrollDir != GuiScrollCtrl::None )
|
||||
autoScroll();
|
||||
|
||||
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
|
||||
|
||||
RectI r( offset, getExtent() );
|
||||
if ( mInAction )
|
||||
{
|
||||
|
|
@ -868,30 +870,30 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
else
|
||||
{
|
||||
//renderSlightlyLoweredBox(r, mProfile);
|
||||
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColor );
|
||||
drawUtil->drawRectFill( r, mProfile->mFillColor );
|
||||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureDepressed )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapStretch( mTextureDepressed, rect );
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureDepressed, rect );
|
||||
}
|
||||
else if ( mTextureNormal )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
|
||||
{
|
||||
GFX->getDrawUtil()->drawLine( l, t, l, b, colorWhite );
|
||||
GFX->getDrawUtil()->drawLine( l, t, r2, t, colorWhite );
|
||||
GFX->getDrawUtil()->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
|
||||
GFX->getDrawUtil()->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
|
||||
drawUtil->drawLine( l, t, l, b, colorWhite );
|
||||
drawUtil->drawLine( l, t, r2, t, colorWhite );
|
||||
drawUtil->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
|
||||
drawUtil->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -912,24 +914,24 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
}
|
||||
else
|
||||
{
|
||||
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColorHL );
|
||||
drawUtil->drawRectFill( r, mProfile->mFillColorHL );
|
||||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureNormal )
|
||||
{
|
||||
RectI rect( offset, mBitmapBounds );
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
|
||||
{
|
||||
GFX->getDrawUtil()->drawLine( l, t, l, b, colorWhite );
|
||||
GFX->getDrawUtil()->drawLine( l, t, r2, t, colorWhite );
|
||||
GFX->getDrawUtil()->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
|
||||
GFX->getDrawUtil()->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
|
||||
drawUtil->drawLine( l, t, l, b, colorWhite );
|
||||
drawUtil->drawLine( l, t, r2, t, colorWhite );
|
||||
drawUtil->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
|
||||
drawUtil->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -942,21 +944,21 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
}
|
||||
else
|
||||
{
|
||||
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColorNA );
|
||||
drawUtil->drawRectFill( r, mProfile->mFillColorNA );
|
||||
}
|
||||
|
||||
// Draw a bitmap over the background?
|
||||
if ( mTextureNormal )
|
||||
{
|
||||
RectI rect(offset, mBitmapBounds);
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapStretch( mTextureNormal, rect );
|
||||
}
|
||||
|
||||
// Do we render a bitmap border or lines?
|
||||
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
|
||||
{
|
||||
GFX->getDrawUtil()->drawRect( r, mProfile->mBorderColorNA );
|
||||
drawUtil->drawRect( r, mProfile->mBorderColorNA );
|
||||
}
|
||||
}
|
||||
// renderSlightlyRaisedBox(r, mProfile); // Used to be the only 'else' condition to mInAction above.
|
||||
|
|
@ -1027,8 +1029,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
{
|
||||
Point2I coloredboxsize( 15, 10 );
|
||||
RectI r( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
|
||||
GFX->getDrawUtil()->drawRectFill( r, boxColor);
|
||||
GFX->getDrawUtil()->drawRect( r, ColorI(0,0,0));
|
||||
drawUtil->drawRectFill( r, boxColor);
|
||||
drawUtil->drawRect( r, ColorI(0,0,0));
|
||||
|
||||
localStart.x += coloredboxsize.x + mProfile->mTextOffset.x;
|
||||
}
|
||||
|
|
@ -1036,7 +1038,7 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
// Draw the text
|
||||
Point2I globalStart = localToGlobalCoord( localStart );
|
||||
ColorI fontColor = mActive ? ( mInAction ? mProfile->mFontColor : mProfile->mFontColorNA ) : mProfile->mFontColorNA;
|
||||
GFX->getDrawUtil()->setBitmapModulation( fontColor ); // was: (mProfile->mFontColor);
|
||||
drawUtil->setBitmapModulation( fontColor ); // was: (mProfile->mFontColor);
|
||||
|
||||
// Get the number of columns in the text
|
||||
S32 colcount = getColumnCount( mText, "\t" );
|
||||
|
|
@ -1048,7 +1050,7 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
|
||||
// Draw the first column
|
||||
getColumn( mText, buff, 0, "\t" );
|
||||
GFX->getDrawUtil()->drawText( mProfile->mFont, globalStart, buff, mProfile->mFontColors );
|
||||
drawUtil->drawText( mProfile->mFont, globalStart, buff, mProfile->mFontColors );
|
||||
|
||||
// Draw the second column to the right
|
||||
getColumn( mText, buff, 1, "\t" );
|
||||
|
|
@ -1059,17 +1061,17 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
// right cap of the border.
|
||||
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
|
||||
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - bitmapBounds[2].extent.x, localStart.y ) );
|
||||
GFX->getDrawUtil()->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
|
||||
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
|
||||
|
||||
} else
|
||||
{
|
||||
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - 12, localStart.y ) );
|
||||
GFX->getDrawUtil()->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
|
||||
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
GFX->getDrawUtil()->drawText( mProfile->mFont, globalStart, mText, mProfile->mFontColors );
|
||||
drawUtil->drawText( mProfile->mFont, globalStart, mText, mProfile->mFontColors );
|
||||
}
|
||||
|
||||
// If we're rendering a bitmap border, then it will take care of the arrow.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue