| 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 | 3d367c8 | 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" | 
|  | 40 | #include "Scheduler/DispSync.h" | 
|  | 41 | #include "Scheduler/EventControlThread.h" | 
|  | 42 | #include "Scheduler/MessageQueue.h" | 
|  | 43 | #include "Scheduler/PhaseOffsets.h" | 
|  | 44 | #include "Scheduler/Scheduler.h" | 
|  | 45 |  | 
|  | 46 | namespace android::surfaceflinger { | 
|  | 47 |  | 
|  | 48 | DefaultFactory::~DefaultFactory() = default; | 
|  | 49 |  | 
|  | 50 | std::unique_ptr<DispSync> DefaultFactory::createDispSync(const char* name, bool hasSyncFramework) { | 
|  | 51 | return std::make_unique<android::impl::DispSync>(name, hasSyncFramework); | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | std::unique_ptr<EventControlThread> DefaultFactory::createEventControlThread( | 
|  | 55 | SetVSyncEnabled setVSyncEnabled) { | 
|  | 56 | return std::make_unique<android::impl::EventControlThread>(std::move(setVSyncEnabled)); | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) { | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 60 | return std::make_unique<android::impl::HWComposer>(serviceName); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 61 | } | 
|  | 62 |  | 
|  | 63 | std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() { | 
|  | 64 | return std::make_unique<android::impl::MessageQueue>(); | 
|  | 65 | } | 
|  | 66 |  | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 67 | std::unique_ptr<scheduler::PhaseConfiguration> DefaultFactory::createPhaseConfiguration( | 
|  | 68 | const scheduler::RefreshRateConfigs& refreshRateConfigs) { | 
|  | 69 | if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) { | 
|  | 70 | return std::make_unique<scheduler::impl::PhaseDurations>(refreshRateConfigs); | 
|  | 71 | } else { | 
|  | 72 | return std::make_unique<scheduler::impl::PhaseOffsets>(refreshRateConfigs); | 
|  | 73 | } | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 74 | } | 
|  | 75 |  | 
|  | 76 | std::unique_ptr<Scheduler> DefaultFactory::createScheduler( | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 77 | SetVSyncEnabled setVSyncEnabled, const scheduler::RefreshRateConfigs& configs, | 
|  | 78 | ISchedulerCallback& schedulerCallback) { | 
| Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 79 | return std::make_unique<Scheduler>(std::move(setVSyncEnabled), configs, schedulerCallback, | 
| Ana Krulec | 3d367c8 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 80 | property_get_bool("debug.sf.use_content_detection_v2", true), | 
|  | 81 | sysprop::use_content_detection_for_refresh_rate(false)); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 82 | } | 
|  | 83 |  | 
|  | 84 | std::unique_ptr<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor( | 
|  | 85 | SurfaceFlinger* flinger) { | 
|  | 86 | return std::make_unique<android::impl::SurfaceInterceptor>(flinger); | 
|  | 87 | } | 
|  | 88 |  | 
|  | 89 | sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread( | 
|  | 90 | bool timestampPropertyValue) { | 
|  | 91 | return new StartPropertySetThread(timestampPropertyValue); | 
|  | 92 | } | 
|  | 93 |  | 
| Lloyd Pique | aad4ebf | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 94 | sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) { | 
|  | 95 | return new DisplayDevice(creationArgs); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 96 | } | 
|  | 97 |  | 
|  | 98 | sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height, | 
|  | 99 | PixelFormat format, uint32_t layerCount, | 
|  | 100 | uint64_t usage, std::string requestorName) { | 
|  | 101 | return new GraphicBuffer(width, height, format, layerCount, usage, requestorName); | 
|  | 102 | } | 
|  | 103 |  | 
|  | 104 | void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer, | 
|  | 105 | sp<IGraphicBufferConsumer>* outConsumer, | 
|  | 106 | bool consumerIsSurfaceFlinger) { | 
|  | 107 | BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger); | 
|  | 108 | } | 
|  | 109 |  | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 110 | sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer( | 
|  | 111 | const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger, | 
|  | 112 | const wp<Layer>& layer) { | 
|  | 113 | return new MonitoredProducer(producer, flinger, layer); | 
|  | 114 | } | 
|  | 115 |  | 
|  | 116 | sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer( | 
|  | 117 | const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine, | 
|  | 118 | uint32_t textureName, Layer* layer) { | 
|  | 119 | return new BufferLayerConsumer(consumer, renderEngine, textureName, layer); | 
|  | 120 | } | 
|  | 121 |  | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 122 | std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface( | 
|  | 123 | const sp<IGraphicBufferProducer>& producer) { | 
|  | 124 | return surfaceflinger::impl::createNativeWindowSurface(producer); | 
|  | 125 | } | 
|  | 126 |  | 
|  | 127 | std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() { | 
|  | 128 | return compositionengine::impl::createCompositionEngine(); | 
|  | 129 | } | 
|  | 130 |  | 
|  | 131 | sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) { | 
|  | 132 | return new ContainerLayer(args); | 
|  | 133 | } | 
|  | 134 |  | 
|  | 135 | sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) { | 
|  | 136 | return new BufferQueueLayer(args); | 
|  | 137 | } | 
|  | 138 |  | 
|  | 139 | sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) { | 
|  | 140 | return new BufferStateLayer(args); | 
|  | 141 | } | 
|  | 142 |  | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 143 | sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) { | 
|  | 144 | return new EffectLayer(args); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 145 | } | 
|  | 146 |  | 
|  | 147 | } // namespace android::surfaceflinger | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 148 |  | 
|  | 149 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 150 | #pragma clang diagnostic pop // ignored "-Wconversion" |