blob: 5aa1f22b9e94fd3339fe7dd9c786ac5084a536ae [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
Peiyong Lin74ca2f42019-01-14 19:36:57 -080025#include <unordered_set>
26
Michael Wright5d22d4f2018-06-21 02:50:34 +010027#include <android/hardware/power/1.3/IPower.h>
28#include <utils/StrongPointer.h>
29
Peiyong Lin74ca2f42019-01-14 19:36:57 -080030#include "DisplayIdentification.h"
Michael Wright5d22d4f2018-06-21 02:50:34 +010031
32namespace android {
33namespace Hwc2 {
34
35class PowerAdvisor {
36public:
37 virtual ~PowerAdvisor();
38
Peiyong Lin74ca2f42019-01-14 19:36:57 -080039 virtual void setExpensiveRenderingExpected(DisplayId displayId, bool expected) = 0;
Michael Wright5d22d4f2018-06-21 02:50:34 +010040};
41
42namespace impl {
43
44namespace V1_3 = android::hardware::power::V1_3;
45
46// PowerAdvisor is a wrapper around IPower HAL which takes into account the
47// full state of the system when sending out power hints to things like the GPU.
48class PowerAdvisor final : public Hwc2::PowerAdvisor {
49public:
50 PowerAdvisor();
51 ~PowerAdvisor() override;
52
Peiyong Lin74ca2f42019-01-14 19:36:57 -080053 void setExpensiveRenderingExpected(DisplayId displayId, bool expected) override;
Michael Wright5d22d4f2018-06-21 02:50:34 +010054
55private:
56 sp<V1_3::IPower> getPowerHal();
57
Peiyong Lin74ca2f42019-01-14 19:36:57 -080058 std::unordered_set<DisplayId> mExpensiveDisplays;
Michael Wright5d22d4f2018-06-21 02:50:34 +010059 bool mNotifiedExpensiveRendering = false;
60 bool mReconnectPowerHal = false;
61};
62
63} // namespace impl
64} // namespace Hwc2
65} // namespace android