• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 // TODO(b/129481165): remove the #pragma below and fix conversion issues
18 #pragma clang diagnostic push
19 #pragma clang diagnostic ignored "-Wconversion"
20 
21 #include <compositionengine/impl/CompositionEngine.h>
22 #include <cutils/properties.h>
23 #include <ui/GraphicBuffer.h>
24 
25 #include "DisplayDevice.h"
26 #include "FrameTracer/FrameTracer.h"
27 #include "Layer.h"
28 #include "NativeWindowSurface.h"
29 #include "StartPropertySetThread.h"
30 #include "SurfaceFlingerDefaultFactory.h"
31 #include "SurfaceFlingerProperties.h"
32 
33 #include "DisplayHardware/ComposerHal.h"
34 #include "FrameTimeline/FrameTimeline.h"
35 #include "Scheduler/Scheduler.h"
36 #include "Scheduler/VsyncConfiguration.h"
37 #include "Scheduler/VsyncController.h"
38 
39 namespace android::surfaceflinger {
40 
41 DefaultFactory::~DefaultFactory() = default;
42 
createHWComposer(const std::string & serviceName)43 std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
44     return std::make_unique<android::impl::HWComposer>(serviceName);
45 }
46 
createVsyncConfiguration(Fps currentRefreshRate)47 std::unique_ptr<scheduler::VsyncConfiguration> DefaultFactory::createVsyncConfiguration(
48         Fps currentRefreshRate) {
49     if (property_get_bool("debug.sf.use_phase_offsets_as_durations", false)) {
50         return std::make_unique<scheduler::impl::WorkDuration>(currentRefreshRate);
51     } else {
52         return std::make_unique<scheduler::impl::PhaseOffsets>(currentRefreshRate);
53     }
54 }
55 
createStartPropertySetThread(bool timestampPropertyValue)56 sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
57         bool timestampPropertyValue) {
58     return sp<StartPropertySetThread>::make(timestampPropertyValue);
59 }
60 
createDisplayDevice(DisplayDeviceCreationArgs & creationArgs)61 sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs& creationArgs) {
62     return sp<DisplayDevice>::make(creationArgs);
63 }
64 
createGraphicBuffer(uint32_t width,uint32_t height,PixelFormat format,uint32_t layerCount,uint64_t usage,std::string requestorName)65 sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
66                                                       PixelFormat format, uint32_t layerCount,
67                                                       uint64_t usage, std::string requestorName) {
68     return sp<GraphicBuffer>::make(width, height, format, layerCount, usage, requestorName);
69 }
70 
createBufferQueue(sp<IGraphicBufferProducer> * outProducer,sp<IGraphicBufferConsumer> * outConsumer,bool consumerIsSurfaceFlinger)71 void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
72                                        sp<IGraphicBufferConsumer>* outConsumer,
73                                        bool consumerIsSurfaceFlinger) {
74     BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
75 }
76 
createNativeWindowSurface(const sp<IGraphicBufferProducer> & producer)77 std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
78         const sp<IGraphicBufferProducer>& producer) {
79     return surfaceflinger::impl::createNativeWindowSurface(producer);
80 }
81 
createCompositionEngine()82 std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
83     return compositionengine::impl::createCompositionEngine();
84 }
85 
createBufferStateLayer(const LayerCreationArgs & args)86 sp<Layer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
87     return sp<Layer>::make(args);
88 }
89 
createEffectLayer(const LayerCreationArgs & args)90 sp<Layer> DefaultFactory::createEffectLayer(const LayerCreationArgs& args) {
91     return sp<Layer>::make(args);
92 }
93 
createLayerFE(const std::string & layerName)94 sp<LayerFE> DefaultFactory::createLayerFE(const std::string& layerName) {
95     return sp<LayerFE>::make(layerName);
96 }
97 
createFrameTracer()98 std::unique_ptr<FrameTracer> DefaultFactory::createFrameTracer() {
99     return std::make_unique<FrameTracer>();
100 }
101 
createFrameTimeline(std::shared_ptr<TimeStats> timeStats,pid_t surfaceFlingerPid)102 std::unique_ptr<frametimeline::FrameTimeline> DefaultFactory::createFrameTimeline(
103         std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) {
104     return std::make_unique<frametimeline::impl::FrameTimeline>(timeStats, surfaceFlingerPid);
105 }
106 
107 } // namespace android::surfaceflinger
108 
109 // TODO(b/129481165): remove the #pragma below and fix conversion issues
110 #pragma clang diagnostic pop // ignored "-Wconversion"
111