summaryrefslogtreecommitdiff
path: root/indra/newview/llsnapshotlivepreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llsnapshotlivepreview.cpp')
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp158
1 files changed, 82 insertions, 76 deletions
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 2ff8f50277..63b1dca693 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -56,16 +56,16 @@
#include "llworld.h"
#include <boost/filesystem.hpp>
-const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f;
+constexpr F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f;
-F32 SHINE_TIME = 0.5f;
-F32 SHINE_WIDTH = 0.6f;
-F32 SHINE_OPACITY = 0.3f;
-F32 FALL_TIME = 0.6f;
-S32 BORDER_WIDTH = 6;
-S32 TOP_PANEL_HEIGHT = 30;
+constexpr F32 SHINE_TIME = 0.5f;
+constexpr F32 SHINE_WIDTH = 0.6f;
+constexpr F32 SHINE_OPACITY = 0.3f;
+constexpr F32 FALL_TIME = 0.6f;
+constexpr S32 BORDER_WIDTH = 6;
+constexpr S32 TOP_PANEL_HEIGHT = 30;
-const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512
+constexpr S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512
std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList;
LLPointer<LLImageFormatted> LLSnapshotLivePreview::sSaveLocalImage = NULL;
@@ -79,24 +79,24 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param
mBigThumbnailImage(NULL) ,
mThumbnailWidth(0),
mThumbnailHeight(0),
- mThumbnailSubsampled(FALSE),
+ mThumbnailSubsampled(false),
mPreviewImageEncoded(NULL),
mFormattedImage(NULL),
mShineCountdown(0),
mFlashAlpha(0.f),
- mNeedsFlash(TRUE),
+ mNeedsFlash(true),
mSnapshotQuality(gSavedSettings.getS32("SnapshotQuality")),
mDataSize(0),
mSnapshotType(LLSnapshotModel::SNAPSHOT_POSTCARD),
mSnapshotFormat(LLSnapshotModel::ESnapshotFormat(gSavedSettings.getS32("SnapshotFormat"))),
- mSnapshotUpToDate(FALSE),
+ mSnapshotUpToDate(false),
mCameraPos(LLViewerCamera::getInstance()->getOrigin()),
mCameraRot(LLViewerCamera::getInstance()->getQuaternion()),
- mSnapshotActive(FALSE),
+ mSnapshotActive(false),
mSnapshotBufferType(LLSnapshotModel::SNAPSHOT_TYPE_COLOR),
mFilterName(""),
- mAllowRenderUI(TRUE),
- mAllowFullScreenPreview(TRUE),
+ mAllowRenderUI(true),
+ mAllowFullScreenPreview(true),
mViewContainer(NULL)
{
setSnapshotQuality(gSavedSettings.getS32("SnapshotQuality"));
@@ -109,16 +109,16 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param
mWidth[1] = gViewerWindow->getWindowWidthRaw();
mHeight[0] = gViewerWindow->getWindowHeightRaw();
mHeight[1] = gViewerWindow->getWindowHeightRaw();
- mImageScaled[0] = FALSE;
- mImageScaled[1] = FALSE;
+ mImageScaled[0] = false;
+ mImageScaled[1] = false;
mMaxImageSize = MAX_SNAPSHOT_IMAGE_SIZE ;
mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ;
- mThumbnailUpdateLock = FALSE ;
- mThumbnailUpToDate = FALSE ;
- mBigThumbnailUpToDate = FALSE ;
+ mThumbnailUpdateLock = false ;
+ mThumbnailUpToDate = false ;
+ mBigThumbnailUpToDate = false ;
- mForceUpdateSnapshot = FALSE;
+ mForceUpdateSnapshot = false;
}
LLSnapshotLivePreview::~LLSnapshotLivePreview()
@@ -153,7 +153,7 @@ F32 LLSnapshotLivePreview::getImageAspect()
return (mKeepAspectRatio ? ((F32)getRect().getWidth()) / ((F32)getRect().getHeight()) : ((F32)getWidth()) / ((F32)getHeight()));
}
-void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail, F32 delay)
+void LLSnapshotLivePreview::updateSnapshot(bool new_snapshot, bool new_thumbnail, F32 delay)
{
LL_DEBUGS("Snapshot") << "updateSnapshot: mSnapshotUpToDate = " << getSnapshotUpToDate() << LL_ENDL;
@@ -167,7 +167,7 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail
setSize(mWidth[old_image_index], mHeight[old_image_index]);
mFallAnimTimer.start();
}
- mSnapshotUpToDate = FALSE;
+ mSnapshotUpToDate = false;
// Update snapshot source rect depending on whether we keep the aspect ratio.
LLRect& rect = mImageRect[mCurImageIndex];
@@ -212,8 +212,8 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail
// Update thumbnail if requested.
if (new_thumbnail)
{
- mThumbnailUpToDate = FALSE ;
- mBigThumbnailUpToDate = FALSE;
+ mThumbnailUpToDate = false ;
+ mBigThumbnailUpToDate = false;
}
}
@@ -241,7 +241,7 @@ void LLSnapshotLivePreview::drawPreviewRect(S32 offset_x, S32 offset_y, LLColor4
glLineWidth(2.0f * line_width) ;
LLColor4 color(0.0f, 0.0f, 0.0f, 1.0f) ;
gl_rect_2d( mPreviewRect.mLeft + offset_x, mPreviewRect.mTop + offset_y,
- mPreviewRect.mRight + offset_x, mPreviewRect.mBottom + offset_y, color, FALSE ) ;
+ mPreviewRect.mRight + offset_x, mPreviewRect.mBottom + offset_y, color, false ) ;
glLineWidth(line_width) ;
//draw four alpha rectangles to cover areas outside of the snapshot image
@@ -254,20 +254,20 @@ void LLSnapshotLivePreview::drawPreviewRect(S32 offset_x, S32 offset_y, LLColor4
dwr = mThumbnailWidth - mPreviewRect.getWidth() - dwl ;
gl_rect_2d(mPreviewRect.mLeft + offset_x - dwl, mPreviewRect.mTop + offset_y,
- mPreviewRect.mLeft + offset_x, mPreviewRect.mBottom + offset_y, alpha_color, TRUE ) ;
+ mPreviewRect.mLeft + offset_x, mPreviewRect.mBottom + offset_y, alpha_color, true ) ;
gl_rect_2d( mPreviewRect.mRight + offset_x, mPreviewRect.mTop + offset_y,
- mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mBottom + offset_y, alpha_color, TRUE ) ;
+ mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mBottom + offset_y, alpha_color, true ) ;
}
if(mThumbnailHeight > mPreviewRect.getHeight())
{
S32 dh = (mThumbnailHeight - mPreviewRect.getHeight()) >> 1 ;
gl_rect_2d(mPreviewRect.mLeft + offset_x - dwl, mPreviewRect.mBottom + offset_y ,
- mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mBottom + offset_y - dh, alpha_color, TRUE ) ;
+ mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mBottom + offset_y - dh, alpha_color, true ) ;
dh = mThumbnailHeight - mPreviewRect.getHeight() - dh ;
gl_rect_2d( mPreviewRect.mLeft + offset_x - dwl, mPreviewRect.mTop + offset_y + dh,
- mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mTop + offset_y, alpha_color, TRUE ) ;
+ mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mTop + offset_y, alpha_color, true ) ;
}
}
}
@@ -323,7 +323,7 @@ void LLSnapshotLivePreview::draw()
}
else
{
- mNeedsFlash = FALSE;
+ mNeedsFlash = false;
}
}
else
@@ -398,7 +398,7 @@ void LLSnapshotLivePreview::draw()
gGL.getTexUnit(0)->bind(mViewerImage[old_image_index]);
// calculate UV scale
// *FIX get this to work with old image
- BOOL rescale = !mImageScaled[old_image_index] && mViewerImage[mCurImageIndex].notNull();
+ bool rescale = !mImageScaled[old_image_index] && mViewerImage[mCurImageIndex].notNull();
F32 uv_width = rescale ? llmin((F32)mWidth[old_image_index] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f) : 1.f;
F32 uv_height = rescale ? llmin((F32)mHeight[old_image_index] / (F32)mViewerImage[mCurImageIndex]->getHeight(), 1.f) : 1.f;
gGL.pushMatrix();
@@ -428,7 +428,7 @@ void LLSnapshotLivePreview::draw()
}
/*virtual*/
-void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_parent)
+void LLSnapshotLivePreview::reshape(S32 width, S32 height, bool called_from_parent)
{
LLRect old_rect = getRect();
LLView::reshape(width, height, called_from_parent);
@@ -439,18 +439,18 @@ void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_pare
{
// We usually resize only on window reshape, so give it a chance to redraw, assign delay
updateSnapshot(
- TRUE, // new snapshot is needed
- FALSE, // thumbnail will be updated either way.
+ true, // new snapshot is needed
+ false, // thumbnail will be updated either way.
AUTO_SNAPSHOT_TIME_DELAY); // shutter delay.
}
}
}
-BOOL LLSnapshotLivePreview::setThumbnailImageSize()
+bool LLSnapshotLivePreview::setThumbnailImageSize()
{
if (getWidth() < 10 || getHeight() < 10)
{
- return FALSE ;
+ return false ;
}
S32 width = (mThumbnailSubsampled ? mPreviewImage->getWidth() : gViewerWindow->getWindowWidthRaw());
S32 height = (mThumbnailSubsampled ? mPreviewImage->getHeight() : gViewerWindow->getWindowHeightRaw()) ;
@@ -476,7 +476,7 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize()
if (mThumbnailWidth > width || mThumbnailHeight > height)
{
- return FALSE ;//if the window is too small, ignore thumbnail updating.
+ return false ;//if the window is too small, ignore thumbnail updating.
}
S32 left = 0 , top = mThumbnailHeight, right = mThumbnailWidth, bottom = 0 ;
@@ -500,10 +500,10 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize()
}
mPreviewRect.set(left - 1, top + 1, right + 1, bottom - 1) ;
- return TRUE ;
+ return true ;
}
-void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update)
+void LLSnapshotLivePreview::generateThumbnailImage(bool force_update)
{
if(mThumbnailUpdateLock) //in the process of updating
{
@@ -519,17 +519,17 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update)
}
////lock updating
- mThumbnailUpdateLock = TRUE ;
+ mThumbnailUpdateLock = true ;
if(!setThumbnailImageSize())
{
- mThumbnailUpdateLock = FALSE ;
- mThumbnailUpToDate = TRUE ;
+ mThumbnailUpdateLock = false ;
+ mThumbnailUpToDate = true ;
return ;
}
// Invalidate the big thumbnail when we regenerate the small one
- mBigThumbnailUpToDate = FALSE;
+ mBigThumbnailUpToDate = false;
if(mThumbnailImage)
{
@@ -558,7 +558,7 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update)
mThumbnailWidth, mThumbnailHeight,
mAllowRenderUI && gSavedSettings.getBOOL("RenderUIInSnapshot"),
gSavedSettings.getBOOL("RenderHUDInSnapshot"),
- FALSE,
+ false,
gSavedSettings.getBOOL("RenderSnapshotNoPost"),
mSnapshotBufferType) )
{
@@ -585,12 +585,12 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update)
}
// Scale to a power of 2 so it can be mapped to a texture
raw->expandToPowerOfTwo();
- mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE);
- mThumbnailUpToDate = TRUE ;
+ mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), false);
+ mThumbnailUpToDate = true ;
}
//unlock updating
- mThumbnailUpdateLock = FALSE ;
+ mThumbnailUpdateLock = false ;
}
LLViewerTexture* LLSnapshotLivePreview::getBigThumbnailImage()
@@ -633,38 +633,38 @@ LLViewerTexture* LLSnapshotLivePreview::getBigThumbnailImage()
}
// Scale to a power of 2 so it can be mapped to a texture
raw->expandToPowerOfTwo();
- mBigThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE);
- mBigThumbnailUpToDate = TRUE ;
+ mBigThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), false);
+ mBigThumbnailUpToDate = true ;
}
return mBigThumbnailImage ;
}
// Called often. Checks whether it's time to grab a new snapshot and if so, does it.
-// Returns TRUE if new snapshot generated, FALSE otherwise.
+// Returns true if new snapshot generated, false otherwise.
//static
-BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
+bool LLSnapshotLivePreview::onIdle( void* snapshot_preview )
{
LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)snapshot_preview;
if (previewp->getWidth() == 0 || previewp->getHeight() == 0)
{
LL_WARNS("Snapshot") << "Incorrect dimensions: " << previewp->getWidth() << "x" << previewp->getHeight() << LL_ENDL;
- return FALSE;
+ return false;
}
if (previewp->mSnapshotDelayTimer.getStarted()) // Wait for a snapshot delay timer
{
if (!previewp->mSnapshotDelayTimer.hasExpired())
{
- return FALSE;
+ return false;
}
previewp->mSnapshotDelayTimer.stop();
}
if (LLToolCamera::getInstance()->hasMouseCapture()) // Hide full-screen preview while camming, either don't take snapshots while ALT-zoom active
{
- previewp->setVisible(FALSE);
- return FALSE;
+ previewp->setVisible(false);
+ return false;
}
// If we're in freeze-frame and/or auto update mode and camera has moved, update snapshot.
@@ -678,18 +678,18 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
previewp->mCameraPos = new_camera_pos;
previewp->mCameraRot = new_camera_rot;
// request a new snapshot whenever the camera moves, with a time delay
- BOOL new_snapshot = gSavedSettings.getBOOL("AutoSnapshot") || previewp->mForceUpdateSnapshot;
+ bool new_snapshot = gSavedSettings.getBOOL("AutoSnapshot") || previewp->mForceUpdateSnapshot;
LL_DEBUGS("Snapshot") << "camera moved, updating thumbnail" << LL_ENDL;
previewp->updateSnapshot(
new_snapshot, // whether a new snapshot is needed or merely invalidate the existing one
- FALSE, // or if 1st arg is false, whether to produce a new thumbnail image.
+ false, // or if 1st arg is false, whether to produce a new thumbnail image.
new_snapshot ? AUTO_SNAPSHOT_TIME_DELAY : 0.f); // shutter delay if 1st arg is true.
- previewp->mForceUpdateSnapshot = FALSE;
+ previewp->mForceUpdateSnapshot = false;
}
if (previewp->getSnapshotUpToDate() && previewp->getThumbnailUpToDate())
{
- return FALSE;
+ return false;
}
// time to produce a snapshot
@@ -701,13 +701,13 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
previewp->mPreviewImage = new LLImageRaw;
}
- previewp->mSnapshotActive = TRUE;
+ previewp->mSnapshotActive = true;
- previewp->setVisible(FALSE);
- previewp->setEnabled(FALSE);
+ previewp->setVisible(false);
+ previewp->setEnabled(false);
previewp->getWindow()->incBusyCount();
- previewp->setImageScaled(FALSE);
+ previewp->setImageScaled(false);
// grab the raw image
if (gViewerWindow->rawSnapshot(
@@ -718,7 +718,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
previewp->getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE,
previewp->mAllowRenderUI && gSavedSettings.getBOOL("RenderUIInSnapshot"),
gSavedSettings.getBOOL("RenderHUDInSnapshot"),
- FALSE,
+ false,
gSavedSettings.getBOOL("RenderSnapshotNoPost"),
previewp->mSnapshotBufferType,
previewp->getMaxImageSize()))
@@ -737,15 +737,15 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
}
// The snapshot is updated now...
- previewp->mSnapshotUpToDate = TRUE;
+ previewp->mSnapshotUpToDate = true;
// We need to update the thumbnail though
previewp->setThumbnailImageSize();
- previewp->generateThumbnailImage(TRUE) ;
+ previewp->generateThumbnailImage(true) ;
}
previewp->getWindow()->decBusyCount();
previewp->setVisible(gSavedSettings.getBOOL("UseFreezeFrame") && previewp->mAllowFullScreenPreview); // only show fullscreen preview when in freeze frame mode
- previewp->mSnapshotActive = FALSE;
+ previewp->mSnapshotActive = false;
LL_DEBUGS("Snapshot") << "done creating snapshot" << LL_ENDL;
}
@@ -760,7 +760,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
previewp->mViewContainer->notify(LLSD().with("snapshot-updated", true));
}
- return TRUE;
+ return true;
}
void LLSnapshotLivePreview::prepareFreezeFrame()
@@ -768,6 +768,8 @@ void LLSnapshotLivePreview::prepareFreezeFrame()
// Get the decoded version of the formatted image
getEncodedImage();
+ LLImageDataSharedLock lock(mPreviewImageEncoded);
+
// We need to scale that a bit for display...
LLPointer<LLImageRaw> scaled = new LLImageRaw(
mPreviewImageEncoded->getData(),
@@ -782,15 +784,15 @@ void LLSnapshotLivePreview::prepareFreezeFrame()
{
// go ahead and shrink image to appropriate power of 2 for display
scaled->biasedScaleToPowerOfTwo(1024);
- setImageScaled(TRUE);
+ setImageScaled(true);
}
else
{
// expand image but keep original image data intact
- scaled->expandToPowerOfTwo(1024, FALSE);
+ scaled->expandToPowerOfTwo(1024, false);
}
- mViewerImage[mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), FALSE);
+ mViewerImage[mCurImageIndex] = LLViewerTextureManager::getLocalTexture(scaled.get(), false);
LLPointer<LLViewerTexture> curr_preview_image = mViewerImage[mCurImageIndex];
gGL.getTexUnit(0)->bind(curr_preview_image);
curr_preview_image->setFilteringOption(getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE ? LLTexUnit::TFO_ANISOTROPIC : LLTexUnit::TFO_POINT);
@@ -827,13 +829,15 @@ LLPointer<LLImageRaw> LLSnapshotLivePreview::getEncodedImage()
{
if (!mPreviewImageEncoded)
{
+ LLImageDataSharedLock lock(mPreviewImage);
+
mPreviewImageEncoded = new LLImageRaw;
-
+
mPreviewImageEncoded->resize(
mPreviewImage->getWidth(),
mPreviewImage->getHeight(),
mPreviewImage->getComponents());
-
+
if (getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE)
{
// We don't store the intermediate formatted image in mFormattedImage in the J2C case
@@ -847,7 +851,7 @@ LLPointer<LLImageRaw> LLSnapshotLivePreview::getEncodedImage()
mPreviewImage->getComponents());
// Scale it as required by J2C
scaled->biasedScaleToPowerOfTwo(MAX_TEXTURE_SIZE);
- setImageScaled(TRUE);
+ setImageScaled(true);
// Compress to J2C
if (formatted->encode(scaled, 0.f))
{
@@ -978,8 +982,10 @@ void LLSnapshotLivePreview::getSize(S32& w, S32& h) const
h = getHeight();
}
-void LLSnapshotLivePreview::saveTexture(BOOL outfit_snapshot, std::string name)
+void LLSnapshotLivePreview::saveTexture(bool outfit_snapshot, std::string name)
{
+ LLImageDataSharedLock lock(mPreviewImage);
+
LL_DEBUGS("Snapshot") << "saving texture: " << mPreviewImage->getWidth() << "x" << mPreviewImage->getHeight() << LL_ENDL;
// gen a new uuid for this asset
LLTransactionID tid;
@@ -1059,5 +1065,5 @@ void LLSnapshotLivePreview::saveLocal(LLPointer<LLImageFormatted> image, const s
{
sSaveLocalImage = image;
- gViewerWindow->saveImageNumbered(sSaveLocalImage, FALSE, success_cb, failure_cb);
+ gViewerWindow->saveImageNumbered(sSaveLocalImage, false, success_cb, failure_cb);
}