blob: bca533b794b938a4be5adf70036eb327dbeb1831 [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
Marin Shalamanov526c3382020-12-10 15:22:29 +010019#include "Fps.h"
20
Alec Mouri717bcb62020-02-10 17:07:19 -080021#include <cutils/compiler.h>
22#include <utils/StrongPointer.h>
23
Lloyd Pique90c115d2018-09-18 21:39:42 -070024#include <cinttypes>
25#include <functional>
26#include <memory>
27#include <string>
28
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070029namespace android {
30
Lloyd Pique90c115d2018-09-18 21:39:42 -070031typedef int32_t PixelFormat;
32
33class BufferQueueLayer;
Lloyd Piquee300b312019-10-03 13:03:45 -070034class BufferLayerConsumer;
Dominik Laskowskie0e0cde2021-07-30 10:42:05 -070035class BufferStateLayer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070036class ContainerLayer;
37class DisplayDevice;
Dominik Laskowskie0e0cde2021-07-30 10:42:05 -070038class EffectLayer;
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080039class FrameTracer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070040class GraphicBuffer;
41class HWComposer;
42class IGraphicBufferConsumer;
43class IGraphicBufferProducer;
Lloyd Piquee300b312019-10-03 13:03:45 -070044class Layer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070045class MessageQueue;
46class Scheduler;
47class StartPropertySetThread;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070048class SurfaceFlinger;
Lloyd Pique90c115d2018-09-18 21:39:42 -070049class SurfaceInterceptor;
Adithya Srinivasan01189672020-10-20 14:23:05 -070050class TimeStats;
Lloyd Pique90c115d2018-09-18 21:39:42 -070051
52struct DisplayDeviceCreationArgs;
Dominik Laskowskie0e0cde2021-07-30 10:42:05 -070053struct ICompositor;
Dominik Laskowski8b01cc02020-07-14 19:02:41 -070054struct ISchedulerCallback;
Lloyd Pique90c115d2018-09-18 21:39:42 -070055struct LayerCreationArgs;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070056
Lloyd Pique70d91362018-10-18 16:02:55 -070057namespace compositionengine {
58class CompositionEngine;
59} // namespace compositionengine
Ana Krulec757f63a2019-01-25 10:46:18 -080060
61namespace scheduler {
Ady Abraham8287e852020-08-12 14:44:58 -070062class VsyncConfiguration;
Ady Abraham8cb21882020-08-26 18:22:05 -070063class VsyncController;
Lloyd Pique10502f52019-05-17 15:26:56 -070064class RefreshRateConfigs;
Ana Krulec757f63a2019-01-25 10:46:18 -080065} // namespace scheduler
Lloyd Pique10502f52019-05-17 15:26:56 -070066
Adithya Srinivasan01189672020-10-20 14:23:05 -070067namespace frametimeline {
68class FrameTimeline;
69} // namespace frametimeline
70
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070071namespace surfaceflinger {
72
Lloyd Pique90c115d2018-09-18 21:39:42 -070073class NativeWindowSurface;
74
75// The interface that SurfaceFlinger uses to create all of the implementations
76// of each interface.
77class Factory {
78public:
Lloyd Pique90c115d2018-09-18 21:39:42 -070079 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
Dominik Laskowskie0e0cde2021-07-30 10:42:05 -070080 virtual std::unique_ptr<MessageQueue> createMessageQueue(ICompositor&) = 0;
Ady Abraham8287e852020-08-12 14:44:58 -070081 virtual std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010082 Fps currentRefreshRate) = 0;
Ady Abraham3efa3942021-06-24 19:01:25 -070083 virtual std::unique_ptr<Scheduler> createScheduler(
84 const std::shared_ptr<scheduler::RefreshRateConfigs>&, ISchedulerCallback&) = 0;
Pablo Gamitoc351d6f2020-09-17 15:34:26 +000085 virtual sp<SurfaceInterceptor> createSurfaceInterceptor() = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070086
87 virtual sp<StartPropertySetThread> createStartPropertySetThread(
88 bool timestampPropertyValue) = 0;
Lloyd Pique9370a482019-10-03 17:58:30 -070089 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070090 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
91 PixelFormat format, uint32_t layerCount,
92 uint64_t usage, std::string requestorName) = 0;
93 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
94 sp<IGraphicBufferConsumer>* outConsumer,
95 bool consumerIsSurfaceFlinger) = 0;
Lloyd Piquee300b312019-10-03 13:03:45 -070096 virtual sp<IGraphicBufferProducer> createMonitoredProducer(const sp<IGraphicBufferProducer>&,
97 const sp<SurfaceFlinger>&,
98 const wp<Layer>&) = 0;
99 virtual sp<BufferLayerConsumer> createBufferLayerConsumer(const sp<IGraphicBufferConsumer>&,
100 renderengine::RenderEngine&,
101 uint32_t tex, Layer*) = 0;
102
Lloyd Pique90c115d2018-09-18 21:39:42 -0700103 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
104 const sp<IGraphicBufferProducer>&) = 0;
105
Lloyd Pique70d91362018-10-18 16:02:55 -0700106 virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
107
Lloyd Pique90c115d2018-09-18 21:39:42 -0700108 virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
109 virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
Vishnu Nairfa247b12020-02-11 08:58:26 -0800110 virtual sp<EffectLayer> createEffectLayer(const LayerCreationArgs& args) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -0700111 virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -0800112 virtual std::unique_ptr<FrameTracer> createFrameTracer() = 0;
Adithya Srinivasan01189672020-10-20 14:23:05 -0700113 virtual std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -0800114 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -0700115
116protected:
117 ~Factory() = default;
118};
119
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -0700120ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
121
122} // namespace surfaceflinger
123} // namespace android