blob: 6638490720a52cb3efb3a896f0ed0db3ef834b8d [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
Alec Mouri717bcb62020-02-10 17:07:19 -080019#include <cutils/compiler.h>
20#include <utils/StrongPointer.h>
21
Lloyd Pique90c115d2018-09-18 21:39:42 -070022#include <cinttypes>
23#include <functional>
24#include <memory>
25#include <string>
26
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070027namespace android {
28
Lloyd Pique90c115d2018-09-18 21:39:42 -070029typedef int32_t PixelFormat;
30
31class BufferQueueLayer;
32class BufferStateLayer;
Lloyd Piquee300b312019-10-03 13:03:45 -070033class BufferLayerConsumer;
Vishnu Nairfa247b12020-02-11 08:58:26 -080034class EffectLayer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070035class ContainerLayer;
36class DisplayDevice;
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080037class FrameTracer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070038class GraphicBuffer;
39class HWComposer;
40class IGraphicBufferConsumer;
41class IGraphicBufferProducer;
Lloyd Piquee300b312019-10-03 13:03:45 -070042class Layer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070043class MessageQueue;
44class Scheduler;
45class StartPropertySetThread;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070046class SurfaceFlinger;
Lloyd Pique90c115d2018-09-18 21:39:42 -070047class SurfaceInterceptor;
Adithya Srinivasan01189672020-10-20 14:23:05 -070048class TimeStats;
Lloyd Pique90c115d2018-09-18 21:39:42 -070049
50struct DisplayDeviceCreationArgs;
Dominik Laskowski8b01cc02020-07-14 19:02:41 -070051struct ISchedulerCallback;
Lloyd Pique90c115d2018-09-18 21:39:42 -070052struct LayerCreationArgs;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070053
Lloyd Pique70d91362018-10-18 16:02:55 -070054namespace compositionengine {
55class CompositionEngine;
56} // namespace compositionengine
Ana Krulec757f63a2019-01-25 10:46:18 -080057
58namespace scheduler {
Ady Abraham8287e852020-08-12 14:44:58 -070059class VsyncConfiguration;
Ady Abraham8cb21882020-08-26 18:22:05 -070060class VsyncController;
Lloyd Pique10502f52019-05-17 15:26:56 -070061class RefreshRateConfigs;
Ana Krulec757f63a2019-01-25 10:46:18 -080062} // namespace scheduler
Lloyd Pique10502f52019-05-17 15:26:56 -070063
Adithya Srinivasan01189672020-10-20 14:23:05 -070064namespace frametimeline {
65class FrameTimeline;
66} // namespace frametimeline
67
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070068namespace surfaceflinger {
69
Lloyd Pique90c115d2018-09-18 21:39:42 -070070class NativeWindowSurface;
71
72// The interface that SurfaceFlinger uses to create all of the implementations
73// of each interface.
74class Factory {
75public:
Lloyd Pique90c115d2018-09-18 21:39:42 -070076 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
77 virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0;
Ady Abraham8287e852020-08-12 14:44:58 -070078 virtual std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration(
Ady Abraham9e16a482019-12-03 17:19:41 -080079 const scheduler::RefreshRateConfigs&) = 0;
Dominik Laskowski8b01cc02020-07-14 19:02:41 -070080 virtual std::unique_ptr<Scheduler> createScheduler(const scheduler::RefreshRateConfigs&,
Ady Abraham3a77a7b2019-12-02 18:46:59 -080081 ISchedulerCallback&) = 0;
Pablo Gamitoc351d6f2020-09-17 15:34:26 +000082 virtual sp<SurfaceInterceptor> createSurfaceInterceptor() = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070083
84 virtual sp<StartPropertySetThread> createStartPropertySetThread(
85 bool timestampPropertyValue) = 0;
Lloyd Pique9370a482019-10-03 17:58:30 -070086 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070087 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
88 PixelFormat format, uint32_t layerCount,
89 uint64_t usage, std::string requestorName) = 0;
90 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
91 sp<IGraphicBufferConsumer>* outConsumer,
92 bool consumerIsSurfaceFlinger) = 0;
Lloyd Piquee300b312019-10-03 13:03:45 -070093 virtual sp<IGraphicBufferProducer> createMonitoredProducer(const sp<IGraphicBufferProducer>&,
94 const sp<SurfaceFlinger>&,
95 const wp<Layer>&) = 0;
96 virtual sp<BufferLayerConsumer> createBufferLayerConsumer(const sp<IGraphicBufferConsumer>&,
97 renderengine::RenderEngine&,
98 uint32_t tex, Layer*) = 0;
99
Lloyd Pique90c115d2018-09-18 21:39:42 -0700100 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
101 const sp<IGraphicBufferProducer>&) = 0;
102
Lloyd Pique70d91362018-10-18 16:02:55 -0700103 virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
104
Lloyd Pique90c115d2018-09-18 21:39:42 -0700105 virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
106 virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
Vishnu Nairfa247b12020-02-11 08:58:26 -0800107 virtual sp<EffectLayer> createEffectLayer(const LayerCreationArgs& args) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -0700108 virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -0800109 virtual std::unique_ptr<FrameTracer> createFrameTracer() = 0;
Adithya Srinivasan01189672020-10-20 14:23:05 -0700110 virtual std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -0800111 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -0700112
113protected:
114 ~Factory() = default;
115};
116
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -0700117ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
118
119} // namespace surfaceflinger
120} // namespace android