blob: 496bbf0349ca5e3c7675f58ac1f0e2bd4a43d1a5 [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
51namespace surfaceflinger {
52
Lloyd Pique90c115d2018-09-18 21:39:42 -070053class NativeWindowSurface;
54
55// The interface that SurfaceFlinger uses to create all of the implementations
56// of each interface.
57class Factory {
58public:
59 virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework,
60 int64_t dispSyncPresentTimeOffset) = 0;
61 virtual std::unique_ptr<EventControlThread> createEventControlThread(
62 std::function<void(bool)> setVSyncEnabled) = 0;
63 virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
64 virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0;
65 virtual std::unique_ptr<Scheduler> createScheduler(std::function<void(bool)> callback) = 0;
66 virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0;
67
68 virtual sp<StartPropertySetThread> createStartPropertySetThread(
69 bool timestampPropertyValue) = 0;
70 virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&&) = 0;
71 virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
72 PixelFormat format, uint32_t layerCount,
73 uint64_t usage, std::string requestorName) = 0;
74 virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
75 sp<IGraphicBufferConsumer>* outConsumer,
76 bool consumerIsSurfaceFlinger) = 0;
77 virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
78 const sp<IGraphicBufferProducer>&) = 0;
79
80 virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
81 virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
82 virtual sp<ColorLayer> createColorLayer(const LayerCreationArgs& args) = 0;
83 virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
84
85protected:
86 ~Factory() = default;
87};
88
Lloyd Piqueea0a5fb2018-09-12 15:04:56 -070089ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
90
91} // namespace surfaceflinger
92} // namespace android