blob: d49133d1fc2f9094821042991b5c887312107272 [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"
36#include "SurfaceInterceptor.h"
37
38#include "DisplayHardware/ComposerHal.h"
39#include "Scheduler/DispSync.h"
40#include "Scheduler/EventControlThread.h"
41#include "Scheduler/MessageQueue.h"
42#include "Scheduler/PhaseOffsets.h"
43#include "Scheduler/Scheduler.h"
44
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
53std::unique_ptr<EventControlThread> DefaultFactory::createEventControlThread(
54 SetVSyncEnabled setVSyncEnabled) {
55 return std::make_unique<android::impl::EventControlThread>(std::move(setVSyncEnabled));
56}
57
58std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080059 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070060}
61
62std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() {
63 return std::make_unique<android::impl::MessageQueue>();
64}
65
Ady Abraham9e16a482019-12-03 17:19:41 -080066std::unique_ptr<scheduler::PhaseConfiguration> DefaultFactory::createPhaseConfiguration(
67 const scheduler::RefreshRateConfigs& refreshRateConfigs) {
68 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
69 return std::make_unique<scheduler::impl::PhaseDurations>(refreshRateConfigs);
70 } else {
71 return std::make_unique<scheduler::impl::PhaseOffsets>(refreshRateConfigs);
72 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070073}
74
75std::unique_ptr<Scheduler> DefaultFactory::createScheduler(
Ady Abraham3a77a7b2019-12-02 18:46:59 -080076 SetVSyncEnabled setVSyncEnabled, const scheduler::RefreshRateConfigs& configs,
77 ISchedulerCallback& schedulerCallback) {
Ady Abraham8a82ba62020-01-17 12:43:17 -080078 return std::make_unique<Scheduler>(std::move(setVSyncEnabled), configs, schedulerCallback,
79 property_get_bool("debug.sf.use_content_detection_v2",
Ady Abrahamb94d84a2020-02-04 01:40:58 +000080 true));
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070081}
82
83std::unique_ptr<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor(
84 SurfaceFlinger* flinger) {
85 return std::make_unique<android::impl::SurfaceInterceptor>(flinger);
86}
87
88sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
89 bool timestampPropertyValue) {
90 return new StartPropertySetThread(timestampPropertyValue);
91}
92
93sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs&& creationArgs) {
94 return new DisplayDevice(std::move(creationArgs));
95}
96
97sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
98 PixelFormat format, uint32_t layerCount,
99 uint64_t usage, std::string requestorName) {
100 return new GraphicBuffer(width, height, format, layerCount, usage, requestorName);
101}
102
103void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
104 sp<IGraphicBufferConsumer>* outConsumer,
105 bool consumerIsSurfaceFlinger) {
106 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
107}
108
Lloyd Piquee300b312019-10-03 13:03:45 -0700109sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer(
110 const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger,
111 const wp<Layer>& layer) {
112 return new MonitoredProducer(producer, flinger, layer);
113}
114
115sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer(
116 const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine,
117 uint32_t textureName, Layer* layer) {
118 return new BufferLayerConsumer(consumer, renderEngine, textureName, layer);
119}
120
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700121std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
122 const sp<IGraphicBufferProducer>& producer) {
123 return surfaceflinger::impl::createNativeWindowSurface(producer);
124}
125
126std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
127 return compositionengine::impl::createCompositionEngine();
128}
129
130sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) {
131 return new ContainerLayer(args);
132}
133
134sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) {
135 return new BufferQueueLayer(args);
136}
137
138sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
139 return new BufferStateLayer(args);
140}
141
Vishnu Nairfa247b12020-02-11 08:58:26 -0800142sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
143 return new EffectLayer(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700144}
145
146} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800147
148// TODO(b/129481165): remove the #pragma below and fix conversion issues
149#pragma clang diagnostic pop // ignored "-Wconversion"