blob: 15a791e4d672ee77b8dcbe976c97e36f9af5e9eb [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 "BufferStateLayer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070026#include "DisplayDevice.h"
Vishnu Nairfa247b12020-02-11 08:58:26 -080027#include "EffectLayer.h"
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080028#include "FrameTracer/FrameTracer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070029#include "Layer.h"
30#include "NativeWindowSurface.h"
31#include "StartPropertySetThread.h"
32#include "SurfaceFlingerDefaultFactory.h"
Ana Krulec8dc3dd22020-02-25 15:02:01 -080033#include "SurfaceFlingerProperties.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070034#include "SurfaceInterceptor.h"
35
36#include "DisplayHardware/ComposerHal.h"
Patrick Williamsbb25f802022-08-30 23:02:34 +000037#include "FrameTimeline/FrameTimeline.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070038#include "Scheduler/Scheduler.h"
Ady Abrahamc581d3c2020-08-06 17:34:27 -070039#include "Scheduler/VsyncConfiguration.h"
Ady Abraham8cb21882020-08-26 18:22:05 -070040#include "Scheduler/VsyncController.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070041
42namespace android::surfaceflinger {
43
44DefaultFactory::~DefaultFactory() = default;
45
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070046std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080047 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070048}
49
Ady Abraham8287e852020-08-12 14:44:58 -070050std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010051 Fps currentRefreshRate) {
Ady Abraham9e16a482019-12-03 17:19:41 -080052 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
Marin Shalamanov526c3382020-12-10 15:22:29 +010053 return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080054 } else {
Marin Shalamanov526c3382020-12-10 15:22:29 +010055 return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080056 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070057}
58
Pablo Gamitoc351d6f2020-09-17 15:34:26 +000059sp<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor() {
Ady Abrahamd11bade2022-08-01 16:18:03 -070060 return sp<android::impl::SurfaceInterceptor>::make();
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070061}
62
63sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
64 bool timestampPropertyValue) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070065 return sp<StartPropertySetThread>::make(timestampPropertyValue);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070066}
67
Lloyd Pique9370a482019-10-03 17:58:30 -070068sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070069 return sp<DisplayDevice>::make(creationArgs);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070070}
71
72sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
73 PixelFormat format, uint32_t layerCount,
74 uint64_t usage, std::string requestorName) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070075 return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070076}
77
78void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
79 sp<IGraphicBufferConsumer>* outConsumer,
80 bool consumerIsSurfaceFlinger) {
81 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
82}
83
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070084std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
85 const sp<IGraphicBufferProducer>& producer) {
86 return surfaceflinger::impl::createNativeWindowSurface(producer);
87}
88
89std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
90 return compositionengine::impl::createCompositionEngine();
91}
92
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070093sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070094 return sp<BufferStateLayer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070095}
96
Vishnu Nairfa247b12020-02-11 08:58:26 -080097sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070098 return sp<EffectLayer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070099}
100
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -0800101std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() {
102 return std::make_unique<FrameTracer>();
103}
Adithya Srinivasan01189672020-10-20 14:23:05 -0700104
105std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -0800106 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) {
107 return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid);
Adithya Srinivasan01189672020-10-20 14:23:05 -0700108}
109
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700110} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800111
112// TODO(b/129481165): remove the #pragma below and fix conversion issues
113#pragma clang diagnostic pop // ignored "-Wconversion"