PowerAdvisor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2018 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. #define HWC2_INCLUDE_STRINGIFICATION
  18. #define HWC2_USE_CPP11
  19. #include <hardware/hwcomposer2.h>
  20. #undef HWC2_INCLUDE_STRINGIFICATION
  21. #undef HWC2_USE_CPP11
  22. #include <unordered_set>
  23. #include <android/hardware/power/1.3/IPower.h>
  24. #include <utils/StrongPointer.h>
  25. #include "DisplayIdentification.h"
  26. namespace android {
  27. namespace Hwc2 {
  28. class PowerAdvisor {
  29. public:
  30. virtual ~PowerAdvisor();
  31. virtual void setExpensiveRenderingExpected(DisplayId displayId, bool expected) = 0;
  32. };
  33. namespace impl {
  34. namespace V1_3 = android::hardware::power::V1_3;
  35. // PowerAdvisor is a wrapper around IPower HAL which takes into account the
  36. // full state of the system when sending out power hints to things like the GPU.
  37. class PowerAdvisor final : public Hwc2::PowerAdvisor {
  38. public:
  39. PowerAdvisor();
  40. ~PowerAdvisor() override;
  41. void setExpensiveRenderingExpected(DisplayId displayId, bool expected) override;
  42. private:
  43. sp<V1_3::IPower> getPowerHal();
  44. std::unordered_set<DisplayId> mExpensiveDisplays;
  45. bool mNotifiedExpensiveRendering = false;
  46. bool mReconnectPowerHal = false;
  47. };
  48. } // namespace impl
  49. } // namespace Hwc2
  50. } // namespace android