DRTVWR-493 LLRender2D to LLParamSingleton
parent
17fae30f72
commit
adeee613c6
|
|
@ -46,8 +46,6 @@
|
|||
// Globals
|
||||
//
|
||||
const LLColor4 UI_VERTEX_COLOR(1.f, 1.f, 1.f, 1.f);
|
||||
/*static*/ LLVector2 LLRender2D::sGLScaleFactor(1.f, 1.f);
|
||||
/*static*/ LLImageProviderInterface* LLRender2D::sImageProvider = NULL;
|
||||
|
||||
//
|
||||
// Functions
|
||||
|
|
@ -108,10 +106,10 @@ void gl_rect_2d_offset_local( S32 left, S32 top, S32 right, S32 bottom, S32 pixe
|
|||
top += LLFontGL::sCurOrigin.mY;
|
||||
|
||||
gGL.loadUIIdentity();
|
||||
gl_rect_2d(llfloor((F32)left * LLRender2D::sGLScaleFactor.mV[VX]) - pixel_offset,
|
||||
llfloor((F32)top * LLRender2D::sGLScaleFactor.mV[VY]) + pixel_offset,
|
||||
llfloor((F32)right * LLRender2D::sGLScaleFactor.mV[VX]) + pixel_offset,
|
||||
llfloor((F32)bottom * LLRender2D::sGLScaleFactor.mV[VY]) - pixel_offset,
|
||||
gl_rect_2d(llfloor((F32)left * LLRender2D::getInstance()->mGLScaleFactor.mV[VX]) - pixel_offset,
|
||||
llfloor((F32)top * LLRender2D::getInstance()->mGLScaleFactor.mV[VY]) + pixel_offset,
|
||||
llfloor((F32)right * LLRender2D::getInstance()->mGLScaleFactor.mV[VX]) + pixel_offset,
|
||||
llfloor((F32)bottom * LLRender2D::getInstance()->mGLScaleFactor.mV[VY]) - pixel_offset,
|
||||
filled);
|
||||
gGL.popUIMatrix();
|
||||
}
|
||||
|
|
@ -800,7 +798,7 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL
|
|||
}
|
||||
gGL.end();
|
||||
|
||||
LLRender2D::setLineWidth(1.f);
|
||||
LLRender2D::getInstance()->setLineWidth(1.f);
|
||||
}
|
||||
|
||||
void gl_arc_2d(F32 center_x, F32 center_y, F32 radius, S32 steps, BOOL filled, F32 start_angle, F32 end_angle)
|
||||
|
|
@ -967,7 +965,7 @@ void gl_rect_2d_checkerboard(const LLRect& rect, GLfloat alpha)
|
|||
}
|
||||
else
|
||||
{ //polygon stipple is deprecated, use "Checker" texture
|
||||
LLPointer<LLUIImage> img = LLRender2D::getUIImage("Checker");
|
||||
LLPointer<LLUIImage> img = LLRender2D::getInstance()->getUIImage("Checker");
|
||||
gGL.getTexUnit(0)->bind(img->getImage());
|
||||
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP);
|
||||
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
|
|
@ -1567,25 +1565,22 @@ void gl_segmented_rect_3d_tex(const LLRectf& clip_rect, const LLRectf& center_uv
|
|||
|
||||
}
|
||||
|
||||
// static
|
||||
void LLRender2D::initClass(LLImageProviderInterface* image_provider,
|
||||
LLRender2D::LLRender2D(LLImageProviderInterface* image_provider,
|
||||
const LLVector2* scale_factor)
|
||||
{
|
||||
sGLScaleFactor = (scale_factor == NULL) ? LLVector2(1.f, 1.f) : *scale_factor;
|
||||
sImageProvider = image_provider;
|
||||
mGLScaleFactor = (scale_factor == NULL) ? LLVector2(1.f, 1.f) : *scale_factor;
|
||||
mImageProvider = image_provider;
|
||||
}
|
||||
|
||||
// static
|
||||
void LLRender2D::cleanupClass()
|
||||
LLRender2D::~LLRender2D()
|
||||
{
|
||||
if(sImageProvider)
|
||||
if(mImageProvider)
|
||||
{
|
||||
sImageProvider->cleanUp();
|
||||
mImageProvider->cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//static
|
||||
void LLRender2D::translate(F32 x, F32 y, F32 z)
|
||||
{
|
||||
gGL.translateUI(x,y,z);
|
||||
|
|
@ -1594,14 +1589,12 @@ void LLRender2D::translate(F32 x, F32 y, F32 z)
|
|||
LLFontGL::sCurDepth += z;
|
||||
}
|
||||
|
||||
//static
|
||||
void LLRender2D::pushMatrix()
|
||||
{
|
||||
gGL.pushUIMatrix();
|
||||
LLFontGL::sOriginStack.push_back(std::make_pair(LLFontGL::sCurOrigin, LLFontGL::sCurDepth));
|
||||
}
|
||||
|
||||
//static
|
||||
void LLRender2D::popMatrix()
|
||||
{
|
||||
gGL.popUIMatrix();
|
||||
|
|
@ -1610,7 +1603,6 @@ void LLRender2D::popMatrix()
|
|||
LLFontGL::sOriginStack.pop_back();
|
||||
}
|
||||
|
||||
//static
|
||||
void LLRender2D::loadIdentity()
|
||||
{
|
||||
gGL.loadUIIdentity();
|
||||
|
|
@ -1619,25 +1611,22 @@ void LLRender2D::loadIdentity()
|
|||
LLFontGL::sCurDepth = 0.f;
|
||||
}
|
||||
|
||||
//static
|
||||
void LLRender2D::setScaleFactor(const LLVector2 &scale_factor)
|
||||
{
|
||||
sGLScaleFactor = scale_factor;
|
||||
mGLScaleFactor = scale_factor;
|
||||
}
|
||||
|
||||
//static
|
||||
void LLRender2D::setLineWidth(F32 width)
|
||||
{
|
||||
gGL.flush();
|
||||
glLineWidth(width * lerp(sGLScaleFactor.mV[VX], sGLScaleFactor.mV[VY], 0.5f));
|
||||
glLineWidth(width * lerp(mGLScaleFactor.mV[VX], mGLScaleFactor.mV[VY], 0.5f));
|
||||
}
|
||||
|
||||
//static
|
||||
LLPointer<LLUIImage> LLRender2D::getUIImageByID(const LLUUID& image_id, S32 priority)
|
||||
{
|
||||
if (sImageProvider)
|
||||
if (mImageProvider)
|
||||
{
|
||||
return sImageProvider->getUIImageByID(image_id, priority);
|
||||
return mImageProvider->getUIImageByID(image_id, priority);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1645,11 +1634,10 @@ LLPointer<LLUIImage> LLRender2D::getUIImageByID(const LLUUID& image_id, S32 prio
|
|||
}
|
||||
}
|
||||
|
||||
//static
|
||||
LLPointer<LLUIImage> LLRender2D::getUIImage(const std::string& name, S32 priority)
|
||||
{
|
||||
if (!name.empty() && sImageProvider)
|
||||
return sImageProvider->getUIImage(name, priority);
|
||||
if (!name.empty() && mImageProvider)
|
||||
return mImageProvider->getUIImage(name, priority);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,28 +121,26 @@ inline void gl_rect_2d_offset_local( const LLRect& rect, S32 pixel_offset, BOOL
|
|||
|
||||
class LLImageProviderInterface;
|
||||
|
||||
class LLRender2D
|
||||
class LLRender2D : public LLParamSingleton<LLRender2D>
|
||||
{
|
||||
LLPARAMSINGLETON(LLRender2D, LLImageProviderInterface* image_provider, const LLVector2* scale_factor);
|
||||
LOG_CLASS(LLRender2D);
|
||||
~LLRender2D();
|
||||
public:
|
||||
static void initClass(LLImageProviderInterface* image_provider,
|
||||
const LLVector2* scale_factor);
|
||||
static void cleanupClass();
|
||||
void pushMatrix();
|
||||
void popMatrix();
|
||||
void loadIdentity();
|
||||
void translate(F32 x, F32 y, F32 z = 0.0f);
|
||||
|
||||
static void pushMatrix();
|
||||
static void popMatrix();
|
||||
static void loadIdentity();
|
||||
static void translate(F32 x, F32 y, F32 z = 0.0f);
|
||||
void setLineWidth(F32 width);
|
||||
void setScaleFactor(const LLVector2& scale_factor);
|
||||
|
||||
static void setLineWidth(F32 width);
|
||||
static void setScaleFactor(const LLVector2& scale_factor);
|
||||
LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0);
|
||||
LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0);
|
||||
|
||||
static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0);
|
||||
static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0);
|
||||
|
||||
static LLVector2 sGLScaleFactor;
|
||||
LLVector2 mGLScaleFactor;
|
||||
private:
|
||||
static LLImageProviderInterface* sImageProvider;
|
||||
LLImageProviderInterface* mImageProvider;
|
||||
};
|
||||
|
||||
class LLImageProviderInterface
|
||||
|
|
|
|||
|
|
@ -120,12 +120,12 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c
|
|||
}
|
||||
}
|
||||
|
||||
LLRender2D::pushMatrix();
|
||||
LLRender2D::getInstance()->pushMatrix();
|
||||
{
|
||||
LLVector3 rect_origin = origin_agent + (rect.mLeft * x_axis) + (rect.mBottom * y_axis);
|
||||
LLRender2D::translate(rect_origin.mV[VX],
|
||||
rect_origin.mV[VY],
|
||||
rect_origin.mV[VZ]);
|
||||
LLRender2D::getInstance()->translate(rect_origin.mV[VX],
|
||||
rect_origin.mV[VY],
|
||||
rect_origin.mV[VZ]);
|
||||
gGL.getTexUnit(0)->bind(getImage());
|
||||
gGL.color4fv(color.mV);
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c
|
|||
rect.getWidth() * x_axis,
|
||||
rect.getHeight() * y_axis);
|
||||
|
||||
} LLRender2D::popMatrix();
|
||||
} LLRender2D::getInstance()->popMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ namespace LLInitParam
|
|||
return;
|
||||
}
|
||||
|
||||
LLUIImage* imagep = LLRender2D::getUIImage(name());
|
||||
LLUIImage* imagep = LLRender2D::getInstance()->getUIImage(name());
|
||||
if (imagep)
|
||||
{
|
||||
updateValue(imagep);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ void LLUI::initClass(const settings_map_t& settings,
|
|||
const LLVector2* scale_factor,
|
||||
const std::string& language)
|
||||
{
|
||||
LLRender2D::initClass(image_provider,scale_factor);
|
||||
LLRender2D::initParamSingleton(image_provider,scale_factor);
|
||||
sSettingGroups = settings;
|
||||
|
||||
if ((get_ptr_in_map(sSettingGroups, std::string("config")) == NULL) ||
|
||||
|
|
@ -207,11 +207,6 @@ void LLUI::initClass(const settings_map_t& settings,
|
|||
LLCommandManager::load();
|
||||
}
|
||||
|
||||
void LLUI::cleanupClass()
|
||||
{
|
||||
SUBSYSTEM_CLEANUP(LLRender2D);
|
||||
}
|
||||
|
||||
void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& remove_popup, const clear_popups_t& clear_popups)
|
||||
{
|
||||
sAddPopupFunc = add_popup;
|
||||
|
|
|
|||
|
|
@ -243,13 +243,13 @@ public:
|
|||
LLUIAudioCallback deferred_audio_callback = NULL,
|
||||
const LLVector2 *scale_factor = NULL,
|
||||
const std::string& language = LLStringUtil::null);
|
||||
static void cleanupClass();
|
||||
|
||||
static void setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t&, const clear_popups_t& );
|
||||
|
||||
static void pushMatrix() { LLRender2D::pushMatrix(); }
|
||||
static void popMatrix() { LLRender2D::popMatrix(); }
|
||||
static void loadIdentity() { LLRender2D::loadIdentity(); }
|
||||
static void translate(F32 x, F32 y, F32 z = 0.0f) { LLRender2D::translate(x, y, z); }
|
||||
static void pushMatrix() { LLRender2D::getInstance()->pushMatrix(); }
|
||||
static void popMatrix() { LLRender2D::getInstance()->popMatrix(); }
|
||||
static void loadIdentity() { LLRender2D::getInstance()->loadIdentity(); }
|
||||
static void translate(F32 x, F32 y, F32 z = 0.0f) { LLRender2D::getInstance()->translate(x, y, z); }
|
||||
|
||||
static LLRect sDirtyRect;
|
||||
static BOOL sDirty;
|
||||
|
|
@ -294,13 +294,13 @@ public:
|
|||
static void getMousePositionScreen(S32 *x, S32 *y);
|
||||
static void setMousePositionLocal(const LLView* viewp, S32 x, S32 y);
|
||||
static void getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y);
|
||||
static LLVector2& getScaleFactor() { return LLRender2D::sGLScaleFactor; }
|
||||
static void setScaleFactor(const LLVector2& scale_factor) { LLRender2D::setScaleFactor(scale_factor); }
|
||||
static void setLineWidth(F32 width) { LLRender2D::setLineWidth(width); }
|
||||
static LLVector2& getScaleFactor() { return LLRender2D::getInstance()->mGLScaleFactor; }
|
||||
static void setScaleFactor(const LLVector2& scale_factor) { LLRender2D::getInstance()->setScaleFactor(scale_factor); }
|
||||
static void setLineWidth(F32 width) { LLRender2D::getInstance()->setLineWidth(width); }
|
||||
static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0)
|
||||
{ return LLRender2D::getUIImageByID(image_id, priority); }
|
||||
{ return LLRender2D::getInstance()->getUIImageByID(image_id, priority); }
|
||||
static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0)
|
||||
{ return LLRender2D::getUIImage(name, priority); }
|
||||
{ return LLRender2D::getInstance()->getUIImage(name, priority); }
|
||||
static LLVector2 getWindowSize();
|
||||
static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y);
|
||||
static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y);
|
||||
|
|
|
|||
|
|
@ -1886,7 +1886,6 @@ bool LLAppViewer::cleanup()
|
|||
LLPrimitive::cleanupVolumeManager();
|
||||
SUBSYSTEM_CLEANUP(LLWorldMapView);
|
||||
SUBSYSTEM_CLEANUP(LLFolderViewItem);
|
||||
SUBSYSTEM_CLEANUP(LLUI);
|
||||
|
||||
//
|
||||
// Shut down the VFS's AFTER the decode manager cleans up (since it cleans up vfiles).
|
||||
|
|
|
|||
Loading…
Reference in New Issue