blob: 573a1a9ad3c5edd2fb4a2d4c6659b6b8bea23021 [file] [log] [blame]
Michael Wright5d22d4f2018-06-21 02:50:34 +01001/*
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
17#pragma once
18
19#define HWC2_INCLUDE_STRINGIFICATION
20#define HWC2_USE_CPP11
21#include <hardware/hwcomposer2.h>
22#undef HWC2_INCLUDE_STRINGIFICATION
23#undef HWC2_USE_CPP11
24
25#include <android/hardware/power/1.3/IPower.h>
26#include <utils/StrongPointer.h>
27
28#include <unordered_set>
29
30namespace android {
31namespace Hwc2 {
32
33class PowerAdvisor {
34public:
35 virtual ~PowerAdvisor();
36
37 virtual void setExpensiveRenderingExpected(hwc2_display_t displayId, bool expected) = 0;
38};
39
40namespace impl {
41
42namespace V1_3 = android::hardware::power::V1_3;
43
44// PowerAdvisor is a wrapper around IPower HAL which takes into account the
45// full state of the system when sending out power hints to things like the GPU.
46class PowerAdvisor final : public Hwc2::PowerAdvisor {
47public:
48 PowerAdvisor();
49 ~PowerAdvisor() override;
50
51 void setExpensiveRenderingExpected(hwc2_display_t displayId, bool expected) override;
52
53private:
54 sp<V1_3::IPower> getPowerHal();
55
56 std::unordered_set<hwc2_display_t> mExpensiveDisplays;
57 bool mNotifiedExpensiveRendering = false;
58 bool mReconnectPowerHal = false;
59};
60
61} // namespace impl
62} // namespace Hwc2
63} // namespace android