hdr_metadata_helper_win.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef UI_GL_HDR_METADATA_HELPER_WIN_H_
  5. #define UI_GL_HDR_METADATA_HELPER_WIN_H_
  6. #include <d3d11_1.h>
  7. #include <dxgi1_6.h>
  8. #include <wrl/client.h>
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "ui/gfx/hdr_metadata.h"
  11. #include "ui/gl/gl_export.h"
  12. #include "ui/gl/gpu_switching_observer.h"
  13. namespace gl {
  14. // This is a very hacky way to get the display characteristics.
  15. // It should be replaced by something that actually knows which
  16. // display is going to be used for, well, display.
  17. class GL_EXPORT HDRMetadataHelperWin : ui::GpuSwitchingObserver {
  18. public:
  19. explicit HDRMetadataHelperWin(
  20. Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device);
  21. HDRMetadataHelperWin(const HDRMetadataHelperWin&) = delete;
  22. HDRMetadataHelperWin& operator=(const HDRMetadataHelperWin&) = delete;
  23. ~HDRMetadataHelperWin() override;
  24. // Return the metadata for the display, if available. Must call
  25. // UpdateDisplayMetadata first.
  26. absl::optional<DXGI_HDR_METADATA_HDR10> GetDisplayMetadata();
  27. // Query the display metadata from all monitors. In the event of monitor
  28. // hot plugging, the metadata should be updated again.
  29. void UpdateDisplayMetadata();
  30. // Convert |hdr_metadata| to DXGI's metadata format.
  31. static DXGI_HDR_METADATA_HDR10 HDRMetadataToDXGI(
  32. const gfx::HDRMetadata& hdr_metadata);
  33. // Implements GpuSwitchingObserver
  34. void OnDisplayAdded() override;
  35. void OnDisplayRemoved() override;
  36. private:
  37. Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_;
  38. absl::optional<DXGI_HDR_METADATA_HDR10> hdr_metadata_;
  39. };
  40. } // namespace gl
  41. #endif // UI_GL_HDR_METADATA_HELPER_WIN_H_