| 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 |  | 
|  | 17 | #include <compositionengine/impl/CompositionEngine.h> | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 18 | #include <cutils/properties.h> | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 19 | #include <ui/GraphicBuffer.h> | 
|  | 20 |  | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 21 | #include "BufferLayerConsumer.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 22 | #include "BufferQueueLayer.h" | 
|  | 23 | #include "BufferStateLayer.h" | 
|  | 24 | #include "ColorLayer.h" | 
|  | 25 | #include "ContainerLayer.h" | 
|  | 26 | #include "DisplayDevice.h" | 
|  | 27 | #include "Layer.h" | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 28 | #include "MonitoredProducer.h" | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 29 | #include "NativeWindowSurface.h" | 
|  | 30 | #include "StartPropertySetThread.h" | 
|  | 31 | #include "SurfaceFlingerDefaultFactory.h" | 
|  | 32 | #include "SurfaceInterceptor.h" | 
|  | 33 |  | 
|  | 34 | #include "DisplayHardware/ComposerHal.h" | 
|  | 35 | #include "Scheduler/DispSync.h" | 
|  | 36 | #include "Scheduler/EventControlThread.h" | 
|  | 37 | #include "Scheduler/MessageQueue.h" | 
|  | 38 | #include "Scheduler/PhaseOffsets.h" | 
|  | 39 | #include "Scheduler/Scheduler.h" | 
|  | 40 |  | 
|  | 41 | namespace android::surfaceflinger { | 
|  | 42 |  | 
|  | 43 | DefaultFactory::~DefaultFactory() = default; | 
|  | 44 |  | 
|  | 45 | std::unique_ptr<DispSync> DefaultFactory::createDispSync(const char* name, bool hasSyncFramework) { | 
|  | 46 | return std::make_unique<android::impl::DispSync>(name, hasSyncFramework); | 
|  | 47 | } | 
|  | 48 |  | 
|  | 49 | std::unique_ptr<EventControlThread> DefaultFactory::createEventControlThread( | 
|  | 50 | SetVSyncEnabled setVSyncEnabled) { | 
|  | 51 | return std::make_unique<android::impl::EventControlThread>(std::move(setVSyncEnabled)); | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) { | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 55 | return std::make_unique<android::impl::HWComposer>(serviceName); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 56 | } | 
|  | 57 |  | 
|  | 58 | std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() { | 
|  | 59 | return std::make_unique<android::impl::MessageQueue>(); | 
|  | 60 | } | 
|  | 61 |  | 
| Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 62 | std::unique_ptr<scheduler::PhaseConfiguration> DefaultFactory::createPhaseConfiguration( | 
|  | 63 | const scheduler::RefreshRateConfigs& refreshRateConfigs) { | 
|  | 64 | if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) { | 
|  | 65 | return std::make_unique<scheduler::impl::PhaseDurations>(refreshRateConfigs); | 
|  | 66 | } else { | 
|  | 67 | return std::make_unique<scheduler::impl::PhaseOffsets>(refreshRateConfigs); | 
|  | 68 | } | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 69 | } | 
|  | 70 |  | 
|  | 71 | std::unique_ptr<Scheduler> DefaultFactory::createScheduler( | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 72 | SetVSyncEnabled setVSyncEnabled, const scheduler::RefreshRateConfigs& configs, | 
|  | 73 | ISchedulerCallback& schedulerCallback) { | 
|  | 74 | return std::make_unique<Scheduler>(std::move(setVSyncEnabled), configs, schedulerCallback); | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 75 | } | 
|  | 76 |  | 
|  | 77 | std::unique_ptr<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor( | 
|  | 78 | SurfaceFlinger* flinger) { | 
|  | 79 | return std::make_unique<android::impl::SurfaceInterceptor>(flinger); | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread( | 
|  | 83 | bool timestampPropertyValue) { | 
|  | 84 | return new StartPropertySetThread(timestampPropertyValue); | 
|  | 85 | } | 
|  | 86 |  | 
|  | 87 | sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs&& creationArgs) { | 
|  | 88 | return new DisplayDevice(std::move(creationArgs)); | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height, | 
|  | 92 | PixelFormat format, uint32_t layerCount, | 
|  | 93 | uint64_t usage, std::string requestorName) { | 
|  | 94 | return new GraphicBuffer(width, height, format, layerCount, usage, requestorName); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer, | 
|  | 98 | sp<IGraphicBufferConsumer>* outConsumer, | 
|  | 99 | bool consumerIsSurfaceFlinger) { | 
|  | 100 | BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger); | 
|  | 101 | } | 
|  | 102 |  | 
| Lloyd Pique | e300b31 | 2019-10-03 13:03:45 -0700 | [diff] [blame] | 103 | sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer( | 
|  | 104 | const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger, | 
|  | 105 | const wp<Layer>& layer) { | 
|  | 106 | return new MonitoredProducer(producer, flinger, layer); | 
|  | 107 | } | 
|  | 108 |  | 
|  | 109 | sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer( | 
|  | 110 | const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine, | 
|  | 111 | uint32_t textureName, Layer* layer) { | 
|  | 112 | return new BufferLayerConsumer(consumer, renderEngine, textureName, layer); | 
|  | 113 | } | 
|  | 114 |  | 
| Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 115 | std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface( | 
|  | 116 | const sp<IGraphicBufferProducer>& producer) { | 
|  | 117 | return surfaceflinger::impl::createNativeWindowSurface(producer); | 
|  | 118 | } | 
|  | 119 |  | 
|  | 120 | std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() { | 
|  | 121 | return compositionengine::impl::createCompositionEngine(); | 
|  | 122 | } | 
|  | 123 |  | 
|  | 124 | sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) { | 
|  | 125 | return new ContainerLayer(args); | 
|  | 126 | } | 
|  | 127 |  | 
|  | 128 | sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) { | 
|  | 129 | return new BufferQueueLayer(args); | 
|  | 130 | } | 
|  | 131 |  | 
|  | 132 | sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) { | 
|  | 133 | return new BufferStateLayer(args); | 
|  | 134 | } | 
|  | 135 |  | 
|  | 136 | sp<ColorLayer> DefaultFactory::createColorLayer(const LayerCreationArgs& args) { | 
|  | 137 | return new ColorLayer(args); | 
|  | 138 | } | 
|  | 139 |  | 
|  | 140 | } // namespace android::surfaceflinger |