blob: 7e6894d3f7fbc9d7b75be450fb26e4001cb651d8 [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 Pique24f3bfe2019-10-02 19:29:10 -070025#include "DisplayDevice.h"
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080026#include "FrameTracer/FrameTracer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070027#include "Layer.h"
28#include "NativeWindowSurface.h"
29#include "StartPropertySetThread.h"
30#include "SurfaceFlingerDefaultFactory.h"
Ana Krulec8dc3dd22020-02-25 15:02:01 -080031#include "SurfaceFlingerProperties.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070032
33#include "DisplayHardware/ComposerHal.h"
Patrick Williamsbb25f802022-08-30 23:02:34 +000034#include "FrameTimeline/FrameTimeline.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070035#include "Scheduler/Scheduler.h"
Ady Abrahamc581d3c2020-08-06 17:34:27 -070036#include "Scheduler/VsyncConfiguration.h"
Ady Abraham8cb21882020-08-26 18:22:05 -070037#include "Scheduler/VsyncController.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070038
39namespace android::surfaceflinger {
40
41DefaultFactory::~DefaultFactory() = default;
42
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070043std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080044 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070045}
46
Ady Abraham8287e852020-08-12 14:44:58 -070047std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010048 Fps currentRefreshRate) {
Ady Abraham9e16a482019-12-03 17:19:41 -080049 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
Marin Shalamanov526c3382020-12-10 15:22:29 +010050 return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080051 } else {
Marin Shalamanov526c3382020-12-10 15:22:29 +010052 return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080053 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070054}
55
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070056sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
57 bool timestampPropertyValue) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070058 return sp<StartPropertySetThread>::make(timestampPropertyValue);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070059}
60
Lloyd Pique9370a482019-10-03 17:58:30 -070061sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070062 return sp<DisplayDevice>::make(creationArgs);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070063}
64
65sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
66 PixelFormat format, uint32_t layerCount,
67 uint64_t usage, std::string requestorName) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070068 return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070069}
70
71void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
72 sp<IGraphicBufferConsumer>* outConsumer,
73 bool consumerIsSurfaceFlinger) {
74 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
75}
76
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070077std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
78 const sp<IGraphicBufferProducer>& producer) {
79 return surfaceflinger::impl::createNativeWindowSurface(producer);
80}
81
82std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
83 return compositionengine::impl::createCompositionEngine();
84}
85
Patrick Williams83f36b22022-09-14 17:57:35 +000086sp<Layer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
87 return sp<Layer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070088}
89
Patrick Williams46b61b92022-09-01 17:25:49 +000090sp<Layer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
91 return sp<Layer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070092}
93
Vishnu Naire14c6b32022-08-06 04:20:15 +000094sp<LayerFE> DefaultFactory::createLayerFE(const std::string& layerName) {
95 return sp<LayerFE>::make(layerName);
96}
97
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080098std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() {
99 return std::make_unique<FrameTracer>();
100}
Adithya Srinivasan01189672020-10-20 14:23:05 -0700101
102std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -0800103 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) {
104 return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid);
Adithya Srinivasan01189672020-10-20 14:23:05 -0700105}
106
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700107} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800108
109// TODO(b/129481165): remove the #pragma below and fix conversion issues
110#pragma clang diagnostic pop // ignored "-Wconversion"