summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterbigpreview.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2014-02-26 17:22:16 -0800
committerMerov Linden <merov@lindenlab.com>2014-02-26 17:22:16 -0800
commited38a0aede09f42c4fe7eb4dd53ecd6490d12ca0 (patch)
tree239e4316183fe9b70d5ac3ee50aa4c697127f7e1 /indra/newview/llfloaterbigpreview.cpp
parent8fb94a96b18d3b115b75f6d40a06da1c31d21623 (diff)
ACME-1327 : WIP : Make rescale of preview isotropic, make preview button a toggle
Diffstat (limited to 'indra/newview/llfloaterbigpreview.cpp')
-rw-r--r--indra/newview/llfloaterbigpreview.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/indra/newview/llfloaterbigpreview.cpp b/indra/newview/llfloaterbigpreview.cpp
index d5f25d5f95..b516e9dd01 100644
--- a/indra/newview/llfloaterbigpreview.cpp
+++ b/indra/newview/llfloaterbigpreview.cpp
@@ -28,8 +28,6 @@
#include "llviewerprecompiledheaders.h"
#include "llfloaterbigpreview.h"
-
-#include "llfloaterreg.h"
#include "llsnapshotlivepreview.h"
///////////////////////
@@ -57,7 +55,7 @@ void LLFloaterBigPreview::onCancel()
void LLFloaterBigPreview::closeOnFloaterOwnerClosing(LLFloater* floaterp)
{
- if (floaterp == mFloaterOwner)
+ if (isFloaterOwner(floaterp))
{
closeFloater();
}
@@ -76,21 +74,25 @@ void LLFloaterBigPreview::draw()
LLSnapshotLivePreview * previewp = static_cast<LLSnapshotLivePreview *>(mPreviewHandle.get());
// Display the preview if one is available
- // HACK!!! We use the puny thumbnail image for the moment
- // *TODO : Use the real large preview
if (previewp && previewp->getBigThumbnailImage())
{
+ // Get the preview rect
const LLRect& preview_rect = mPreviewPlaceholder->getRect();
-// const S32 thumbnail_w = previewp->getThumbnailWidth();
-// const S32 thumbnail_h = previewp->getThumbnailHeight();
- // calc preview offset within the preview rect
-// const S32 local_offset_x = (preview_rect.getWidth() - thumbnail_w) / 2 ;
-// const S32 local_offset_y = (preview_rect.getHeight() - thumbnail_h) / 2 ;
- const S32 local_offset_x = 0 ;
- const S32 local_offset_y = 0 ;
+ // Get the preview texture size
+ S32 thumbnail_w = previewp->getBigThumbnailWidth();
+ S32 thumbnail_h = previewp->getBigThumbnailHeight();
+
+ // Compute the scaling ratio and the size of the final texture in the rect: we want to prevent anisotropic scaling (distorted in x and y)
+ F32 ratio = llmax((F32)(thumbnail_w)/(F32)(preview_rect.getWidth()), (F32)(thumbnail_h)/(F32)(preview_rect.getHeight()));
+ thumbnail_w = (S32)((F32)(thumbnail_w)/ratio);
+ thumbnail_h = (S32)((F32)(thumbnail_h)/ratio);
- // calc preview offset within the floater rect
+ // Compute the preview offset within the preview rect: we want to center that preview in the available rect
+ const S32 local_offset_x = (preview_rect.getWidth() - thumbnail_w) / 2 ;
+ const S32 local_offset_y = (preview_rect.getHeight() - thumbnail_h) / 2 ;
+
+ // Compute preview offset within the floater rect
S32 offset_x = preview_rect.mLeft + local_offset_x;
S32 offset_y = preview_rect.mBottom + local_offset_y;
@@ -98,9 +100,10 @@ void LLFloaterBigPreview::draw()
// Apply floater transparency to the texture unless the floater is focused.
F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
LLColor4 color = LLColor4::white;
+
+ // Draw the preview texture
gl_draw_scaled_image(offset_x, offset_y,
- //thumbnail_w, thumbnail_h,
- preview_rect.getWidth(), preview_rect.getHeight(),
+ thumbnail_w, thumbnail_h,
previewp->getBigThumbnailImage(), color % alpha);
}
}