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