aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatersnapshot.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llfloatersnapshot.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloatersnapshot.cpp550
1 files changed, 444 insertions, 106 deletions
diff --git a/linden/indra/newview/llfloatersnapshot.cpp b/linden/indra/newview/llfloatersnapshot.cpp
index 54895d5..9c91348 100644
--- a/linden/indra/newview/llfloatersnapshot.cpp
+++ b/linden/indra/newview/llfloatersnapshot.cpp
@@ -36,7 +36,9 @@
36#include "llfontgl.h" 36#include "llfontgl.h"
37#include "llsys.h" 37#include "llsys.h"
38#include "llgl.h" 38#include "llgl.h"
39#include "llglimmediate.h"
39#include "v3dmath.h" 40#include "v3dmath.h"
41#include "llmath.h"
40#include "lldir.h" 42#include "lldir.h"
41#include "llsdserialize.h" 43#include "llsdserialize.h"
42 44
@@ -86,7 +88,7 @@ F32 FALL_TIME = 0.6f;
86S32 BORDER_WIDTH = 6; 88S32 BORDER_WIDTH = 6;
87 89
88const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte 90const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte
89 91#define MAX_TEXTURE_SIZE 512 //max upload texture size 512 * 512
90///---------------------------------------------------------------------------- 92///----------------------------------------------------------------------------
91/// Class LLSnapshotLivePreview 93/// Class LLSnapshotLivePreview
92///---------------------------------------------------------------------------- 94///----------------------------------------------------------------------------
@@ -112,6 +114,8 @@ public:
112 void setSize(S32 w, S32 h); 114 void setSize(S32 w, S32 h);
113 void getSize(S32& w, S32& h) const; 115 void getSize(S32& w, S32& h) const;
114 S32 getDataSize() const { return mDataSize; } 116 S32 getDataSize() const { return mDataSize; }
117 void setMaxImageSize(S32 size) ;
118 S32 getMaxImageSize() {return mMaxImageSize ;}
115 119
116 ESnapshotType getSnapshotType() const { return mSnapshotType; } 120 ESnapshotType getSnapshotType() const { return mSnapshotType; }
117 BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } 121 BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; }
@@ -138,7 +142,8 @@ protected:
138 S32 mWidth[2]; 142 S32 mWidth[2];
139 S32 mHeight[2]; 143 S32 mHeight[2];
140 BOOL mImageScaled[2]; 144 BOOL mImageScaled[2];
141 145 S32 mMaxImageSize ;
146
142 S32 mCurImageIndex; 147 S32 mCurImageIndex;
143 LLPointer<LLImageRaw> mRawImage; 148 LLPointer<LLImageRaw> mRawImage;
144 LLPointer<LLImageRaw> mRawImageEncoded; 149 LLPointer<LLImageRaw> mRawImageEncoded;
@@ -161,6 +166,7 @@ protected:
161 166
162public: 167public:
163 static std::set<LLSnapshotLivePreview*> sList; 168 static std::set<LLSnapshotLivePreview*> sList;
169 BOOL mKeepAspectRatio ;
164}; 170};
165 171
166std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList; 172std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList;
@@ -195,6 +201,9 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) :
195 mHeight[1] = gViewerWindow->getWindowDisplayHeight(); 201 mHeight[1] = gViewerWindow->getWindowDisplayHeight();
196 mImageScaled[0] = FALSE; 202 mImageScaled[0] = FALSE;
197 mImageScaled[1] = FALSE; 203 mImageScaled[1] = FALSE;
204
205 mMaxImageSize = MAX_IMAGE_SIZE ;
206 mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ;
198} 207}
199 208
200LLSnapshotLivePreview::~LLSnapshotLivePreview() 209LLSnapshotLivePreview::~LLSnapshotLivePreview()
@@ -208,6 +217,18 @@ LLSnapshotLivePreview::~LLSnapshotLivePreview()
208 sList.erase(this); 217 sList.erase(this);
209} 218}
210 219
220void LLSnapshotLivePreview::setMaxImageSize(S32 size)
221{
222 if(size < MAX_IMAGE_SIZE)
223 {
224 mMaxImageSize = size;
225 }
226 else
227 {
228 mMaxImageSize = MAX_IMAGE_SIZE ;
229 }
230}
231
211LLImageGL* LLSnapshotLivePreview::getCurrentImage() 232LLImageGL* LLSnapshotLivePreview::getCurrentImage()
212{ 233{
213 return mViewerImage[mCurImageIndex]; 234 return mViewerImage[mCurImageIndex];
@@ -221,9 +242,9 @@ F32 LLSnapshotLivePreview::getImageAspect()
221 } 242 }
222 243
223 F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]); 244 F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]);
224 F32 window_aspect_ratio = ((F32)mRect.getWidth()) / ((F32)mRect.getHeight()); 245 F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight());
225 246
226 if (gSavedSettings.getBOOL("KeepAspectForSnapshot")) 247 if (!mKeepAspectRatio)//gSavedSettings.getBOOL("KeepAspectForSnapshot"))
227 { 248 {
228 return image_aspect_ratio; 249 return image_aspect_ratio;
229 } 250 }
@@ -262,26 +283,26 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot)
262 } 283 }
263 284
264 LLRect& rect = mImageRect[mCurImageIndex]; 285 LLRect& rect = mImageRect[mCurImageIndex];
265 rect.set(0, mRect.getHeight(), mRect.getWidth(), 0); 286 rect.set(0, getRect().getHeight(), getRect().getWidth(), 0);
266 287
267 F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]); 288 F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]);
268 F32 window_aspect_ratio = ((F32)mRect.getWidth()) / ((F32)mRect.getHeight()); 289 F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight());
269 290
270 if (gSavedSettings.getBOOL("KeepAspectForSnapshot")) 291 if (mKeepAspectRatio)//gSavedSettings.getBOOL("KeepAspectForSnapshot"))
271 { 292 {
272 if (image_aspect_ratio > window_aspect_ratio) 293 if (image_aspect_ratio > window_aspect_ratio)
273 { 294 {
274 // trim off top and bottom 295 // trim off top and bottom
275 S32 new_height = llround((F32)mRect.getWidth() / image_aspect_ratio); 296 S32 new_height = llround((F32)getRect().getWidth() / image_aspect_ratio);
276 rect.mBottom += (mRect.getHeight() - new_height) / 2; 297 rect.mBottom += (getRect().getHeight() - new_height) / 2;
277 rect.mTop -= (mRect.getHeight() - new_height) / 2; 298 rect.mTop -= (getRect().getHeight() - new_height) / 2;
278 } 299 }
279 else if (image_aspect_ratio < window_aspect_ratio) 300 else if (image_aspect_ratio < window_aspect_ratio)
280 { 301 {
281 // trim off left and right 302 // trim off left and right
282 S32 new_width = llround((F32)mRect.getHeight() * image_aspect_ratio); 303 S32 new_width = llround((F32)getRect().getHeight() * image_aspect_ratio);
283 rect.mLeft += (mRect.getWidth() - new_width) / 2; 304 rect.mLeft += (getRect().getWidth() - new_width) / 2;
284 rect.mRight -= (mRect.getWidth() - new_width) / 2; 305 rect.mRight -= (getRect().getWidth() - new_width) / 2;
285 } 306 }
286 } 307 }
287} 308}
@@ -314,15 +335,14 @@ void LLSnapshotLivePreview::draw()
314 mSnapshotUpToDate) 335 mSnapshotUpToDate)
315 { 336 {
316 LLColor4 bg_color(0.f, 0.f, 0.3f, 0.4f); 337 LLColor4 bg_color(0.f, 0.f, 0.3f, 0.4f);
317 gl_rect_2d(mRect, bg_color); 338 gl_rect_2d(getRect(), bg_color);
318 LLRect &rect = mImageRect[mCurImageIndex]; 339 LLRect &rect = mImageRect[mCurImageIndex];
319 LLRect shadow_rect = mImageRect[mCurImageIndex]; 340 LLRect shadow_rect = mImageRect[mCurImageIndex];
320 shadow_rect.stretch(BORDER_WIDTH); 341 shadow_rect.stretch(BORDER_WIDTH);
321 gl_drop_shadow(shadow_rect.mLeft, shadow_rect.mTop, shadow_rect.mRight, shadow_rect.mBottom, LLColor4(0.f, 0.f, 0.f, mNeedsFlash ? 0.f :0.5f), 10); 342 gl_drop_shadow(shadow_rect.mLeft, shadow_rect.mTop, shadow_rect.mRight, shadow_rect.mBottom, LLColor4(0.f, 0.f, 0.f, mNeedsFlash ? 0.f :0.5f), 10);
322 343
323 LLGLSTexture set_texture;
324 LLColor4 image_color(1.f, 1.f, 1.f, 1.f); 344 LLColor4 image_color(1.f, 1.f, 1.f, 1.f);
325 glColor4fv(image_color.mV); 345 gGL.color4fv(image_color.mV);
326 LLViewerImage::bindTexture(mViewerImage[mCurImageIndex]); 346 LLViewerImage::bindTexture(mViewerImage[mCurImageIndex]);
327 // calculate UV scale 347 // calculate UV scale
328 F32 uv_width = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mWidth[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f); 348 F32 uv_width = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mWidth[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f);
@@ -330,26 +350,26 @@ void LLSnapshotLivePreview::draw()
330 glPushMatrix(); 350 glPushMatrix();
331 { 351 {
332 glTranslatef((F32)rect.mLeft, (F32)rect.mBottom, 0.f); 352 glTranslatef((F32)rect.mLeft, (F32)rect.mBottom, 0.f);
333 glBegin(GL_QUADS); 353 gGL.begin(GL_QUADS);
334 { 354 {
335 glTexCoord2f(uv_width, uv_height); 355 gGL.texCoord2f(uv_width, uv_height);
336 glVertex2i(rect.getWidth(), rect.getHeight() ); 356 gGL.vertex2i(rect.getWidth(), rect.getHeight() );
337 357
338 glTexCoord2f(0.f, uv_height); 358 gGL.texCoord2f(0.f, uv_height);
339 glVertex2i(0, rect.getHeight() ); 359 gGL.vertex2i(0, rect.getHeight() );
340 360
341 glTexCoord2f(0.f, 0.f); 361 gGL.texCoord2f(0.f, 0.f);
342 glVertex2i(0, 0); 362 gGL.vertex2i(0, 0);
343 363
344 glTexCoord2f(uv_width, 0.f); 364 gGL.texCoord2f(uv_width, 0.f);
345 glVertex2i(rect.getWidth(), 0); 365 gGL.vertex2i(rect.getWidth(), 0);
346 } 366 }
347 glEnd(); 367 gGL.end();
348 } 368 }
349 glPopMatrix(); 369 glPopMatrix();
350 370
351 glColor4f(1.f, 1.f, 1.f, mFlashAlpha); 371 gGL.color4f(1.f, 1.f, 1.f, mFlashAlpha);
352 gl_rect_2d(mRect); 372 gl_rect_2d(getRect());
353 if (mNeedsFlash) 373 if (mNeedsFlash)
354 { 374 {
355 if (mFlashAlpha < 1.f) 375 if (mFlashAlpha < 1.f)
@@ -393,23 +413,23 @@ void LLSnapshotLivePreview::draw()
393 S32 y2 = gViewerWindow->getWindowHeight(); 413 S32 y2 = gViewerWindow->getWindowHeight();
394 414
395 LLGLSNoTexture no_texture; 415 LLGLSNoTexture no_texture;
396 glBegin(GL_QUADS); 416 gGL.begin(GL_QUADS);
397 { 417 {
398 glColor4f(1.f, 1.f, 1.f, 0.f); 418 gGL.color4f(1.f, 1.f, 1.f, 0.f);
399 glVertex2i(x1, y1); 419 gGL.vertex2i(x1, y1);
400 glVertex2i(x1 + gViewerWindow->getWindowWidth(), y2); 420 gGL.vertex2i(x1 + gViewerWindow->getWindowWidth(), y2);
401 glColor4f(1.f, 1.f, 1.f, SHINE_OPACITY); 421 gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY);
402 glVertex2i(x2 + gViewerWindow->getWindowWidth(), y2); 422 gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2);
403 glVertex2i(x2, y1); 423 gGL.vertex2i(x2, y1);
404 424
405 glColor4f(1.f, 1.f, 1.f, SHINE_OPACITY); 425 gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY);
406 glVertex2i(x2, y1); 426 gGL.vertex2i(x2, y1);
407 glVertex2i(x2 + gViewerWindow->getWindowWidth(), y2); 427 gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2);
408 glColor4f(1.f, 1.f, 1.f, 0.f); 428 gGL.color4f(1.f, 1.f, 1.f, 0.f);
409 glVertex2i(x3 + gViewerWindow->getWindowWidth(), y2); 429 gGL.vertex2i(x3 + gViewerWindow->getWindowWidth(), y2);
410 glVertex2i(x3, y1); 430 gGL.vertex2i(x3, y1);
411 } 431 }
412 glEnd(); 432 gGL.end();
413 } 433 }
414 434
415 if (mShineAnimTimer.getElapsedTimeF32() > SHINE_TIME) 435 if (mShineAnimTimer.getElapsedTimeF32() > SHINE_TIME)
@@ -422,31 +442,31 @@ void LLSnapshotLivePreview::draw()
422 // draw framing rectangle 442 // draw framing rectangle
423 { 443 {
424 LLGLSNoTexture no_texture; 444 LLGLSNoTexture no_texture;
425 glColor4f(1.f, 1.f, 1.f, 1.f); 445 gGL.color4f(1.f, 1.f, 1.f, 1.f);
426 LLRect outline_rect = mImageRect[mCurImageIndex]; 446 LLRect outline_rect = mImageRect[mCurImageIndex];
427 glBegin(GL_QUADS); 447 gGL.begin(GL_QUADS);
428 { 448 {
429 glVertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); 449 gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH);
430 glVertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); 450 gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH);
431 glVertex2i(outline_rect.mRight, outline_rect.mTop); 451 gGL.vertex2i(outline_rect.mRight, outline_rect.mTop);
432 glVertex2i(outline_rect.mLeft, outline_rect.mTop); 452 gGL.vertex2i(outline_rect.mLeft, outline_rect.mTop);
433 453
434 glVertex2i(outline_rect.mLeft, outline_rect.mBottom); 454 gGL.vertex2i(outline_rect.mLeft, outline_rect.mBottom);
435 glVertex2i(outline_rect.mRight, outline_rect.mBottom); 455 gGL.vertex2i(outline_rect.mRight, outline_rect.mBottom);
436 glVertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); 456 gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH);
437 glVertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); 457 gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH);
438 458
439 glVertex2i(outline_rect.mLeft, outline_rect.mTop); 459 gGL.vertex2i(outline_rect.mLeft, outline_rect.mTop);
440 glVertex2i(outline_rect.mLeft, outline_rect.mBottom); 460 gGL.vertex2i(outline_rect.mLeft, outline_rect.mBottom);
441 glVertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); 461 gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH);
442 glVertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); 462 gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH);
443 463
444 glVertex2i(outline_rect.mRight, outline_rect.mBottom); 464 gGL.vertex2i(outline_rect.mRight, outline_rect.mBottom);
445 glVertex2i(outline_rect.mRight, outline_rect.mTop); 465 gGL.vertex2i(outline_rect.mRight, outline_rect.mTop);
446 glVertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); 466 gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH);
447 glVertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); 467 gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH);
448 } 468 }
449 glEnd(); 469 gGL.end();
450 } 470 }
451 471
452 // draw old image dropping away 472 // draw old image dropping away
@@ -455,12 +475,10 @@ void LLSnapshotLivePreview::draw()
455 S32 old_image_index = (mCurImageIndex + 1) % 2; 475 S32 old_image_index = (mCurImageIndex + 1) % 2;
456 if (mViewerImage[old_image_index].notNull() && mFallAnimTimer.getElapsedTimeF32() < FALL_TIME) 476 if (mViewerImage[old_image_index].notNull() && mFallAnimTimer.getElapsedTimeF32() < FALL_TIME)
457 { 477 {
458 LLGLSTexture texture_set;
459
460 F32 fall_interp = mFallAnimTimer.getElapsedTimeF32() / FALL_TIME; 478 F32 fall_interp = mFallAnimTimer.getElapsedTimeF32() / FALL_TIME;
461 F32 alpha = clamp_rescale(fall_interp, 0.f, 1.f, 0.8f, 0.4f); 479 F32 alpha = clamp_rescale(fall_interp, 0.f, 1.f, 0.8f, 0.4f);
462 LLColor4 image_color(1.f, 1.f, 1.f, alpha); 480 LLColor4 image_color(1.f, 1.f, 1.f, alpha);
463 glColor4fv(image_color.mV); 481 gGL.color4fv(image_color.mV);
464 LLViewerImage::bindTexture(mViewerImage[old_image_index]); 482 LLViewerImage::bindTexture(mViewerImage[old_image_index]);
465 // calculate UV scale 483 // calculate UV scale
466 // *FIX get this to work with old image 484 // *FIX get this to work with old image
@@ -470,23 +488,23 @@ void LLSnapshotLivePreview::draw()
470 glPushMatrix(); 488 glPushMatrix();
471 { 489 {
472 LLRect& rect = mImageRect[old_image_index]; 490 LLRect& rect = mImageRect[old_image_index];
473 glTranslatef((F32)rect.mLeft, (F32)rect.mBottom - llround(mRect.getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); 491 glTranslatef((F32)rect.mLeft, (F32)rect.mBottom - llround(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f);
474 glRotatef(-45.f * fall_interp, 0.f, 0.f, 1.f); 492 glRotatef(-45.f * fall_interp, 0.f, 0.f, 1.f);
475 glBegin(GL_QUADS); 493 gGL.begin(GL_QUADS);
476 { 494 {
477 glTexCoord2f(uv_width, uv_height); 495 gGL.texCoord2f(uv_width, uv_height);
478 glVertex2i(rect.getWidth(), rect.getHeight() ); 496 gGL.vertex2i(rect.getWidth(), rect.getHeight() );
479 497
480 glTexCoord2f(0.f, uv_height); 498 gGL.texCoord2f(0.f, uv_height);
481 glVertex2i(0, rect.getHeight() ); 499 gGL.vertex2i(0, rect.getHeight() );
482 500
483 glTexCoord2f(0.f, 0.f); 501 gGL.texCoord2f(0.f, 0.f);
484 glVertex2i(0, 0); 502 gGL.vertex2i(0, 0);
485 503
486 glTexCoord2f(uv_width, 0.f); 504 gGL.texCoord2f(uv_width, 0.f);
487 glVertex2i(rect.getWidth(), 0); 505 gGL.vertex2i(rect.getWidth(), 0);
488 } 506 }
489 glEnd(); 507 gGL.end();
490 } 508 }
491 glPopMatrix(); 509 glPopMatrix();
492 } 510 }
@@ -497,7 +515,7 @@ void LLSnapshotLivePreview::draw()
497/*virtual*/ 515/*virtual*/
498void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_parent) 516void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_parent)
499{ 517{
500 LLRect old_rect = mRect; 518 LLRect old_rect = getRect();
501 LLView::reshape(width, height, called_from_parent); 519 LLView::reshape(width, height, called_from_parent);
502 if (old_rect.getWidth() != width || old_rect.getHeight() != height) 520 if (old_rect.getWidth() != width || old_rect.getHeight() != height)
503 { 521 {
@@ -552,10 +570,12 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview )
552 if(gViewerWindow->rawSnapshot(previewp->mRawImage, 570 if(gViewerWindow->rawSnapshot(previewp->mRawImage,
553 previewp->mWidth[previewp->mCurImageIndex], 571 previewp->mWidth[previewp->mCurImageIndex],
554 previewp->mHeight[previewp->mCurImageIndex], 572 previewp->mHeight[previewp->mCurImageIndex],
555 !gSavedSettings.getBOOL("KeepAspectForSnapshot"), 573 previewp->mKeepAspectRatio,//gSavedSettings.getBOOL("KeepAspectForSnapshot"),
574 previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_TEXTURE,
556 gSavedSettings.getBOOL("RenderUIInSnapshot"), 575 gSavedSettings.getBOOL("RenderUIInSnapshot"),
557 FALSE, 576 FALSE,
558 previewp->mSnapshotBufferType)) 577 previewp->mSnapshotBufferType,
578 previewp->getMaxImageSize()))
559 { 579 {
560 previewp->mRawImageEncoded->resize(previewp->mRawImage->getWidth(), previewp->mRawImage->getHeight(), previewp->mRawImage->getComponents()); 580 previewp->mRawImageEncoded->resize(previewp->mRawImage->getWidth(), previewp->mRawImage->getHeight(), previewp->mRawImage->getComponents());
561 581
@@ -726,6 +746,9 @@ public:
726 static void onClickKeep(void* data); 746 static void onClickKeep(void* data);
727 static void onClickNewSnapshot(void* data); 747 static void onClickNewSnapshot(void* data);
728 static void onClickAutoSnap(LLUICtrl *ctrl, void* data); 748 static void onClickAutoSnap(LLUICtrl *ctrl, void* data);
749 //static void onClickAdvanceSnap(LLUICtrl *ctrl, void* data);
750 static void onClickLess(void* data) ;
751 static void onClickMore(void* data) ;
729 static void onClickUICheck(LLUICtrl *ctrl, void* data); 752 static void onClickUICheck(LLUICtrl *ctrl, void* data);
730 static void onClickHUDCheck(LLUICtrl *ctrl, void* data); 753 static void onClickHUDCheck(LLUICtrl *ctrl, void* data);
731 static void onClickKeepOpenCheck(LLUICtrl *ctrl, void* data); 754 static void onClickKeepOpenCheck(LLUICtrl *ctrl, void* data);
@@ -736,19 +759,22 @@ public:
736 static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); 759 static void onCommitLayerTypes(LLUICtrl* ctrl, void*data);
737 static void onCommitSnapshotType(LLUICtrl* ctrl, void* data); 760 static void onCommitSnapshotType(LLUICtrl* ctrl, void* data);
738 static void onCommitCustomResolution(LLUICtrl *ctrl, void* data); 761 static void onCommitCustomResolution(LLUICtrl *ctrl, void* data);
762 static void checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value);
739 763
740 static LLSnapshotLivePreview* getPreviewView(LLFloaterSnapshot *floater); 764 static LLSnapshotLivePreview* getPreviewView(LLFloaterSnapshot *floater);
741 static void setResolution(LLFloaterSnapshot* floater, const std::string& comboname); 765 static void setResolution(LLFloaterSnapshot* floater, const std::string& comboname);
742 static void updateControls(LLFloaterSnapshot* floater); 766 static void updateControls(LLFloaterSnapshot* floater);
743 static void updateLayout(LLFloaterSnapshot* floater); 767 static void updateLayout(LLFloaterSnapshot* floater);
744 768
745 static LLViewHandle sPreviewHandle; 769 static LLHandle<LLView> sPreviewHandle;
770 static BOOL sAspectRatioCheckOff ;
746 771
747private: 772private:
748 static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater); 773 static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater);
749 static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater); 774 static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater);
750 static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname); 775 static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname);
751 static void checkAutoSnapshot(LLSnapshotLivePreview* floater); 776 static void checkAutoSnapshot(LLSnapshotLivePreview* floater);
777 static void checkAspectRatio(LLFloaterSnapshot *view, S32 index) ;
752 778
753public: 779public:
754 std::vector<LLAnimPauseRequest> mAvatarPauseHandles; 780 std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
@@ -757,12 +783,14 @@ public:
757}; 783};
758 784
759// static 785// static
760LLViewHandle LLFloaterSnapshot::Impl::sPreviewHandle; 786LLHandle<LLView> LLFloaterSnapshot::Impl::sPreviewHandle;
761 787
788//static
789BOOL LLFloaterSnapshot::Impl::sAspectRatioCheckOff = FALSE ;
762// static 790// static
763LLSnapshotLivePreview* LLFloaterSnapshot::Impl::getPreviewView(LLFloaterSnapshot *floater) 791LLSnapshotLivePreview* LLFloaterSnapshot::Impl::getPreviewView(LLFloaterSnapshot *floater)
764{ 792{
765 LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)LLView::getViewByHandle(sPreviewHandle); 793 LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)sPreviewHandle.get();
766 return previewp; 794 return previewp;
767} 795}
768 796
@@ -811,13 +839,37 @@ void LLFloaterSnapshot::Impl::setResolution(LLFloaterSnapshot* floater, const st
811void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) 839void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
812{ 840{
813 LLSnapshotLivePreview* previewp = getPreviewView(floaterp); 841 LLSnapshotLivePreview* previewp = getPreviewView(floaterp);
842
843 S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : -230 ;
844
845 LLComboBox* combo;
846 if(!gSavedSettings.getBOOL("AdvanceSnapshot")) //set to original window resolution
847 {
848 previewp->mKeepAspectRatio = TRUE ;
849
850 combo = LLUICtrlFactory::getComboBoxByName(floaterp, "postcard_size_combo");
851 combo->setCurrentByIndex(0) ;
852 gSavedSettings.setS32("SnapshotPostcardLastResolution", 0) ;
853
854 combo = LLUICtrlFactory::getComboBoxByName(floaterp, "texture_size_combo");
855 combo->setCurrentByIndex(0) ;
856 gSavedSettings.setS32("SnapshotTextureLastResolution", 0) ;
857
858 combo = LLUICtrlFactory::getComboBoxByName(floaterp, "local_size_combo");
859 combo->setCurrentByIndex(0) ;
860 gSavedSettings.setS32("SnapshotLocalLastResolution", 0) ;
861
862 LLSnapshotLivePreview* previewp = getPreviewView(floaterp);
863 previewp->setSize(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight());
864 }
865
814 if (floaterp->childGetValue("freeze_frame_check").asBoolean()) 866 if (floaterp->childGetValue("freeze_frame_check").asBoolean())
815 { 867 {
816 // stop all mouse events at fullscreen preview layer 868 // stop all mouse events at fullscreen preview layer
817 floaterp->getParent()->setMouseOpaque(TRUE); 869 floaterp->getParent()->setMouseOpaque(TRUE);
818 870
819 // shrink to smaller layout 871 // shrink to smaller layout
820 floaterp->reshape(floaterp->mRect.getWidth(), 410); 872 floaterp->reshape(floaterp->getRect().getWidth(), 526 + delta_height);
821 873
822 // can see and interact with fullscreen preview now 874 // can see and interact with fullscreen preview now
823 if (previewp) 875 if (previewp)
@@ -850,7 +902,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
850 else // turning off freeze frame mode 902 else // turning off freeze frame mode
851 { 903 {
852 floaterp->getParent()->setMouseOpaque(FALSE); 904 floaterp->getParent()->setMouseOpaque(FALSE);
853 floaterp->reshape(floaterp->mRect.getWidth(), 510); 905 floaterp->reshape(floaterp->getRect().getWidth(), 526 + delta_height);
854 if (previewp) 906 if (previewp)
855 { 907 {
856 previewp->setVisible(FALSE); 908 previewp->setVisible(FALSE);
@@ -878,6 +930,8 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp)
878// static 930// static
879void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) 931void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
880{ 932{
933 BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot") ;
934
881 LLRadioGroup* snapshot_type_radio = LLUICtrlFactory::getRadioGroupByName(floater, "snapshot_type_radio"); 935 LLRadioGroup* snapshot_type_radio = LLUICtrlFactory::getRadioGroupByName(floater, "snapshot_type_radio");
882 snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType")); 936 snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType"));
883 LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater); 937 LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater);
@@ -895,19 +949,29 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
895 combo = LLUICtrlFactory::getComboBoxByName(floater, "local_size_combo"); 949 combo = LLUICtrlFactory::getComboBoxByName(floater, "local_size_combo");
896 if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution")); 950 if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution"));
897 951
898
899 floater->childSetVisible("upload_btn", FALSE); 952 floater->childSetVisible("upload_btn", FALSE);
900 floater->childSetVisible("send_btn", FALSE); 953 floater->childSetVisible("send_btn", FALSE);
901 floater->childSetVisible("save_btn", FALSE); 954 floater->childSetVisible("save_btn", FALSE);
902 955 floater->childSetEnabled("keep_aspect_check", FALSE) ;
956
903 switch(shot_type) 957 switch(shot_type)
904 { 958 {
905 case LLSnapshotLivePreview::SNAPSHOT_POSTCARD: 959 case LLSnapshotLivePreview::SNAPSHOT_POSTCARD:
906 layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR; 960 layer_type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
907 floater->childSetValue("layer_types", "colors"); 961 floater->childSetValue("layer_types", "colors");
908 floater->childSetEnabled("layer_types", FALSE); 962 floater->childSetEnabled("layer_types", FALSE);
909 floater->childSetEnabled("image_quality_slider", TRUE); 963
910 setResolution(floater, "postcard_size_combo"); 964 if(is_advance)
965 {
966 floater->childSetEnabled("image_quality_slider", TRUE);
967 setResolution(floater, "postcard_size_combo");
968
969 if(!sAspectRatioCheckOff)
970 {
971 floater->childSetEnabled("keep_aspect_check", TRUE) ;
972 }
973 }
974
911 floater->childSetVisible("send_btn", TRUE); 975 floater->childSetVisible("send_btn", TRUE);
912 break; 976 break;
913 case LLSnapshotLivePreview::SNAPSHOT_TEXTURE: 977 case LLSnapshotLivePreview::SNAPSHOT_TEXTURE:
@@ -915,18 +979,69 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
915 floater->childSetValue("layer_types", "colors"); 979 floater->childSetValue("layer_types", "colors");
916 floater->childSetEnabled("layer_types", FALSE); 980 floater->childSetEnabled("layer_types", FALSE);
917 floater->childSetEnabled("image_quality_slider", FALSE); 981 floater->childSetEnabled("image_quality_slider", FALSE);
918 setResolution(floater, "texture_size_combo"); 982
983 if(is_advance)
984 {
985 setResolution(floater, "texture_size_combo");
986 }
987
919 floater->childSetVisible("upload_btn", TRUE); 988 floater->childSetVisible("upload_btn", TRUE);
920 break; 989 break;
921 case LLSnapshotLivePreview::SNAPSHOT_BITMAP: 990 case LLSnapshotLivePreview::SNAPSHOT_BITMAP:
922 floater->childSetEnabled("layer_types", TRUE); 991 floater->childSetEnabled("layer_types", TRUE);
923 floater->childSetEnabled("image_quality_slider", FALSE); 992 floater->childSetEnabled("image_quality_slider", FALSE);
924 setResolution(floater, "local_size_combo"); 993
994 if(is_advance)
995 {
996 setResolution(floater, "local_size_combo");
997
998 if(!sAspectRatioCheckOff)
999 {
1000 floater->childSetEnabled("keep_aspect_check", TRUE) ;
1001 }
1002 }
1003
925 floater->childSetVisible("save_btn", TRUE); 1004 floater->childSetVisible("save_btn", TRUE);
926 break; 1005 break;
927 default: 1006 default:
928 break; 1007 break;
929 } 1008 }
1009
1010 if(is_advance)
1011 {
1012 floater->childSetVisible("type_label2", TRUE) ;
1013 floater->childSetVisible("layer_types", TRUE) ;
1014 floater->childSetVisible("layer_type_label", TRUE) ;
1015 floater->childSetVisible("snapshot_width", TRUE) ;
1016 floater->childSetVisible("snapshot_height", TRUE) ;
1017 floater->childSetVisible("keep_aspect_check", TRUE) ;
1018 floater->childSetVisible("ui_check", TRUE) ;
1019 floater->childSetVisible("hud_check", TRUE) ;
1020 floater->childSetVisible("keep_open_check", TRUE) ;
1021 floater->childSetVisible("freeze_frame_check", TRUE) ;
1022 floater->childSetVisible("auto_snapshot_check", TRUE) ;
1023 floater->childSetVisible("image_quality_slider", TRUE);
1024 floater->childSetVisible("more_btn", FALSE);
1025 floater->childSetVisible("less_btn", TRUE);
1026 }
1027 else
1028 {
1029 floater->childSetVisible("type_label2", FALSE) ;
1030 floater->childSetVisible("layer_types", FALSE) ;
1031 floater->childSetVisible("layer_type_label", FALSE) ;
1032 floater->childSetVisible("snapshot_width", FALSE) ;
1033 floater->childSetVisible("snapshot_height", FALSE) ;
1034 floater->childSetVisible("keep_aspect_check", FALSE) ;
1035 floater->childSetVisible("ui_check", FALSE) ;
1036 floater->childSetVisible("hud_check", FALSE) ;
1037 floater->childSetVisible("keep_open_check", FALSE) ;
1038 floater->childSetVisible("freeze_frame_check", FALSE) ;
1039 floater->childSetVisible("auto_snapshot_check", FALSE) ;
1040 floater->childSetVisible("image_quality_slider", FALSE);
1041 floater->childSetVisible("more_btn", TRUE);
1042 floater->childSetVisible("less_btn", FALSE);
1043 }
1044
930 LLSnapshotLivePreview* previewp = getPreviewView(floater); 1045 LLSnapshotLivePreview* previewp = getPreviewView(floater);
931 if (previewp) 1046 if (previewp)
932 { 1047 {
@@ -939,7 +1054,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
939void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp) 1054void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp)
940{ 1055{
941 if (previewp) 1056 if (previewp)
942 { 1057 {
943 previewp->updateSnapshot(gSavedSettings.getBOOL("AutoSnapshot")); 1058 previewp->updateSnapshot(gSavedSettings.getBOOL("AutoSnapshot"));
944 } 1059 }
945} 1060}
@@ -1026,6 +1141,59 @@ void LLFloaterSnapshot::Impl::onClickAutoSnap(LLUICtrl *ctrl, void* data)
1026 } 1141 }
1027} 1142}
1028 1143
1144void LLFloaterSnapshot::Impl::onClickMore(void* data)
1145{
1146 //floater->childSetVisible("more_btn", FALSE);
1147 //floater->childSetVisible("less_btn", TRUE);
1148
1149 gSavedSettings.setBOOL( "AdvanceSnapshot", TRUE );
1150
1151 LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
1152 if (view)
1153 {
1154 view->translate( 0, -230 );
1155 view->reshape(view->getRect().getWidth(), 526);
1156
1157 updateControls(view) ;
1158 updateLayout(view) ;
1159 }
1160}
1161void LLFloaterSnapshot::Impl::onClickLess(void* data)
1162{
1163 //floater->childSetVisible("less_btn", FALSE);
1164 //floater->childSetVisible("more_btn", TRUE);
1165
1166 gSavedSettings.setBOOL( "AdvanceSnapshot", FALSE );
1167
1168 LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
1169 if (view)
1170 {
1171 view->translate( 0, 230 );
1172 view->reshape(view->getRect().getWidth(), 294);
1173
1174 updateControls(view) ;
1175 updateLayout(view) ;
1176 }
1177}
1178
1179//void LLFloaterSnapshot::Impl::onClickAdvanceSnap(LLUICtrl *ctrl, void* data)
1180//{
1181// LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
1182// gSavedSettings.setBOOL( "AdvanceSnapshot", check->get() );
1183//
1184// LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
1185// if (view)
1186// {
1187// S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : -230 ;
1188//
1189// view->translate( 0, delta_height ? 230 : -230 );
1190// view->reshape(view->getRect().getWidth(), 526 + delta_height);
1191//
1192// updateControls(view) ;
1193// updateLayout(view) ;
1194// }
1195//}
1196
1029// static 1197// static
1030void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) 1198void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data)
1031{ 1199{
@@ -1069,7 +1237,31 @@ void LLFloaterSnapshot::Impl::onClickKeepAspectCheck(LLUICtrl* ctrl, void* data)
1069 LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; 1237 LLFloaterSnapshot *view = (LLFloaterSnapshot *)data;
1070 if (view) 1238 if (view)
1071 { 1239 {
1072 checkAutoSnapshot(getPreviewView(view)); 1240 LLSnapshotLivePreview* previewp = getPreviewView(view) ;
1241 if(previewp)
1242 {
1243 previewp->mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ;
1244
1245 S32 w, h ;
1246 previewp->getSize(w, h) ;
1247 checkImageSize(previewp, w, h, TRUE, previewp->getMaxImageSize()) ;
1248 previewp->setSize(w, h) ;
1249
1250 //update textbox
1251 LLSpinCtrl *sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_width") ;
1252 if(sctrl)
1253 {
1254 sctrl->setValue(w) ;
1255 }
1256
1257 sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_height") ;
1258 if(sctrl)
1259 {
1260 sctrl->setValue(h) ;
1261 }
1262
1263 checkAutoSnapshot(previewp);
1264 }
1073 } 1265 }
1074} 1266}
1075 1267
@@ -1104,6 +1296,48 @@ void LLFloaterSnapshot::Impl::onCommitFreezeFrame(LLUICtrl* ctrl, void* data)
1104} 1296}
1105 1297
1106// static 1298// static
1299void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 index)
1300{
1301 LLSnapshotLivePreview *previewp = getPreviewView(view) ;
1302
1303 if(!index) //current window size
1304 {
1305 sAspectRatioCheckOff = TRUE ;
1306 view->childSetEnabled("keep_aspect_check", FALSE) ;
1307
1308 if(previewp)
1309 {
1310 previewp->mKeepAspectRatio = TRUE ;
1311 }
1312 }
1313 else if(-1 == index) //custom
1314 {
1315 sAspectRatioCheckOff = FALSE ;
1316 if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE != gSavedSettings.getS32("LastSnapshotType"))
1317 {
1318 view->childSetEnabled("keep_aspect_check", TRUE) ;
1319
1320 if(previewp)
1321 {
1322 previewp->mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ;
1323 }
1324 }
1325 }
1326 else
1327 {
1328 sAspectRatioCheckOff = TRUE ;
1329 view->childSetEnabled("keep_aspect_check", FALSE) ;
1330
1331 if(previewp)
1332 {
1333 previewp->mKeepAspectRatio = FALSE ;
1334 }
1335 }
1336
1337 return ;
1338}
1339
1340// static
1107void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) 1341void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data)
1108{ 1342{
1109 LLComboBox* combobox = (LLComboBox*)ctrl; 1343 LLComboBox* combobox = (LLComboBox*)ctrl;
@@ -1126,7 +1360,7 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data)
1126 std::string sdstring = combobox->getSelectedValue(); 1360 std::string sdstring = combobox->getSelectedValue();
1127 LLSD sdres; 1361 LLSD sdres;
1128 std::stringstream sstream(sdstring); 1362 std::stringstream sstream(sdstring);
1129 LLSDSerialize::fromNotation(sdres, sstream); 1363 LLSDSerialize::fromNotation(sdres, sstream, sdstring.size());
1130 1364
1131 S32 width = sdres[0]; 1365 S32 width = sdres[0];
1132 S32 height = sdres[1]; 1366 S32 height = sdres[1];
@@ -1148,7 +1382,12 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data)
1148 previewp->setSize(width, height); 1382 previewp->setSize(width, height);
1149 } 1383 }
1150 1384
1385 checkAspectRatio(view, width) ;
1386
1151 previewp->getSize(width, height); 1387 previewp->getSize(width, height);
1388 checkImageSize(previewp, width, height, TRUE, previewp->getMaxImageSize()) ;
1389 previewp->setSize(width, height);
1390
1152 view->childSetValue("snapshot_width", width); 1391 view->childSetValue("snapshot_width", width);
1153 view->childSetValue("snapshot_height", height); 1392 view->childSetValue("snapshot_height", height);
1154 // hide old preview as the aspect ratio could be wrong 1393 // hide old preview as the aspect ratio could be wrong
@@ -1193,7 +1432,74 @@ void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const s
1193 if (combo) 1432 if (combo)
1194 { 1433 {
1195 combo->setCurrentByIndex(combo->getItemCount() - 1); 1434 combo->setCurrentByIndex(combo->getItemCount() - 1);
1435
1436 checkAspectRatio(floater, -1);//combo->getCurrentIndex()) ;
1437 }
1438}
1439
1440
1441
1442//static
1443void LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value)
1444{
1445 //if texture, ignore aspect ratio setting, round image size to power of 2.
1446 if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE == gSavedSettings.getS32("LastSnapshotType"))
1447 {
1448 if(width > max_value)
1449 {
1450 width = max_value ;
1451 }
1452 if(height > max_value)
1453 {
1454 height = max_value ;
1455 }
1456
1457 //round to nearest power of 2
1458 width = get_nearest_power_two(width, MAX_TEXTURE_SIZE) ;
1459 height = get_nearest_power_two(height, MAX_TEXTURE_SIZE) ;
1460
1461 return ;
1196 } 1462 }
1463
1464 if(previewp && previewp->mKeepAspectRatio)
1465 {
1466 if(gViewerWindow->getWindowDisplayWidth() < 1 || gViewerWindow->getWindowDisplayHeight() < 1)
1467 {
1468 return ;
1469 }
1470
1471 //aspect ratio of the current window
1472 F32 aspect_ratio = (F32)gViewerWindow->getWindowDisplayWidth() / gViewerWindow->getWindowDisplayHeight() ;
1473
1474 //change another value proportionally
1475 if(isWidthChanged)
1476 {
1477 height = (S32)(width / aspect_ratio) ;
1478 }
1479 else
1480 {
1481 width = (S32)(height * aspect_ratio) ;
1482 }
1483
1484 //bound w/h by the max_value
1485 if(width > max_value || height > max_value)
1486 {
1487 if(width > height)
1488 {
1489 width = max_value ;
1490 height = (S32)(width / aspect_ratio) ;
1491 }
1492 else
1493 {
1494 height = max_value ;
1495 width = (S32)(height * aspect_ratio) ;
1496 }
1497 }
1498 }
1499 else
1500 {
1501 }
1502 return ;
1197} 1503}
1198 1504
1199//static 1505//static
@@ -1216,6 +1522,33 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat
1216 1522
1217 if (w != curw || h != curh) 1523 if (w != curw || h != curh)
1218 { 1524 {
1525 S32 width = w ;
1526 S32 height = h ;
1527
1528 previewp->setMaxImageSize((S32)((LLSpinCtrl *)ctrl)->getMaxValue()) ;
1529 checkImageSize(previewp, width, height, width != curw, previewp->getMaxImageSize()) ;
1530
1531 if(width != w || height != h)
1532 {
1533 LLSpinCtrl *sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_width") ;
1534 if(sctrl)
1535 {
1536 sctrl->setValue(width) ;
1537 }
1538
1539 sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_height") ;
1540 if(sctrl)
1541 {
1542 sctrl->setValue(height) ;
1543 }
1544
1545 w = width ;
1546 h = height ;
1547
1548 gSavedSettings.setS32("LastSnapshotWidth", w);
1549 gSavedSettings.setS32("LastSnapshotHeight", h);
1550 }
1551
1219 previewp->setSize(w,h); 1552 previewp->setSize(w,h);
1220 checkAutoSnapshot(previewp); 1553 checkAutoSnapshot(previewp);
1221 comboSetCustom(view, "postcard_size_combo"); 1554 comboSetCustom(view, "postcard_size_combo");
@@ -1242,8 +1575,8 @@ LLFloaterSnapshot::~LLFloaterSnapshot()
1242{ 1575{
1243 if (sInstance == this) 1576 if (sInstance == this)
1244 { 1577 {
1245 delete LLView::getViewByHandle(Impl::sPreviewHandle); 1578 LLView::deleteViewByHandle(Impl::sPreviewHandle);
1246 Impl::sPreviewHandle = LLViewHandle::sDeadHandle; 1579 Impl::sPreviewHandle = LLHandle<LLView>();
1247 sInstance = NULL; 1580 sInstance = NULL;
1248 } 1581 }
1249 1582
@@ -1269,7 +1602,12 @@ BOOL LLFloaterSnapshot::postBuild()
1269 1602
1270 childSetValue("auto_snapshot_check", gSavedSettings.getBOOL("AutoSnapshot")); 1603 childSetValue("auto_snapshot_check", gSavedSettings.getBOOL("AutoSnapshot"));
1271 childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this); 1604 childSetCommitCallback("auto_snapshot_check", Impl::onClickAutoSnap, this);
1272 1605
1606 //childSetValue("advance_snapshot_check", gSavedSettings.getBOOL("AdvanceSnapshot"));
1607 //childSetCommitCallback("advance_snapshot_check", Impl::onClickAdvanceSnap, this);
1608 childSetAction("more_btn", Impl::onClickMore, this);
1609 childSetAction("less_btn", Impl::onClickLess, this);
1610
1273 childSetAction("upload_btn", Impl::onClickKeep, this); 1611 childSetAction("upload_btn", Impl::onClickKeep, this);
1274 childSetAction("send_btn", Impl::onClickKeep, this); 1612 childSetAction("send_btn", Impl::onClickKeep, this);
1275 childSetAction("save_btn", Impl::onClickKeep, this); 1613 childSetAction("save_btn", Impl::onClickKeep, this);
@@ -1315,7 +1653,7 @@ BOOL LLFloaterSnapshot::postBuild()
1315 sInstance->getRootView()->addChild(previewp); 1653 sInstance->getRootView()->addChild(previewp);
1316 sInstance->getRootView()->addChild(gSnapshotFloaterView); 1654 sInstance->getRootView()->addChild(gSnapshotFloaterView);
1317 1655
1318 Impl::sPreviewHandle = previewp->mViewHandle; 1656 Impl::sPreviewHandle = previewp->getHandle();
1319 1657
1320 impl.updateControls(this); 1658 impl.updateControls(this);
1321 1659
@@ -1332,7 +1670,7 @@ void LLFloaterSnapshot::draw()
1332 return; 1670 return;
1333 } 1671 }
1334 1672
1335 if(getVisible() && !mMinimized) 1673 if(getVisible() && !isMinimized())
1336 { 1674 {
1337 if (previewp && previewp->getDataSize() > 0) 1675 if (previewp && previewp->getDataSize() > 0)
1338 { 1676 {
@@ -1354,12 +1692,12 @@ void LLFloaterSnapshot::draw()
1354 if (previewp->getSnapshotUpToDate()) 1692 if (previewp->getSnapshotUpToDate())
1355 { 1693 {
1356 LLString bytes_string; 1694 LLString bytes_string;
1357 gResMgr->getIntegerString(bytes_string, previewp->getDataSize()); 1695 gResMgr->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 );
1358 childSetTextArg("file_size_label", "[SIZE]", bytes_string); 1696 childSetTextArg("file_size_label", "[SIZE]", bytes_string);
1359 } 1697 }
1360 else 1698 else
1361 { 1699 {
1362 childSetTextArg("file_size_label", "[SIZE]", childGetText("unknwon")); 1700 childSetTextArg("file_size_label", "[SIZE]", getString("unknown"));
1363 childSetColor("file_size_label", gColors.getColor( "LabelTextColor" )); 1701 childSetColor("file_size_label", gColors.getColor( "LabelTextColor" ));
1364 } 1702 }
1365 childSetEnabled("upload_btn", previewp->getSnapshotUpToDate()); 1703 childSetEnabled("upload_btn", previewp->getSnapshotUpToDate());
@@ -1382,11 +1720,11 @@ void LLFloaterSnapshot::draw()
1382 LLFloater::draw(); 1720 LLFloater::draw();
1383 1721
1384 // draw snapshot thumbnail if not in fullscreen preview mode 1722 // draw snapshot thumbnail if not in fullscreen preview mode
1385 if (!gSavedSettings.getBOOL("UseFreezeFrame") && previewp && previewp->getCurrentImage() && previewp->getSnapshotUpToDate()) 1723 if (/*!gSavedSettings.getBOOL("UseFreezeFrame") &&*/ previewp && previewp->getCurrentImage() && previewp->getSnapshotUpToDate())
1386 { 1724 {
1387 F32 aspect = previewp->getImageAspect(); 1725 F32 aspect = previewp->getImageAspect();
1388 // UI size for thumbnail 1726 // UI size for thumbnail
1389 S32 max_width = mRect.getWidth() - 20; 1727 S32 max_width = getRect().getWidth() - 20;
1390 S32 max_height = 90; 1728 S32 max_height = 90;
1391 1729
1392 S32 img_render_width = 0; 1730 S32 img_render_width = 0;
@@ -1414,7 +1752,7 @@ void LLFloaterSnapshot::draw()
1414 glScalef(llmin(1.f, (F32)image_width / (F32)previewp->getCurrentImage()->getWidth()), llmin(1.f, (F32)image_height / (F32)previewp->getCurrentImage()->getHeight()), 1.f); 1752 glScalef(llmin(1.f, (F32)image_width / (F32)previewp->getCurrentImage()->getWidth()), llmin(1.f, (F32)image_height / (F32)previewp->getCurrentImage()->getHeight()), 1.f);
1415 } 1753 }
1416 glMatrixMode(GL_MODELVIEW); 1754 glMatrixMode(GL_MODELVIEW);
1417 gl_draw_scaled_image((mRect.getWidth() - img_render_width) / 2, 35 + (max_height - img_render_height) / 2, img_render_width, img_render_height, previewp->getCurrentImage(), LLColor4::white); 1755 gl_draw_scaled_image((getRect().getWidth() - img_render_width) / 2, getRect().getHeight() - 205 + (max_height - img_render_height) / 2, img_render_width, img_render_height, previewp->getCurrentImage(), LLColor4::white);
1418 } 1756 }
1419 glMatrixMode(GL_TEXTURE); 1757 glMatrixMode(GL_TEXTURE);
1420 glPopMatrix(); 1758 glPopMatrix();