blob: d077aee5669457187b37c4cb25df5a1a686e1963 [file] [log] [blame]
Sean Paul98e73c82015-06-24 14:38:49 -07001/*
2 * Copyright (C) 2015 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#ifndef ANDROID_DRM_DISPLAY_COMPOSITION_H_
18#define ANDROID_DRM_DISPLAY_COMPOSITION_H_
19
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030020#include <hardware/hardware.h>
21#include <hardware/hwcomposer.h>
Sean Paul98e73c82015-06-24 14:38:49 -070022
Zach Reiznerfd6dc332015-10-13 21:12:48 -070023#include <sstream>
Sean Paul98e73c82015-06-24 14:38:49 -070024#include <vector>
25
Roman Stratiienko13cc3662020-08-29 21:35:39 +030026#include "drm/DrmCrtc.h"
27#include "drm/DrmPlane.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030028#include "drmhwcomposer.h"
Sean Paul98e73c82015-06-24 14:38:49 -070029
30namespace android {
31
Sean Paul4c4646e2016-05-10 04:19:24 -040032class Importer;
Sean Paulaa18d912016-05-12 14:28:05 -040033class Planner;
Zach Reizner92f8e632015-10-12 17:47:13 -070034
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020035constexpr size_t kUndefinedSourceLayer = UINT16_MAX;
36
Sean Paulca699be2016-05-11 16:29:45 -040037class DrmCompositionPlane {
38 public:
39 DrmCompositionPlane() = default;
40 DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
41 DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
Roman Stratiienko67cebf52021-12-17 13:31:27 +020042 DrmCompositionPlane(DrmPlane *plane, size_t source_layer)
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020043 : plane_(plane), source_layer_(source_layer) {
Sean Paulca699be2016-05-11 16:29:45 -040044 }
45
46 DrmPlane *plane() const {
47 return plane_;
48 }
Sean Paulca699be2016-05-11 16:29:45 -040049
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020050 size_t source_layer() const {
51 return source_layer_;
Sean Paulca699be2016-05-11 16:29:45 -040052 }
53
54 private:
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020055 DrmPlane *plane_ = nullptr;
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020056 size_t source_layer_ = kUndefinedSourceLayer;
Zach Reizner4a253652015-09-10 18:30:54 -070057};
Sean Paul98e73c82015-06-24 14:38:49 -070058
59class DrmDisplayComposition {
60 public:
Zach Reizner92f8e632015-10-12 17:47:13 -070061 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
Matvii Zorin704ea0e2021-01-08 12:55:45 +020062 DrmDisplayComposition(DrmCrtc *crtc, Planner *planner);
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020063 ~DrmDisplayComposition() = default;
Sean Paul98e73c82015-06-24 14:38:49 -070064
Roman Stratiienko36a7f282021-10-05 18:17:53 +030065 int SetLayers(DrmHwcLayer *layers, size_t num_layers);
Sean Paul4f4ef692016-05-03 16:40:59 -070066 int AddPlaneComposition(DrmCompositionPlane plane);
Sean Paul98e73c82015-06-24 14:38:49 -070067
Rob Herringaf0d9752018-05-04 16:34:19 -050068 int Plan(std::vector<DrmPlane *> *primary_planes,
Zach Reizner92f8e632015-10-12 17:47:13 -070069 std::vector<DrmPlane *> *overlay_planes);
Sean Paulacb2a442015-06-24 18:43:01 -070070
Zach Reizner92f8e632015-10-12 17:47:13 -070071 std::vector<DrmHwcLayer> &layers() {
72 return layers_;
73 }
74
Zach Reizner92f8e632015-10-12 17:47:13 -070075 std::vector<DrmCompositionPlane> &composition_planes() {
76 return composition_planes_;
77 }
78
Zach Reizner92f8e632015-10-12 17:47:13 -070079 DrmCrtc *crtc() const {
80 return crtc_;
81 }
82
Sean Paulaa18d912016-05-12 14:28:05 -040083 Planner *planner() const {
84 return planner_;
85 }
86
Zach Reizner92f8e632015-10-12 17:47:13 -070087 private:
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020088 DrmCrtc *crtc_ = nullptr;
89 Planner *planner_ = nullptr;
Sean Paul98e73c82015-06-24 14:38:49 -070090
Zach Reizner92f8e632015-10-12 17:47:13 -070091 std::vector<DrmHwcLayer> layers_;
Zach Reizner92f8e632015-10-12 17:47:13 -070092 std::vector<DrmCompositionPlane> composition_planes_;
Sean Paul98e73c82015-06-24 14:38:49 -070093};
Sean Paulf72cccd2018-08-27 13:59:08 -040094} // namespace android
Sean Paul98e73c82015-06-24 14:38:49 -070095
96#endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_