blob: bd4cdbad453a235c45241c72717637a111d6787e [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
17#include <compositionengine/impl/CompositionEngine.h>
18#include <ui/GraphicBuffer.h>
19
Lloyd Piquee300b312019-10-03 13:03:45 -070020#include "BufferLayerConsumer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070021#include "BufferQueueLayer.h"
22#include "BufferStateLayer.h"
23#include "ColorLayer.h"
24#include "ContainerLayer.h"
25#include "DisplayDevice.h"
26#include "Layer.h"
Lloyd Piquee300b312019-10-03 13:03:45 -070027#include "MonitoredProducer.h"
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070028#include "NativeWindowSurface.h"
29#include "StartPropertySetThread.h"
30#include "SurfaceFlingerDefaultFactory.h"
31#include "SurfaceInterceptor.h"
32
33#include "DisplayHardware/ComposerHal.h"
34#include "Scheduler/DispSync.h"
35#include "Scheduler/EventControlThread.h"
36#include "Scheduler/MessageQueue.h"
37#include "Scheduler/PhaseOffsets.h"
38#include "Scheduler/Scheduler.h"
39
40namespace android::surfaceflinger {
41
42DefaultFactory::~DefaultFactory() = default;
43
44std::unique_ptr<DispSync> DefaultFactory::createDispSync(const char* name, bool hasSyncFramework) {
45 return std::make_unique<android::impl::DispSync>(name, hasSyncFramework);
46}
47
48std::unique_ptr<EventControlThread> DefaultFactory::createEventControlThread(
49 SetVSyncEnabled setVSyncEnabled) {
50 return std::make_unique<android::impl::EventControlThread>(std::move(setVSyncEnabled));
51}
52
53std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
54 return std::make_unique<android::impl::HWComposer>(
55 std::make_unique<Hwc2::impl::Composer>(serviceName));
56}
57
58std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() {
59 return std::make_unique<android::impl::MessageQueue>();
60}
61
62std::unique_ptr<scheduler::PhaseOffsets> DefaultFactory::createPhaseOffsets() {
63 return std::make_unique<scheduler::impl::PhaseOffsets>();
64}
65
66std::unique_ptr<Scheduler> DefaultFactory::createScheduler(
Ady Abraham3a77a7b2019-12-02 18:46:59 -080067 SetVSyncEnabled setVSyncEnabled, const scheduler::RefreshRateConfigs& configs,
68 ISchedulerCallback& schedulerCallback) {
69 return std::make_unique<Scheduler>(std::move(setVSyncEnabled), configs, schedulerCallback);
Lloyd Pique24f3bfe2019-10-02 19:29:10 -070070}
71
72std::unique_ptr<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor(
73 SurfaceFlinger* flinger) {
74 return std::make_unique<android::impl::SurfaceInterceptor>(flinger);
75}
76
77sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
78 bool timestampPropertyValue) {
79 return new StartPropertySetThread(timestampPropertyValue);
80}
81
82sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs&& creationArgs) {
83 return new DisplayDevice(std::move(creationArgs));
84}
85
86sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
87 PixelFormat format, uint32_t layerCount,
88 uint64_t usage, std::string requestorName) {
89 return new GraphicBuffer(width, height, format, layerCount, usage, requestorName);
90}
91
92void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
93 sp<IGraphicBufferConsumer>* outConsumer,
94 bool consumerIsSurfaceFlinger) {
95 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
96}
97
Lloyd Piquee300b312019-10-03 13:03:45 -070098sp<IGraphicBufferProducer> DefaultFactory::createMonitoredProducer(
99 const sp<IGraphicBufferProducer>& producer, const sp<SurfaceFlinger>& flinger,
100 const wp<Layer>& layer) {
101 return new MonitoredProducer(producer, flinger, layer);
102}
103
104sp<BufferLayerConsumer> DefaultFactory::createBufferLayerConsumer(
105 const sp<IGraphicBufferConsumer>& consumer, renderengine::RenderEngine& renderEngine,
106 uint32_t textureName, Layer* layer) {
107 return new BufferLayerConsumer(consumer, renderEngine, textureName, layer);
108}
109
Lloyd Pique24f3bfe2019-10-02 19:29:10 -0700110std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
111 const sp<IGraphicBufferProducer>& producer) {
112 return surfaceflinger::impl::createNativeWindowSurface(producer);
113}
114
115std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
116 return compositionengine::impl::createCompositionEngine();
117}
118
119sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) {
120 return new ContainerLayer(args);
121}
122
123sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) {
124 return new BufferQueueLayer(args);
125}
126
127sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
128 return new BufferStateLayer(args);
129}
130
131sp<ColorLayer> DefaultFactory::createColorLayer(const LayerCreationArgs& args) {
132 return new ColorLayer(args);
133}
134
135} // namespace android::surfaceflinger