Merge branch 'master' of github.com:singularity-viewer/SingularityViewer

This commit is contained in:
Salvatore La Bua
2013-09-24 01:20:35 +02:00
11 changed files with 659 additions and 244 deletions

View File

@@ -133,6 +133,26 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
parameters.cp_reduce = base.getRawDiscardLevel(); parameters.cp_reduce = base.getRawDiscardLevel();
if(parameters.cp_reduce == 0 && *(U16*)(base.getData() + base.getDataSize() - 2) != 0xD9FF)
{
bool failed = true;
for(S32 i = base.getDataSize()-1; i > 42; --i)
{
if(base.getData()[i] != 0x00)
{
failed = *(U16*)(base.getData()+i-1) != 0xD9FF;
break;
}
}
if(failed)
{
opj_image_destroy(image);
base.decodeFailed();
return TRUE;
}
}
/* decode the code-stream */ /* decode the code-stream */
/* ---------------------- */ /* ---------------------- */
@@ -212,7 +232,7 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
if(image->numcomps <= first_channel) if(image->numcomps <= first_channel)
{ {
llwarns << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl; LL_WARNS("Texture") << "trying to decode more channels than are present in image: numcomps: " << image->numcomps << " first_channel: " << first_channel << llendl;
if (image) if (image)
{ {
opj_image_destroy(image); opj_image_destroy(image);

View File

@@ -48,8 +48,28 @@ LLDir_Win32::LLDir_Win32()
WCHAR w_str[MAX_PATH]; WCHAR w_str[MAX_PATH];
HRESULT (WINAPI* pSHGetKnownFolderPath)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath) = NULL;
HMODULE shell = LoadLibrary(L"shell32");
if(shell) //SHGetSpecialFolderPath is deprecated from Vista an onwards. Try to use SHGetKnownFolderPath if it's available
{
pSHGetKnownFolderPath = (HRESULT (WINAPI *)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *))GetProcAddress(shell, "SHGetKnownFolderPath");
}
// Application Data is where user settings go // Application Data is where user settings go
SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE); if(pSHGetKnownFolderPath)
{
WCHAR* pPath = NULL;
if((*pSHGetKnownFolderPath)(FOLDERID_RoamingAppData, 0, NULL, &pPath) == S_OK)
wcscpy_s(w_str,pPath);
else
SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE);
if(pPath)
CoTaskMemFree(pPath);
}
else //XP doesn't support SHGetKnownFolderPath
{
SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE);
}
mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); mOSUserDir = utf16str_to_utf8str(llutf16string(w_str));
@@ -64,17 +84,14 @@ LLDir_Win32::LLDir_Win32()
// We used to store the cache in AppData\Roaming, and the installer // We used to store the cache in AppData\Roaming, and the installer
// cleans up that version on upgrade. JC // cleans up that version on upgrade. JC
if(HMODULE shell = LoadLibrary(L"shell32")) //SHGetSpecialFolderPath is deprecated from Vista an onwards. Try to use SHGetSpecialFolderPath if it's available
if(pSHGetKnownFolderPath)
{ {
HRESULT (WINAPI* pSHGetKnownFolderPath)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
pSHGetKnownFolderPath = (HRESULT (WINAPI *)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *))GetProcAddress(shell, "SHGetKnownFolderPath");
WCHAR* pPath = NULL; WCHAR* pPath = NULL;
if(pSHGetKnownFolderPath && (*pSHGetKnownFolderPath)(FOLDERID_LocalAppData, 0, NULL, &pPath) == S_OK) if((*pSHGetKnownFolderPath)(FOLDERID_LocalAppData, 0, NULL, &pPath) == S_OK)
wcscpy_s(w_str,pPath); wcscpy_s(w_str,pPath);
else else
SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE);
FreeLibrary(shell);
if(pPath) if(pPath)
CoTaskMemFree(pPath); CoTaskMemFree(pPath);
} }
@@ -82,6 +99,10 @@ LLDir_Win32::LLDir_Win32()
{ {
SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE);
} }
if(shell)
FreeLibrary(shell);
mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str)); mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str));
if (GetTempPath(MAX_PATH, w_str)) if (GetTempPath(MAX_PATH, w_str))

View File

