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 | |
Alec Mouri | 717bcb6 | 2020-02-10 17:07:19 -0800 | [diff] [blame] | 19 | #include <cutils/compiler.h> |
| 20 | #include <utils/StrongPointer.h> |
| 21 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 22 | #include <cinttypes> |
| 23 | #include <functional> |
| 24 | #include <memory> |
| 25 | #include <string> |
| 26 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 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; |
Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 33 | class BufferLayerConsumer; |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 34 | class EffectLayer; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 35 | class ContainerLayer; |
| 36 | class DisplayDevice; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 37 | class GraphicBuffer; |
| 38 | class HWComposer; |
| 39 | class IGraphicBufferConsumer; |
| 40 | class IGraphicBufferProducer; |
Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 41 | class Layer; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 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; |
| 47 | |
| 48 | struct DisplayDeviceCreationArgs; |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 49 | struct ISchedulerCallback; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 50 | struct LayerCreationArgs; |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 51 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 52 | namespace compositionengine { |
| 53 | class CompositionEngine; |
| 54 | } // namespace compositionengine |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 55 | |
| 56 | namespace scheduler { |
Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 57 | class VsyncConfiguration; |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame^] | 58 | class VsyncController; |
Lloyd Pique | 10502f5 | 2019-05-17 15:26:56 -0700 | [diff] [blame] | 59 | class RefreshRateConfigs; |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 60 | } // namespace scheduler |
Lloyd Pique | 10502f5 | 2019-05-17 15:26:56 -0700 | [diff] [blame] | 61 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 62 | namespace surfaceflinger { |
| 63 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 64 | class NativeWindowSurface; |
| 65 | |
| 66 | // The interface that SurfaceFlinger uses to create all of the implementations |
| 67 | // of each interface. |
| 68 | class Factory { |
| 69 | public: |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 70 | virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0; |
| 71 | virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0; |
Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 72 | virtual std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration( |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 73 | const scheduler::RefreshRateConfigs&) = 0; |
Dominik Laskowski | 8b01cc0 | 2020-07-14 19:02:41 -0700 | [diff] [blame] | 74 | virtual std::unique_ptr<Scheduler> createScheduler(const scheduler::RefreshRateConfigs&, |
Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 75 | ISchedulerCallback&) = 0; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 76 | virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0; |
| 77 | |
| 78 | virtual sp<StartPropertySetThread> createStartPropertySetThread( |
| 79 | bool timestampPropertyValue) = 0; |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 80 | virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&) = 0; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 81 | virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height, |
| 82 | PixelFormat format, uint32_t layerCount, |
| 83 | uint64_t usage, std::string requestorName) = 0; |
| 84 | virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer, |
| 85 | sp<IGraphicBufferConsumer>* outConsumer, |
| 86 | bool consumerIsSurfaceFlinger) = 0; |
Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 87 | virtual sp<IGraphicBufferProducer> createMonitoredProducer(const sp<IGraphicBufferProducer>&, |
| 88 | const sp<SurfaceFlinger>&, |
| 89 | const wp<Layer>&) = 0; |
| 90 | virtual sp<BufferLayerConsumer> createBufferLayerConsumer(const sp<IGraphicBufferConsumer>&, |
| 91 | renderengine::RenderEngine&, |
| 92 | uint32_t tex, Layer*) = 0; |
| 93 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 94 | virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface( |
| 95 | const sp<IGraphicBufferProducer>&) = 0; |
| 96 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 97 | virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0; |
| 98 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 99 | virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0; |
| 100 | virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0; |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 101 | virtual sp<EffectLayer> createEffectLayer(const LayerCreationArgs& args) = 0; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 102 | virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0; |
| 103 | |
| 104 | protected: |
| 105 | ~Factory() = default; |
| 106 | }; |
| 107 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 108 | ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger(); |
| 109 | |
| 110 | } // namespace surfaceflinger |
| 111 | } // namespace android |