Skip to content

Commit

Permalink
add in a second overlay window, remove (hide) some control knobs
Browse files Browse the repository at this point in the history
- Fix on screen window size to 800x600
- Only expose update window contol
  • Loading branch information
David Scherba committed May 21, 2014
1 parent ffef890 commit 8ab0999
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
1 change: 1 addition & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ namespace WpfRenderPerformance
public partial class App : Application
{
public OverlayWindow ow_;
public OverlayWindow ow2_;
}
}
15 changes: 10 additions & 5 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF Render Performance Control Panel" Height="147.649" Width="525" Loaded="OnLoaded" Closed="Window_Closed" Topmost="True">
<Grid>
<CheckBox Name="TransparentChk" Content="Transparent" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" IsChecked="True" Click="CheckBox_Checked" Checked="CheckBox_Checked"/>
<Slider Name="WindowSizeSlider" HorizontalAlignment="Left" Margin="105,80,0,0" VerticalAlignment="Top" Width="391" ValueChanged="WindowSizeSlider_ValueChanged" Value="10.0"/>
<Label Content="Window Size" HorizontalAlignment="Left" Margin="10,76,0,0" VerticalAlignment="Top" Width="78"/>
<CheckBox Name="RenderChk" Content="Update overlay (30fps)" HorizontalAlignment="Left" Margin="10,29,0,0" VerticalAlignment="Top" IsChecked="True"/>
<CheckBox Name="SoftwareRenderChk" Content="Force Software Render" HorizontalAlignment="Left" Margin="10,49,0,0" VerticalAlignment="Top" Checked="SoftwareRenderChk_Checked" Unchecked="SoftwareRenderChk_Checked"/>
<CheckBox Visibility="Hidden" Name="TransparentChk" Content="Transparent" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" IsChecked="True" Click="CheckBox_Checked" Checked="CheckBox_Checked"/>
<Slider Visibility="Hidden" Name="WindowSizeSlider" HorizontalAlignment="Left" Margin="105,80,0,0" VerticalAlignment="Top" Width="391" ValueChanged="WindowSizeSlider_ValueChanged" Value="10.0"/>
<Label Visibility="Hidden" Content="Window Size" HorizontalAlignment="Left" Margin="10,76,0,0" VerticalAlignment="Top" Width="78"/>
<CheckBox Name="RenderChk" Content="Update overlay (30fps)." HorizontalAlignment="Left" Margin="10,29,0,0" VerticalAlignment="Top" IsChecked="True"/>
<CheckBox Visibility="Hidden" Name="SoftwareRenderChk" Content="Force Software Render" HorizontalAlignment="Left" Margin="10,49,0,0" VerticalAlignment="Top" Checked="SoftwareRenderChk_Checked" Unchecked="SoftwareRenderChk_Checked"/>
<Label x:Name="DesktopRes" Content="Resolution: " HorizontalAlignment="Left" Margin="311,4,0,0" VerticalAlignment="Top"/>
<Label Content="Window Width: " HorizontalAlignment="Left" Margin="311,23,0,0" VerticalAlignment="Top"/>
<Label Content="asdf" x:Name="WinWidth" HorizontalAlignment="Left" Margin="415,23,0,0" VerticalAlignment="Top"/>
<Label Content="Window Height: " HorizontalAlignment="Left" Margin="311,43,0,0" VerticalAlignment="Top"/>
<Label Content ="asdf" x:Name="WinHeight" HorizontalAlignment="Left" Margin="415,43,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>
33 changes: 27 additions & 6 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@ private void OnLoaded(object sender, RoutedEventArgs e)