@@ -85,7 +85,7 @@ LLDebugView::LLDebugView(const std::string& name, const LLRect &rect)
mFastTimerView->setVisible(FALSE); // start invisible mFastTimerView->setVisible(FALSE); // start invisible
addChild(mFastTimerView); addChild(mFastTimerView);
r.set(150, rect.getHeight() - 50, 870, 100); r.set(150, rect.getHeight() - 50, 970, 100);
LLTextureView::Params tvp; LLTextureView::Params tvp;
tvp.name("gTextureView"); tvp.name("gTextureView");
tvp.rect(r); tvp.rect(r);

View File

@@ -163,7 +163,7 @@ LLPanelGroup::LLPanelGroup(const LLUUID& group_id)
LLGroupMgr::getInstance()->addObserver(this); LLGroupMgr::getInstance()->addObserver(this);
mCommitCallbackRegistrar.add("Group.CopyURI", boost::bind(copy_group_profile_uri, group_id)); mCommitCallbackRegistrar.add("Group.CopyURI", boost::bind(copy_group_profile_uri, boost::ref(mID)));
// Pass on construction of this panel to the control factory. // Pass on construction of this panel to the control factory.
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_group.xml", &getFactoryMap()); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_group.xml", &getFactoryMap());
} }

View File

@@ -373,9 +373,9 @@ bool LLTextureCacheRemoteWorker::doRead()
if (!done && (mState == LOCAL)) if (!done && (mState == LOCAL))
{ {
llassert(local_size != 0); // we're assuming there is a non empty local file here... llassert(local_size != 0); // we're assuming there is a non empty local file here...
if (!mDataSize || mDataSize > local_size - mOffset) if (!mDataSize || mDataSize > local_size/* - mOffset*/)
{ {
mDataSize = local_size - mOffset; mDataSize = local_size/* - mOffset*/;
} }
// Allocate read buffer // Allocate read buffer
mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize); mReadData = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), mDataSize);

File diff suppressed because it is too large Load Diff

View File

@@ -84,8 +84,14 @@ public:
S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p, S32 getFetchState(const LLUUID& id, F32& decode_progress_p, F32& requested_priority_p,
U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http); U32& fetch_priority_p, F32& fetch_dtime_p, F32& request_dtime_p, bool& can_use_http);
void dump(); void dump();
S32 getNumRequests() ; // Threads: T*
U32 getTotalNumHTTPRequests() ; S32 getNumRequests();
// Threads: T*
S32 getNumHTTPRequests();
// Threads: T*
U32 getTotalNumHTTPRequests();
// Public for access by callbacks // Public for access by callbacks
S32 getPending(); S32 getPending();

View File

