Large snapshot update (part 1)

This commit concentrates on remembering what parameters
where used for the last snapshot (the actual source, not
the formatted one), thus - the parameters passed to
rawSnapshot() - and then shows this snapshot as if it
was just made whenever the UI parameter selection matches.
The result is that the user can make a snapshot, save
it (for example) to their harddisk and then change the
destination and upload the same thing as snapshot.
The code tries hard to make this possible by automatically
adjusting the UI parameters to match every time the destination
is changed PROVIDED it was already saved or uploaded before.
If a snapshot wasn't saved and one changes destination
then this currently doesn't happen (by you could manually
make the parameters match, and still upload it). Also, if
the resolution is changed for a particular destination then
it won't automatically adjust it again.

Obviously, snapshots are no longer refreshed when changing
destination etc. You have to explicitly click "Refresh
Snapshot" before the last one is deleted / replaced.

The Debug Setting variables reflect the (last) manual choices
in most cases (set in the onCommit functions). If such a choice
is not allowed for a different destination then the UI is
changed to reflect the current behavior and the checkbox is
disabled so the user can't change it anymore. Then, if they
change destination back - the Debug Setting variable is used
to remember their last preference. A new Debug Setting has
been added for this purpose: SnapshotLayerType (colors or depth).

The old mSnapshotUpToDate has been removed and replaced with
mShowFreezeFrameSnapshot. The old getSnapshotUpToDate() now
returns something else (than mShowFreezeFrameSnapshot), namely
whether or not the current raw snapshot was taken with the same
parameters as are currently set in the UI.

The unused functions getImageAspect() and getAspect() were
removed.

mCurImageIndex has been deleted. Index 0 now means "the last
snapshot" and index 1 is temporarily used for the Falling Away
animation.

mDataSize was renamed to mFormattedDataSize.

The size spinner arrows are now disabled too whenever the spinner
edit field is disabled.

A bug in Freeze Time was fixed, where avatars would still
rotate around their axis in place (and without that their
attachments moved!)

Pressing ESC would return keyboard control to "walking"
for the own avatar with the above as result for the own
avatar. We now intercept ESC and use it (in Freeze Time mode)
to return to the cammable preview when a 2D preview was
being shown.
This commit is contained in:
Aleric Inglewood
2012-11-26 17:04:05 +01:00
parent 14c046108e
commit 7faa19b297
7 changed files with 555 additions and 279 deletions

View File

@@ -13431,6 +13431,17 @@ Found in Advanced->Rendering->Info Displays</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>SnapshotLayerType</key>
<map>
<key>Comment</key>
<string>Save snapshots in this format (0 = Colors, 1 = Depth)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>0</integer>
</map>
<key>SnapshotLocalLastResolution</key>
<map>
<key>Comment</key>

File diff suppressed because it is too large Load Diff

View File

@@ -57,6 +57,7 @@ public:
/*virtual*/ void draw();
/*virtual*/ void onClose(bool app_quitting);
/*virtual*/ void onOpen();
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
static void show(void*);
static void hide(void*);

View File

