blob: b1d8ba9a2f8ba7338745ce1ad3dd9223f5164c63 [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"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070029#include "SurfaceFlingerDefaultFactory.h"
Ana Krulec8dc3dd22020-02-25 15:02:01 -080030#include "SurfaceFlingerProperties.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070031
32#include "DisplayHardware/ComposerHal.h"
Patrick Williamsbb25f802022-08-30 23:02:34 +000033#include "FrameTimeline/FrameTimeline.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070034#include "Scheduler/Scheduler.h"
Ady Abrahamc581d3c2020-08-06 17:34:27 -070035#include "Scheduler/VsyncConfiguration.h"
Ady Abraham8cb21882020-08-26 18:22:05 -070036#include "Scheduler/VsyncController.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070037
38namespace android::surfaceflinger {
39
40DefaultFactory::~DefaultFactory() = default;
41
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070042std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080043 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070044}
45
Ady Abraham8287e852020-08-12 14:44:58 -070046std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010047 Fps currentRefreshRate) {
Ady Abraham9e16a482019-12-03 17:19:41 -080048 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
Marin Shalamanov526c3382020-12-10 15:22:29 +010049 return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080050 } else {
Marin Shalamanov526c3382020-12-10 15:22:29 +010051 return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080052 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070053}
54
Lloyd Pique9370a482019-10-03 17:58:30 -070055sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070056 return sp<DisplayDevice>::make(creationArgs);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070057}
58
59sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
60 PixelFormat format, uint32_t layerCount,
61 uint64_t usage, std::string requestorName) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070062 return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070063}
64
65void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
66 sp<IGraphicBufferConsumer>* outConsumer,
67 bool consumerIsSurfaceFlinger) {
68 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
69}
70
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070071std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
72 const sp<IGraphicBufferProducer>& producer) {
73 return surfaceflinger::impl::createNativeWindowSurface(producer);
74}
75
76std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
77 return compositionengine::impl::createCompositionEngine();
78}
79
Patrick Williams83f36b22022-09-14 17:57:35 +000080sp<Layer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
81 return sp<Layer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070082}
83
Patrick Williams46b61b92022-09-01 17:25:49 +000084sp<Layer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
85 return sp<Layer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070086}
87
Lloyd Pique70ddc672024-04-30 18:20:40 -070088sp<LayerFE> DefaultFactory::createLayerFE(const std::string& layerName, const Layer* /* owner */) {
Vishnu Naire14c6b32022-08-06 04:20:15 +000089 return sp<LayerFE>::make(layerName);
90}
91
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -080092std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() {
93 return std::make_unique<FrameTracer>();
94}
Adithya Srinivasan01189672020-10-20 14:23:05 -070095
96std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -080097 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) {
98 return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid);
Adithya Srinivasan01189672020-10-20 14:23:05 -070099}
100
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700101} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800102
103// TODO(b/129481165): remove the #pragma below and fix conversion issues
104#pragma clang diagnostic pop // ignored "-Wconversion"