blob: 54ce60e950fa143b601771d2222964adb2bcda6d [file] [log] [blame]
Lloyd Pique24f3bfe2019-10-02 19:29:10 -07001/*
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 Abrahamb0dbdaa2020-01-06 16:19:42 -080017// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
20
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070021#include <compositionengine/impl/CompositionEngine.h>
Ady Abraham9e16a482019-12-03 17:19:41 -080022#include <cutils/properties.h>
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070023#include <ui/GraphicBuffer.h>
24
Lloyd Piquee300b312019-10-03 13:03:45 -070025#include "BufferLayerConsumer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070026#include "BufferQueueLayer.h"
27#include "BufferStateLayer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070028#include "ContainerLayer.h"
29#include "DisplayDevice.h"
Vishnu Nairfa247b12020-02-11 08:58:26 -080030#include "EffectLayer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070031#include "Layer.h"
Lloyd Piquee300b312019-10-03 13:03:45 -070032#include "MonitoredProducer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070033#include "NativeWindowSurface.h"
34#include "StartPropertySetThread.h"
35#include "SurfaceFlingerDefaultFactory.h"
Ana Krulec8dc3dd22020-02-25 15:02:01 -080036#include "SurfaceFlingerProperties.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070037#include "SurfaceInterceptor.h"
38
39#include "DisplayHardware/ComposerHal.h"
40#include "Scheduler/DispSync.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070041#include "Scheduler/MessageQueue.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070042#include "Scheduler/Scheduler.h"
Ady Abrahamc581d3c2020-08-06 17:34:27 -070043#include "Scheduler/VsyncConfiguration.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070044
45namespace android::surfaceflinger {
46
47DefaultFactory::~DefaultFactory() = default;
48
49std::unique_ptr<DispSync> DefaultFactory::createDispSync(const char* name, bool hasSyncFramework) {
50 return std::make_unique<android::impl::DispSync>(name, hasSyncFramework);
51}
52
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070053std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080054 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070055}
56
57std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() {
58 return std::make_unique<android::impl::MessageQueue>();
59}
60
Ady Abraham8287e852020-08-12 14:44:58 -070061std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
Ady Abraham9e16a482019-12-03 17:19:41 -080062 const scheduler::RefreshRateConfigs& refreshRateConfigs) {
63 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
Ady Abraham8287e852020-08-12 14:44:58 -070064 return std::make_unique<scheduler::impl::WorkDuration>(refreshRateConfigs);
Ady Abraham9e16a482019-12-03 17:19:41 -080065 } else {
66 return std::make_unique<scheduler::impl::PhaseOffsets>(refreshRateConfigs);
67 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070068}
69
70std::unique_ptr<Scheduler> DefaultFactory::createScheduler(
Dominik Laskowski8b01cc02020-07-14 19:02:41 -070071 const scheduler::RefreshRateConfigs& configs, ISchedulerCallback& callback) {
72 return std::make_unique<Scheduler>(configs, callback);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070073}
74
75std::unique_ptr<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor(
76 SurfaceFlinger* flinger) {
77 return std::make_unique<android::impl::SurfaceInterceptor>(flinger);
78}
79
80sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
81 bool timestampPropertyValue) {
82 return new StartPropertySetThread(timestampPropertyValue);
83}
84
Lloyd Pique9370a482019-10-03 17:58:30 -070085sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
86 return new DisplayDevice(creationArgs);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070087}
88
89sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
90 PixelFormat format, uint32_t layerCount,
91 uint64_t usage, std::string requestorName) {
92 return new GraphicBuffer(width, height, format, layerCount, usage, requestorName);
93}
94
95void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
96 sp<IGraphicBufferConsumer>* outConsumer,
97 bool consumerIsSurfaceFlinger) {
98 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
99}
100
Lloyd Piquee300b312019-10-03 13:03:45 -0700101sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer(
102 const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger,
103 const wp<Layer>& layer) {
104 return new MonitoredProducer(producer, flinger, layer);
105}
106
107sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer(
108 const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine,
109 uint32_t textureName, Layer* layer) {
110 return new BufferLayerConsumer(consumer, renderEngine, textureName, layer);
111}
112
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700113std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
114 const sp<IGraphicBufferProducer>& producer) {
115 return surfaceflinger::impl::createNativeWindowSurface(producer);
116}
117
118std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
119 return compositionengine::impl::createCompositionEngine();
120}
121
122sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) {
123 return new ContainerLayer(args);
124}
125
126sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) {
127 return new BufferQueueLayer(args);
128}
129
130sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
131 return new BufferStateLayer(args);
132}
133
Vishnu Nairfa247b12020-02-11 08:58:26 -0800134sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
135 return new EffectLayer(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700136}
137
138} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800139
140// TODO(b/129481165): remove the #pragma below and fix conversion issues
141#pragma clang diagnostic pop // ignored "-Wconversion"