@@ -4286,24 +4286,24 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p
}
// Saves the image from the screen to the specified filename and path.
BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height,
BOOL keep_window_aspect, BOOL is_texture, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size, F32 supersample)
S32 LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height,
BOOL keep_window_aspect, BOOL /*is_texture*/, BOOL show_ui, BOOL do_rebuild, ESnapshotType type, S32 max_size, F32 supersample)
{
if (!raw)
{
return FALSE;
return 0;
}
//check if there is enough memory for the snapshot image
if(LLPipeline::sMemAllocationThrottled)
{
return FALSE ; //snapshot taking is disabled due to memory restriction.
return 0; //snapshot taking is disabled due to memory restriction.
}
if(image_width * image_height > (1 << 22)) //if snapshot image is larger than 2K by 2K
{
if(!LLMemory::tryToAlloc(NULL, image_width * image_height * 3))
{
llwarns << "No enough memory to take the snapshot with size (w : h): " << image_width << " : " << image_height << llendl ;
return FALSE ; //there is no enough memory for taking this snapshot.
return 0; //there is no enough memory for taking this snapshot.
}
}
@@ -4331,17 +4331,15 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
// Copy screen to a buffer
// crop sides or top and bottom, if taking a snapshot of different aspect ratio
// from window
LLRect window_rect = show_ui ? getWindowRectRaw() : getWorldViewRectRaw();
LLRect const window_rect = show_ui ? getWindowRectRaw() : getWorldViewRectRaw();
S32 const window_width = window_rect.getWidth();
S32 const window_height = window_rect.getHeight();
S32 snapshot_width = window_rect.getWidth();
S32 snapshot_height = window_rect.getHeight();
// SNAPSHOT
S32 window_width = snapshot_width;
S32 window_height = snapshot_height;
S32 snapshot_width = window_width;
S32 snapshot_height = window_height;
F32 scale_factor = 1.0f ;
bool is_tiling = false;
//fbo method no longer supported. Good riddance
@@ -4409,6 +4407,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
snapshot_width = (S32)(ratio * image_width) ;
snapshot_height = (S32)(ratio * image_height) ;
scale_factor = llmax(1.0f, 1.0f / ratio) ;
Dout(dc::warning, "USING TILING FOR SNAPSHOT!");
is_tiling = true;
}
}
@@ -4420,10 +4419,11 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
S32 image_buffer_x = llfloor(snapshot_width*scale_factor) ;
S32 image_buffer_y = llfloor(snapshot_height*scale_factor) ;
S32 max_image_buffer = llmax(image_buffer_x, image_buffer_y);
#if 1//SHY_MOD // screenshot improvement
if(internal_scale <= 1.f) //If supersampling... Don't care about max_size.
#endif //shy_mod
if(image_buffer_x > max_size || image_buffer_y > max_size) //boundary check to avoid memory overflow
if(max_image_buffer > max_size) //boundary check to avoid memory overflow
{
scale_factor *= llmin((F32)max_size / image_buffer_x, (F32)max_size / image_buffer_y) ;
image_buffer_x = llfloor(snapshot_width*scale_factor) ;
@@ -4435,11 +4435,11 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
}
else
{
return FALSE ;
return 0;
}
if(raw->isBufferInvalid())
{
return FALSE ;
return 0;
}
BOOL high_res = scale_factor > 1.f;
@@ -4591,11 +4591,11 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
#if 1//SHY_MOD // screenshot improvement
if(raw->isBufferInvalid()) //Just checking!
return FALSE;
return 0;
if(internal_scale != 1.f) //Scale down our render to the desired dimensions.
raw->scale( image_width/internal_scale, image_height/internal_scale );
if(raw->isBufferInvalid()) //Just checking!
return FALSE;
return 0;
#endif //shy_mod
setCursor(UI_CURSOR_ARROW);
@@ -4615,7 +4615,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
send_agent_resume();
}
return ret;
return ret ? max_image_buffer : 0;
}
void LLViewerWindow::destroyWindow()

View File

@@ -308,10 +308,11 @@ public:
enum ESnapshotType
{
SNAPSHOT_TYPE_COLOR,
SNAPSHOT_TYPE_DEPTH,
SNAPSHOT_TYPE_DEPTH
};
BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR);
BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE,
// Returns the largest dimension (x or y) of the buffer (which is never larger than max_size), or 0 on failure.
S32 rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE,
BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_SNAPSHOT_IMAGE_SIZE, F32 supersample = 1.f );
BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type) ;
BOOL isSnapshotLocSet() const { return ! sSnapshotDir.empty(); }

View File

@@ -4099,6 +4099,13 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
// Frozen!
if (areAnimationsPaused())
{
updateMotions(LLCharacter::NORMAL_UPDATE); // This is necessary to get unpaused again.
return FALSE;
}
// clear debug text
mDebugText.clear();
if (LLVOAvatar::sShowAnimationDebug)

View File

