blob: f0457e3e8a62e498a436813c4f98e6e0a671a9ef [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
20#include "BufferQueueLayer.h"
21#include "BufferStateLayer.h"
22#include "ColorLayer.h"
23#include "ContainerLayer.h"
24#include "DisplayDevice.h"
25#include "Layer.h"
26#include "NativeWindowSurface.h"
27#include "StartPropertySetThread.h"
28#include "SurfaceFlingerDefaultFactory.h"
29#include "SurfaceInterceptor.h"
30
31#include "DisplayHardware/ComposerHal.h"
32#include "Scheduler/DispSync.h"
33#include "Scheduler/EventControlThread.h"
34#include "Scheduler/MessageQueue.h"
35#include "Scheduler/PhaseOffsets.h"
36#include "Scheduler/Scheduler.h"
37
38namespace android::surfaceflinger {
39
40DefaultFactory::~DefaultFactory() = default;
41
42std::unique_ptr<DispSync> DefaultFactory::createDispSync(const char* name, bool hasSyncFramework) {
43 return std::make_unique<android::impl::DispSync>(name, hasSyncFramework);
44}
45
46std::unique_ptr<EventControlThread> DefaultFactory::createEventControlThread(
47 SetVSyncEnabled setVSyncEnabled) {
48 return std::make_unique<android::impl::EventControlThread>(std::move(setVSyncEnabled));
49}
50
51std::unique_ptr<HWComposer> DefaultFactory::createHWComposer(const std::string& serviceName) {
52 return std::make_unique<android::impl::HWComposer>(
53 std::make_unique<Hwc2::impl::Composer>(serviceName));
54}
55
56std::unique_ptr<MessageQueue> DefaultFactory::createMessageQueue() {
57 return std::make_unique<android::impl::MessageQueue>();
58}
59
60std::unique_ptr<scheduler::PhaseOffsets> DefaultFactory::createPhaseOffsets() {
61 return std::make_unique<scheduler::impl::PhaseOffsets>();
62}
63
64std::unique_ptr<Scheduler> DefaultFactory::createScheduler(
65 SetVSyncEnabled setVSyncEnabled, const scheduler::RefreshRateConfigs& configs) {
66 return std::make_unique<Scheduler>(std::move(setVSyncEnabled), configs);
67}
68
69std::unique_ptr<SurfaceInterceptor> DefaultFactory::createSurfaceInterceptor(
70 SurfaceFlinger* flinger) {
71 return std::make_unique<android::impl::SurfaceInterceptor>(flinger);
72}
73
74sp<StartPropertySetThread> DefaultFactory::createStartPropertySetThread(
75 bool timestampPropertyValue) {
76 return new StartPropertySetThread(timestampPropertyValue);
77}
78
79sp<DisplayDevice> DefaultFactory::createDisplayDevice(DisplayDeviceCreationArgs&& creationArgs) {
80 return new DisplayDevice(std::move(creationArgs));
81}
82
83sp<GraphicBuffer> DefaultFactory::createGraphicBuffer(uint32_t width, uint32_t height,
84 PixelFormat format, uint32_t layerCount,
85 uint64_t usage, std::string requestorName) {
86 return new GraphicBuffer(width, height, format, layerCount, usage, requestorName);
87}
88
89void DefaultFactory::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
90 sp<IGraphicBufferConsumer>* outConsumer,
91 bool consumerIsSurfaceFlinger) {
92 BufferQueue::createBufferQueue(outProducer, outConsumer, consumerIsSurfaceFlinger);
93}
94
95std::unique_ptr<surfaceflinger::NativeWindowSurface> DefaultFactory::createNativeWindowSurface(
96 const sp<IGraphicBufferProducer>& producer) {
97 return surfaceflinger::impl::createNativeWindowSurface(producer);
98}
99
100std::unique_ptr<compositionengine::CompositionEngine> DefaultFactory::createCompositionEngine() {
101 return compositionengine::impl::createCompositionEngine();
102}
103
104sp<ContainerLayer> DefaultFactory::createContainerLayer(const LayerCreationArgs& args) {
105 return new ContainerLayer(args);
106}
107
108sp<BufferQueueLayer> DefaultFactory::createBufferQueueLayer(const LayerCreationArgs& args) {
109 return new BufferQueueLayer(args);
110}
111
112sp<BufferStateLayer> DefaultFactory::createBufferStateLayer(const LayerCreationArgs& args) {
113 return new BufferStateLayer(args);
114}
115
116sp<ColorLayer> DefaultFactory::createColorLayer(const LayerCreationArgs& args) {
117 return new ColorLayer(args);
118}
119
120} // namespace android::surfaceflinger