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