blob: 20784d27078e410c08a0f970b0798bcbc15d19e2 [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;
Lloyd Piquee300b312019-10-03 13:03:45 -070043class Layer;
Lloyd Pique90c115d2018-09-18 21:39:42 -070044class MessageQueue;
45class Scheduler;
46class StartPropertySetThread;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070047class SurfaceFlinger;
Lloyd Pique90c115d2018-09-18 21:39:42 -070048class SurfaceInterceptor;
49
50struct DisplayDeviceCreationArgs;
51struct LayerCreationArgs;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070052
Lloyd Pique70d91362018-10-18 16:02:55 -070053namespace compositionengine {
54class CompositionEngine;
55} // namespace compositionengine
Ana Krulec757f63a2019-01-25 10:46:18 -080056
57namespace scheduler {
58class PhaseOffsets;
Lloyd Pique10502f52019-05-17 15:26:56 -070059class RefreshRateConfigs;
Ana Krulec757f63a2019-01-25 10:46:18 -080060} // namespace scheduler
Lloyd Pique10502f52019-05-17 15:26:56 -070061
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070062namespace surfaceflinger {
63
Lloyd Pique90c115d2018-09-18 21:39:42 -070064class NativeWindowSurface;
65
66// The interface that SurfaceFlinger uses to create all of the implementations
67// of each interface.
68class Factory {
69public:
Dominik Laskowski98041832019-08-01 18:35:59 -070070 using SetVSyncEnabled = std::function<void(bool)>;
71
72 virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework) = 0;
73 virtual std::unique_ptr<EventControlThread> createEventControlThread(SetVSyncEnabled) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070074 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
75 virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0;
Ana Krulec757f63a2019-01-25 10:46:18 -080076 virtual std::unique_ptr<scheduler::PhaseOffsets> createPhaseOffsets() = 0;
Dominik Laskowski98041832019-08-01 18:35:59 -070077 virtual std::unique_ptr<Scheduler> createScheduler(SetVSyncEnabled,
78 const scheduler::RefreshRateConfigs&) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070079 virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0;
80
81 virtual sp<StartPropertySetThread> createStartPropertySetThread(
82 bool timestampPropertyValue) = 0;
83 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&&) = 0;
84 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
85 PixelFormat format, uint32_t layerCount,
86 uint64_t usage, std::string requestorName) = 0;
87 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
88 sp<IGraphicBufferConsumer>* outConsumer,
89 bool consumerIsSurfaceFlinger) = 0;
Lloyd Piquee300b312019-10-03 13:03:45 -070090 virtual sp<IGraphicBufferProducer> createMonitoredProducer(const sp<IGraphicBufferProducer>&,
91 const sp<SurfaceFlinger>&,
92 const wp<Layer>&) = 0;
93 virtual sp<BufferLayerConsumer> createBufferLayerConsumer(const sp<IGraphicBufferConsumer>&,
94 renderengine::RenderEngine&,
95 uint32_t tex, Layer*) = 0;
96
Lloyd Pique90c115d2018-09-18 21:39:42 -070097 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
98 const sp<IGraphicBufferProducer>&) = 0;
99
Lloyd Pique70d91362018-10-18 16:02:55 -0700100 virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
101
Lloyd Pique90c115d2018-09-18 21:39:42 -0700102 virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
103 virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
104 virtual sp<ColorLayer> createColorLayer(const LayerCreationArgs& args) = 0;
105 virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
106
107protected:
108 ~Factory() = default;
109};
110
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -0700111ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
112
113} // namespace surfaceflinger
114} // namespace android