@@ -17,10 +17,10 @@
Send via email
</radio_item>
<radio_item bottom="-57" height="16" name="texture">
Save to your inventory ([UPLOADFEE])
Save to my inventory ([UPLOADFEE])
</radio_item>
<radio_item bottom="-76" height="16" name="local">
Save to your hard drive
Save to my hard drive
</radio_item>
</radio_group>
<button bottom_delta="-28" follows="left|top" height="20" label="Refresh Snapshot" left="10"
@@ -40,13 +40,13 @@
<button bottom_delta="0" follows="left|top" height="20" label="Cancel" left="120"
name="discard_btn" width="85" />
<button bottom_delta="-26" follows="left|top" font="SansSerifSmall" halign="center"
height="20" label="More &gt;&gt;" left="10"
height="20" label="Advanced &gt;&gt;" left="10"
mouse_opaque="true" name="more_btn" scale_image="TRUE"
tool_tip="Advanced Options" width="80" />
tool_tip="Advanced Options. Default uses current window size." width="80" />
<button bottom_delta="0" follows="left|top" font="SansSerifSmall" halign="center"
height="20" label="&lt;&lt; Less" left_delta="0"
height="20" label="&lt;&lt; Default" left_delta="0"
mouse_opaque="true" name="less_btn" scale_image="TRUE"
tool_tip="Advanced Options" width="80" />
tool_tip="Advanced Options. Default uses current window size." width="80" />
<text bottom_delta="-20" follows="top|left" height="15" left="10" name="type_label2"
width="115">
Size
@@ -72,8 +72,11 @@
<combo_item name="1024x768" value="[i1024,i768]">
1024x768 (resized)
</combo_item>
<combo_item name="1280x1024" value="[i1280,i1024]">
1280x1024 (resized)
<combo_item name="1280x960" value="[i1280,i960]">
1280x960 (resized)
</combo_item>
<combo_item name="1600x1200" value="[i1600,i1200]">
1600x1200 (resized)
</combo_item>
<combo_item name="Custom" value="[i-1,i-1]">
Custom
@@ -87,6 +90,9 @@
<combo_item name="640x480" value="[i640,i480]">
640x480
</combo_item>
<combo_item name="700x525" value="[i700,i525]">
700x525
</combo_item>
<combo_item name="800x600" value="[i800,i600]">
800x600
</combo_item>
@@ -98,7 +104,7 @@
</combo_item>
</combo_box>
<combo_box bottom_delta="0" follows="left|top" height="20" label="Resolution" left="10"
name="texture_size_combo" width="150">
name="texture_size_combo" width="115">
<combo_item name="CurrentWindow" value="[i0,i0]">
Current Window
</combo_item>
@@ -111,9 +117,6 @@
<combo_item name="Large(512x512)" value="[i512,i512]">
Large (512x512)
</combo_item>
<combo_item name="Humongous (1024x1024)" value="[i1024,i1024]">
Humongous (1024x1024)
</combo_item>
<combo_item name="Custom" value="[i-1,i-1]">
Custom
</combo_item>
@@ -135,6 +138,9 @@
<combo_item name="1024x768" value="[i1024,i768]">
1024x768
</combo_item>
<combo_item name="1280x960" value="[i1280,i960]">
1280x960
</combo_item>
<combo_item name="1280x1024" value="[i1280,i1024]">
1280x1024
</combo_item>
@@ -186,18 +192,18 @@
</combo_item>
</combo_box>
<check_box bottom_delta="-20" follows="left|top" label="Show interface in snapshot"
left="10" name="ui_check" />
left="10" name="ui_check" tool_tip="Show the UI in the snapshot. This enforces the resolution of the snapshot to that of your current window." />
<check_box bottom_delta="-20" follows="left|top" label="Show HUD objects in snapshot"
left="10" name="hud_check" />
left="10" name="hud_check" tool_tip="Show your HUD objects in the snapshot. This enforces the resolution of the snapshot to that of your current window." />
<check_box bottom_delta="-20" follows="left|top" label="Keep open after saving" left="10"
name="keep_open_check" />
<check_box bottom_delta="-20" follows="left|top" label="Freeze frame (fullscreen preview)"
left="10" name="freeze_frame_check" />
name="keep_open_check" tool_tip="Do not close the snapshot floater after saving or uploading. This allows you to save, upload or send the SAME snapshot again with different formats and/or to a different destination." />
<check_box bottom_delta="-20" follows="left|top" label="Freeze time (CAM 3D preview)"
left="10" name="freeze_frame_check" tool_tip="Show a fullscreen preview. Allows to cam around as if time is frozen and make multiple snapshots of the same scene." />
<check_box bottom_delta="-20" follows="left|top" label="Auto-refresh" left="10"
name="auto_snapshot_check" />
name="auto_snapshot_check" tool_tip="Handy in conjunction with Freeze Time: creates a new fullscreen preview whenever you stop camming." />
<check_box bottom_delta="-20" follows="left|top" control_name="TemporaryUpload" enabled="true"
initial_value="false" label="Temporary Image (Free)" left="10"
name="temp_check" tooltip="Sets the asset to be temporary, meaning it's free, but in return, only good for a short time before it ceases to exist." />
name="temp_check" tool_tip="Uploads the texture to the sim instead of the asset server, meaning it's free but only visible in the current sim and deleted when you leave the sim." />
<string name="unknown">
unknown
</string>