Finished LLGLTexture. Migrated opengl related code from llui.h/cpp to llrender2dutils.h/cpp. Moved lluiimage to llrender library.

This commit is contained in:
Shyotl
2013-01-07 20:12:14 -06:00
parent d71210e942
commit c5c1294d7d
27 changed files with 2392 additions and 2266 deletions

View File

@@ -243,7 +243,7 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(BOOL usemipma
if(generate_gl_tex)
{
tex->generateGLTexture() ;
tex->setCategory(LLViewerTexture::LOCAL) ;
tex->setCategory(LLGLTexture::LOCAL) ;
}
return tex ;
}
@@ -253,14 +253,14 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLUUID&
if(generate_gl_tex)
{
tex->generateGLTexture() ;
tex->setCategory(LLViewerTexture::LOCAL) ;
tex->setCategory(LLGLTexture::LOCAL) ;
}
return tex ;
}
LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLImageRaw* raw, BOOL usemipmaps)
{
LLPointer<LLViewerTexture> tex = new LLViewerTexture(raw, usemipmaps) ;
tex->setCategory(LLViewerTexture::LOCAL) ;
tex->setCategory(LLGLTexture::LOCAL) ;
return tex ;
}
LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex)
@@ -269,7 +269,7 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 wid
if(generate_gl_tex)
{
tex->generateGLTexture() ;
tex->setCategory(LLViewerTexture::LOCAL) ;
tex->setCategory(LLGLTexture::LOCAL) ;
}
return tex ;
}
@@ -277,7 +277,7 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 wid
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(
const LLUUID &image_id,
BOOL usemipmaps,
LLGLTexture::EBoostLevel boost_priority,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
LLGLenum primary_format,
@@ -289,7 +289,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile(
const std::string& filename,
BOOL usemipmaps,
LLGLTexture::EBoostLevel boost_priority,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
LLGLenum primary_format,
@@ -301,7 +301,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile(
//static
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const std::string& url,
BOOL usemipmaps,
LLGLTexture::EBoostLevel boost_priority,
LLViewerTexture::EBoostLevel boost_priority,
S8 texture_type,
LLGLint internal_format,
LLGLenum primary_format,
@@ -384,7 +384,7 @@ void LLViewerTextureManager::init()
LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
#endif
LLViewerFetchedTexture::sDefaultImagep->dontDiscard();
LLViewerFetchedTexture::sDefaultImagep->setCategory(LLViewerTexture::OTHER) ;
LLViewerFetchedTexture::sDefaultImagep->setCategory(LLGLTexture::OTHER) ;
LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, TRUE, LLGLTexture::BOOST_UI);
LLViewerFetchedTexture::sSmokeImagep->setNoDelete() ;
@@ -440,25 +440,6 @@ void LLViewerTexture::initClass()
}
}
// static
S32 LLViewerTexture::getTotalNumOfCategories()
{
return MAX_GL_IMAGE_CATEGORY - (BOOST_HIGH - BOOST_SCULPTED) + 2 ;
}
// static
//index starts from zero.
S32 LLViewerTexture::getIndexFromCategory(S32 category)
{
return (category < BOOST_HIGH) ? category : category - (BOOST_HIGH - BOOST_SCULPTED) + 1 ;
}
//static
S32 LLViewerTexture::getCategoryFromIndex(S32 index)
{
return (index < BOOST_HIGH) ? index : index + (BOOST_HIGH - BOOST_SCULPTED) - 1 ;
}
// tuning params
const F32 discard_bias_delta = .25f;
const F32 discard_delta_time = 0.5f;
@@ -599,45 +580,38 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
//-------------------------------------------------------------------------------------------
const U32 LLViewerTexture::sCurrentFileVersion = 1;
LLViewerTexture::LLViewerTexture(BOOL usemipmaps)
LLViewerTexture::LLViewerTexture(BOOL usemipmaps) :
LLGLTexture(usemipmaps)
{
init(true);
mUseMipMaps = usemipmaps ;
mID.generate();
sImageCount++;
}
LLViewerTexture::LLViewerTexture(const LLUUID& id, BOOL usemipmaps)
: mID(id)
LLViewerTexture::LLViewerTexture(const LLUUID& id, BOOL usemipmaps) :
LLGLTexture(usemipmaps),
mID(id)
{
init(true);
mUseMipMaps = usemipmaps ;
sImageCount++;
}
LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps)
LLViewerTexture::LLViewerTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps) :
LLGLTexture(width, height, components, usemipmaps)
{
init(true);
mFullWidth = width ;
mFullHeight = height ;
mUseMipMaps = usemipmaps ;
mComponents = components ;
setTexelsPerImage();
mID.generate();
sImageCount++;
}
LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps)
LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps) :
LLGLTexture(raw, usemipmaps)
{
init(true);
mUseMipMaps = usemipmaps ;
mGLTexturep = new LLImageGL(raw, usemipmaps) ;
// Create an empty image of the specified size and width
mID.generate();
sImageCount++;
}
@@ -648,18 +622,9 @@ LLViewerTexture::~LLViewerTexture()
sImageCount--;
}
// virtual
void LLViewerTexture::init(bool firstinit)
{
mBoostLevel = LLGLTexture::BOOST_NONE;
mFullWidth = 0;
mFullHeight = 0;
mTexelsPerImage = 0 ;
mUseMipMaps = FALSE ;
mComponents = 0 ;
mTextureState = NO_DELETE ;
mDontDiscard = FALSE;
mMaxVirtualSize = 0.f;
mNeedsGLTexture = FALSE ;
mMaxVirtualSizeResetInterval = 1;
@@ -670,7 +635,6 @@ void LLViewerTexture::init(bool firstinit)
mNumVolumes = 0;
mFaceList.clear() ;
mVolumeList.clear();
#if !NEW_MEDIA_TEXTURE
mIsMediaTexture = false;
#endif //!NEW_MEDIA_TEXTURE
@@ -686,42 +650,17 @@ void LLViewerTexture::cleanup()
{
mFaceList.clear() ;
mVolumeList.clear();
if(mGLTexturep)
{
mGLTexturep->cleanup();
}
}
// virtual
void LLViewerTexture::dump()
{
if(mGLTexturep)
{
mGLTexturep->dump();
}
LLGLTexture::dump();
llinfos << "LLViewerTexture"
<< " mID " << mID
<< llendl;
}
void LLViewerTexture::setBoostLevel(S32 level)
{
if(mBoostLevel != level)
{
mBoostLevel = level ;
if(mBoostLevel != LLGLTexture::BOOST_NONE)
{
setNoDelete() ;
}
if(gAuditTexture)
{
setCategory(mBoostLevel);
}
}
}
bool LLViewerTexture::bindDefaultImage(S32 stage)
{
if (stage < 0) return false;
@@ -924,66 +863,6 @@ void LLViewerTexture::switchToCachedImage()
//nothing here.
}
void LLViewerTexture::forceActive()
{
mTextureState = ACTIVE ;
}
void LLViewerTexture::setActive()
{
if(mTextureState != NO_DELETE)
{
mTextureState = ACTIVE ;
}
}
//set the texture to stay in memory
void LLViewerTexture::setNoDelete()
{
mTextureState = NO_DELETE ;
}
void LLViewerTexture::generateGLTexture()
{
if(mGLTexturep.isNull())
{
mGLTexturep = new LLImageGL(mFullWidth, mFullHeight, mComponents, mUseMipMaps) ;
}
}
LLImageGL* LLViewerTexture::getGLTexture() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep ;
}
BOOL LLViewerTexture::createGLTexture()
{
if(mGLTexturep.isNull())
{
generateGLTexture() ;
}
return mGLTexturep->createGLTexture() ;
}
BOOL LLViewerTexture::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename, BOOL to_create, S32 category)
{
llassert(mGLTexturep.notNull()) ;
BOOL ret = mGLTexturep->createGLTexture(discard_level, imageraw, usename, to_create, category) ;
if(ret)
{
mFullWidth = mGLTexturep->getCurrentWidth() ;
mFullHeight = mGLTexturep->getCurrentHeight() ;
mComponents = mGLTexturep->getComponents() ;
setTexelsPerImage();
}
return ret ;
}
//virtual
void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw)
@@ -991,219 +870,6 @@ void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw)
//nothing here.
}
void LLViewerTexture::setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes)
{
llassert(mGLTexturep.notNull()) ;
mGLTexturep->setExplicitFormat(internal_format, primary_format, type_format, swap_bytes) ;
}
void LLViewerTexture::setAddressMode(LLTexUnit::eTextureAddressMode mode)
{
llassert(mGLTexturep.notNull()) ;
mGLTexturep->setAddressMode(mode) ;
}
void LLViewerTexture::setFilteringOption(LLTexUnit::eTextureFilterOptions option)
{
llassert(mGLTexturep.notNull()) ;
mGLTexturep->setFilteringOption(option) ;
}
//virtual
S32 LLViewerTexture::getWidth(S32 discard_level) const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getWidth(discard_level) ;
}
//virtual
S32 LLViewerTexture::getHeight(S32 discard_level) const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getHeight(discard_level) ;
}
S32 LLViewerTexture::getMaxDiscardLevel() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getMaxDiscardLevel() ;
}
S32 LLViewerTexture::getDiscardLevel() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getDiscardLevel() ;
}
S8 LLViewerTexture::getComponents() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getComponents() ;
}
LLGLuint LLViewerTexture::getTexName() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getTexName() ;
}
BOOL LLViewerTexture::hasGLTexture() const
{
if(mGLTexturep.notNull())
{
return mGLTexturep->getHasGLTexture() ;
}
return FALSE ;
}
BOOL LLViewerTexture::getBoundRecently() const
{
if(mGLTexturep.notNull())
{
return mGLTexturep->getBoundRecently() ;
}
return FALSE ;
}
LLTexUnit::eTextureType LLViewerTexture::getTarget(void) const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getTarget() ;
}
BOOL LLViewerTexture::setSubImage(const LLImageRaw* imageraw, S32 x_pos, S32 y_pos, S32 width, S32 height, bool fast_update)
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->setSubImage(imageraw, x_pos, y_pos, width, height, fast_update) ;
}
BOOL LLViewerTexture::setSubImage(const U8* datap, S32 data_width, S32 data_height, S32 x_pos, S32 y_pos, S32 width, S32 height, bool fast_update)
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->setSubImage(datap, data_width, data_height, x_pos, y_pos, width, height, fast_update) ;
}
void LLViewerTexture::setGLTextureCreated (bool initialized)
{
llassert(mGLTexturep.notNull()) ;
mGLTexturep->setGLTextureCreated (initialized) ;
}
void LLViewerTexture::setCategory(S32 category)
{
llassert(mGLTexturep.notNull()) ;
mGLTexturep->setCategory(category) ;
}
LLTexUnit::eTextureAddressMode LLViewerTexture::getAddressMode(void) const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getAddressMode() ;
}
S32 LLViewerTexture::getTextureMemory() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->mTextureMemory ;
}
LLGLenum LLViewerTexture::getPrimaryFormat() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getPrimaryFormat() ;
}
BOOL LLViewerTexture::getIsAlphaMask() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getIsAlphaMask() ;
}
BOOL LLViewerTexture::getMask(const LLVector2 &tc)
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getMask(tc) ;
}
F32 LLViewerTexture::getTimePassedSinceLastBound()
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getTimePassedSinceLastBound() ;
}
BOOL LLViewerTexture::getMissed() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getMissed() ;
}
BOOL LLViewerTexture::isJustBound() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->isJustBound() ;
}
void LLViewerTexture::forceUpdateBindStats(void) const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->forceUpdateBindStats() ;
}
/*U32 LLViewerTexture::getTexelsInAtlas() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getTexelsInAtlas() ;
}
U32 LLViewerTexture::getTexelsInGLTexture() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getTexelsInGLTexture() ;
}
BOOL LLViewerTexture::isGLTextureCreated() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->isGLTextureCreated() ;
}
S32 LLViewerTexture::getDiscardLevelInAtlas() const
{
llassert(mGLTexturep.notNull()) ;
return mGLTexturep->getDiscardLevelInAtlas() ;
}*/
void LLViewerTexture::destroyGLTexture()
{
if(mGLTexturep.notNull() && mGLTexturep->getHasGLTexture())
{
mGLTexturep->destroyGLTexture() ;
mTextureState = DELETED ;
}
}
void LLViewerTexture::setTexelsPerImage()
{
S32 fullwidth = llmin(mFullWidth,(S32)MAX_IMAGE_SIZE_DEFAULT);
S32 fullheight = llmin(mFullHeight,(S32)MAX_IMAGE_SIZE_DEFAULT);
mTexelsPerImage = (F32)fullwidth * fullheight;
}
BOOL LLViewerTexture::isLargeImage()
{
return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize ;