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