1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UI_GL_HDR_METADATA_HELPER_WIN_H_
6 #define UI_GL_HDR_METADATA_HELPER_WIN_H_
7 
8 #include <d3d11_1.h>
9 #include <dxgi1_6.h>
10 #include <wrl/client.h>
11 
12 #include <memory>
13 #include <utility>
14 #include <vector>
15 
16 #include "base/macros.h"
17 #include "base/optional.h"
18 #include "ui/gfx/hdr_metadata.h"
19 #include "ui/gl/gl_export.h"
20 
21 namespace gl {
22 
23 // This is a very hacky way to get the display characteristics.
24 // It should be replaced by something that actually knows which
25 // display is going to be used for, well, display.
26 class GL_EXPORT HDRMetadataHelperWin {
27  public:
28   explicit HDRMetadataHelperWin(
29       const Microsoft::WRL::ComPtr<ID3D11Device>& d3d11_device);
30   ~HDRMetadataHelperWin();
31 
32   // Return the metadata for the display, if available.  Must call
33   // CacheDisplayMetadata first.
34   base::Optional<DXGI_HDR_METADATA_HDR10> GetDisplayMetadata();
35 
36   // Convert |hdr_metadata| to DXGI's metadata format.
37   static DXGI_HDR_METADATA_HDR10 HDRMetadataToDXGI(
38       const gfx::HDRMetadata& hdr_metadata);
39 
40  private:
41   void CacheDisplayMetadata(
42       const Microsoft::WRL::ComPtr<ID3D11Device>& d3d11_device);
43 
44   base::Optional<DXGI_HDR_METADATA_HDR10> hdr_metadata_;
45 
46   DISALLOW_COPY_AND_ASSIGN(HDRMetadataHelperWin);
47 };
48 
49 }  // namespace gl
50 
51 #endif  // UI_GL_HDR_METADATA_HELPER_WIN_H_
52