blob: dcfd96e1cea83a5b2e4ec3a3a159c533be40e4fe [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;
Zach Reizner92f8e632015-10-12 17:47:13 -070033
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020034constexpr size_t kUndefinedSourceLayer = UINT16_MAX;
35
Sean Paulca699be2016-05-11 16:29:45 -040036class DrmCompositionPlane {
37 public:
38 DrmCompositionPlane() = default;
39 DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
40 DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
Roman Stratiienko67cebf52021-12-17 13:31:27 +020041 DrmCompositionPlane(DrmPlane *plane, size_t source_layer)
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020042 : plane_(plane), source_layer_(source_layer) {
Sean Paulca699be2016-05-11 16:29:45 -040043 }
44
45 DrmPlane *plane() const {
46 return plane_;
47 }
Sean Paulca699be2016-05-11 16:29:45 -040048
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020049 size_t source_layer() const {
50 return source_layer_;
Sean Paulca699be2016-05-11 16:29:45 -040051 }
52
53 private:
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020054 DrmPlane *plane_ = nullptr;
Roman Stratiienko5d1f5572021-12-17 15:09:28 +020055 size_t source_layer_ = kUndefinedSourceLayer;
Zach Reizner4a253652015-09-10 18:30:54 -070056};
Sean Paul98e73c82015-06-24 14:38:49 -070057
58class DrmDisplayComposition {
59 public:
Zach Reizner92f8e632015-10-12 17:47:13 -070060 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
Roman Stratiienko753d1072021-12-30 18:05:27 +020061 explicit DrmDisplayComposition(DrmCrtc *crtc);
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020062 ~DrmDisplayComposition() = default;
Sean Paul98e73c82015-06-24 14:38:49 -070063
Roman Stratiienko36a7f282021-10-05 18:17:53 +030064 int SetLayers(DrmHwcLayer *layers, size_t num_layers);
Sean Paul4f4ef692016-05-03 16:40:59 -070065 int AddPlaneComposition(DrmCompositionPlane plane);
Sean Paul98e73c82015-06-24 14:38:49 -070066
Rob Herringaf0d9752018-05-04 16:34:19 -050067 int Plan(std::vector<DrmPlane *> *primary_planes,
Zach Reizner92f8e632015-10-12 17:47:13 -070068 std::vector<DrmPlane *> *overlay_planes);
Sean Paulacb2a442015-06-24 18:43:01 -070069
Zach Reizner92f8e632015-10-12 17:47:13 -070070 std::vector<DrmHwcLayer> &layers() {
71 return layers_;
72 }
73
Zach Reizner92f8e632015-10-12 17:47:13 -070074 std::vector<DrmCompositionPlane> &composition_planes() {
75 return composition_planes_;
76 }
77
Zach Reizner92f8e632015-10-12 17:47:13 -070078 DrmCrtc *crtc() const {
79 return crtc_;
80 }
81
Zach Reizner92f8e632015-10-12 17:47:13 -070082 private:
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020083 DrmCrtc *crtc_ = nullptr;
Sean Paul98e73c82015-06-24 14:38:49 -070084
Zach Reizner92f8e632015-10-12 17:47:13 -070085 std::vector<DrmHwcLayer> layers_;
Zach Reizner92f8e632015-10-12 17:47:13 -070086 std::vector<DrmCompositionPlane> composition_planes_;
Sean Paul98e73c82015-06-24 14:38:49 -070087};
Sean Paulf72cccd2018-08-27 13:59:08 -040088} // namespace android
Sean Paul98e73c82015-06-24 14:38:49 -070089
90#endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_