diff options
Diffstat (limited to 'linden/indra/newview/llviewerimage.cpp')
-rw-r--r-- | linden/indra/newview/llviewerimage.cpp | 144 |
1 files changed, 129 insertions, 15 deletions
diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp index 671a359..28561ed 100644 --- a/linden/indra/newview/llviewerimage.cpp +++ b/linden/indra/newview/llviewerimage.cpp | |||
@@ -61,6 +61,7 @@ | |||
61 | #include "llappviewer.h" | 61 | #include "llappviewer.h" |
62 | #include "llface.h" | 62 | #include "llface.h" |
63 | #include "llviewercamera.h" | 63 | #include "llviewercamera.h" |
64 | #include "llvovolume.h" | ||
64 | /////////////////////////////////////////////////////////////////////////////// | 65 | /////////////////////////////////////////////////////////////////////////////// |
65 | 66 | ||
66 | // statics | 67 | // statics |
@@ -352,6 +353,11 @@ void LLViewerImage::init(bool firstinit) | |||
352 | mDesiredSavedRawDiscardLevel = -1 ; | 353 | mDesiredSavedRawDiscardLevel = -1 ; |
353 | 354 | ||
354 | mCanUseHTTP = true; //default on if cap/settings allows us | 355 | mCanUseHTTP = true; //default on if cap/settings allows us |
356 | |||
357 | mNumFaces = 0 ; | ||
358 | mNumVolumes = 0; | ||
359 | mFaceList.clear() ; | ||
360 | mVolumeList.clear(); | ||
355 | } | 361 | } |
356 | 362 | ||
357 | // virtual | 363 | // virtual |
@@ -388,6 +394,7 @@ LLViewerImage::~LLViewerImage() | |||
388 | void LLViewerImage::cleanup() | 394 | void LLViewerImage::cleanup() |
389 | { | 395 | { |
390 | mFaceList.clear() ; | 396 | mFaceList.clear() ; |
397 | mVolumeList.clear(); | ||
391 | for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); | 398 | for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); |
392 | iter != mLoadedCallbackList.end(); ) | 399 | iter != mLoadedCallbackList.end(); ) |
393 | { | 400 | { |
@@ -754,19 +761,19 @@ void LLViewerImage::updateVirtualSize() | |||
754 | { | 761 | { |
755 | addTextureStats(0.f, FALSE) ;//reset | 762 | addTextureStats(0.f, FALSE) ;//reset |
756 | } | 763 | } |
757 | if(mFaceList.size() > 0) | 764 | for(U32 i = 0 ; i < mNumFaces ; i++) |
758 | { | 765 | { |
759 | for(std::list<LLFace*>::iterator iter = mFaceList.begin(); iter != mFaceList.end(); ++iter) | 766 | LLFace* facep = mFaceList[i] ; |
767 | if(facep->getDrawable()->isRecentlyVisible()) | ||
760 | { | 768 | { |
761 | LLFace* facep = *iter ; | 769 | addTextureStats(facep->getVirtualSize()) ; |
762 | if(facep->getDrawable()->isRecentlyVisible()) | 770 | setAdditionalDecodePriority(facep->getImportanceToCamera()) ; |
763 | { | 771 | } |
764 | addTextureStats(facep->getVirtualSize()) ; | ||
765 | setAdditionalDecodePriority(facep->getImportanceToCamera()) ; | ||
766 | } | ||
767 | } | ||
768 | } | 772 | } |
773 | |||
769 | mNeedsResetMaxVirtualSize = TRUE ; | 774 | mNeedsResetMaxVirtualSize = TRUE ; |
775 | reorganizeFaceList(); | ||
776 | reorganizeVolumeList(); | ||
770 | #endif | 777 | #endif |
771 | } | 778 | } |
772 | void LLViewerImage::scaleDown() | 779 | void LLViewerImage::scaleDown() |
@@ -1759,13 +1766,19 @@ void LLViewerImage::setCachedRawImage() | |||
1759 | if(mForSculpt) | 1766 | if(mForSculpt) |
1760 | { | 1767 | { |
1761 | max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA ; | 1768 | max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA ; |
1769 | // Even though we don't use the full pixel size, we want to decode up to discard 0, | ||
1770 | // because some legacy sculpts are weird like that. | ||
1771 | mCachedRawImageReady = !mRawDiscardLevel ; | ||
1772 | } | ||
1773 | else | ||
1774 | { | ||
1775 | mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)) ; | ||
1762 | } | 1776 | } |
1763 | 1777 | ||
1764 | while(((w >> i) * (h >> i)) > max_size) | 1778 | while(((w >> i) * (h >> i)) > max_size) |
1765 | { | 1779 | { |
1766 | ++i ; | 1780 | ++i ; |
1767 | } | 1781 | } |
1768 | mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)) ; | ||
1769 | 1782 | ||
1770 | if(i) | 1783 | if(i) |
1771 | { | 1784 | { |
@@ -1776,7 +1789,8 @@ void LLViewerImage::setCachedRawImage() | |||
1776 | mRawImage->scale(w >> i, h >> i) ; | 1789 | mRawImage->scale(w >> i, h >> i) ; |
1777 | } | 1790 | } |
1778 | mCachedRawImage = mRawImage ; | 1791 | mCachedRawImage = mRawImage ; |
1779 | mCachedRawDiscardLevel = mRawDiscardLevel + i ; | 1792 | mRawDiscardLevel += i ; |
1793 | mCachedRawDiscardLevel = mRawDiscardLevel ; | ||
1780 | } | 1794 | } |
1781 | } | 1795 | } |
1782 | 1796 | ||
@@ -1784,7 +1798,7 @@ void LLViewerImage::checkCachedRawSculptImage() | |||
1784 | { | 1798 | { |
1785 | if(mCachedRawImageReady && mCachedRawDiscardLevel > 0) | 1799 | if(mCachedRawImageReady && mCachedRawDiscardLevel > 0) |
1786 | { | 1800 | { |
1787 | if(mCachedRawImage->getWidth() * mCachedRawImage->getHeight() < MAX_CACHED_RAW_SCULPT_IMAGE_AREA) | 1801 | if(getDiscardLevel() != 0) |
1788 | { | 1802 | { |
1789 | mCachedRawImageReady = FALSE ; | 1803 | mCachedRawImageReady = FALSE ; |
1790 | } | 1804 | } |
@@ -1810,11 +1824,111 @@ void LLViewerImage::setForSculpt() | |||
1810 | checkCachedRawSculptImage() ; | 1824 | checkCachedRawSculptImage() ; |
1811 | } | 1825 | } |
1812 | 1826 | ||
1827 | //virtual | ||
1813 | void LLViewerImage::addFace(LLFace* facep) | 1828 | void LLViewerImage::addFace(LLFace* facep) |
1814 | { | 1829 | { |
1815 | mFaceList.push_back(facep) ; | 1830 | if(mNumFaces >= mFaceList.size()) |
1831 | { | ||
1832 | mFaceList.resize(2 * mNumFaces + 1) ; | ||
1833 | } | ||
1834 | mFaceList[mNumFaces] = facep ; | ||
1835 | facep->setIndexInTex(mNumFaces) ; | ||
1836 | mNumFaces++ ; | ||
1837 | mLastFaceListUpdateTimer.reset() ; | ||
1838 | } | ||
1839 | |||
1840 | //virtual | ||
1841 | void LLViewerImage::removeFace(LLFace* facep) | ||
1842 | { | ||
1843 | if(mNumFaces > 1) | ||
1844 | { | ||
1845 | S32 index = facep->getIndexInTex() ; | ||
1846 | mFaceList[index] = mFaceList[--mNumFaces] ; | ||
1847 | mFaceList[index]->setIndexInTex(index) ; | ||
1848 | } | ||
1849 | else | ||
1850 | { | ||
1851 | mFaceList.clear() ; | ||
1852 | mNumFaces = 0 ; | ||
1853 | } | ||
1854 | mLastFaceListUpdateTimer.reset() ; | ||
1855 | } | ||
1856 | |||
1857 | S32 LLViewerImage::getNumFaces() const | ||
1858 | { | ||
1859 | return mNumFaces ; | ||
1860 | } | ||
1861 | |||
1862 | |||
1863 | //virtual | ||
1864 | void LLViewerImage::addVolume(LLVOVolume* volumep) | ||
1865 | { | ||
1866 | if( mNumVolumes >= mVolumeList.size()) | ||
1867 | { | ||
1868 | mVolumeList.resize(2 * mNumVolumes + 1) ; | ||
1869 | } | ||
1870 | mVolumeList[mNumVolumes] = volumep ; | ||
1871 | volumep->setIndexInTex(mNumVolumes) ; | ||
1872 | mNumVolumes++ ; | ||
1873 | mLastVolumeListUpdateTimer.reset() ; | ||
1874 | } | ||
1875 | |||
1876 | //virtual | ||
1877 | void LLViewerImage::removeVolume(LLVOVolume* volumep) | ||
1878 | { | ||
1879 | if(mNumVolumes > 1) | ||
1880 | { | ||
1881 | S32 index = volumep->getIndexInTex() ; | ||
1882 | mVolumeList[index] = mVolumeList[--mNumVolumes] ; | ||
1883 | mVolumeList[index]->setIndexInTex(index) ; | ||
1884 | } | ||
1885 | else | ||
1886 | { | ||
1887 | mVolumeList.clear() ; | ||
1888 | mNumVolumes = 0 ; | ||
1889 | } | ||
1890 | mLastVolumeListUpdateTimer.reset() ; | ||
1816 | } | 1891 | } |
1817 | void LLViewerImage::removeFace(LLFace* facep) | 1892 | |
1893 | S32 LLViewerImage::getNumVolumes() const | ||
1818 | { | 1894 | { |
1819 | mFaceList.remove(facep) ; | 1895 | return mNumVolumes ; |
1896 | } | ||
1897 | |||
1898 | void LLViewerImage::reorganizeFaceList() | ||
1899 | { | ||
1900 | static const F32 MAX_WAIT_TIME = 20.f; // seconds | ||
1901 | static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ; | ||
1902 | |||
1903 | if(mNumFaces + MAX_EXTRA_BUFFER_SIZE > mFaceList.size()) | ||
1904 | { | ||
1905 | return ; | ||
1906 | } | ||
1907 | |||
1908 | if(mLastFaceListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME) | ||
1909 | { | ||
1910 | return ; | ||
1911 | } | ||
1912 | |||
1913 | mLastFaceListUpdateTimer.reset() ; | ||
1914 | mFaceList.erase(mFaceList.begin() + mNumFaces, mFaceList.end()); | ||
1915 | } | ||
1916 | |||
1917 | void LLViewerImage::reorganizeVolumeList() | ||
1918 | { | ||
1919 | static const F32 MAX_WAIT_TIME = 20.f; // seconds | ||
1920 | static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ; | ||
1921 | |||
1922 | if(mNumVolumes + MAX_EXTRA_BUFFER_SIZE > mVolumeList.size()) | ||
1923 | { | ||
1924 | return ; | ||
1925 | } | ||
1926 | |||
1927 | if(mLastVolumeListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME) | ||
1928 | { | ||
1929 | return ; | ||
1930 | } | ||
1931 | |||
1932 | mLastVolumeListUpdateTimer.reset() ; | ||
1933 | mVolumeList.erase(mVolumeList.begin() + mNumVolumes, mVolumeList.end()); | ||
1820 | } | 1934 | } |