OSDN Git Service

drm_hwcomposer: Modify source_layers_ to be integer instead of array
[android-x86/external-drm_hwcomposer.git] / compositor / DrmDisplayComposition.h
1 /*
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
20 #include <hardware/hardware.h>
21 #include <hardware/hwcomposer.h>
22
23 #include <sstream>
24 #include <vector>
25
26 #include "drm/DrmCrtc.h"
27 #include "drm/DrmPlane.h"
28 #include "drmhwcomposer.h"
29
30 namespace android {
31
32 class Importer;
33 class Planner;
34
35 constexpr size_t kUndefinedSourceLayer = UINT16_MAX;
36
37 class DrmCompositionPlane {
38  public:
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) {
44   }
45
46   DrmPlane *plane() const {
47     return plane_;
48   }
49
50   size_t source_layer() const {
51     return source_layer_;
52   }
53
54  private:
55   DrmPlane *plane_ = NULL;
56   size_t source_layer_ = kUndefinedSourceLayer;
57 };
58
59 class DrmDisplayComposition {
60  public:
61   DrmDisplayComposition(const DrmDisplayComposition &) = delete;
62   DrmDisplayComposition(DrmCrtc *crtc, Planner *planner);
63   ~DrmDisplayComposition() = default;
64
65   int SetLayers(DrmHwcLayer *layers, size_t num_layers);
66   int AddPlaneComposition(DrmCompositionPlane plane);
67
68   int Plan(std::vector<DrmPlane *> *primary_planes,
69            std::vector<DrmPlane *> *overlay_planes);
70
71   std::vector<DrmHwcLayer> &layers() {
72     return layers_;
73   }
74
75   std::vector<DrmCompositionPlane> &composition_planes() {
76     return composition_planes_;
77   }
78
79   DrmCrtc *crtc() const {
80     return crtc_;
81   }
82
83   Planner *planner() const {
84     return planner_;
85   }
86
87  private:
88   DrmCrtc *crtc_ = NULL;
89   Planner *planner_ = NULL;
90
91   std::vector<DrmHwcLayer> layers_;
92   std::vector<DrmCompositionPlane> composition_planes_;
93 };
94 }  // namespace android
95
96 #endif  // ANDROID_DRM_DISPLAY_COMPOSITION_H_