DisplayCreationArgs.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2019 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <cstdint>
  18. #include <optional>
  19. #include "DisplayHardware/DisplayIdentification.h"
  20. namespace android::compositionengine {
  21. class CompositionEngine;
  22. /**
  23. * A parameter object for creating Display instances
  24. */
  25. struct DisplayCreationArgs {
  26. // True if this display is secure
  27. bool isSecure = false;
  28. // True if this display is a virtual display
  29. bool isVirtual = false;
  30. // Identifies the display to the HWC, if composition is supported by it
  31. std::optional<DisplayId> displayId;
  32. };
  33. /**
  34. * A helper for setting up a DisplayCreationArgs value in-line.
  35. * Prefer this builder over raw structure initialization.
  36. *
  37. * Instead of:
  38. *
  39. * DisplayCreationArgs{false, false, displayId}
  40. *
  41. * Prefer:
  42. *
  43. * DisplayCreationArgsBuilder().setIsSecure(false).setIsVirtual(false)
  44. * .setDisplayId(displayId).build();
  45. */
  46. class DisplayCreationArgsBuilder {
  47. public:
  48. DisplayCreationArgs build() { return std::move(mArgs); }
  49. DisplayCreationArgsBuilder& setIsSecure(bool isSecure) {
  50. mArgs.isSecure = isSecure;
  51. return *this;
  52. }
  53. DisplayCreationArgsBuilder& setIsVirtual(bool isVirtual) {
  54. mArgs.isVirtual = isVirtual;
  55. return *this;
  56. }
  57. DisplayCreationArgsBuilder& setDisplayId(std::optional<DisplayId> displayId) {
  58. mArgs.displayId = displayId;
  59. return *this;
  60. }
  61. private:
  62. DisplayCreationArgs mArgs;
  63. };
  64. } // namespace android::compositionengine