host_display_client.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2017 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 COMPONENTS_VIZ_HOST_HOST_DISPLAY_CLIENT_H_
  5. #define COMPONENTS_VIZ_HOST_HOST_DISPLAY_CLIENT_H_
  6. #include <memory>
  7. #include "base/task/single_thread_task_runner.h"
  8. #include "build/build_config.h"
  9. #include "build/chromeos_buildflags.h"
  10. #include "components/viz/host/viz_host_export.h"
  11. #include "mojo/public/cpp/bindings/pending_remote.h"
  12. #include "mojo/public/cpp/bindings/receiver.h"
  13. #include "services/viz/privileged/mojom/compositing/display_private.mojom.h"
  14. #include "ui/gfx/native_widget_types.h"
  15. namespace viz {
  16. class LayeredWindowUpdaterImpl;
  17. // mojom::DisplayClient implementation that relays calls to platform specific
  18. // functions.
  19. class VIZ_HOST_EXPORT HostDisplayClient : public mojom::DisplayClient {
  20. public:
  21. explicit HostDisplayClient(gfx::AcceleratedWidget widget);
  22. HostDisplayClient(const HostDisplayClient&) = delete;
  23. HostDisplayClient& operator=(const HostDisplayClient&) = delete;
  24. ~HostDisplayClient() override;
  25. mojo::PendingRemote<mojom::DisplayClient> GetBoundRemote(
  26. scoped_refptr<base::SingleThreadTaskRunner> task_runner);
  27. private:
  28. // mojom::DisplayClient implementation:
  29. #if BUILDFLAG(IS_APPLE)
  30. void OnDisplayReceivedCALayerParams(
  31. const gfx::CALayerParams& ca_layer_params) override;
  32. #endif
  33. #if BUILDFLAG(IS_WIN)
  34. void CreateLayeredWindowUpdater(
  35. mojo::PendingReceiver<mojom::LayeredWindowUpdater> receiver) override;
  36. #endif
  37. // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
  38. // of lacros-chrome is complete.
  39. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
  40. void DidCompleteSwapWithNewSize(const gfx::Size& size) override;
  41. #endif
  42. mojo::Receiver<mojom::DisplayClient> receiver_{this};
  43. #if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_WIN)
  44. gfx::AcceleratedWidget widget_;
  45. #endif
  46. #if BUILDFLAG(IS_WIN)
  47. std::unique_ptr<LayeredWindowUpdaterImpl> layered_window_updater_;
  48. #endif
  49. };
  50. } // namespace viz
  51. #endif // COMPONENTS_VIZ_HOST_HOST_DISPLAY_CLIENT_H_