compositing_mode_reporter_impl.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_COMPOSITING_MODE_REPORTER_IMPL_H_
  5. #define COMPONENTS_VIZ_HOST_COMPOSITING_MODE_REPORTER_IMPL_H_
  6. #include "components/viz/host/viz_host_export.h"
  7. #include "mojo/public/cpp/bindings/pending_remote.h"
  8. #include "mojo/public/cpp/bindings/receiver_set.h"
  9. #include "mojo/public/cpp/bindings/remote_set.h"
  10. #include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h"
  11. namespace viz {
  12. class VIZ_HOST_EXPORT CompositingModeReporterImpl
  13. : public mojom::CompositingModeReporter {
  14. public:
  15. // Creates the CompositingModeReporterImpl and binds it to the deferred mojo
  16. // pointer behind the |request|.
  17. CompositingModeReporterImpl();
  18. ~CompositingModeReporterImpl() override;
  19. // Called for each consumer of the CompositingModeReporter interface, to
  20. // bind a receiver for them.
  21. void BindReceiver(
  22. mojo::PendingReceiver<mojom::CompositingModeReporter> receiver);
  23. // Call to inform the reporter that software compositing is being used instead
  24. // of gpu. This is a one-way setting that can not be reverted. This will
  25. // notify any registered CompositingModeWatchers.
  26. void SetUsingSoftwareCompositing();
  27. // mojom::CompositingModeReporter implementation.
  28. void AddCompositingModeWatcher(
  29. mojo::PendingRemote<mojom::CompositingModeWatcher> watcher) override;
  30. private:
  31. bool gpu_ = true;
  32. mojo::ReceiverSet<mojom::CompositingModeReporter> receivers_;
  33. mojo::RemoteSet<mojom::CompositingModeWatcher> watchers_;
  34. };
  35. } // namespace viz
  36. #endif // COMPONENTS_VIZ_HOST_COMPOSITING_MODE_REPORTER_IMPL_H_