diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltextureview.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/lltextureview.cpp')
-rw-r--r-- | linden/indra/newview/lltextureview.cpp | 323 |
1 files changed, 323 insertions, 0 deletions
diff --git a/linden/indra/newview/lltextureview.cpp b/linden/indra/newview/lltextureview.cpp new file mode 100644 index 0000000..75abb39 --- /dev/null +++ b/linden/indra/newview/lltextureview.cpp | |||
@@ -0,0 +1,323 @@ | |||
1 | /** | ||
2 | * @file lltextureview.cpp | ||
3 | * @brief LLTextureView class implementation | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include <set> | ||
31 | |||
32 | #include "lltextureview.h" | ||
33 | |||
34 | #include "llrect.h" | ||
35 | #include "llerror.h" | ||
36 | |||
37 | #include "viewer.h" | ||
38 | #include "llui.h" | ||
39 | |||
40 | #include "llviewerimagelist.h" | ||
41 | #include "llselectmgr.h" | ||
42 | #include "llviewerobject.h" | ||
43 | #include "llviewerimage.h" | ||
44 | #include "llhoverview.h" | ||
45 | |||
46 | LLTextureView *gTextureView = NULL; | ||
47 | |||
48 | //static | ||
49 | std::set<LLViewerImage*> LLTextureView::sDebugImages; | ||
50 | |||
51 | // Used for sorting | ||
52 | struct SortTextureBars | ||
53 | { | ||
54 | bool operator()(const LLView* i1, const LLView* i2) | ||
55 | { | ||
56 | LLTextureBar* bar1p = (LLTextureBar*)i1; | ||
57 | LLTextureBar* bar2p = (LLTextureBar*)i2; | ||
58 | LLViewerImage *i1p = bar1p->mImagep; | ||
59 | LLViewerImage *i2p = bar2p->mImagep; | ||
60 | F32 pri1 = i1p->getDecodePriority(); // i1p->mRequestedDownloadPriority | ||
61 | F32 pri2 = i2p->getDecodePriority(); // i2p->mRequestedDownloadPriority | ||
62 | if (pri1 > pri2) | ||
63 | return true; | ||
64 | else if (pri2 > pri1) | ||
65 | return false; | ||
66 | else | ||
67 | return i1p->getID() < i2p->getID(); | ||
68 | } | ||
69 | }; | ||
70 | |||
71 | LLTextureView::LLTextureView(const std::string& name, const LLRect& rect) | ||
72 | : LLContainerView(name, rect) | ||
73 | { | ||
74 | setVisible(FALSE); | ||
75 | mFreezeView = FALSE; | ||
76 | |||
77 | mNumTextureBars = 0; | ||
78 | setDisplayChildren(TRUE); | ||
79 | mGLTexMemBar = 0; | ||
80 | } | ||
81 | |||
82 | LLTextureView::~LLTextureView() | ||
83 | { | ||
84 | // Children all cleaned up by default view destructor. | ||
85 | delete mGLTexMemBar; | ||
86 | mGLTexMemBar = 0; | ||
87 | } | ||
88 | |||
89 | EWidgetType LLTextureView::getWidgetType() const | ||
90 | { | ||
91 | return WIDGET_TYPE_TEXTURE_VIEW; | ||
92 | } | ||
93 | |||
94 | LLString LLTextureView::getWidgetTag() const | ||
95 | { | ||
96 | return LL_TEXTURE_VIEW_TAG; | ||
97 | } | ||
98 | |||
99 | |||
100 | typedef std::pair<F32,LLViewerImage*> decode_pair_t; | ||
101 | struct compare_decode_pair | ||
102 | { | ||
103 | bool operator()(const decode_pair_t& a, const decode_pair_t& b) | ||
104 | { | ||
105 | return a.first > b.first; | ||
106 | } | ||
107 | }; | ||
108 | |||
109 | void LLTextureView::draw() | ||
110 | { | ||
111 | if (!mFreezeView) | ||
112 | { | ||
113 | // LLViewerObject *objectp; | ||
114 | // S32 te; | ||
115 | |||
116 | for_each(mTextureBars.begin(), mTextureBars.end(), DeletePointer()); | ||
117 | mTextureBars.clear(); | ||
118 | |||
119 | delete mGLTexMemBar; | ||
120 | mGLTexMemBar = 0; | ||
121 | |||
122 | typedef std::multiset<decode_pair_t, compare_decode_pair > display_list_t; | ||
123 | display_list_t display_image_list; | ||
124 | |||
125 | for (LLViewerImageList::image_list_t::iterator iter = gImageList.mImageList.begin(); | ||
126 | iter != gImageList.mImageList.end(); ) | ||
127 | { | ||
128 | LLPointer<LLViewerImage> imagep = *iter++; | ||
129 | #if 1 | ||
130 | if (imagep->getDontDiscard()) | ||
131 | { | ||
132 | continue; | ||
133 | } | ||
134 | #endif | ||
135 | if (imagep->isMissingAsset()) | ||
136 | { | ||
137 | continue; | ||
138 | } | ||
139 | |||
140 | #define HIGH_PRIORITY 100000000.f | ||
141 | F32 pri = imagep->getDecodePriority(); | ||
142 | |||
143 | if (sDebugImages.find(imagep) != sDebugImages.end()) | ||
144 | { | ||
145 | pri += 3*HIGH_PRIORITY; | ||
146 | } | ||
147 | |||
148 | #if 1 | ||
149 | if (pri < HIGH_PRIORITY && gSelectMgr) | ||
150 | { | ||
151 | S32 te; | ||
152 | LLViewerObject *objectp; | ||
153 | for (gSelectMgr->getFirstTE(&objectp, &te); objectp; gSelectMgr->getNextTE(&objectp, &te)) | ||
154 | { | ||
155 | if (imagep == objectp->getTEImage(te)) | ||
156 | { | ||
157 | pri += 2*HIGH_PRIORITY; | ||
158 | break; | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | #endif | ||
163 | #if 1 | ||
164 | if (pri < HIGH_PRIORITY) | ||
165 | { | ||
166 | LLViewerObject *objectp = gHoverView->getLastHoverObject(); | ||
167 | if (objectp) | ||
168 | { | ||
169 | S32 tex_count = objectp->getNumTEs(); | ||
170 | for (S32 i = 0; i < tex_count; i++) | ||
171 | { | ||
172 | if (imagep == objectp->getTEImage(i)) | ||
173 | { | ||
174 | pri += 2*HIGH_PRIORITY; | ||
175 | break; | ||
176 | } | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | #endif | ||
181 | #if 0 | ||
182 | if (pri < HIGH_PRIORITY) | ||
183 | { | ||
184 | if (imagep->mBoostPriority) | ||
185 | { | ||
186 | pri += 4*HIGH_PRIORITY; | ||
187 | } | ||
188 | } | ||
189 | #endif | ||
190 | #if 1 | ||
191 | if (pri > 0.f && pri < HIGH_PRIORITY) | ||
192 | { | ||
193 | if (imagep->mLastPacketTimer.getElapsedTimeF32() < 1.f || | ||
194 | imagep->mLastDecodeTime.getElapsedTimeF32() < 1.f) | ||
195 | { | ||
196 | pri += 1*HIGH_PRIORITY; | ||
197 | } | ||
198 | } | ||
199 | #endif | ||
200 | // if (pri > 0.0f) | ||
201 | { | ||
202 | display_image_list.insert(std::make_pair(pri, imagep)); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | static S32 max_count = 50; | ||
207 | S32 count = 0; | ||
208 | for (display_list_t::iterator iter = display_image_list.begin(); | ||
209 | iter != display_image_list.end(); iter++) | ||
210 | { | ||
211 | LLViewerImage* imagep = iter->second; | ||
212 | S32 hilite = 0; | ||
213 | F32 pri = iter->first; | ||
214 | if (pri >= 1 * HIGH_PRIORITY) | ||
215 | { | ||
216 | hilite = (S32)((pri+1) / HIGH_PRIORITY) - 1; | ||
217 | } | ||
218 | if ((hilite || count < max_count-10) && (count < max_count)) | ||
219 | { | ||
220 | if (addBar(imagep, hilite)) | ||
221 | { | ||
222 | count++; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | sortChildren(SortTextureBars()); | ||
228 | |||
229 | mGLTexMemBar = new LLGLTexMemBar("gl texmem bar"); | ||
230 | addChild(mGLTexMemBar); | ||
231 | |||
232 | reshape(mRect.getWidth(), mRect.getHeight(), TRUE); | ||
233 | |||
234 | /* | ||
235 | count = gImageList.getNumImages(); | ||
236 | char info_string[512]; | ||
237 | sprintf(info_string, "Global Info:\nTexture Count: %d", count); | ||
238 | mInfoTextp->setText(info_string); | ||
239 | */ | ||
240 | |||
241 | |||
242 | for (child_list_const_iter_t child_iter = getChildList()->begin(); | ||
243 | child_iter != getChildList()->end(); ++child_iter) | ||
244 | { | ||
245 | LLView *viewp = *child_iter; | ||
246 | if (viewp->getRect().mBottom < 0) | ||
247 | { | ||
248 | viewp->setVisible(FALSE); | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | LLContainerView::draw(); | ||
254 | |||
255 | } | ||
256 | |||
257 | BOOL LLTextureView::addBar(LLViewerImage *imagep, S32 hilite) | ||
258 | { | ||
259 | if (!imagep) | ||
260 | { | ||
261 | return FALSE; | ||
262 | } | ||
263 | |||
264 | LLTextureBar *barp; | ||
265 | LLRect r; | ||
266 | |||
267 | mNumTextureBars++; | ||
268 | |||
269 | for (std::vector<LLTextureBar*>::iterator iter = mTextureBars.begin(); | ||
270 | iter != mTextureBars.end(); iter++) | ||
271 | { | ||
272 | LLTextureBar* barp = *iter; | ||
273 | if (barp->mImagep == imagep) | ||
274 | { | ||
275 | barp->mHilite = hilite; | ||
276 | return FALSE; | ||
277 | } | ||
278 | } | ||
279 | |||
280 | barp = new LLTextureBar("texture bar", r); | ||
281 | barp->mImagep = imagep; | ||
282 | barp->mHilite = hilite; | ||
283 | |||
284 | addChild(barp); | ||
285 | mTextureBars.push_back(barp); | ||
286 | |||
287 | // Rearrange all child bars. | ||
288 | reshape(mRect.getWidth(), mRect.getHeight()); | ||
289 | return TRUE; | ||
290 | } | ||
291 | |||
292 | BOOL LLTextureView::handleMouseDown(S32 x, S32 y, MASK mask) | ||
293 | { | ||
294 | if (mask & MASK_SHIFT) | ||
295 | { | ||
296 | mFreezeView = !mFreezeView; | ||
297 | return TRUE; | ||
298 | } | ||
299 | else if (mask & MASK_CONTROL) | ||
300 | { | ||
301 | return FALSE; | ||
302 | } | ||
303 | else | ||
304 | { | ||
305 | return FALSE; | ||
306 | } | ||
307 | } | ||
308 | |||
309 | BOOL LLTextureView::handleMouseUp(S32 x, S32 y, MASK mask) | ||
310 | { | ||
311 | return FALSE; | ||
312 | } | ||
313 | |||
314 | BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent) | ||
315 | { | ||
316 | if (key == ' ') | ||
317 | { | ||
318 | mFreezeView = !mFreezeView; | ||
319 | return TRUE; | ||
320 | } | ||
321 | return FALSE; | ||
322 | } | ||
323 | |||