summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-01-28 17:45:48 -0800
committerMerov Linden <merov@lindenlab.com>2014-01-28 17:45:48 -0800
commitb35889a6510440692be4b7f1aa590cf645fbba90 (patch)
treec570c084a7c154883d043b93b80ef7c4d64b448d
parent6dfba5829e3f9cf5986c627b537da55cf84c84c7 (diff)
ACME-1195 : Complete perf improvements. Also we do not regrab/refresh when we don't have to (e.g. change format) in particular when changing filter. Better control that way and faster UI.
-rw-r--r--indra/newview/llfloaterfacebook.cpp17
-rw-r--r--indra/newview/llfloaterflickr.cpp27
-rwxr-xr-xindra/newview/llfloatersnapshot.cpp15
-rw-r--r--indra/newview/llfloatertwitter.cpp15
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp244
-rw-r--r--indra/newview/llsnapshotlivepreview.h2
6 files changed, 154 insertions, 166 deletions
diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp
index 9676dfaf93..1cd7ecbcd8 100644
--- a/indra/newview/llfloaterfacebook.cpp
+++ b/indra/newview/llfloaterfacebook.cpp
@@ -314,8 +314,6 @@ void LLFacebookPhotoPanel::onClickNewSnapshot()
LLSnapshotLivePreview* previewp = getPreviewView();
if (previewp)
{
- //setStatus(Impl::STATUS_READY);
- lldebugs << "updating snapshot" << llendl;
previewp->updateSnapshot(TRUE);
}
}
@@ -461,24 +459,17 @@ void LLFacebookPhotoPanel::updateResolution(BOOL do_update)
// Recompute quality setting
mQuality = compute_jpeg_quality(width, height);
- bool quality_reset = previewp->setSnapshotQuality(mQuality, false);
+ previewp->setSnapshotQuality(mQuality, false);
- if (original_width != width || original_height != height || quality_reset)
+ if (original_width != width || original_height != height)
{
previewp->setSize(width, height);
-
- // hide old preview as the aspect ratio could be wrong
- lldebugs << "updating thumbnail" << llendl;
-
- previewp->updateSnapshot(FALSE, TRUE);
- if (do_update || quality_reset)
+ if (do_update)
{
- lldebugs << "Will update controls" << llendl;
+ previewp->updateSnapshot(TRUE);
updateControls();
- LLFacebookPhotoPanel::onClickNewSnapshot();
}
}
-
}
}
diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp
index fbf4d758be..2dc62dcda8 100644
--- a/indra/newview/llfloaterflickr.cpp
+++ b/indra/newview/llfloaterflickr.cpp
@@ -215,8 +215,6 @@ void LLFlickrPhotoPanel::onClickNewSnapshot()
LLSnapshotLivePreview* previewp = getPreviewView();
if (previewp)
{
- //setStatus(Impl::STATUS_READY);
- lldebugs << "updating snapshot" << llendl;
previewp->updateSnapshot(TRUE);
}
}
@@ -355,27 +353,26 @@ void LLFlickrPhotoPanel::updateResolution(BOOL do_update)
checkAspectRatio(width);
previewp->getSize(width, height);
+ if ((original_width != width) || (original_height != height))
+ {
+ previewp->setSize(width, height);
+ if (do_update)
+ {
+ previewp->updateSnapshot(TRUE);
+ updateControls();
+ }
+ }
// Get the old filter, compare to the current one "filter_name" and set if changed
- // If changed, also force the updateSnapshot() here under
std::string original_filter = previewp->getFilter();
-
- if ((original_width != width) || (original_height != height) || (original_filter != filter_name))
+ if (original_filter != filter_name)
{
- previewp->setSize(width, height);
previewp->setFilter(filter_name);
-
- // hide old preview as the aspect ratio could be wrong
- lldebugs << "updating thumbnail" << llendl;
-
- previewp->updateSnapshot(FALSE, TRUE);
- if(do_update)
+ if (do_update)
{
- lldebugs << "Will update controls" << llendl;
+ previewp->updateSnapshot(FALSE, TRUE);
updateControls();
- LLFlickrPhotoPanel::onClickNewSnapshot();
}
}
-
}
}
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 7ba5fc7b87..27a9e3da44 100755
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -622,9 +622,9 @@ void LLFloaterSnapshot::Impl::applyKeepAspectCheck(LLFloaterSnapshot* view, BOOL
previewp->getSize(w, h) ;
updateSpinners(view, previewp, w, h, TRUE); // may change w and h
- lldebugs << "updating thumbnail" << llendl;
+ lldebugs << "updating snapshot" << llendl;
previewp->setSize(w, h) ;
- previewp->updateSnapshot(FALSE, TRUE);
+ previewp->updateSnapshot(TRUE);
checkAutoSnapshot(previewp, TRUE);
}
}
@@ -821,8 +821,8 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
// hide old preview as the aspect ratio could be wrong
checkAutoSnapshot(previewp, FALSE);
- lldebugs << "updating thumbnail" << llendl;
- getPreviewView(view)->updateSnapshot(FALSE, TRUE);
+ lldebugs << "updating snapshot" << llendl;
+ getPreviewView(view)->updateSnapshot(TRUE);
if(do_update)
{
lldebugs << "Will update controls" << llendl;
@@ -859,7 +859,6 @@ void LLFloaterSnapshot::Impl::onImageQualityChange(LLFloaterSnapshot* view, S32
{
previewp->setSnapshotQuality(quality_val);
}
- checkAutoSnapshot(previewp, TRUE);
}
// static
@@ -868,8 +867,6 @@ void LLFloaterSnapshot::Impl::onImageFormatChange(LLFloaterSnapshot* view)
if (view)
{
gSavedSettings.setS32("SnapshotFormat", getImageFormat(view));
- lldebugs << "image format changed, updating snapshot" << llendl;
- getPreviewView(view)->updateSnapshot(TRUE);
updateControls(view);
setNeedRefresh(view, false); // we're refreshing
}
@@ -969,8 +966,8 @@ void LLFloaterSnapshot::Impl::applyCustomResolution(LLFloaterSnapshot* view, S32
previewp->setSize(w,h);
checkAutoSnapshot(previewp, FALSE);
- lldebugs << "applied custom resolution, updating thumbnail" << llendl;
- previewp->updateSnapshot(FALSE, TRUE);
+ lldebugs << "applied custom resolution, updating snapshot" << llendl;
+ previewp->updateSnapshot(TRUE);
comboSetCustom(view, "profile_size_combo");
comboSetCustom(view, "postcard_size_combo");
comboSetCustom(view, "texture_size_combo");
diff --git a/indra/newview/llfloatertwitter.cpp b/indra/newview/llfloatertwitter.cpp
index 68bc4f1c3c..5e0f652264 100644
--- a/indra/newview/llfloatertwitter.cpp
+++ b/indra/newview/llfloatertwitter.cpp
@@ -217,8 +217,6 @@ void LLTwitterPhotoPanel::onClickNewSnapshot()
LLSnapshotLivePreview* previewp = getPreviewView();
if (previewp)
{
- //setStatus(Impl::STATUS_READY);
- lldebugs << "updating snapshot" << llendl;
previewp->updateSnapshot(TRUE);
}
}
@@ -417,22 +415,15 @@ void LLTwitterPhotoPanel::updateResolution(BOOL do_update)
previewp->getSize(width, height);
- if(original_width != width || original_height != height)
+ if (original_width != width || original_height != height)
{
previewp->setSize(width, height);
-
- // hide old preview as the aspect ratio could be wrong
- lldebugs << "updating thumbnail" << llendl;
-
- previewp->updateSnapshot(FALSE, TRUE);
- if(do_update)
+ if (do_update)
{
- lldebugs << "Will update controls" << llendl;
+ previewp->updateSnapshot(TRUE);
updateControls();
- LLTwitterPhotoPanel::onClickNewSnapshot();
}
}
-
}
}
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 04dd86a77d..0d1562b6d4 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -147,48 +147,48 @@ F32 LLSnapshotLivePreview::getImageAspect()
void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail, F32 delay)
{
- // Invalidate current image.
lldebugs << "updateSnapshot: mSnapshotUpToDate = " << getSnapshotUpToDate() << llendl;
- if (getSnapshotUpToDate())
+
+ // Update snapshot if requested.
+ if (new_snapshot)
{
- S32 old_image_index = mCurImageIndex;
- mCurImageIndex = (mCurImageIndex + 1) % 2;
- setSize(mWidth[old_image_index], mHeight[old_image_index]);
- mFallAnimTimer.start();
- }
- mSnapshotUpToDate = FALSE;
+ if (getSnapshotUpToDate())
+ {
+ S32 old_image_index = mCurImageIndex;
+ mCurImageIndex = (mCurImageIndex + 1) % 2;
+ setSize(mWidth[old_image_index], mHeight[old_image_index]);
+ mFallAnimTimer.start();
+ }
+ mSnapshotUpToDate = FALSE;
- // Update snapshot source rect depending on whether we keep the aspect ratio.
- LLRect& rect = mImageRect[mCurImageIndex];
- rect.set(0, getRect().getHeight(), getRect().getWidth(), 0);
+ // Update snapshot source rect depending on whether we keep the aspect ratio.
+ LLRect& rect = mImageRect[mCurImageIndex];
+ rect.set(0, getRect().getHeight(), getRect().getWidth(), 0);
- F32 image_aspect_ratio = ((F32)getWidth()) / ((F32)getHeight());
- F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight());
+ F32 image_aspect_ratio = ((F32)getWidth()) / ((F32)getHeight());
+ F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight());
- if (mKeepAspectRatio)//gSavedSettings.getBOOL("KeepAspectForSnapshot"))
- {
- if (image_aspect_ratio > window_aspect_ratio)
- {
- // trim off top and bottom
- S32 new_height = llround((F32)getRect().getWidth() / image_aspect_ratio);
- rect.mBottom += (getRect().getHeight() - new_height) / 2;
- rect.mTop -= (getRect().getHeight() - new_height) / 2;
- }
- else if (image_aspect_ratio < window_aspect_ratio)
- {
- // trim off left and right
- S32 new_width = llround((F32)getRect().getHeight() * image_aspect_ratio);
- rect.mLeft += (getRect().getWidth() - new_width) / 2;
- rect.mRight -= (getRect().getWidth() - new_width) / 2;
- }
- }
+ if (mKeepAspectRatio)//gSavedSettings.getBOOL("KeepAspectForSnapshot"))
+ {
+ if (image_aspect_ratio > window_aspect_ratio)
+ {
+ // trim off top and bottom
+ S32 new_height = llround((F32)getRect().getWidth() / image_aspect_ratio);
+ rect.mBottom += (getRect().getHeight() - new_height) / 2;
+ rect.mTop -= (getRect().getHeight() - new_height) / 2;
+ }
+ else if (image_aspect_ratio < window_aspect_ratio)
+ {
+ // trim off left and right
+ S32 new_width = llround((F32)getRect().getHeight() * image_aspect_ratio);
+ rect.mLeft += (getRect().getWidth() - new_width) / 2;
+ rect.mRight -= (getRect().getWidth() - new_width) / 2;
+ }
+ }
- // Stop shining animation.
- mShineAnimTimer.stop();
+ // Stop shining animation.
+ mShineAnimTimer.stop();
- // Update snapshot if requested.
- if (new_snapshot)
- {
mSnapshotDelayTimer.start();
mSnapshotDelayTimer.setTimerExpirySec(delay);
LLFloaterSnapshot::preUpdate();
@@ -198,7 +198,7 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail
}
// Update thumbnail if requested.
- if(new_thumbnail)
+ if (new_thumbnail)
{
mThumbnailUpToDate = FALSE ;
}
@@ -215,7 +215,7 @@ bool LLSnapshotLivePreview::setSnapshotQuality(S32 quality, bool set_by_user)
{
gSavedSettings.setS32("SnapshotQuality", quality);
}
- mSnapshotUpToDate = FALSE;
+ mFormattedImage = NULL; // Invalidate the already formatted image if any
return true;
}
return false;
@@ -451,8 +451,8 @@ void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_pare
LLView::reshape(width, height, called_from_parent);
if (old_rect.getWidth() != width || old_rect.getHeight() != height)
{
- lldebugs << "window reshaped, updating thumbnail" << llendl;
- updateSnapshot(FALSE, TRUE);
+ lldebugs << "window reshaped, updating snapshot" << llendl;
+ updateSnapshot(TRUE);
}
}
@@ -635,98 +635,101 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
previewp->mSnapshotActive =
(previewp->mSnapshotDelayTimer.getStarted() && previewp->mSnapshotDelayTimer.hasExpired())
&& !LLToolCamera::getInstance()->hasMouseCapture(); // don't take snapshots while ALT-zoom active
- if ( ! previewp->mSnapshotActive)
+ if (!previewp->mSnapshotActive && previewp->getSnapshotUpToDate() && previewp->getThumbnailUpToDate())
{
return FALSE;
}
// time to produce a snapshot
- lldebugs << "producing snapshot" << llendl;
- if (!previewp->mPreviewImage)
- {
- previewp->mPreviewImage = new LLImageRaw;
- }
+ if(!previewp->getSnapshotUpToDate())
+ {
+ lldebugs << "producing snapshot" << llendl;
+ if (!previewp->mPreviewImage)
+ {
+ previewp->mPreviewImage = new LLImageRaw;
+ }
- previewp->setVisible(FALSE);
- previewp->setEnabled(FALSE);
-
- previewp->getWindow()->incBusyCount();
- previewp->setImageScaled(FALSE);
-
- // grab the raw image
- if(gViewerWindow->rawSnapshot(
- previewp->mPreviewImage,
- previewp->getWidth(),
- previewp->getHeight(),
- previewp->mKeepAspectRatio,//gSavedSettings.getBOOL("KeepAspectForSnapshot"),
- previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_TEXTURE,
- gSavedSettings.getBOOL("RenderUIInSnapshot"),
- FALSE,
- previewp->mSnapshotBufferType,
- previewp->getMaxImageSize()))
- {
- // Invalidate/delete any existing encoded image
- previewp->mPreviewImageEncoded = NULL;
- // Invalidate/delete any existing formatted image
- previewp->mFormattedImage = NULL;
- // Update the data size
- previewp->estimateDataSize();
-
- // Full size preview is set: get the decoded image result and save it for animation
- if (gSavedSettings.getBOOL("UseFreezeFrame"))
+ previewp->setVisible(FALSE);
+ previewp->setEnabled(FALSE);
+
+ previewp->getWindow()->incBusyCount();
+ previewp->setImageScaled(FALSE);
+
+ // grab the raw image
+ if (gViewerWindow->rawSnapshot(
+ previewp->mPreviewImage,
+ previewp->getWidth(),
+ previewp->getHeight(),
+ previewp->mKeepAspectRatio,//gSavedSettings.getBOOL("KeepAspectForSnapshot"),
+ previewp->getSnapshotType() == LLSnapshotLivePreview::SNAPSHOT_TEXTURE,
+ gSavedSettings.getBOOL("RenderUIInSnapshot"),
+ FALSE,
+ previewp->mSnapshotBufferType,
+ previewp->getMaxImageSize()))
{
- // Get the decoded version of the formatted image
- previewp->getEncodedImage();
-
- // We need to scale that a bit for display...
- LLPointer<LLImageRaw> scaled = new LLImageRaw(
- previewp->mPreviewImageEncoded->getData(),
- previewp->mPreviewImageEncoded->getWidth(),
- previewp->mPreviewImageEncoded->getHeight(),
- previewp->mPreviewImageEncoded->getComponents());
-
- if (!scaled->isBufferInvalid())
+ // Invalidate/delete any existing encoded image
+ previewp->mPreviewImageEncoded = NULL;
+ // Invalidate/delete any existing formatted image
+ previewp->mFormattedImage = NULL;
+ // Update the data size
+ previewp->estimateDataSize();
+
+ // Full size preview is set: get the decoded image result and save it for animation
+ if (gSavedSettings.getBOOL("UseFreezeFrame"))
{
- // leave original image dimensions, just scale up texture buffer
- if (previewp->mPreviewImageEncoded->getWidth() > 1024 || previewp->mPreviewImageEncoded->getHeight() > 1024)
- {
- // go ahead and shrink image to appropriate power of 2 for display
- scaled->biasedScaleToPowerOfTwo(1024);
- previewp->setImageScaled(TRUE);
- }
- else
+ // Get the decoded version of the formatted image
+ previewp->getEncodedImage();
+
+ // We need to scale that a bit for display...
+ LLPointer<LLImageRaw> scaled = new LLImageRaw(
+ previewp->mPreviewImageEncoded->getData(),
+ previewp->mPreviewImageEncoded->getWidth(),
+ previewp->mPreviewImageEncoded->getHeight(),
+ previewp->mPreviewImageEncoded->getComponents());
+
+ if (!scaled->isBufferInvalid())
{
- // expand image but keep original image data intact
- scaled->expandToPowerOfTwo(1024, FALSE);
+ // leave original image dimensions, just scale up texture buffer
+ if (previewp->mPreviewImageEncoded->getWidth() > 1024 || previewp->mPreviewImageEncoded->getHeight() > 1024)
+ {
+ // go ahead and shrink image to appropriate power of 2 for display
+ scaled->biasedScaleToPowerOfTwo(1024);
+ previewp->setImageScaled(TRUE);
+ }
+ else
+ {
+ // expand image but keep original image data intact
+ scaled->expandToPowerOfTwo(1024, FALSE);
+ }
+
+ previewp->mViewerImage[previewp->mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE);
+ LLPointer<LLViewerTexture> curr_preview_image = previewp->mViewerImage[previewp->mCurImageIndex];
+ gGL.getTexUnit(0)->bind(curr_preview_image);
+ curr_preview_image->setFilteringOption(previewp->getSnapshotType() == SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT);
+ curr_preview_image->setAddressMode(LLTexUnit::TAM_CLAMP);
+
+ previewp->mPosTakenGlobal = gAgentCamera.getCameraPositionGlobal();
+ previewp->mShineCountdown = 4; // wait a few frames to avoid animation glitch due to readback this frame
}
-
- previewp->mViewerImage[previewp->mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE);
- LLPointer<LLViewerTexture> curr_preview_image = previewp->mViewerImage[previewp->mCurImageIndex];
- gGL.getTexUnit(0)->bind(curr_preview_image);
- curr_preview_image->setFilteringOption(previewp->getSnapshotType() == SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT);
- curr_preview_image->setAddressMode(LLTexUnit::TAM_CLAMP);
-
- previewp->mPosTakenGlobal = gAgentCamera.getCameraPositionGlobal();
- previewp->mShineCountdown = 4; // wait a few frames to avoid animation glitch due to readback this frame
}
- }
- // K, the snapshot is updated...
- previewp->mSnapshotUpToDate = TRUE;
+ // The snapshot is updated now...
+ previewp->mSnapshotUpToDate = TRUE;
- // We need to update the thumbnail though
- previewp->setThumbnailImageSize();
- previewp->generateThumbnailImage(TRUE) ;
- }
- previewp->getWindow()->decBusyCount();
- previewp->setVisible(gSavedSettings.getBOOL("UseFreezeFrame")); // only show fullscreen preview when in freeze frame mode
- previewp->mSnapshotDelayTimer.stop();
- previewp->mSnapshotActive = FALSE;
-
- if(!previewp->getThumbnailUpToDate())
+ // We need to update the thumbnail though
+ previewp->setThumbnailImageSize();
+ previewp->generateThumbnailImage(TRUE) ;
+ }
+ previewp->getWindow()->decBusyCount();
+ previewp->setVisible(gSavedSettings.getBOOL("UseFreezeFrame")); // only show fullscreen preview when in freeze frame mode
+ previewp->mSnapshotDelayTimer.stop();
+ previewp->mSnapshotActive = FALSE;
+ lldebugs << "done creating snapshot" << llendl;
+ }
+
+ if (!previewp->getThumbnailUpToDate())
{
previewp->generateThumbnailImage() ;
}
- lldebugs << "done creating snapshot" << llendl;
LLFloaterSnapshot::postUpdate();
LLFloaterFacebook::postUpdate();
LLFloaterFlickr::postUpdate();
@@ -889,6 +892,15 @@ void LLSnapshotLivePreview::setSize(S32 w, S32 h)
setHeight(h);
}
+void LLSnapshotLivePreview::setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat format)
+{
+ if (mSnapshotFormat != format)
+ {
+ mFormattedImage = NULL; // Invalidate the already formatted image if any
+ mSnapshotFormat = format;
+ }
+}
+
void LLSnapshotLivePreview::getSize(S32& w, S32& h) const
{
w = getWidth();
diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h
index 4fd6dedeed..10f20e7fe8 100644
--- a/indra/newview/llsnapshotlivepreview.h
+++ b/indra/newview/llsnapshotlivepreview.h
@@ -96,7 +96,7 @@ public:
const LLVector3d& getPosTakenGlobal() const { return mPosTakenGlobal; }
void setSnapshotType(ESnapshotType type) { mSnapshotType = type; }
- void setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat type) { mSnapshotFormat = type; }
+ void setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat format);
bool setSnapshotQuality(S32 quality, bool set_by_user = true);
void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; }
void setFilter(std::string filter_name) { mFilterName = filter_name; }