2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_DRM_DISPLAY_COMPOSITION_H_
18 #define ANDROID_DRM_DISPLAY_COMPOSITION_H_
20 #include <hardware/hardware.h>
21 #include <hardware/hwcomposer.h>
26 #include "drm/DrmCrtc.h"
27 #include "drm/DrmPlane.h"
28 #include "drmhwcomposer.h"
35 constexpr size_t kUndefinedSourceLayer = UINT16_MAX;
37 class DrmCompositionPlane {
39 DrmCompositionPlane() = default;
40 DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
41 DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
42 DrmCompositionPlane(DrmPlane *plane, size_t source_layer)
43 : plane_(plane), source_layer_(source_layer) {
46 DrmPlane *plane() const {
50 size_t source_layer() const {
55 DrmPlane *plane_ = NULL;
56 size_t source_layer_ = kUndefinedSourceLayer;
59 class DrmDisplayComposition {
61 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
62 DrmDisplayComposition(DrmCrtc *crtc, Planner *planner);
63 ~DrmDisplayComposition() = default;
65 int SetLayers(DrmHwcLayer *layers, size_t num_layers);
66 int AddPlaneComposition(DrmCompositionPlane plane);
68 int Plan(std::vector<DrmPlane *> *primary_planes,
69 std::vector<DrmPlane *> *overlay_planes);
71 std::vector<DrmHwcLayer> &layers() {
75 std::vector<DrmCompositionPlane> &composition_planes() {
76 return composition_planes_;
79 DrmCrtc *crtc() const {
83 Planner *planner() const {
88 DrmCrtc *crtc_ = NULL;
89 Planner *planner_ = NULL;
91 std::vector<DrmHwcLayer> layers_;
92 std::vector<DrmCompositionPlane> composition_planes_;
94 } // namespace android
96 #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_