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