Skip to content

Commit

Permalink
perf: MinFrameRateOptions 改为静态成员
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Dec 31, 2024
1 parent c59f2ce commit 258c7c4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Magpie/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
Margin="0,0,8,0"
HorizontalAlignment="Stretch"
DropDownOpened="ComboBox_DropDownOpened"
ItemsSource="{x:Bind ViewModel.MinFrameRateOptions, Mode=OneTime}"
ItemsSource="{x:Bind local:HomeViewModel.MinFrameRateOptions, Mode=OneTime}"
SelectedIndex="{x:Bind ViewModel.MinFrameRateIndex, Mode=TwoWay}" />
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
Expand Down
17 changes: 10 additions & 7 deletions src/Magpie/HomeViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,17 @@ void HomeViewModel::IsSimulateExclusiveFullscreen(bool value) {

static constexpr std::array MIN_FRAME_RATE_OPTIONS{ 0,5,10,20,30 };

IVector<IInspectable> HomeViewModel::MinFrameRateOptions() const {
std::vector<IInspectable> options;
options.reserve(MIN_FRAME_RATE_OPTIONS.size());
for (int option : MIN_FRAME_RATE_OPTIONS) {
options.push_back(box_value(std::to_wstring(option)));
}
IVector<IInspectable> HomeViewModel::MinFrameRateOptions() {
static IVector<IInspectable> result = [] {
std::vector<IInspectable> options;
options.reserve(MIN_FRAME_RATE_OPTIONS.size());
for (int option : MIN_FRAME_RATE_OPTIONS) {
options.push_back(box_value(std::to_wstring(option)));
}

return single_threaded_vector(std::move(options));
return single_threaded_vector(std::move(options));
}();
return result;
}

int HomeViewModel::MinFrameRateIndex() const noexcept {
Expand Down
8 changes: 7 additions & 1 deletion src/Magpie/HomeViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct HomeViewModel : HomeViewModelT<HomeViewModel>, wil::notify_property_chang
bool IsSimulateExclusiveFullscreen() const noexcept;
void IsSimulateExclusiveFullscreen(bool value);

IVector<IInspectable> MinFrameRateOptions() const;
static IVector<IInspectable> MinFrameRateOptions();

int MinFrameRateIndex() const noexcept;
void MinFrameRateIndex(int value);
Expand Down Expand Up @@ -116,3 +116,9 @@ struct HomeViewModel : HomeViewModelT<HomeViewModel>, wil::notify_property_chang
};

}

namespace winrt::Magpie::factory_implementation {

struct HomeViewModel : HomeViewModelT<HomeViewModel, implementation::HomeViewModel> {};

}
2 changes: 1 addition & 1 deletion src/Magpie/HomeViewModel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Magpie {
Boolean IsAllowScalingMaximized;
Boolean IsInlineParams;
Boolean IsSimulateExclusiveFullscreen;
IVector<IInspectable> MinFrameRateOptions { get; };
static IVector<IInspectable> MinFrameRateOptions { get; };
Int32 MinFrameRateIndex;

Boolean IsDeveloperMode;
Expand Down

0 comments on commit 258c7c4

Please sign in to comment.