Skip to content

Commit

Permalink
Windows 10 Version 1803 - September 2018 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing committed Sep 13, 2018
2 parents 157c9eb + f29cda9 commit dca302e
Show file tree
Hide file tree
Showing 65 changed files with 2,608 additions and 307 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
<td><a href="Samples/WiFiDirectServices">Wi-Fi Direct services</a></td>
</tr>
<tr>
<td><a href="Samples/HotspotAuthentication">Wi-Fi hotspot authentication</a></td>
<td><a href="Samples/WiFiScan">Wi-Fi scanning</a></td>
</tr>
</table>
Expand Down
1 change: 0 additions & 1 deletion Samples/AdaptiveStreaming/cs/AdaptiveStreaming.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
<Link>Shared\Logging\Extensions\MediaPlaybackListStringExtensions.cs</Link>
</Compile>
<Compile Include="Helpers\CommonLicenseRequest.cs" />
<Compile Include="Helpers\MediaPlayerExtensions.cs" />
<Compile Include="Helpers\PlayReadyHelper.cs" />
<Compile Include="Controls\ContentSelector.xaml.cs">
<DependentUpon>ContentSelector.xaml</DependentUpon>
Expand Down
73 changes: 0 additions & 73 deletions Samples/AdaptiveStreaming/cs/Helpers/MediaPlayerExtensions.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)
var mp = mediaPlayerElement.MediaPlayer;
if (mp != null)
{
// Explicitly disposing sources facilitates faster memory reclamation.
mp.DisposeSource(); // From SDKTemplate.Helpers.MediaPlayerExtensions

// Ensure MediaPlayerElement drops its reference to MediaPlayer.
mediaPlayerElement.SetMediaPlayer(null);

Expand Down
2 changes: 0 additions & 2 deletions Samples/AdaptiveStreaming/cs/Scenario2_EventHandlers.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

UnregisterHandlers(mediaPlayer);

mediaPlayer.DisposeSource();
mediaPlayerElement.SetMediaPlayer(null);
mediaPlayer.Dispose();
}
Expand Down Expand Up @@ -133,7 +132,6 @@ private void Page_OnLoaded(object sender, RoutedEventArgs e)
private async Task<MediaPlaybackItem> LoadSourceFromUriAsync(Uri uri, HttpClient httpClient = null)
{
UnregisterHandlers(mediaPlayerElement.MediaPlayer);
mediaPlayerElement.MediaPlayer?.DisposeSource();

AdaptiveMediaSourceCreationResult result = null;
if (httpClient != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

UnregisterHandlers(mediaPlayer);

mediaPlayer.DisposeSource();
mediaPlayerElement.SetMediaPlayer(null);
mediaPlayer.Dispose();
}
Expand Down Expand Up @@ -149,7 +148,6 @@ private void Page_OnLoaded(object sender, RoutedEventArgs e)
private async Task<MediaPlaybackItem> LoadSourceFromUriAsync(Uri uri, HttpClient httpClient = null)
{
UnregisterHandlers(mediaPlayerElement.MediaPlayer);
mediaPlayerElement.MediaPlayer?.DisposeSource();

if (tokenMethod == AzureKeyAcquisitionMethod.AuthorizationHeader)
{
Expand Down
2 changes: 0 additions & 2 deletions Samples/AdaptiveStreaming/cs/Scenario4_Tuning.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

UnregisterHandlers(mediaPlayer);

mediaPlayer.DisposeSource();
mediaPlayerElement.SetMediaPlayer(null);
mediaPlayer.Dispose();
}
Expand Down Expand Up @@ -134,7 +133,6 @@ private async void PollForInboundBitsPerSecond(CancellationTokenSource cts)
private async Task<MediaPlaybackItem> LoadSourceFromUriAsync(Uri uri, HttpClient httpClient = null)
{
UnregisterHandlers(mediaPlayerElement.MediaPlayer);
mediaPlayerElement.MediaPlayer?.DisposeSource();

AdaptiveMediaSourceCreationResult result = null;
if (httpClient != null)
Expand Down
2 changes: 0 additions & 2 deletions Samples/AdaptiveStreaming/cs/Scenario5_Metadata.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

UnregisterHandlers(mediaPlayer);

mediaPlayer.DisposeSource();
mediaPlayerElement.SetMediaPlayer(null);
mediaPlayer.Dispose();
}
Expand Down Expand Up @@ -112,7 +111,6 @@ private void Page_OnLoaded(object sender, RoutedEventArgs e)
private async Task<MediaPlaybackItem> LoadSourceFromUriAsync(Uri uri, HttpClient httpClient = null)
{
UnregisterHandlers(mediaPlayerElement.MediaPlayer);
mediaPlayerElement.MediaPlayer?.DisposeSource();

AdaptiveMediaSourceCreationResult result = null;
if (httpClient != null)
Expand Down
2 changes: 0 additions & 2 deletions Samples/AdaptiveStreaming/cs/Scenario6_AdInsertion.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

UnregisterHandlers(mediaPlayer);

mediaPlayer.DisposeSource();
mediaPlayerElement.SetMediaPlayer(null);
mediaPlayer.Dispose();
}
Expand Down Expand Up @@ -108,7 +107,6 @@ private void Page_OnLoaded(object sender, RoutedEventArgs e)
private async Task<MediaPlaybackItem> LoadSourceFromUriAsync(Uri uri, HttpClient httpClient = null)
{
UnregisterHandlers(mediaPlayerElement.MediaPlayer);
mediaPlayerElement.MediaPlayer?.DisposeSource();

AdaptiveMediaSourceCreationResult result = null;
if (httpClient != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)

UnregisterHandlers(mediaPlayer);

mediaPlayer.DisposeSource();
mediaPlayerElement.SetMediaPlayer(null);
mediaPlayer.Dispose();
}
Expand Down Expand Up @@ -104,7 +103,6 @@ private void Page_OnLoaded(object sender, RoutedEventArgs e)
private async Task<MediaPlaybackItem> LoadSourceFromUriAsync(Uri uri, HttpClient httpClient = null)
{
UnregisterHandlers(mediaPlayerElement.MediaPlayer);
mediaPlayerElement.MediaPlayer?.DisposeSource();

AdaptiveMediaSourceCreationResult result = null;
if (httpClient != null)
Expand Down
2 changes: 1 addition & 1 deletion Samples/BluetoothLE/cs/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.17134.0" />
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.15063.0" MaxVersionTested="10.0.17134.0" />
</Dependencies>

<Resources>
Expand Down
2 changes: 1 addition & 1 deletion Samples/CustomCapability/cs/ServiceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class ServiceViewModel : INotifyPropertyChanged
[DllImport("api-ms-win-core-sysinfo-l1-2-1.dll")]
static extern void GetSystemTimeAsFileTime(ref FILETIME lpSystemTimeAsFileTime);

[DllImport("api-ms-win-core-libraryloader-l2-1.dll")]
[DllImport("api-ms-win-core-libraryloader-l2-1-0.dll", CharSet = CharSet.Unicode)]
static extern IntPtr LoadPackagedLibrary(string filename, uint reserved);

public static ServiceViewModel Current { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using namespace Windows::UI::Xaml;

static const float sc_MaxZoom = 1.0f; // Restrict max zoom to 1:1 scale.
static const unsigned int sc_MaxBytesPerPixel = 16; // Covers all supported image formats.
static const float sc_nominalRefWhite = 80.0f; // Nominal white nits for sRGB and scRGB.

// 400 bins with gamma of 10 lets us measure luminance to within 10% error for any
// luminance above ~1.5 nits, up to 1 million nits.
Expand All @@ -43,13 +44,13 @@ D2DAdvancedColorImagesRenderer::D2DAdvancedColorImagesRenderer(
) :
m_deviceResources(deviceResources),
m_renderEffectKind(RenderEffectKind::None),
m_imageInfo{},
m_zoom(1.0f),
m_minZoom(1.0f), // Dynamically calculated on window size.
m_imageOffset(),
m_pointerPos(),
m_maxCLL(-1.0f),
m_brightnessAdjust(1.0f),
m_imageInfo{},
m_isComputeSupported(false)
{
// Register to be notified if the GPU device is lost or recreated.
Expand Down Expand Up @@ -116,7 +117,9 @@ void D2DAdvancedColorImagesRenderer::SetRenderOptions(
m_renderEffectKind = effect;
m_brightnessAdjust = brightnessAdjustment;

UpdateWhiteLevelScale(m_brightnessAdjust, m_dispInfo->SdrWhiteLevelInNits);
auto sdrWhite = m_dispInfo ? m_dispInfo->SdrWhiteLevelInNits : sc_nominalRefWhite;

UpdateWhiteLevelScale(m_brightnessAdjust, sdrWhite);

// Adjust the Direct2D effect graph based on RenderEffectKind.
// Some RenderEffectKind values require us to apply brightness adjustment
Expand Down Expand Up @@ -338,7 +341,7 @@ void D2DAdvancedColorImagesRenderer::CreateHistogramResources()

histogramMatrix->SetInputEffect(0, m_histogramPrescale.Get());

float scale = sc_histMaxNits / 80.0f; // scRGB 1.0 is defined as 80 nits.
float scale = sc_histMaxNits / sc_nominalRefWhite;

D2D1_MATRIX_5X4_F rgbtoYnorm = D2D1::Matrix5x4F(
0.2126f / scale, 0, 0, 0,
Expand Down Expand Up @@ -652,8 +655,7 @@ void D2DAdvancedColorImagesRenderer::UpdateWhiteLevelScale(float brightnessAdjus
case AdvancedColorKind::StandardDynamicRange:
case AdvancedColorKind::WideColorGamut:
default:
// Nominal reference white of sRGB is 80 nits.
scale = sdrWhiteLevel / 80.0f;
scale = sdrWhiteLevel / sc_nominalRefWhite;
break;
}

Expand Down Expand Up @@ -710,7 +712,9 @@ void D2DAdvancedColorImagesRenderer::ComputeHdrMetadata()
// Initialize with a sentinel value.
m_maxCLL = -1.0f;

if (!m_isComputeSupported)
// MaxCLL is not meaningful for SDR or WCG images.
if ((!m_isComputeSupported) ||
(m_imageInfo.imageKind != AdvancedColorKind::HighDynamicRange))
{
return;
}
Expand All @@ -722,54 +726,52 @@ void D2DAdvancedColorImagesRenderer::ComputeHdrMetadata()

auto ctx = m_deviceResources->GetD2DDeviceContext();

if (m_imageInfo.imageKind == AdvancedColorKind::HighDynamicRange)
{
ctx->BeginDraw();
ctx->BeginDraw();

ctx->DrawImage(m_histogramEffect.Get());
ctx->DrawImage(m_histogramEffect.Get());

// We ignore D2DERR_RECREATE_TARGET here. This error indicates that the device
// is lost. It will be handled during the next call to Present.
HRESULT hr = ctx->EndDraw();
if (hr != D2DERR_RECREATE_TARGET)
{
DX::ThrowIfFailed(hr);
}
// We ignore D2DERR_RECREATE_TARGET here. This error indicates that the device
// is lost. It will be handled during the next call to Present.
HRESULT hr = ctx->EndDraw();
if (hr != D2DERR_RECREATE_TARGET)
{
DX::ThrowIfFailed(hr);
}

float *histogramData = new float[sc_histNumBins];
DX::ThrowIfFailed(
m_histogramEffect->GetValue(D2D1_HISTOGRAM_PROP_HISTOGRAM_OUTPUT,
reinterpret_cast<BYTE*>(histogramData),
sc_histNumBins * sizeof(float)
)
);
float *histogramData = new float[sc_histNumBins];
DX::ThrowIfFailed(
m_histogramEffect->GetValue(D2D1_HISTOGRAM_PROP_HISTOGRAM_OUTPUT,
reinterpret_cast<BYTE*>(histogramData),
sc_histNumBins * sizeof(float)
)
);

unsigned int maxCLLbin = 0;
float runningSum = 0.0f; // Cumulative sum of values in histogram is 1.0.
for (int i = sc_histNumBins - 1; i >= 0; i--)
{
runningSum += histogramData[i];
maxCLLbin = i;
unsigned int maxCLLbin = 0;
float runningSum = 0.0f; // Cumulative sum of values in histogram is 1.0.
for (int i = sc_histNumBins - 1; i >= 0; i--)
{
runningSum += histogramData[i];
maxCLLbin = i;

if (runningSum >= 1.0f - maxCLLPercent)
{
break;
}
if (runningSum >= 1.0f - maxCLLPercent)
{
break;
}

float binNorm = static_cast<float>(maxCLLbin + 1) / static_cast<float>(sc_histNumBins);
m_maxCLL = powf(binNorm, 1 / sc_histGamma) * sc_histMaxNits;
}
else
{
// MaxCLL is not meaningful for SDR or WCG images.
}

float binNorm = static_cast<float>(maxCLLbin) / static_cast<float>(sc_histNumBins);
m_maxCLL = powf(binNorm, 1 / sc_histGamma) * sc_histMaxNits;

// Some drivers have a bug where histogram will always return 0. Treat this as unknown.
m_maxCLL = (m_maxCLL == 0.0f) ? -1.0f : m_maxCLL;
}

// Set HDR10 metadata to allow HDR displays to optimize behavior based on our content.
void D2DAdvancedColorImagesRenderer::EmitHdrMetadata()
{
if (m_dispInfo->CurrentAdvancedColorKind == AdvancedColorKind::HighDynamicRange)
auto acKind = m_dispInfo ? m_dispInfo->CurrentAdvancedColorKind : AdvancedColorKind::StandardDynamicRange;

if (acKind == AdvancedColorKind::HighDynamicRange)
{
DXGI_HDR_METADATA_HDR10 metadata = {};

Expand Down
Loading

0 comments on commit dca302e

Please sign in to comment.