@@ -81,7 +81,7 @@ static std::string title_string1a("Tex UUID Area DDis(Req) DecodePri(Fetch)
static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max"); static std::string title_string1b("Tex UUID Area DDis(Req) Fetch(DecodePri) [download] pk/max");
static std::string title_string2("State"); static std::string title_string2("State");
static std::string title_string3("Pkt Bnd"); static std::string title_string3("Pkt Bnd");
static std::string title_string4(" W x H (Dis) Mem"); static std::string title_string4(" W x H (Dis) Mem Type");
static S32 title_x1 = 0; static S32 title_x1 = 0;
static S32 title_x2 = 460; static S32 title_x2 = 460;
@@ -211,6 +211,9 @@ void LLTextureBar::draw()
std::string uuid_str; std::string uuid_str;
mImagep->mID.toString(uuid_str); mImagep->mID.toString(uuid_str);
uuid_str = uuid_str.substr(0,7); uuid_str = uuid_str.substr(0,7);
std::string vsstr = llformat("%f",mImagep->mMaxVirtualSize);
std::string dpstr = llformat("%f",mImagep->getDecodePriority());
if (mTextureView->mOrderFetch) if (mTextureView->mOrderFetch)
{ {
tex_str = llformat("%s %7.0f %d(%d) 0x%08x(%8.0f)", tex_str = llformat("%s %7.0f %d(%d) 0x%08x(%8.0f)",
@@ -223,14 +226,14 @@ void LLTextureBar::draw()
} }
else else
{ {
tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x) %1.2f", tex_str = llformat("%s %7.0f %d(%d) %8.0f(0x%08x) %3d%%",
uuid_str.c_str(), uuid_str.c_str(),
mImagep->mMaxVirtualSize, mImagep->mMaxVirtualSize,
mImagep->mDesiredDiscardLevel, mImagep->mDesiredDiscardLevel,
mImagep->mRequestedDiscardLevel, mImagep->mRequestedDiscardLevel,
mImagep->getDecodePriority(), mImagep->getDecodePriority(),
mImagep->mFetchPriority, mImagep->mFetchPriority,
mImagep->mDownloadProgress); llfloor(mImagep->mDownloadProgress*100.f));
} }
LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(), LLFontGL::getFontMonospace()->renderUTF8(tex_str, 0, title_x1, getRect().getHeight(),
@@ -239,12 +242,14 @@ void LLTextureBar::draw()
// State // State
// Hack: mirrored from lltexturefetch.cpp // Hack: mirrored from lltexturefetch.cpp
struct { const std::string desc; LLColor4 color; } fetch_state_desc[] = { struct { const std::string desc; LLColor4 color; } fetch_state_desc[] = {
{ "---", LLColor4::red }, // INVALID { "-?-", LLColor4::red }, // INVALID
{ "INI", LLColor4::white }, // INIT { "INI", LLColor4::white }, // INIT
{ "DSK", LLColor4::cyan }, // LOAD_FROM_TEXTURE_CACHE { "DSK", LLColor4::cyan }, // LOAD_FROM_TEXTURE_CACHE
{ "DSK", LLColor4::blue }, // CACHE_POST { "DSK", LLColor4::blue }, // CACHE_POST
{ "NET", LLColor4::green }, // LOAD_FROM_NETWORK { "NET", LLColor4::green }, // LOAD_FROM_NETWORK
{ "SIM", LLColor4::green }, // LOAD_FROM_SIMULATOR { "SIM", LLColor4::green }, // LOAD_FROM_SIMULATOR
{ "REQ", LLColor4::magenta },// SEND_UDP_REQ
{ "UDP", LLColor4::cyan }, // WAIT_UDP_REQ
{ "REQ", LLColor4::yellow },// SEND_HTTP_REQ { "REQ", LLColor4::yellow },// SEND_HTTP_REQ
{ "HTP", LLColor4::green }, // WAIT_HTTP_REQ { "HTP", LLColor4::green }, // WAIT_HTTP_REQ
{ "DEC", LLColor4::yellow },// DECODE_IMAGE { "DEC", LLColor4::yellow },// DECODE_IMAGE
@@ -252,12 +257,12 @@ void LLTextureBar::draw()
{ "WRT", LLColor4::purple },// WRITE_TO_CACHE { "WRT", LLColor4::purple },// WRITE_TO_CACHE
{ "WRT", LLColor4::orange },// WAIT_ON_WRITE { "WRT", LLColor4::orange },// WAIT_ON_WRITE
{ "END", LLColor4::red }, // DONE { "END", LLColor4::red }, // DONE
#define LAST_STATE 12 #define LAST_STATE 14
{ "CRE", LLColor4::magenta }, // LAST_STATE+1 { "CRE", LLColor4::magenta }, // LAST_STATE+1
{ "FUL", LLColor4::green }, // LAST_STATE+2 { "FUL", LLColor4::green }, // LAST_STATE+2
{ "BAD", LLColor4::red }, // LAST_STATE+3 { "BAD", LLColor4::red }, // LAST_STATE+3
{ "MIS", LLColor4::red }, // LAST_STATE+4 { "MIS", LLColor4::red }, // LAST_STATE+4
{ "---", LLColor4::white }, // LAST_STATE+5 { "-!-", LLColor4::white }, // LAST_STATE+5
}; };
const S32 fetch_state_desc_size = (S32)LL_ARRAY_SIZE(fetch_state_desc); const S32 fetch_state_desc_size = (S32)LL_ARRAY_SIZE(fetch_state_desc);
S32 state = S32 state =
@@ -370,8 +375,39 @@ void LLTextureBar::draw()
// draw the image size at the end // draw the image size at the end
{ {
std::string num_str = llformat("%3dx%3d (%d) %7d", mImagep->getWidth(), mImagep->getHeight(), std::string boost_lvl("UNKNOWN");
mImagep->getDiscardLevel(), mImagep->hasGLTexture() ? mImagep->getTextureMemory() : 0); switch(mImagep->getBoostLevel())
{
#define BOOST_LVL(type) case LLGLTexture::BOOST_##type: boost_lvl="B_"#type; break;
#define CAT_LVL(type) case LLGLTexture::type: boost_lvl=#type; break;
BOOST_LVL(NONE)
BOOST_LVL(AVATAR_BAKED)
BOOST_LVL(AVATAR)
BOOST_LVL(CLOUDS)
BOOST_LVL(SCULPTED)
BOOST_LVL(HIGH)
BOOST_LVL(BUMP)
BOOST_LVL(TERRAIN)
BOOST_LVL(SELECTED)
BOOST_LVL(AVATAR_BAKED_SELF)
BOOST_LVL(AVATAR_SELF)
BOOST_LVL(SUPER_HIGH)
BOOST_LVL(HUD)
BOOST_LVL(ICON)
BOOST_LVL(UI)
BOOST_LVL(PREVIEW)
BOOST_LVL(MAP)
BOOST_LVL(MAP_VISIBLE)
CAT_LVL(LOCAL)
CAT_LVL(AVATAR_SCRATCH_TEX)
CAT_LVL(DYNAMIC_TEX)
CAT_LVL(MEDIA)
CAT_LVL(OTHER)
CAT_LVL(MAX_GL_IMAGE_CATEGORY)
default:;
};
std::string num_str = llformat("%4dx%4d (%+d) %7d %s", mImagep->getWidth(), mImagep->getHeight(),
mImagep->getDiscardLevel(), mImagep->hasGLTexture() ? mImagep->getTextureMemory() : 0, boost_lvl.c_str());
LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color, LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color,
LLFontGL::LEFT, LLFontGL::TOP); LLFontGL::LEFT, LLFontGL::TOP);
} }

