| 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; | 
 | 37 | class DispSync; | 
 | 38 | class EventControlThread; | 
 | 39 | class GraphicBuffer; | 
 | 40 | class HWComposer; | 
 | 41 | class IGraphicBufferConsumer; | 
 | 42 | class IGraphicBufferProducer; | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 43 | class ISchedulerCallback; | 
| 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; | 
 | 50 |  | 
 | 51 | struct DisplayDeviceCreationArgs; | 
 | 52 | struct LayerCreationArgs; | 
| Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 53 |  | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 54 | namespace compositionengine { | 
 | 55 | class CompositionEngine; | 
 | 56 | } // namespace compositionengine | 
| Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 57 |  | 
 | 58 | namespace scheduler { | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 59 | class PhaseConfiguration; | 
| Lloyd Pique | 10502f5 | 2019-05-17 15:26:56 -0700 | [diff] [blame] | 60 | class RefreshRateConfigs; | 
| Ana Krulec | 757f63a | 2019-01-25 10:46:18 -0800 | [diff] [blame] | 61 | } // namespace scheduler | 
| Lloyd Pique | 10502f5 | 2019-05-17 15:26:56 -0700 | [diff] [blame] | 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: | 
| Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 71 |     using SetVSyncEnabled = std::function<void(bool)>; | 
 | 72 |  | 
 | 73 |     virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework) = 0; | 
 | 74 |     virtual std::unique_ptr<EventControlThread> createEventControlThread(SetVSyncEnabled) = 0; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 75 |     virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0; | 
 | 76 |     virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0; | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 77 |     virtual std::unique_ptr<scheduler::PhaseConfiguration> createPhaseConfiguration( | 
 | 78 |             const scheduler::RefreshRateConfigs&) = 0; | 
| Dominik Laskowski | 9804183 | 2019-08-01 18:35:59 -0700 | [diff] [blame] | 79 |     virtual std::unique_ptr<Scheduler> createScheduler(SetVSyncEnabled, | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 80 |                                                        const scheduler::RefreshRateConfigs&, | 
 | 81 |                                                        ISchedulerCallback&) = 0; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 82 |     virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0; | 
 | 83 |  | 
 | 84 |     virtual sp<StartPropertySetThread> createStartPropertySetThread( | 
 | 85 |             bool timestampPropertyValue) = 0; | 
| Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 86 |     virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&) = 0; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 87 |     virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height, | 
 | 88 |                                                   PixelFormat format, uint32_t layerCount, | 
 | 89 |                                                   uint64_t usage, std::string requestorName) = 0; | 
 | 90 |     virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer, | 
 | 91 |                                    sp<IGraphicBufferConsumer>* outConsumer, | 
 | 92 |                                    bool consumerIsSurfaceFlinger) = 0; | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 93 |     virtual sp<IGraphicBufferProducer> createMonitoredProducer(const sp<IGraphicBufferProducer>&, | 
 | 94 |                                                                const sp<SurfaceFlinger>&, | 
 | 95 |                                                                const wp<Layer>&) = 0; | 
 | 96 |     virtual sp<BufferLayerConsumer> createBufferLayerConsumer(const sp<IGraphicBufferConsumer>&, | 
 | 97 |                                                               renderengine::RenderEngine&, | 
 | 98 |                                                               uint32_t tex, Layer*) = 0; | 
 | 99 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 100 |     virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface( | 
 | 101 |             const sp<IGraphicBufferProducer>&) = 0; | 
 | 102 |  | 
| Lloyd Pique | 70d9136 | 2018-10-18 16:02:55 -0700 | [diff] [blame] | 103 |     virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0; | 
 | 104 |  | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 105 |     virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0; | 
 | 106 |     virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0; | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 107 |     virtual sp<EffectLayer> createEffectLayer(const LayerCreationArgs& args) = 0; | 
| Lloyd Pique | 90c115d | 2018-09-18 21:39:42 -0700 | [diff] [blame] | 108 |     virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0; | 
 | 109 |  | 
 | 110 | protected: | 
 | 111 |     ~Factory() = default; | 
 | 112 | }; | 
 | 113 |  | 
| Lloyd Pique | ea0a5fb | 2018-09-12 15:04:56 -0700 | [diff] [blame] | 114 | ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger(); | 
 | 115 |  | 
 | 116 | } // namespace surfaceflinger | 
 | 117 | } // namespace android |