Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 1 | /* |
| 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 Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 18 | #pragma clang diagnostic push |
| 19 | #pragma clang diagnostic ignored "-Wconversion" |
| 20 | |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 21 | #include <compositionengine/impl/CompositionEngine.h> |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 22 | #include <cutils/properties.h> |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 23 | #include <ui/GraphicBuffer.h> |
| 24 | |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 25 | #include "DisplayDevice.h" |
Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 26 | #include "FrameTracer/FrameTracer.h" |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 27 | #include "Layer.h" |
| 28 | #include "NativeWindowSurface.h" |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 29 | #include "SurfaceFlingerDefaultFactory.h" |
Ana Krulec | 8dc3dd2 | 2020-02-25 15:02:01 -0800 | [diff] [blame] | 30 | #include "SurfaceFlingerProperties.h" |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 31 | |
| 32 | #include "DisplayHardware/ComposerHal.h" |
Patrick Williams | bb25f80 | 2022-08-30 23:02:34 +0000 | [diff] [blame] | 33 | #include "FrameTimeline/FrameTimeline.h" |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 34 | #include "Scheduler/Scheduler.h" |
Ady Abraham | c581d3c | 2020-08-06 17:34:27 -0700 | [diff] [blame] | 35 | #include "Scheduler/VsyncConfiguration.h" |
Ady Abraham | 8cb2188 | 2020-08-26 18:22:05 -0700 | [diff] [blame] | 36 | #include "Scheduler/VsyncController.h" |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 37 | |
| 38 | namespace android::surfaceflinger { |
| 39 | |
| 40 | DefaultFactory::~DefaultFactory() = default; |
| 41 | |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 42 | std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) { |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 43 | return std::make_unique<android::impl::HWComposer>(serviceName); |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Ady Abraham | 8287e85 | 2020-08-12 14:44:58 -0700 | [diff] [blame] | 46 | std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration( |
Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 47 | Fps currentRefreshRate) { |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 48 | if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) { |
Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 49 | return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate); |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 50 | } else { |
Marin Shalamanov | 526c338 | 2020-12-10 15:22:29 +0100 | [diff] [blame] | 51 | return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate); |
Ady Abraham | 9e16a48 | 2019-12-03 17:19:41 -0800 | [diff] [blame] | 52 | } |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Lloyd Pique | 9370a48 | 2019-10-03 17:58:30 -0700 | [diff] [blame] | 55 | sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) { |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 56 | return sp<DisplayDevice>::make(creationArgs); |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height, |
| 60 | PixelFormat format, uint32_t layerCount, |
| 61 | uint64_t usage, std::string requestorName) { |
Ady Abraham | d11bade | 2022-08-01 16:18:03 -0700 | [diff] [blame] | 62 | return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName); |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer, |
| 66 | sp<IGraphicBufferConsumer>* outConsumer, |
| 67 | bool consumerIsSurfaceFlinger) { |
| 68 | BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger); |
| 69 | } |
| 70 | |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 71 | std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface( |
| 72 | const sp<IGraphicBufferProducer>& producer) { |
| 73 | return surfaceflinger::impl::createNativeWindowSurface(producer); |
| 74 | } |
| 75 | |
| 76 | std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() { |
| 77 | return compositionengine::impl::createCompositionEngine(); |
| 78 | } |
| 79 | |
Patrick Williams | 83f36b2 | 2022-09-14 17:57:35 +0000 | [diff] [blame] | 80 | sp<Layer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) { |
| 81 | return sp<Layer>::make(args); |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 82 | } |
| 83 | |
Patrick Williams | 46b61b9 | 2022-09-01 17:25:49 +0000 | [diff] [blame] | 84 | sp<Layer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) { |
| 85 | return sp<Layer>::make(args); |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Lloyd Pique | 70ddc67 | 2024-04-30 18:20:40 -0700 | [diff] [blame] | 88 | sp<LayerFE> DefaultFactory::createLayerFE(const std::string& layerName, const Layer* /* owner */) { |
Vishnu Nair | e14c6b3 | 2022-08-06 04:20:15 +0000 | [diff] [blame] | 89 | return sp<LayerFE>::make(layerName); |
| 90 | } |
| 91 | |
Adithya Srinivasan | 2db3c1b | 2020-11-18 12:43:17 -0800 | [diff] [blame] | 92 | std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() { |
| 93 | return std::make_unique<FrameTracer>(); |
| 94 | } |
Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 95 | |
| 96 | std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline( |
Adithya Srinivasan | 9b2ca3e | 2020-11-10 10:14:17 -0800 | [diff] [blame] | 97 | std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) { |
| 98 | return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid); |
Adithya Srinivasan | 0118967 | 2020-10-20 14:23:05 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Lloyd Pique | 24f3bfe | 2019-10-02 19:29:10 -0700 | [diff] [blame] | 101 | } // namespace android::surfaceflinger |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 102 | |
| 103 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 104 | #pragma clang diagnostic pop // ignored "-Wconversion" |