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; |
Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 34 | class BufferStateLayer; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 35 | class DisplayDevice; |
Dominik Laskowski | e0e0cde | 2021-07-30 10:42:05 -0700 | [diff] [blame] | 36 | class EffectLayer; |
Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 37 | class FrameTracer; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 38 | class GraphicBuffer; |
| 39 | class HWComposer; |
| 40 | class IGraphicBufferConsumer; |
| 41 | class IGraphicBufferProducer; |
Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 42 | class Layer; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 43 | class StartPropertySetThread; |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 44 | class SurfaceFlinger; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 45 | class SurfaceInterceptor; |
Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 46 | class TimeStats; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 47 | |
| 48 | struct DisplayDeviceCreationArgs; |
| 49 | struct LayerCreationArgs; |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 50 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 51 | namespace compositionengine { |
| 52 | class CompositionEngine; |
| 53 | } // namespace compositionengine |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 54 | |
| 55 | namespace scheduler { |
Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 56 | class VsyncConfiguration; |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 57 | class VsyncController; |
Lloyd Pique | 10502f5 | 2019-05-17 15:26:56 -0700 | [diff] [blame] | 58 | class RefreshRateConfigs; |
Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 59 | } // namespace scheduler |
Lloyd Pique | 10502f5 | 2019-05-17 15:26:56 -0700 | [diff] [blame] | 60 | |
Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 61 | namespace frametimeline { |
| 62 | class FrameTimeline; |
| 63 | } // namespace frametimeline |
| 64 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 65 | namespace surfaceflinger { |
| 66 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 67 | class NativeWindowSurface; |
| 68 | |
| 69 | // The interface that SurfaceFlinger uses to create all of the implementations |
| 70 | // of each interface. |
| 71 | class Factory { |
| 72 | public: |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 73 | virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0; |
Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 74 | virtual std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration( |
Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 75 | Fps currentRefreshRate) = 0; |
Pablo Gamito | c351d6f | 2020-09-17 15:34:26 +0000 | [diff] [blame] | 76 | virtual sp<SurfaceInterceptor> createSurfaceInterceptor() = 0; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 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 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 88 | virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface( |
| 89 | const sp<IGraphicBufferProducer>&) = 0; |
| 90 | |
Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 91 | virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0; |
| 92 | |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 93 | virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0; |
Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 94 | virtual sp<EffectLayer> createEffectLayer(const LayerCreationArgs& args) = 0; |
Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 95 | virtual std::unique_ptr<FrameTracer> createFrameTracer() = 0; |
Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 96 | virtual std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline( |
Adithya Srinivasan | 9b2ca3e | 2020-11-10 10:14:17 -0800 | [diff] [blame] | 97 | std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) = 0; |
Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 98 | |
| 99 | protected: |
| 100 | ~Factory() = default; |
| 101 | }; |
| 102 | |
Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 103 | ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger(); |
| 104 | |
| 105 | } // namespace surfaceflinger |
| 106 | } // namespace android |