| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 2019 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 |  | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 18 | #pragma clang diagnostic push | 
|  | 19 | #pragma clang diagnostic ignored "-Wconversion" | 
|  | 20 |  | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 21 | #include <compositionengine/impl/CompositionEngine.h> | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 22 | #include <cutils/properties.h> | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 23 | #include <ui/GraphicBuffer.h> | 
|  | 24 |  | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 25 | #include "BufferLayerConsumer.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 26 | #include "BufferQueueLayer.h" | 
|  | 27 | #include "BufferStateLayer.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 28 | #include "ContainerLayer.h" | 
|  | 29 | #include "DisplayDevice.h" | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 30 | #include "EffectLayer.h" | 
| Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 31 | #include "FrameTracer/FrameTracer.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 32 | #include "Layer.h" | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 33 | #include "MonitoredProducer.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 34 | #include "NativeWindowSurface.h" | 
|  | 35 | #include "StartPropertySetThread.h" | 
|  | 36 | #include "SurfaceFlingerDefaultFactory.h" | 
| Ana Krulec | 8dc3dd2 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 37 | #include "SurfaceFlingerProperties.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 38 | #include "SurfaceInterceptor.h" | 
|  | 39 |  | 
|  | 40 | #include "DisplayHardware/ComposerHal.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 41 | #include "Scheduler/MessageQueue.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 42 | #include "Scheduler/Scheduler.h" | 
| Ady Abraham | c581d3c | 2020-08-06 17:34:27 -0700 | [diff] [blame] | 43 | #include "Scheduler/VsyncConfiguration.h" | 
| Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 44 | #include "Scheduler/VsyncController.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 45 |  | 
|  | 46 | namespace android::surfaceflinger { | 
|  | 47 |  | 
|  | 48 | DefaultFactory::~DefaultFactory() = default; | 
|  | 49 |  | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 50 | std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) { | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 51 | return std::make_unique<android::impl::HWComposer>(serviceName); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 52 | } | 
|  | 53 |  | 
|  | 54 | std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() { | 
|  | 55 | return std::make_unique<android::impl::MessageQueue>(); | 
|  | 56 | } | 
|  | 57 |  | 
| Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 58 | std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration( | 
| Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 59 | Fps currentRefreshRate) { | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 60 | if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) { | 
| Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 61 | return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate); | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 62 | } else { | 
| Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 63 | return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate); | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 64 | } | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 65 | } | 
|  | 66 |  | 
|  | 67 | std::unique_ptr<Scheduler> DefaultFactory::createScheduler( | 
| Ady Abraham | 3efa394 | 2021-06-24 19:01:25 -0700 | [diff] [blame] | 68 | const std::shared_ptr<scheduler::RefreshRateConfigs>& refreshRateConfigs, | 
|  | 69 | ISchedulerCallback& callback) { | 
|  | 70 | return std::make_unique<Scheduler>(std::move(refreshRateConfigs), callback); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 71 | } | 
|  | 72 |  | 
| Pablo Gamito | c351d6f | 2020-09-17 15:34:26 +0000 | [diff] [blame] | 73 | sp<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor() { | 
|  | 74 | return new android::impl::SurfaceInterceptor(); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 75 | } | 
|  | 76 |  | 
|  | 77 | sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread( | 
|  | 78 | bool timestampPropertyValue) { | 
|  | 79 | return new StartPropertySetThread(timestampPropertyValue); | 
|  | 80 | } | 
|  | 81 |  | 
| Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 82 | sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) { | 
|  | 83 | return new DisplayDevice(creationArgs); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 84 | } | 
|  | 85 |  | 
|  | 86 | sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height, | 
|  | 87 | PixelFormat format, uint32_t layerCount, | 
|  | 88 | uint64_t usage, std::string requestorName) { | 
|  | 89 | return new GraphicBuffer(width, height, format, layerCount, usage, requestorName); | 
|  | 90 | } | 
|  | 91 |  | 
|  | 92 | void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer, | 
|  | 93 | sp<IGraphicBufferConsumer>* outConsumer, | 
|  | 94 | bool consumerIsSurfaceFlinger) { | 
|  | 95 | BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger); | 
|  | 96 | } | 
|  | 97 |  | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 98 | sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer( | 
|  | 99 | const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger, | 
|  | 100 | const wp<Layer>& layer) { | 
|  | 101 | return new MonitoredProducer(producer, flinger, layer); | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer( | 
|  | 105 | const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine, | 
|  | 106 | uint32_t textureName, Layer* layer) { | 
|  | 107 | return new BufferLayerConsumer(consumer, renderEngine, textureName, layer); | 
|  | 108 | } | 
|  | 109 |  | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 110 | std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface( | 
|  | 111 | const sp<IGraphicBufferProducer>& producer) { | 
|  | 112 | return surfaceflinger::impl::createNativeWindowSurface(producer); | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() { | 
|  | 116 | return compositionengine::impl::createCompositionEngine(); | 
|  | 117 | } | 
|  | 118 |  | 
|  | 119 | sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) { | 
|  | 120 | return new ContainerLayer(args); | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) { | 
|  | 124 | return new BufferQueueLayer(args); | 
|  | 125 | } | 
|  | 126 |  | 
|  | 127 | sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) { | 
|  | 128 | return new BufferStateLayer(args); | 
|  | 129 | } | 
|  | 130 |  | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 131 | sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) { | 
|  | 132 | return new EffectLayer(args); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 133 | } | 
|  | 134 |  | 
| Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 135 | std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() { | 
|  | 136 | return std::make_unique<FrameTracer>(); | 
|  | 137 | } | 
| Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 138 |  | 
|  | 139 | std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline( | 
| Adithya Srinivasan | 9b2ca3e | 2020-11-10 10:14:17 -0800 | [diff] [blame] | 140 | std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) { | 
|  | 141 | return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid); | 
| Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 142 | } | 
|  | 143 |  | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 144 | } // namespace android::surfaceflinger | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 145 |  | 
|  | 146 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 147 | #pragma clang diagnostic pop // ignored "-Wconversion" |