blob: 5c96f35ae721fb2b55783dec8afde29ba288ce19 [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"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070037#include "Scheduler/Scheduler.h"
Ady Abrahamc581d3c2020-08-06 17:34:27 -070038#include "Scheduler/VsyncConfiguration.h"
Ady Abraham8cb21882020-08-26 18:22:05 -070039#include "Scheduler/VsyncController.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070040
41namespace android::surfaceflinger {
42
43DefaultFactory::~DefaultFactory() = default;
44
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070045std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080046 return std::make_unique<android::impl::HWComposer>(serviceName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070047}
48
Ady Abraham8287e852020-08-12 14:44:58 -070049std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
Marin Shalamanov526c3382020-12-10 15:22:29 +010050 Fps currentRefreshRate) {
Ady Abraham9e16a482019-12-03 17:19:41 -080051 if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
Marin Shalamanov526c3382020-12-10 15:22:29 +010052 return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080053 } else {
Marin Shalamanov526c3382020-12-10 15:22:29 +010054 return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate);
Ady Abraham9e16a482019-12-03 17:19:41 -080055 }
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070056}
57
Pablo Gamitoc351d6f2020-09-17 15:34:26 +000058sp<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor() {
Ady Abrahamd11bade2022-08-01 16:18:03 -070059 return sp<android::impl::SurfaceInterceptor>::make();
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070060}
61
62sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
63 bool timestampPropertyValue) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070064 return sp<StartPropertySetThread>::make(timestampPropertyValue);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070065}
66
Lloyd Pique9370a482019-10-03 17:58:30 -070067sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070068 return sp<DisplayDevice>::make(creationArgs);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070069}
70
71sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
72 PixelFormat format, uint32_t layerCount,
73 uint64_t usage, std::string requestorName) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070074 return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070075}
76
77void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
78 sp<IGraphicBufferConsumer>* outConsumer,
79 bool consumerIsSurfaceFlinger) {
80 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
81}
82
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070083std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
84 const sp<IGraphicBufferProducer>& producer) {
85 return surfaceflinger::impl::createNativeWindowSurface(producer);
86}
87
88std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
89 return compositionengine::impl::createCompositionEngine();
90}
91
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070092sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070093 return sp<BufferStateLayer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070094}
95
Vishnu Nairfa247b12020-02-11 08:58:26 -080096sp<EffectLayer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
Ady Abrahamd11bade2022-08-01 16:18:03 -070097 return sp<EffectLayer>::make(args);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070098}
99
Adithya Srinivasan2db3c1b2020-11-18 12:43:17 -0800100std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() {
101 return std::make_unique<FrameTracer>();
102}
Adithya Srinivasan01189672020-10-20 14:23:05 -0700103
104std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline(
Adithya Srinivasan9b2ca3e2020-11-10 10:14:17 -0800105 std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) {
106 return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid);
Adithya Srinivasan01189672020-10-20 14:23:05 -0700107}
108
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700109} // namespace android::surfaceflinger
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800110
111// TODO(b/129481165): remove the #pragma below and fix conversion issues
112#pragma clang diagnostic pop // ignored "-Wconversion"