blob: 0db941d4199b5870209b60c832e40331f15af1ca [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
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070024#include <cutils/compiler.h>
25#include <utils/StrongPointer.h>
26
27namespace 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;
Lloyd Pique90c115d2018-09-18 21:39:42 -070034class ColorLayer;
35class ContainerLayer;
36class DisplayDevice;
37class DispSync;
38class EventControlThread;
39class GraphicBuffer;
40class HWComposer;
41class IGraphicBufferConsumer;
42class IGraphicBufferProducer;
Ady Abraham3a77a7b2019-12-02 18:46:59 -080043class ISchedulerCallback;
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;
50
51struct DisplayDeviceCreationArgs;
52struct 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 {
59class PhaseOffsets;
Lloyd Pique10502f52019-05-17 15:26:56 -070060class RefreshRateConfigs;
Ana Krulec757f63a2019-01-25 10:46:18 -080061} // namespace scheduler
Lloyd Pique10502f52019-05-17 15:26:56 -070062
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:
Dominik Laskowski98041832019-08-01 18:35:59 -070071 using SetVSyncEnabled = std::function<void(bool)>;
72
73 virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework) = 0;
74 virtual std::unique_ptr<EventControlThread> createEventControlThread(SetVSyncEnabled) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070075 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
76 virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0;
Ana Krulec757f63a2019-01-25 10:46:18 -080077 virtual std::unique_ptr<scheduler::PhaseOffsets> createPhaseOffsets() = 0;
Dominik Laskowski98041832019-08-01 18:35:59 -070078 virtual std::unique_ptr<Scheduler> createScheduler(SetVSyncEnabled,
Ady Abraham3a77a7b2019-12-02 18:46:59 -080079 const scheduler::RefreshRateConfigs&,
80 ISchedulerCallback&) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070081 virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0;
82
83 virtual sp<StartPropertySetThread> createStartPropertySetThread(
84 bool timestampPropertyValue) = 0;
85 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&&) = 0;
86 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
87 PixelFormat format, uint32_t layerCount,
88 uint64_t usage, std::string requestorName) = 0;
89 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
90 sp<IGraphicBufferConsumer>* outConsumer,
91 bool consumerIsSurfaceFlinger) = 0;
Lloyd Piquee300b312019-10-03 13:03:45 -070092 virtual sp<IGraphicBufferProducer> createMonitoredProducer(const sp<IGraphicBufferProducer>&,
93 const sp<SurfaceFlinger>&,
94 const wp<Layer>&) = 0;
95 virtual sp<BufferLayerConsumer> createBufferLayerConsumer(const sp<IGraphicBufferConsumer>&,
96 renderengine::RenderEngine&,
97 uint32_t tex, Layer*) = 0;
98
Lloyd Pique90c115d2018-09-18 21:39:42 -070099 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
100 const sp<IGraphicBufferProducer>&) = 0;
101
Lloyd Pique70d91362018-10-18 16:02:55 -0700102 virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
103
Lloyd Pique90c115d2018-09-18 21:39:42 -0700104 virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
105 virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
106 virtual sp<ColorLayer> createColorLayer(const LayerCreationArgs& args) = 0;
107 virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
108
109protected:
110 ~Factory() = default;
111};
112
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -0700113ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
114
115} // namespace surfaceflinger
116} // namespace android