blob: 4f303a37be83b7b7599c55a4f01d4cd3411b30b5 [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;
33class ColorLayer;
34class ContainerLayer;
35class DisplayDevice;
36class DispSync;
37class EventControlThread;
38class GraphicBuffer;
39class HWComposer;
40class IGraphicBufferConsumer;
41class IGraphicBufferProducer;
42class MessageQueue;
43class Scheduler;
44class StartPropertySetThread;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070045class SurfaceFlinger;
Lloyd Pique90c115d2018-09-18 21:39:42 -070046class SurfaceInterceptor;
47
48struct DisplayDeviceCreationArgs;
49struct LayerCreationArgs;
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070050
Lloyd Pique70d91362018-10-18 16:02:55 -070051namespace compositionengine {
52class CompositionEngine;
53} // namespace compositionengine
Ana Krulec757f63a2019-01-25 10:46:18 -080054
55namespace scheduler {
56class PhaseOffsets;
57} // namespace scheduler
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070058namespace surfaceflinger {
59
Lloyd Pique90c115d2018-09-18 21:39:42 -070060class NativeWindowSurface;
61
62// The interface that SurfaceFlinger uses to create all of the implementations
63// of each interface.
64class Factory {
65public:
Dominik Laskowski98041832019-08-01 18:35:59 -070066 using SetVSyncEnabled = std::function<void(bool)>;
67
68 virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework) = 0;
69 virtual std::unique_ptr<EventControlThread> createEventControlThread(SetVSyncEnabled) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070070 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
71 virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0;
Ana Krulec757f63a2019-01-25 10:46:18 -080072 virtual std::unique_ptr<scheduler::PhaseOffsets> createPhaseOffsets() = 0;
Dominik Laskowski98041832019-08-01 18:35:59 -070073 virtual std::unique_ptr<Scheduler> createScheduler(SetVSyncEnabled,
74 const scheduler::RefreshRateConfigs&) = 0;
Lloyd Pique90c115d2018-09-18 21:39:42 -070075 virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0;
76
77 virtual sp<StartPropertySetThread> createStartPropertySetThread(
78 bool timestampPropertyValue) = 0;
79 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&&) = 0;
80 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
81 PixelFormat format, uint32_t layerCount,
82 uint64_t usage, std::string requestorName) = 0;
83 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
84 sp<IGraphicBufferConsumer>* outConsumer,
85 bool consumerIsSurfaceFlinger) = 0;
86 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
87 const sp<IGraphicBufferProducer>&) = 0;
88
Lloyd Pique70d91362018-10-18 16:02:55 -070089 virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
90
Lloyd Pique90c115d2018-09-18 21:39:42 -070091 virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
92 virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
93 virtual sp<ColorLayer> createColorLayer(const LayerCreationArgs& args) = 0;
94 virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
95
96protected:
97 ~Factory() = default;
98};
99
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -0700100ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
101
102} // namespace surfaceflinger
103} // namespace android