blob: d1f21bfb437678df5053e20f6d909d90d3bd051a [file] [log] [blame]
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -07001/*
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
Lloyd Pique90c115d2018-09-18 21:39:42 -070019#include <cinttypes>
20#include <functional>
21#include <memory>
22#include <string>
23
Dominik Laskowskif6b4ba62021-11-09 12:46:10 -080024#include <cutils/compiler.h>
25#include <utils/StrongPointer.h>
26
27#include <scheduler/Fps.h>
28
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070029namespace android {
30
Lloyd Pique90c115d2018-09-18 21:39:42 -070031typedef int32_t PixelFormat;
32
Lloyd Piquee300b312019-10-03 13:03:45 -070033class BufferLayerConsumer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070034class DisplayDevice;
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080035class FrameTracer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070036class GraphicBuffer;
37class HWComposer;
38class IGraphicBufferConsumer;
39class IGraphicBufferProducer;
Lloyd Piquee300b312019-10-03 13:03:45 -070040class Layer;
Vishnu Naire14c6b32022-08-06 04:20:15 +000041class LayerFE;
Lloyd Pique90c115d2018-09-18 21:39:42 -070042class StartPropertySetThread;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070043class SurfaceFlinger;
Adithya Srinivasan01189672020-10-20 14:23:05 -070044class TimeStats;
Lloyd Pique90c115d2018-09-18 21:39:42 -070045
46struct DisplayDeviceCreationArgs;
47struct LayerCreationArgs;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070048
Lloyd Pique70d91362018-10-18 16:02:55 -070049namespace compositionengine {
50class CompositionEngine;
51} // namespace compositionengine
Ana Krulec757f63a2019-01-25 10:46:18 -080052
53namespace scheduler {
Ady Abraham8287e852020-08-12 14:44:58 -070054class VsyncConfiguration;
Ady Abraham8cb21882020-08-26 18:22:05 -070055class VsyncController;
Lloyd Pique10502f52019-05-17 15:26:56 -070056class RefreshRateConfigs;
Ana Krulec757f63a2019-01-25 10:46:18 -080057} // namespace scheduler
Lloyd Pique10502f52019-05-17 15:26:56 -070058
Adithya Srinivasan01189672020-10-20 14:23:05 -070059namespace frametimeline {
60class FrameTimeline;
61} // namespace frametimeline
62
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070063namespace surfaceflinger {
64
Lloyd Pique90c115d2018-09-18 21:39:42 -070065class NativeWindowSurface;
66
67// The interface that SurfaceFlinger uses to create all of the implementations
68// of each interface.
69class Factory {
70public:
Lloyd Pique90c115d2018-09-18 21:39:42 -070071 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
Ady Abraham8287e852020-08-12 14:44:58 -070072 virtual std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010073 Fps currentRefreshRate) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070074
75 virtual sp<StartPropertySetThread> createStartPropertySetThread(
76 bool timestampPropertyValue) = 0;
Lloyd Pique9370a482019-10-03 17:58:30 -070077 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070078 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
79 PixelFormat format, uint32_t layerCount,
80 uint64_t usage, std::string requestorName) = 0;
81 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
82 sp<IGraphicBufferConsumer>* outConsumer,
83 bool consumerIsSurfaceFlinger) = 0;
Lloyd Piquee300b312019-10-03 13:03:45 -070084
Lloyd Pique90c115d2018-09-18 21:39:42 -070085 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
86 const sp<IGraphicBufferProducer>&) = 0;
87
Lloyd Pique70d91362018-10-18 16:02:55 -070088 virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
89
Patrick Williams83f36b22022-09-14 17:57:35 +000090 virtual sp<Layer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
Patrick Williams46b61b92022-09-01 17:25:49 +000091 virtual sp<Layer> createEffectLayer(const LayerCreationArgs& args) = 0;
Vishnu Naire14c6b32022-08-06 04:20:15 +000092 virtual sp<LayerFE> createLayerFE(const std::string& layerName) = 0;
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080093 virtual std::unique_ptr<FrameTracer> createFrameTracer() = 0;
Adithya Srinivasan01189672020-10-20 14:23:05 -070094 virtual std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -080095 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070096
97protected:
98 ~Factory() = default;
99};
100
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -0700101ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
102
103} // namespace surfaceflinger
104} // namespace android