1 /* 2 * Copyright (C) 2023 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 namespace android::hardware::graphics::composer { 20 21 enum RefreshSource { 22 // Refresh triggered by presentation. 23 kRefreshSourceActivePresent = (1 << 0), 24 kRefreshSourceIdlePresent = (1 << 1), 25 // Refresh NOT triggered by presentation. 26 kRefreshSourceFrameInsertion = (1 << 2), 27 kRefreshSourceBrightness = (1 << 3), 28 }; 29 30 static constexpr int kRefreshSourcePresentMask = 31 kRefreshSourceActivePresent | kRefreshSourceIdlePresent; 32 33 static constexpr int kRefreshSourceNonPresentMask = 34 kRefreshSourceFrameInsertion | kRefreshSourceBrightness; 35 36 class RefreshListener { 37 public: 38 virtual ~RefreshListener() = default; 39 setExpectedPresentTime(int64_t __unused timestampNanos,int __unused frameIntervalNs)40 virtual void setExpectedPresentTime(int64_t __unused timestampNanos, 41 int __unused frameIntervalNs) {} 42 onPresent(int32_t __unused fence)43 virtual void onPresent(int32_t __unused fence) {} 44 onPresent(int64_t __unused presentTimeNs,int __unused flag)45 virtual void onPresent(int64_t __unused presentTimeNs, int __unused flag) {} 46 onNonPresentRefresh(int64_t __unused refreshTimeNs,RefreshSource __unused source)47 virtual void onNonPresentRefresh(int64_t __unused refreshTimeNs, 48 RefreshSource __unused source) {} 49 }; 50 51 class VsyncListener { 52 public: 53 virtual ~VsyncListener() = default; 54 55 virtual void onVsync(int64_t timestamp, int32_t vsyncPeriodNanos) = 0; 56 }; 57 58 class PowerModeListener { 59 public: 60 virtual ~PowerModeListener() = default; 61 62 virtual void onPowerStateChange(int from, int to) = 0; 63 }; 64 65 class RefreshRateChangeListener { 66 public: 67 virtual ~RefreshRateChangeListener() = default; 68 69 virtual void onRefreshRateChange(int refreshRate) = 0; 70 }; 71 72 } // namespace android::hardware::graphics::composer 73