blob: 39a5d0fc0567eb7afae5e4b86fe2b4b71af57efc [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 "BufferStateLayer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070027#include "ContainerLayer.h"
28#include "DisplayDevice.h"
Vishnu Nairfa247b12020-02-11 08:58:26 -080029#include "EffectLayer.h"
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080030#include "FrameTracer/FrameTracer.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"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070040#include "Scheduler/Scheduler.h"
Ady Abrahamc581d3c2020-08-06 17:34:27 -070041#include "Scheduler/VsyncConfiguration.h"
Ady Abraham8cb21882020-08-26 18:22:05 -070042#include "Scheduler/VsyncController.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070043
44namespace android::surfaceflinger {
45
46DefaultFactory::~DefaultFactory() = default;
47
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070048std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080049 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070050}
51
Ady Abraham8287e852020-08-12 14:44:58 -070052std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010053 Fps currentRefreshRate) {
Ady Abraham9e16a482019-12-03 17:19:41 -080054 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
Marin Shalamanov526c3382020-12-10 15:22:29 +010055 return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080056 } else {
Marin Shalamanov526c3382020-12-10 15:22:29 +010057 return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080058 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070059}
60
Pablo Gamitoc351d6f2020-09-17 15:34:26 +000061sp<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor() {
62 return new android::impl::SurfaceInterceptor();
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070063}
64
65sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
66 bool timestampPropertyValue) {
67 return new StartPropertySetThread(timestampPropertyValue);
68}
69
Lloyd Pique9370a482019-10-03 17:58:30 -070070sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
71 return new DisplayDevice(creationArgs);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070072}
73
74sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
75 PixelFormat format, uint32_t layerCount,
76 uint64_t usage, std::string requestorName) {
77 return new GraphicBuffer(width, height, format, layerCount, usage, requestorName);
78}
79
80void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
81 sp<IGraphicBufferConsumer>* outConsumer,
82 bool consumerIsSurfaceFlinger) {
83 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
84}
85
Lloyd Piquee300b312019-10-03 13:03:45 -070086sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer(
87 const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger,
88 const wp<Layer>& layer) {
89 return new MonitoredProducer(producer, flinger, layer);
90}
91
92sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer(
93 const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine,
94 uint32_t textureName, Layer* layer) {
95 return new BufferLayerConsumer(consumer, renderEngine, textureName, layer);
96}
97
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070098std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
99 const sp<IGraphicBufferProducer>& producer) {
100 return surfaceflinger::impl::createNativeWindowSurface(producer);
101}
102
103std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
104 return compositionengine::impl::createCompositionEngine();
105}
106
107sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) {
108 return new ContainerLayer(args);
109}
110
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700111sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
112 return new BufferStateLayer(args);
113}
114
Vishnu Nairfa247b12020-02-11 08:58:26 -0800115sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
116 return new EffectLayer(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700117}
118
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -0800119std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() {
120 return std::make_unique<FrameTracer>();
121}
Adithya Srinivasan01189672020-10-20 14:23:05 -0700122
123std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -0800124 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) {
125 return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid);
Adithya Srinivasan01189672020-10-20 14:23:05 -0700126}
127
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700128} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800129
130// TODO(b/129481165): remove the #pragma below and fix conversion issues
131#pragma clang diagnostic pop // ignored "-Wconversion"