Skip to content
Snippets Groups Projects
Commit 6e820bf7 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Reduce findChild calls during snapshot by 28000

parent 5c277922
No related branches found
No related tags found
No related merge requests found
......@@ -92,13 +92,13 @@ LLSnapshotModel::ESnapshotFormat LLFloaterSnapshot::Impl::getImageFormat(LLFloat
LLSpinCtrl* LLFloaterSnapshot::Impl::getWidthSpinner(LLFloaterSnapshotBase* floater)
{
LLPanelSnapshot* active_panel = getActivePanel(floater);
return active_panel ? active_panel->getWidthSpinner() : floater->getChild<LLSpinCtrl>("snapshot_width");
return active_panel ? active_panel->getWidthSpinner() : nullptr;
}
LLSpinCtrl* LLFloaterSnapshot::Impl::getHeightSpinner(LLFloaterSnapshotBase* floater)
{
LLPanelSnapshot* active_panel = getActivePanel(floater);
return active_panel ? active_panel->getHeightSpinner() : floater->getChild<LLSpinCtrl>("snapshot_height");
return active_panel ? active_panel->getHeightSpinner() : nullptr;
}
void LLFloaterSnapshot::Impl::enableAspectRatioCheckbox(LLFloaterSnapshotBase* floater, BOOL enable)
......@@ -134,7 +134,7 @@ LLSnapshotLivePreview* LLFloaterSnapshotBase::ImplBase::getPreviewView()
LLSnapshotModel::ESnapshotLayerType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSnapshotBase* floater)
{
LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR;
LLSD value = floater->getChild<LLUICtrl>("layer_types")->getValue();
LLSD value = floater->getLayerTypesCombo()->getValue();
const std::string id = value.asString();
if (id == "colors")
type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR;
......@@ -270,7 +270,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater)
LLSnapshotModel::ESnapshotLayerType layer_type = getLayerType(floater);
floater->getChild<LLComboBox>("local_format_combo")->selectNthItem(gSavedSettings.getS32("SnapshotFormat"));
floater->getChildView("layer_types")->setEnabled(shot_type == LLSnapshotModel::SNAPSHOT_LOCAL);
floater->getLayerTypesCombo()->setEnabled(shot_type == LLSnapshotModel::SNAPSHOT_LOCAL);
LLPanelSnapshot* active_panel = getActivePanel(floater);
if (active_panel)
......@@ -360,17 +360,17 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater)
{
case LLSnapshotModel::SNAPSHOT_WEB:
layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR;
floater->getChild<LLUICtrl>("layer_types")->setValue("colors");
floater->getLayerTypesCombo()->setValue("colors");
setResolution(floater, "profile_size_combo");
break;
case LLSnapshotModel::SNAPSHOT_POSTCARD:
layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR;
floater->getChild<LLUICtrl>("layer_types")->setValue("colors");
floater->getLayerTypesCombo()->setValue("colors");
setResolution(floater, "postcard_size_combo");
break;
case LLSnapshotModel::SNAPSHOT_TEXTURE:
layer_type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR;
floater->getChild<LLUICtrl>("layer_types")->setValue("colors");
floater->getLayerTypesCombo()->setValue("colors");
setResolution(floater, "texture_size_combo");
break;
case LLSnapshotModel::SNAPSHOT_LOCAL:
......@@ -741,20 +741,24 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
previewp->getSize(width, height);
// We use the height spinner here because we come here via the aspect ratio
// checkbox as well and we want height always changing to width by default.
// If we use the width spinner we would change width according to height by
// default, that is not what we want.
updateSpinners(view, previewp, width, height, !getHeightSpinner(view)->isDirty()); // may change width and height
if(getWidthSpinner(view)->getValue().asInteger() != width || getHeightSpinner(view)->getValue().asInteger() != height)
auto panel = getActivePanel(view);
if (panel)
{
getWidthSpinner(view)->setValue(width);
getHeightSpinner(view)->setValue(height);
if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE)
// We use the height spinner here because we come here via the aspect ratio
// checkbox as well and we want height always changing to width by default.
// If we use the width spinner we would change width according to height by
// default, that is not what we want.
updateSpinners(view, previewp, width, height, !getHeightSpinner(view)->isDirty()); // may change width and height
if (getWidthSpinner(view)->getValue().asInteger() != width || getHeightSpinner(view)->getValue().asInteger() != height)
{
getWidthSpinner(view)->setIncrement(width >> 1);
getHeightSpinner(view)->setIncrement(height >> 1);
getWidthSpinner(view)->setValue(width);
getHeightSpinner(view)->setValue(height);
if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE)
{
getWidthSpinner(view)->setIncrement(width >> 1);
getHeightSpinner(view)->setIncrement(height >> 1);
}
}
}
......@@ -991,8 +995,9 @@ BOOL LLFloaterSnapshot::postBuild()
((Impl*)impl)->setAspectRatioCheckboxValue(this, gSavedSettings.getBOOL("KeepAspectForSnapshot"));
childSetCommitCallback("layer_types", Impl::onCommitLayerTypes, this);
getChild<LLUICtrl>("layer_types")->setValue("colors");
getChildView("layer_types")->setEnabled(FALSE);
mLayerTypesCombo = getChild<LLUICtrl>("layer_types");
mLayerTypesCombo->setValue("colors");
mLayerTypesCombo->setEnabled(FALSE);
mFreezeFrameCheck = getChild<LLUICtrl>("freeze_frame_check");
mFreezeFrameCheck->setValue(gSavedSettings.getBOOL("UseFreezeFrame"));
......
......@@ -65,6 +65,8 @@ class LLFloaterSnapshotBase : public LLFloater
void setFailureLabelPanelVisible(bool value) { if (mFailureLblPanel) mFailureLblPanel->setVisible(value); }
void inventorySaveFailed();
LLUICtrl* getLayerTypesCombo() { return mLayerTypesCombo; }
class ImplBase;
friend class ImplBase;
ImplBase* impl;
......@@ -73,6 +75,7 @@ class LLFloaterSnapshotBase : public LLFloater
LLUICtrl* mThumbnailPlaceholder;
LLUICtrl *mRefreshBtn, *mRefreshLabel;
LLUICtrl *mSucceessLblPanel, *mFailureLblPanel;
LLUICtrl* mLayerTypesCombo = nullptr;
LLUICtrl* mFreezeFrameCheck = nullptr;
LLTextBox* m360Label = nullptr;
};
......@@ -173,6 +176,7 @@ class LLFloaterSnapshot final : public LLFloaterSnapshotBase
class Impl;
friend class Impl;
friend class LLFloaterSnapshotBase::ImplBase;
};
///----------------------------------------------------------------------------
......@@ -181,6 +185,7 @@ class LLFloaterSnapshot final : public LLFloaterSnapshotBase
class LLFloaterSnapshot::Impl final : public LLFloaterSnapshotBase::ImplBase
{
friend class LLFloaterSnapshotBase;
LOG_CLASS(LLFloaterSnapshot::Impl);
public:
Impl(LLFloaterSnapshotBase* floater)
......
......@@ -65,11 +65,13 @@ BOOL LLPanelSnapshot::postBuild()
getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onResolutionComboCommit, this, _1));
if (!getWidthSpinnerName().empty())
{
getChild<LLUICtrl>(getWidthSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this));
mWidthSpinner = getChild<LLSpinCtrl>(getWidthSpinnerName());
mWidthSpinner->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this));
}
if (!getHeightSpinnerName().empty())
{
getChild<LLUICtrl>(getHeightSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this));
mHeightSpinner = getChild<LLSpinCtrl>(getHeightSpinnerName());
mHeightSpinner->setCommitCallback(boost::bind(&LLPanelSnapshot::onCustomResolutionCommit, this));
}
if (!getAspectRatioCBName().empty())
{
......@@ -112,25 +114,25 @@ void LLPanelSnapshot::enableControls(BOOL enable)
LLSpinCtrl* LLPanelSnapshot::getWidthSpinner()
{
llassert(!getWidthSpinnerName().empty());
return getChild<LLSpinCtrl>(getWidthSpinnerName());
return mWidthSpinner;
}
LLSpinCtrl* LLPanelSnapshot::getHeightSpinner()
{
llassert(!getHeightSpinnerName().empty());
return getChild<LLSpinCtrl>(getHeightSpinnerName());
return mHeightSpinner;
}
S32 LLPanelSnapshot::getTypedPreviewWidth() const
{
llassert(!getWidthSpinnerName().empty());
return getChild<LLUICtrl>(getWidthSpinnerName())->getValue().asInteger();
return mWidthSpinner->getValue().asInteger();
}
S32 LLPanelSnapshot::getTypedPreviewHeight() const
{
llassert(!getHeightSpinnerName().empty());
return getChild<LLUICtrl>(getHeightSpinnerName())->getValue().asInteger();
return mHeightSpinner->getValue().asInteger();
}
void LLPanelSnapshot::enableAspectRatioCheckbox(BOOL enable)
......@@ -201,28 +203,23 @@ void LLPanelSnapshot::cancel()
void LLPanelSnapshot::onCustomResolutionCommit()
{
LLSD info;
std::string widthSpinnerName = getWidthSpinnerName();
std::string heightSpinnerName = getHeightSpinnerName();
llassert(!widthSpinnerName.empty() && !heightSpinnerName.empty());
LLSpinCtrl *widthSpinner = getChild<LLSpinCtrl>(widthSpinnerName);
LLSpinCtrl *heightSpinner = getChild<LLSpinCtrl>(heightSpinnerName);
if (getName() == "panel_snapshot_inventory")
{
S32 width = widthSpinner->getValue().asInteger();
S32 width = mWidthSpinner->getValue().asInteger();
width = power_of_two(width, MAX_TEXTURE_SIZE);
info["w"] = width;
widthSpinner->setIncrement(width >> 1);
widthSpinner->forceSetValue(width);
S32 height = heightSpinner->getValue().asInteger();
mWidthSpinner->setIncrement(width >> 1);
mWidthSpinner->forceSetValue(width);
S32 height = mHeightSpinner->getValue().asInteger();
height = power_of_two(height, MAX_TEXTURE_SIZE);
heightSpinner->setIncrement(height >> 1);
heightSpinner->forceSetValue(height);
mHeightSpinner->setIncrement(height >> 1);
mHeightSpinner->forceSetValue(height);
info["h"] = height;
}
else
{
info["w"] = widthSpinner->getValue().asInteger();
info["h"] = heightSpinner->getValue().asInteger();
info["w"] = mWidthSpinner->getValue().asInteger();
info["h"] = mHeightSpinner->getValue().asInteger();
}
getParentByType<LLFloater>()->notify(LLSD().with("custom-res-change", info));
}
......
......@@ -74,6 +74,9 @@ class LLPanelSnapshot: public LLPanel
void onKeepAspectRatioCommit(LLUICtrl* ctrl);
LLFloaterSnapshotBase* mSnapshotFloater;
LLSpinCtrl* mWidthSpinner = nullptr;
LLSpinCtrl* mHeightSpinner = nullptr;
};
#endif // LL_LLPANELSNAPSHOT_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment