• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 #pragma once
18 
19 #include <cinttypes>
20 #include <functional>
21 #include <memory>
22 #include <string>
23 
24 #include <cutils/compiler.h>
25 #include <utils/StrongPointer.h>
26 
27 #include <scheduler/Fps.h>
28 
29 namespace android {
30 
31 typedef int32_t PixelFormat;
32 
33 class BufferLayerConsumer;
34 class DisplayDevice;
35 class FrameTracer;
36 class GraphicBuffer;
37 class HWComposer;
38 class IGraphicBufferConsumer;
39 class IGraphicBufferProducer;
40 class Layer;
41 class LayerFE;
42 class StartPropertySetThread;
43 class SurfaceFlinger;
44 class TimeStats;
45 
46 struct DisplayDeviceCreationArgs;
47 
48 namespace compositionengine {
49 class CompositionEngine;
50 } // namespace compositionengine
51 
52 namespace scheduler {
53 class VsyncConfiguration;
54 class VsyncController;
55 } // namespace scheduler
56 
57 namespace frametimeline {
58 class FrameTimeline;
59 } // namespace frametimeline
60 
61 namespace surfaceflinger {
62 
63 struct LayerCreationArgs;
64 class NativeWindowSurface;
65 
66 // The interface that SurfaceFlinger uses to create all of the implementations
67 // of each interface.
68 class Factory {
69 public:
70     virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
71     virtual std::unique_ptr<scheduler::VsyncConfiguration> createVsyncConfiguration(
72             Fps currentRefreshRate) = 0;
73 
74     virtual sp<StartPropertySetThread> createStartPropertySetThread(
75             bool timestampPropertyValue) = 0;
76     virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&) = 0;
77     virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
78                                                   PixelFormat format, uint32_t layerCount,
79                                                   uint64_t usage, std::string requestorName) = 0;
80     virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
81                                    sp<IGraphicBufferConsumer>* outConsumer,
82                                    bool consumerIsSurfaceFlinger) = 0;
83 
84     virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
85             const sp<IGraphicBufferProducer>&) = 0;
86 
87     virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
88 
89     virtual sp<Layer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
90     virtual sp<Layer> createEffectLayer(const LayerCreationArgs& args) = 0;
91     virtual sp<LayerFE> createLayerFE(const std::string& layerName) = 0;
92     virtual std::unique_ptr<FrameTracer> createFrameTracer() = 0;
93     virtual std::unique_ptr<frametimeline::FrameTimeline> createFrameTimeline(
94             std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid) = 0;
95 
96 protected:
97     ~Factory() = default;
98 };
99 
100 ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
101 
102 } // namespace surfaceflinger
103 } // namespace android
104