blob: 2ddfaacf44a1df4feaa8b6dd309c1b982b909eaf [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
Sean Paulca699be2016-05-11 16:29:45 -040035class DrmCompositionPlane {
36 public:
37 DrmCompositionPlane() = default;
38 DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
39 DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
Roman Stratiienko67cebf52021-12-17 13:31:27 +020040 DrmCompositionPlane(DrmPlane *plane) : plane_(plane) {
Sean Paulca699be2016-05-11 16:29:45 -040041 }
Roman Stratiienko67cebf52021-12-17 13:31:27 +020042 DrmCompositionPlane(DrmPlane *plane, size_t source_layer)
43 : plane_(plane), source_layers_(1, source_layer) {
Sean Paulca699be2016-05-11 16:29:45 -040044 }
45
46 DrmPlane *plane() const {
47 return plane_;
48 }
49 void set_plane(DrmPlane *plane) {
50 plane_ = plane;
51 }
52
Sean Paulca699be2016-05-11 16:29:45 -040053 std::vector<size_t> &source_layers() {
54 return source_layers_;
55 }
56
57 const std::vector<size_t> &source_layers() const {
58 return source_layers_;
59 }
60
61 private:
Sean Paulca699be2016-05-11 16:29:45 -040062 DrmPlane *plane_ = NULL;
Sean Paulca699be2016-05-11 16:29:45 -040063 std::vector<size_t> source_layers_;
Zach Reizner4a253652015-09-10 18:30:54 -070064};
Sean Paul98e73c82015-06-24 14:38:49 -070065
66class DrmDisplayComposition {
67 public:
Zach Reizner92f8e632015-10-12 17:47:13 -070068 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
Matvii Zorin704ea0e2021-01-08 12:55:45 +020069 DrmDisplayComposition(DrmCrtc *crtc, Planner *planner);
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020070 ~DrmDisplayComposition() = default;
Sean Paul98e73c82015-06-24 14:38:49 -070071
Roman Stratiienko36a7f282021-10-05 18:17:53 +030072 int SetLayers(DrmHwcLayer *layers, size_t num_layers);
Sean Paul4f4ef692016-05-03 16:40:59 -070073 int AddPlaneComposition(DrmCompositionPlane plane);
Sean Paul98e73c82015-06-24 14:38:49 -070074
Rob Herringaf0d9752018-05-04 16:34:19 -050075 int Plan(std::vector<DrmPlane *> *primary_planes,
Zach Reizner92f8e632015-10-12 17:47:13 -070076 std::vector<DrmPlane *> *overlay_planes);
Sean Paulacb2a442015-06-24 18:43:01 -070077
Zach Reizner92f8e632015-10-12 17:47:13 -070078 std::vector<DrmHwcLayer> &layers() {
79 return layers_;
80 }
81
Zach Reizner92f8e632015-10-12 17:47:13 -070082 std::vector<DrmCompositionPlane> &composition_planes() {
83 return composition_planes_;
84 }
85
Zach Reizner92f8e632015-10-12 17:47:13 -070086 DrmCrtc *crtc() const {
87 return crtc_;
88 }
89
Sean Paulaa18d912016-05-12 14:28:05 -040090 Planner *planner() const {
91 return planner_;
92 }
93
Zach Reizner92f8e632015-10-12 17:47:13 -070094 private:
Zach Reizner92f8e632015-10-12 17:47:13 -070095 DrmCrtc *crtc_ = NULL;
Sean Paulaa18d912016-05-12 14:28:05 -040096 Planner *planner_ = NULL;
Sean Paul98e73c82015-06-24 14:38:49 -070097
Zach Reizner92f8e632015-10-12 17:47:13 -070098 std::vector<DrmHwcLayer> layers_;
Zach Reizner92f8e632015-10-12 17:47:13 -070099 std::vector<DrmCompositionPlane> composition_planes_;
Sean Paul98e73c82015-06-24 14:38:49 -0700100};
Sean Paulf72cccd2018-08-27 13:59:08 -0400101} // namespace android
Sean Paul98e73c82015-06-24 14:38:49 -0700102
103#endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_