View File

@@ -926,7 +926,7 @@ void LLViewerFetchedTexture::init(bool firstinit)
mIsMissingAsset = FALSE; mIsMissingAsset = FALSE;
mLoadedCallbackDesiredDiscardLevel = S8_MAX; mLoadedCallbackDesiredDiscardLevel = S8_MAX;
mPauseLoadedCallBacks = TRUE ; mPauseLoadedCallBacks = FALSE ;
mNeedsCreateTexture = FALSE; mNeedsCreateTexture = FALSE;
@@ -1288,6 +1288,7 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
// An inappropriately-sized image was uploaded (through a non standard client) // An inappropriately-sized image was uploaded (through a non standard client)
// We treat these images as missing assets which causes them to // We treat these images as missing assets which causes them to
// be renderd as 'missing image' and to stop requesting data // be renderd as 'missing image' and to stop requesting data
llwarns << "!size_ok, setting as missing" << llendl;
setIsMissingAsset(); setIsMissingAsset();
destroyRawImage(); destroyRawImage();
return FALSE; return FALSE;
@@ -1712,6 +1713,7 @@ bool LLViewerFetchedTexture::updateFetch()
{ {
//discard all oversized textures. //discard all oversized textures.
destroyRawImage(); destroyRawImage();
llwarns << "oversize, setting as missing" << llendl;
setIsMissingAsset(); setIsMissingAsset();
mRawDiscardLevel = INVALID_DISCARD_LEVEL ; mRawDiscardLevel = INVALID_DISCARD_LEVEL ;
mIsFetching = FALSE ; mIsFetching = FALSE ;
@@ -1741,6 +1743,10 @@ bool LLViewerFetchedTexture::updateFetch()
// We finished but received no data // We finished but received no data
if (current_discard < 0) if (current_discard < 0)
{ {
llwarns << "!mIsFetching, setting as missing, decode_priority " << decode_priority
<< " mRawDiscardLevel " << mRawDiscardLevel
<< " current_discard " << current_discard
<< llendl;
setIsMissingAsset(); setIsMissingAsset();
desired_discard = -1; desired_discard = -1;
} }
@@ -1781,6 +1787,10 @@ bool LLViewerFetchedTexture::updateFetch()
{ {
make_request = false; make_request = false;
} }
else if(mDesiredDiscardLevel > getMaxDiscardLevel())
{
make_request = false;
}
else if (mNeedsCreateTexture || mIsMissingAsset) else if (mNeedsCreateTexture || mIsMissingAsset)
{ {
make_request = false; make_request = false;
@@ -1789,6 +1799,11 @@ bool LLViewerFetchedTexture::updateFetch()
{ {
make_request = false; make_request = false;
} }
else if(mCachedRawImage.notNull() && (current_discard < 0 || current_discard > mCachedRawDiscardLevel))
{
make_request = false;
switchToCachedImage() ; //use the cached raw data first
}
//else if (!isJustBound() && mCachedRawImageReady) //else if (!isJustBound() && mCachedRawImageReady)
//{ //{
// make_request = false; // make_request = false;
@@ -1881,11 +1896,14 @@ void LLViewerFetchedTexture::forceToDeleteRequest()
{ {
if (mHasFetcher) if (mHasFetcher)
{ {
LLAppViewer::getTextureFetch()->deleteRequest(getID(), true); //LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
mHasFetcher = FALSE; mHasFetcher = FALSE;
mIsFetching = FALSE ; mIsFetching = FALSE ;
resetTextureStats();
} }
resetTextureStats();
mDesiredDiscardLevel = getMaxDiscardLevel() + 1; //defer LLAppViewer::getTextureFetch()->deleteRequest to updateFetch?
} }
void LLViewerFetchedTexture::setIsMissingAsset() void LLViewerFetchedTexture::setIsMissingAsset()
@@ -1928,10 +1946,18 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
mLoadedCallbackDesiredDiscardLevel = llmin(mLoadedCallbackDesiredDiscardLevel, (S8)discard_level) ; mLoadedCallbackDesiredDiscardLevel = llmin(mLoadedCallbackDesiredDiscardLevel, (S8)discard_level) ;
} }
if(mPauseLoadedCallBacks && !pause) if(mPauseLoadedCallBacks)
{ {
unpauseLoadedCallbacks(src_callback_list) ; if(!pause)
{
unpauseLoadedCallbacks(src_callback_list) ;
}
} }
else if(pause)
{
pauseLoadedCallbacks(src_callback_list) ;
}
LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata, src_callback_list, this, pause); LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata, src_callback_list, this, pause);
mLoadedCallbackList.push_back(entryp); mLoadedCallbackList.push_back(entryp);

