1 /* 2 * Copyright (C) 2024 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 #include "../EventQueue.h" 20 #include "AODRefreshRateCalculator.h" 21 #include "CombinedRefreshRateCalculator.h" 22 #include "ExitIdleRefreshRateCalculator.h" 23 #include "InstantRefreshRateCalculator.h" 24 #include "PeriodRefreshRateCalculator.h" 25 #include "RefreshRateCalculator.h" 26 #include "VideoFrameRateCalculator.h" 27 28 namespace android::hardware::graphics::composer { 29 30 class RefreshRateCalculatorFactory { 31 public: 32 RefreshRateCalculatorFactory() = default; 33 ~RefreshRateCalculatorFactory() = default; 34 35 RefreshRateCalculatorFactory(const RefreshRateCalculatorFactory&) = delete; 36 RefreshRateCalculatorFactory& operator=(const RefreshRateCalculatorFactory&) = delete; 37 38 // Build InstantRefreshRateCalculator. 39 std::shared_ptr<RefreshRateCalculator> BuildRefreshRateCalculator(EventQueue* eventQueue, 40 int64_t maxValidPeriodNs); 41 42 // Build ExitIdleRefreshRateCalculator. 43 std::unique_ptr<RefreshRateCalculator> BuildRefreshRateCalculator( 44 EventQueue* eventQueue, const ExitIdleRefreshRateCalculatorParameters& params); 45 46 // Build VideoFrameRateCalculator 47 std::shared_ptr<RefreshRateCalculator> BuildRefreshRateCalculator( 48 EventQueue* eventQueue, const VideoFrameRateCalculatorParameters& params); 49 50 // Build PeriodRefreshRateCalculator. 51 std::shared_ptr<RefreshRateCalculator> BuildRefreshRateCalculator( 52 EventQueue* eventQueue, const PeriodRefreshRateCalculatorParameters& params); 53 54 // Build CombinedRefreshRateCalculator. 55 std::shared_ptr<RefreshRateCalculator> BuildRefreshRateCalculator( 56 EventQueue* eventQueue, const std::vector<RefreshRateCalculatorType>& types); 57 58 // Build CombinedRefreshRateCalculator. 59 std::shared_ptr<RefreshRateCalculator> BuildRefreshRateCalculator( 60 std::vector<std::shared_ptr<RefreshRateCalculator>> refreshRateCalculators, 61 int minValidRefreshRate = 1, int maxValidRefreshRate = 120); 62 63 // Build various RefreshRateCalculator with default settings. 64 std::shared_ptr<RefreshRateCalculator> BuildRefreshRateCalculator( 65 EventQueue* eventQueue, RefreshRateCalculatorType type); 66 }; 67 68 } // namespace android::hardware::graphics::composer 69