if (app.ow_ == null) {
app.ow_ = new OverlayWindow();
app.ow_.Width = (app.MainWindow as MainWindow).WindowSizeSlider.Value / 10.0 * System.Windows.SystemParameters.PrimaryScreenWidth;
app.ow_.Height = app.ow_.Width * 480.0 / 640.0;
app.ow_.Width = 800.0; // (app.MainWindow as MainWindow).WindowSizeSlider.Value / 10.0 * System.Windows.SystemParameters.PrimaryScreenWidth;
app.ow_.Height = 600.0; // app.ow_.Width * 480.0 / 640.0;

app.ow2_ = new OverlayWindow();
app.ow2_.Width = app.ow_.Width;
app.ow2_.Height = app.ow_.Height;

DesktopRes.Content = "Desktop Res: " + System.Windows.SystemParameters.PrimaryScreenWidth.ToString() + "x" + System.Windows.SystemParameters.PrimaryScreenHeight.ToString();
WinWidth.Content = app.ow_.Width.ToString();
WinHeight.Content = app.ow_.Height.ToString();
app.ow_.Show();
app.ow2_.Show();
}
}

Expand All @@ -46,34 +55,42 @@ private void CheckBox_Checked(object sender, RoutedEventArgs e)
if (app.ow_ == null) return;

app.ow_.Close();
app.ow2_.Close();

app.ow_ = new OverlayWindow();
app.ow_.Width = (app.MainWindow as MainWindow).WindowSizeSlider.Value / 10.0 * System.Windows.SystemParameters.PrimaryScreenWidth;
app.ow_.Height = app.ow_.Width * 480.0 / 640.0;
app.ow2_ = new OverlayWindow();
app.ow_.Width = app.ow2_.Width = 800; // (app.MainWindow as MainWindow).WindowSizeSlider.Value / 10.0 * System.Windows.SystemParameters.PrimaryScreenWidth;
app.ow_.Height = app.ow2_.Height = 600; // app.ow_.Width * 480.0 / 640.0;

if (TransparentChk.IsChecked.GetValueOrDefault(false)) {
app.ow_.AllowsTransparency = true;
app.ow2_.AllowsTransparency = true;
}
else {
app.ow_.AllowsTransparency = false;
app.ow2_.AllowsTransparency = false;
}

app.ow_.Show();
app.ow2_.Show();
}

private void Window_Closed(object sender, EventArgs e)
{
App app = App.Current as App;
app.ow_.Close();
app.ow2_.Close();
}

private void WindowSizeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
App app = App.Current as App;
if (app.ow_ != null)
{
app.ow_.Width = e.NewValue / 10.0 * System.Windows.SystemParameters.PrimaryScreenWidth;
app.ow_.Height = app.ow_.Width * 480.0 / 640.0;
app.ow_.Width = app.ow2_.Width = e.NewValue / 10.0 * System.Windows.SystemParameters.PrimaryScreenWidth;
app.ow_.Height = app.ow2_.Height = app.ow_.Width * 480.0 / 640.0;
WinWidth.Content = app.ow_.Width.ToString();
WinHeight.Content = app.ow_.Height.ToString();
}
}

Expand All @@ -82,10 +99,14 @@ private void SoftwareRenderChk_Checked(object sender, RoutedEventArgs e)
App app = App.Current as App;
HwndSource hwndSource = PresentationSource.FromVisual(app.ow_) as HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
HwndSource hwndSource2 = PresentationSource.FromVisual(app.ow2_) as HwndSource;
HwndTarget hwndTarget2 = hwndSource2.CompositionTarget;
if (SoftwareRenderChk.IsChecked.GetValueOrDefault(false)) {
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
hwndTarget2.RenderMode = RenderMode.SoftwareOnly;
} else {
hwndTarget.RenderMode = RenderMode.Default;
hwndTarget2.RenderMode = RenderMode.Default;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions WpfRenderHelper/WpfRenderHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ namespace WpfRenderHelper {
{
System::Console::WriteLine("working!");

array<Byte>^ bgra = gcnew array<Byte>(640*480*4);
while(true) {
array<Byte>^ bgra = gcnew array<Byte>(640*480*4);

for (int i=0;i<640*480*4;i++) {
bgra[i] = 0x99; // Just a transparent gray square
}
for (int i=0;i<640*480*4;i++) {
bgra[i] = 0x99; // Just a transparent gray square
}

while(true) {
NewWriteableImage(bgra);
Threading::Thread::Sleep(33); // 30fps-ish
Threading::Thread::Sleep(20); // 30fps-ish
}
}
};
Expand Down

0 comments on commit 8ab0999

Please sign in to comment.