Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 1 | /* |
| 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 Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 19 | #include <cinttypes> |
| 20 | #include <functional> |
| 21 | #include <memory> |
| 22 | #include <string> |
| 23 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 24 | #include <cutils/compiler.h> |
| 25 | #include <utils/StrongPointer.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 29 | typedef int32_t PixelFormat; |
| 30 | |
| 31 | class BufferQueueLayer; |
| 32 | class BufferStateLayer; |
| 33 | class ColorLayer; |
| 34 | class ContainerLayer; |
| 35 | class DisplayDevice; |
| 36 | class DispSync; |
| 37 | class EventControlThread; |
| 38 | class GraphicBuffer; |
| 39 | class HWComposer; |
| 40 | class IGraphicBufferConsumer; |
| 41 | class IGraphicBufferProducer; |
| 42 | class MessageQueue; |
| 43 | class Scheduler; |
| 44 | class StartPropertySetThread; |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 45 | class SurfaceFlinger; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 46 | class SurfaceInterceptor; |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame^] | 47 | class TimeStats; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 48 | |
| 49 | struct DisplayDeviceCreationArgs; |
| 50 | struct LayerCreationArgs; |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 51 | |
| 52 | namespace surfaceflinger { |
| 53 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 54 | class NativeWindowSurface; |
| 55 | |
| 56 | // The interface that SurfaceFlinger uses to create all of the implementations |
| 57 | // of each interface. |
| 58 | class Factory { |
| 59 | public: |
| 60 | virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework, |
| 61 | int64_t dispSyncPresentTimeOffset) = 0; |
| 62 | virtual std::unique_ptr<EventControlThread> createEventControlThread( |
| 63 | std::function<void(bool)> setVSyncEnabled) = 0; |
| 64 | virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0; |
| 65 | virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0; |
| 66 | virtual std::unique_ptr<Scheduler> createScheduler(std::function<void(bool)> callback) = 0; |
| 67 | virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0; |
| 68 | |
| 69 | virtual sp<StartPropertySetThread> createStartPropertySetThread( |
| 70 | bool timestampPropertyValue) = 0; |
| 71 | virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&&) = 0; |
| 72 | virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height, |
| 73 | PixelFormat format, uint32_t layerCount, |
| 74 | uint64_t usage, std::string requestorName) = 0; |
| 75 | virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer, |
| 76 | sp<IGraphicBufferConsumer>* outConsumer, |
| 77 | bool consumerIsSurfaceFlinger) = 0; |
| 78 | virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface( |
| 79 | const sp<IGraphicBufferProducer>&) = 0; |
| 80 | |
| 81 | virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0; |
| 82 | virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0; |
| 83 | virtual sp<ColorLayer> createColorLayer(const LayerCreationArgs& args) = 0; |
| 84 | virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0; |
| 85 | |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame^] | 86 | virtual std::unique_ptr<TimeStats> createTimeStats() = 0; |
| 87 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 88 | protected: |
| 89 | ~Factory() = default; |
| 90 | }; |
| 91 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 92 | ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger(); |
| 93 | |
| 94 | } // namespace surfaceflinger |
| 95 | } // namespace android |