View File

@@ -1466,6 +1466,7 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **
LLViewerFetchedTexture* image = gTextureList.findImage( image_id ); LLViewerFetchedTexture* image = gTextureList.findImage( image_id );
if( image ) if( image )
{ {
llwarns << "not in db" << llendl;
image->setIsMissingAsset(); image->setIsMissingAsset();
} }
} }

View File

@@ -3768,6 +3768,23 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
else if (!getParent() && mIsSitting && !isMotionActive(ANIM_AGENT_SIT_GROUND_CONSTRAINED)) else if (!getParent() && mIsSitting && !isMotionActive(ANIM_AGENT_SIT_GROUND_CONSTRAINED))
{ {
getOffObject(); getOffObject();
//<edit>
//Singu note: this appears to be a safety catch:
// when getParent() is NULL and we're note playing ANIM_AGENT_SIT_GROUND_CONSTRAINED then we aren't sitting!
// The previous call existed in an attempt to fix this inconsistent state by standing up from an object.
// However, since getParent() is NULL that function would crash!
// Since we never got crash reports regarding to this, that apparently never happened, except, I discovered
// today, when you are ground sitting and then LLMotionController::deleteAllMotions or
// LLMotionController::deactivateAllMotions is called, which seems to only happen when previewing an
// to-be-uploaded animation on your own avatar (while ground sitting).
// Hence, we DO need this safety net but not for standing up from an object but for standing up from the ground.
// I fixed the crash in getOffObject(), so it's ok to call that. In order to make things consistent with
// the server we need to actually stand up though, or we can't move anymore afterwards.
if (isSelf())
{
gAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
}
//</edit>
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@@ -6564,7 +6581,7 @@ void LLVOAvatar::getOffObject()
gAgentCamera.setSitCamera(LLUUID::null); gAgentCamera.setSitCamera(LLUUID::null);
if (!sit_object->permYouOwner() && gSavedSettings.getBOOL("RevokePermsOnStandUp")) if (sit_object && !sit_object->permYouOwner() && gSavedSettings.getBOOL("RevokePermsOnStandUp"))
{ {
gMessageSystem->newMessageFast(_PREHASH_RevokePermissions); gMessageSystem->newMessageFast(_PREHASH_RevokePermissions);
gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->nextBlockFast(_PREHASH_AgentData);